Folks,
I am writing a Pd object to control a Sensable Phantom haptic device. For those of you who don't know what I'm talking about, a Phantom is a device which lets you feel virtual objects and force fields by manipulating a pen in free space. See www.sensable.com for more info.
For now, what matters is that the Phantom's servo loop runs at 1000Hz. In practice it's usually 3 or 4 microseconds off, but rarely more than 10. Furthermore, bi-directional communication is required. The signals on the 3 inlets of my object should get sent to the Phantom as the force to be rendered, and the 3 outlets should continuously spew out the position of the Phantom tip. (All inlets and outlets are audio-type.)
The difficulty I'm encoutering is the seeminly erradic scheduling of the Pd dsp tick. I tried timing it with Windows XP's QueryPerformanceTimer call, and it reported everything from 300usec to 20000usec between dsp ticks. And that variation was regular -- it wasn't just happening once or twice.
Why does Pd behave like that? I assume it can get away with it because the sound card buffers its output, right? But that's no good to me -- a sound card is uni-directional.
I tried communicating from Pd to the Phantom with a buffer in order to absorb the jitter. It seemed to work fine in one direction, though the bigger the buffer, the bigger the delay, from what I can figure. And delay is bad. So I'm hesitant to go through a buffer both ways.
But the performance so far with one buffer is not acceptable. The same algorithms that run fine without Pd cause noticable instability in the Phantom with it.
Is there any way to force Pd to run its ticks more regularly? Any other suggestions? OSC has been mentioned, but I don't see how it would help for this low-low level a problem. Please correct me if I'm wrong.
Thanks so much for your help.
you can't rely on the timing of pd's dsp tick! it's linked to the audio hardware and depending on how many samples of audio data the audio hardware is processing in one block, the pd's dsp tick is called several times to fulfill the requirements of the audio interface.
e.g.:
audio hardware: | | | | | pd: || || || || ||
if you need to synchronize with anything that requires more exact timing, the way to go would be to use another thread ...
hth ... tim
-- TimBlechmann@gmx.de ICQ: 96771783 http://www.mokabar.tk
Linux is like a wigwam: no windows, no gates, apache inside, stable.