This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
oak:tutorials:stepper_motor [2017/01/14 16:37] Rover#18 updated max speed to 1000 steps/sec |
oak:tutorials:stepper_motor [2017/01/14 16:52] (current) Rover#18 minor edits in the remote commanding description |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| {{ :oak:tutorials:oak_stepper_motor_setup.jpg?direct&500 | Oak commanding stepper motor via A4988 driver. A 6-wire 2-phase unipolar stepper motor is shown here, with its coil center tap leads (white/yellow) unconnected. The A4988 driver (red) is upside-down in this photo, showing the backside of the board, which is opposite of the view shown in the Fritzing diagram. The motor is powered from a common 12V DC wall wart transformer, with a 68uF cap connected at the jack. }} | {{ :oak:tutorials:oak_stepper_motor_setup.jpg?direct&500 | Oak commanding stepper motor via A4988 driver. A 6-wire 2-phase unipolar stepper motor is shown here, with its coil center tap leads (white/yellow) unconnected. The A4988 driver (red) is upside-down in this photo, showing the backside of the board, which is opposite of the view shown in the Fritzing diagram. The motor is powered from a common 12V DC wall wart transformer, with a 68uF cap connected at the jack. }} | ||
| - | This lesson teaches you how to: | + | **This lesson teaches you how to:** |
| * Control a stepper motor using an [[https://www.pololu.com/file/download/A4988.pdf?file_id=0J450|A4988]] stepper motor driver, | * Control a stepper motor using an [[https://www.pololu.com/file/download/A4988.pdf?file_id=0J450|A4988]] stepper motor driver, | ||
| * Expose functions and variables to the Particle Cloud, for remote commanding via either [[http://digistu.mp/oakterm|OakTerm]], the Particle mobile app, or a [[https://digistump.com/wiki/oak/tutorials/stepper_motor?do=edit#stepper_controller_web_interface|custom web interface]]. | * Expose functions and variables to the Particle Cloud, for remote commanding via either [[http://digistu.mp/oakterm|OakTerm]], the Particle mobile app, or a [[https://digistump.com/wiki/oak/tutorials/stepper_motor?do=edit#stepper_controller_web_interface|custom web interface]]. | ||
| Line 301: | Line 301: | ||
| * **motion(start)** starts motion, if you previously configured speed and direction. | * **motion(start)** starts motion, if you previously configured speed and direction. | ||
| * **motion(stop)** stops motion. | * **motion(stop)** stops motion. | ||
| - | * **setspeed(**[stepsPerSecond]**)** sets the motor speed in steps per second. | + | * **setspeed**(stepsPerSecond) sets the motor speed in steps per second. |
| - | * Accepts floating point values between -1000 and 1000. | + | * Accepts floating point values between -1000 and 1000. |
| * Example: speed of 0.5 steps/sec will step once per 2 seconds. | * Example: speed of 0.5 steps/sec will step once per 2 seconds. | ||
| - | * Negative values set direction negative. | + | * Negative values set direction negative. |
| - | * You can command a different speed while the motor is running. | + | * You can command a different speed while the motor is running. |
| - | * setdir(-1 or 1) sets motor direction. | + | * **setdir**(-1 or 1) sets motor direction. |
| - | * Whether 1 corresponds to CW or CCW depends on which coil you hooked up to A and B. | + | * Whether 1 corresponds to CW or CCW depends on which coil you hooked up to A and B. |
| - | * You can command a different direction while the motor is running. | + | * You can command a different direction while the motor is running. |
| Line 383: | Line 383: | ||
| As noted in the stepper motor overview above, stepper motors can only reach a finite set of positions. A stepper motor with 200 steps/rev, for example, can only position within 0.9° from an arbitrary target position, when operated in full-step mode. If you require better accuracy, consider researching and experimenting with [[https://en.wikipedia.org/wiki/Stepper_motor#Microstepping|micro-stepping]]. The A4988 facilitates micro-stepping to 1/16th-step resolution, and enabling this function is quite simple. If you want to use 1/4, 1/8, or 1/16th step sizes exclusively, then you can configure the A4988 for this with 1, 2, or 3 additional jumpers or resistors, respecively. If you want to toggle between step sizes, then connect 3 Oak GPIO pins to the A4988 MS1, MS2, and MS3 pins and update the sketch to manage these pins. | As noted in the stepper motor overview above, stepper motors can only reach a finite set of positions. A stepper motor with 200 steps/rev, for example, can only position within 0.9° from an arbitrary target position, when operated in full-step mode. If you require better accuracy, consider researching and experimenting with [[https://en.wikipedia.org/wiki/Stepper_motor#Microstepping|micro-stepping]]. The A4988 facilitates micro-stepping to 1/16th-step resolution, and enabling this function is quite simple. If you want to use 1/4, 1/8, or 1/16th step sizes exclusively, then you can configure the A4988 for this with 1, 2, or 3 additional jumpers or resistors, respecively. If you want to toggle between step sizes, then connect 3 Oak GPIO pins to the A4988 MS1, MS2, and MS3 pins and update the sketch to manage these pins. | ||
| - | + | Hope you found this useful! | |