To control the
speed of unipolar stepper motor we use a Microcontroller to control the
activation and also control activation time. ULN2003 is used as current amplifier. Preset use to control speed of motor
Circuit to speed control of stepper motor |
connection of stepper motor |
1 - coil 1
2 - coil 2
3 - coil 3
4 - coil 4
&
5 - CMN
CODE:-
unsigned short i,k; // Globle variable initialisation
void delay(unsigned short j) // Delay function
{
for(i=0;i<=j;i++) // For loop to generate multiple delay
{
delay_ms(1); // delay 1ms
}
}
void main() // Main function
{
ANSEL = 0x00; // Analog selection register
TRISA = 0x07; // Input/output selection register
TRISC = 0x00; // Input/output selection register
PORTC = 0x00; // Default PORTC all output zero
a = 0; // bit a is clear
ADC_Init(); // initialise ADC
while(1) // Inf loop
{
k = 20 - ADC_Read(0)/60; // Formula to generat delay by read ADC at analog 0
PORTC=0x01; //
delay(k); //
PORTC=0x04; //
Delay(k); //
PORTC=0x02; //
Delay(k); //
PORTC=0x08; //
Delay(k); //
}
}
No comments:
Post a Comment