1
\$\begingroup\$

I've got an experimental box of tricks -- the console of an MRI scanner -- that spits out a 4 µs long, +5V TTL about every 100 ms, when something interesting happens. I'd like to ultimately create a timestamp in a file every time one of these happens, and write the data to disk on a linux computer that runs the show next door.

At the moment, as described on Stack Overflow, I've just wired the TTL into a parallel port on the linux box, and I poll it regularly by a high-priority process when the scan starts. Unfortunately, sometimes the process is suspended, and I miss a few (or a lot) of the short pulses.

Rather than handling the TTL as an interrupt, as my original question was about, it's been suggested that I use a hardware PIC to deal with the signals, and spit data back over USB (or ethernet) to the host machine.

Can anyone suggest a good PIC that can deal with short pulses, has an accurate timebase, and ideally already has a USB or TCP/IP stack implemented? I get the feeling that this has got to be a solved problem, I just don't know what to look for!

\$\endgroup\$
  • \$\begingroup\$ I'd recommend PIC32: It has an RTCC for getting timestamps, multuple high resolution timers for accurate timing, Interrupt pins for rapid response to pulses, and more importantly is available in the form of chipKIT development boards (chipkt.net) \$\endgroup\$ – Majenko Jul 12 '14 at 9:47
1
\$\begingroup\$

Does it have to be specifically a PIC, or are you mentioning that because it was suggested? Any small microcontroller should be able to accept that signal as an interrupt (or even polled) input and count the number of pulses. Both the pulse width and the repetition rate should be well within the capability of most MCU's. The controller can then be interfaced to a PC via USB or other serial protocol to download the result.

You are right in that it is a solved problem. One solution is to purchase a datalogger that can read the pulses and timestamp them. Then the list of timestamps can be downloaded.

I have a similar off the shelf solution: a pulse counter board (normally used to interface flowmeters to PC's) with serial output. It will handle reading the pulses, but the logging and timestamping would be up to you. I don't want to turn this into an ad, so I won't include a link. However if you're interested in the off the shelf solution, contact me.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

I'd use an RS-232 port. You could try seting up the serial port to 115200 bauds, ignore parity and framing errors and count the "characters". 115200 bauds means ~8 µs per bit; you can use a monostable (e.g. 74LS123) to make sure the pulse lasts at least that much; at 7/N/1 you're likely to receive 0xFF or 0xFE characters. You only need to count them! The only drawbacks would be that the pulses must not come at a faster rate than 1 ms and that you need a negative voltage for the pulse, but you could take that from the DTR signal.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.