Hi! I'm trying to use the exodriver stream example (u6Stream.c) to get measurements from two 3 axis magnetometers.
This requires me to read either 3 or 6 channels by differential in a stream. In the example it is stated that nr of channels must be and even multiple of 25 (samplesPerPackage). Is there any way around this?
When streaming you can set SamplesPerPacket to 25 and have 3 or 6 channels. In general SamplesPerPacket is recommended to be 25 for efficiency, and will work with any number of NumChannels (that are valid).
The u6Stream.c example is just trying to be simple when it mentions SamplesPerPacket needing to be a multiple of NumChannels, and makes the math work out nicely for array sizes. If it is not a multiple, make sure to update this line of code:
double voltages[(SamplesPerPacket/NumChannels)*readSizeMultiplier*numReadsPerDisplay*numDisplay][NumChannels];
Since SamplesPerPacket/NumChannels is using integer math and will round down, causing the voltages array to be too small leading to array access being out of bounds.
Also, take a look at our differential readings app note:
https://labjack.com/support/app-notes/differential-analog-inputs
It can help determine if differential readings are needed, or if single-ended is what you want.