LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Irregular timing in a timed loop

Hi,

I have a code for creating two analog signals successively. The first one acts a trigger signal (a 10ms rising edge) and the second one is for driving a speaker (2s sawtooth) and the whole thing is in a timed-loop which repeates every 10s. I can't create a digital signal for the triggering because it fires up a PIV system which only works on analog signals. I have a USB-6001 DAQ card with two analog outputs that each of them is used for each of the output signals. The vi file is attached.

since I take phase-locked pictures with PIV system, it is crucial that the timing of the speaker output signal be at the same time (with max 1ms tolerance) but it doesn't happen in action. When I time the signals in the vi, I get very oscillating delta-t for the signals. the pictures are attached.

Is there any other way to do this to make the time oscillations go away or at least be less frequent with less amplitude?

I really appreciate any help.  

Download All
0 Kudos
Message 1 of 8
(3,598 Views)

All your timing measurements are arbitrary because you don't know when the ticks execute relative to the rest of the code. The various output nodes of the frame can output the elapsed time of the previous frame directly, so use that.  Then you have express VIs (DAQ assistants), each with an unknown startup delay.

 

Why don't you combine the two simulated signals into two channels, one all zero in the second part and the second all zero in the first part and use lowlevel IO and run a two-channel output once. You don't even need a time sequence for that.

 

Timed strictures are of limited usefulness on a windows system. They are more useful on a RT system.

 

 

 

 

Message 2 of 8
(3,556 Views)

Am I correct that your goal is to make a Trigger signal (which I take it can be a pulse of some width and some height, though you mention a 10ms rising edge, which I assume is the maximum rise time, i.e. a 0.01ms rising edge would also work) and a sawtooth waveform (you say "2s sawtooth", but don't say whether this is the duration of the entire waveform, the duration of the sawtooth rise, the amplitude of the rise, how many "sawteeth" you want to output)?  Is there any relationship between the Trigger and the Analog Waveform?

 

I presume you understand that a Digital Signal is simply an Analog Signal that takes on two values, typically 0v and +5v (and often called a TTL signal), and thus creates pulses whose width can be (programmatically) varied but those amplitude is (generally) fixed.  TTL signals make excellent triggers, by the way.

 

As Altenbach explained, timed loops are rarely used in Windows systems, since Windows is notoriously "sloppy" about keeping time rigorously.  On the other hand, DAQ devices (such as the 6001) typically have very accurate clocks within them and can often be programmed to give you very tight control of timing.

 

You usually do not need (and should not use) a Sequence Frame, as you can sequence things by using Error In and Error Out and having successive DAQ Assistants use the same Error Line.  Also remember how Data Flow works.

 

I don't believe you should need to "Simulate arbitrary signals".  Do you understand how the USB-6001 handles Analog Output?  You can generate a single ramp once, present it to the 6001 as its Buffer, and ask it to output the points at some rate, letting you know when it finishes a cycle.  Its clock handles all the hard work, works independent of the CPU's clock, and is very reliable.

 

Bob Schor

Message 3 of 8
(3,514 Views)

Thanks altenbach for the response,

I don't understand what you mean by "lowlevel IO" and how can I make it repeatable every 10s with minimum time fluctuation? will a simple while loop suffice? 

0 Kudos
Message 4 of 8
(3,500 Views)

Thanks Bob,

Well actually I'm not an expert on Labview, I just need a code to make my devices going! As I said there are two devices that should be controlled. The first one, the PIV system, need a trigger signal (the ramp). I tried a digital signal on it but it didn't work with that signal. It only works with analog signal. maybe I'm doing something wrong in generating the digital signal. Could you help in that?

The second device, a speaker, needs a sawtooth shaped signal (attached picture) that ramps up quickly and down slowly. the complete signal is 2s. 

I didn't undestand the "You can generate a single ramp once, present it to the 6001 as its Buffer, and ask it to output the points at some rate" part. How can I give the signal to the DAQ card once and make it repeatable? Could you please tell me how? 

0 Kudos
Message 5 of 8
(3,498 Views)

@altenbach wrote:

Timed strictures are of limited usefulness on a windows system. They are more useful on a RT system.


I'd even take it a step further. They're detrimental on a Windows system.  All of the pretty node add overhead.  With a non-deterministic OS, like Windows, the strengths of the timed loop vanish.  Windows is still your scheduler.  You've added overhead without nearly enough to show for it.  Just use a while loop. 

 

If you need strict timing, you'll want to setup a hardware task to control the timing and get away from anything using waits in loops.  That sytle of timing will increase considerable jitter, aka irregular timing.

Message 6 of 8
(3,481 Views)

@pirniaa wrote:

I didn't undestand the "You can generate a single ramp once, present it to the 6001 as its Buffer, and ask it to output the points at some rate" part. How can I give the signal to the DAQ card once and make it repeatable? Could you please tell me how? 


I was thinking of Retriggerable Tasks in DAQmx, such as discussed here.  I'll confess I've not done this myself (though I know about it), and am not 100% that the USB-6001 supports this, but it does have Hardware Continuous Output mode, so you should at least be able to get it to output one 2-second "complex waveform" that you've pre-generated.  If retriggering isn't supported, when it finishes, you just call its "Generate" state again and "do it again".


The first one, the PIV system, need a trigger signal (the ramp). I tried a digital signal on it but it didn't work with that signal. It only works with analog signal. maybe I'm doing something wrong in generating the digital signal. Could you help in that?

Well, as I tried to explain, a Digital Signal is simply an Analog Signal that takes on only two voltages, typically 0 and +5 volts, switching between them almost instantaeously (as fast as the transistor can switch).  If your device requires a slowly-rising signal, or if it gets triggered by something other than a voltage in the range of 3-5 volts, you may need to either (a) shape your Digital Output, or (b) do "something else" (like maybe use an AO channel).  I hope you realize that you want to make a "really fat pulse", say something that is True/On/1/+5v for a few milliseconds before you turn it False/Off/0/0v.

 

Bob Schor

Message 7 of 8
(3,475 Views)

I got rid of the timed structure and used two channels in one DAQ assistant and put the whole thing in a simple loop and the timing is now very good. Thanks everyone! 

0 Kudos
Message 8 of 8
(3,459 Views)