Go Down

Topic: Arduino UNO 4 servo + two motor control pls help (Read 743 times) previous topic - next topic

charlieboi

May 21, 2018, 09:07 am Last Edit: May 21, 2018, 09:29 am by charlieboi
I am completely new to Arduino and most electronics/circuitry stuff. I'm building an IR controlled robot with a turret on top requiring 4 servos - x and y axis as well as two for firing. I need help with a circuit to power and control those servos, leaving room for two hobby motors for wheels. Is this possible without any shield or motor/servo driver? Please let me know.

I have made a circuit in Tinkercad that might work to control the servos, but there are only two PWM pins left and I'm not sure whether non-PWM pins can control the hobby motors. There is also a problem where one of the servos will not turn like the other three in the Tinkercad simulation. Not sure whether this will happen irl. Here is the link to the project: https://www.tinkercad.com/things/5D8Siv4Jaqk

Thank you in advance.

AWOL

Check the documentation for the Arduino Servo library to see if it is suitable for your requirements.

slipstick

Servos are usually controlled using the Servo library. It does not need to use the PWM pins.

If your drive motors are DC motors then you will need an H-bridge motor driver for them if you want to be able to go both forward and backward. Forward only would just need a couple of MOSFETs.

That sounds like an ambitious project for someone with no experience but most of it will have been done before so Google will have plenty of useful information. Good luck.

Steve

charlieboi

Thank you so much for replying Steve. I was not aware that PWM pins were not required for controlling servos. That information will make this project much easier for me - and I know it's a little ambitious for someone as new to this as me, but I was hoping that something like this would help develop my skills in this area quickly, and there's always Youtube and Google - like you said. If you see this reply it would be very much appreciated if you could have a quick look at the motors I want to use, because a Youtube video told me that it was possible to control them using two PWM pins set to HIGH and LOW depending on whether you wanted the motor to spin clockwise or anticlockwise, and I was planning to use this method to create forward, back, left and right controls by using the IR signals to trigger some "if" commands. Thank you again, you have saved me a lot of trouble.

motors: https://www.banggood.com/KittenBot-5V-200RPM-1-Pair-of-TT-Motor-DIY-Smart-Robot-Car-Accessories-p-1279531.html?rmmds=search&cur_warehouse=CN

*looking back at these motors made me realize that they look a bit dodgy and I'm not entirely sure whether they work or not because they haven't arrived yet. I'm just going to assume they will for now. I can always order different ones because as I'm sure you know, lots of different companies and websites sell motors that are almost exactly identical to these.

slipstick

Those motors themselves should be OK. But I would guess the information about one pin high, one pin low was actually talking about driving the motors via a motor driver like the old L298N or perhaps a more modern version.

You will need something similar because the Arduino pins definitely cannot provide enough current to directly drive any motors without damaging the Arduino.

Make sure that both the servos and the motor/motor driver are powered directly from whatever battery or power supply you will use. The Arduino only sends control signals to them NOT the main power.

Steve

gwareloth

You can even use the analog pins A0-A5 for servos, since they're digital pins anyway.


charlieboi

I trust your knowledge on this subject because you clearly have a lot of experience, but I saw this video: https://www.youtube.com/watch?v=DeJTb0f67Vc, which shows a DC motor being controlled without a driver. Is this a viable option?

gwareloth

Is this a viable option?

Short answer: No

Medium answer: No, and will damage Arduino

Long answer: No. The digital pins are unlikely to be able to supply enough current. Maximum recommended is about 20mA per pin, with 40 as absolute max. And an inductive load like a motor needs a flyback diode. To have both directions, you would need two diodes of opposite polarity, and then of course one will be a dead short in each direction.

slipstick

I trust your knowledge on this subject because you clearly have a lot of experience, but I saw this video: https://www.youtube.com/watch?v=DeJTb0f67Vc, which shows a DC motor being controlled without a driver. Is this a viable option?
Not for any real use of a motor. If you have a very small motor with no load on it, i.e. the motor isn't driving anything just sitting in the open spinning its own spindle, then you may get away with it for a few seconds. But as soon as you put a gearbox and wheels on the motor or a real propeller the current will increase to a level that damages the Arduino.

It would be easy enough to test it but you need to realise that after you've done the test you'll almost certainly need a new Arduino.

Steve

AWOL

Thank you so much for replying Steve. I was not aware that PWM pins were not required for controlling servos.   
Be aware, though, that using the Servo library will reduce the number of PWM pins available.

Go Up