Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

pulsed PWM output via cDAQ 9174

Solved!
Go to solution

Hello

I want to output a 1 kHz PWM signal with a cDAQ 9174 through a 9402 fast DIO-module.

Continuous output works nicely. However, now I need to generate pulses of this PWM´, i.e. 50 msecs PWM on, 100 msecs PWM off. And this, furthermore, for a defined number of pulses.

 

It seems to me that I'd need 3 counters for this:

ctr1 to continuously generate 1 kHz y% duty cycle PWM,

ctr2 to generate the 50ms/100ms on-off-pattern

ctr3 to count to n pulses of ctr2

 

I can set up a MAX task of finite number of n pulses 50/100 ms. I can also set up a MAX task of 1 kHz/y%dc PWM.

 

On dedicated ctr-cards, I believe I could gate ctr1 output through ctr2. But I do not know, how to set this up in cDAQ hardware.

0 Kudos
Message 1 of 7
(8,470 Views)

Meanwhile, I thought of another solution that does not work:

 

Use ctr0 to generate finite length of PWM with desired duty cycle (e.g. 50 PWM cycles at 1 kHz), then ctr0 stops.

Trigger ctr0 periodically for n pulses with period length 150 ms and with trigger signal generated by ctr1.

Problem:

Error -89137 route already in use. Apparently, ctr1 output cannot be used to trigger ctr0.

 

Any idea is appreciated....

 

Michael

 

 

0 Kudos
Message 2 of 7
(8,469 Views)

I have done something similar with a 6602 timer/counter card and a couple TTL gates the old school way:

 

Generate the 1KHz PWM on one channel.

Generate the 50/100 msec ON/OFF signal on another channel.

Input those to signals into a NAND gate (akin to good ol SN7404) followed by an inverter (SN7408) if needed.

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 3 of 7
(8,466 Views)

Hi Michael,

 

You should be able to trigger the counters with each other on the 9174--can you post your code so I can see what routes you are trying to make?

 

However, I should also point out that the 9174 supports buffered counter outputs.  If you know ahead of time what pulse characteristics you need, you should be able to write an array of pulses to the counter output and get what you need using only a single counter.  If you need help implementing this let me know--here is an example that uses this functionality to generate a PWM signal that might help you get started.

 

 

Best Regards,

John Passiak
0 Kudos
Message 4 of 7
(8,453 Views)

 

Hello.

This is my attempt of code.

  

Result is 89137: Route already in use

 

 

 

 

 

 

 

 

 

 

 

 

 I also tried this version:

Result: Ctr1 acts only as start trigger.

 

GatedPulses_1.jpg

  

 

When I try to set the Gate0 Property to Pause Trigger, like this:

 

 

GatedPulses_2.jpg

I'm back to 89137, route in use error again.

 

I feel I'm completely lost in fuzzy details of counters.....

thank you for assistance

0 Kudos
Message 5 of 7
(8,447 Views)

ooops, one version go tlost in transit

 

PausedPulses.jpg

 

 

Download All
0 Kudos
Message 6 of 7
(8,446 Views)
Solution
Accepted by topic author conzemic

The image in your most recent post is closest to what you need to do (I didn't see a corresponding VI for it though).  Instead of using "/cDAQ2Mod1/PFI3" as your pause trigger, you should instead use "/cDAQ2/Ctr1InternalOutput".  This will allow you to route the counter output to the other counter along the backplane and does not require an open PFI line. 

Along those same lines, instead of "cDAQ2Mod1/ctr1" (the counter name on your bottom task) you can instead use "cDAQ2/_ctr1" to reference the backplane counter independent of whatever module you happen to be using.  Since the output is only routed internally I'd recommend doing this to avoid reserving any unnecessary lines on the module.

 

 

Alternatively, you could accomplish what you need with a single counter if desired by writing the pre-determined buffer to the counter task before starting it (see the example in my previous post).

 

 

Best Regards,

John Passiak
Message 7 of 7
(8,302 Views)