Help on connecting VEX 393 motors to Raspberry Pi

I’m trying to build a 4-motor robot with a raspberry pi 3, and I want to use VEX 393 motors (I have to use a Raspberry Pi for an image processing component). However, I have little experience working with these types of electronics, as I am mainly a programmer. What is the best way to make this work? I have the motor controller 29s, cortex, and also an Arduino. Should I use the cortex or Arduino to control the motors, then have it interface with the raspberry pi? Or, should I connect the motors directly to the raspberry pi?

Unfortunately, there aren’t many tutorials/videos on using VEX 393s with Raspberry Pi, so a rundown on how to set it up would be hugely appreciated.

You need a motor hat to be able to drive the motors. This one https://www.amazon.com/Motorshield-Raspberry-Expansion-Control-ultrasonic/dp/B01MQ2MZDV/fosterworld will drive 4 motors, and has two IR sensor ports and an ultrasonic port. This one lets you drive the motors off a separate power input like the VEX battery. There are a ton of these out there.

You are going to need to program the motor by first setting GPIO pins to set forward / backward and then pulse a pin for speed. The hat should come with instructions. Adafruit makes a 2 motor board, there is a good tutorial on how it works. All of the other boards work about the same (may have different GPIO pins)

3 Likes

Thanks for the reply! With this motor shield, do I still need to use the VEX motor controller 29s?

No actually.
(I was about to type yes, assuming all it did was add “analog output” ports capable of pwm to talk motor controller. Was wrong has H bridge)

4 Likes

No, it’s got 2 dual H-bridges on the bottom. You’ll need to look at the details of the board to see the total power. Remember stall current is a bad thing, plan your mechanical construction accordingly.

For those following along, an H-bridge is a set of 4 transistors arranged with the Direct current (DC) motor in the center, the drawing looks like the letter H. By driving the transistors in different ways you can get stop, forward, reverse and brake functions.

@randomguy will use the PI to switch the pins on and off to get the movement they want. The 29 controller has a H bridge to drive the motor and a microprocessor to decode the Pulse Width Modulation (PWM) that comes from the Cortex to what the H-Bridge wants to see.

There are also Pi Hats that will put out PWM signals to drive hobby servos. Those boards would need the 29 controller, making things a little more complex.

Lastly, if the H-Bridges are running warm, you can attach a heat sink to them to dissipate the excess heat from the current flow. That’s a stopgap measure, the chips do have a limited amount of current they can pass.

7 Likes

The MC29’s take in servo PWM as input. Here’s a function for Arduino that converts between -127 -> 127 to the 40-140 range that I have found works by trial and error. If the Pi is capable of servo control then it will be able to control MC-29s. The range may be off slightly so may need some tuning to get it to work accurately.

//MC29 control function using Arduino servo library
int motor(int val){
int motval = map(val, -127, 127, 40, 140); //scales the the -127 - +127 to +40 - +140
my_servo.write(motval); // sets motor speed according to motval
}
You will of course need to run the motors off an unregulated power supply and some big fairly large capacitors would also be a good idea.

1 Like

Thanks for the advice! Would the VEX 7.2V battery work as the power supply? Also, could I use the VEX power expander to connect the MC29’s to the power supply and the Arduino?

Yes, the motor expansion is the way to go for the arduino example. The Pi board I referenced has input for a motor only supply.

Very true. You will also need to make sure the motor drivers on the board have thermal shutdown protection.

Most cheap Arduino motor expansion boards don’t have it and their max continuous current is <1200 ma, while 393 stall current could easily jump to 4000 ma. We ended up frying one by having 393 motor connected directly to H-Bridge.

MC29 controllers work great with Arduino PWM outputs, but some of the cheap Arduino boards have no crystal and their clock (and therefore PWM timing signals) are not very precise. We had to experimentally tweak our control range mapping (see @marinmersenne comment) to get it to stop at exactly at 0 power level.

Any Arduino board with a crystal should work fine without any extra effort.

4 Likes

Thanks for your input! I have the Arduino Uno, will that work fine?

The power expander should work. Try using it without connecting the middle V+ pin input on the power expander and see if it works and if not, check the voltage first with a voltmeter to see if it is connected to the 7.2V battery.
The Arduino can be powered off one of the middle 7.2V pins on the power expander output side.

1 Like