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: 

What am I doing wrong with my code?

Solved!
Go to solution

Hello LabVIEW Champs,

 

I'm stuck on a part of my code and would like to know what am I doing wrong with it. The Wash option reference is not reflecting the recent values for Wash option buttons. 

0 Kudos
Message 1 of 11
(3,101 Views)

There's no code!  All that you have provided is a picture.  Attach your VI so we can poke at it and find what "makes it tick".

 

Bob Schor

0 Kudos
Message 2 of 11
(3,078 Views)

And what are you doing with the reference? 

It is a reference to a cluster control. 

0 Kudos
Message 3 of 11
(3,078 Views)
Solution
Accepted by topic author ackatharotiya

As Bob says, we can't debug a picture.  And I bet part of the explanation is based on what is happening in the subVI you show, but don't provide for us to know what it is doing.

 

I'm going out on a limb and guess you have a data flow problem.  That you set values in a control and they are read, but they change by the time you get around to hit the start button which is what will cause the Event Structure to execute because it is just sitting there waiting.

Message 4 of 11
(3,034 Views)

Hi,

 

In short; you should use shift registers to update your internal state with the state of your controls.

 

In long; have an event in your event structure for value change in 'wash options'. When a value change occurs, update the state of the 'wash options' in your data cluster (which should be a shift register). Then when you press start you operate depending on the state of your data cluster, not the state of the controls. This means that you can easily implement parallel processes; one reading the state of the control and updating the data cluster and another performing the operation.

 

In general; you are doing a CLD exam with a state machine. You want to run the machine based on the state of the controls at run-time. State machines are certainly viable here, but you should consider a producer-consumer architecture. These are pretty great at providing the functionality required for a CLD. For example; consider how your state machine would interpret conflicting information, such as: User moves the car into the wrong position during a wash cycle; the program should immediately respond to this in a sensible manner.

CLA - Kudos is how we show our appreciation for comments that helped us!
Message 5 of 11
(3,016 Views)

Sorry for not considering the code as an essential attachment. Please find it here. 

0 Kudos
Message 6 of 11
(2,972 Views)

Sorry for not considering the code as an essential attachment. Please find it here. 

Download All
0 Kudos
Message 7 of 11
(2,971 Views)

Thanks for the suggestion. I'll surely consider Producer Consumer architect for next example. Having an event with washoptions change value indeed works. 

 

I'm wondering why is the reference not reflecting the recent values for Wash options? The subVI typically take the reference and get value for each control and or them to know if any of the wash option selected. 

0 Kudos
Message 8 of 11
(2,966 Views)

The subVI is simply taking the Wash option reference and get the values of each of the cluster control and then perform logical or on them. 

 

You're right Man. My old values are sitting there by the time I get around to hit the start button. I just need to improve my data flow paradigm here. 

 

Thanks a lot man. 🙂 🙂

Really Really appreciate it. 

0 Kudos
Message 9 of 11
(2,961 Views)

@ackatharotiya wrote:

 

You're right Man. My old values are sitting there by the time I get around to hit the start button. I just need to improve my data flow paradigm here. 

 


You probably need to do a little more than that, but yes, the was option control belongs inside the event structure and the data itself in a shift register.

 

There is a lot of other convoluted code. For example  in the "under body wash" case, what do you think would happen if you would delete that inner case structure and just wire the boolean that is currently going to the selector terminal directly to the "bundle by name"? Your cases only differ by a diagram constant which is identical to the selector value, so why duplicate all that other code?

 

Of course your entire wash process completes in about a nanosecond, so you should probably add some timing to see the progress.

Message 10 of 11
(2,945 Views)