hemnath
Advanced Member level 3
- Joined
- Jun 24, 2012
- Messages
- 702
- Helped
- 61
- Reputation
- 120
- Reaction score
- 57
- Trophy points
- 1,308
- Location
- Chennai
- Activity points
- 6,589
Im using pic 16F877A uC and crystal frequency is about 16Mhz. Compiler : CCS c compiler. I'm driving the stepper motor with mosfet.
Motor specs is about 1.8 deg. To find the 360 deg complete rotation, I have attached a needle and pointing as the starting point. Problem is that, when i program and power the stepper motor, stepper motor goes one step backward and starts rotating forward. Why is it happens? Because of that, 360 deg complete rotation is not achieved. It misses out some deg for one rotation. and, more degree misses out for many rotation. Couldn't find the solution.
connections:
uc pin C5 to stepper motor A
uc pin C3 to stepper motor A'
uc pin C4 to stepper motor B
uc pin C2 to stepper motor B'
I want the stepper motor to stop where it has been started(i.e, ending point to be same where it has been started)
Please help.
Motor specs is about 1.8 deg. To find the 360 deg complete rotation, I have attached a needle and pointing as the starting point. Problem is that, when i program and power the stepper motor, stepper motor goes one step backward and starts rotating forward. Why is it happens? Because of that, 360 deg complete rotation is not achieved. It misses out some deg for one rotation. and, more degree misses out for many rotation. Couldn't find the solution.
connections:
uc pin C5 to stepper motor A
uc pin C3 to stepper motor A'
uc pin C4 to stepper motor B
uc pin C2 to stepper motor B'
I want the stepper motor to stop where it has been started(i.e, ending point to be same where it has been started)
HTML:
#include "16F877a.h"
#fuses HS // High speed crystal
#use delay(clock=16000000)
#define RS PIN_B2
#define EN PIN_B0
void lcd_init();
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
unsigned int16 i;
void main()
{
output_low(PIN_B1);
lcd_init();
delay_ms(100);
for(i=1;i<=50;i++)
{
output_c(0b00100000);
delay_ms(100);
output_c(0b00010000);
delay_ms(100);
output_c(0b00001000);
delay_ms(100);
output_c(0b00000100);
delay_ms(100);
}
}
void lcd_init()
{
lcd_cmd(0x38); // Configure the LCD in 8-bit mode, 2 line and 5x7 font
lcd_cmd(0x0c); // display on and cursor off
lcd_cmd(0x01); // clear display screen
lcd_cmd(0x06); // increment cursor
lcd_cmd(0x80); // set cursor to 1st line
}
void lcd_cmd(unsigned char c)
{
output_b(c);
output_low(RS);
output_high(EN);
delay_ms(15);
output_low(EN);
}
void lcd_data(unsigned char z)
{
output_b(z);
output_high(RS);
output_high(EN);
delay_ms(15);
output_low(EN);
}
Please help.