Automatic Polarity Reverse without Arduino for MicroServo Control

Thread Starter

APires

Joined Mar 29, 2022
7
Hello!
First post here in this forum!

I will be using a SG90 MicroServo to perform an automatic/no-human-interaction rotation movement along one axis from, for example, 0 to 15 degrees of rotation after being powered on. These values are not fixed yet, so it might be 0 / +20, as I am still building my contraption. Even though exact precision is not required, I do want it to move slowly.
Several numbered questions for an easier answer:

1. One straightforward way would be to use an Arduino and, instead of a POT to control the PWM length/duration, an automatic varying function from -x to +x value that could replicate the human interaction of rotating a POT. This said, how do you limit the speed at which the servo rotates? Limiting the current or the voltage, and how would you do it? Thing is...
2. Imagine I don't want to use an Arduino - I can remove the feedback POT from the servo and just control its direction of rotation by swapping polarity between VCC and GND, since they use simple Brushed DC Motors. Now I just need something that automatically reverses polarity.
2.1. What kind of electronic component can I use or what circuit can I build that every x seconds reverses the polarity on its output (i.e., where the servo power wires would connect)? Ideally it would take around 5-10 seconds between its maximum - and + amplitudes that I am still to define. How easy to tweak are these polarity reverse circuits or components?​
2.2. Assuming the motor will still be moving way faster than I want it to, what would be the solution to move it slower? Does it generally come integrated in any component that I can buy to reverse the polarity, or I'd be able to do it by supplying different voltages or reducing the amps flowing to the motor with resistors?​
I'd rather have it without the micro controller since for this task it is an overkill. It is basically just a tilting mechanism, to behave much like a pendulum, slowly and without the need of being too accurate at all. Ideally, all I do is flip a power switch manually and the mechanism would start penduluming by itself - not yet decided if I want it to take 3 seconds to move to each side, or 10, but that's it. I'd have a small set of batteries for power, the reverse polarity component, and the servo.

I am 100% open to suggestions, and feel free to ask for some extra explanation in case something is not clear for you.
Cheers!
 

Thread Starter

APires

Joined Mar 29, 2022
7
hi AP,
Welcome to AAC,
You appear not to know how a Servo is Driven/Controlled.
Have you done any work with the SG90?
E
I've worked with similar stuff for controlling Ailerons/Rudders and so on in RC Planes, but I am mostly tasked with the mechanical connections and electrical wiring, not deciding the components.
I am struggling to find an alternative that could negate the need of an Arduino board for this dumb purpose, even if in the end I use the micro controller.
I am typically not too dumb with these things, but now I am scared by what you said haha!
 

ericgibbs

Joined Jan 29, 2010
18,766
hi AP,
Don't be scared.;)
Look at the Blue image I posted.
At Rest, the Servo pulses are High/On for 1.5mSec period.
Clockwise rotation 2mSec
AntiClock rotation 1mSec

E
BTW: the Frequency of the pulses is commonly at 50Hz ie: 20mSec
 

Thread Starter

APires

Joined Mar 29, 2022
7
hi AP,
Don't be scared.;)
Look at the Blue image I posted.
At Rest, the Servo pulses are High/On for 1.5mSec period.
Clockwise rotation 2mSec
AntiClock rotation 1mSec

E
BTW: the Frequency of the pulses is commonly at 50Hz
The image didn't load until I refreshed the page, for some reason!
So, I understand the PWM component of a servo, and I believe there is some IC Timer chip that's commonly used to produce a PWM signal without the need of an actual MicroController (Arduino).
I know, from all the googling I have already done, that you can bridge the feedback potentiometer built in in the Servo so that by simply powering the VCC and GND cables that come out of the servo (the 3rd one is the PWM), you have a freely rotating motor that doesn't care about positioning anymore. By flipping polarities, you can get CW or CCW movement. I like the servo packaging and the motor + integrated gearbox is perfect for my purpose, but I am basically using it as a DC Motor.

How can you automatically flip polarities on a DC motor? I've heard H Bridges can do that, but I am unsure how I can time how long it moves on each direction, and how I can have it moving faster or slower.
TLDR: Title is probably dumb, as I am using the Servo as a DC Motor instead. What circuit/component exists that flips polarity, and how can I mess around with the rotation speed of the motor?

Thanks for your time!
Pires
 

ericgibbs

Joined Jan 29, 2010
18,766
hi AP,.
A short description.
Consider that on power up, the Controller sends a pulse of 1.5mSrc to the SG90 servo every 20mS.

The servo shaft would rotate to say to 0 deg.

If the pulse width of 1.5mSec was slowly increased every 20mSeec up to a maximum of 2mS, the shaft would rotate 90 deg Clockwise.
If the pulse width was slowly decreased to 1mSec the shaft would slowly rotate to -90deg.

So you have shaft rotation control over a +/-90 degrees, with ability to stop the shaft at any angle between +/-90 degrees by sending the correct pulse width.
E
 

djsfantasi

Joined Apr 11, 2010
9,156
You’ve mentioned several requirements in addition to back and forth movement. In particular, the speed of the motion

First, reversing the direction of an RC servo is NOT done with reversing polarity. Acting as if it was a DC motor is a good way of destroying the servo.

Similarly adjusting speed by controlling voltage or current will also cause trouble with the servo.

An RC servo has an internal potentiometer connected to a small circuit board. When the output of the board equals the input signal, the servo stops.
 

Ya’akov

Joined Jan 27, 2019
9,071
Why do you object to an MCU? You could do this whole thing, flexibly, primarily with one 8=pin ~$2.00 part like an ATTiny13a and put it on your own circuit board. No "Arduino" in sight.
 

Thread Starter

APires

Joined Mar 29, 2022
7
hi AP,.
A short description.
Consider that on power up, the Controller sends a pulse of 1.5mSrc to the SG90 servo every 20mS.

The servo shaft would rotate to say to 0 deg.

If the pulse width of 1.5mSec was slowly increased every 20mSeec up to a maximum of 2mS, the shaft would rotate 90 deg Clockwise.
If the pulse width was slowly decreased to 1mSec the shaft would slowly rotate to -90deg.

So you have shaft rotation control over a +/-90 degrees, with ability to stop the shaft at any angle between +/-90 degrees by sending the correct pulse width.
E
Hmm, ok, that answers perfectly my 'How to move it slow or fast' - I simply slowly change the input variable that my MCU reads to decide the pulse width, so that it also changes slowly. Since the 1ms to 2ms range decides its shaft position and IIRC the servo always tries to move as fast as it can to the desired position (depending on the PWM reaching it), if I slowly increment the signal, it will indeed move slowly.
For some reason I was thinking that the best option would be to starve it of either voltage or current to reduce its speed, and simply wait for it to reach its target position. Not some reason, just my typical overthinking when I don't really know what I am talking about :D

Now that I know this, using the 555 IC Timers that can replicate/produce a PWM signal makes sense. I just need the PWM to vary slowly between my ranges, and that is it. Any specific document or page where I can grab some info on how I can limit the range (from 1.1 to 1.4ms for example , since I just want a 30-40 degree arc movement from start to end) and make it vary the PWM output slowly to keep the shaft movement also slow?

Thanks a lot Eric.
Eye opening stuff.
 

Thread Starter

APires

Joined Mar 29, 2022
7
You’ve mentioned several requirements in addition to back and forth movement. In particular, the speed of the motion

First, reversing the direction of an RC servo is NOT done with reversing polarity. Acting as if it was a DC motor is a good way of destroying the servo.

Similarly adjusting speed by controlling voltage or current will also cause trouble with the servo.

An RC servo has an internal potentiometer connected to a small circuit board. When the output of the board equals the input signal, the servo stops.
Thanks for your answer!
There's people bridging the potentiometer with fixed resistors on that internal circuit board to transform servos in continuous moving motors. There's also people removing all the wires and completely disconnecting the circuit board from the 2 DC Motor power wires and, by doing so, you get CW or CCW rotation by simply flipping the polarity.

Imagine I do that, and I have a simple DC Motor (and I definitely can treat it as such if I wire my power supply directly to its cables). How do you limit its speed? Isn't it by limiting the voltage across it? It is an almost 0 torque application, so the motor itself will never be under actual stress IMO.
I lack a lot of Basics in motor control, so my suggestion might be dumb indeed.
Oh, and I am absolutely sure you are right, I don't doubt that. I am probably just being picky and, in the end, overcomplicating by not wanting to use a MC, but I would like to know if there's a possible workaround to using a MC or not.
 

KeithWalker

Joined Jul 10, 2017
3,063
If you do not plan on using the servo to rotate more than it's built in limit of 180 degrees, don't destroy a perfectly good serve.
The position of the servo depends on the length of positive pulses supplied to it. 0.5mS will set it to one extreme. 2.5mS will drive it through 180 degrees to the other extreme. There is a linear relationship between the servo position and the pulse length for anything between the two extremes.
The rotation speed of the servo is specified for a standard R/C system which has a pulse repetition rate of 18mS. The speed can be reduced by increasing the time between the pulses. At very low speeds, the movement will be a little bumpy but if the speed and position are all that is required, that should not be a problem.
From the above, you can see that you need a source of pulses that can vary in length from 0.5 to 2.5ms with a fixed repetition rate greater than 18mS. You will need something that will switch the length of pulses between one length and another.
You will need to decide on the servo speed, pulse lengths and time between reversals.
 
Last edited:

Thread Starter

APires

Joined Mar 29, 2022
7
Why do you object to an MCU? You could do this whole thing, flexibly, primarily with one 8=pin ~$2.00 part like an ATTiny13a and put it on your own circuit board. No "Arduino" in sight.
I'd need the flexibility to define its range and motion speed at the start, a bit by trial and error, but after that it is quite fixed.
Pardon my ignorance, but those tiny chips require a programmer, right? I have just enough knowledge on Arduino to make use of the Servo libraries and tweak them a little, but close to nothing when it comes to programming IC and the common SWs used.

I am probably just being picky not wanting to use a MCU.
I'll probably go for a clone of a Nano - I want to keep whatever electronics I use as small and closed as possible, since the environment is quite dirty. I just think it would be easier to easily seal a small perf board with a small number of components than an arduino board with some kind of electrical tape, but it might be just as easy (or just as hard!).

I am testing a small mechanism for Metal BJT 3D printing depowdering phase. We are using powdered stainless steel and I can tell you it is a real mess, since all those micron particles keep floating for several minutes and get every-fu**ing-where.

Anyway, thanks for your help! Sometimes all I need is a blunt 'stop being dumb and do not overthink dumb tasks'. :D
 

Thread Starter

APires

Joined Mar 29, 2022
7
If you do not plan on using the servo to rotate more than it's built in limit of 180 degrees, don't destroy a perfectly good serve.
The position of the servo depends on the length of positive pulses supplied to it. 0.5mS will set it to one extreme. 2.5mS will drive it through 180 degrees to the other extreme. There is a linear relationship between the servo position and the pulse length for anything between the two extremes.
The rotation speed of the servo is specified for a standard R/C system which has a pulse repetition rate of 18mS. The speed can be reduced by increasing the time between the pulses. At very low speeds, the movement will be a little bumpy but if the speed and position are all that is required, that should not be a problem.
From the above, you can see that you need a source of pulses that can vary in length from 0.5 to 2.5ms with a fixed repetition rate greater than 18mS. You will need something that will switch the length of pulses between one length and another.
You will need to decide on the servo speed, pulse lengths and time between reversals.
There's a lot of good stuff here.
I do not mind the servo being a bit jerky when moving, as long as it is slow. Even if it is discrete steps and not a continuous movement between the ranges that I want it to move, if it is slow enough it should work good.
I assume your answer 'forces me' to use an Arduino/PLC or some PWM generating circuit that has that 555 IC Timer. Which one would you choose? I am quite decent at soldering and interpreting schematics so I just need to know what to buy, how to connect them and how I am able to tweak the PWM length and range using one of those Timer ICs automatically, without requiring me to rotate a POT back and forth (if that's even possible).
If it is simpler in your opinion to go for an Arduino, just say so! ^^ I like to build my own stuff so if I have to complicate a little by building a circuit that performs just as good as the Arduino would, I'd probably go for it.
 

Ya’akov

Joined Jan 27, 2019
9,071
I'd need the flexibility to define its range and motion speed at the start, a bit by trial and error, but after that it is quite fixed.
Pardon my ignorance, but those tiny chips require a programmer, right? I have just enough knowledge on Arduino to make use of the Servo libraries and tweak them a little, but close to nothing when it comes to programming IC and the common SWs used.

I am probably just being picky not wanting to use a MCU.
I'll probably go for a clone of a Nano - I want to keep whatever electronics I use as small and closed as possible, since the environment is quite dirty. I just think it would be easier to easily seal a small perf board with a small number of components than an arduino board with some kind of electrical tape, but it might be just as easy (or just as hard!).

I am testing a small mechanism for Metal BJT 3D printing depowdering phase. We are using powdered stainless steel and I can tell you it is a real mess, since all those micron particles keep floating for several minutes and get every-fu**ing-where.

Anyway, thanks for your help! Sometimes all I need is a blunt 'stop being dumb and do not overthink dumb tasks'. :D
Yes, you do need a programmer but that’s not an issue. It will cost you less then $10. You can use the Arduino IDE to write the code. Size is no issue. It is literally one 8 pin DIP package and a few passives. You might also need a 3 pin voltage regulator.

The ATTiny 85 is an excellent candidate. There are boards that provide a socket for the IC and the pin header for the programmer. It’s very easy. You program the IC, and put it in a socket on your board. You can even put a programming header on yout own board. You don’t need an elaborate MCU development board.
 

KeithWalker

Joined Jul 10, 2017
3,063
It would be cheaper and less time consuming to use an Arduino if you are already familiar with the Arduino IDE and programming the microcontrollers, If you are not, there will be a very steep learning curve for you, but we are here to help. I would choose a Uno or Nano to avoid having to use an additional programmer (unless you already have one). They are both vast overkill for what you want to achieve but if you build on a breadboard, you can always re-use them on future projects.
 

Ya’akov

Joined Jan 27, 2019
9,071
It would be cheaper and less time consuming to use an Arduino if you are already familiar with the Arduino IDE and programming the microcontrollers, If you are not, there will be a very steep learning curve for you, but we are here to help. I would choose a Uno or Nano to avoid having to use an additional programmer (unless you already have one). They are both vast overkill for what you want to achieve but if you build on a breadboard, you can always re-use them on future projects.
The programmer above with two ATTiny 85s is ~20 bucks. He was already talking about protoboarding, and he can use the Arduino IDE for development. That programmer also has sockets for pin access to do prototyping. There really is no more complexity with this combination than any Arduino board and it is much smaller for his use.
 

KeithWalker

Joined Jul 10, 2017
3,063
The programmer above with two ATTiny 85s is ~20 bucks. He was already talking about protoboarding, and he can use the Arduino IDE for development. That programmer also has sockets for pin access to do prototyping. There really is no more complexity with this combination than any Arduino board and it is much smaller for his use.
I buy Nanos from AliExpress for $3.23CD (including shipping). I have never had a bad component yet. They have a USB interface for plugging into the computer to downlod programs direct.
 
Top