Batteriesnotincluded
Posts: 7
Joined: Fri Apr 04, 2014 12:34 pm

Raspberry pi robot

Fri Apr 04, 2014 12:39 pm

Hello all
I am part of a science group, and we are trying to build a raspberry pi robot with body made out of k'nex. I am programming it. We are using 2 raspberry pis, one in a control like box plugged into a TV as the monitor to act as a controlling computer, the other RPi will be in the robot. For controlling the robot, we are hoping to use wireless radio transceivers to and from the robot which uses DC motors (I think) stolen from several RC cars. I am programming the whole programme in python, can anyone help me on how to programme the h-bridge to take radio signals and use them to operate the motors?
Any help would be greatly appreciated!
Thanks

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Raspberry pi robot

Fri Apr 04, 2014 2:45 pm

The H-bridge is really a simple device. You don't "program" the bridge, it just takes inputs from the Pi to determine how to pass signals to the higher-voltage outputs.

Each motor will have Enable, IN1, and IN2. The easy way is to jumper Enable to +5 and just use IN1 and IN2 to control direction.
If you need to control speed as well, some people prefer to put the PWM onto Enable, whereas others are happy to PWM each IN pin. Same result, it's just how many wires and GPIOs you use, and how your program is designed. Either method has the same end result.
In1 on and In2 off will spin the motor in one direction
In1 off and In2 on will spin the motor in the opposite direction.
Both off will idle the motor
Both on will "brake" the motor, and come to a sudden stop.

Model it up on the desk before you put it in the robot. Note that reversing the wires from the motor to the H-bridge will reverse the direction of the motor's spin for a given input. If you find one or both of your motors is going backward, you can either reverse it in code or by reversing the motor wires.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Raspberry pi robot

Fri Apr 04, 2014 3:25 pm

Another thing I'd add is some H-bridge chips (I've noticed this with the L293) drop a volt or more from the battery when powering the motor. I see several people posting that their motor doesn't work off the H-bridge and it's because the 6V battery is enough to turn the motor when connected directly, but not with the H-bridge in circuit. So if it doesn't work at first, just check that you don't need an extra few volts in the battery.

And another thing is you can often test the wiring of the H-bridge without even connecting the controller. I recommend this at first just to reduce the risk of accidentally damaging the raspberry. Just wire your motor, driver chip and battery - nothing on the driver inputs - then carefully connect the driver's relevant input pins to either 0V or to the battery voltage. (Search for a data sheet for your driver, to check the absolute max input voltage though.) You should be able to see the combinations of highs and lows you need.

PickUpaPi
Posts: 15
Joined: Thu Jan 30, 2014 5:48 pm
Contact: Website

Re: Raspberry pi robot

Fri Apr 04, 2014 8:20 pm

You might find it easier to stick a WiFi dongle on the Pi and control it through a web browser than using actual 'radio control'.

With regards to the H-Bridge its easy enough to do, as the poster above said you really only need to connect 2 pins to the Pi, however for more accurate movement if you needed arms consider using servos or stepper motors(this will be slow though).

Let me know if you get stuck on the H-Bridge setup, I can help you out. If your looking for a diagram for the H-Bridge check this out - http://www.pickupapi.com/blogs/pitronic ... al-control
Check out the Pick Up a Pi Pitronics series for free detailed guides and diagrams on how to control Servos, Motors, LEDs and buttons from your Pi using python.

Return to “Automation, sensing and robotics”