Thursday 3 January 2013

Programming Half Step Sequence

►Programming Half step Sequence

►C Programming
Just the main routine changes rest everything remains same, i mean same delay routine.


CODE:
void main(){
        while(1){
                stepper = 0x08;
                delay();
                stepper = 0x0C;
                delay();
                stepper = 0x04;
                delay();
                stepper = 0x06;
                delay();
                stepper = 0x02;
                delay();
                stepper = 0x03;
                delay();
                stepper = 0x01;
                delay();
                stepper = 0x09;
                delay();
        }
}



►Assembly Programming
Here also the main routine changes rest everything remains same.


CODE:
main:
        mov stepper, #08H
        acall delay
        mov stepper, #0CH
        acall delay
        mov stepper, #04H
        acall delay
        mov stepper, #06H
        acall delay
        mov stepper, #02H
        acall delay
        mov stepper, #03H
        acall delay
        mov stepper, #01H
        acall delay
        mov stepper, #09H
        acall delay
        sjmp main


The working of the above code can be seen in the demo animation below.

unipolar stepper motor in half step sequence

No comments:

Post a Comment