11-05-2015 05:07 PM
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:
The other is connected in conjuction with a pullup resistor shown below:
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:
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
11-06-2015 04:20 PM
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.
11-06-2015 06:16 PM
ok here is more images of my code. The image in the above post initiates the counters and continues with this image:
Then from there it goes into a loop to initiate the sample mode.
Finally i stop the task outside the loop
Does this give you the information you need?
11-09-2015 05:39 PM
Have you tried running one of the counter input shipping examples to confirm that the problem is not related to the hardware?
11-10-2015 01:29 PM
11-11-2015 05:59 PM
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.