Pelsea

 

I will not deny that digital control via Arduino or similar systems is the bee's knees for controlling servo motors. I've been doing that for years, and teaching others how. However, there is overhead in any microcomputer system, overhead that includes programming devices and software, the boards themselves, and of course, the time invested in learning how to code. For this reason, simple problems are often best handled by simple circuits. If all you need is a two position servo control (for turnouts or whatever), this thread will show how to build a circuit with a single IC and a dozen or so parts that will provide just that.

Theory will follow today, and the build should be posted tomorrow.

pqe

Reply 0
Eugene Griffin EGRX

All aboard.. the pulse train

Perfect....  And I agree, you could use any processor if you have one.  

I am tempted to dust off that old PDP-11...

So will it be dual 555s...?

Thanks for this post.

Reply 0
Pelsea

The circuit

The design goal for this circuit is to control a servo motor with a simple switch that selects one of two preset positions. In addition, the presets must be easily adjustable and provide precise alignment. First a recap of servo theory:

A servo motor sets its position by comparing the voltage off a potentiometer connected to the shaft to an input control voltage. In the case of the little RC servos we use, the control is provided as a series of pulses, and the servo translates the pulse duration into a voltage internally. This is essentially the same PWM system we use to control our trains. Different servos behave differently, but there is a loosely held standard that the midpoint of rotation will be specified by a pulse duration of 1.5 ms. The pulses are sent at 20 ms intervals or faster. The servo I am experimenting with (Parallax) has a 180° range of rotation specified by pulse durations from 0.75 ms to 2.25 ms. So the problem is to send pulses within that range at 50 hz or so.

The goto chip for analog timing is the venerable 555. We've seen this before:

ss_1d.jpg 

Technical discussion you can skim over:

Even though this is a simple chip by modern standards, there's a lot of stuff in there. It all exists to manage the switching to charge and discharge a capacitor. Capacitor charging cycles are a popular way to mark time. Briefly, when the trigger input is pulled below 1/3 of +V, a memory cell (flip-flop) is set on.  When the threshold pin is brought above 2/3 V, the flip-flop goes off. The output of the flip-flop is connected to a transistor in such a way that the pin labeled discharge is connected to ground when the flip-flop is off and unconnected  when the flip-flop is on.

This circuit can be used in two ways:

ss_1e.png  SS_1f.png 

Monostable or one-shot                                                     Astable, or oscillator

In both of these circuits, there is a capacitor connected to the threshold and discharge. On the left, the capacitor is connected directly to the discharge- when discharge is unconnected a resistor (RA) connected to +V can charge the capacitor. When the discharge pin connects to ground, the capacitor is discharged almost instantly. What makes the change happen? The trigger disconnects discharge, then the threshold pin reconnects it. This cycle will happen once, every time the trigger input is brought low. This is called monostable or one-shot operation. The time it takes for a complete cycle is 1.1xRAxC.

The right hand circuit is a bit more complex, with a resistor (RB) between the capacitor and discharge as well as between the discharge and +V. This means the discharge is gradual as well as the charge. The other change is a connection between the threshold and the trigger. That means when the capacitor has discharged enough to make the filp-flop flip, the circuit triggers itself for another go-round. Thus the circuit oscillates in what is called astable operation. The frequency is 1.44/((RA+2RB)C).

End tech talk, back to paying attention

Our servo circuit requires one of the above to produce a steady stream of pulses and one of the other to provide pulses of a controllable width. Here is a circuit that combines the two:

SS_1aaa.png 

*Edit: 4/7/16  corrected C2 value

Note that the output of the oscillator section (left side) is perfectly suited to trigger the one-shot side. The resistor and capacitor values shown give a pulse frequency of about 70Hz and a pulse duration just shy of 2ms. How do we translate that into servo control? 

There's another input on the 555 that seldom gets much discussion. This is the control voltage input-- most sources just tell you to put a small cap on it and don't say much more. But it's actually a very useful pin. If you look back at the drawing of the innards of the 555, you will see a set of three resistors-- these comprise a voltage divider that determines the 2/3 V and 1/3 V flipping points. The control pin lets us apply our own voltage to determine the point at which the circuit switches into discharge. (The trigger point will likewise change to 1/2 of that.) That of course will change the timing of the circuit. The section of circuit labeled preset is a voltage divider that will adjust the discharge point between 31% and 69% of +V. (The pots are 10k-- my cheap circuit simulator refuses to show the values.) This will set the pulse duration from 0.75 ms to 2.25  ms, just what the specs call for. Note that there are two preset voltage dividers, chosen by a switch. When the switch is thrown, capacitor C3 will smooth the transition from one voltage to the other, slowing the movement of the servo arm. Experiment with different values of C3 to get the transition you want.

Before I go, here is a scope shot of the circuit in action on the breadboard:

SS_1b.jpg 

The output of the oscillator is in red, and the output of the one-shot (the servo control) is in yellow.

Tomorrow I'll build a permanent version.

pqe

edited 12-10-16 for minor cleanup

Reply 1
Graeme Nitz OKGraeme

Pelsea...

...You must have read my mind! This is just what I have been thinking of!

Graeme Nitz

An Aussie living in Owasso OK

K NO W Trains

K NO W Fun

 

There are 10 types of people in this world,

Those that understand Binary and those that Don't!

Reply 0
Kevin Rowbotham

Folowing along...

Good stuff Pelsea!

Question:  Could you have chosen a 556 for this circuit?  Your thoughts?

Regards,

~Kevin

Appreciating Modeling In All Scales but majoring in HO!

Not everybody likes me, luckily not everybody matters.

Reply 0
Pelsea

556 yes

Yep, the build will use a 556 IC, which contains two 555 circuits. You can just barely see it in the video. I actually find the 556 easier to work with than a 555 because all connections for a circuit are on the same side of the chip.

pqe

Reply 0
Greg Williams GregW66

This is fantastic, I am

This is fantastic, I am watching.

Greg Williams
Superintendent - Eastern Canada Division - NMRA
Reply 0
Kevin Rowbotham

Video!

Hi pqe,

For some reason the video didn't register, I thought it was an image, my bad!

I can clearly see the 556 IC when watching the video full screen.  The movement of the servo is very nice.  I've been playing with the pro mini as a servo controller but I am happy to see this tutorial appear.  I think I might have most of the parts I need to breadboard this circuit.

Please continue.

Regards,

~Kevin

Appreciating Modeling In All Scales but majoring in HO!

Not everybody likes me, luckily not everybody matters.

Reply 0
le Nordiste

Hi from Paris suburb

Hi from Paris suburb (France)

Is there any way to control the rotation speed ?
This in order to rotate a little turntable, i'm modelling HO meter gauge.

 

Reply 0
wildecoupe

This makes me miss being an EE

Love playing with circuits like this!  Should have stayed in EE back in the day and not switched to CompE. Thanks for sharing this!  

Reply 0
Greg Williams GregW66

Voltages and Current

How much current does each little circuit draw? I see a 9v supply but you don't use that for the servo power do you? I am assuming a 5v source for the servo? How much current would each servo draw? Do they continue to draw current when thrown to each position? I am thinking about powering enough circuits and servos for a 12 turnout layout.

Greg Williams
Superintendent - Eastern Canada Division - NMRA
Reply 0
Pelsea

Questions, questions, I like questions.

First note there was an error in the schematic, which I have just corrected.

Voltage-- I indicated 9V in the schematic, but the circuit will work with 5-12V, whatever your servo prefers.

Current-- the servo draws current all of the time, depending on load. This one is rated at 15 ma with no load, but it will pull up to 200 ma when working hard. Consult your specs.

Speed-- the rotational speed is determined by C3, the larger the slower. You can have as many presets as you like with appropriate switching. With a servo controlled TT, you could have a preset for each position, probably with multi-turn pots to get precision alignment. You'd need a multi turn servo like this one. Most servos advertised as 360° are really continuous run. Continuous run servos sit still when the pulse is 1.5 ms, move clockwise when the pulse is 1.3 and back up when the pulse is 1.7. There's no positional keying, so it's just a nice motor for our purposes.

pqe

Reply 0
Greg Williams GregW66

More questions

What value are the adjustment pots, or if my training does not fail me, does it even matter?

Greg Williams
Superintendent - Eastern Canada Division - NMRA
Reply 0
Pelsea

It does matter

The trim pots are 10k, multi-turn in a fussy situation. My cheap schematic program doesn't want to display the values (I think I've figured out how to fool it for the next iteration.)

Most of the time the actual values of a voltage divider don't matter, since the voltage is determined by the ratio of the resistors. (RB/ (RT+RB) where RT is on top.) However in this case, the divider is in parallel with a divider hidden in the IC. The values for that hidden divider aren't given, but it's probably in the 300k range. When you have resistors in parallel, the math gets a little complex, but if one is an order of magnitude less than the other, you can just go with the small value. So if our external divider is 30k or less, we can ignore the one inside.

Incidentally, the resistors on either side of the pots are found by experimenting with the servo. We want a wide range of motion, but without overdriving the thing (no jitters please). I found 7.5k avoids overdrive but only provides 160° of motion. 6.2k gave me full range, but could get into overdrive, where the motor starts pulling 50ma. You should choose resistors that provide just the motion necessary (90° in most cases) in order to maximize the sensitivity of the adjustment.

pqe

Reply 0
Pelsea

The build...

I didn't expect this to take long in the building, and it didn't. About two hours if you discount the things I did just to make it pretty for this presentation.

I choose veroboard as the base, because it is the cheapest approach and the circuit lends itself to that kind of layout. You can lay out veroboard projects on ordinary graph paper once you have a bit of experience, or you can download special paper here. Either way, you draw in the components with pencil-- neatness counts, but only a bit. the important thing is to allow plenty of room for each component. Here's a fancy version of my layout;

SS_2c.png 

The black squares indicate places to cut the tracks-- note that they are shown here from the top of the board. (These are the bare minimum. I actually cut every track so it doesn't extend to the edge. That way I can test without getting shorts from my board holder.) The value for each component is read from the schematic-- for your convenience I'll repeat it just below. The resistors labeled R are chosen to match your servo and the amount of travel you desire. I used 7.5k for my Parallax servo. The boxes labeled "to servo" and "to switch" are three pin female headers. This allows the board to be mounted in a convenient location. The wires to the switch should be fairly short, less than a meter or so. The servo wires can be as long as you like. Note that power is carried to the servo  from this board, so you only have one connection. Your power wires will be soldered to the tracks labeled GND and +V. Use whatever fits into your system for a connector.

The schematic:

SS_1aaa.png 

This shows 9V power, but use what your servos like- probably 5 volts for the little ones. The voltage doesn't affect the timing.

Here's the version I built. I didn't follow the layout exactly because I used thin kynar wire-- that let me put two wires in the same hole and save some space.

SS_2aa.jpg 

Note the orientation of the trimpots, with the bottom to the left. This makes the servo move in the same direction the pot does when you turn it. Also note the orientation of the large caps. They have a negative side marked with a white stripe. Make sure this connects to ground. The green blob is a mylar cap for C2. It is not polarized.

And here's the ugly backside. It's flipped left to right.

SS_2b.jpg 

Veroboards are easy to work with, but remember to sand before you solder. The track cuts will never be neat. I use a light weight hand grinder with a Dremel engraving ball.

As a final treat, here's the board in action:

 

I hope you find this useful-- please post your experience here.

pqe

Reply 0
Eugene Griffin EGRX

Grade Crossing Circuit

Any chance of expanding this circuit to control a gate crossing?

Maybe triggered by energizing a small section of electrically isolated rail on either side of the crossing with the opposing side acting as a keep alive.

Thanks again, always enjoy the electrical circuits.

 

Reply 0
Bing

HUH!

​I used to repair TV's in a previous life. But now if you mention IC, circuit boards, resistors, and such I find my eyes glazing over and my brain getting foggy. Heck, when I get to the bottom of the first of two pages of comments and it says 2, next or last, I get stumped as what to do next.

​Keep up the good work and keep the ideas coming! Enjoy posts of all types and MRH has supplied many wonderful ideas and problem solvers Thanks everyone.

This has been a tongue in cheek production.

God's Best and Happy Rails to You!

 Bing,

The RIPRR (The Route of the Buzzards)

The future: Dead Rail Society

Reply 0
Pelsea

Grade crossing

That seems like a dandy application, especially since I have already posted an optical detection circuit. The problem is to replace the mechanical switch with something made of silicon. A 4066 or 4051 will do the trick. I'll need to order some parts, so check in next week.

pqe

Reply 0
kingbf

servo controller

Geoff,

     Since I believe you believe in simplicity and frugality, have you considered using an Attiny 85 microchip to control a servo? It is cheap, easy to program with an Arduino, and I believe less component intensive than using the 555. Granted there is a learning curve and some minimal hardware requirements to get started, but it might be worth considering. Just saying...

               Brian F. King

Reply 0
Pelsea

Itty bitty µprocessors

I agree that you (& I) can get efficient and precise control of servos with microprocessors, and there are several 8 pin options like the Attiny 85 or the PICAXE. However, my adventures teaching digital arts to graduate students convinced me that there are many folks who don't take to programming in any form-- the words simple and code just don't belong in the same sentence. I suspect this applies to many modelers.

However, every railroad modeler can solder and build things from plans. My intention with these posts is to provide easy to build analog solutions to common railroad modeling tasks. I'm in the habit of explaining things, but even if my technical comments miss the mark, I hope that anyone will be able to build these circuits from the pictures. I'm looking forward to hearing from anyone who tries and either succeeds or fails.

Another point: My first computer on a card was a KIM-1 board with a 6502 microprossor, my first personal computer an OSI challenger, followed by IMSAI, Apple, Sinclair, Commodore, Atari, MacIntosh etc, all with different operating systems and programming languages. I still use C and LISP daily, but I also spent a lot of time learning FORTH, PASCAL, smalltalk and others that are not much use today. Even now Apple is making me learn Swift just as I was really comfortable in objective-C.  Arduino seems to have better legs than most academic development systems, but I will be (pleasantly) surprised if it is still around in 10 years. Even Java is looking shaky as Oracle tries to put up toll booths. On the other hand, the 555 has not changed in over 40 years, and I designed this servo circuit in 1975. Plenty of other chips have fallen by the wayside, of course, but a few will never go away, and there will always be opamps and bipolar transistors. I expect these posts to be around for a long time, and I want them to stay valid.

So my criteria for "simple":

  • One or two chip design.
  • Use mainstream chips, nothing exotic.
  • Fits on a 2"x3" breadboard (or similar sized modules).
  • All parts in stock at Jameco (the lowest common denominator of supply houses).
  • Cost less than $10 (not counting controls and things that a µprocessor design would also need).

I am happy to entertain suggestions, like the campfire circuit.

pqe

Reply 0
Kevin Rowbotham

Backstory

Peter,

Thank you for sharing some more of your background, added to what you've mentioned before, it seems you have a rather diverse skill set.

While I can code for the arduino, I am also thoroughly enjoying your foray back into analog circuits.  This servo controller is on my radar and I will post when I get going with it.  Until then, know you have avid analog followers!

Best regards,

~Kevin

Appreciating Modeling In All Scales but majoring in HO!

Not everybody likes me, luckily not everybody matters.

Reply 0
Pelsea

Detector actuated servo

I have modified my servo circuit so it can be controlled by the second generation optical detector. To do this, I replaced the switch with a CD4066 CMOS bilateral switch IC. Here is the modified schematic:

ss_3a.png 

The CD 4066 has four independent switch sections. To duplicate the SPDT (two way) action we need to use two, turning one off as the other comes on. A section is turned on by a high voltage, something close to the positive power supply. A low voltage turns it off. (In between, it acts as the mood takes it, so always ensure a solid on or off.) The control will come from the optical detector circuit, which provides a high when any of its four sensors are darkened. This signal can be connected directly to the section A control, which will pass the preset voltage 1 to the control pin of the second 555 timer. The signal is also passed (via a 10k resistor) to the base of a 2N3904 NPN transistor. The emitter of the transistor is connected to ground and the collector is connected to +power via another 10k resistor. When this signal is high, the transistor is turned on, connecting the resistor to ground. The bottom of the resistor is connected to the control B pin on the 4066, so section B is off. When the decoder signal goes back to ground, the transistor is off, and the collector resistor pulls the control B pin of the 4066 high. In this condition, the preset 2 voltage is passed to the 555.

To build this, we have to add a CD4066 IC to the board. Here it is:

ss_3b.jpg 

This is built on vero board again. I'm still learning how to use this stuff-- this time around I basically treated it like any other breadboard, holding off on making any cuts in the tracks until I had a section completely laid out. I used 30ga Kynar wire to make it clear where everything is connected, but you may find 26 ga wire easier to work with. I stuck some Kapton tape on the edges so I could test this in my circuit board holder, which otherwise would short the traces out.

This makes the back a lot cleaner than my first try. (Board flipped left to right)

ss_3c.jpg 

Looking back at the top view, the left IC is a 556, with two independent 555s. The right IC is the CD4066. Here are pinouts:

556.png 4066.png 

Left: 556, right: CD4066  Note notches at pin one end of chips. Put one in backwards and you will let the magic smoke out.

Note that the pins on each side of the 556 are listed in the same order, but offset because of the power and ground pins. I wish the designer of the 4066 had been as considerate. The signal pins are labeled in/out and out/in. You can use either for the input, then the complement is the output.

And here's a layout diagram. I made this diagram first, built the board following it loosely, debugged the board, then corrected the diagram to match what I actually built.

ss_3dd.png 

Here's a pin by pin description to help you build. Pins are numbered anti-clockwise. First the 556:

  1. (upper left) R1 (20k) to +V.
  2. R2 (820Ω) to pin 1,  jumper to pin 6.
  3. C4 (10nf) to ground at pin 7.
  4. Jumper to +V (that's a bit hard to see, but there are two wires in the same hole.)
  5. Jumper to pin 8 (this is the output of the driver oscillator)
  6. C1 (1µf)  to ground (note polarity).  [also jumper to pin 2]
  7. Ground
  8. (lower right) [jumper from pin 5]
  9. Jumper to servo connector (other pins on connector power servo)
  10. Jumper to +V
  11. Jumper to pin 4 of 4066, C3 (47µf) to ground (note polarity)
  12. Jumper to pin 13, C2 (100nf) to ground. 100 nanofarads is also known as 0.1 microfarad.
  13. R3 (20k) to +V
  14. +V

Now the 4066:

  1. (upper left) Jumper from pin 2 of P1.
  2. Jumper to pin 4.
  3. Jumper from pin 2 of P2.
  4. Jumper from pin 2.
  5. Jumper from collector of transistor.
  6. nc
  7. ground
  8. nc
  9. nc
  10. nc
  11. nc
  12. nc
  13. R8 (10k) to base of transistor, jumper to control input. Input also has ground connection between boards.
  14. +V

The transistor pins are top to bottom; collector, base, emitter. (Note the flat side is on the right) The emitter is connected to ground.

The potentiometers are wired identically, with resistors from pin 3 (upper) to ground and pin 1 to +V. Pin 2 is the wiper.

There is a set of jumpers right down the middle of the board to tie the ground busses together. The lower +V buss is powered from a jumper to pin 4 of the 556.

Black bars indicate where copper traces are to be cut.

And for the grand finale, I have tied all three boards together, blinker , detector and servo.

I hope you find this set of circuits useful. Blessings and brickbats are welcome.

pqe

Reply 0
Eugene Griffin EGRX

Long live the 555...

and the 741, and the 4000 series and C.....

Always a fan of circuits.

But it looks like I need to do a little bit of homework and add a count down timer to keep the circuit alive after it is triggered. 

As for another programming language, I think it is time to let WATSON do the programming.

Thanks for the circuits...

 

Eugene

Reply 0
Pelsea

Keep alive

I showed one way to extend the control signal in the detector thread, but I haven't tried it on this version of the circuit. I'll breadboard it tomorrow and see if any changes are required, or if there is a better approach.

pqe

Reply 0
Jim at BSME

Carelessness

Digital (uP) and Analog, I like both, but of course if you are careless with the programing the desired function won't work, but careless with the wiring of an analog circuit and you might let out the magic smoke.

Just like I see two people carelessly use the wrong name to address you Pelsa by, of course it could just be the excitement to comment on your excellent work and interesting background.

A thought about the 4066 pinout, it might very well be the layout on the silicon chip inside that prevented them from keeping all the pins in the same order.  Even though they are "independent" circuits they do share power and ground, so they may have had to make a compromise on keeping the pins in order. And while not in order you can see a grouping, if you look at B&D go: Control, IN/OUT, OUT/IN, A&C going Counter (Anti) Clockwise around the chip: Control, IN/OUT, OUT/IN. So all four have the same order from the control pin towards the IN/OUT pin end with the OUT/IN pin.

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: FacebookInstagram
Reply 0
Reply