Problem with Serial communication

General discussion of using Roboclaw motor controllers
Post Reply
ejunkins
Posts: 13
Joined: Mon Mar 18, 2019 8:28 am
Problem with Serial communication

Post by ejunkins »

I'm running into a strange issue trying to connect to a set of 5 RoboClaw 2x7a, wired up in parallel being controlled from a Raspberry Pi. The issue is that when I boot up the robot and try to communicate to the RoboClaws it hits the timeout on each one of them. Because of the placement of the Roboclaws inside our robot we also have each of them connected to their micro USB connector via a USB Hub for debugging purposes. I was wondering if this hub is creating this communication issue? As soon as I open up basic micro studio and connect/disconnect to any of the 5 roboclaws it is then able to connect via serial, without changing any of the settings on any devices.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Problem with Serial communication

Post by Basicmicro Support »

1. Did you enable multi-unit mode on all the Roboclaws?2
2. What baudrate are you using?
3. Does communications work with a single Roboclaw without first connecting via USB? Eg only one Roboclaw connected to the RPi serial port.
ejunkins
Posts: 13
Joined: Mon Mar 18, 2019 8:28 am
Re: Problem with Serial communication

Post by ejunkins »

Sorry for the late response on this.. Multi unit mode is enabled, and it uses 115200 Baud rate. I didn't test one singular Roboclaw to the Pi yet, they are all plugged into a custom PCB that ties all their serial lines together and isn't particularly easy to remove this to test one single roboclaw connection to Pi.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Problem with Serial communication

Post by Basicmicro Support »

What is your pullup resistor value?

You cant disconnect all the other Roboclaws and leave one connected to your customer board? If you do that and disable multiunit mode is should work the same as if you had a direct connection(eg the pullup wont matter since the Roboclaw will output a driven signal).
ejunkins
Posts: 13
Joined: Mon Mar 18, 2019 8:28 am
Re: Problem with Serial communication

Post by ejunkins »

The pullup resistor value i'm using is 4.7K. The issue with trying to take one of the boards off is that the entire PCB system is embedded into a robot and requires a non-trivial amount of taking things apart to reach them at this point. I had tested everything previous to adding a USB hub for communication for debugging purposes, didn't realize it was going to create any issues.

I also realized that it is not exactly tied to connecting with the Basic Motion studio. I have tried several times to recreate the scenario, and it appears that sometimes upon booting of the system it will establish serial connection to the Roboclaws if I just connect the USB hub to my computer, and sometimes it doesn't even after connecting to each Roboclaw individually. Is it just that the USB hub should not be used in a system this way?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Problem with Serial communication

Post by Basicmicro Support »

Just to be clear, If Im understanding you, this only seems to be a problem when the Roboclaws are attached to the USB hub?

In other words, If you completely remove the USB connections from the Roboclaws can you talk to them via the TTL serial properly?

Roboclaw does adjust its internal oscilator to match the USB clock when it is attached to USB. This is because USB is very particular and must match basically exactly.

On the R-Pi do you have any control over the baudrate or are they specificaly defined(Its been a while since I used the RPI TTL serial port)?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Problem with Serial communication

Post by Basicmicro Support »

You shouldnt need to add any delay when sending commands to the Roboclaw as long as the bitrate and format(8N1) is correct. It has a hardware buffered serial port with seperate 256 byte buffer for TX and RX.

You can safely use 8N2 when sending to the Roboclaw.

The commands are processed in the main idle loop. Serial data is buffered via interrupt so nothing the main loop is doing would interfere with receiving serial data.
ejunkins
Posts: 13
Joined: Mon Mar 18, 2019 8:28 am
Re: Problem with Serial communication

Post by ejunkins »

Yes the problem seems to be when I have Rooboclaws attached to the USB hub. It is a powered USB hub, that I use to connect to 5 seperate RoboClaws. Testing I just did yielded the following result:

On Boot of robot:
- When USB hub is powered and connected to RoboClaws - Unable to establish serial connection
- When USB hub is not powered and connected to RoboClaws - Able to establish serial connection
- When USB hub is powered and not connected to RoboClaws - Able to establish serial connection

Afterwards I did the following:

- When USB hub is powered and connected to Roboclaws, removed USB connection to RoboClaws - Able to establish serial connection
I then plugged all connections to USB hub back in, and it can still connect over TTL serial to Roboclaws, and USB simultaneously.

It appears that there is something about there being a connection to the RoboClaws that causes them to refuse the TTL Serial connection but only until that communication is established once. As soon as I got the TTL serial to work once it was fine the rest of the time.

To answer your last question yes I have control of baudrate of the RPi, I've been using 115200, but it has all standard baud rates available.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Problem with Serial communication

Post by Basicmicro Support »

Is the HUB attached to a PC when you power it while connected to the Roboclaw?

The Roboclaw adjusts its main clock to match the USB communications clock when USB is attached. This is because USB is very particular. However if something is odd about the HUB, the hub may be causing the Roboclaw to change its main clock too much when NOT attached to a PC. This is just a guess since I've never seen this before but it is a possibility.
ejunkins
Posts: 13
Joined: Mon Mar 18, 2019 8:28 am
Re: Problem with Serial communication

Post by ejunkins »

The Hub is not attached to a PC when the system powers on. I think my plan is going to be to add a switch on the power of the USB hub that will only turn on when I need to debug the system, so I won't have to worry about this during normal operation

Post Reply