LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronized finite digital pulse trains

I'd like to have two finite digital pulse trains (controlled by counters) such that one train is 'on' while the other is 'off' and vice versa.  Is it possible to link them somehow to accomplish this?  I've used the Dig Pulse Train-Finite vi to get one pulse, but am have trouble coordinating it with a second pulse so that they're always in the opposite state.

 

If this isn't possible, I suppose I can have two pulse trains with the same start trigger, and give one pulse some sort of time delay so that it starts when the other goes to it's first 'off' state (they will have the same frequency but different duty cycles).  Using the PCI 6010.

 

Thanks.

0 Kudos
Message 1 of 7
(3,075 Views)

Hi jman1,

 

I'm slightly confused by your question.  You say "but am have trouble coordinating it with a second pulse so that they're always in the opposite state" implying you want them to exactly mirror each other in opposite states.

 

However, in the second paragraph you say they will have different duty cycles.  They will have to have exact inverse duty cycles in order to always be in opposite states.

 

The obvious pulse train has 50% duty cycle, the two signals echoing each other each pulse.

 

When one is 70% duty cycle, the other must be 30%.

 

Is this what you're trying to do?

 

 

 

In either case you can set both counter tasks to use the same start trigger, rate, and source, and then just have one have the opposite idle state.  

 

Eric S.
AE Specialist | Global Support
National Instruments
Message 2 of 7
(3,047 Views)
That is exactly what I'm trying for - different duty cycles that sum to 100%.  Sorry I wasn't more clear.  I'll try and do what you suggest.  Thanks.
0 Kudos
Message 3 of 7
(3,044 Views)

I tried to implement your suggestion but whenever I try and use both counters I get the following error:

 

Error -50103 occurred at DAQmx Start Task.vi:1
Possible reason(s):

The specified resource is reserved. The operation could not be completed as specified.

Task Name: _unnamedTask<D>

 

I'm using one DAQmx Create Virtual Channel vi for each counter; is this not the way to go?

 

Thanks.

0 Kudos
Message 4 of 7
(3,024 Views)

I figured out how to use a single trigger to control both counters and give them different idle states.  This gives me approximately what I want - two pulse trains of opposite state.  The issue I have is that when measured with an oscilloscope, there is a small delay between when one pulse turns off (say, counter 0) and the pulse turns on in the other train (counter 1).  The delay is ~10ms when counter 0 is turning on and ~6ms when counter 1 is turning on.  I'd like to get rid of this delay if possible.  I need the pulse of one train to turn on immediately (or as close as possible) to when the pulse of the other train turns off.  I'm okay with either finite or continuous trains.

 

I thought maybe the delay is caused by one counter having to send a signal to the other counter, so, using various examples, I tried a different approach.  I tried to use two digital outputs to simply toggle their state between 'on' and 'off' with a user specified 'wait' time setting how long each on and off is.  I'm able to get the two outputs to toggle their states, but can't get them to coordinate in any way.  I'd like to just have a simple toggle train, and take the inverse of this toggle, then send the original to one output and the inverse to another output.

 

I've attached my attempt using counters (Continuous Triggered Pulse Train2.vi) and my attempt using two digital outputs before attempting to coordinate them (simpleDigitalPulse.vi).  I would appreciate any general advice or specific programming tips.  Thanks.

Download All
0 Kudos
Message 5 of 7
(2,993 Views)

Hey jman,

 

So I tested those VIs here on my end, and they seem to work for me.  I'm wondering why you had a CI.frequency property node, but I deleted that since it didn't impact the task.

 

I ran the  on two counters (ctr0 and ctr1) and ran the output into two digital in lines, (P0.0 and P0.1) which I polled at 1,000,000 times a second.  I'm using an X-Series, PCIe-6321 to do this test.

 

Here are two pictures, the first showing the macro level, the second zoomed in, to see the signals were off by about 6.4us (when you said 6ms, did you mean 6 milliseconds or 6 microseconds?)

 

The counters were outputting at 10Hz, at opposite pulse widths and opposite idle states.  What is the frequency of your pulse train?

  

 

Test.jpg 

 

Test zoomed in.jpg

 

Eric S.
AE Specialist | Global Support
National Instruments
Message 6 of 7
(2,968 Views)
Thanks, Eric.  I figured out what I was doing wrong.  As you showed, the VI is working great.  My problem was that I was measuring the output with an oscilloscope after sending each pulse train through a photoMOS relay and power supply that I'm using Labview to control.  Apparently my relay and power supply are producing a 6-10ms delay.  I should be able to compensate for this by changing the virtual channels to be time controlled and making small changes to the high time, low time, and initial delay.  I'll be sure to use something like your Read Digital Channels VI in the future to avoid confusing software and hardware delays.  Thanks again!
0 Kudos
Message 7 of 7
(2,954 Views)