03-12-2013 12:10 PM
How do I get the digital state of a counter input?
I am using a method similar to the example below to measure duty cycle using counter inputs of a multifunction DAQ. If the duty cycle is 0% or 100% for a given period, the DAQ Read times out and returns an error. In that case I would like to get the digital state of the counter input so I can set the duty cycle measurement to 0% or 100%. I would like to do that without knowing the digital port and line of the counter input ... for example I would like to continue referencing DAQ/ctrX since I already have that information.
The specific application is using a PXI-6229 M Series DAQ and LabVIEW 2011 to make a Custom Device for VeriStand.
https://decibel.ni.com/content/docs/DOC-12396
Solved! Go to Solution.
03-14-2013 08:03 AM
Hi I'm Basil with Applications Engineering at National Instruments. Could you go into a little more detail about what you mean by the digital state of the counter? Also, why would you be using a duty cycle of 100% or 0% as these would just be a dc- constant and 0 voltage respectively? If you could provide me with a little more context about your application I would be a able to help you.
03-15-2013 10:42 AM
We use PWM for several applications and most of them have the potential to be 0% or 100% duty cycle.
A good example is the control line of an LED. When the LED is off, the duty cycle is 0%. When the the LED is on during the day the duty cycle is 100%. When the LED is on at night the duty cycle will be less than 100% to decrease the perceived brightness.
In the case of 0% or 100% duty cycle, the DAQ Read VI returns and error due to timeout. When that error occurs I would like to set the duty cycle measurement to 100% or 0%, depending on whether the voltage is high or low. I would like to do that by referencing the counter input because the user has already input that information.
Currently I can get the digital state of the counter line by using a Digital Input task and referencing the port and line that shares a physical connection with the counter input. However that requires knowing port and line I'd like to make the user interface as simple as possible.
Does this info help to clear things up?
03-15-2013 11:54 AM
The counter detects edges so I think you would need to have another line connected to it to detect whether it was high or low. The counter responds to either falling or rising edges. Is that something you can do (wire the counter to another input line)? You can make the user interface so that that line is automatically referenced in the block diagram.
03-15-2013 12:28 PM
For now I've wired the block diagram to use a case structure to check the counter ID and string constants to set the digital input ID, since they share the physical connection. As far as I can tell that makes the code specific to the PXI-6229 (or any DAQ with only two counters that share connections with p2.1 and p 1.4.
I've attached the sub VI.
If and when the device is used with a different DAQ I can add the seperate control and/or connection. It looks like at least one will be necessary since the counter input can only detect edges ... I think that was the piece of information I needed.
Thanks for your help!