Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate single pulse via PWM output?

Hello everyone,

 

This is my first post and I'm a newbie at using MyRIO and LabVIEW.

I'm making a program which allows to measure the changes in time of flight of an ultrasound wave in the air.

I'm using a 40kHz piezoelectric emmiter and reciever, the electronic part has already been made. The emmited singal needs to be generated by MyRIO. 

 

I need your help with generating short time single pusle with, as i think, 12,5 us pulse width. I tried to do it by digital out and analog out but measurments were not proper. I'm afraid it occured due to nesessity of very short loop period in ultrasound measurments. The generating and measuring loop iteration executed longer than demanded.

digital perodic.png

Here is the test where I tried to generate a square wave to arouse a resonance in the reciever. The generated frequency was wrong.

The white line is emitted signal, the red one is recieved. No matter how I changed the distace between transducers, nothing changed. 

 

 

The program worked properly only with generating signal by PWM out, but periodic PWM signal allowed me to measure only short time changes (within half of phase - 12,5 us).

So i tried to generate 40kHz PWM witch duty cycle variable form 0 to 0.5 to achieve a single pulse, but because that switching wasn't sychronised with PWM phase and frequency, achiewing a single pule with correct pulse width was a matter of luck..

pulse.png

So my question is: how to generate a proper single pulse by PWM output? Is it possible?

 

 

I attach both programs, the not working program (first picture) and almost working one (second picture).

Thank you in advance for your help:)

 

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

Hi Miech and welcome to NI forums!

 

Since PWM functionality is not specifically meant for single pulses, you either have to work around its limitations or create your own functionality.

 

As a workaround try using low frequency and an even lower duty cycle, say 100Hz PWM with 0.125% duty cycle equals to a 12.5us pulse. Then when the pulse was generated, you have 10ms (until the next cycle of the PWM begins) to set the duty cycle to 0, thus stopping the generation after the first pulse.

 

The other option is to create your own FPGA personality that allows for single pulses. For this, you will need to modify or create the FPGA code in LabVIEW FPGA. Here you will find some additional info how this is done.

 

Let me know if this was helpful.

 

Kind regards:

Andrew Valko
National Instruments Hungary
0 Kudos
Message 2 of 3
(7,925 Views)

Thank you for your reply,

 

The workaround idea was smart but my approach was wrong. The code without FPGA doesn't allow to use required sampling frequency - every loop iteration was late and my "correct" measurments were result of aliasing.

 

So now I'm trying to create an FPGA program based on myRio custom FPGA template. It seems to me that some kind of buffer will be necessary to acquire data with so high sampling frequency. I found some examples working with NI CompactRIO Waveform Reference Library, but I'm afraid it will not work with MyRIO.

 

So now my question is:

How to build an FPGA code with high speed data acquisition for MyRIO? Where can I get more info about it?

 

Thank you in advance:)

0 Kudos
Message 3 of 3
(7,841 Views)