07-11-2016 03:27 PM
Hello. I have a Teensy 3.1 ADC sending out data at a rate of 1KHz to the serial port , and i have a while loop that reads the port by using "Bytes at port " as counts to "read serial " block with a time delay of 1 milliseconds inside the while loop.It seems though i read with or withot the time delay inside while loop ,i miss the data in between in a random manner.
The data after converting into numbers using "spreadsheet string to array" function in a waveform chart, i see random spikes and dips for a sinusoidal wave fed as an input which is of 1 Hz frequency.
I doubt that while reading itself ,the strings are being concatenated with one another which creates these random spikes.,since a continuous sine wave input should provide a smooth waveform output in the chart.
I have taken ADC data from Teensy directly and plot them in Excel sheet, and no spikes at all.
Can the problem arise from labview not in synch with ADC outputrate ? or the conversion from strings to numbers?
Please have a look at the VI i have attched.
Thanks .
07-11-2016 03:51 PM
roopesh689,
Your description gives no details on how the Teensy is transmitting the data.
07-11-2016 08:33 PM
The Bytes At Port is an almost guaranteed way to get out of sync with your data messages. Mind sharing the code you have for your Teensy? That would tell us what the messages it is sending are and we can make a lot better suggestions from there.
07-18-2016 03:52 AM
You can see the Teensy code attached below.
We get AsCII characters from Teensy.
The delay of 1000 microseconds are kept in code for samping frequency of 1 Khz.
07-18-2016 04:05 AM
The strings miss in between and after concatenate them the result is some like this
16112 65536 65536 65536
16114 65536 65536 65536
65536 65536 65536
16118 65536 65536 65536
The ADC data are send sequentialy at 1 khz samples .After concatenate them the channel data are not in order since in between channel reading is lost somehow.Hence it creates a sudden drop or spike in waveform plot as well.
07-18-2016 07:10 AM - edited 07-18-2016 07:10 AM
1. It looks like your Teensy is actually performing the read twice per iteration. Is that by design?
2. You are using a PrintLn at the ench of each 4 measurements. This shows that you are using a termination character and it should be a carriage return (0xA). So enable using the termination character and tell the VISA Read to use more bytes than you would expect in a single read. This way you know you got the full message.