This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
pic_controlled_stepper_motor [2009/02/28 06:23] jonmash |
pic_controlled_stepper_motor [2009/03/08 18:22] (current) jonmash |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== PIC Controlled Stepper motor ====== | ====== PIC Controlled Stepper motor ====== | ||
- | Code to send desired position to the motor controller: | + | * [[Code to send desired position to the motor controller]] |
- | <code cpp> | + | |
- | void setup() | + | |
- | { | + | |
- | pinMode(3, OUTPUT); // sets the digital pin as output | + | |
- | } | + | |
- | void loop() | ||
- | { | ||
- | pulseMicroseconds(3, 1500); //1.5 mS | ||
- | delay(100); | ||
- | } | ||
- | |||
- | /* pulseMicroseconds(int, int); | ||
- | * | ||
- | * 1.0 mS = 1000 uS --> 0 degrees | ||
- | * 1.5 mS = 1500 uS --> 90 degrees | ||
- | * 2.0 mS = 2000 uS --> 180 degrees | ||
- | * | ||
- | * For some, unknown, reason the Servo library did not produce a pulse | ||
- | * that was compatible with the motor controller. This work-around was | ||
- | * required to produce the desired results. | ||
- | */ | ||
- | void pulseMicroseconds(int pin, int dur) | ||
- | { | ||
- | digitalWrite(pin, HIGH); | ||
- | delayMicroseconds(dur); | ||
- | digitalWrite(pin, LOW); | ||
- | } | ||
- | </code> |