Motor is missing commands
-
- Posts: 2
- Joined: Fri Jun 24, 2022 2:09 pm
Motor is missing commands
I have
Roboclaw 2x7a V5C
Arduino Nano Every
Adafruit Bluefruit UART Friend
The Robo claw is connected via software serial (38400 BAUD) as well as the BT module on a second software serial connection (9600 BUAD, I think). The device I am working on is supposed to be able to go back and forth with the Motor. Right now, we are having issues where commands seem to only get through to the motor at random. This function is supposed to find a "home" point, where the arm driven by the motor is fully retracted.
I then can execute the
over and over until the motor finally stops. Sometimes it stops on the first try, sometimes it takes 15 tries.
Why are these commands missing? Some members of my team think it could be that the 3 Serial connections on the arduino board interfering with each other. I personally cannot find a pattern anywhere, sometimes the status light blinks when a command is sent and the motor continues to run, sometimes it blinks and the motor stops.This device used to work before we implemented the BT module (previously Xbee with HWSerial) but I can't see the reason why the BT module would be interfering. Thank you for your time.
Roboclaw 2x7a V5C
Arduino Nano Every
Adafruit Bluefruit UART Friend
The Robo claw is connected via software serial (38400 BAUD) as well as the BT module on a second software serial connection (9600 BUAD, I think). The device I am working on is supposed to be able to go back and forth with the Motor. Right now, we are having issues where commands seem to only get through to the motor at random. This function is supposed to find a "home" point, where the arm driven by the motor is fully retracted.
Code: Select all
// Home SMURF and reset encoder values to zero
void home_encoder(){
int enc_last = 0;
int enc_now = 1;
while (enc_last != enc_now){
enc_last = enc_now;
roboclaw.BackwardM1(0x80,100); // moves foot up //always runs fine, starts the motor, no problem
delay(100);
roboclaw.ReadEncoders(address,enc1,enc2); // can use encoders for error detection
enc_now = enc1;
Serial.print("enc_now =");Serial.println(enc_now); //currently the device is deconstructed
Serial.print("enc_last =");Serial.println(enc_last); //these match on the first or second run
//through the loop and break
}//while (enc_last != enc_now)
roboclaw.ResetEncoders(address);
roboclaw.BackwardM1(0x80,0); // stops foot //misses consistently, stops the motor once in a blue moon
}//home_encoder()
Code: Select all
roboclaw.BackwardM1(0x80,0);
Why are these commands missing? Some members of my team think it could be that the 3 Serial connections on the arduino board interfering with each other. I personally cannot find a pattern anywhere, sometimes the status light blinks when a command is sent and the motor continues to run, sometimes it blinks and the motor stops.This device used to work before we implemented the BT module (previously Xbee with HWSerial) but I can't see the reason why the BT module would be interfering. Thank you for your time.
-
- Posts: 2
- Joined: Fri Jun 24, 2022 2:09 pm
Re: Motor is missing commands
This will not be my final update as we are not totally operational yet. But here is the current state of things.
I was able to speak to a very knowledgeable engineer on the support line for Basic Micro and he gave me a few valuable points of advice.
1) BackwardM1() is not supposed to be used that way
apparently it is a compatibility feature for legacy hardware
2)The encoders are not being used properly
we read them, but handling position control on arduino side doesn't truly take advantage of roboclaw
3)The fundamentals of the circuit were WAY OFF.
Power to the arduino, BT module, & loadcell were all drawn from 12v input to roboclaw
BIG NO-NO!! TOO MUCH NOISE
So I got off the phone with 3 main objectives
1)reroute the power to logic components
I chose to draw from the 5v output on the roboclaw. This supplies 5VDC with 50mv ripple, I was able add bypass capacitors and an inductor to bring the ripple down to 20mv which seems good enough. It should also deal with any noise that comes through during operation.
2)Tune the motors with Motion Studio for position control
This was super easy and also allowed me to find out that the encoders were wired backwards.
it also allowed me to push new firmware and get the new tuning numbers
Here is the link to the instruction page: https://resources.basicmicro.com/auto-t ... on-studio/
One question that I have is, should I write the tuning parameters into my code using the function
obviously I would take the correct parameters from motion studio. This device won't be easy to retune so is it a good idea to have the arduino set them every time the device powers on?
3) I rewrote the code to do everything based on position, but here is my final roadblock. The device has a limited range of motion, if fully retracted, the arm can extend 3400 encoder steps until it runs out of room.
This is good and makes controlling the arm rather easy. But wherever the arm is when the device turns on is the encoder position 0. I need a way to reliably make the arm fully retract and set that position to 0.
If the motor hits one of the endpoints with too much force, the roboclaw panics and resets the entire device. (I'm sure this is partly caused of my decision to route power from the roboclaw)
commands like
only get a small twitch from the motor; perhaps I am misunderstanding them?
Your feedback is much appreciated.
I was able to speak to a very knowledgeable engineer on the support line for Basic Micro and he gave me a few valuable points of advice.
1) BackwardM1() is not supposed to be used that way
apparently it is a compatibility feature for legacy hardware
2)The encoders are not being used properly
we read them, but handling position control on arduino side doesn't truly take advantage of roboclaw
3)The fundamentals of the circuit were WAY OFF.
Power to the arduino, BT module, & loadcell were all drawn from 12v input to roboclaw
BIG NO-NO!! TOO MUCH NOISE
So I got off the phone with 3 main objectives
1)reroute the power to logic components
I chose to draw from the 5v output on the roboclaw. This supplies 5VDC with 50mv ripple, I was able add bypass capacitors and an inductor to bring the ripple down to 20mv which seems good enough. It should also deal with any noise that comes through during operation.
2)Tune the motors with Motion Studio for position control
This was super easy and also allowed me to find out that the encoders were wired backwards.
it also allowed me to push new firmware and get the new tuning numbers
Here is the link to the instruction page: https://resources.basicmicro.com/auto-t ... on-studio/
One question that I have is, should I write the tuning parameters into my code using the function
Code: Select all
// roboclaw.SetM1VelocityPID(address,Kp,Ki,Kd,qpps);
// roboclaw.SetM1PositionPID(address, 20.0, 0.0, 0.0, 0,0,0,30000);
3) I rewrote the code to do everything based on position, but here is my final roadblock. The device has a limited range of motion, if fully retracted, the arm can extend 3400 encoder steps until it runs out of room.
This is good and makes controlling the arm rather easy. But wherever the arm is when the device turns on is the encoder position 0. I need a way to reliably make the arm fully retract and set that position to 0.
If the motor hits one of the endpoints with too much force, the roboclaw panics and resets the entire device. (I'm sure this is partly caused of my decision to route power from the roboclaw)
commands like
Code: Select all
roboclaw.SpeedM1(address, 1500);
roboclaw.SpeedAccelM1(address,100,10000);
Your feedback is much appreciated.