Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

storing digital input

I am fairly new to Labview, and I have a question on receving inputs (maybe trivial).
I am trying to receive an input from a momentary pushbutton switch (SPST). I am running it through an NI 9401 as a digital input. I set up the DAQ assistant and I am receiving an input signal once every second. I would like to store each input (which is a boolean) in an array. I've initialized an array, and I am able to place the input into the array, but my problem is that every time a new signal is recieved, the array is reset, so that the signal I want to store appears but is not stored. Thanks to anyone who can help me.
0 Kudos
Message 1 of 6
(4,443 Views)
Are you re-initializing your array every loop?

If you can post your code it would help in finding the cause of the bug.

Brian

Message Edited by BrianPack on 05-23-2007 02:04 PM

0 Kudos
Message 2 of 6
(4,436 Views)
Thanks, Brian.
I've attached the part of my code which is giving me problems. Basically what i am trying to do is save all the inputs in an array, and then sum them and determine whether the sum is even or odd. What happens is the array resets every time the DAQ receives a new input so none of the inputs are stored.
 
0 Kudos
Message 3 of 6
(4,422 Views)
Hi Felso,
 
The problem is everytime you run your VI it will initialize a new array.  So you will need to make it so your VI saves the array from one acquisition to the next.  This is no problem but first a few questions.  When and how do you want the acquisition to occur, do you want the VI to keep running and count how many times the button is pushed irrespective of how long it is pushed for, do you want to sample the button every 1 second, or do you want it to sample the button everytime you run the VI?  Each one of these will be slightly different in your implementation.
 
Brian
0 Kudos
Message 4 of 6
(4,412 Views)

Hi Brian,

Based on your reply to Felso, I would like you to explain on how if I need to sample the button everytime I run the VI (how long it is pushed) and to write to the spreadsheet file.

 

Thank you.

Nam78

0 Kudos
Message 5 of 6
(4,073 Views)
Hi Nam78,

I would like to address your question, but I can't understand what you want to do. It sounds like you want to measure how long the button is pushed down. Is that correct?

If so, one way is with a digital input task. You can use the 9172 chassis clock for hardware-timed digital reads. In order to use the chassis' clock, you will need to use the 9401 in slots 1 through 4. Once you have your task configured, you can read continuous measurements and find which data points are '1's and extrapolate the timeline using the sample rate you've specified.
Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
0 Kudos
Message 6 of 6
(4,046 Views)