LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Forcing Control

Dear all,

i would like your thoughts on the best way to acheive this objective and if there are any examples that would help.

I have speaker that operates from 0 to 4000 Hz, and at each frequency it produces a specefic amplitude when driven by a constant amplitude soundwave. Due to the nature of the speaker deflection amplitude is not constant over this frequency range for a given sinsosoidal voltage input voltage input. i.e. if a drive the speaker at 3V peak to peak, the deflection will be different at 100Hz than at 2000 Hz for example, even though the input sin wave is the same.

I would like to implement a specefic labview program that would do the following. I set a target for the required deflection. Then the program automatically changes the forcing amplitude for each frequency to achieve a constant deflection, and then saves the voltage used to drive that specefic frequency to a file.

i.e  I set a target of 1mm displacement of the speaker diaghragm. The program start at five hertz, varies the input waveform to produce the 1mm displacement which is measured by the displacement sensor. After it acheives this target, it goes to ten hertz adjusts the input amplitude to acheive 1mm displacement which is sensed by the displacement sesor, then saves the amplitude and so on so fourth.

Cheers,
Ala



0 Kudos
Message 1 of 11
(3,655 Views)
I did something very similar to this with the first LV program I developed in LV 1.2. We were trying to produce specific sound pressure levels at various frequencies and magnitudes on four channels. We made a calibration chart by making measurements at each frequency and for each speaker as you have described.

We had about twenty data points and the system was expected to be quite stable so we made diagram constants for the corrections.

Today I would probably save the calibration coefficients to a file, possibly using the configuration file utilities and format. Read the file when the program starts and pass the data to the speaker driver algorithm. Depending on the structure of your program, several different methods might be used. Direct wiring is almost always the best if practical. An Action Engine or functional global is good if the data may be used in subVIs or parallel nodes. Since the data will not change except at startup a global variable could be used. The risk of race conditions is minimal.

The data could be formatted as a 2D array with the frequencies in the first column and the displacement correction factor in the second column. Be cautious about searching an array of non-integer numerics. Binary representation issues can cause exact equality comparisons to fail in ways which are consistent and predictable, but often not intuitive.

Lynn
0 Kudos
Message 2 of 11
(3,636 Views)
What are you planning to use to measure the displacement? Do you want the LabVIEW program to control the frequency of the sine wave, and if so, what are you going to use to do that?

Linear displacement sensors are very reliable and fairly simple to use with any analog input device. The output should be easy too. After that, programming the logic to control your output and measure the input in a loop is simple enough. And like Lynn said, you can save that data to an array or whatever format you'd like.

Good luck!

B-)
0 Kudos
Message 3 of 11
(3,627 Views)
Hi Guys,

Thank you for the answers. I will be using a laser displacement meter. I am competent in labview view DAQ AI AO and all that, but not to sure about how to input the output into a loop as you mentioned. May you send me just a simple representation of the program? I have a 6229 DAQ  i will be using labview to generate the signal that is fed into the speake ( i.e to control frequency and amplitude) as well as using it for DAQ.


Cheers,
Ala



0 Kudos
Message 4 of 11
(3,621 Views)
There are lots of examples that come with LabVIEW that would help you a lot. Check out the Feedback Node, Tank Simulation, Control Mixer Process, etc.

In general, what you want to do is:
* Measure the input from the laser
* Output the signal to the speaker
* Display the Displacement and Freq/Amplitude in a table, or an array or whatever.
* Just keep doing those in a while loop until you are done.

You can adjust the output manually until you get the desired displacement, or, if you want to get fancy, you would use a comparison of the measured displacement with a desired setpoint (which you can enter with a numeric control) and adjust the output of the speaker if the displacement is too great or too small.

I can probably come up with a quick simulation, but you'll still want to investigate the examples that come with LabVIEW and your DAQ board, because they may already have what you need.

B-)
0 Kudos
Message 5 of 11
(3,615 Views)
HI,

Attached is a program I developed, that does almost what you mentioned. Basically I input the frequency range and drive amplitude and record the displacement. This will let me build up a matrix of freqeucny versus displacement, therefore I have all the drive amplitudes I need to obtain a specedic displacement. I will be scanning from 0 to 4000 Hz with 5 Hz increments for 10 amplitudes, thats about 8000 runs. While this is Ok, I would rather do it as you mentioned and write a specefic program that is 'fancy' and have the a) drive amplitude varied until it acheives a desired set point specefied by me, 2) saves the drive amplitude in an array and 3) moves on to  the next frequency and so on and so forth ( fully automated), this way I do not have to build the whole calibration maktrix, but rather only the drive amplitudes I need to acheive the required set point. I will check the examples you mentioned, and will try to come up with a solution. A quick simulation would be great, I will check out the examples today.

Cheers,
Ala


0 Kudos
Message 6 of 11
(3,592 Views)
Also, check out the examples of a State Machine. That might also give you some pointers. But basically, you will include in your main while loop the conditionals that determine if the measured value matches the desired range. You may want to use some averaging here over a certain period of time, so that it sees a constant displacement before going to the next frequency or amplitude or whatever. When the measured value meets the criteria, have the program save the data, then increment to the next frequency. You'll have a single case stucture that handles all of the automatic functions.

If I may offer some suggestions on your code, there are some things you can do to clean things up a bit. For one thing, you only need (and should only use) one Event Structure, since you can Add Event Case(s) to the same structure to handle different events. The Start Signal button, for example, should be inside its Event Case. You can also create an Event Case for your Stop button, and you may be able to migrate all the code in that while loop into the one loop. The Timeout event is good for handling things that need to occur repeatedly and at regular intervals, such as the automatic measuring and changing of frequencies. This way, when you're in "automatic" mode, the program will still respond to other events, and you can stop the run at any time.

I don't have the DAQmx drivers, so I can't test your program, but some of the examples may get you further along. You have a lot of work to do, but I think you're on the right track.

Good luck, and let us know how things go!

0 Kudos
Message 7 of 11
(3,587 Views)

Hello All,

Attached is my solution, it might not be elegant but it works!!!!.

 

Thank you labviewguru for you tips,

 

Cheers,

Ala

0 Kudos
Message 8 of 11
(3,549 Views)
Actually there is one thing that does not work, I know what the problem is. Whats happening is that the while loop inside the for loop checks the condition before running through the sequence. What this does, is that if my signal input is in range, it will wait for the next forcing iteration to stop the while loop. And if it was in range then goes out of range, it will still go to the next frequency becasause the while loop checks the condition at the beginning. How can I force the while loop to only check the condition at the end?
 
 
0 Kudos
Message 9 of 11
(3,542 Views)

Fixed the Problem,

 

Attahced,

 

Ala

0 Kudos
Message 10 of 11
(3,539 Views)