LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to structure a loop with constant output of a analog-signal generated from a table?

Hello,

 

I am new to LabVIEW-programming and trying to make a project with the myDAQ. I would be happy to get help from the community here for the following issue:

 

I have a simple *.txt-file where is one row with voltage-values. In fact this are values from a audio-file with the following properties:

Number of entrys: 3306

Recorded at sample-rate: 44,1 kHz

(So the calculated time duration of the audio-file is (1/44100)*3306=74,966 ms)

 

Now I want to play this audio-file over an Analog-output where the sequence of 74,966 ms is running again and again without a pause between the loops. My Idea now was, to make a timed loop with exactly 74,966 ms and write with the DAQmx exactly these 3306 samples within this time-span to the analog output.  If I run it, I can see that the loop-time is longer (Around 140 ms) and if I listen to the audio, of course there are brakes between the loops....

 

I am sure my structure is inefficient because of reading the file, configuring the DAQmx task and probably my programm structure is not suitable for this problem.

Can someone tell me how I can make a proper structure for this problem? (Later, I want to read in different audio-files which have different length and modulate them with the "arbitrary waveform generator" in frequency and amplitude. 

But first I would be happy to get this basics done...


Thank you very much!

Download All
0 Kudos
Message 1 of 6
(3,391 Views)

A few wrong things in your vi. Never configure/clear task over and over in a loop, Configure once before and clear after. A time loop is useless, the timing is performed by your sample clock.

 

For what you want to do set the generation mode to continuous, it will generate the buffered data over and over again until you press stop.

 

Ben64

 

cont analog output.png

0 Kudos
Message 2 of 6
(3,358 Views)

Hi ben64,

 

thank you very much for you answer! I just changed my VI according to your advice and it generates a constant output and repeats endless which is very good :-). Some further questions came to my mind: 

  1. As soon as the task is startet, I guess the values of the array are "uploaded" to the hardware and are running and running until you press stop the task? I am wondering why the loop now has a cycle time of 6 seconds?
  2. Now I want to implement a function, in which the Sound-File can be "streched or compressed" in the time-axis, which I thougt is possible with the "arbitrary-wave generator". But then the array will have no constant length any more. For example: In the first iteration, the length is 3000 values, in the second 3120, in the third 2900 and son on... And these iterations should be set one behind the other without break. So how can I implement this. As far as I can see, with your configuration its only possible to configure the array one time?arbitraryWave.JPG

Overview configured.jpg

0 Kudos
Message 3 of 6
(3,352 Views)

6 seconds is very odd, is it constant?

 

Ben64

0 Kudos
Message 4 of 6
(3,336 Views)

Hi ben64, I must correct myself, it only between 15-16 ms, I tried it again. I dont know why it was at the first try 6 seconds....

0 Kudos
Message 5 of 6
(3,332 Views)

Tooly a écrit :

Hi ben64, I must correct myself, it only between 15-16 ms, I tried it again. I dont know why it was at the first try 6 seconds....


This make more sense. I don't know about the 6 seconds, if you ran only 1 loop iteration and got this value it can be explained by the shift register initialized to 0 instead of being initialized with the tick count function (also the tick count roll back to 0 when it reaches 2^32-1). It is expected that the loop delay is different from the time it takes to generate 3306 samples, in the loop we are only polling the task status repetitively.

 

I'm not sure what is your goal with the second part of your questin, why don't you just concatenate the 3 pattern arrays?

 

Ben64

0 Kudos
Message 6 of 6
(3,289 Views)