LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help speeding up program serial communications read and/or data calculations and/or writing to disk

Hi,

 

Please see the attached code for serial communication with a patient monitor; after getting help on the forums once before it works, but you wont able to run it without the monitor etc. Excuse the front panel its a mess:)

 

https://forums.ni.com/t5/LabVIEW/Serial-communication-problem-TermChar-Enable-to-False-and-ASRL/m-p/...

 

However I have pretty high spec'd laptop and it works ok enough, with a couple of second delay at the most, displaying on the screen, however the people using the software arent as lucky and it takes exponentially it would seem longer and longer to display. The realtime samples are coming through at 100Hz or one every 10msec.

 

I have read that I should only use serial communication calls sparingly, and yes the producer loop is taking about long to get the sample, but the consumer loop has too much to do it would appear (and yes I am writing two files to disk... well that is what was required). 

 

I have some ideas, including writing to memory first and then disk, creating a single loop for data calculations (hoping to reduce calls to VIs, or even stopping display to the monitor but then hard to know what is going on...

 

Any help or guidance would be appreciated and yes I am self taught. NM3v2.vi is the main file, I have included the subvis but let me know if anything is missing.

 

Cheers

0 Kudos
Message 1 of 6
(2,985 Views)

Sorry, I can't seen anything that sticks out but overall, there are many "strange" and inefficient code constructs.

  • Index array is resizable, so you only need once instance per location.
  • Instead of "bundle...cluster to array", just use "built array".
  • Your "conversions" are pure rube goldberg. First of all, your array constants are the wrong representation (should be U8), and there is no need to even convert to a string just to immediately typecast a nanosecond later.
  • There is no need to carry most of the data around as DBL. It just takes 8x more space.
  • Only one of the little inner cases can be true, so you could use a single case structure with N cases instead. You can wire the string directly to the case selector and display the radix as hex for easier readability.
  • What's the purpose of the outermost loop?
  • You don't need to constanty open and close the file with each write operation (highlevel file IO). open the file once before the loop, keep writing to it, and close it after the loop has finished.
0 Kudos
Message 4 of 6
(2,962 Views)

One other tip.  When dealing with more than 2 files, zip them up and attach the zip file to your message.  It is easier to download 1 zip file rather than 7 individual files spread over 3 messages.

0 Kudos
Message 5 of 6
(2,933 Views)

Thanks for the feedback! Very much appreciated and yes I am guessing that the learning curve was such that when I went looking for answers and found something that worked I kept repeating it ( I do admit at the beginning I thought some of the ways "labview" did things didnt make a lot of sense, though now I see it was my interpretation that didnt make any sense lol Smiley Very Happy). I will go about the improvements in the next couple of weeks but might check back in, and yes no idea about the outer loop...

 

Cheers!

0 Kudos
Message 6 of 6
(2,904 Views)