I’m running a G2 24V12 (item 1365) motor controller using I2C and a Pololu 25D brushed DC motor (item 4843). The board is configured the control with the software. This works very nicely. The sample code works very well to set motor power and to read variables from the control. By using a PID loop values are sent to the control very quickly (about every 20ms). Most of the time it works but occasionally there is “safe start” error. The Error Status Code (ID=0) only is a value of 1, Meaning Save start violation. Status (ID=3) also return a 1, indicating only Safe-Start violation.
If “Disable safe start” is checked the motor does not fault out, although on a speed sweep you will occasionally hear a glitch in the noise during a smooth speed.
After implementing the cyclic redundancy check (CRC) I think that these may be trapped but now it must be creating an error on the CRC error unless the “Ignore ERR line high” box is also checked.
No point in turning off all error checking. Any idea on what could be causing the error and what to do to correct it?
Note: The I2C bus has pull-up 6.8K resistors to the Mega’s 5V pin. I only have SDL/SCL and GND connected (other than motor supply and A&B).
It should be fine to have the “Ignore ERR line high” option enabled since you are not using the controller’s ERR line as an input. It sounds like you probably have some noise problems with your I2C lines. Could you post some pictures of your system that show all of your connections? Also, could you connect your controller to the Simple Motor Control Center G2 and monitor the “Errors” box in the “Status” tab while the system is running to see which errors are occurring?
Here is my setup: The orange wires are SDA and the yellow are SCL. The Robogaia encoder board is using SPI. If I remove the board I get the same errors so don’t think the issue is the board.
I typically don’t look at these so not sure if they look good are not. My thought is there may be a long RC time constant but the clock is getting up to 5V.
Thank you for the additional information. It might be possible that you are introducing some noise to your Arduino from coupling your encoder wires tightly with your motor wires. As a quick test, could you try disconnecting the encoder shield from your Arduino, then disconnecting the encoders from the shield to see if that makes the CRC errors stop?
@BrandonM, I tested with the encoder board removed completely and got the same result. i normally would agree to keep the encoder wires away from the motor wires but the standard Pololu motor has the wires from the motor all together. The encoder and motor wires are nowhere near the I2C wires and I think the error being generated.
The Serial Error count is sometimes higher than the CRC count. I have also noted a few “Format” errors.
I have been testing on the main motor (a 24V larger DC motor) and am experiencing the same problems so no finger pointing at the Pololu motor.
Overall the board works well with the exception of instantaneous glitches in speed.on the errors.
Regarding the I2C traces, this is the normal trace: Look at the yellow clock trace. Nice and even, with a good 0V.
This or a variant of this happens occasionally. Notice the small step in the clock signal. This one shows three little steps. Some have one or two. Also note the duration increased. Any thoughts?
I do not see anything else obvious that would cause corrupted serial data. Any time there is a motor in the system there can be some risk of noise. I agree that your setup looks separated enough, but since you are still having some kind of interference, could you try disconnecting the motor completely and running your system without it to definitively rule it out?
How quickly does the occurrence count of the CRC error increase? Is there any predictability or noticeable pattern to the frequency it’s happening?
@BrandonM, With the motor disconnected and sending a 0 speed command every 20ms:
with an I2C bus of 40KHz I saw 14 serial errors and 11 CRC errors in one minute
with an I2C bus of 300KHz I saw 8 serial errors and 6 CRC errors in one minute
with an I2C bus of 200KHz I saw 3 serial errors and 2 CRC errors in one minute
with an I2C bus of 100KHz I am not seeing the errors in one minute
Long term test at 100KHz (for 30 minutes)
with an I2C bus of 100HKz I am not seeing the errors, even with the motor running.
I guess we chalk it up to I2C bus speed. Is it safe to assume a maximum I2C bus speed of 100KHz?
I though most devices could handle 400KHz and seeing this note on the specs sheet made me assume I could even go to 500KHz
Autodetects baud rates between 1200 and 500,000 bps, or can be set to any fixed baud rate in this range.
I did not expect there to be a problem with I2C at 400 kHz, but we did not thoroughly test its limits in various setups. You might try using more aggressive pull-up resistors to see if that helps reduce the errors at higher speeds.