From ProdDocs
Jump to: navigation, search




The ServoPAL is a tiny module that plugs in between your microcontroller and two servo motors to pulse the motors so your microcontroller doesn’t have to. In addition, it provides an “alarm clock” function to perform timing in the background while the microcontroller is busy with other tasks.

ST-00074 Servo PAL DSC 1607 1280x1280.JPG ST-00074 Servo PAL DSC 1595 1280x1280.JPG ST-00074 Servo PAL DSC 1604 1280x1280.JPG

Product Features

  • Plugs in between servo headers and servos: no wiring necessary.
  • Simplifies programming for both standard and continuous-rotation servos.
  • Pulses two servos continuously based on single incoming pulses received from the microcontroller.
  • Provides an alarm output (200mS to 30 min delay), which can be set by a single pulse.
  • All interfacing is done by pulsing: no serial protocols to learn.
  • Runs from the servo’s power (up to 6.5VDC): no additional power source needed.

Technical Details

  • Power requirements: 5 to 6.5v
  • Communication: Pulsing
  • Dimensions: 3/4 x 3/4 x 3/16 in (20 x 20 x 5 mm)
  • Operating temp range: -32 to +158 °F (-0 to +70 °C)

The ServoPAL was originally launched by Parallax under stock code #28824 and it’s currently made by SimplyTronics as stock ST-00074.

What's Included

ST-00074 Servo PAL DSC 1594 1280x1280.JPG

What You Need to Provide

  • BASIC Stamp and carrier board (such as the BOE)
  • One or two servo motors


Installation of the ServoPAL is a simple:

  • 1. Unplug the servo connectors from the servo headers
  • 2. Plug the ServoPAL into the servo headers. (See diagram below.)
  • 3. Plug the servo connectors into the ServoPAL.


Below is a photo of the ServoPAL installed on a BOE-Bot’s P12/P13 servo header. The wheel servo motor cables are plugged into the ServoPAL. In this case, the /Inp input pin is P12, the Alarm output pin is P13, the right servo is Servo 0, and the left servo is Servo 1.


Hardware Interface and Initialization

Interface to the ServoPAL is realized through its /Inp input and Alarm “output”. When the ServoPAL powers up, both lines are configured as normally-high inputs, pulled up to a nominal +5V through internal 20K to 50K resistances. Commands to the ServoPAL are sent as negative pulses to the /Inp pin. If the alarm feature is not used, the BASIC Stamp can use the Alarm pin for any other purpose. If this is done, however, you must be careful not to trigger an alarm inadvertently, or else a bus conflict may occur.

The ServoPAL runs autonomously on power obtained from the servo headers. Therefore, it does not reset when the BASIC Stamp resets, and continues to send out pulses during and after reset if it was sending them out before. But it can be reset, nonetheless, by sending a pulse of 100mS duration to the /Inp pin. Here’s the recommended initialization sequence for the ServoPAL in PBASIC:


This sequence accomplishes a couple things:

  • In systems, like the BOE-Bot, where the servo power is switched on after the BASIC Stamp powers up, it will wait for the ServoPAL to be turned on. It does this by setting the nInp line to an input and waiting for that line to go high, signifying not only that that the ServoPAL has powered up, but that it has come out of reset and engaged its internal pull-ups.
  • In case the ServoPAL was already running, it then sends a long reset pulse to terminate any servo pulses, to abort any pending alarm, and to ready the ServoPAL for further commands.

Programming Servo Pulses

Servo pulses are programmed in much the same way you’d send pulses directly to a servo motor, using the PBASIC PULSOUT command. The only differences are that the pulses are negative-going instead of positive and that both servos are programmed from the same pin. Here’s an example that will cause the Servo 0 output to begin pulsing with 1.5mS pulses. These pulses are automatically repeated every 10- 15mS without further intervention from the BASIC Stamp.

Capture 3.JPG

Notice that this is identical to the statement that would have been used, had the servo been connected directly to the BASIC Stamp. Once the initialization code is executed, your program is primed for negative-going pulses, and you don’t need to do anything special to send them. Here’s what the waveforms look like that result from the above example:

Capture 4.JPG

But what about Servo 1? There’s only one pin, so how does it get programmed? That’s easy: just send another pulse within 1mS of the first one, and that one will be assigned to Servo 1:

Capture 5.JPG

The preceding code will program Servo 0 with a pulse width of 1.5mS and Servo 1 with a pulse width of 2.0mS. Here’s what the waveforms will look like:


To terminate a sequence of pulses on /Inp, just wait at least 2mS before sending another pulse. This signals the ServoPAL that the next pulse is intended for Servo 0.

Now, what if you want to program only Servo 1 and leave Servo 0 alone? That’s easy, as well. Just send a very short pulse (4 – 100µS) for Servo 0 first, then a pulse for Servo 1. The ServoPAL will interpret the short pulse as indicating that you don’t want to change Servo 0’s pulse stream, if one has already been programmed. Here’s an example:


Here’s what the resulting waveforms look like:


 Note: Do not send the ServoPAL any pulses less than 4µS in duration. It could easily become confused, as it might miss them entirely.

And finally, what if you want to terminate a servo’s pulse stream? The ServoPAL will only send pulses to a servo that are between approximately 0.5 and 2.5mS. If it encounters a request for pulses well outside this range, it will cease sending pulses to the affected servo. Here’s how you can use this to stop sending pulses to a servo:


Here's the result:


To summarize, here’s a table showing the various pulse durations and what they mean:

4 - 100µS Skip this servo. (Don’t change its output.)
0.5 - 2.5mS Program this pulse width into the affected servo
4 – 30mS Kill the servo’s output
100mS or more Reset the ServoPAL

Pulse widths outside the individual ranges shown may have unpredictable effects.

Programing the Alarm Function

In addition to servo control, the ServoPAL has an alarm clock (timer) function. You can set an alarm to occur anywhere from 200mS to 30 minutes after it’s set (triggered). For programming purposes, the timer is treated by the ServoPAL as a third servo: i.e. after sending pulses for Servo 0 and Servo 1, you send a pulse for the timer. As soon as such a pulse is received, the Alarm output is pulled low. It will remain low until the programmed time elapses, whereupon it will again float and be pulled high by means of the internal pullup resistor.

The relation between the pulse width sent by the BASIC Stamp and the actual time programmed into the timer is

Programmed time = Pulse width * 50000 (approximately)

So a pulse width of 4µS yields a timeout of 200mS, and a pulse width of 36000µS yields a timeout of 30 minutes. In terms of PULSOUT units, here’s the timing for various BASIC Stamps:


Here’s a BS2 program fragment that sets the timeout period to 5 minutes:


And here’s the output waveform:


One additional thing to note about the timer is that it’s retriggerable. What this means is that if you set it before a previous setting has timed out, it will start over with the new timeout value. This feature makes the ServoPAL useful as a watchdog timer for the BS2p, BS2pe, and BS2px, which support automatic polling. As long as you keep resetting the watchdog timer, the Alarm output will stay low. But if your program hangs up somewhere, the timer will eventually time out and the rising edge on Alarm can be used to (re)start the program specified by POLLRUN.

Simple Example Program

Here’s a simple-minded BS2 program that moves a BOE-Bot forward for 5 seconds, then in reverse for five seconds, using the Alarm output as a timer:

File:28824-ServoPAL-Simple-Demo-Code (1).zip

IR Roaming Program

The next example is an IR roaming program for the BOE-Bot. To use this program, you should connect the IR emitters and sensors as shown in Parallax’s Robotics with the Boe-Bot, figure 7-4 (copied below).


The program works like this:

  • 1. Start the BOE-Bot moving forward.
  • 2. Keep checking for obstacles until one is found.
  • 3. If obstacle is on left or right, begin turning in opposite direction.
  • 4. If obstacle is in front, back up for one second, then begin turning right for at least ½ second.
  • 5. Continue evasive action until clear of obstacles AND any timed motion has completed.
  • 6. Go to step 1.

Here’s the program: