Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the digital state of a counter input?

Solved!
Go to solution

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

0 Kudos
Message 1 of 5
(3,597 Views)

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.

Regards,
Basil
Applications Engineering
National Instruments
0 Kudos
Message 2 of 5
(3,570 Views)

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?

0 Kudos
Message 3 of 5
(3,553 Views)

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.

Regards,
Basil
Applications Engineering
National Instruments
0 Kudos
Message 4 of 5
(3,548 Views)
Solution
Accepted by jaime_c

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!

0 Kudos
Message 5 of 5
(3,543 Views)