Jump to content
 

Simple servo controller


Dartmothian
 Share

Recommended Posts

The main issue with simple two value resistor switching circuits is that the servo will always move at its maximum speed between one position and the other, which may be rather fast (and rather noisy, if brief).

 

Hi Gordon,

 

That will depend on the change in the angle of the servo's horns. It's always best to make the angle a large as possible because that reduces the torque that tends to "back-drive" the servo.

 

Andy

Link to post
Share on other sites

I should have mentioned that you can slow down the servo's speed by decreasing the pulse frequency. The maximum pulse frequency is 50 Hz to produce the maximum rotation speed, but there is nothing wrong with using a much lower pulse frequency to slow down the rotation. In the 555 circuit above the frequency is controlled (mostly) by the 270 k resistor. A 500 k resistor will approximately half the pulse frequency.

 

Another option is to use two of these circuits to drive as many servos as you like. One circuit is set to produce wide pulses and the other is set to produce narrow pulses. You select which pulse stream to send to each servo with a single pole changeover switch. Of course all the servos will rotate through the same angle and you'll have to use a mechanical arrangement to adjust the throw at the points but a large angle (around 140 degrees) is preferable to prevent "back driving".

Link to post
Share on other sites

Pulse frequency does not set the speed of rotation, some may respond this way but it should not be relied upon. It is purely the pulse width that sets the position, and the servo will move to this position. On analogue servos they will usually move slowly if the positional change is small, but a digital servo will move at full speed.

Link to post
Share on other sites

Pulse frequency does not set the speed of rotation, some may respond this way but it should not be relied upon. It is purely the pulse width that sets the position, and the servo will move to this position. On analogue servos they will usually move slowly if the positional change is small, but a digital servo will move at full speed.

 

Yes, that's quite correct. I should have made it clear that I was referring to the ubiquitous SG90 analog servo. AFAIK all analog servos use the same "pulse stretching" method, so It probably works with other analog servos too, but it would be best to test a sample to make sure. It definitely will not work with digital servos.

Link to post
Share on other sites

Can anyone suggest a simple circuit for a basic servo controller for one or two turnouts

Here is a link to the N Gauge Forum (you may need to register with the forum to view).

One of the members has an excellent decription of how to "hack" a servo to make it drive continuously and then show how to turn it into an excellent point actuator. Converting a servo like this is both cheap and effective and has multiple uses (not exclusively N Gauge! ).......for points, signals, gates etc. Hope this helps.

 

http://www.ngaugeforum.co.uk/SMFN/index.php?topic=32488.msg380059#msg380059

Link to post
Share on other sites

 to make it drive continuously and then show how to turn it into an excellent point actuator.

I imagine that making it into a continuous servo (aka DC motor) would make it more difficult to use a servo for point and signal control.

 

...R

Link to post
Share on other sites

Here is a link to the N Gauge Forum (you may need to register with the forum to view).

One of the members has an excellent decription of how to "hack" a servo to make it drive continuously and then show how to turn it into an excellent point actuator. Converting a servo like this is both cheap and effective and has multiple uses (not exclusively N Gauge! ).......for points, signals, gates etc. Hope this helps.

 

http://www.ngaugeforum.co.uk/SMFN/index.php?topic=32488.msg380059#msg380059

 

Hi Dave,

 

If you don't mind tearing the servo apart the motor and gear reduction make a great basis for a point motor. I like this method because it eliminates the need for any special controller and there is no possibility of the jittering, twitching, buzzing or ticking that some people experience with servos.

 

Here's a similar hack:

 

http://www.rmweb.co.uk/community/index.php?/topic/96929-no-stall-servo-point-motor-servo-hack/?hl=%2Bservo+%2Bhack

 

Andy

Link to post
Share on other sites

  • 3 weeks later...

Here is something else to consider, pretty cheap and no electronics degree required

 

Heath-Robinson is alive and well. Of course, taking account of the accent I should say Rube Goldberg.  :)

 

...R

Edited by Robin2
Link to post
Share on other sites

Pulse frequency does not set the speed of rotation, some may respond this way but it should not be relied upon. It is purely the pulse width that sets the position, and the servo will move to this position. On analogue servos they will usually move slowly if the positional change is small, but a digital servo will move at full speed.

 

Analog and the simple digital servos always move at full speed, they have no speed control. If the position change is small then the movement is small. If the position is updated slowly by small increments then the servo moves at full speed between the two points. The net effect is of moving at slow sped.

 

The fully programmable digital servos are a different beast altogether.

Link to post
Share on other sites

Analog and the simple digital servos always move at full speed, they have no speed control.

 

Because the analog servo controller supplies pulses to the motor it's true that power to the the motor is either "off" or "on", but the motor has inertia and the controller modulates the pulse widths. The greater the "error", the wider the drive pulses etc, so the average motor voltage does vary to create a basic form of speed/acceleration control.

 

At full speed (maximum error) a SG90 servo rotates about 10 degrees every time it receives a drive pulse. It takes at least 12 drive pulses to rotate through 120 degrees and at the maximum pulse rate of 50 pulses per second that movement will take about one quarter of a second. If the pulse rate is reduced to 25 pulses per second the same angle will require half a second. Of course, if you slow the pulse rate down too much you can see (and hear) the servo move in a series of steps rather than a sweeping motion.

Link to post
Share on other sites

Because the analog servo controller supplies pulses to the motor it's true that power to the the motor is either "off" or "on", but the motor has inertia and the controller modulates the pulse widths. The greater the "error", the wider the drive pulses etc, so the average motor voltage does vary to create a basic form of speed/acceleration control.

I may be misunderstanding this but it sounds as if the control of the motor by the electronics inside the servo is being mixed up with the signals that are sent to the servo to identify the angle it should be at. The PWM control of the motor by the internal electronics is likely to be at a frequency of 1kHz or 10kHz or maybe even more. It will be independent of the frequency or width of the pulses sent to the servo, only taking account of what is needed to keep the servo at the desired position - which could be anything between zero and max power.

 

...R

Link to post
Share on other sites

Analogue servos have analogue electronics in them which integrates the positive going part of the pulse to produce a reference voltage which is compared to the voltage produced by the feedback potentiometer in a comparator which amplifies the difference and applies it to the motor. The comparator/amplifier does not have infinite gain so for small movements does not apply full voltage to the motor. Due to having to reset the integrator after every pulse (which are expected every 20mS) there is only a small window when the analogue servo can apply power to the motor before having to wait for the next pulse. It is not smoke and mirrors or new fangled PWM technology, it is old fashioned simple analogue electronics made of monostables and op-amps with a few resistors and capacitors thrown in. 

 

Electronically speaking an analogue servo is far more complex (and expensive to make) than a digital one - hence why the fake SG90s have digital electronics in them and they are not actually analogue! 

Link to post
Share on other sites

The only way to control speed is to adjust the rate at which the pluse width changes from the present position to the new position.

 

So you divide the difference in pulse width between the two positions by say 10 and then change the delay between each incremental pulse change. The longer the delay the slower the speed of the servo.

Edited by meil
Link to post
Share on other sites

The only way to control speed is to adjust the rate at which the pluse width changes from the present position to the new position.

So you divide the difference in pulse width between the two positions by say 10 and then change the delay between each incremental pulse change. The longer the delay the slower the speed of the servo.

This produces the classic slow speed stutter you see on simple controllers, the correct method is to insert as many change of position pulses just greater then the deadband as needed ax this is the smallest increment you can control

Link to post
Share on other sites

This produces the classic slow speed stutter you see on simple controllers, the correct method is to insert as many change of position pulses just greater then the deadband as needed ax this is the smallest increment you can control

A nuance on a theme.

Link to post
Share on other sites

There seem to be some misconceptions about how analog servos work. This is what I understand about the SG90. (Other analog servos may be different.)

 

The SG90 uses a controller that is a derivative of the ancient Signetics NE544 Servo Amplifier. It's actually a lot more digital than analog :)

 

The rising edge of an input pulse starts a cycle. The width of the input pulse determines the desired position. When the cycle starts the controller also produces an internal pulse. The width of the internal pulse is determined by the current position of the servo. The controller effectively compares the width of the input pulse with the width of the internal pulse. That produces another pulse the width of which represents the "error". If the error pulse is greater than a defined "dead-band", the error pulse is stretched and applied to the drive circuit that turns on the motor.

 

The error pulse has to be stretched a lot to turn on the motor. My guess is the motor drive pulse is something like ten to fifteen times longer than the error pulse and it looks like the relationship isn't exactly linear.

 

The motor direction is determined by the race between the input pulse and the internal pulse. If the input pulse ends before the internal pulse, the steering logic drives the motor in one direction and vice-versa it ends after the input pulse.

 

I've probably left out a few details, but that's pretty much all there is to it. The NE544 datasheet has a nice circuit diagram if you are interested.

Link to post
Share on other sites

The only way to control speed is to adjust the rate at which the pluse width changes from the present position to the new position.

 

I'll probably have to post a video on Youtube to convince you that you absolutely can control the speed by altering the pulse frequency.

Link to post
Share on other sites

So back to basics for a bit. The simple circuit in post #22 switches from one value of resistance to another to switch from one position to another. If I substitute a variable resistor for this arrangement I can rotate this pot slowly to move the servo as slow as I like. Could I add a capacitor across the fixed resistor arrangement to effect a slow change from one value to the other, or is that too simplistic ?

Link to post
Share on other sites

So back to basics for a bit. The simple circuit in post #22 switches from one value of resistance to another to switch from one position to another. If I substitute a variable resistor for this arrangement I can rotate this pot slowly to move the servo as slow as I like. Could I add a capacitor across the fixed resistor arrangement to effect a slow change from one value to the other, or is that too simplistic ?

 

Alas, no :)

 

But assuming you are using a SG90 servo, you can increase the value of the 270k resistor to slow down the pulse frequency and that will slow down the speed. (Not everyone agrees with this :) ) You might try 390k or 470k. As you increase the value you will start to see that the servo is moving in a series of steps. Whether that's a problem or not will depend on what you are doing with the servo.

 

You could also add a 500k variable resistor in series with the 270k resistor to allow you to experiment with speed adjustment.

Link to post
Share on other sites

Ok, so next thought. How about this, hope it makes sense. A mechanical solution. The pot size would need some work as we are only using a small portion of the possible rotation. It would probably be possible to use presets or skeleton pots mounted on pieces of PCB, but the levers could easily be made to look like genuine point levers. 

 

post-15258-0-46808300-1514899291.png

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...