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: 

Issue with Logging Data Sub VI

Hi Folks,

 

I need a little assistance to fix a bug in my project.  I have a main VI which is supposed to automatically start my subVIs.  My subVIs include a relay triggering program, an analogue read program, a voltage indicator program and a logging program.  When I press start on the main VI window the subVIs start but the logging subVI only does 1 loop then stops.  I have to go into the subVI and start it manually then it work OK.

 

Can anyone see what might be going wrong with the subVI execution??

 

I've attached the full project for clarity.

0 Kudos
Message 1 of 10
(2,558 Views)

Hi Catriona,

 

Can anyone see what might be going wrong with the subVI execution??

1. Too many global variables.

2. Race conditions because of global variables…

 

What about using a proper producer-consumer scheme?

Best regards,
GerdW


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

Yer doin' it wrong...

 

Why are you treating and calling your subvi's as separate threads or whatever and using Global variables to pass data to your Main vi?

 

Race condition much?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 10
(2,549 Views)

Do a search for Queued Message Handler.  You should not be using a Global Variable to stop such loops.  You should be sending commands to tell the loop to stop.  And let the QMH manage the queue (ie release it when it is done).  This will avoid a lot of issues.


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 10
(2,536 Views)

The OP needs to go back and do some of the tutorials as there are several very basic things that are done totally wrong here. Well not "totally wrong" because they sort of work but they show a very large lack of understanding the basics.

 

For instance there is this:

equals1.PNG

Why check to see of X = 21 by dividing X by 21 and checking if the remainder is 0? 

 

When you can do this:

equal2.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 10
(2,526 Views)

@GerdW wrote:

Hi Catriona,

 

Can anyone see what might be going wrong with the subVI execution??

1. Too many global variables.

2. Race conditions because of global variables…

 

What about using a proper producer-consumer scheme?



From what I have read the global variables should be OK of you are only writing to it in one place.  I only have variables that are written to in one location and read from in the other callouts.  Was the information I was given wrong?

 

I am not a computer programmer and I have only literally just started using LabVIEW and have been only given 3 weeks to write this test procedure so I haven't had a lot of time to learn and I have never heard of producer-consumer schemes.  Can you give me more detail on what I would need to change to allow me to do this?

0 Kudos
Message 6 of 10
(2,517 Views)

@RTSLVU wrote:

 

The OP needs to go back and do some of the tutorials as there are several very basic things that are done totally wrong here. Well not "totally wrong" because they sort of work but they show a very large lack of understanding the basics.

 

For instance there is this:

equals1.PNG

Why check to see of X = 21 by dividing X by 21 and checking if the remainder is 0? 

 

When you can do this:

equal2.PNG



 Yikes.  You have just made me look at this section again and neither what I have, not what you have suggested will work the way I need it to!

 

I need a test sequence that basically does the following:

 

turn on relay 1, apply load 1, turn off relay 1

turn on relay 2, apply load 1, turn off relay 2

.

.

.

turn on relay 10, apply load 1, turn off relay 10

*Repeat sequence more time*

turn on relay 1, apply load 2, turn off relay 1

.

.

turn on relay 10, apply load 2, turn off relay 10

*go back to the start.*

 

As you can see I have embedded sequences and I'm really struggling to figure out how to properly control them.  Any suggestions?

0 Kudos
Message 7 of 10
(2,513 Views)

@Catriona wrote:

As you can see I have embedded sequences and I'm really struggling to figure out how to properly control them.  Any suggestions?


Look up State Machine in the LabVIEW example finder (Help->Find Examples).


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 8 of 10
(2,503 Views)

@Catriona

 

I am not a computer programmer and I have only literally just started using LabVIEW and have been only given 3 weeks to write this test procedure so I haven't had a lot of time to learn and I have never heard of producer-consumer schemes.  Can you give me more detail on what I would need to change to allow me to do this?


Why would anyone expect you to be able to accomplish this in 3 weeks? You are not a programmer and you don't know LabVIEW. Shouldn't whoever is assigning this task allow you sometime to actually learn what you are expected to do?



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 10
(2,502 Views)

I don't know the specifics of your test but I have done my share of battery tests over the years and find a State Machine architecture works most of the time  

 

Take a step back and break your test down into steps from beginning to end and try to think of each step as a "state" in  a state machine.  Remember that you can always "reuse" a state, so if you need several different time delays you can have one "dealy state" that has a different time delays.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 10
(2,501 Views)