I thought most servos want 50Hz and you control the "high" time to control position of the servo.View attachment 103528 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?
Couple of things:View attachment 103528 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?
'******************RR Crossing Gate.bas****************
'Version 1.0
'AJZ/April 1, 2016
'this code is used to drive a servo operated crossing gate
'based on a digital input signal
'====Input=======
symbol trigger = pinC.1 'signal to raise & lower the gate
'===Outputs===
symbol gate_Servo = C.2 'PWM out to servo
'===Variables===
symbol pos0 = b0
'===Directives===
#com 3 'specify serial port
#picaxe 08M2 'specify processor
servo gate_Servo, 150 'make sure gate is in raised position
pause 500
main:
do
if trigger = 1 then 'train detected
exit
end if
loop while trigger = 0
gosub activate
activate:
for pos0 = 150 to 80 step -1 'lower the gate
servopos gate_Servo, pos0
pause 5 'sets the lower speed
next pos0
do
if trigger = 0 then 'train clears the sensor
exit
end if
loop while trigger = 1
pause 500 'pause to let the last car clear
for pos0 = 80 to 150 'raise the gate
servopos gate_Servo,pos0
pause 5 'sets the gate speed
next pos0
goto main
Thanks Bertz (and all other replies). I'll try your recommendations before going the PICAXE route. I'm trying to keep this simple.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.
Use one of these.PS, how would I power the servo from a different supply on a model train setup?
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.Use one of these.
Perhaps the 74LS123 is the wrong chip to use in this application. Consider the following taken directly from the TI application notes: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?
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.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.
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?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.
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?)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.
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:my problem is this circuit is reacting to a nearby circuit, no actual wire connections...some kind of radio control??
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.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.