LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a string of number in sequence with a boolean

Sorry if this is such a rookie question but I've searched a lot and found no elegant solution to my problem.

I have a PLC with which I communicate via a VI (MB Ethernet Master Query Write Single Coil).
In an event structure, I have assigned each of my 15 relay on the PLC to open when I press the associated boolean.

In other word, when I activate the boolean on my front panel, it triggers an event that send the corresponding Modbus adress and the boolean value to the Modbus VI.

Now for my issue:
I want to create a protection that if there's an error, if the Main VI is stopped or if the window is accidentally closed, it will close all channels
But for the VI to do that, I need to send, in sequence, all the adresses (0-15) as well as a FALSE state for each of them.

And I'm just at lost on how to do that.

Thanks for any help
Sans titre.png

0 Kudos
Message 1 of 9
(3,780 Views)
You need to send the signal to PLC ?
----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 9
(3,775 Views)

I need to send a FALSE to each of the 15 adresses in succession so that all physical channel would close to prevent problems.

(For all I care, it could be done in parallel but as far as I understand what I made, I can only send one adress and one boolean at a time to the VI, the alternative would be to duplicate the VI, but this seemed like a clumsy way to handle things and a potential communication problem by fulling the buffer)

0 Kudos
Message 3 of 9
(3,773 Views)
Use Reentrant VI
----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 9
(3,754 Views)
Create a wrapper for writers coil and the make a looping for 15 iteration.with different channels
----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 9
(3,750 Views)

in which case do you expect error? I assumed this is the main VI so you can hide the options which lets the user to close the application accidentally. Generally we must have a shutdown sequence in which we can close the things we have to. So put all the addresses in an array and loop it in a for loop to close everything in a sub vi. So whenever you need to shutdown you can all this VI. Does it make sense?

 

BTW:@PalanivelT: How would a re-entrant vi solve the issue?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 6 of 9
(3,744 Views)

Put a for loop that will turn off all channels after main while loop.

To process application close I usually use Filter events (app -> instance close? or VI-> Front Panel Close?) and discard them. After a last action of VI I close the front panel (invoke node) if  needed. I am used to doing that because I am not completely sure event structure processes the frame "App Instance close" before really closing application. And it definitely does not process anything after this event.

0 Kudos
Message 7 of 9
(3,739 Views)

I mean it as a protection against accidental closing, VI error (mainly communication error over ethernet), if the computer shuts down etc. as well as an startup condition so everything always start up as closed (the timeout)

I tried to cover as much as possible, you could be surprised as to how clever students can be when it come to breaking stuff.

I'm looking for the reentrant VI (I'm really a novice with just the basic course of how to make loops, and save files so I need to learn everything from the bottom) The Wrapper thing left me baffled but eventually I should figure how to use it.

I was thinking about using an array in a FOR loop with 15 iterations, but I don't know how exactly to extract the adresses one at a time and combining them with a boolean False each time.

I'm not sure if this is clear?

0 Kudos
Message 8 of 9
(3,737 Views)

In Tools - VI properties -> Appearance -> Customize you can Disable possibility to close window or you can discard it and process. 

Application instance close? event happens, when you close project window, or, possibly when another vi calls StopLabview function. It will not help against task manager task abort or computer shut down. 

Edit: it helps against shutdown: it processes event and loop when I press Windows Start button -> Shut down. Possibly if it takes longer than windows timeout, it will force destroy it. 

 

I do not know how you make your address, if it is 0 - 14, see below - connect your Write Relay state vi instead of fake picture

 

 

Write15 on close.png

 Edit 2: If WriteVI can be reentrant, you can parallelize closing loop so that all relay close at the same time, not one after one. I do not know how long each one takes, so it might or might not speed up closing all.

0 Kudos
Message 9 of 9
(3,708 Views)