I'm currently working on a project where I have build a RC car with one DC motor (forward/backward) and one servo motor (steering). I'm a newbie with electronics so I figured out by myself I needed a motorhat shield for my Raspberry pi 3 B model. Problem is, that it only can run DC motors or stepper motors.

My question is: how can I control my servo motor as well as my DC motor at the same time?

  • 1
    \$\begingroup\$ This is probably not a good application for a raspberry pi, rather it calls for a flash-based MCU (Arduino, nRF BLE chip, ESP whatever, etc). That doesn't impact the DC motor control much, but producing the PWM signals for a hobby servo tends to be tightly specific to the controller you are using. \$\endgroup\$ – Chris Stratton Mar 4 '19 at 20:15
  • \$\begingroup\$ Reason why I use a pi, is because I want to make the car autonomous in combination with Android Things. \$\endgroup\$ – Carlo Matulessy Mar 23 '19 at 9:04
  • \$\begingroup\$ That may be your desire, but it is unlikely to work well. What specific aspect of Android things do you believe justifies the difficulty and the need to always command the pi to shutdown before removing power. \$\endgroup\$ – Chris Stratton Mar 23 '19 at 9:27

DC motor (forward/backward functionality) should be controlled by H-bridge. There are a lot of ICs and PCB modules/boards for this purpose. Basically you can use any of them (depends on you DC motor parameters, of course).

Servo is not stepper. Servo is controlled by just 1 control pin by PWM frequency (digital pin), so you don't need any special IC or board for this.

So, you can connect H-bridge IC to several (4-6) digital pins of RPI, and servo to another PWM digital pin.

| improve this answer | |
  • \$\begingroup\$ Hi sorry for asking so late, but can you help me out with some links what to buy to achieve my goal? Thanks (newbie level on eletronics here) \$\endgroup\$ – Carlo Matulessy Mar 17 '19 at 20:57
  • \$\begingroup\$ @CarloMatulessy You didn't provide any DC motor parameters (e.g. voltage and current), so it's hard to recommend you something definite. There are several widely used ICs/modules for standard "toy size" RC cars models. Try to google something like "dc motor H-bridge tutorial". The most popular of them are: L293(D), L298, but they are rather old designs used bipolar transistors. Look at something newer with MOS transistors like L9110S, MX1508 or TB6612FNG modules. For servo you don't need to buy anything, but make sure that you servo works with 3.3V signal from RPI (or use level shifter). \$\endgroup\$ – cyclone125 Mar 17 '19 at 22:42
  • \$\begingroup\$ These are the DC and servo motor I have: conrad.nl/p/… and conrad.nl/p/adafruit-169-motor-1516595. I was looking at the explorer pHAT module for the pi, is this compatible with the two motors I just shared? kiwi-electronics.nl/… \$\endgroup\$ – Carlo Matulessy Mar 23 '19 at 9:03
  • \$\begingroup\$ @CarloMatulessy No, Explorer pHAT is not suitable to drive such a high power motor. Look, this motor consumes 1,1 A current with no load, and 6,6 A with max efficiency, and up to 33 A at start. DRV8833 IC on pHAT can supply max 0.5...1,5 A continuous and 2 A peak current at each channel (note, that pHAT datasheet itself states that it can supply only 0,2 A per channel!). I don't know why do you want to use this motor, as it is very high rotation speed and low torque, which is not suitable for RC-car. It could be also too powerful for RC-car, as it will drain the battery within several minutes. \$\endgroup\$ – cyclone125 Mar 24 '19 at 2:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.