LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 9401 with cDAQ 9178, Inconsistent readings

Hello I am trying to read two digital inputs, but for some reason sometimes T get readings and other times I get no digital inputs being read.

 

One input is working as a swittch which is connected as shown below:

Untitled.png

 

The other is connected in conjuction with a pullup resistor shown below:

Untitled.png

 

I'm working off a previous developed labview software that worked perfectly before.  I just modified it becuase we switched are gas meter from an encoder to the riotronics device shown above.  The previous connection followed that of the NI-Tutorial-7109-Encoder document where Wire A is connected to Pin 14, Wire B is connected to Pin 17, “5 VDC Power” is connected to any unused digital line set to “high" (Pin 16 in this case), and “Ground” is connected to any COM terminal (Pin 1 in this case).  So i changed the wiring and added pulse with fitler for the switch and specified the count edge terminal when i initiate the counter as shown below:

Untitled.png

 

I tried using different channels with no avail.  I tested one counter at a time and still sometimes it would read and other times i get no signal.  Also when having both counters connected sometimes one reads and not the other and vice versa.  Can anyone help me understand why I am getting inconsistent reads.

 

Thank you,

Miguel

0 Kudos
Message 1 of 6
(3,969 Views)

Hi Miguel, 

If you're getting readings sometimes it sounds to me like your connections are probably okay.
Would you be able to attach a screenshot of the portion of your code with the read function? I'm wondering if there might be some issue there that is causing inconsistent readings.

Shalini M.
Partner Development Engineer
Alliance Partner Network
National Instruments
0 Kudos
Message 2 of 6
(3,935 Views)

ok here is more images of my code.  The image in the above post initiates the counters and continues with this image:

Untitled.png

 

Then from there it goes into a loop to initiate the sample mode.

Untitled.png

 

 

Finally i stop the task outside the loop

Untitled.png

 

Does this give you the information you need?

0 Kudos
Message 3 of 6
(3,918 Views)

Have you tried running one of the counter input shipping examples to confirm that the problem is not related to the hardware?

Shalini M.
Partner Development Engineer
Alliance Partner Network
National Instruments
0 Kudos
Message 4 of 6
(3,876 Views)
That is a good idea. Thank you I will try that.
0 Kudos
Message 5 of 6
(3,855 Views)

It seems adding the below code helped.  All of what is posted on NI says the following code is needed when implementing bidirectional code, but nothing is stated as for input only counters.  I tried it anyways and now everything seems to work.  I also found another piece of code that synchronizes the counters (which I can't seem to find anymore, but it was similiar to this one without the analog input though. https://decibel.ni.com/content/docs/DOC-5706) which also worked when my trigger was PFI0, but that code wouldn't work for the functionality I wanted.

I found other examples that may work for other people having similar issues here. http://forums.ni.com/t5/LabVIEW/How-can-I-use-two-counters-simultaneously-for-pulse-width/td-p/24249...

 

Thanks for everyones input.

Untitled.png

0 Kudos
Message 6 of 6
(3,827 Views)