LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating custom analogical signal synchronize with an external trigger

Solved!
Go to solution

Hi,

I'm trying to generate an oscillating voltage of custom shape. Furthermore, I would like that signal to be synchronize with a 100kHz square wave signal. I want my custom signal to repeat itself each time I receive, let's say, 500 triggers from my square signal.

 

I'm kinda new with labview. I did that small demonstration and generated a custom sinus signal but it only generates predetermined signal shapes.

http://www.ni.com/academic/students/learn-daq/generate/

 

Obviously they are many ways to do this but what would be the most efficient way to do it? Which functions should I look into to achieve that?

 

Thank you.

0 Kudos
Message 1 of 7
(2,594 Views)

1. A great source of examples can be found right in the LabVIEW environment.  From the menu choose "Help-->Find Examples...-->Hardware Input and Output-->DAQmx-->Analog Output"

 

2. Choose the example for "Voltage - Continuous Output".

 

3. To avoid changing the built-in example, immediately go to the menu and choose "File-->Save As...".   Choose the option to Copy and to "Substitute copy for original" (a safe option thought it may not sound like it), then save it to your favorite local folder such as your Desktop.

 

4. This is a *starting* point.  There's still some stuff for you to do.  But most of the guts are here to learn from while you make a few small modifications.   Remaining items:

- configure the 'Sample Clock Source' to be a PFI pin that you wire your 100 kHz signal to

- create your own array of 500 samples that you want to keep regenerating.  The task is already set to be "Continuous" so it will keep repeatedly re-cycling through whatever samples you write to the task.

- there will be a little bit of learning and understanding to do regarding the difference between writing samples as an array of values vs. writing samples as a waveform (which contains the same values plus timing info)

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 7
(2,569 Views)

Thank you.

Small question is it normal if in the example the Waveform Settings, Ouyput and trigger setting in the front panel are left empty? By default, if I choose the right physical channel and OnboardClock the vi runs but does't give me any output.

Thanks.

0 Kudos
Message 3 of 7
(2,535 Views)

In the original example I referenced:

 

Waveform Settings: this defines the signal to be generated.  If the array is empty, you won't be defining any signal to generate and can expect to get an error when you run.  So no, it's not normal for this to be empty.

 

 

Output:  this is a graph that shows the signal you're (intending to be) generating.  It's an indicator that the program will update when it runs.  Again no, not normal to be empty.

 

Trigger Setting:  this is an area configuring a variety of possible triggering options for your task.  This is "empty" when you choose the "No Trigger" tab, and it *is* pretty normal to run a task without any triggering. 

 

Once you get the original example working reasonably, then you can follow the steps I suggested before (save a copy of the example before modifying, then substitute in your own code to create the array or waveform you need to generate instead of the standard sine/square/etc functions offered in the original example.)

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 4 of 7
(2,527 Views)

Hi,

 

Thank you for the help. I manage to make everything work except the trigger. Could you try to explain what that part of the code those? I don't understand how it uses the trigger.

-Those Labview expect to recieve a trigger each 100ms to time his frequency.

-How those it creates his frequency from this information?

Thank you.

RMT 

0 Kudos
Message 5 of 7
(2,499 Views)
Solution
Accepted by topic author RaphaelMT

I think you and I are using the term "trigger" differently.  I believe you should be using the term "sample clock" instead.

 

This was what I was getting at in msg #2.  The 100 kHz square wave would act as a *sample clock* for your AO task.  To make your waveform repeat every 500 cycles of that square wave, you just need to define your waveform shape to have 500 sample values.

 

I don't follow your comment about receiving a "trigger" every 100 msec.  This is the first mention of such a time interval.  Are you referring to your 100 kHz square wave that I think needs to be treated as a sample clock?  If so, it cycles every 1/100th of a msec not every 100 msec.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 6 of 7
(2,494 Views)

Thank you. Everything works now.

0 Kudos
Message 7 of 7
(2,487 Views)