|
|
View previous topic :: View next topic |
Author |
Message |
davevu22 Guest
|
Stepper motor controller |
Posted: Fri Nov 30, 2007 12:36 am |
|
|
I have a 6 wire stepper motor and I connect both center tap to 12V. My motor is a 1.8 degree so one rev would be 200 steps but i'm not getting that. My motor turns 1 rev per 50 steps and I'm not sure why. Here is my code.
Code: | #include <16F777>
#DEVICE ADC=8
#fuses INTRC_IO, NOWDT, NOPROTECT, NOBROWNOUT, NOMCLR
#use delay(clock = 8000000)
setup_oscillator(OSC_8MHZ);
main()
{
//int sequence[8] = {7,6,14,12,13,9,11,3}; //good
//int sequence[8] = {8,10,2,6,4,5,1,9}; // my own
int sequence[8] = {10,6,5,9};
//int sequence[4]={5,9,10,6};
//int sequence[8] = {10,8,9,1,5,4,6,2};
int i=0;
int16 c=0;
while(1)
{
delay_us(2000);
output_B(sequence[i]);
i++;
if (i>3)
{
c++;
i=0;
}
if (c==500)
{
c=0;
delay_ms(1000);
}
} |
|
|
|
davevu22 Guest
|
|
Posted: Fri Nov 30, 2007 12:38 am |
|
|
For the code above, i'm telling the motor to turn 10 times and stop for one second. The C=500 should be C=200 if it takes the motor 200 steps per rev.
Wierd. |
|
|
davevu22 Guest
|
|
Posted: Fri Nov 30, 2007 12:39 am |
|
|
davevu22 wrote: | For the code above, i'm telling the motor to turn 10 times and stop for one second. The C=500 should be C=200 if it takes the motor 200 steps per rev.
Wierd. |
Sorry I mean C=2000 |
|
|
Ttelmah Guest
|
|
Posted: Fri Nov 30, 2007 3:29 am |
|
|
When does C increment?.
Think about it, you are incrementing C, every four times round the loop (when i>3). Not suprising that the motor goes four times further than you expect.....
Best Wishes |
|
|
davevu22 Guest
|
|
Posted: Fri Nov 30, 2007 11:12 am |
|
|
To complete one step, don't you need to go output value 10,6,5,9 to port B? Its a full step sequence.
From what i've read, to make the motor turn 1.8 degree (1 step) I would have to output this sequence 10,6,5,9. I don't think the motor would step 1.8 degree if I just output 10. Would it? I'm at work so I guess I'll try it later.
Thanks. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|