Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use internal counter of cDAQ 9172 to measure PWM and generate frequency ?

Solved!
Go to solution

Hi,

My project's requirement is to measure 6 PWM channels and generate 5 frequency channels.

From suggestion of NI engineer, I bought cDAQ chassis 9172 and NI 9423 (8 DI correlated) and NI 9474 (8 DO correlated) for this requirement. I have some questions

 

From the article:

 

1> What Do I Need to Know Customize My CompactDaq 9172 Chassis

http://zone.ni.com/devzone/cda/tut/p/id/9367

I know that this system support 32 physical timing channels to correlated I/O pins for slots 1-4.

 

=> I don't really sure how to use these timing support channels.

 

2> Using Internal Counters on a NI cDAQ-9172 as a Sample Clock for Other Tasks

http://digital.ni.com/public.nsf/allkb/ADFC4DD8C9690232862575B70079FBD4

I know that I can change the property of the physical channel so I can get 2 counter externally from chassis 6 and 7.

 

=> I don't think that this solution will have me because I can only use 2 counters with this method.

 

Could anyone please tell me how to solve my project requirement? How to select the setting for DAQmx VIs?

 

I have experience with measure the PWM and generate frequency, but with seperate counter only.

 

Best regards,

Thang Nguyen

 

Message 1 of 16
(9,052 Views)

Hello Thang,

You can use internal Counter clock and control the DIO lines by using that as a sample clock. Keep in mind that for generation you will have to use custom wavefrom for each line and will have to do little math on freq division. I have attached a pseudo code for you have a look at it this might help you. Put your DIO module in slots 1-4 and you can use internal counter lines.

 

Cheers

 

-Lab

Message 2 of 16
(9,022 Views)

Thank you so much,

What I want to do is to be able to change the frequency of the output signal. I will try to find a way to do it.

Do you have the sub VI1.vi file?

 

Best regards,
Thang Nguyen

0 Kudos
Message 3 of 16
(9,001 Views)
Solution
Accepted by topic author THANG NGUYEN

Hey Thang,

Aha...for that you can use Channel Property node.

Channel Property Node.jpg

Cheers

Lab

0 Kudos
Message 4 of 16
(8,985 Views)
 
0 Kudos
Message 5 of 16
(8,984 Views)

Sorry forgot to attach VI.

😉

 

0 Kudos
Message 6 of 16
(8,983 Views)

Thank you so much,

I think this is the solution for my project without using a more expensive system.

But do you think I can do the same thing to measure the PWM pulse? Use the internal counter to measure the duty cycle?

 

Best regards,

Thang Nguyen

0 Kudos
Message 7 of 16
(8,978 Views)

Hey,

I beleive you can do you using Counter input task as Pulse Width use implicit timing and perfrom buffer acqusition. This way you get high and low time measurement of the input signal. Another thing you can try is just perfrom AI and write some code to calculate time period.

 

-Lab

0 Kudos
Message 8 of 16
(8,968 Views)

Hi guys,

 

You can measure the duty cycle using the internal counter as Lab mentioned, but instead of a Pulse Width Measurement you would use a Semi Period Measurement.  The Pulse Measurement is only going to measure either high or low (your choice).  Semi Period will measure both high and low.  Here's a link that shows how to do this:

 

DAQmx - Measure Duty Cycle Continuous

 

One caveat is that you need to know which edge is going to occur first--the data returned will be an interleaved array of High and Low times, so you need to know which to start on.

 

 

There are only two counters on the 9172, so you won't be able to use this method for more than two channels (one channel if using the other counter to generate the PWM signal).

John Passiak
0 Kudos
Message 9 of 16
(8,943 Views)

Could I use this setup to the 9172 to control a PWM in the NI9403?? I'm trying to generate a PWM using the NI9403 but without sucess. I know the 9403 is not a counter but I'm trying to use the software time control (http://digital.ni.com/public.nsf/allkb/1AE66AE0D542BCB386257522005434BE ). When I test my VI with the a virtual output of the 9403 in the DAQ Assistant, the control is OK and the frequancy is very good. But when I change the DAQ Assistant to a real output to test my VI with my hardware (9403 and Daqmx), the frequency change to a very low speed.

 

Could you please let me know what is happening and what can I do to fix this issue??

 

Thanks to all

 

Galli

0 Kudos
Message 10 of 16
(8,327 Views)