Waiting for buffer/motors to arrive at destination
-
- Posts: 32
- Joined: Fri Jan 29, 2016 4:00 pm
Waiting for buffer/motors to arrive at destination
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?
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
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: Waiting for buffer/motors to arrive at destination
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).
-
- Posts: 32
- Joined: Fri Jan 29, 2016 4:00 pm
Re: Waiting for buffer/motors to arrive at destination
Thanks. I think my code will work then. I'll set up a test environment and check it out.