LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write two analog signals simultaniously while both are editiable by the userinterface

Hallo, my current attemt to create two waveforms has faild me and i need forum help 😛

 

I want to create a very low frequency sinewave together with a pwm/rectangular waveform,

 

Output Device: NI9264, on cDAQ-9178

 

Wave properties

Sine: 0,4Hz to 2Hz, Voltagefrom: 2,5V to 0V

Rectangular: Ton:250~2000ms Toff:5ms Voltage: Ton:3,1V Toff:0V

 

My current problem is that i thought i could use "build waveform" to create a short part of the waveform and then output it to the output and keep it in sync/ continously without breaking the waveform.

 

The appended .vi has been created with Labview 2014, i can convert it for anyone to an older version if needed

 

 

Should i rethink my approach and use an array to write to the output or run both signals in one loop (repeating the slower one just with the same data?)

 

I am bit lost currently 😞

0 Kudos
Message 1 of 10
(3,854 Views)

What is your problem?  What about the current design doesn't work?  I know the card is a simultanious output, but does that mean you still can only have one task running at once?  And they are clocked at the same output instead of muxing?

 

If that is the case then using this hardware the only option you have is to generate one task with both channels in it.  As you mentioned you can do this and have multiple cycles of the slow waveform and maybe one of the faster.  The problem with this technique is that the data output rate needs to be the same on all channels, and the max is 25Ks/s/channel so only 12.25Ks/s on two channels.  You then need to find a common frequency that they both can agree on.  If your slow wave is at 5Hz and your fast wave is at 12Hz then you'll need to generate 5 cycles of the 12Hz, and 10 cycles of the 5Hz so that they both run for the same amount of time, and when one cycle ends the other begins.

 

If you can do all that then you can generate your two outputs.  But a much easier solution would be to generate the sine wave on one analog output, and genverate the PWM output with a counter and get it to be driven to one of the two BNC connectors you have on the front of your cDAQ-9178.

0 Kudos
Message 2 of 10
(3,846 Views)

that means the chassi counter can be used as an output?

 

i haven't seen that before ^^

 

is there any tutorial on how to use the chassi alone?

 

 

Thank you for the tip, does that mean my box can't output more than one channel at a time? That would be crazy sad 😞

 

 

0 Kudos
Message 3 of 10
(3,824 Views)

@Meins321 wrote:

that means the chassi counter can be used as an output?

 

i haven't seen that before ^^

 

is there any tutorial on how to use the chassi alone?

 

 

Thank you for the tip, does that mean my box can't output more than one channel at a time? That would be crazy sad 😞 

 


Don't misunderstand what I said, you can output more than one channel at a time in a finite or continuous output.  As long as the number of samples on each channel are the same, and the clock rate between all the channels are the same.  You only have one clock for all of your AO, which is where this limitation comes from.  Single point writes don't have any real limitation just finite or continuous outputs.

 

As for the example of using the BNC connectors. Here is an overly complicated one I did a while ago which makes a frequency sweep on a PWM waveform using one of those BNCs as the output.

0 Kudos
Message 4 of 10
(3,818 Views)

Thank you for your time and help!

 

While having only one clock source, can i downsize the sampling size from my sinewave and still use the other analog outputs to send some extremely slow analog signals?

 

It would be enought for me, as the frequency is low, just to use a lower sampling and Buffer size to keep the abillity to write to other ports...

 

 

Please have a look at the posted vi, it does run but wont give any output to the analog outs of my card 😞

0 Kudos
Message 5 of 10
(3,774 Views)

Meins321 wrote:

 

Please have a look at the posted vi, it does run but wont give any output to the analog outs of my card 😞


Does it also generate errors?  Cause it should.  You cannot start two tasks on two outputs which share the same clock.

 

But even beyond that what is that weird while loop doing for you that runs once reading controls?  

 

And you are generating a 2D array of setpoints but you have no timing source so when should the hardware output the next value?  

 

You can either define a clock source in one place (remember only one task), or set the output with single point values which doesn't use a clock source but you will be limited by how fast Windows can update it, and that will probably be around 10-50 times a second, but the jitter will be large and inconsistent.  Windows goes out to lunch and you have no control over that.  What is wrong with using the counter on the BNC as I suggested?  

 

From your original description it sounded like that would work.  Or as we mentioened earlier, use one task for all outputs, and do some math to generate the slow and fast waveforms in one clock source.

0 Kudos
Message 6 of 10
(3,760 Views)

No it does not generate any errors 😞

 

i thought that i have to start two tasks with the same clock, as i have only one clock??

 

The wired while loop should run every 100ms (while) and take slow readings from the user (to save performance) and write it to an array, which was needed for the daq mx write for two channels.

 

"And you are generating a 2D array of setpoints but you have no timing source so when should the hardware output the next value?"  <= i thought that it would write while it "has" time, not to interfere with the faster signal...

 

Yes your original proposition was nice but my second signal is square wave where i needed a setable high time and i have used two quick vi's who can write simulaniously to two outputs 😉

 

 

it should be possible ist just me beeing unable to write a labview programm while keeping the hardware limitations 😞

0 Kudos
Message 7 of 10
(3,748 Views)
@Meins321 wrote:

 

i thought that i have to start two tasks with the same clock, as i have only one clock?? 


AnalogOut.SineSquare.TwoP (1)_BD.png

 


@Meins321 wrote:

 

The wired while loop should run every 100ms (while) and take slow readings from the user (to save performance) and write it to an array, which was needed for the daq mx write for two channels.


AnalogOut.SineSquare.TwoP (1)_BD2.png

This loop will never stop, it will never output any data, and will never run the rest of the software that needs these values, turn on hightlight execution to see the data flow, the second while loop where you take data will never run.

 


@Meins321 wrote:

 

"And you are generating a 2D array of setpoints but you have no timing source so when should the hardware output the next value?"  <= i thought that it would write while it "has" time, not to interfere with the faster signal...


Nope, no timing source defined, I can't say what it will do.  You've probably seen but there is free training here, but more that that I think you need a sit down conversation with someone who can help and explain how things work, and understand what you really need.

 

0 Kudos
Message 8 of 10
(3,738 Views)

Hello, Thank you Hoovahh for your time and effort!

 

Well yes that while loop was out of my mind, i didn't ment to be offending in any way Cat Sad...

 

 

Well the first .vi that i append here does output the defined voltage, which i needed twice.

 

I have a few specific questions toward the programm below:

Signal Generator.jpg

1. Is it the right approach to bundle the signals together for the DAQmx write?

2.If i set both task to the same clocksource it gives me an error, but even using another source from my chassi/other modules which i could choose gives the same error

 

--->Does that mean, by the time you use the daqmx sample clock theres no way to create another analog output which is not contained insided the same task? (no more analog task creation for output possible?)

 

3.Is it okey to use the signal generator more than once as it might collide with the upper one?

 

4.For user input purposes i would like to write only slowly, do i disturb the other DAQmx Tasks by doing so?

 

 

As i now know having only one onboard clock is mental, the NI9264 is worth nothing if it can't output to more than one analog port at  a time 😞

0 Kudos
Message 9 of 10
(3,712 Views)

@Meins321 wrote:

 

 

As i now know having only one onboard clock is mental, the NI9264 is worth nothing if it can't output to more than one analog port at  a time 😞


You've stated this several times, and each time I've corrected you.  You can output more than one analog at a time.  With a single point output you can set them all you want.  The limiting factor here is Windows is not deterministic and the update right will be inconsistent.  Or you can set a set of outputs as an arbitrary waveform generator.

 

Open the Voltage - Continuous Output example in the example finder.  Here you can set as many analog outputs at the same time, (more or less because we still only have one DTA)  In the Waveform Settings you can define one output to be a sine wave, one to be a square wave, the next a Triangle, all at varying amplitudes.

 


@Meins321 wrote:

 

1. Is it the right approach to bundle the signals together for the DAQmx write?


That depends on what you actually want it to do.  I'm still confused because your original request seems to have changed.  Originally you asked for a "low frequency sine" on one output, and a square wave output up to 2Hz.  Now you write code that writes to 4 outputs.  It is hard to suggest approaches, or answer specific questions when the requirements change.  Clearly state, what you want.  What are your outputs?  What type of signal are they?  What is the range?  What is the acceptable resolution in steps for things like frequency?

 

I believe the right approach is to bundle the signals together for the DAQmx write but again that might depend on the signals types.

 


@Meins321 wrote:

 

2.If i set both task to the same clocksource it gives me an error, but even using another source from my chassi/other modules which i could choose gives the same error

 

--->Does that mean, by the time you use the daqmx sample clock theres no way to create another analog output which is not contained insided the same task? (no more analog task creation for output possible?) 

 


Right because you can't have two tasks running at the same time.  You have two channels in the top task, and two in the bottom.  You need one task.  Either put all signals in one task, or you can update channels with a single point write and not reserve the clock.

 


Meins321 wrote:

3.Is it okey to use the signal generator more than once as it might collide with the upper one? 


It's just a VI for generating a wave, so you can have many copies all over the place.  I believe these are reentrant so there is a chance that these will run in parallel on separate cores of your CPU.

 


Meins321 wrote:

4.For user input purposes i would like to write only slowly, do i disturb the other DAQmx Tasks by doing so?


It might be over kill but generally asking the user for an input means using the event structure, then there is no polling it reacts when the user interacts with a control.  In your situation it probably isn't that big of a deal to just read the control values in the loop, and then only regenerate the waveforms if the control values change.

0 Kudos
Message 10 of 10
(3,667 Views)