UniPolar Stepper Motor Controller Optimized
Описание
Stepper program for the 28YBJ-48 (stepper MTR) and degrees step
/64
Speed is controlled by a delay between each step.
The longer the delay the slower the rotation.
That delay value is obtained by reading and analog-to-digital
cover (A0 in this case/10K trimmer POT) which gives a value from
0 to 1023.
The value is divided by 4 and add 10 for a delay
in milliseconds:delay(analogRead(0)/4 +10)
For faster speeds change 10 to say 2.
This is calculated between every step to vary speed while stepping.
I incorporated unsigned long int Val, in order read a little bit more of the AN/Map
A nice feature of unsigned int's: if a val is unsigned, then val / 4 is optimized by the compiler into a bit shift, much more efficient than the actual division you would get if val was signed.
Highlights of this code:
1) NO debouncing program
2) NO external Stepper lib
3) NO PWM
4) unsigned long int val = (analogRead('...') / 4 + 2); if a val is unsigned, then val / 4 is optimized by the compiler into a bit shift, much more efficient than the actual division you get if val was signed.
5) Push button control incorporates 2 functions per switch;
1: momentary push & release = Start/Stop
2: press & hold = Continuous operation
Complete code can be found here; http://playground.arduino.cc/Main/StepperMotorControl
Schematics an full projet details and files will be available at: http://hackaday.io/project/18126-dav5-v301-raman-spectrometer