This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
projects:a4sim:servos:x27168 [2019/08/21 01:00] dwheele created |
projects:a4sim:servos:x27168 [2020/02/22 17:07] (current) admin ↷ Links adapted because of a move operation |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| These specs are from [[https:// | These specs are from [[https:// | ||
| + | |||
| + | Adafruit info: | ||
| + | |||
| + | //This stepper motor is a little different than the large NEMA-17 types you may be used to. These are often used in gauges for motorcycles and cars to replace the old-style fully-analog type. They have extremely fine step precision of about 1/2 a degree per step, 600 steps for single stepping, fast response for quick movements, and a range of ~315° degrees. Their smooth motion makes good for small projects that need a dial indicator, and more precision motion than you may get with a needle gauge.// | ||
| + | |||
| + | //Since this is a bi-polar stepper motor you do need to have some sort of H-Bridge to drive it. A L293D or TB6612 will do the job nicely. If you have a microcontroller that can drive 200 ohm loads you might be able to use the direct pins without extra MOSFETs, just remember to include kickback/ | ||
| + | |||
| + | //Note that the motor is quite ' | ||
| ==== Specs ==== | ==== Specs ==== | ||
| Line 24: | Line 32: | ||
| Motor Thickness (w/o pins): 9mm / 0.35" | Motor Thickness (w/o pins): 9mm / 0.35" | ||
| + | {{ a4sim: | ||
| + | |||
| + | ==== Working example ==== | ||
| + | |||
| + | <code c> | ||
| + | /* | ||
| + | | ||
| + | |||
| + | This program drives a unipolar or bipolar stepper motor. | ||
| + | The motor is attached to digital pins 8 - 11 of the Arduino. | ||
| + | |||
| + | The motor will step one step at a time, very slowly. | ||
| + | test that you've got the four wires of your stepper wired to the correct | ||
| + | pins. If wired correctly, all steps should be in the same direction. | ||
| + | |||
| + | Use this also to count the number of steps per revolution of your motor, | ||
| + | if you don't know it. Then plug that number into the oneRevolution | ||
| + | | ||
| + | |||
| + | | ||
| + | by Tom Igoe | ||
| + | |||
| + | */ | ||
| + | |||
| + | #include < | ||
| + | |||
| + | const int stepsPerRevolution = 600; // change this to fit the number of steps per revolution | ||
| + | // for your motor | ||
| + | |||
| + | // initialize the stepper library on pins 8 through 11: | ||
| + | Stepper myStepper(stepsPerRevolution, | ||
| + | |||
| + | int stepPosition = 0; // number of steps the motor has taken | ||
| + | int stepPoints[] = {100, 300, 200, 250, 50}; | ||
| + | int sPtr = 0; | ||
| + | |||
| + | void setup() { | ||
| + | // initialize the serial port: | ||
| + | // Serial.begin(19200); | ||
| + | // myStepper.step(-600); | ||
| + | |||
| + | // Deleted Serial writing, it might be interfering. | ||
| + | // setSpeed of 10 seems to work. Trying 30. | ||
| + | // 8/21/2019 | ||
| + | myStepper.setSpeed(60); | ||
| + | stepPosition = 0; | ||
| + | | ||
| + | int i; | ||
| + | for (i = 0;i < 600;i += 10) { | ||
| + | myStepper.step(-10); | ||
| + | delay(40); | ||
| + | } | ||
| + | delay(500); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | int newLoc = stepPoints[sPtr]; | ||
| + | sPtr++; | ||
| + | if (sPtr >= 5) { | ||
| + | sPtr = 0; | ||
| + | } | ||
| + | int stepAmount = newLoc - stepPosition; | ||
| + | myStepper.step(stepAmount); | ||
| + | stepPosition = newLoc; | ||
| + | delay(10); | ||
| + | } | ||
| + | </ | ||