LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Latching Function for a Case Structure

Solved!
Go to solution

Hi,

 

Looking for help with a solution. I have a limit switch input on a digital line that is being used to change a case structure. The case structure True and False is for the Forward and Reverse for a motor. At the moment, when the limit is tripped/High the motor goes Forward but once it has passed the limit switch it returns to Reverse. How is it possible to keep/latch the case structure that only a True value from limit switch will change the case structure.

 

Regards,

0 Kudos
Message 1 of 7
(4,737 Views)

Hi Gob,

 

instead of looking at the current state of your switch you should detect rising edges in it's signal.

 

There are functions provided by LabVIEW to do so: PtByPt-BooleanCrossing!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(4,726 Views)

Hi GerdW,

 

Thanks for your reply, I'm very much a beginner but I am not sure it is possible edge detect, I am using a 6501, all DIO. The limit

switch is coming in as a simple boolean 0,1.

 

Regards,

0 Kudos
Message 3 of 7
(4,721 Views)

Sounds like you need the limit switch to toggle a boolean in your code.

Perform a compare of the input to it's previous value, storing the previous value in a shift register for example, and if "new value > old value" then you have a rising edge detection. Feed that into the True case of your case structure to invert a boolean signal using a NOT function. That boolean signal will simply pass through in the False case. Keep this boolean the same for each iteration of your code by storing it in a shift register as well. When True, rotate clockwise, and when False rotate anti-clockwise.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 4 of 7
(4,720 Views)

Hi Thoric,

 

Thanks for your help, I have tried your approach, which I may not be doing correctly using a feedback node instead to store the last value but unfortunately it is not working for me. I have attached a simple VI of what the system is trying to do. The limit switch LED 1 should go High along with LED 2 however when LED 1 goes Low, LED 2 should remain high until the next time LED 1 is High.

 

Regards,

0 Kudos
Message 5 of 7
(4,702 Views)
Solution
Accepted by topic author GOB82

It seems you attached your original code as there is no feedback node in this VI?

 

Anyway, shown below is how to achieve what I was describing using a Select function instead of case structure. Note, I believe you can also use an Exclusive Or instead (as shown in the lower screenshot, but I haven't tested that)

 

trigger_latched_bool.jpg

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 6 of 7
(4,685 Views)

maybe this....

latching.png

Message 7 of 7
(4,683 Views)