Roboclaw occasionally unresponsive to packet serial

General discussion of using Roboclaw motor controllers
Post Reply
eng101
Posts: 6
Joined: Fri Sep 21, 2018 5:58 am
Roboclaw occasionally unresponsive to packet serial

Post by eng101 »

Running ~10 Roboclaw 2x15A and I'm having issues with communication to the devices. Every so often on boot my program will not get a response from some of the Roboclaw units over serial. I haven't been able to see any pattern to the issue (occurs on multiple units so I suspect it's something in the way I'm interacting with them), they will respond to USB and usually after I connect USB a few times they will then respond to my embedded system (so I know it's not an address, baud or wiring issue).

Apart from this occasional issue communication between the devices works great. Do the Roboclaws need to be powered up for some number of seconds before they become responsive? Is there anything else I'm missing? FWIF the first message I send on boot is a "stop motor" command, then I send some initialisaion messages to set PID values.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw occasionally unresponsive to packet serial

Post by Basicmicro Support »

The start up takes around 1 second before the main loop is running which processes serial data.

Can you describe your wiring layout(complete including any extra signal lines and power lines)?

I've never had a problem with communication with the Roboclaw on powerup(unless its mode has been change to RC or Analog of course, so I dont have a quick answer to your problem.

Please send the code you are using for startup as well. I may see something in it that could be causing it.
eng101
Posts: 6
Joined: Fri Sep 21, 2018 5:58 am
Re: Roboclaw occasionally unresponsive to packet serial

Post by eng101 »

The only wiring to the Roboclaw (other than motor and encoders) are the UART RX, TX and Gnd. This is the only common ground between the control unit and the Roboclaw as they are driven from separate power supplies.

The issue is still persisting (but still inconsistent). It seems to be resolved if I connect the Roboclaw to USB. I saw a forum post with someone else having a similar problem but it was related to an older Arduino library (http://forums.ionmc.com/viewtopic.php?t=266).

I'd have to dig into my code to pull out the Roboclaw library I'm using, but I did capture some data using a logic analyser, I've attached the capture which can be viewed with the software from Saleae (https://www.saleae.com/downloads/). S1 was Roboclaw RX and S0 was Roboclaw TX, you can see that there is no response from the Roboclaw. The timing looks fine to me, I didn't put a scope on it to see if the edges were clean or not. There are 3 retries of each command, the command is the first thing I send the Roboclaw from my program after boot, a motor stop on M1 and a motor stop on M2.

Everything is running on a Cypress PSoC4.
Attachments
Roboclaw_Failure.zip
(1.95 KiB) Downloaded 282 times
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw occasionally unresponsive to packet serial

Post by Basicmicro Support »

Based on your post Im assuming you are using arduino. Download and use the latest version of the Roboclaw arduino library we provide if you dont know for sure it is the latest or if you got it from some other website.

The forum post you mention was a long long time ago(two years and many firmware updates ago). It also is using software serial. Please confirm you are using software serial as well.

Note that software serial can be interfered with by other code on your arduino. Please send me your test code so I can check for any potential issues and also so I can run a test on it to try to reproduce the problem.

Also test at different baud rates, 38400, 57600 and 115200. Arduino cant go any higher than 115200 and actually runs that baudrate at 111111bps.

P.S. Make sure your Roboclaw firmware is 4.1.26. If it isnt, update it with Ion Studio.
eng101
Posts: 6
Joined: Fri Sep 21, 2018 5:58 am
Re: Roboclaw occasionally unresponsive to packet serial

Post by eng101 »

Everything is running on a Cypress PSoC4 not Arduino. The library was written by someone else but I believe they ported to the PSoC platform from an opensource version, not sure of the details.
eng101
Posts: 6
Joined: Fri Sep 21, 2018 5:58 am
Re: Roboclaw occasionally unresponsive to packet serial

Post by eng101 »

It's not running software serial it is a hardware serial controller (you can see the bit timing in the above timing diagram). The Roboclaws have all been updated to run the latest firmware 4.1.26, the issue is being seen with that firmware.

What's confusing me is why this works once the USB is attached and continues to work after the USB is disconnected.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw occasionally unresponsive to packet serial

Post by Basicmicro Support »

Then you will need to debug the psoc libary you have. Since we didnt write it I can't say if the problem is in that library or not.

What else is your PSoC doing?

Have you tested at other baudrates yet? Your scope trace was at 38400. I'd like to see if the problem is consistent at 57600 and 115200 as well.

When you plug in USB the Clock trim is adjusted so that the 48mhz USB clock meets timing requirements for USB. This could cause the main clock to adjust a small amount. However asyncronous serial has a 5% error window. That post you found was caused by the total error excedeing 5%. We fixed that problem two years ago. The current baudrate error due to clock drift is +-1%. If the error on the PSoc side was more than 4% I would expect a problem. It doesnt appear to be that far off though based on the 10bit timing width(I didnt check individual bits though).
eng101
Posts: 6
Joined: Fri Sep 21, 2018 5:58 am
Re: Roboclaw occasionally unresponsive to packet serial

Post by eng101 »

Ok I figured it might be timing related but again it all looked fine. The only other thing that the USB might change is the ground connection, but the traces look pretty clean on the scope.

I'll try a different baudrate, at this point I've determined that I can consistently "fix" it by attaching a USB connected to any host. Strangely I've noticed that other ones that were exhibiting this behavior seem to have started booting consistently with no apparent change other than connecting to USB a few times.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw occasionally unresponsive to packet serial

Post by Basicmicro Support »

Which indicates a timing problem but that can be fixed on either side(or not) depending on what control you have over the bitrate on the PSOC. The roboclaw is setup to be accurate to +-1% on the baudrate under most conditions. Under extreme conditions it can go to +-2%(high temps) but that is still with in the error margin for asyncronous serial(+-2.5% per device).

Maybe I wasnt clear. When you attach USB you are effectively adjusting the timing of the Roboclaw to match the PC which will have a very low error(near 0%). But since connecting the USB to a PC probably isnt an option in the long run you will probably need to adjust the baudrate of the PSOC(assuming another baudrate doesnt just work).

Post Reply