I have multichannel serial data from an 8 channel ADC chip that I'm connecting to my computer via a serial-USB cable. I want to use these separate channels in Pure Data, but the pd_comport object doesn't read multi-channel serial data. I've scoured the Pd discussion fora but there's no mention of how to do this. Any thoughts on how I can go about it?
1 Answers
per definition a serial connection is only single-channel. if you have multiple (synchronized) channels, it's called parallel.
so your problem is basically one of the two following:
parallel serial streams
if you are transmitting the 8 ADC-channels via different serial connections, your (special) cable should register 8 different devices (e.g. /dev/ttyUSB5
, /dev/ttyUSB6
, .../dev/ttyUSB12
).
in this case, simply use multiple [comport]
objects (one for each serial device you want to interface)
single multiplex stream
in the (more likely) case, that your ADC transmits it's 8 channels in a single serial connection by multiplexing the data, you will have to demultiplex the serial stream yourself. how to do this, is very much depending on the actual format of the data.
assuming your ADCs are only 8bit and you have only 4 channels (for simplicity), then you might receive a serial stream like: ... A1 B1 C1 D1 A2 B2 C2 D2 A3 B3 ....
(with A, B,... being the samples for the 4 channels; and 1,2,... being the sample frames), then you could demultiplex the signal into 4 streams with something like
|
[t b f]
| |
| +------------+ |
[i ]/[+ 1]/[% 4]/ |
| |
[pack 0 0]
|
[route 0 1 2 3]
| | | |
in practice your protocol might look slightly different (e.g. there ought to be a way to specify frame boundaries (there's no way by just looking at the numbers, whether you are actually seeing A1 B1 C1 D1 A2 B2
or B1 C1 D1 A2 B2 C2
, so it's unclear whether the 1st sample belongs to channelA or channelB).
thus you really must get your hands on the protocol definition and interpret the data you get from [comport]

- 28,885
- 9
- 68
- 122