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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

values written to a table are not preserved

Solved!
Go to solution

Hello,

I am building a tool based on state machine approcah as shown below:

Flow chart.jpg

Basically, this tool get access to a hardware device via its DLL file and send read request based on a predefined parameter values (parameters list), the recieved values are displayed on a table (output table).

The process is repeated for ever until user stop it.

in the mean time a log file is created and the results are saved on Excel file as shown below

Log excel.jpg

 

Problem: the problem is, the timestamp is not saved in the excel file and this is because the timestamp is populated for short time on Output Table as shown below.

In the below picture, you can see that output values are written and displayed on Output Table, but timestamp is displayed for short time (I can see this during Highlight Exceution mode) and when a new output value is written the previous timestamp will disappear!

TableOut.jpg

 

I can not find the reason of such behaviour, I want the timestamps and output values to stay displayed on the Output Table.

 

any advise?

 

I attached the complete project for your reference but is wont work without the hardware.

 

Best Regards

Hakam

 

Note: I am using Labview 2016

Download All
0 Kudos
Message 1 of 15
(3,472 Views)
Solution
Accepted by topic author hbs_80

Hi hbs,

 

RACE CONDITIONS ahead!

 

Learn to use shift registers and your problems are gone…

General recommendation: use less local variables and (much) more wire!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 15
(3,466 Views)

Are you using Replace Array Subset Function: https://zone.ni.com/reference/en-XX/help/371361J-01/glang/replace_array_subset/ it simply replaces the previous value.

 

Edit: Ignore this message.

Thanks
uday
0 Kudos
Message 3 of 15
(3,459 Views)

Hello GerdW

 

Actually this is my first project in Labview.

I am using shift register for the state machine and also for passing setting parameters but I can not imagine how can I use shift register for my Output Table. Both timestamp and output value are written inside the same loop.

0 Kudos
Message 4 of 15
(3,458 Views)
Passing Data Between Loop Iterations in LabVIEW: http://www.ni.com/getting-started/labview-basics/shift-registers
Thanks
uday
0 Kudos
Message 5 of 15
(3,455 Views)
Solution
Accepted by topic author hbs_80
Edit to my previous post:
You can also resize the Replace Array Subset Function and pass multiple values at the same time instead of two times. https://zone.ni.com/reference/en-XX/help/371361J-01/glang/replace_array_subset/
Thanks
uday
Message 6 of 15
(3,428 Views)

Hi udka,

I can not figure out how to use shift register for my Output Table

Local variable seems working fine netween states, but inside state "Read cito" I am facing the problem. How can I use shift register inside the loop itself?

0 Kudos
Message 7 of 15
(3,425 Views)

Disclaimer: Local and global variables are advanced LabVIEW concepts. They are inherently not part of the LabVIEW dataflow execution model. Block diagrams can become difficult to read when you use local and global variables, so you should use them carefully. Misusing local and global variables, such as using them instead of a connector pane or using them to access values in each frame of a sequence structure, can lead to unexpected behavior in VIs. Overusing local and global variables, such as using them to avoid long wires across the block diagram or using them instead of data flow, slows performance. Source: https://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/using_local_and_global/

 

-Coming to your problem Read : http://www.ni.com/getting-started/labview-basics/ and http://www.learnni.com/ to learn how to use local variable and Shift register.

-Did you follow by expanding the replace array instead of two times?

Thanks
uday
Message 8 of 15
(3,417 Views)

You solved it!

resizing the Replace Array Subset Function solved the problem

 

The log file is somehow not correct, it should be easy to correct it

 

Thank you udka

 

0 Kudos
Message 9 of 15
(3,416 Views)

Hi hbs,

 

you solved the race conditon (mentioned above) by deleting the parallel access to the very same local variables - but you should still use a shift register to hold your "output table" data!

 

What's the point of having a stop condition in your FOR loop, but not use it?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 15
(3,394 Views)