From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-28-2016 08:48 PM
Hi,
I am quite new to Labview and Arduino, so excuse me if I use incorrect terms. I am having some troubles with the following project, I hope you guys can give me some guidance!
I have 16 sensors connected to 16 analog pins on an Arduino mega board. This board has a wireless shield mounted on it, with an Xbee module. I have another Xbee module which communicates with it and is mounted on a USB dongle that plugs into a PC, with Labview 2015.
The A/D output from the Arduino analog pins is read and sent every 50ms to the Xbee module connected to the PC. So every 50ms (that is, a sampling frequency of 20Hz), a new line of comma separated analog readings is sent, using AnalogRead and Serialprint in Arduino. This data is fed to a Labview code with a producer-consumer architecture. This code configures a VISA serial port, reads the data, converts it to a voltage value and writes the data to a text file (see block_diagram.jpg).
The problem is that at a sampling frequency of 20Hz (with the configuration of the attached jpg) when reaching 400 processing iterations the code drastically slows down and values are not parsed correctly. It behaves as if the queue was overflowed (but queue elements indicators show 0), or memory or buffers were full. This seems quite suprising to me since the sampling frequency is so slow. I tried a couple of configurations setting buffer size, flushing the buffer, using waiting times but nothing seemed to work. Is it because the processor loop takes too much time to iterate? I tried disabling the data parsing, the voltage conversion and the text file generation, and just keep the dequeueing reading, and still got the same behaviour.
What may be causing this? Any suggestions to modify the block diagram are very welcome! Is there a more efficient way to do this than with VISA, or queues...?
I am using Labview 2015 on Windows 7.
Thanks!!
Solved! Go to Solution.
03-29-2016 05:11 AM
@sminanog wrote:It behaves as if the queue was overflowed (but queue elements indicators show 0), or memory or buffers were full.
You are thinking along the right things. But the big problem I see here is that you have an ever growing array until you stop the program. You should move the writing of the file to be inside of your consumer loop. This will eliminate the need to constantly grow your array in the shift register, using up tons of memory and causing memory copies (which gets very expensive).
The other concern I have is the rate at which your data comes in. If you have a Baud Rate of 9600, then in the 50ms you can transmit 48 bytes. That leaves 3 bytes per sample, including the comma. If you have a baud rate of 115200, this turns into 576 bytes you can send in the 50ms. So the lesson here is to make sure you are using a baud rate that is fast enough to handle the data you are trying to send.
04-05-2016 11:37 AM
Hi crossrulz,
Thank you very much for your help, it was indeed the baud rate that was too low for the data being sent. I was so focused on the Labview code that I didn't realize, so thanks for the insight!