LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger an Event from I/O

Solved!
Go to solution

I am working on a remote interface for a Vitrek V53 Hipot tester.  This tester is designed to work remotely with a PLC via DB-9 connector, but I am attempting to get a working interface with LabVIEW.  I am using a USB-6501 digital I/O with logic relays to trigger the start and reset switches.  The tester then has internal relays who's contacts short two pins on the DB-9 when engaged. These states are Testing, Pass and Fail.  I have +5V from the 6501 tied to one of the pins for each state, and an input line connected to the other pin for each state.  All I/Os work well in NIMAX, so the circuitry end of it works well. 

 

With the program, everything works as desired, except when the test is complete, I have to click the start button a second time in order for the CAUTION-TESTING indicator to turn off and the Pass/Fail indicator to turn on.  If there is a way to trigger an event when one of the internal relays is closed, then the program would simply switch through the events and all will work well.

 

Additionally, any comments on my code are welcome, as this is my first attempt at a LabVIEW program, so tips on best practices would be excellent.

0 Kudos
Message 1 of 13
(5,251 Views)

Hello,

to turn the yellow LED off after one test is completed,

You could add a sequence structure inside of the while loop with a flat sequence composed of three frames.

In the first frame the event case, in the second one the tests and in the third frame you would add a local variable (CAUTION-TESTING) and a wait function.  

 

Yellow LED off.jpg

 

Greetings and Regards,

James.

Greetings and Regards,
James
0 Kudos
Message 2 of 13
(5,174 Views)

James,

Thank you for your reply, but in this specific case a sequence structure will not work well.  Depending on the specifications of the part being tested, there is a wide range of times that the test may run for.  This range can be from just under 1 second all of the way to a couple minutes in duration.  I could place a control on the front panel that would have the user enter the duration of the test.

 

With that said, there would still be issues.  Say if the duration of the test is meant to be 1 minute, but the part failed 3 seconds in, the user would be forced to wait the remaining duration of the test.  Also, the reset button acts as a stop button for a live test.  In the event that the user would need to stop the test, he/she is unable to stop the test until that wait portion of the sequence is completed.  This could be potentially dangerous considering this tester is outputting in the range of 5kV.

 

Thank you again for your reply, and my apologies that I was not thorough enough in my initial post.

0 Kudos
Message 3 of 13
(5,164 Views)

Hello,

 

Thank you for your precision. There are lot of ways to implement what you have described above.

One possibility could be State Machines. There you could run the test, and if the Part has failed, jump in next state.

 

Because of the dataflow in LabVIEW, you would not be able to implement your program without either a (defined) structure or a state machine.

Hope you have more useful hints after going through the links.

 

Have fun programming in LabVIEW,

James.

 

PS: Use of the highlight function makes you see how the data flows through the wires.

Greetings and Regards,
James
0 Kudos
Message 4 of 13
(5,156 Views)
Solution
Accepted by topic author TAmbriole

I'm not certain exactly how your circuitry works, but it looks like just wiring a value to the timeout value might be sufficient to solve your problem? (The blue icon in the top left corner of the event structure).

 

That being said, a more well defined architecture like a State Machine or the Producer/Consumer pattern would probably make this easier to reason with/extend, if either of those things concern you.


GCentral
0 Kudos
Message 5 of 13
(5,154 Views)

Pass_Input.JPG

 

Just to help from a clarification standpoint, the Hipot shorts two pins together in order to indicate Testing/Pass/Fail.  So, 6 of the pins on the DB9 are designated as Pass1, Pass2, Fail1, Fail2, Testing1, and Testing2.  I do not know the circuit inside of the Hipot, but when the states change, I can hear relays clicking.  So, my assumption is that these pins are shorted via relays. 

 

The 6501 is simply used to detect if the switch is open or closed, which is what I would like to use to trigger a new event, if possible. 

 

I will begin reading up on State Machines and Producer/Consumer architectures as this program is likely to be edited over the years for future needs.  Thanks for the comments and help!

0 Kudos
Message 6 of 13
(5,144 Views)

Did a timeout solve the issue with having to press the button twice?


GCentral
0 Kudos
Message 7 of 13
(5,139 Views)

I just had a second to test this, and yes it did.  I have wired 100ms to the timeout and the program works as desired.  Thank you!

0 Kudos
Message 8 of 13
(5,133 Views)

My apologies for flip flopping here.  Upon further testing, I am further understanding how the timeout works.  Over long durations, it is using quite a bit of CPU since the event is looping.  The machine I am running is capable of handling this, however the machines in production will have issues with this.

 

Am I correct to think that DAQmx Events should allow me to trigger events based on the state of an input?

0 Kudos
Message 9 of 13
(5,121 Views)

Whilst it's true that DAQmx does support events, in particular a 'change detection' event, it doesn't look like the 6501 is a supported device.

 

A tutorial for using the Change Detection event can be found here. Nothing in the 6501 datasheet looked promising either for a Change Detection event.

 

Sorry to be the bringer of bad news! I don't know if your production machines are using the same hardware - maybe you have something else you can use from the supported list.

 

An alternative work-around would be to continue with the timeout case, but try to reduce the number of things being checked in the while loop. Your timeout is (was?) empty, so that takes no time, but the digital reads will happen each time. Moving some of the code (in particular, the creation of the task!) outside of the while loop will definitely tidy up your code and save some processing time.


GCentral
0 Kudos
Message 10 of 13
(5,110 Views)