Continuing the cheapest servo controller in the world method, (not counting the computer)... I used a digital oscilloscope running at 50ks/s, so the best time resolution is 20us. Using a metro set to 20ms to send the number 0 through [comport], the jitter can be brought down to about 300us on my 200MHz linux pentium MMX linux machine. It is necessary to set the audio delay in Media->Audio Settings... to 20ms, that is, the same value as the metro. It is also necessary to enable and then disable "compute audio" on the main pd window. Leaving the audio enabled adds about 300us to the metro period, causing it to jitter at the 2ms level. Also, don't move the mouse or try to do anything else with the machine :(
It should be possible to control a single servo with this, but the output needs to be clipped so that it runs between 0 and 5 Volts instead of +/- 12 Volts. The easiest way to do this would be to put a 5Volt zener diode in series with a 1k resistor between the transmit data pin and ground:
TxD-----+
/
\ 1000 Ohm 1/4 Watt resistor
/
+-------------->to servo control
|
___
^ 5V zener diode
/
|
|
Gnd-----+-------------->to servo ground
A better way would use at least a transistor. For the same price as a single transistor an IC comparator like the LM311 running on the same power supply as the servo would be the best interface:
+5Volts-+-------to servo 5V
|\ | /
| \| \ 10k
Gnd----|+ \ / | ______________to servo control | / TxD----|- / | /| |/ | + Gnd-----------to servo Gnd
To control a servo, using 1200 baud, the numbers 0, 128, 192 and 224, 240 should position the servo roughly at 1/5 range steps. 240, 248, 252, 254 and 255 may be too short. The binary representation of these numbers is all 1s ending in all 0s. RS232 communications sends a 1 level (-12V) by default, and starts every character with a 0 bit (+12V). The least significant bit of each character is transmitted next, so to make variable pulse widths, 255 (all 1s) gives the narrowest pulse (just the start bit). Servo pulses are supposed to be at least 1ms and no more than 2ms, so 248 is probably as narrow as you can go at 2400 baud.
I fixed some more things with comport, but can't get them into cvs today (authorization failed, worked OK yesterday...). I'll try again tomorrow. Also I plan to make the DTR line settable so possibly that could be used as a cheap digital output as well. Martin