{"id":16048314,"url":"https://github.com/luxedo/rpistepper","last_synced_at":"2025-03-18T04:30:58.744Z","repository":{"id":57462860,"uuid":"46951535","full_name":"luxedo/RPistepper","owner":"luxedo","description":"Library to control stepper motors with a RPI","archived":false,"fork":false,"pushed_at":"2018-12-19T13:27:27.000Z","size":186,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T17:04:17.578Z","etag":null,"topics":["gpio","motor","python","python-library","raspberry-pi","rpi","stepper-motor","uln2803a"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luxedo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-27T00:09:11.000Z","updated_at":"2024-02-29T19:40:34.000Z","dependencies_parsed_at":"2022-09-05T17:22:15.729Z","dependency_job_id":null,"html_url":"https://github.com/luxedo/RPistepper","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxedo%2FRPistepper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxedo%2FRPistepper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxedo%2FRPistepper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxedo%2FRPistepper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luxedo","download_url":"https://codeload.github.com/luxedo/RPistepper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244156547,"owners_count":20407526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpio","motor","python","python-library","raspberry-pi","rpi","stepper-motor","uln2803a"],"created_at":"2024-10-09T00:06:23.249Z","updated_at":"2025-03-18T04:30:58.435Z","avatar_url":"https://github.com/luxedo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RPistepper\n\nRPistepper is a library containing:\n* A class to control a stepper motor with a RPi.\n* A function to execute a zig-zag motion with two motors.\n* A function to execute a square_spiral motion with two motors.\n\n## Wiring\nIn our setup, the power to the motors (Vm) is supplied with the 5V pins of the RPi, the grounding of the coils is controlled with a [ULN2803A](http://www.ti.com/lit/ds/symlink/uln2803a.pdf) transistor array.\n\n![Alt text](pinout.png \"Example setup\")\n\n#### Conections RPi - ULN2803A:\n\n| RPi Pin (BCM)| ULN2803A|\n|--------------|---------|\n|      17      |    1B   |\n|      27      |    2B   |\n|      10      |    3B   |\n|      9       |    4B   |\n|      14      |    5B   |\n|      15      |    6B   |\n|      23      |    7B   |\n|      24      |    8B   |\n\n#### Conections ULN2803A - Motors:\n\n| ULN2803A| Motors          |\n|---------|-----------------|\n|    1C   | Motor_1 Coil_A1 |\n|    2C   | Motor_1 Coil_A2 |\n|    3C   | Motor_1 Coil_B1 |\n|    4C   | Motor_1 Coil_B2 |\n|    5C   | Motor_2 Coil_A1 |\n|    6C   | Motor_2 Coil_A2 |\n|    7C   | Motor_2 Coil_B1 |\n|    8C   | Motor_2 Coil_B2 |\n\nIn this case, two motors were attached to the ULN2803A.\n\n\n## Usage\n### class Motor\nThis class allows the user to control a 6 pin stepper motor using 4 GPIO pins of a RPi.\n\nSoftware uses BCM mode for pin indexing.\n\nThis class is best used with the 'with' statement to properly handle the cleanup of the GPIOs.\n\nself.steps is a property of this class that will get the number of steps taken from the initial position or set to a specific step, similar to self.move.\n\nIn order to save power, it's advised to call self.release() when the motor is idle.\n\nArguments are a list with the 4 pins (Coil_A1, Coil_A2, Coil_B1, Coil_B2), the delay between steps (default = 20ms) and verbose to display reports on the motor movements, the last two are optional.\ne.g:\n```python\nimport RPistepper as stp\nM1_pins = [17, 27, 10, 9]\nwith stp.Motor(M1_pins) as M1:\n    for i in range(10):               # moves 20 steps,release and wait\n        print M1\n        M1.move(20)\n        M1.release()\n        raw_input('enter to execute next step')\n```\nIf the class is instantiated normally, use the method `cleanup` prior to closing the application to close the GPIO resources.\nAlso, if it's important to go back to the initial position when finishing the routine, use the method `reset`.\n\n```python\nimport RPistepper as stp\nM1_pins = [17, 27, 10, 9]\nM1 = stp.Motor(M1_pins)\nfor i in range(10):               # moves 20 steps,release and wait\n    print M1\n    M1.move(20)\n    M1.release()\n    raw_input('enter to execute next step')\nM1.reset()\nM1.cleanup()\n```\n\n\n#### Methods\nCurrently there are five implemented methods:\n```python\ndef move(self, steps):\n    '''\n    Moves the motor 'steps' steps. Negative steps moves the motor backwards\n    '''\n```\n```python\ndef release(self):\n    '''\n    Sets all pins low. Power saving mode\n    '''\n```\n```python\ndef reset(self):\n    '''\n    Returns the motor to it's initial position\n    '''\n```\n```python\ndef zero(self):\n    '''\n    Sets the motor to the next position which Coil_A1 and Coil_A2\n    are on. Sets this position as the reference (steps = 0).\n    '''\n```\n```python\ndef cleanup(self):\n    '''\n    Cleans the GPIO resources\n    '''\n```\nThe main method is `move`, which moves the motor the desired number of steps\n\n#### steps property\nIt's possible to check the motor position or manually set the desired step using the `steps` property:\n```python\nimport RPistepper as stp\nM1_pins = [17, 27, 10, 9]\nwith stp.Motor(M1_pins) as M1:\n    for i in range(10):               # moves 20 steps,release and wait\n        print M1.steps\n        M1.steps = 20*i\n        M1.release()\n        raw_input('enter to execute next step')\n    M1.reset()\n```\n#### Attributes\nThis class haves the following attributes:\n\n| Attribute    |  Data   |\n|--------------|---------|\n| DELAY        | Time between steps           |\n| VERBOSE      | Display motor data on screen |\n| PINS         | GPIOs used by the instance   |\n| actual_state | A list with the status of the coils (on/off) |\n\n### functions\nThese two functions executes pre determined movements and requires two stepper motor objects:\n```python\ndef zig_zag(motor1, motor2, amp1, amp2, delay=None):\n    '''\n    Executes a zig-zag movement with two RPistepper objects.\n    Arguments are: motor1 and motor2 objects and amp1, amp2, the amplitude\n    of movement, a tuple (step, rep) representing the number of steps per\n    iteration and the number of iterations of the following algorithm:\n        Repeat rep1 times:\n            1. Moves motor 2 step2*rep2 steps forward\n            2. Moves motor 1 step1 steps forward\n            3. Moves motor 2 step2*rep2 steps backwards\n            4. Moves motor 1 step1 steps forward\n        Reset to initial state\n        Release the motors\n    It's possible to change the delay between steps with the 'delay' argument\n    '''\n```\n```python\ndef square_spiral(motor1, motor2, amplitude, delay=None):\n    '''\n    Executes a square spiral movement with two RPistepper objects.\n    Arguments are: motor1 and motor2 objects and the amplitude of movement,\n    a tuple (step, rep) representing the number of steps per iteration and\n    the number of iterations of the following algorithm:\n        for i in range(rep):\n            1. Moves motor 2 to position i\n            2. Moves motor 1 to position i\n            3. Moves motor 1 to position -i\n            4. Moves motor 2 to position -i\n        Reset to initial state\n        Release the motors\n    It's possible to change the delay between steps with the 'delay' argument\n    '''\n```\n\n## /bin/rpistepper\n`rpistepper` is a shell for controlling the motors. It provides all the methods in the `Motor` class. All the commands are documented in the shell.\nIt's possible to pipe a list of commands to the shell:\n```bash\nrpistepper \u003c sample.stp\n        or\ncat sample.stp | rpistepper\n```\nInvoking `rpistepper` with `-g` flag will open a GUI application with similar functionality\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxedo%2Frpistepper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluxedo%2Frpistepper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxedo%2Frpistepper/lists"}