SRCMBC Banner
   


Servo Controller


...  

Servo Controller For R/C Models

Overview
This module was developed for the control of servo operated guns and cranes mounted on the decks of model boats, but aircraft, military and robotics modellers etc will doubtless find other applications for it. It combines the functionality of an R/C switch, a servo-slower and a servo stretcher in a single unit not much larger than a standard servo.

The R/C switch function detects joystick positions either side of a centre deadband and sets the servo moving in the appropriate direction. Releasing the stick (to centre) at any time stops the movement and holds the servo position achieved. The end of travel limits for port and starboard can be individually set by the user. Also, if the servo can cope with being (mechanically) over-driven, the usual +/- 45 degrees of available swing can be extended up to a full +/- 90 degrees, thereby avoiding having to gear up the servo shaft to achieve such an angle of rotation - this solution is also free of the backlash and jerkiness associated with gearing or chain drive. The traverse rate of the servo can be set to take from approximately 2 to 30 seconds from end-to-end (180 degree swing)

So What Does It Actually Look Like In Action?
Below you can access two short video clips that show the unit in operation. In the background of the one taken in the workshop you can see the servo tester being operated and note how the servo moves in response to that. The second one shows it driving the gun turret on a moving boat.

control demonstration in action afloat

Programmable Interface Controllers (PICs)
The high degree of functionality of this module is made possible by using chips called PICs (programmable interface controllers) -aka microcontrollers.

The particular variant of PIC I am using is called the 'PICAXE' which is programmed in BASIC. As well as being easy to understand and use, this particular dialect of BASIC has many specialised commands intended for radio control and robotics applications which renders it ideal for this project. A good starting point to see the entire range of PICAXE chips, their support hardware and accessories - not to mention downloading the free programming editor software - is on the TECHNOBOTS site.

Arrangements have been made with TECHNOBOTS to supply all the specialised components required for this unit, including a pre-programmed PICAXE chip) as a complete 'kit'. The circuit diagram and assembly drawings are available for download from the TECHNOBOTS site, where the software (source code) may also be found for those wishing to program the chip themselves and/or tweak the code.

Hardware
The input signal from the receiver (via PL1) is converted if necessary to a full range 5v signal required to interface with the PIC (U1) by a transistor buffer stage (Q1, R1, R2, R3) which has the consequence of inverting the polarity of the signal, but this is dealt with by the software. This gives compatibilty with receivers which have insufficient output voltage swing to operate the PIC.

The potentiometer RV1 is connected to one of the PIC's ADC channels (analogue to digital converter) and is used to set the limits of travel during a set-up phase or in normal operation it sets, in real time, the slew rate of the servo.

Link LK1 and pushbutton switch SW1 are connected to the PIC's digital input channels. LK1 is used to invoke the set-up routine and SW1 is used to step through the stages of the set-up.

The servo (connected to SK2) is driven directly by one of the PIC's digital output channels.

C1 and C2 serve to decouple the supply rail from high frequency and low frequency disturbances respectively.

Software
The published software has been extensively commented so it is proposed to just give an overview of its operation in general. If any points are still obscure please e-mail me. A listing of the software is available here as a pdf file.

At power up the status of LK1 is checked. If it is in the normal run position, the user defined limits of travel are retrieved from the PICAXE's non-volatile memory, the servo is commanded to centre position and the software enters the main loop.

The setting of RV1 is then read and quantized into 10 possible values which determine the servo traverse rate required. The parameters used to define the chosen traverse rate are read from a 10 element lookup table.

Next the pulsewidth of the input signal is measured. If it exceeds the preset values then movement direction flags are set accordingly. A large deadzone has been set such that joystick movements on the neighbouring channel are unlikely to trigger an accidental servo movement request.

The servo then drives a small positional step in the direction determined by the appropriate flag, before returning to the main loop. Each time round the loop the input signal is checked and the servo either continues, stops or reverses as commanded. The servo is also checked to see if it has reached the end limit yet and if so it stops there until commanded to reverse.

The basic servo slowing action is achieved by only moving the servo position by 5uSec increments once each time round the main loop, which itself runs at 50x per second. Thus to traverse from the standard 1mSec to 2mSec servo end positions would take 200 trips round the main loop - or 4 seconds. Longer periods are achieved by only nudging the servo every second, or third etc. time round the main loop and shorter periods are achieved by increasing the 5uSec positional increments to 10uSec or even 20uS.

The values for the positional increment and the number of trips round the main loop are held in the lookup table described above and are chosen to yield a relatively linear adjustment characteristic.

If link LK1 is not found to be in the normal run position at power up, then the software enters the setup procedure. The receiver input is ignored and potentiometer RV1 now controls the servo position directly, allowing the user to set the clockwise limit of travel. When the desired position has been set, pressing the pushbutton SW1 stores this position in the PIC's non-volatile memory and then assigns RV1 to control the servo to set the anticlockwise limit of travel. Again, pressing SW1 stores this position in the PIC's non-volatile memory and the program then drops into the main loop, where now at any time, RV1 adjusts the servo's traverse rate.

The Build
A brief overview of the build is given below. More detailed instructions are beyond the scope of this article but a 12 page full colour booklet with step by step photos is included with the kit.

The drawings below show a strip-board layout which has been designed with the less experienced constructor in mind. To keep the unit as small as possible, a personal computer serial interface has not been included so the constructor must have his own means of uploading the published program into the the PIC chip, or buy a pre-programmed chip instead.

track cutting guide the cut stripboard

The strip-board should be cut to size and then the tracks cut in the indicated positions. A 3 or 4 mm drill bit makes a good track cutter - just place the tip in the appropriate hole and twist it back forth between your fingers. Lowest profile parts should be inserted first so that means the wire links. Note that to save space, there are wire links beneath U1, SW1 and RV1 so they must be inserted before these components are fitted. Then add the components in order of ascending height. Finally fit the programmed PICAXE chip.

parts layout built unit

The flying lead plug and socket (PL1 and SKT1) are made from cutting a servo extension lead in two. The cables are positioned for exit from the box (if used) and fastened in place with a turn of fishing line, button thread or similar threaded through the stripboard holes (see photo at top of article). Finally check for solder splashes between adjacent tracks, the most common fault in strip-board assemblies.

For those club members who feel unable to attempt the precision assembly and soldering or chip programming, I might be conned into making a unit for you at cost, for some assistance in return with glamorizing the temporary cardboard decking and superstructures for which my models are famed, or maybe I could be tempted by some article from your junk-box.

Non club members always have the option to buy a ready built and tested unit.

Set-up And Installation
Initial testing of and familiarisation with the unit can be performed on the bench using a spare servo and a servo tester. If the latter is not available a transmitter and receiver can equally well be used. If the unit is to be fitted in a box for protection from moisture and accidental shorting, then it must be set up driving the servo prior to putting the lid on!

The set-up mode can only be entered following a power-up with link LK1 in the set-up position. During the set-up mode the unit ignores the receiver input and is controlled entirely by the potentiometer RV1 and push-button switch SW1.

link in 'set-up' position link in normal 'run' position

Set RV1 fully clockwise, put jumper-link LK1 in the set-up postion and then power-up the unit. Now adjust RV1 to set the desired limit of clockwise rotation. Care must be taken when exceeding 45 degrees of travel from the centre position that the servo is not driven into its mechanical endstop for any significant period of time as its motor will be stalled and it, or its driver circuitry may overheat, with potentially fatal results. The amount of over-travel available varies with different models of servo, so again care should be taken if moving the (set-up) unit to a different model.

Once the clockwise rotation limit is set, press the pushbutton SW1. This locks that position into the unit's memory and then assigns RV1 to adjust the anticlockwise rotation limit. The same caveat applies to settings in the over-travel region.

When the anticlockwise rotation limit has been set, press the pushbutton SW1 again. This locks the anticlockwise position into the unit's memory and then drops the program into the main loop and the servo movement will now respond to the receiver input. At this point, don't forget to remove the jumper-link and park it in the normal run position, otherwise next time you use the unit you will enter set-up mode.

RV1 is now operational at all times for adjusting the rate of traverse of the servo and may be set whilst the servo is moving to choose a 'realistic' speed for your gun/crane etc.

Future Enhancements
If sufficient interest is displayed, the next logical step could be to implement a "fire" function for gun control applications. This could take the form of operating a relay for use by your own effects units or possibly a crude PICAXE generated machine gun sound I have developed - but how to activate? Another channel? . . . . maybe the digital Ch5 or Ch6? . . . . or automatically at the extreme of traverse? . . . . Over to you!

I look forward to discussing all or any of the above with you, at the pondside, by e-mail, or by using my Feedback form.


Page maintained by Alan Bond Last modified: 13:34, 10 June 2009