I'm writing a program for testing motors.
I want to use timers for a preset value for sending in and out the
motors.
This is the code I use. (see bottem of the message)
waarde = preset time for sending motors in ms. (works).
the setLeds is the command for steering the motors (works).
The programs works, sends OUT motor one, then StatusM becomes 2;
The motor stops.
StatusM becomes 3, motor one goed IN.
After this the programm keeps sending IN motor one.
StatusM remains 3.
I guess my problem is in the timerReady statement.
The first time the timer is ready, it will give timerReady==true.
But the second time I set the timer, it doesn't.
Does anybody know why ?
// Motor 1 Out
if (StatusM==0)
{
waarde=(Fm1uit*1000.0);
timerSet(1,waarde);
timerStart(1);
u16Value1=1;
setLeds(u16Value1);
StatusM=1;
}
if ((StatusM==1)&(timerReady(1)==true))
{
setLeds(0X0000);
StatusM=2;
}
// Motor 1 In
if (StatusM==2)
{
waarde=(Fm1in*1000.0);
timerSet(1,waarde);
timerStart(1);
u16Value1=2;
setLeds(u16Value1);
StatusM=3;
}
if ((StatusM==3)&(timerReady(1)==true))
{
setLeds(0X0000);
StatusM=4;
}
// Motor 2 Out
if (StatusM==4)
{
waarde=(Fm2uit*1000.0);
timerSet(1,waarde);
timerStart(1);
u16Value1=4;
setLeds(u16Value1);
StatusM=5;
}
if ((StatusM==5)&(timerReady(1)==true))
{
setLeds(0X0000);
StatusM=6;
}
// Motor 2 In
if (StatusM==6)
{
waarde=(Fm2in*1000.0);
timerSet(1,waarde);
timerStart(1);
u16Value1=8;
setLeds(u16Value1);
StatusM=7;
}