[PD] comport and servos
Hans-Christoph Steiner
hans at eds.org
Thu Jun 22 22:07:59 CEST 2006
Sounds like a crazy hack, but fun stuff for sure. Maybe this will
give some insight to serial port jitter in general when using
[comport]. I measured 0.5ms to 22 ms for roundtrip latency on the
serial port, with an average of around 12ms. So I guess that
translates to 0.25ms to 11 ms with an average of 6ms for just sending
or receiving.
But that is some serious jitter. I am wondering how much is caused
by the hardware and/or OS buffering and how much is caused by Pd and
the [comport] object. It would be nice to reduce the jitter caused
by [comport] as much as possible.
.hc
On Jun 19, 2006, at 10:04 PM, Martin Peach wrote:
> 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
>
>
>
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/
> listinfo/pd-list
------------------------------------------------------------------------
As we enjoy great advantages from inventions of others, we should be
glad of an opportunity to serve others by any invention of ours; and
this we should do freely and generously. - Benjamin Franklin
More information about the Pd-list
mailing list