Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Using trigger and timer to switch value of a digital output line

I have a NI PCI-6115 board and the BNC-2110 and basically want to capture data from an analog source with LabVIEW 6.1.

The capturing itself works perfectly. I am using a tigger signal to start the recording to the internal RAM of the 6115 (AI Config/AI Start/AI Read).

In the next step I want to synchronize a digital output line to the trigger signal. The digital output value shall be inverted at time x after the trigger signal came in. I am looking for a way to start a timer with the same trigger signal that is used to start the capturing. As soon as the time is up the digital output has to be inverted. I didn't find an example which gave me the right idea. I found the LabVIEW functions to generate a
hardware timed pulse, but none to invert a digital output line... Maybe I just missed it. Thanks for any hints in advance!
0 Kudos
Message 1 of 6
(4,199 Views)
That should be possible as described in the attached example. A Counter is used to have a single pulse if the trigger occures. Using the polarity property you can invert the signal. A second counter could be the gating counter to wait a specific time before output the pulse.
0 Kudos
Message 2 of 6
(4,199 Views)
I coulnd't modify the example so that it fits my needs so I added a flip flop to my hardware to generate the toggeling from the pulse signal dividing the pulse frequency by 2. My problem is solved although I couldn't get the NI hardware to do what the manual promised. I found a short hint how to activate the toggeling mode, but it did not toggle at all. Never mind, I can live with the current solution.
0 Kudos
Message 3 of 6
(4,199 Views)
Unfortunately, I don't have access to Labview to look over DirkW's code right now, so I may end up being redundant. A few words may help clarify a method that shouldn't require an external flip-flop.

You'll be using a counter output as your toggled digital bit. The standard digital i/o on your board can't be activated with hardware-timing precision.

The counter should be configured to do "retriggerable pulse generation." (Is there an analogous selection for a single triggered pulse? I can't recall and am unable to check now. If there is one, that may be a better choice, especially if your trigger signal might generate multiple pulses.) Wire the trigger signal to the counter's Gate input.

By default, the counter's output sign
al will be low while waiting for the trigger, remain low for a duration corresponding to "Pulse Spec 1", go high for a duration corresponding to "Pulse Spec 2", then revert to low again. Note that the counter can be software configured for opposite polarity on the output, if desired.
From your description it sounds like you'd ideally want to specify "Pulse Spec 1" with great precision AND make "Pulse Spec 2" as long as possible. Well, real-world trade-off time.
If you use the internal 20 MHz timebase for your source for best timing precision, the pulse duration will be limited to be <1.0 sec. With the internal 100 kHz timebase, you're limited to ~10 microsecond precision, but can have a pulse duration over 2.5 minutes.

Now that the "answer" is out of the way, what exactly was the question again? What behavior does your flip-flop give you that you couldn't accomplish with the NI hardware? I'm not sure I understand your reference to dividing a pulse frequency -- I thoug
ht you wanted a single pulse, not a pulse train...
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 6
(4,199 Views)
Hi Kevin,

I'm not a native English speaker so I may have chosen the wrong words...

What I need is basically no pulse I need a digital signal that behaves like this:

First trigger event is occuring, after a specified waiting time the value of e.g. GPCTR0_OUT changes from low to high and simultaneously the analog signal recording is started and runs for the duration of 1.6 secons (maximum time the internal memory of the PCI-6115 can hold at maximum resolution). The trigger signal is repeated with a frequency of 100 to 400 Hz. After each trigger signal plus the waiting time the GPCTR0_OUT shall change its value (toggle the output either from high to low or from low to high). I attached a bitmap to illustrate the output sig
nal I need.

Background: I have two elements and each of these elements can be used as sender and as receiver. Now I have to tell the hardware which element has to send and which has to receive. The hardware accepts a digital signal for this, as long as the signal is low one direction is active. When the signal is high the other direction is active. This is why the signal has to stay what it is untill I want to switch directions. Whatever happens the signal is only allowed to change for the brief moment when I switch directions.

I hope I described the problem detailed enough to be understood.

From the manual there should be a way to toggle the output of GPCTR0_OUT instead of generating a pulse. I found the parameter to activate toggle mode, but it resulted in short spikes instead of a toggeling of the signal the way I need it. I found no example using the toggle mode and no description what else I have to configure to get it working so I might be missing something in my test pr
ogram.

However I have a working solution for now so everything else is academic although I would like not to use the flip flop solution for easier timing calculation.
0 Kudos
Message 5 of 6
(4,199 Views)
First, I'm impressed with your English -- you've expressed your question and description better than many natives!

Second, I may have a solution that doesn't require any external logic circuitry, though it will require both counters on your DAQ board. It goes like this:

GPCTR0 - the helper
-----------------------------
1. Configure GPCTR0 for "retriggerable pulse generation", with output mode set to PULSE (not toggle). Use the default output polarity = high pulse.
2. Configure the Gate to use your trigger signal, setting polarity to respond to falling edges.
3. Configure the Source to use the max internal timebase (20 MHz).
4. Program the pulse to have a total cycle time of 0.7 msec. This corresponds to 14000 cycl
es of your 20 MHz timebase. May as well set delay and pulse times equal at 7000 each.
5. Operation: each falling edge of the trigger signal will cause GPCTR0 to generate 2 pulses of 50 nanosecond duration. The falling edge of the 2nd pulse will occur exactly 0.70000 msec after the trigger signal.

GPCTR1 - the generator
----------------------------------
1. Configure GPCTR1 for continuous pulse train generation, with output mode set to TOGGLE (the default).
2. Configure the Source to be "other counter output" or "other counter TC", setting polarity to respond to falling edges.
3. Program the pulse to have the minimum legal delay and pulse times -- 2 source edges each.
4. Operation: on every 2nd falling edge coming from GPCTR0, the output of GPCTR1 will toggle its state. This should satisfy your timing diagram.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 6
(4,199 Views)