Projects

Non-Microcontroller Servo Driver

Using discrete components, no microcontroller

Daniel Koch

Issue 57, April 2022

A servo driver made from discrete components, without the need for a microcontroller

BUILD TIME: A FEW HOURS
DIFFICULTY RATING: INTERMEDIATE

In the current maker landscape, servos are a common option for a diverse range of builds, doing everything from moving armatures to deploying rocket parachutes. The standard way of doing this is to drive them with a microcontroller, seeing as in most cases, the rest of the project already depends on one.

However, this has not always been the case. There was a time, not too long ago, when microcontrollers were not so easily accessible to the average maker. Coding languages were more complex and less well-known outside engineering circles and like-minded people. Microcontrollers themselves were more complex, far harder to program than the bootloader-equipped versions of today. In addition, they were often quite expensive and less accessible in the domestic market.

Servos themselves have been used in radio control and model railway hobbies for decades, even without microcontrollers. The operating principle has not changed, either. The basic premise is to feed a rectangular wave of fixed frequency to the servo’s control circuit. The width of the high pulse determines the angle of the servo via an internal feedback circuit connected to a potentiometer on the base of the servo output shaft.

Once the potentiometer has rotated to the right point, the two pulse widths are the same. They are, therefore, Pulse Width Modulation-controlled (PWM) devices even though the PWM does not directly drive the motor as it does in a speed controller.

Microcontrollers make this very easy because they can process a variety of inputs, and respond with an appropriate PWM output. If you want the servo to correspond to the position of a potentiometer, you can connect it as a voltage divider and use the Analog-to-Digital Converter (ADC) of the microcontroller to map the value to a PWM value. You can make it respond to pushbuttons and move between two points, or even move a given number of degrees for every push of a single button.

Before things were so easy, many makers had to find other solutions. Servos have been one of two main methods of driving model railway turnouts (points being their other common name), alongside solenoids. This necessitates the ability of the controller to respond to two button pushes: One for straight, and one for turning. It also necessitates a limit to be set on the travel of the servo, as the travel of the turnout is almost always less. The same applies to model railway semaphore signals, boom gates, and a variety of other situations.

Outside model railways, servos were often used in applications like making components of machines move, such as opening the gate on a timer-based home-made cat feeder, or pretty much any application where you would use one today. The idea of a servo has not changed, just the way we drive them.

The uses for them have become more accessible to us with the advent of microcontrollers, but not as drastically as you would be forgiven for thinking. In all these situations, however, some form of drive circuit was needed. Before looking at some of the non-microcontroller ways to drive a servo, it is worth recapping how a servo actually works.

SERVO THEORY

There is slightly more to driving a servo than feeding a random PWM signal to the input and watching the armature turn. Inside a servo, there is quite a bit more going on than just some gears and a motor. The motor has a pinion gear which drives a series of gears between it and the output gear, resulting in a speed reduction and torque increase. The speed of rotation is determined by the motor speed and gear ratio, and is part of the servo data in degrees per second (°/s). One end of the drive shaft in the output gear is attached to the output spindle outside the case, while the other is attached to a potentiometer. Housed in the base of the servo is a circuit board, with this potentiometer interfaced to it. The potentiometer controls an oscillator on this board, which is fed to one input of an error amplifier.

An error amplifier is a form of comparator, which gives an output with a swing almost all the way to either the ground or supply voltage, depending on whether the difference between inputs is positive or negative. The output of the error amplifier is connected to a motor driver circuit which controls the drive current to the motor.

The other input to the error amplifier comes from the signal from the controller. This may be a radio control receiver, or a dedicated drive circuit such as outs. In older servos, the PWM signal would be used with a charge pump to give a voltage to feed to the error amplifier. In modern servos, there is often not a true error amplifier as such. Instead, a dedicated tiny microcontroller (a purpose-made device rather than an open-ended device like an ATmega IC) does the processing of the PWM signal, the comparison of it to the reference from the internal potentiometer, and the driving of the output to the motor. The principle remains the same.

In either case, if the error is positive, the motor turns one way until the error is eliminated as the potentiometer turns to match. If the error is negative, the motor turns the other way. For a fully clockwise rotation, a 1ms PWM pulse is used. For a fully anticlockwise position, a 2ms PWM pulse is used. That means that for a centred position, the pulse width needs to be around 1.5ms. In fact, the centre position should be 1520 microseconds (µs), and the full-travel numbers are not exactly whole milliseconds either.

In addition to being the right width, the incoming pulses need to arrive at the right time. The stated frequency of radio control servos is 50Hz, or fifty per second. This means that the total pulse length, including the high and the low between highs, needs to be one second divided by fifty, giving twenty milliseconds (20ms). Many servos will work above or below this by some margin, but others have to be quite precise. Additionally, we found some evidence that older servo systems worked on a 27Hz frequency. Further, some high-speed servos meant for trimming helicopter flight surfaces operate above 560Hz. However, the vast majority of servos encountered by most makers operate on 50Hz.

Servos are commonly made in 90° and 180° versions, which describes the total travel. In other words, a 90° will travel 45° either side of centre, while a 180° servo travels 90° either side of centre. 270° servos were once more common, and somewhere in the dark depths of the corner of the workshop here is an old model sailing yacht which uses two such servos for sail trimming. They are still around, but harder to find.

Also in the mix are 360° servos, also known as continuous rotation servos. Instead of a potentiometer, these have wheel attached to the non-driving end of the output shaft, the rotation speed of which is either magnetically or optically measured by a tachometer circuit. The internal circuitry compares this value to the incoming PWM signal. In these servos, a 1ms pulse width is full speed clockwise, a 1.5ms pulse is stopped, and a 2ms pulse is full speed anticlockwise. They are therefore directly compatible with existing servo controllers and need no special treatment.

WHAT NOT TO DO

Initially, it seems obvious that the venerable NE555 would be ideal. It can just be arranged so that its output pulse is between 1ms and 2ms. A variable potentiometer is used to control the timing. Problem solved, servo rotates.

Not quite. This means running the NE555 in astable mode, so that the pulse train is continuous. In this mode, the total time period ‘T’ is made up of ‘T1’ and ‘T2’, the high and low time respectively. T1 is determined by the value of RA, RB, and CT. T2 is determined by RB and CT, with no involvement from RA. This means that as the value of RB changes in order to control the pulse width, the total time T changes too, meaning that a fixed frequency is not possible. As noted above, some servos need a very precise input frequency to work well. Others can have their speed varied, albeit crudely, by varying the PWM frequency. In either case, unintentional change to frequency is undesirable.

It is also not possible in this configuration to have the NE555 with a low time longer than the high time. A value of close to 50% duty cycle is possible, but it will always be in the decimal point range above 50%, never exact or below. That’s a problem, seeing as the high time needs to be between 1ms and 2ms out of a total 20ms cycle, amounting to a duty cycle of between 5% and 10%. A transistor inverter on the output would solve the duty cycle problem, enabling the duty cycle to simply be revered to between 90% and 95%, but it does not help with the issue of varying frequency as the pulse width changes.

There are ways to control the charge and discharge sections of the timing cycle of an astable NE555 independently. The first diagram with two diodes and one potentiometer allows duty cycle to be changed with only limited impact on the output frequency. This works by changing the amount of RB involved in the discharge phase, effectively shifting some of it to RA and therefore maintaining a fixed value for the overall amount of RA and RB.

A similar method allows independent setting of the values of RA, accompanied by R1, and RB. This comes close to giving some of the functionality we want, but in enabling the pulse length to be varied, it still changes the total frequency. We felt there was a better way.

DOING THE MATHS

There are a couple of warnings for the maths above. Although simple for some, it is daunting for others who just never ‘got it’ at school despite being capable and able to do plenty of other seemingly more complex things. Additionally, despite being routine for anyone who is mathematically minded or does this on a regular basis, anyone who hasn’t used this kind of maths regularly may struggle to recall the process even if they were fine with it in school. None of this is a statement on intelligence, either.

We regularly get commented or emailed questions regarding people not getting the same answers as we do. Almost all of the time, we analyse what is happening and find that the cause is Order of Operations. Remember BODMAS from school? Brackets, Orders, Division and Multiplication, then Addition and Subtraction.

The challenge seems to be in many cases the calculator that someone is using. Far too many phone calculator apps do not apply order of operations, or do not apply it properly. If you enter the calculation, the calculator may simply perform the equation left to right, ignoring whether there are multiplications and divisions in the middle. 12 - 3 x 3 + 7 should be performed by first multiplying 3 x 3 to get 9, then subtracting 9 from 12, then adding 7 to get 10. Some calculators will take 3 from 12, then multiply the resulting 9 by 3, before adding 7 for a total of 34. It only gets worse as the equations get more complicated.

If you are having trouble getting answers that are near what you expected, try doing the order of operations yourself. Go through the equation, and calculate the contents of any brackets, being careful of any orders (powers of, like 103), and write them down. Then do the same for any multiplications or divisions. Write those down too, and then you should be able to enter the equation left to right, having already done the harder parts separately, and the calculator will only have to contend with addition and subtraction. However, make sure you have already factored in anything like a subtraction inside a set of brackets when you did that part earlier.

The other option you have is to simply fill your equation with extra brackets. That is one thing even the simplest of calculators or apps seem to understand. Even on a good calculator, we often add brackets around powers and similar situations, just to make really sure.

There are a couple of other things we see, again often when people have just forgotten things they used to know, through lack of use. Any time that two items are next to each other, this means multiplication. For example, RB CT is RB multiplied by CT . Some people seem to add them together. If it’s been a few years for you, this would be an easy mistake.

The other thing we find is that people forget the commutative rules, a big word for a simple concept. Commutation in maths means changing direction or order. For example, 5 x 2 = 10, while 2 x 5 = 10. Rearranging the factors does not change the answer (product). However, in division, the dividend and divisor are determined by place. So, 50 ÷ 10 = 5, where 50 is the dividend, 10 the divisor, and 5 the quotient. However, 10 ÷ 50 = 0.2, a very different quotient with the same numbers before the =, just in a different order. The position matters. This becomes particularly important when rearranging equations and is easy to forget when you are dealing with algebraic letters and symbols, not numbers.

The same goes for addition and subtraction. Addition is commutative, so 4 + 7 = 11, and 7 + 4 = 11. However, subtraction is not commutative. 7 - 4 = 3, while 4 - 7 = -3. This may seem like child’s play, but if you don’t do this regularly, it’s easy to forget. It is even easier to have forgotten in the moment because you’re rusty, and not realise later because you only forgot that one time and otherwise remember.

BASE UNITS

Finally on the maths, remember to make sure everything is in base units. That’s easier for resistance, because most people remember that 10kΩ is 10 000Ω, and so on. It’s also rarely too many zeros to fit on the calculator screen. However, in some of the questions we get asked about maths in articles, we have found a trend in people forgetting that µF, nF, and pF are multipliers as well (technically divisors but they are still referred to as multipliers). More specifically, because we rarely hear of a capacitor bigger than the microFarad (µF, not mF which is milliFarads) range, it is easy to forget that this is not the base unit. We have helped people not getting the same answers we did, and found that nanoFarads and picoFarads had been converted, but only into µF, not F.

We’ve added a link to a comparison table in the ‘Reading and Resources’ section, but we have also covered this in some detail in our Kids' Basics Issue 43.

It is also worth noting that, while mF is definitely milliFarads (one thousand microFarads), you will sometimes see the unit MFD. This is MicroFaraD, and is a legacy of a time when type fonts did not support greek letters like µ so easily. It is capitalised and has the letter ‘D’ added to distinguish it from the rare but still sometimes used mF for milliFarads.

PROPOSED SOLUTION

The solution seemed to be two use two NE555 circuits. The first would establish an astable pulse train of consistent frequency, which would feed a monostable circuit to deliver the desired pulse width. This gets around the problem of the astable configuration not being able to have a short high time and long low time, because the monostable circuit triggers from a low-going pulse. The duty cycle of the astable could be 99% and the monostable would still trigger. It also means that the final output pulse width can be adjusted with no possibility of affecting the frequency. In addition, the frequency can be adjusted with no effect on the pulse width. While some servos will not work at all without the correct frequency, others can be crudely speed-controlled this way.

The output from the monostable circuit can directly drive a servo signal pin. Because the output sinks current when low, there is no need even for an anti-float resistor or circuit to stop noise to the servo when the pulse is low. The output can comfortably drive a transistor if needed. However, the servo will be supplied with voltage from the main rail and is not powered by the driver circuit output. The PWM signal is just that: A signal. It does not drive the motor directly like a speed controller output does. In addition, the NE555 can operate anywhere from 5V to 15V while most servos are 5V, 6V, or 7.4V. All this means transistor outputs are unlikely to be necessary. If there is a reason to provide a higher voltage, then the 200mA source or sink current capability of the NE555 will happily supply enough gate current to a MOSFET to overcome its gate capacitance and so not leave the gate in the transition zone too long. See Classroom from Issue 32 for more on the MOSFET driving challenge.

REQUIREMENTS

The circuit has to have independent ability to control both frequency and pulse width. We have also arbitrarily decided to isolate the output so that there can be a disconnect maintained between the circuit power and servo power. This isn’t a requirement in general terms but some servos, particularly large ones under load, will cause significant voltage drop when operating from limited supplies or batteries without enough surge capability. The floating output provides an option to use a separate power supply for the servo, or running the servo and circuit from the same supply.

The circuit also needs different input methods. In one arrangement, it needs to work with a switched system with pre-settable limits for both ends of the travel. Either a toggle switch or two push buttons would be ok. Either could be replaced with a relay, transistor, or optoisolator if the driver is to be triggered from another circuit rather than manually. In the other arrangement, the servo needs to be able to follow the travel of a potentiometer so that turning the knob turns the servo.

FIRST EXPERIMENTS

The first task was to set up an astable NE555 circuit. This had to be adjustable so that the frequency can be altered. It also had to have a low-going output pulse (T2) that is shorter than the shortest monostable period that we want. This made component selection a bit of a painful process. The easiest way that we found was to rearrange the time period equation, and add an arbitrary capacitor value to result in a combined resistance value. From there, RA and RB were calculated so that T2, the low period, was less than one millisecond. To do so, we first calculated what the time period needed to be to produce a 50Hz signal, which is just one second divided by the frequency: 1 ÷ 50 = 0.02s, or twenty milliseconds.

After a little guess-and-check, we settled on a value of 560nF for CT. Note that in the equation, 560nF is written as 56x10-8. 1nF is 1x10-9, but the zero in 560 gets dropped, taking one place value with it. If you struggle with powers and keeping them straight in your head, most calculators will work if you enter 560x10-9.

Now, we were left with 51 535.8Ω, which we rounded up in the following calculations. We already knew that the low time, T2, had to be less than 1ms, so that was calculated first. We rearranged the T2 equation with the nominal capacitor value to give an arbitrarily-decided low period of 500µs, or 0.0005s. At half the shortest time period that we want from the monostable section, this will guarantee no retiggering.

The returned value of 893Ω for RB is shown here already rounded up. The actual number was many decimal places, but we will be measuring the actual numbers later with a multimeter and adjusting with a screwdriver, so decimals become a pipe dream. This meant we could calculate the value of RA, first by subtracting it twice (2RB) from the original 51 536Ω total resistance figure from the time period equation, then by plugging it into the T1 equation to make sure the numbers matched.

You can see from the equation that even the limited rounding performed so far is generating an error. We arrived at a figure of T1 = 19.65ms. Very close to the 19.5ms we were expecting, but adjustment is needed. Because the value of the capacitor will have a 10% tolerance anyway, unless we track down. Realistically, we knew these numbers told us all we needed to know. The values showed that we needed potentiometers in the circuit anyway, so this would enable future tweaking to get the overall frequency to exactly 50Hz. As long as the T2 time does not approach 1ms, it can deviate from the nominal 500µs we chose.

So, the figures gave us a guide for the selection of components for the astable circuit. Just to make sure, we repeated the calculations for 27Hz, the older standard that we found some information for. Few makers are likely to need it, but it felt like a good idea to make sure the circuit was capable of it. The end result was that we needed to increase the value of RA by almost double, which is logical seeing as we wanted the same T2 value but a nearly double T1 value in order to give the same 500µs pulses at a nearly double interval. While we were originally going to use a 50kΩ trimpot for RA, we instead chose a 100kΩ trimpot.

The calculated and rounded RA value of 94 544Ω is just within this, as is the original 49 750Ω. To get the accuracy required, we decided on 25-turn top-adjust trimpots. If you are sure that you will not need the 27Hz capability (which we feel will apply to most people), then there is no reason not to use a 50kΩ trimpot and gain some extra finesse in the control of the adjustment, effectively doubling the resolution.

THE MONOSTABLE

All of that was just the astable side of the circuit! Thankfully, the monostable section was less head-bending because we only had to calculate the high period once the trigger pulse arrives from the astable. There is no duty cycle to worry about, and the high time is not affected by the low time. Also, we had two known values to work with as our extreme ends: 1ms and 2ms. The time period for a monostable NE555 circuit is calculated in a similar way to the astable, just with a simpler formula. We started by the same process, choosing a capacitor value and calculating to see if the resistance value was reasonable. We initially arrived at a capacitor value of 220nF, a 1ms resistor value of 4132Ω and a 2ms resistor value of 8264Ω.

However, it looked really tempting to try to make the difference between upper and lower resistance values as close to 5kΩ as possible, so that the full rotation of a 5kΩ potentiometer would follow the full sweep of the servo. Knowing that the maximum value is going to be double the minimum value based on 1ms and 2ms pulse times, we chose 10kΩ as the value of RT and rearranged the equation to find CT. This time, we found a value of 180nF would, tolerance depending, get us where we needed to be.

Again, we needed trimpots. We needed two separate options, one for the switched preset version, and another for the potentiometer-follower version. As noted, the potentiometer-follower version was largely done for us based on the equation above. The switched version needed two presettable values, controlled by a switch. In the end, we decided to use a total of four trimpots, two pairs of two in series. This allowed the minimum value of 1ms to be found on each pair with the first trimpot, then left there forever. Adjustment as desired can then be gained from the second trimpot, so that the adjustment only ever occurs within the 1ms to 2ms range. Using one trimpot risks the value falling well below 1ms. This strategy in turn means that the user can adjust visually rather than needing to watch a multimeter display to figure out where the lower limit is: The lower 1ms limit is always the starting point.

PROTOTYPING

While we had built several prototype circuits while we explored some of the aspects described above, the whole circuit had not been built together as one block yet. We set about making the whole circuit fit neatly on one breadboard, using wire links and no jumper wires. Jumpers would of course be necessary for off-board components like the switch and potentiometer when the time came, but we try hard to avoid them for on-board connections. It is much easier to see the whole circuit for photography, not to mention trace it and fault-find it, when there is not a mass of wire over the top of it. It is also a whole lot easier for both us and you as readers to follow what is going on.

There are some challenges with solderless breadboards. They are notoriously prone to noise and leakage. Those were not an issue for this circuit at these frequencies, but the quality of the connections certainly was. Several times during the prototyping phase, we saw significant changes on the oscilloscope screen when a trimpot was bumped, for example. However, the exercise was still valuable. We were able to verify the overall circuit, and some of the discoveries above had been sound this way, too. That said, a more solid solution was definitely needed.

We also rediscovered during this process something that we knew already but had neglected to think about. Trimpots, or any form of potentiometer, have a tolerance just like a fixed component. The 5kΩ trimpots used had a tolerance of 10%, meaning that we may not get close to the 5kΩ we need for the monostable section. The ranges needed from the 100kΩ trimpot in the astable section are well within the 10%. Therefore, we added a 510Ω resistor in series with the first trimpot, in order to guarantee a 1ms starting point. To an extent, this also gives a buffer to cope with tolerance on the capacitor.

On that note, regular MKT capacitors from the main electronics retailers are generally 5% (designated by the letter ‘J’) or 10% (designated by the letter ‘K’). Our 180nF was a 5%, while the 560nF was a 10%. We used an LCR meter to go through our stock and find one that was close.

We decided against adding a reverse-polarity protection diode in both the prototype and permanent builds. The NE555 has a recommended operating voltage, according to the Texas Instruments datasheet at least, of 4.5V to 16V. Most silicon rectifier diodes have a voltage drop of 0.6V to 0.7V. On a 5V supply, this will take the supply voltage below the minimum. Other brands may have a lower minimum, but ours were genuine TI products so we dropped the diode idea. It always pays to use the datasheet from the manufacturer of your specific stock of IC, not another manufacturer of nominally the same product, because variations do occur between manufacturers. The BC337 is a classic example. Current handling is between 500mA and 800mA depending on the brand and model!

The Build:

Bottom View
Top View
Parts Required (SWITCHED):Jaycar
1 x Solder BreadboardHP9570
1 x Packet of Wire LinksPB8850
1 x 2kΩ 25-Turn TrimpotRT4646
1 x 100kΩ 25-Turn TrimpotRT4656
3 x 100nF MKT CapacitorRM7125
1 x 180nF MKT CapacitorRM7140
1 x 560nF MKT CapacitorRM7166
1 x 470 µF 16V Aluminium Electrolytic CapacitorRE6194
2 x NE555 Timer ICZL3555
2 x 510Ω ResistorsRR0565
4 x 5kΩ 25-Turn TrimpotsRT4648
1 x SPDT Toggle SwitchST0335
3 x Jumper Wires or use Hookup WireWC6024
Parts Required (POTENTIOMETER):Jaycar
1 x Solder BreadboardHP9570
1 x Packet of Wire LinksPB8850
1 x 2kΩ 25-Turn TrimpotRT4646
1 x 100kΩ 25-Turn TrimpotRT4656
3 x 100nF MKT CapacitorRM7125
1 x 180nF MKT CapacitorRM7140
1 x 560nF MKT CapacitorRM7166
1 x 470 µF 16V Aluminium Electrolytic CapacitorRE6194
2 x NE555 Timer ICZL3555
1 x 510Ω ResistorRR0565
1 x 5kΩ 25-Turn TrimpotRT4648
1 x 5kΩ PotentiometerRP7508
1 x Jumper Wire or use Hookup WireWC6024

Having prototyped both designs on solderless breadboards, it made sense to make the permanent versions on the solder equivalent. Most of the electronics retailers have a version of these, but some are closer to the normal solderless breadboards than other versions. The one we use is slightly shorter than the solderless counterpart, and has a shorter distance between the rows, and the distribution rails. However, each row still has five holes, and the gap in the centre is still the same width as the inside of a DIP IC package. On this version, the gap is taken up by two power rails again, so from the top, it looks like continuous rows. Besides that, the layout can transfer straight to the solder version. The only differences are that the wires between power rails and rows will be one hole shorter; and there are a few less rows to use. We still used the standard wire links used on the solderless breadboards, where colour indicates length.

The only significant change between the prototype and the permanent version, is the addition of a 470µF Electrolytic capacitor and a 100nF MKT capacitor across the supply rails at the point where the servo attaches. This helps keep the power supply stable even when larger servos are used under load. However, if you are driving very big servos, you may consider a separate power supply. We built the Switched version first, then backtracked to build the Potentiometer version.

Construction was started by fitting the wire links that go around IC1, the NE555 responsible for the astable pulse train. These were followed by the IC and two capacitors: A 100nF to ground to deal with noise on pin 5; and the 560nF timer capacitor on pin 2.

Next, the trimpots were fitted. These took a little wriggling, the right-hand 1kΩ one in particular. It was necessary to first bend the wire links outwards slightly to make the trimpot body sit flat on the board.

Now, the process was repeated for the second IC. The wire links surrounding it were fitted first, along with the wire link to connect IC1’s pin 3 output to IC2’s pin 2 trigger input. We also installed the 510Ω resistors in this step. Mechanical connections are best practice when soldering components to boards. With things like resistors and wire links, that’s just a case of bending the legs at a 45° angle after inserting them. With ICs, they need to be held firmly down, and one leg from each side bent over. However, one of the advantages of working from low-profile to high-profile components is that masking tape can be used to help keep everything firm and secure.

It was at this point that we were reminded of just how far components can be from their stated values. The 180nF capacitors used had a ‘J’ designation, for 5%. One of them was 180.2nF, so we chose that one. The other two were more than 5nF different. Well within tolerance (9nF) but still, enough to matter. We used our favourite LCR meter to check all of our timing capacitors for this build. For the 100nF coupling capacitors, the value is arbitrary to a point. Other designs use 10nF!

Up to this point, construction is identical except for some wire links around IC2. To construct the switched version with two preset positions, four trimpots were needed. Two of these were first set with a multimeter to 0Ω, and marked with yellow paint marker. The other two were soldered into the board and a multimeter with spring-hook tips was used to set the series pair of the 510Ω resistor and 5kΩ trimpot to be exactly 5000Ω. These potentiometers were marked with red paint marker. Then, the yellow trimpots were installed too, along with the timing and coupling capacitors.

Finally, a header for incoming power was added, along with the two power rail filter capacitors, and three header pins for the servo connection. Two of the latter go in the supply rails, while one goes to the pin 3 output. To make this circuit work, a single-pole, double-throw (SPDT) toggle switch was fitted with jumper wires. The Common terminal goes to the pin 6/7 junction of IC2. The two remaining connections are taken to the output of the timpot series pairs. One forms the upper limit of travel, and the other the lower limit. Which one is which doesn’t really matter and will depend on how you mount your switch in situ.

Note that in the photos above, we forgot two of the wire links until we were about to install the trimpots. One goes between pins 6 and 7 of IC2, while another goes in the row beside pin 5 and the orw next to that one. This serves to short the wiper and one end of the taper in one of the trimpots. You can see these links fitted in the photo with the trimpots installed.

POTENTIOMETER VERSION

To build the potentiometer-follower version, we need to backtrack a little. There are some differences in the wire links around IC2: Namely, there are fewer of them, and those which remain are in a different place. The 510Ω resistor has also moved slightly left.

After that, the single 5kΩ trimpot was installed, along with two wires to be soldered to a 5kΩ potentiometer. One of these goes to the pin 6/7 junction of IC2, while the other goes to the trimpot. We soldered one wire to one end of the taper of the potentiometer, and the other wire to both the remaining end, and the wiper. If you mount your potentiometer and find the servo direction of rotation is opposite what you expect (in other words, it turns clockwise when the servo turns anticlockwise), reverse these connections. Note that the photo was snapped before the power supply filter capacitors were installed. Also note that we completely forgot to add the wire links joining the supply rails! These were added before we tested the circuits.

Finally, all of these photographs show the IC1 astable section with a 1kΩ potentiometer fitted. We specified 2kΩ in the parts list and schematic, but were waiting on fresh stock when we built this. The 1kΩ trimpots theoretically have the range we need (the calculated value is 893Ω) but with the combination of capacitor tolerance and trimpot tolerance both being 10%, a 1kΩ potentiometer may not cut it in

some builds. In fact, we came very close in one of our builds, when a capacitor was found to be close to 110% of its nominal value and the potentiometer was at 90% of its nominal value. Measuring the capacitor and trimpot values is very helpful if you have enough to choose from.

CALIBRATION

Calibrating these circuits is best done with an oscilloscope, but not everyone has one. In fact, quite a lot of makers do not have one. Accordingly, we’ll show you both the multimeter version, and the oscilloscope version.

THE ASTABLE SECTION

Calibrating the astable section involves first setting the low T2 period to be 500µs, then adjusting the overall frequency to be 50Hz. If you are using a multimeter, first measure the value of the 560nF capacitor. This is very helpful in knowing what to do next. Then, add this measured value to the astable T2 equation presented earlier, to gain an actual value for RB, which is the 2kΩ trimpot in this build. If you do not have a multimeter that can measure capacitance, or an LCR meter, you’ll have to accept the nominal value of the capacitor. In that case, you can use our calculations from earlier (which were performed with nominal capacitor values). Either way, connect a multimeter to the 2kΩ trimpot by using pins 6 and 7 of IC1, and adjust until you see your calculated value, or 893Ω, depending on what you need.

By the same token, measure RA, the 100kΩ trimpot, between the supply rail and pin 7. We acknowledge that it is best to measure resistance out of circuit in case of stray paths and other effects, however we elected not to in this case. With the IC unpowered, there is negligible connection between the IC ends of the resistors, and anything else. The nominal value for this is 49 750Ω, or whatever value you get after recalculating T1 with your measured capacitor value. The challenge is that most multimeters measuring in the 10x k range will display 49.7kΩ here, with no further resolution. You can watch carefully for the point where the display changes from 49.6 to 49.7, then again from 49.7 to 49.8, and try to adjust to the middle of this point.

If using an oscilloscope, connect the ground clip to the ground rail and the probe to pin 3 of IC1, and turn on the power. Adjust the vertical resolution until you are comfortable to view the whole waveform, then the horizontal resolution until each graduation is 100µs. Then, adjust the 2kΩ trimpot until the low period is 500ms. Then, adjust the 100kΩ trimpot until the frequency shows as close as you can get to 50Hz.

CALIBRATING THE SWITCHED VERSION

The output section can be calibrated in a similar manner to the astable section. First, turn the second trimpots in each series pair (the yellow dot ones electrically closest to the IC) to be at its minimum. You can check with a multimeter when you hear the click of the limit being reached. It should read 0Ω. If you are using nominal capacitor values, turn the trimpots that are closest to the supply rail in the series pair (electrically closest, the red dot ones in our pictures) until the value between the supply rail and the output of the wiper reads 5kΩ. Do the same for either side of the switch.

If you are using a measured capacitor value, recalculate based on the equations from earlier, and adjust these first trimpots to be the desired value in order to have a high period of 1ms.

For oscilloscope calibration, connect the ground clip to the ground rail, and the probe to the output pin 3 of IC2. Adjust the horizontal scale until each graduation is 500µs, and adjust the trimpot electrically closest to the IC (the yellow dotted ones in our pictures) to be 0Ω. You might want to check with a multimeter, but we did do this during construction. Then, adjust the red-dotted trimpot, the one electrically closest to the supply rail, until the oscilloscope display shows a high pulse of 1ms. Do this again for the other switch position.

There is also a super-rough but effective method. With the second (yellow-dotted) trimpots set to 0Ω, turn the relevant red-dotted trimpot, the closest electrically to the supply rail, until the servo begins to move. When it does, turn the trimpot back and forth until you have found the exact point at which movement begins.

With either method, after this, the calibration is entirely nominal. With power applied, turn whichever of the second trimpots (the yellow dots in our pictures) the switch is currently selecting, until the servo has moved to where you want it to for that switch position.

CALIBRATING THE POTENTIOMETER-FOLLOWER VERSION

This one is even easier. For a multimeter, turn the trimpot until the value between the supply rail and pin 6/7 of the IC reads 5kΩ. If you are using a measured capacitor value, recalculate the equations from earlier to find the required value.

For an oscilloscope, set the horizontal resolution to 500µs per division, then turn the potentiometer until it reads 0Ω between the end of the taper, and its conjoined wiper/taper junction. Adjust the trimpot until the output pulse is 1ms.

WHERE TO FROM HERE?

The circuit is not perfect, but perfect would be far more complex that we were willing to commit to. Explored with both all the servo types we have in the workshop, and close examination with an oscilloscope, we haven’t found any problems with the behaviour of the circuit which will stop a servo working, or damage it.

The one thing we have not yet explored are the reports online that servos can be crudely speed-controlled by varying the frequency. Given the design of the astbale section to have a fixed T2 low time and a variable T1 high time, this should be straightforward for those wanting to explore it.

The next step we can think of is to adapt the switched position version to have multiple positions rather than two, with a rotary switch involved. We originally decided to have two identical sets of resistors for the two-position version. However, after we completely finished the build, solder version included, we realised that a more practical way to do things would be to have one minimum value, for the 1ms end of the chain, and as many trimpots as needed after it, connected to a suitable switch. You could also have a series of pushbuttons for different positions, rather than a rotary switch.

The other potential alteration is a transistor or MOSFET drive section for the output of IC2. We haven’t found any sevros yet which require this, given the 200mA capability and 5-15V range of the NE555. However, we would not be surprised to find them out there. Given that most of the relevant servos (servo is a term that covers position-controllable motors other than the radio-control style we have been focusing on) work on 5V, 6V, or 7.4V, a load voltage above the circuit supply voltage is unlikely, but possible. You may also wish to separate the control circuit and motor power supplies. The reason we tried to condense the circuit board so much was to leave room for a possible transistorised output. Given the switching time, a regular bipolar transistor would be more than fast enough for the job, but MOSFETs are faster still for those who want an ultra-crisp switching waveform, and have the advantage of being effectively voltage-isolated from the drive circuit: The gate voltage needs to share a ground with the load voltage, but the load voltage can be much higher. This is hard to achieve with a transistor output, making a MOSFET the simple option. The 200mA output from the NE555 is enough to overcome the gate capacitance issue, particularly if a logic-level device is used.

However, because we need a timed high pulse, the 1ms to 2ms that we’ve been chasing this whole time, the output MOSFET needs to be a P-Channel type, which can function as a high-side switch. P-Channel MOSFETs need to have a gate voltage pulled below 0V (with respect to the gate), and this is a bit awkward with the output we have. You need a transistor arrangement to provide this, and it’s beyond the scope of this article given the number of other things that need to be explained with it.

For most people, the best way to drive a servo with a higher voltage than the circuit, or with a separate power supply, is with an optoisolator. Then, a regular transistor circuit can be used to give the high-side switching needed to repeat the PWM signal. You may find adjustments are needed to the trimpots to compensate for switching time in this circuit.

Daniel Koch

Staff Writer