Current flowing from roboclaw to RPi?

General discussion of using Roboclaw motor controllers
Post Reply
Vincent_vd
Posts: 2
Joined: Fri Dec 01, 2017 10:27 am
Current flowing from roboclaw to RPi?

Post by Vincent_vd »

I recently acquired a roboclaw 2x7A and have been trying to vet it for the project I am working on.
When running some tests in order to check current acquisition I had an anomaly that we are having trouble explaining.
The setup is the following:
- A raspberry Pi 3, using python
- A roboclaw 2x7A connected by USB (the board does not have a lb-mb jumper option)
- A 34V power supply
- A DC motor connected to M1
- A 10Ω resistor connected to M2

- Problem 1:
This is my main question and biggest concern. Is there any possibility for power to flow back to the Raspberry Pi through the USB connection?
During the testing, i used an o-scope to measure current as well as voltage over the resistor. When powering the resistor the system seemed to completely short out, the roboclaw's error light went on and the power supply went to 0V and its max current setting (I believe it was set to 6A). Worse though, the RPi turned off, to never turn on again. With a second test the same thing happened to a second pi. I then realized that the o-scope has a capacitor inline, and that this shorting behavior only happens when there's a capacitor connected over the load (a motor with a capacitor shows the same behavior). I assume a capacitor and locked antiphase PWM don't play well together, please correct me if I'm wrong in that aspect.
Do you have any idea what could have happened to the RPi? We are planning on using this in an autonomous robot so any chance of the motor controller destroying the main computer when an error occurs is of course a risk we can't take.

- Problem 2:
This is more of a question than a problem. When reading the RoboClaw's current readings, I noticed that on a lower PWM setting this value is much higher than the actual (average) current draw of the motor. I suspect that the roboclaw only measures direct current draw whenever the h-bridge is set to high, and thus reads a current value on every PWM pulse higher than the average, is this correct? Does the roboclaw have any averaging filter options built in to get actual current draw, or is this something I would have to do myself?


Thank you for your help
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Current flowing from roboclaw to RPi?

Post by Basicmicro Support »

1. The 34v power supply is a problem. The maximum voltage is 34v on the Roboclaw. A 34v power supply is only nominally 34v. By default the roboclaw will put the motors into braking mode when the voltage goes over 34v. You are so close to that voltage Im not sure what will be happening when you try to drive a motor. Also if oyu are going to use a power supply you should setup a voltage clamp circuit as described in the manual. If you do please use the recommened mosfet in our forum announcement.

Unless the Roboclaw is damaged(something burns and short power to the USB through the processor) no there is no way for power to flow from through the USB from the Roboclaw. The USB 5v line has a resistor on it to prevent any significant current flow(used to prevent the USB from powering the Roboclaw but would prevent power going back to the R-Pi).

The fact your power supply shorted out(0v ) and pulled max current when you plugged it in indicates you have something wired wrong. It may be the cap but small caps(.1uf) are regularly added across the motor leads of DC motors to snub voltage spikes from the motor commutator. Larger caps would probably allow alot of current to flow but I would not expect the oscope probe lead to have much capacitance(less than .1uf in fact). However you cant usually put the probe and its ground lead across the motor channels(you will end up shorting the ground lead connected sied). Your scope would need to have a floating ground option to measure across the motor channel leads.

Why do you have a 10ohm resistor on M2? If you have to drive a resistive load you need to set the PWM mode to Sign Magnitude. But I dont see any reason for doing this so please explain what you are trying to acomplish.

Locked Antiphase PWM mode drives both sides of the motor channel with different PWM duty cycles to generate an average current. This only works on inductive loads.

My best guess is when shorting out the Roboclaw the ground of the Roboclaw got a large spike of noise on it. R-Pi have a very narrow operating range. Going outside of that range and it will go poof. If the ground saw a large spike(probably negative) the r-pi would have suddenly seen much higher input voltage(because the ground dropped) than it was designed for. This is just a guess. Note the R-Pi was killed, not because the Roboclaw indicated an error. It was killed because of the thing that caused the Roboclaw to indicate the error.

2. Motor current is a function of input current * 1/PWM duty. If 1 amp is being drawn from the power supply and the motor is being driven at 10% duty the motor is seeing 10amps(1 amp at 100% = 10amps at 10%). Current doesnt change on a dime. It will keep flowing. The current reading at each PWM pulse is, within a small margin of error, the current the motor is seeing even when the PWM is on the low side of the pulse. You may think that is free energy but it isnt. What gives is the average voltage of that current. If you are PWM at 34v at 10% duty the motor sees 1/10th the voltage at 10 times the amps being drawn from the power source.
cyberdemon
Posts: 10
Joined: Sun Oct 08, 2017 3:41 am
Re: Current flowing from roboclaw to RPi?

Post by cyberdemon »

The USB ground on the RoboClaw is connected to the main battery ground. This can cause problems with ground loops in my experience, if the RPi is powered from the same battery as the RoboClaw (I have blown up one RPi the same way as you).

I recommend these USB opto-isolators to avoid ground loops:
Image They are widely available on eBay, aliexpress etc.

I have tested these with the RoboClaw. The opto-isolators include an isolated 5V supply, so you can use a bus-powered USB hub to address multiple RoboClaws through one opto-isolator.

Make sure the switch is in the "OFF" position, which sets it to "high speed" USB 2.0 mode instead of USB 1.1. (I don't know why the switch exists - it should always be "off")
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Current flowing from roboclaw to RPi?

Post by Basicmicro Support »

Also I just noted you have a resister wired on M2. If you are using Locked Antiphase this will also short out the Roboclaw. Locked antiphase PWM mode REQUIRES an inductive load. You can change the PWM mode to Sign magnitude if you want to use a resistive load.

Post Reply