How to control a DC motor?

I see documentation and examples on ESC but I don’t see on Quad copters with DC motors. Without Navio and with just Raspbeery Pi, I am able to control motor using GPIO and http://www.robotshop.com/en/pololu-dual-dc-motor-driver-1a-4-5v-3-5v-tb6612fng.html something like http://thingswatihavedonewithmyraspberrypi.blogspot.com/2012/10/controlling-bigtrack-motors-with-my.html

What pins can I use with Navio?

There are ESCs for brushed DC and brushless motors. Both are controlled with a PWM signal.
The dual motor controller in the link you posted is just like a special kind of ESC. You would connect it to a servo/ESC output of the Navio.
There are more advanced motor controllers like a sabertooth or roboclaw for robot applications. They can be controlled by a variety of signals, like analogue voltage level, serial communication and PWM too

1 Like

Thanks Sebastian.
Posting link to Servo example code here
http://docs.emlid.com/Navio-dev/servo-and-rgb-led/

Sebastian, I am able to control speed using PWM pwm.setPWMmS(NAVIO_RCOUTPUT_1, SERVO_MIN); but how to control direction? what non GPIO pins on the board should I connect to AIN1 & AIN2 of http://4.bp.blogspot.com/-ZhqvJ77REvU/UInGuL1mcJI/AAAAAAABDtE/wRHR_IEqrYo/s1600/Back+of+controller.jpg
and what sample code can I use to control the voltage from pins?

I tried connecting to Power(+) and GND(-) of channel 3(Output 1 on board) but can’t make it work or don’t know the code to use to control Power & GND

Your question leaves out a lot of details.
What did you connect to the Navio?
With PWM a 1500us puls is usually center for servos.
An aircraft ESC uses the whole PWM range (ca. 1000 -2000us) to control throttle in one direction.
A car ESC turns a motor in both directions, below 1500us backwards, above 1500us forwards.

You can not vary the output voltage of tbe Navios servo pins. The voltage is 5V and thats it.
The only way to control anything from the servo pins, is the PWM signal on the signal pin.

Edit:

Sorry, my smartphone did not load the link you posted. If this is an h-bridge based motor controller, you may have to send it some kind of a signal to switch directions. It should be described in the controllers manual.

Edit2:

I looked at the datasheet of the controller and to use it you will have to connect 6 control inputs (3 per motor). AIN1 and 2 (or BIN for the other motor)
must be set high or low to achieve braking and reversing. This will be hard to do with RPi and Navio attached. The way I would do it, is to put a microcontroller (arduino for example) between navio and the motor controller. It would convert the PWM range from the Navio to the inputs required by the motor controller.

1 Like

Thanks Sebastian.
I am looking for a way to control a brushed DC motor in a quadcopter(http://www.amazon.com/gp/product/B00D3IN11Q) using PWM(for speed as well as direction). I can get rid of DC Motor Driver TB6612FNG(http://www.robotshop.com/en/pololu-dual-dc-motor-driver-1a-4-5v-3-5v-tb6612fng.html) and use any ESC available in market.

Probably a quadcopter doesn’t need to reverse the direction of motors so the TB6612FNG I have or may be this will work
http://www.hobbyking.com/hobbyking/store/__9090__Turnigy_20A_BRUSHED_ESC.html for my usecase.

If I need motor direction control for my quadcopter, do you think I can use an ESC with direction control like http://www.ebay.com/itm/320A-Brush-Speed-Controller-ESC-1-8-1-10-Reverse-For-RC-Car-Boat-Truck-Nice-/291414834679

Hm, I thought you were going to build a rover. I really doubt that you will be happy with this quadcopter. It weighs only 130g, so if you are lucky, it has a thrust to weight ratio of 2:1.
Even with a RPi A+ and Navio you are going to add about 50g. You will spare some weight by removing the original FC/MC, but this will not be much.
Then you need a power source for the RPi/Navio combo, GPS, telemetry, another motor controller, your RC receiver, cabling and things I forget right now. By the end of your build you may have a brick that moves air, I am afraid.
I would build a copter from standard rc components. You will be a lot happier and it will be repairable.
If you need help selecting the components, feel free to ask.

1 Like

I have a similar need but for a very different project. I am building a Rover which has a single DC motor. I have an H bridge and I was intending to write some code to read in the RC throttle in values and then using some basic logic output the correct PWM values on 2 of the servo outputs (one of which is the forward PWM, the other is the backward PWM). Plug those into the H-bridge and boom, my rover can go forward and backwards.

I wrote a python script to do just that: https://gist.github.com/bradleyscott/06fda582d37c012e357df1806adf4c46
But then I realised that you can only run this when Arducopter is NOT running. Which defeats the point.

What is the correct way to achieve something like this?

This post was flagged by the community and is temporarily hidden.