silveroblado WROTE:initA = A; //get current A value //overshoot depends on load and speed of the motor
initB = B; //get current B value
do
{
run_cw(speed); //run motor in clockwise direction with user defined speed
}while(initA ==A && initB ==B); //continue run until state change
countAB++; //increment counter for each state change
}
The thing is I dont get the meaning of continue run until state change......the state will change when ever the motor shaft rotates!!
silveroblado WROTE:So should I write like this,
while(1)
{
initA = A; //get current A value
initB = B; //get current B value
while(initA=A && initB=B)
{
countAB++;
if(countAB==10)
{
buzzer=1;
}
}
}
while(1)
{
initA = A; //get current A value
initB = B; //get current B value
MotorRun(); //run motor function
while(initA==A && initB==B);
countAB++;
if(countAB==10)
{
buzzer=1;
}
}
initA = A; //get current A value
initB = B; //get current B value
MotorRun(); //run motor function
countAB = 10;
while(countAB < 20)
{
while(initA==A && initB==B);
countAB++;
}
buzzer=1;
Motorstop(0);
stopA;
stopB;
initA = A; //get current A value
initB = B; //get current B value
MotorReverseRun(); //run motor function
while(countAB > 10)
{
while(initA==A && initB==B);
countAB--;
}
buzzer=0;
Motorstop(0);
stopA;
stopB;
}
Users browsing this forum: No registered users and 12 guests