From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-20-2019 09:39 AM
Hello,
I'm attempting to read a stream of serial data at a baud rate of 9600. I've attached the main VI (FAV-1 Flight Testing Data Recorder_serial) in addition to the subVI's for that program. The DAQmx functions all work perfectly - I'm just debugging the serial read and write to file functionality.
I receive the error AFTER I press the stop button and the program has been running for more than a few seconds. I do not get the error when the program has only run for 3 or 4 seconds. So far, the error hasn't terminated the program prematurely but as with any buffer-related issue I suspect that it will after the program has been running for a while.
I've implemented the advice on other forums for correcting this error including:
- using producer/consumer architecture
- ensuring that the serial settings match the serial device
- using the terminating char functionality
I've also read that I can manually increase the buffer size, but the default value is 4096 bytes. The device producing the serial data is sending three streams in a continual rotation: one data stream of 225 bytes, one that is 93 bytes, and one that is 74 bytes so the current buffer value should be plenty large enough.
Any advice would be greatly appreciated.
Thank you!
03-20-2019 10:35 AM
OMG: I hate to sound mean but you need to just throw this out and start over with a proper program architecture.
One Big Loop (OBL) is never a good program architecture. I know NI makes it look like that's the only way to write a LabVIEW program in their training. But that's because all the training programs are very simple.
Just fixing your serial overrun would be analogous to putting a band-aid on a bullet wound.
03-20-2019 12:48 PM
Your comment isn't mean, just unhelpful.
What changes would help make this program better? Putting each DAQmx read in it's own separate producer loop and/or it's own subVI? Put the consumer loop in a separate subVI?
Thanks,
Sheila
03-20-2019 04:14 PM - edited 03-20-2019 04:17 PM
There is just so much wrong...
For instance this:
Could be replaced with this:
I don't have a DAQ so the DAQ I/O array constant did not populate properly.
03-20-2019 04:46 PM
Thank you for taking another look and clarifying. That is an elegant solution if each strain gauge had the exact same gage factor, resistance, poisson ratio, etc., which it does in this program only as a placeholder until the gauges arrive.
You alluded to the fact that having all the data collection occur in one big loop is not good. I split out all the DAQmx Read vi's and the serial read vi into their own producer loops with a 50ms wait, which solved the overrun error issue (for now at least - I haven't run this for more than a couple minutes).
03-20-2019 04:57 PM - edited 03-20-2019 05:01 PM
Sure, but it's nothing to add another array constant or two for the parameters that are different. Imagine a larger setup where these values are read from a file. You would read the file once and put all the values into an array, then feed that array to a loop like this...
A lot of this code can be refactored as I have done with that one part. Look for repetitive tasks where only one or two parameters change and put them, in a loop.
I see you attempted some sub-vi's but more of this could be done.
It is a very common thing to try to keep your code small and neat so you can see it all on one screen. When it starts growing and you are constantly scrolling left, right, up, and down then it's time to start refactoring and simplifying.
Also next time you post a VI with lots of sub-vi's zip them all into one file and upload it.
10-26-2021 01:33 PM
I keep getting over run errors, please help!!!