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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.