in reply to Any ideas for using perl as a simple pulse generator?

I'm driving a pump with electronic pulses. Writing a "1" to a file generates a pulse. ... I want to start one write exactly every 500 milliseconds.

I'm probably being thick, but wouldn't this be sort of equivalent to running a D-to-A converter (DAC) at, say, 48000 samples/sec, and sending it a stream in which a single high-value sample is followed by 23999 zeros?

If so, you could just declare an array of short ints big enough to hold 0.5 sec of samples, set the first element of the array to a high value, and set the rest to zero; hook the voltage output of the DAC (i.e. the audio jack) to your pump, open the audio device for output and configure it to the desired sample rate, then just keep pushing the array out to that device until you want to stop. Let the DAC's own clock handle the timing.

  • Comment on Re: Any ideas for using perl as a simple pulse generator?