LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange Variance of Duration for Pulse Generation

Solved!
Go to solution

Alexander,

 

I'm interested in figuring out whether I'm wrong about the "restriction" I referred to.  I'm pretty sure that it *was* true for continuous pulse trains back around DAQmx 8-point-something.  I'm not quite as sure whether I ran into it with a 6602 or an M-series board.

 

However, I'm not sure I was entirely clear about how this "restriction" (if it exists) works.  You commented that you doubted that you coincidentally updated your pulse properties during the 24 idle usec rather than the 975 usec low time.  My understanding of the "restriction" is that it doesn't matter when you change the pulse property values as long as you've already generated at least one pulse with the previous values.

 

I've thought that to be a true restriction for continuous pulse trains and remember producing an error when I tried to change the pulse specs too rapidly.  I *do* now wonder whether there was a similar restriction for retriggered single pulses.  And either way, I wonder whether that restriction has gone away either with a newer DAQmx version or with newer counter chips like those in the X-series boards.

 

In the interest of learning things while not having hardware available to experiment, let me describe the way I've long believed that restriction to work:

 

1. The counter generates pulses based on the pulse count values that are in its active registers.  These counts represent the low and high times for the pulse.  Our code never writes to these registers directly.

2. There's another pair of "pending" registers that our code *does* affect.  When we write to these, a flag gets set somewhere (driver?  board chip?) to tell the board that there are new values to load.

3. At the next appropriate opportunity (not sure when this is, but likely exactly once per pulse cycle), the board will check that flag and if the flag is set the board will transfer the values from the pending registers into the active registers. 

4. I *think* that the flag won't be cleared until after both pending registers get copied to the active registers.  I'm guessing that this process must take 1 cycle because they can't both be copied at once.  You'd have to write the low time while the high time is counting down and write the high time while the low time is counting down.

5. Any attempt to write to the pending registers while the flag is still set produce an error

6. After the flag is cleared, we are allowed to write to the software registers again.  Any time, without regard to the phase of the pulse(s) being generated.

7. So, since the flag doesn't clear until after producing 1 cycle of the new pulse times and since we can't change the software register until after that, I *think* that the 2nd set of new pulse times can only take effect after at least 2 cycles of the first pulse times.

 

After all that, my question is: do you know whether you were ever able to create 3 consecutive retriggered single pulses with different pulse specs for all 3?   I'm beginning to think that might have *always* been possible.  The way I outlined my understanding of things above, it seems like the pending registers could almost always be moved into the active registers during the idle time between the end of one pulse and the receipt of the next trigger.

 

-Kevin P

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 11 of 26
(1,554 Views)

Hi everybody! Thank you so much for this great conversation!

 

I tried to design one VI fitting for us, but there is still something missing. You can find it in the appendix.

Unfortunatly I get an error due to the spectrometer triggering, because the task is already in use. Isn't it possible to use the PFI twice (starting edge for two counters)?

If I delete the spec trigger, everything seems to work at first glance.

I know that the spec trigger has to be initialized again for each sample but this cannot be the point.

 

Thanks for your help!

 

Download All
0 Kudos
Message 12 of 26
(1,546 Views)

On the 6602, the "spec" finite pulse train you configure on ctr0 must also use ctr1 as a helper.  (Behind the scenes, DAQmx uses the "paired counter" to gate / pause-trigger the pulse train generated by ctr0.)

 

I'd wire & configure the counter input speed measuring task to use ctr4 or higher.   If you ever need to make your "lamp" pulses be a finite pulse train out of ctr2, that task would need to use ctr3 as a helper.  By staying at ctr4 or above for your speed measurement, you shouldn't run into this again.

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 13 of 26
(1,537 Views)

Interesting VI:

The top for loop goes to the next iteration when everyting else stops.

The spectrometer behaviour has changed: previously it generated 1 trigger pulse per N Lamp pulses, now it generates N pulses with period (= SpecHigh time + Spec delay + SpecDelay for initial pulse) < Lamp period and then repeats them after retrigger. What is correct?

 

 

0 Kudos
Message 14 of 26
(1,533 Views)

Kevin,

I have checked the continuous samples generation and changing frequency on the fly, it works fine. Also I have tried to change several times per cycle (1 Hz frequency, changing it on the fly 10 times per second). No error.

 

I had the error you might be speaking about: the properties you change should match the type of the task. Daqmx does not recalculate them automatically.

When you create counter output task specifying high/low time, you can change only high/low time, but not frequency / duty cycle pair.

Message 15 of 26
(1,526 Views)

@ Kevin

Thank you for this comment. I have to admit, that I'm totally new in this triggering stuff and still learning a lot. I got this system with a (really bad) written labview-software a few month ago, rewrote it and now what to optimize the triggering, too. Are these "help" counter taken automatically, or have they be to defined somewhere? Would you comment on how you would do the wiring on the Ni-Box. Thanks a lot. 🙂

 

@ Alexander

Yes you are true, my trigger example is not complete and has some weak points. But I just wanted to check if everything fits together.

About the spectrometer triggering: In the first example I had a very high integration time, making it possible to flash multiple times on the spectrometer. This is fine, but you increase noise of course, too. Therefore I decided to make the integration time as small as possible (1ms) independent on the period and perform the triggering in this way, that the flash (and sample) is always in the middle of my integration time. Hence there are no multiple flashes in one integration period but of course multiple spectra should avaraged to increase the signal to noise ratio.

Furthermore there is still something missing, because my hardware (spec and lamp) could slow at some period (~ 350 Hz). Then I would have to trigger only one every second digital edge and synchronize the lamp and spectrometer. But this is the next step...

0 Kudos
Message 16 of 26
(1,518 Views)

Hi everybody! I have now changed my routing on the NI BOX (Lamp -> Ctr0 , Spec -> Ctr2, Speed -> Ctr6 but unfortunatly I got problems with the updates of the lamps low time (please refer to the attached snapshot).

Alexander, you told us that you got this working. What am I doing wrong? I would be grateful for any help!

Furthermore, do you have any recommendations for me how to do the lamp and spec trigger only on every second (or maybe third) edge upon some frequency (500 Hz) and how to synchronize this?

Thank you so much!

 

Download All
0 Kudos
Message 17 of 26
(1,501 Views)

Sorry, I have confused you.

I have tested on the simulated 6602, it did not give this error, the real one does. NI says you can not write pulse properties twice a cycle, exactly as Kevin warned.

http://digital.ni.com/public.nsf/allkb/5F4D0C03B345468986256E85005A2FCC

You can track the change of the delay and update only when required. I assume it happens on the first iteration, because your delay is more than period

 

> About the spectrometer triggering: In the first example I had a very high integration time, making it possible to flash multiple times on the spectrometer. This is fine, but you increase noise of course, too. Therefore I decided to make the integration time as small as possible (1ms) independent on the period and perform the triggering in this way, that the flash (and sample) is always in the middle of my integration time. Hence there are no multiple flashes in one integration period but of course multiple spectra should avaraged to increase the signal to noise ratio.

Then you can have spectrometer pulses going just like lamp pulses and split the signals after you acquire them. 

Another option is to generate finite number of pulses with the period = sync period (not high + delay as in your vi) and specified delay.

 

Furthermore, do you have any recommendations for me how to do the lamp and spec trigger only on every second (or maybe third) edge upon some frequency (500 Hz) and how to synchronize this?

I would use one more counter as a frequency divider (single pulse, low time = 0+J, high= (N-1)*T, retriggerable) and synchronize previous tasks from it.


Message 18 of 26
(1,478 Views)

Hi Alexander, thanks for your reply!

 

> You can track the change of the delay and update only when required. I assume it happens on the first iteration, because your delay is more than period

Do you have a hint for me how to do this. A wait multiple function as shown in the link isn't very functional because it "reacts to slow" on changes.

 

Then you can have spectrometer pulses going just like lamp pulses and split the signals after you acquire them. 

Unfortunatly this won't work because the spectrometer reacts to slow. But however with 0,5 ms before the lamp flash I should be save.

 

Another option is to generate finite number of pulses with the period = sync period (not high + delay as in your vi) and specified delay.

This is what I want to do and it should work fine.

 

> I would use one more counter as a frequency divider (single pulse, low time = 0+J, high= (N-1)*T, retriggerable) and synchronize previous tasks from it.

Can you show this to me in a small VI? This would be really great! Do I have to do hardware routing on my NI BOX in this case or can I use the internaloutput to gate this signal?

Because for the first case (0-500 Hz) I have another trigger source as for the second one (500-1000Hz). At the moment a gated my trigger signal (at Ctr6) to Ctr0 and Ctr2, is this really necessary?

 

Sorry for this bunch of questions!

 

0 Kudos
Message 19 of 26
(1,471 Views)

I think Alexander has a better understanding of your overall test setup.   Also, I can't see any LV2011 code b/c I'm using 2010. 

 

Meanwhile, here's an example of a way to divide down the trigger signal.  Note that you should be able to change the division factor on-the-fly without stopping the task.  To help with that, note the "CO.ReadyForNewValue" property.  By only updating the High & Low Ticks when the counter task is ready, you should avoid the error you posted.

 

You could also do the division using the retriggerable single pulse method Alexander referred to.  Either can probably work, but they have some subtle distinctions.  Since I don't have hw here to test with, I'm more confident how the code below will behave.  I'm not quite sure how that "Ready For New Value" property would behave in a retriggerable single pulse task.

 

The basic idea of the method below is to change the default behavior of the counter so that instead of toggling state each time it counts down the low and high ticks, it will instead generate a pulse.  By feeding the same value N to high, low, and initial delay, you'll get output pulses after every Nth input pulse.  (One subtle distinction: this method produces output pulses on the Nth of every set of N inputs, the retriggerable single pulse would produce pulses on the 1st of every set of N inputs.)

 

-Kevin P

 

P.S.  You should replace the "reference" and the "DigiNum (strict)" property nodes with a local variable of "N".  That's what I had but apparently it gets changed when making it snippet.

 

 

divided trigger.png

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 20 of 26
(1,462 Views)