LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Selector and Conditional Programming


@andrew_h01 wrote:

andrew_h01_0-1750875349759.png

 


Note that all three case structures run in parallel and at the same time, and some try to access the same resources at the same time. This is highly flawed!

0 Kudos
Message 11 of 22
(155 Views)

Hey Christian, thanks for your help so far. I am in the process of cleaning up my code for it to be better understood and debugged.

 

I checked the logic of your program you sent and it makes sense. However; what's unclear to me is the connection between the True/False Boolean LED on the end inside the while loop and how that can be connected to parallel case structures to determine if the solenoids should be on or off.

 

A couple of common errors is:

1. When running this program when I was using the DAQ Assistants the resource tasks were being used simultaneously therefore I switched to using DAQmx code and ending and clearing the tasks but I think this is an issue as well because if I do that then the solenoids states only switch for a split second because they immediately will get turned back off, I believe, seems like I am at a crossroads where I potentially need to nest conditions with the other solenoids? 

 

2. Case selectors not triggering the solenoids so probably stemming back to issue with what I asked above and attached images of which is the connection between True/False Boolean and how the case structures can be in parallel.

 

See images below.

Screenshot 2025-06-25 141600.png

Screenshot 2025-06-25 143442.png

  

0 Kudos
Message 12 of 22
(151 Views)

On further thought, inside the while loop I probably don't need the case selectors and can just go straight from and/or logic to auto-start of the DAQmx write function.

 

andrew_h01_0-1750877245952.png

 

0 Kudos
Message 13 of 22
(149 Views)

They cannot run truly in parallel but the order is unknown and whatever goes first grabs the resource and the other will probably fail. Do you get any errors?

0 Kudos
Message 14 of 22
(148 Views)

@andrew_h01 wrote:

On further thought, inside the while loop I probably don't need the case selectors and can just go straight from and/or logic to auto-start of the DAQmx write function.


That's what I already said..

 

You still need to create the channels only once before the loop (and close them after the loop) and just write the values.

 

I doubt you need the third case structure all all, because you can just determine the correct boolean output for each channel based on all three comparisons.

0 Kudos
Message 15 of 22
(143 Views)

Attached is cleaned up program and edited. Tested the logic, and tested with hardware, and solenoids are still not firing, is there a way I can wire up an LED to light up as the Digital Outputs are being triggered if one solenoid is on vs. off? 

0 Kudos
Message 16 of 22
(109 Views)

@andrew_h01 wrote:

 is there a way I can wire up an LED to light up as the Digital Outputs are being triggered if one solenoid is on vs. off? 


You can right-click on any wire and create indicator. For a boolean wire you would get an LED.

 

LabVIEW also has "probes". Are you familiar with the debugging tools?

 

I am currently doing some "real work". Will look at your VI later.

0 Kudos
Message 17 of 22
(92 Views)

You are still creating duplicate virtual channels and then write to them in parallel.

 

altenbach_0-1750885069723.png

 

0 Kudos
Message 18 of 22
(91 Views)

So, assuming that you want an unconditional FALSE on both channels if the third comparison is true, but otherwise output the values from the upper two comparisons, here's a quick draft without all the trimming.

 

Note that you did not wire the booleans correctly at all. The output of the comparison does NOT belong to the optional autostart input on top. That's plain crazy!

 

altenbach_0-1750885565983.png

 

I am sure if you setup the channels correctly, all you need is a single write where you wire an array of the two booleans.

0 Kudos
Message 19 of 22
(80 Views)

@altenbach wrote:

They cannot run truly in parallel but the order is unknown and whatever goes first grabs the resource and the other will probably fail. Do you get any errors?


From the screen shots those look like software timed digital tasks. You can run multiple ones at a time. See this

0 Kudos
Message 20 of 22
(67 Views)