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: 

Attempt to log error data using Producer-Consumer

In my application I want to repeatable cycle two banks of relays over a long period while simultaneously monitoring the N.O. contacts to verify that they are opening and closing when they should. I am trying to catch the event where one or more of the relay contacts fails to close or fails to open. There is a total of 14 contacts to be monitored while the two banks of relays are cycled and I am using 16 analog voltage channels to do this. The relay coils are being controlled by 2 digout channels on the DAQ with the intention of turning one set of relays on while the other set is off. This all seems to work fine (Tester 3.vi), but errors are very infrequent so catching that rare event that an error shows up is not useful.

I decided on using a producer-consumer method to log these infrequent errors as shown in Tester 3B.vi . Data being logged in the event of an error include the current index of the error and the current 16 analog measurements for the relay contacts. Unfortunately the producer ‘while’ loop stops and does not run continuously. The only way I can log data and get the while loop to cycle is by pressing [Data Log]. The ‘error’ indicator is the what I want to be the triggering event but with the loop stopped there is no error light to act.

So my first question is whether producer-consumer is the way to go to capture rare error events. Second question is why does the loop cease up when I add the event structure and the queue?

I am using LabVIEW base development system with a PCIe-6321 DAQmx.

0 Kudos
Message 1 of 5
(1,096 Views)

I'm assuming you meant to attach VIs to this, but you don't appear to have actually done so.  As such, there's not a lot of feedback we can give...

 

Since you haven't posted yet, I'll take this chance to point out that if you are using a newer version of LabVIEW, if you save it as an older version before posting you will get more replies because not everyone uses the most recent one.  Going back 3 versions from the current one is probably enough (2020--->2017).

0 Kudos
Message 2 of 5
(1,083 Views)

Thank you Kyle for the reply. here is the attachment I forgot. This NI blog doesn't have the familiar paper clip like outlook has.

0 Kudos
Message 3 of 5
(1,042 Views)

OK... there's quite a lot wrong with your code.

 

One thing you should know is that a "Value change" event doesn't occur because you have written to a terminal.  It will only occur if changed manually by being clicked on by a user, or by a property node set to write to the "Value (Signaling)" property.

 

You also need to not put your event structure in the same loop as the rest of your code, though honestly in this case I wouldn't use an event case at all. Just use a case structure or something that detects the condition you're looking for, and put the code you have in the event case right now inside the cases as needed.

 

You also have a lot of potential timing problems.  You will likely want to set up the code so the "write" on the top always happens before the reads on the bottom, and instead of doing 242 reads one point at a time, consider using a DAQmx timing node to set it up to capture all of the data points you need at once as a 2D array, and ditch the FOR loop entirely.

0 Kudos
Message 4 of 5
(1,009 Views)

Thank you Kyle for your reply. My first attempt to use an event structure and a queue in a producer-consumer structure was to have the failed relay contact data in the producer loop be recorded and then processed by the consumer loop. admittedly I am just learning how to use this P-C method so I'm not attached to it. You also suggested that I use a DAQ timing node but actually I don't need that many samples. I was viewing the malfunction on a scope and was trying to reproduce that, but really, all I need to know is when a relay is malfunctioning and since I am testing all those relays simultaneously, I would rather keep it simple.

I added a case structure in the new Tester 4.vi but I'm still having problems with detecting errors and then logging them. I suspect it is a timing problem as I see plenty of error show up on the "index of error" indicator but they are simply not logged. 

In the block diagram I am taking two 16-channel measurements every 500ms then all of the relays switch with the Cntl_2bit digital Boolean control at the top. I am comparing all of 16 channels, which represent the relay contact positions, either open (~8.5volts) or closed (~1.2volts)  with the "InRange or Coerce" function, testing the output with a 'Search 1D array', and if the result is anything but -1 then it will go to the case and log the failing voltage array into a designated 2-d array. 

Any suggestions would be appreciated.

0 Kudos
Message 5 of 5
(952 Views)