LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Polling digital inputs

I am trying to simulate an annunciator panel on a WIN_XP PC with LV7 and DAQMx hardware. This is part of a much larger machine control code.

The number of digital input channels is 17.

For those who wonder what an annunciator is :

When an input becomes active I have to switch on a LED indicator on the PC screen and switch on an alarm. When the user presses the ACK push button, the alarm is silenced, but the LED remains lit till the relevant input becomes inactive.

The response time for (reading) each input must be about 20ms.

Question is, what would be the best possible way to code this without loading the CPU heavily ?

I am not listing the possible options, lest the replies should end up discussing the pros and cons of my suggestions. In other words, I simply do not want to bias the replies...

Thanks for your time, friends.

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 12
(3,859 Views)
Here is one possible method:
Create a loop which polls each DAQ channel and puts its data in a queue (along with any info that is pertinent to that channel, like pressure1=2 or temperature6=80). This loop will have a 20mSec wait. Create another loop to dequeue the data and act on it. Here is where you can determine an alarm condition and set off the LED and buzzer (using a case structure). You can also determine if the alarm condition has gone away (another case) to turn off the LED and buzzer. Inside this loop can be an event structure to capture the ACK button beig pressed to reset the buzzer. This loop can also have a 20mS or faster wait so that it can keep up with the other loop.
- tbob

Inventor of the WORM Global
Message 2 of 12
(3,850 Views)

"Create a loop which polls each DAQ channel and puts its data in a queue (along with any info that is pertinent to that channel, like pressure1=2 or temperature6=80)."

I got the idea. But how exactly would one go about doing it ? 

I would be using the DAQMx functions and thus the DI will be read in as a  "1 D Boolean N  lines "  once everey 20mS.

Then this array is indexed to read the status of each bit ( line ) and the resulting status queued in. Is that it ? A basic sample  code with some 2 or 3 DIs would help immensly.

Thanks

Raghunathan

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 12
(3,798 Views)
Hello Raghunathan,
 
Take a look at the LabVIEW shipping examples found under Help >> Find Examples.  In the Example finder, search for Queues, and take a look at Queue Basics.vi.  This will give you a good start on using queues in LabVIEW.
 
Let me know if you have any further questions.
 
Regards,
Sean C.
0 Kudos
Message 4 of 12
(3,779 Views)
I am not familiar with DAQmx but here is a vi that shows the basic principle behind gathering data in one loop and processing it in another.  The data gathering loop puts the data in a queue.  The processing loop reads the queue and acts on the data.  I have also added an alarm LED and an ACK button to show you how that could work.  You will have to figure how to get data from your DI and put it into the queue.  If you get an array of data at a time, create a loop to index the array and stuff each element into the queue.  This loop would go into your data gathering loop.  The best thing to do is to program the DAQ to get one value at a time.  If you are using a DI and your data is boolean, change the queue element from a DBL to a boolean at the beginning of the vi at the Obtain Queue function.  You would also have to change the alarm condition code.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 12
(3,773 Views)

not sure how this would work but this would be what i would try first.  (of course you would need 17 of these loops)

 

 

Ryan

Ryan

LV 7.1
0 Kudos
Message 6 of 12
(3,766 Views)
Hi Bob,

Thanks for the sample. It made the concept of  queue quite clear.  In the actual case,  the problem is to  identify the  bits as  the input array is a  boolean data type.  

I have hence coded a  slightly differnt  VI to handle about 8 switches which when switched OFF generate a fault.  In an actual  system, the switch array can simply  be replaced with data from a DAQmx DI read function.

Trust this could also do the job ?

Raghunathan

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 7 of 12
(3,743 Views)
Seems to work, except for a couple of bugs you have to work out.  The Alarm should stay on until acknowledged, even if the fault condition goes away.  If you ACK an alarm, the alarm indicator goes off, and then if you click the ACK button again, the alarm comes on again.  This should not happen.  You need to refine your logic.  You probably need to use shift registers to help you do this.  Look at the vi I sent previously and look at the second loop for an idea of how to use shift registers to perform ACK on an alarm.
- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 12
(3,738 Views)
"The Alarm should stay on until acknowledged, even if the fault condition goes away"

Actually in my case , the requirement is to silence the Buzzer with the ACK command  as the machine running in any case held up, till the fault clears and the "No fault " relay comes ON. What you have mentioned  is normally done for a  distributed I/O setup where several locations can raise an alarm to  a central supervisor to react. ( like a SCADA set up )  In my case it is  single-machine-single-operator. 

The other bug of being able to activate to alarm with a second push of  ACK needs correction  !

Ideally this is what I want to finally accomplish :

-  Fault  occurs . Alarm sounds. Silenced with ACK.
-  First  Fault remains and Second Fault occurs. Alarm again comes ON.

Working on it and will post when complete.

Thanks for checking out the code.

Raghunathan

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 9 of 12
(3,731 Views)
I worked in SCADA for three years so I assumed that the typical alarm-ACK scheme is what you were after.  Sorry for the wrong assumption.  Keep us posted and don't hesitate to ask question.
- tbob

Inventor of the WORM Global
0 Kudos
Message 10 of 12
(3,719 Views)