LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Single Pulse TTL

Solved!
Go to solution

Hello all,

 

I am going through the debugging stage of my small vi and found an inconsistency that does not make sense. My goal is to generate a single TTL pulse as soon as I discover a zero crossing of a sine wave. So I generate a simple sine wave and send a logical true to the block that supposedly should initiate TTL pulse generation. I first tested at 1Hz sine wave, and optained 1Hz TTL pulse. I then set my sine funnction to 5Hz, but still I got only 1Hz TTL signal, instead of 5Hz(1 pulse at each zero crossing of a 5Hz sine wave).

 

Can anybody suggest where the problem might be? 

 

Thank you in advance!

0 Kudos
Message 1 of 21
(5,078 Views)
Solution
Accepted by topic author Oleks

I believe your problem is easily explained by one sentence in the help for the zero-crossing VI: "If you wire a waveform value or a dynamic data type value to input data point, this VI evaluates only the first value of the input data."

Message 2 of 21
(5,052 Views)

Oh I see, thanks for pointing that out. I guess if I split signal into "time" and "amplitude" that would solve the problem. I'll give it a try. Thanks!

0 Kudos
Message 3 of 21
(5,044 Views)

@Oleks wrote:

Oh I see, thanks for pointing that out. I guess if I split signal into "time" and "amplitude" that would solve the problem. I'll give it a try. Thanks!


I'm not quite sure what you mean by splitting the signal into time and amplitude.

 

I probably should have elaborated more on my first reply, in case it wasn't clear. Your code generates the sine wave in segments, not point by point. The zero crossing VI only looks at the first point of a segment. If a segment contains a peak of the sine wave, the first and last points could be on the same side of 0 and the zero crossing would be missed. As you increase the sine wave frequency, each segment contains more of a cycle so it becomes more likely that zero crossings will not be counted.

0 Kudos
Message 4 of 21
(5,035 Views)

Hi nathand,

 

Thanks for the clarifications. I think I just encountered what you described. I added some changes to the VI so the signal from the function generator can be connected and I can test it on it. And I think I am hitting the exact problem you mentioned. In the range 1-5Hz, zero-crossing VI seems to be working(even though now I am not sure if it works correctly). At 10Hz sine wave, I dont get any zero crossing, or maybe 1-2 with some delay. That puts a big question mark on my final goal, to get a zero crossing on a live sine wave signal with frequency between 1kHz to 5kHz and send a single TTL pulse at that moment of time.

 

Is there a better options then zero-crossing VI for this particular task?(i attached my VI just in case)

 

Thanks in advance!

0 Kudos
Message 5 of 21
(5,029 Views)

Oleks,

 

How much time between the zero crossing and the pulse can you tolerate?  I seriously doubt that you have any chance of getting a pulse withn the same cycle at kilohertz frequencies unless you are running on a real time OS or FPGA.  Tne hertz, yes. Ten, mostly. 1 kHz, no way.

 

Some comments on your VI.

 

- None of the inputs to the DAQmx Channel property ever change after the loop starts.  Move it outside the loop.

- You did not fix the waveform to Zero Crossing PtbyPt issue. You read all available points and only use one of them.  This is practically guaranteed to miss most of the zero crossings, particularly since you read no more than 10 times per second.  Ten samples out of 10000 at random phase with regard to the signal.  You might find a zero crossing once a day and even then you would be 100 ms late.  If you only read one sample at a time, you would at least process all of them but it will only be a short time until you get buffer overflow errors.

- Right to left wires make it hard to see what is going on.

 

What is the ultimate purpose of your project? As I said above, I am not sure you can achieve your stated goals without significant changes. If we have an idea of the whole project, we may be able to offer better suggestions.

 

Lynn

0 Kudos
Message 6 of 21
(5,019 Views)

How much of a delay can you tolerate between the zero crossing and the pulse? Your loop has a 100ms wait, so you could potentially have a 100ms delay between the zero crossing and the pulse, assuming you even detected the pulse. You could shorten the wait, but you won't get consistent timing and you'll keep your processor busier than necessary. If the delay is acceptable, you could write a VI that loops through all the acquired data and looks for a zero crossing, instead of checking only the first point in the waveform.

 

If you want a pulse at the exact moment of the zero crossing, you need to do it in hardware. I'm not an expert in the DAQmx options, but I'd look at the Trigger functions. There's an Analog Edge trigger that triggers when an analog input crosses a given level. You'll need to determine if your hardware supports this, and whether you can use it as a trigger for a digital channel. You probably want to configure the pulse channel differently as well, if it's an option - you want it to be retriggerable, instead of starting and stopping the task every time (starting and stopping tasks is slow). If your hardware supports hardware timed digital output, you might find it better to use a digital output instead of a counter to generate the pulse.

0 Kudos
Message 7 of 21
(5,018 Views)

nathand, johnsold, Thanks a bunch for all your input!

 

You both raised important point that I was not paying attention to. I would like to describe the project to some extend, maybe that indeed will help to find a most suiatble aproach to handle it.

 

I am measuring a pressure in the air inline gate valve(very high range of velocities), at the time when resonance occurs. At that particular time, air flow couples with acustic cross modes present in the valve and pressure signal can be described as sinusoidal. So, that is the reason I was testing my VI with a sine function. There are several acoustic cross modes that can couple with flow, hence the resonance can occure in the frequency range between 1-5kHz. I collect pressure data through PXI 4472. 

 

Now, regarding zero crossing. I would like to visualise the flow patterns at certain phase insatnce of the pressure signal. For that I thought I can find a zero crossing in my pressure signal and send TTL pulse to capture flow patterns at that time. I can then offset TTL pulse and move to the second phase I am interested in. So, in terms of the delay tolerance, I think as close to 0 as possible, otherwise I will be hitting wrong phases (and I guess it is what was happening). 

 

I guess while the whole idea seems to be straightforward, the correct solution of it might indeed require to rethink the whole thing and some additional hardware might be needed.

 

Any suggestion would be highly appreciated. I will also research if our hardware is capable in any kind of hardware crossing detection.

0 Kudos
Message 8 of 21
(5,009 Views)

Oleks,

 

Sounds like an interesting project!

 

How are you visualizing the flow patterns?

 

Are you using all the channels of the PXI-4472?  Do you have any other data acquisition equipment available?  What kinds of pressure sensors are you using? What OS and computing platform?

 

I have some ideas, but they depend on the types of measurements you are making.

 

What is the duration of the resonance?

 

Lynn

0 Kudos
Message 9 of 21
(5,005 Views)

I am glad that you find this project interesting! I have some DAQ hardware, it is a bit old though.

 

Our platform is PXI 1042 with 32bit Windows XP on it. In this project I am only using 3 channels of PXI-4472, and potentially can  only live with just one, as the other two are served for identification of the acoustic mode orientation.

 

The pressure sensors are: PCB model 103A02, piezoelectric

 

The resonance duration is something I have full control on as it is a function of inflow velocity. Air can be supplied without interuption 24/7 so the resonance can occure as long as needed, within safety limits of course(~ 165dB). I usually record about 20sec of data, at 2^16 Hz.

 

The flow visualization is done by PIV system, made by LaVison Germany, basically a dual cavity laser and a camera connected to a PTU unit that sychronize both. It can synchronize the aquisition from external trigger(TTL). It can be either cyclic(that was  the reason why I wanted to fire TTL pulse at each zero crossing) or random.  The only condition is the TTL should fire at "exactly" the same point(zero crossing). I can offset Image acuisition from PIV system to shift between the phases.

 

Besides that I have PXI 6221, BNC 2110, and SCC 2345. We might be able to get additional modules from NI if they can be useful.

 

Let me know if there is any other information that might be helpful. Thanks again for your time!!!

 

Oleks

0 Kudos
Message 10 of 21
(4,996 Views)