From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My graphical display of converted hexadecimal numbers changes with every run!

Dear all,

I've created a Vi that can select and convert hexadecimal numbers from a string array. These hexadecimal numbers contain acceleration data (units g).
My string array (from line 68+) places every 10 rows a 1 line of hexadecimal number with a length of 300. I've managed to convert this into 1D array DBL.

My current problem is, when I run my for loop my graphical representation of the acceleration data changes overtime!

Can anybody help me solve this problem?

Thanks in advance

0 Kudos
Message 1 of 4
(1,978 Views)

It's likely because you have race conditions.  LabVIEW is a data flow language.  It will execute code when the data is available.  By using the value property nodes, you have broken your data dependence.  Use wires instead.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 4
(1,972 Views)

You have four code islands that all start in parallel.

 

When you run the program, the code segment on the right immediately reads the three value properties (Since the corresponding indicators have not been updated at this point, they are most likely stale or empty). Once this part is done, the graph will never update again and changing the ring later will not make a difference.

The three FOR loops also start in parallel with the same problem. the Array value property is read before the loop below had a change to update the indicator. The big loop starts while the "element" array is still being filled, leading to completely unpredictable results.

 

Overall, the code does not make a lot of sense. Lost of duplicate code and lots of dead code. I have the feeling it could be done with 20% of the code overall. In many places you could use autoindexing.

 

0 Kudos
Message 3 of 4
(1,943 Views)

I found a little dead time and decided to have a little fun cleaning up.  Notice that I removed the FOR loops on the left side.  The biggest thing was that I used the Read Text File configured to read lines (it gives me an array of the lines in the file), got rid of the first 68 lines, and then passed that array into the FOR loop.  Your code there was next to impossible to figure out, even with the comment.  I have no clue where you came up with trying to update every 25ms.  It shouldn't take your processing that long.  Instead, just index out the lines inside of the loop.

 

There's still a bunch of cleaning up to do, but it's quitting time for me.  I'll try to get on sometime this weekend of you have more questions.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(1,931 Views)