Raspi with DFRobot Dual Motor Controller


10 posts
by Cudy789 » Fri Jun 14, 2013 11:16 pm
Hi all, i have been trying to make a pretty small robot, and i am having problems with controlling motors.I purchased this motor controller http://www.robotshop.com/productinfo.aspx?pc=RB-Dfr-19&lang=en-US and thought i would be able to power my way through the programming part of it. After it arrived at my house i realized it is more of a hassle than i previously thought :evil: . While i was caught up in all of the other logistics of my project, i thought that i would be able to easily communicate between my pi and the motor controller, but i cannot find a way to. Is there any supported projects with this specific controller? Is there even a way to communicate to it with my pi? Would i need to download a different library into python?

(i am trying not to spend anymore money on different devices)

-Cudy
Posts: 18
Joined: Thu Apr 04, 2013 10:16 pm
by Gbaman » Fri Jun 14, 2013 11:35 pm
Those motor controllers are very simple to work with, you got a bit ripped off though as I have something like 12 very similar ones (same chip) only costing me £3 each off eBay from china.
Anyways, each controller supports 2 motors both directions.
To use them simply hook up your motor to either of the 2 sets of terminal blocks on the outsides, I then power mine with 6 AA batteries to get around 9v. The power cable goes into 12v port and ground into GND port (unless you are using voltages higher than 12v)
Them from the GPIO header from the pi, attach 2 jumper cables from your chosen pins to the control pin header on the board.
You will also need to attach pi ground (pi pin 6) into the GND port of the motor controller, this threw me the first time I did this.
Then it is a simple matter of turning on the control pin (setting pin high) using something like wiringpython, simple.

More details can be found on an old blog post of mine
http://pi.gbaman.info/?p=14
Do you love Lego and Raspberry Pis. Ever wondered what would happen if you combine them into a robot? I decided to try it out.
Check out my blog for more info

pi.gbaman.info
Posts: 40
Joined: Mon Jan 21, 2013 2:43 pm
by liudr » Sat Jun 15, 2013 2:21 am
How are you wiring the device up? What code have you tried and what outcome did you observe? These are the basic things you should provide. You provided a product link, so +1 for you but you didn't provide the rest. There is no way to help you without knowing anything YOU did.
User avatar
Posts: 134
Joined: Sat Jun 01, 2013 12:11 am
Location: Central MN, USA
by Cudy789 » Sat Jun 15, 2013 5:14 pm
Ok thanks, i hooked up pin six to the board and it worked like a charm :D . I was wondering though, since my robot goes 10 mp/h on True/1, and comes to a dead stop on False/0, would be able to use PWM to control the speed of my motors?
Thanks for the help!

-Cudy
Posts: 18
Joined: Thu Apr 04, 2013 10:16 pm
by PiGraham » Sat Jun 15, 2013 5:29 pm
Cudy789 wrote:Ok thanks, i hooked up pin six to the board and it worked like a charm :D . I was wondering though, since my robot goes 10 mp/h on True/1, and comes to a dead stop on False/0, would be able to use PWM to control the speed of my motors?
Thanks for the help!

-Cudy


Yes. Look up pigpio. The author, Joan on this board, has posted links and info here.
Posts: 733
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville
by Cudy789 » Sat Jun 15, 2013 7:13 pm
So i am messing around with the wiring for this and i am wondering if it safe to connect my pi's ground directly to the logic supply (9v.) ground for the board. Basically combining the two grounds into one master ground and plugging it into the board.

-Cudy
Posts: 18
Joined: Thu Apr 04, 2013 10:16 pm
by liudr » Sat Jun 15, 2013 11:15 pm
I think it's probably safe enough. With PWM you will be able to give variable power to your motor. There might be a minimal pulse width/duty cycle to keep the motor running. I would experiment the library PiGraham suggested.
User avatar
Posts: 134
Joined: Sat Jun 01, 2013 12:11 am
Location: Central MN, USA
by Gbaman » Sat Jun 15, 2013 11:24 pm
Yes, it is fine to combine the grounds, just don't combine all the live sources :)
Software based PWM is pretty simple in python using RPi.GPIO. It was only added recently so as long as you are up to date with your apt updates then you should be fine.
I will hunt around for the examples tomorrow, it was quite easy though if you know your python.
The easy way though is if I remember right, scratch GPIO has PWM support so might want to check that out
Do you love Lego and Raspberry Pis. Ever wondered what would happen if you combine them into a robot? I decided to try it out.
Check out my blog for more info

pi.gbaman.info
Posts: 40
Joined: Mon Jan 21, 2013 2:43 pm
by Cudy789 » Sat Jun 15, 2013 11:32 pm
liudr wrote:I think it's probably safe enough. With PWM you will be able to give variable power to your motor. There might be a minimal pulse width/duty cycle to keep the motor running. I would experiment the library PiGraham suggested.

Ok thanks, ill see if i can get that working. Ya right now im currently messing around with rpi gpio but ill look into it if im not satisfied with my current library.

Thank you everybody for the help! I still might have some bugs to work out but ill keep you updated!

-Cudy
Posts: 18
Joined: Thu Apr 04, 2013 10:16 pm
by Cudy789 » Thu Jun 20, 2013 6:56 pm
This should be one of my lasts posts, because i finally got it to work! So i want to start my python script right when i plug in my raspberry pi into a power source, so i don't have to plug it into a monitor and run the script manually. How would i do this?

-Cudy
Posts: 18
Joined: Thu Apr 04, 2013 10:16 pm