| ??? 08/03/99 18:05 Read: times |
#603 - RE: Stepper-Motor Routine |
The way to control a stepper varies, depending on the stepper type that you have. But in general steppers are controlled by sequentially energizing the windings in the mtr.
Let's say you had a stepper with 3 windings, each independent, each attached to a positive supply at one end, and a transistor which the 8052 will be turning on and off at the other end. To control this mtr you would energize the xistors in sequence. Presuming that the transistors were connected to bits 0, 1 & 2, do the following. · Establish a const for the max number of steps in a full sequence. · Establish an array with the number representing the bit status for each step of the sequence, (eg, 1, 2, 4). · Then when you want to advance the mtr 1 step, move to the next element in the array, and write that element's value to the port. · Include code that tests to see if you are at the last element in 1 direction, or the 1st element when running the mtr in the other direction. const maxSteps = 2; int mtr[]={1,2,4}; // 001, 010, 100. int i; if(dir==1){ if(i==maxSteps)i=-1; outp(mtr[++i]; } else{ if(i==0)i=maxSteps+1; outp(mtr[--i]; } (I don't know the statement to output a value to one of the ports. You'll have to supply that knowledge yourself. Sorry...) |
| Topic | Author | Date |
| Stepper-Motor Routine | 01/01/70 00:00 | |
| RE: Stepper-Motor Routine | 01/01/70 00:00 | |
| RE: Stepper-Motor Routine | 01/01/70 00:00 | |
RE: Stepper-Motor Routine | 01/01/70 00:00 |



