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 Pololu Dual DC Motor Driver 1A, 4.5V-13.5V- TB6612FNG - RobotShop something like Things wat i have done with my Raspberry Pi: Controlling BigTrack Motors with my Raspberry Pi

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

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
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.


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.


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( using PWM(for speed as well as direction). I can get rid of DC Motor Driver TB6612FNG(Pololu Dual DC Motor Driver 1A, 4.5V-13.5V- TB6612FNG - RobotShop) 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 for my usecase.

If I need motor direction control for my quadcopter, do you think I can use an ESC with direction control like 320a Brush Speed Controller ESC 1/8 1/10 Reverse for RC Car Boat Truck for sale online | eBay

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: Rover PWM output · GitHub
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?