Page 1 of 1

Waiting for buffer/motors to arrive at destination

Posted: Wed Aug 17, 2016 11:04 am
by SouthernAtHeart
Hi, When I tell the roboclaw to move the 2 motors to a position, what's the best way to find out when they arrive there. To read the encoder values and see if they match up to what I sent them to, or to read the buffer? If I read the buffer and it's empty, does that mean they have successfully completed the positions I sent to them? If so, then that sounds like an easy way to tell my machine it's ready to execute the next step.
thanks.

ps. Will this work?

Code: Select all

roboclaw.SpeedAccelDeccelPositionM1(address, accel, maxSpeed, deccel, M1val, 0); //
roboclaw.SpeedAccelDeccelPositionM2(address, accel, maxSpeed, deccel, M2val, 0); //

uint8_t depth1; //buffer 1 reading
uint8_t depth2; //buffer 2 reading

 while (depth1 != 0x80 && depth2 != 0x80) { //wait for buffers to be empty
   roboclaw.ReadBuffers(address, depth1, depth2);
   delay(100);         
} //end of waiting for drillhead position

Re: Waiting for buffer/motors to arrive at destination

Posted: Wed Aug 17, 2016 5:32 pm
by Basicmicro Support
The buffer value will be 0x80 if the motors are idle. Other wise the number returned is how many commands are buffered waiting to run(eg 1 means there is one command waiting to run when the current command finished, 0 means the last command in the buffer for that motor is still running and 0x80 means the motor is idle and no more commands are buffered).

Re: Waiting for buffer/motors to arrive at destination

Posted: Thu Aug 18, 2016 6:51 am
by SouthernAtHeart
Thanks. I think my code will work then. I'll set up a test environment and check it out.