Servo Motor

Adding a Servo Motor

I like to make things modular, so I created several general purpose modules. The original purpose of this module was to drive a servo motor based on 3 ultrasonic SRF05 inputs.

That’s why, when looking at the schematics, there seems to be so much connected. These are all alternative connections for other uses.

I used a Picaxe because it’s really a microchip PIC with a basic interpreter preloaded. It’s just pennies above the cost of a normal PIC and the ease of use is worth it.

The code turns the servo to one of 5 locations. The optimal values for the 5 locations are full left, half left, center, half right and full right. The speed at which it turns was found via trial and error. The command ‘pulseout’ gives a length of pulse proportional to the location of shaft on the servo motor. Changing the ‘pulseout’ value in increments of 5, 10, 50 and the pause time, gives the movement speed. A minus step speed reverses the direction. One problem you can run into is that the movement is too fast and the servo overshoots one way, then the other, giving an oscillation effect.

Example servoultrasonic schematic PDF
Example servo code PDF
I have included an example schematic

I used Kicad (open source software) to draw the schematic and layout the PCB. The PCB has traces on both sides.
Kicad creates a 3D view as well as gerbers.

3d PCB

The three groups of four holes (P1,P2,P3) on the right are for the SRF05 detectors.
They feed into the 28 pin picaxe (U19) on the left.
The three holes immediately above the (U21) 8 pin picaxe connect to the servo motor (J9).

Schematic description

In my application U19 scans the inputs available (in2, in3, in4), reads a binary number and jumps to the location suggested by the number. This translates the inputs to a rotational position turning the servo to the left or right. When it has finished moving the servo it rescans the three inputs, and makes the servo rotate based on the next set of numbers.