Using a 556 to control RC servo speed

Discussion in 'The Projects Forum' started by MikeK, Apr 1, 2016.

  1. MikeK

    Thread Starter Member

    Apr 1, 2016
    33
    0
    servo2.gif
    I'm using a 556 to slow down a Tower Pro SG 90 servo for a model railroad crossing gate. I'm using 'Frequency' to control speed, 'High-Time' to control position. Anyway, the action is a little jerky at the speed I like. I would like to smooth this out. Any ideas?
     
  2. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,689
    901
    Using frequency to control servo speed is an old way to do that and will result in jerkiness. In my experience, the range of available speeds is very limited. Above about 100 to 120 Hz, movement is extremely jerky. I suspect the same at very low refresh rates. I did those experiments about 10 years ago and don't recall the details. My advice is to use a microcontroller and slowly ramp up or down the pulse width to control speed.

    John
     
  3. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,031
    3,803
    I thought most servos want 50Hz and you control the "high" time to control position of the servo.
     
  4. bertz

    Member

    Nov 11, 2013
    238
    31
    Couple of things:
    It is poor practice to power the servo from the same supply as the controller. Best to use a separate supply. Insert a 330 ohm resistor in series with the white (signal lead) going to the servo. Also, put a 0.1 uF cap across the red and black wires. Most low priced servos use brushed motors and they are noisy as hell.
    If that doesn't solve your problem, do as JPH suggests and use a microcontroller. I would use a PICAXE since they are cheap, easy to program and have lots of uses in a model RR. I could post the code for you if that is the direction you think you might want to go.
     
    MikeK likes this.
  5. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,797
    1,103
    Here's a simple alternative solution.
    SlowServo.PNG
    R4/R5/U1a/U1b form a wide-hysteresis Schmitt trigger which, with R6/C3 makes a fixed frequency ~ 50Hz oscillator. The pseudo-triangle wave output taken from C3 is summed by R8/R9 with a control voltage from cap C4. The sum is the input to gate U1c, which generates a square wave with a pulse-width dependent on the control voltage. Flipping the switch will cause the pulse width to go from <1mS to >2mS or vice versa over an interval set by R7/C4. With the component values shown this is about 5 secs.
     
    Bernard likes this.
  6. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,541
    2,369
    @MikeK For future, can you place RC in the title then is avoids unnecessary reading/deciphering of the posts when using the broad universal term 'Servo'.;)
    Max.
     
    JohnInTX and MikeK like this.
  7. bertz

    Member

    Nov 11, 2013
    238
    31
    Here is an alternative using a microprocessor, in this case a PICAXE 08M2. In this scheme an approaching train triggers a signal to the microprocessor to initiate the closing of the gate. For purposes of this example, the signal to close the gate will be a logic HIGH on pin C.1.

    When pin C.1 goes HIGH it initiates the closing sequence. The speed of closing is governed by the pause command. A longer pause will result in a slower gate motion. When the train passes, pin C.1 goes LOW which initiates the raising sequence. Here is the code:

    Code (Text):
    1. '******************RR Crossing Gate.bas****************
    2. 'Version 1.0
    3. 'AJZ/April 1, 2016
    4. 'this code is used to drive a servo operated crossing gate
    5. 'based on a digital input signal
    6.  
    7. '====Input=======
    8. symbol trigger = pinC.1        'signal to raise & lower the gate
    9.  
    10. '===Outputs===
    11. symbol gate_Servo  = C.2    'PWM out to servo
    12.  
    13. '===Variables===
    14. symbol pos0 = b0
    15.  
    16. '===Directives===
    17. #com 3                'specify serial port
    18. #picaxe 08M2            'specify processor
    19. servo gate_Servo, 150        'make sure gate is in raised position
    20. pause 500
    21.  
    22. main:  
    23. do
    24.     if trigger = 1 then        'train detected
    25.         exit
    26.     end if
    27. loop while trigger = 0
    28. gosub activate              
    29.  
    30. activate:
    31. for pos0 = 150 to 80 step -1         'lower the gate
    32.     servopos gate_Servo, pos0
    33.     pause 5                'sets the lower speed
    34. next pos0
    35. do
    36. if trigger = 0 then            'train clears the sensor
    37.     exit
    38. end if
    39. loop while trigger = 1
    40. pause 500                    'pause to let the last car clear
    41. for pos0 = 80 to 150             'raise the gate
    42.      servopos gate_Servo,pos0  
    43.     pause 5                'sets the gate speed
    44. next pos0
    45.     goto main
    46.  
    And here is the circuit:

    crossing gate.jpg
     
  8. MikeK

    Thread Starter Member

    Apr 1, 2016
    33
    0
    Thanks Bertz (and all other replies). I'll try your recommendations before going the PICAXE route. I'm trying to keep this simple.
    PS, how would I power the servo from a different supply on a model train setup? The track power box has an AC accessories output of about 18 volts, which really heats up my bridge/7812. I've gone to using a larger voltage regulator with it's own bridge.
     
  9. bertz

    Member

    Nov 11, 2013
    238
    31
    Use one of these.
     
  10. MikeK

    Thread Starter Member

    Apr 1, 2016
    33
    0
    Thanks, I'll do some tests. Maybe I'll use another one to power the rest of the crossing controller, instead of the whole track transformer-accessory outlet-power supply route. Less mess, and it leaves the accessory outlet for some other use.
     
  11. MikeK

    Thread Starter Member

    Apr 1, 2016
    33
    0
    I've built a circuit board using IC chips (74ls123 voltage comparator for photosensors, a 556 to control the servos, a 555 to control the flashers, and a dpdt relay between the sensor chip and the servo chip to determine up or down on the gates). The circuit operates fine away from the track, but every time I connect or even get near the track and run a loco, the circuit picks up noise and acts up. Just turning on the track controller is picked up, triggers a reaction from the 74ls123. I have put .1uf disc caps on the track bus and only feed battery power to the crossing controller. I tried snubbers, and a home-made Butterworth filter. Still the controller picks up the noise. My test track is a circle. DC.
    Any clues?
     
  12. bertz

    Member

    Nov 11, 2013
    238
    31
    Perhaps the 74LS123 is the wrong chip to use in this application. Consider the following taken directly from the TI application notes:

    Special Considerations

    Because these monostable multivibrators are half analog and half digital, they inherently are more sensitive to noise on the analog portion (timing leads) than standard digital circuits. They should not be located near noise-producing sources or transient-carrying conductors and liberal power-supply bypassing is recommended for greater reliability and repeatibility.

    Also, a monostable should not be used as a fix for asynchronous systems; synchronous design techniques always provide better performance. For time delays over 1.5 s or timing capacitors over 100 mF, it is usually better to use a free-running astable multivibrator and a couple of inexpensive decade counters (such as a 7490A) to generate the equivalent of a long-delay one-shot. Astable oscillators made with monostable building blocks have stabilities approaching five parts in 100 and should not be used if system timing is critical. Crystal oscillators provide better stability.In all one-shot applications, follow these guidelines:

    • Use good high-frequency 0.1-mF (ceramic disk) capacitors, located 1 to 2 inches from the monostable package, to bypass VCC to ground.

    • Keep timing components (Rt, Ct) close to the package and away from high transient voltage or current-carrying conductors.

    • Keep the Q-output trace away from the CLR lead; the negative-going edge when the one-shot times out may cause the C lead to be pulled down, which may restart the cycle. If this happens, constantly high (Q = H, Q = L) outputs with 50-ns low spikes will occur at the repetition rate determined by Rt and Ct. If sufficient trace isolation cannot be obtained, a 50-pF capacitor bypassing the C lead to ground usually eliminates the problem.

    • Beware of using the diode or transistor protective arrangement when retriggerable operation is required; the second output pulse may be shorter due to excess charge left on the capacitor. This may result in early time out and apparent failure of retriggerable operation. Use a good capacitor, one that is able to withstand 1 V in reverse and meet the leakage current requirements of the particular one-shot.

    • Remember that the timing equation associated with each device has a prediction accuracy. Generally, for applications requiring better than ±10% accuracy, trimming to pulse duration is necessary.
     
  13. MikeK

    Thread Starter Member

    Apr 1, 2016
    33
    0
    Thanks, I'll check my board against your recommendations. I have these little .1uf caps, the size of a small aspirin, will they do, or do I need the ones the size of a penny? (to bypass VCC to ground) I also have ones that are rectangular, purse-shaped.
    The timing equation is probably ok, since I'm using a relay after the 74ls123, and using it's quick pulse to power a latching coil in the relay.
    When the 123 is acting up, it rapidly fluctuates between the Q outputs. I have LEDs on the other relay pins to show me that the sensors are activated, and they flash rapidly alternately. The relay doesn't like that, I've already failed one. I expect the coils see parallel current, and one can't take it, just guessing.
     
  14. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,031
    3,803
    The size/shape/color of the cap is not important. The important part of the rating for voltage. There are other cap ratings but they seem to matter less when used as a simple timing capacitor for an application where this level of accuracy is needed. I have not see ceramic caps rated at less than 50V so you are likely ok with what you have. The big ones can be rated for 1000 V or more.
     
  15. bertz

    Member

    Nov 11, 2013
    238
    31
    This thread is no good without pictures! Please post your circuit diagram - that way we can see what's going on. By the way, do you have a diode across the relay coil?
     
  16. MikeK

    Thread Starter Member

    Apr 1, 2016
    33
    0
    I'll try to put together a diagram, I make drawings of both sides of the board, from datasheets and breadboard work. It may be hard to see what's going on from them. Meanwhile, no, I don't have that diode across the relay, that's next. Would this diode keep the circuit from picking up signals from the train track. Keep in mind, my problem is this circuit is reacting to a nearby circuit, no actual wire connections...some kind of radio control??
     
  17. bertz

    Member

    Nov 11, 2013
    238
    31
    No, this diode wont keep the circuit from picking up signals from the track. But it will protect whatever component is driving the relay (transistor?)
    The best place for the diode is right at the relay, Cathode at the + end, and anode at GND.
    No Mike it's not radio control. The source of the interference is most likely arcing at the brushes of the motor and possibly arcing between the wheels and the rails, especially if the track is dirty. So how do you deal with it? First make sure that your circuit has by-pass capaciors correctly installed at all the right locations. Rather than going into a treatise here on by-pass capacitors, I refer you to this article:

    http://www.allaboutcircuits.com/tec...ry-ic-part-1-understanding-bypass-capacitors/

    Then I would take a look at the motor. A good practice is that of soldering three ceramic capacitors (having a value between 10 nF and 100 nF) directly on the motor’s contacts, for the purpose of suppressing the noise coming from brushes rubbing on the collector. The capacitors have to be soldered between the two terminals and the frame, and possibly also one of the two power supply terminals. See attached photos.
    These capacitors will do nicely.

    Finally, I would take a look at your circuit. You have components that are highly susceptible to electrical noise (74LS123). It seems to me that you have far too many components to do a simple task. Raise & lower the crossing gate while flashing a couple of LED's.

    Capacitor on brushed Motor 2.jpg fig-10-500x194.png
     
    MikeK likes this.
  18. MikeK

    Thread Starter Member

    Apr 1, 2016
    33
    0
    Thanks so much for the help. I'll follow the advice of the link on caps. Meanwhile, yes, I have what seems to be a lot of components. The 74ls123 takes two photosensor inputs and has two low outputs and two high outputs. I use the low outputs for indicator LEDs to let me know if the sensors are working, and the high outputs to drive 337 transistors to operate the latching relay that then goes through a 556 to control the servos. The 556 does a nice job of slowing the servos down for a more realistic gate speed. I have not been able to smooth that out, the beginning of this thread.
    I use a pin on the relay to operate the 555 alternating flasher and a recorder for loco horn sounds. Lots of stuff at a train crossing.
    Since this has gotten overly complicated, I'm considering learning about the PICAXE chip. Programmable chips seem the way to go these days. Looks like more time down the rabbit hole for me.
    I have lots of locos, and want this circuit to work for others without having to modify locos. Modeling these days either uses DC or DCC. Even the DC is not especially controlled by a big rheostat, but I think they chop it (PWM?) to allow the locos to crawl while still pulling a long train. All this fancy electronics makes for more noise, I'm sure.
    I still contend that something funny is happening, my circuit fires a sensor LED when I turn on the track control, loco on the tracks or not. My track is a big (antenna?) circle and the crossing control circuit is right there next to the tracks. When a loco passes, a led fires. I'm temped to move it back to my work bench and have my wife operate the track to see how far the interference can travel. On my bench, or with the track power off, it works fine.
     
  19. MikeK

    Thread Starter Member

    Apr 1, 2016
    33
    0
    Bertz, the more I beat my head against the wall, the better the picaxe looks. What do I need to get started, where to get it? And will my photoresistors or phototransistors do for the 'digital input' ? I sure hope the picaxe is noise resistant. I think I read where the alternating flashers and recorder can be included, too.
     
  20. bertz

    Member

    Nov 11, 2013
    238
    31
    I assume you are using pulsed DC control for your locos instead of DCC. Remember that pulsed DC can act very similar to AC except the waveform never goes below 0 volts. I like your idea of moving the control board away from the tracks (you indicate that it is right next to the tracks). Anytime you have a current carrying conductor it is surrounded by a magnetic field. If this field is collapsing on a regular basis (as in pulsed DC) it will induce a current in an adjacent conductor. Could this be the source of your problems? Move the control board some distance from the track and find out.

    I sure wish you could post a schematic of your control board, it would make it easier to help you.
     
Loading...