LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

making the Dc voltage active in the code

Hi all, 

 

I have aquastion about making the Dc voltage active in the code, that means i can change the dc voltage while the code is running. I have traied many times to solve the problem.

I have attached the Vi file.

 

Khalid

0 Kudos
Message 1 of 17
(3,198 Views)

Khalid,

 

I do not see any changeable DC voltage in your VI. What do you want to change?

 

In general anything you want to change while the program is running must be inside the loop.

 

Lynn

0 Kudos
Message 2 of 17
(3,179 Views)

Hi Lynn, 

 

Thank you very much for your reply. Actually, I am i am sweeping the frequency from 100 to 500 Hz to find the resonant frequency where acquiring and generating the signal continuously. However, I need to make the Dc voltage that I indicated on the attached image, active to control the resonant frequency . I have tried to locate the '' generating signal '' on the whil loop but does not work.

Could you please help me at this point.

 

Best reagards, 

Khalid

0 Kudos
Message 3 of 17
(3,144 Views)

Instead of using the function generater VI to generate a 0Hz 0 amplitude signal with a 9 volt offset. Have you tried replacing this part with a numeric control or constant?

S1.PNG

 

 

S2.PNG

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 17
(3,111 Views)

Hi Rtslvu, 

 

I have tried to offset the the sweeping frequency by using a numeric control but it does not work. However, I need to change the Dc voltage while the code is running with synchronize the input voltage with output. I have tried to place the dc voltage in while loop but does not work.

 

 

Khalid

0 Kudos
Message 5 of 17
(3,096 Views)

Khalid,

 

The freqeuncy inputs of the Chirp Pattern.vi are in units of cycles/sample. (Read the Detailed Help.) The values wired to the VI with your default settings are f1' = 100 cycles/sample and f2' = 1000 cycles/sample.  This results in severe aliasing and is probably not the kind of signal you expected.

 

chirp.png

 

In any case the Nyquist criterion would prevent you from creating a waveform with frequencies in the MHz region while sampling at 10 kHz.

 

Setting that error aside, other questions still occur. It appears that you want the chirp to last 1 second (10000 samples at 10 kHz). Do you want to change the DC component during one chirp or only between chirps?  It is easier to run a complete chirp for each value of DC but if you need variable DC, it can be done.  And as RTSLVU has pointed out your Function Generator plus AC DC Estimator is exactly equivalent to a simple control.

 

Everything which needs to change must be inside the loop. So the DC offset and the sum function and the DAQmx Write all have to be insde the loop. You may want to use an event structure or a change detector and case structure so the valeus are only written when a change occurs.

 

Because of the Nyquist errors and structural problems with your VI, please describe what you are trying to accomplish overall. Frequency ranges, sweep speeds, expected Q of the resonance, rate of change of the DC, and other relevant factors. Then someone can probably give you suggestions for a process which will work.

 

Lynn

0 Kudos
Message 6 of 17
(3,079 Views)

Hi Lynn,

 

You are right about aliasing issue.


In regards of your question.I need to make Ac and sweeping frequency constant while running the code. The only one thing that needs to be changed is Dc voltage. Actually, I am working on Mems and I intend to add control system to this code. The parameter that needs to be controlled to modulate the stiffness for my design is the Dc voltage. I add the ac voltage to vibrate the system from 100 to 500 hz. for this reason, I need to make the Dc voltage active.

 

Khalid

 

0 Kudos
Message 7 of 17
(3,067 Views)

Khalid,

 

I think I understand now. I am busy with something else now but will have some suggestions later.

 

Lynn

0 Kudos
Message 8 of 17
(3,063 Views)

no worries

0 Kudos
Message 9 of 17
(3,049 Views)

Khalid,

 

Here is a quick modification of your VI that may help you get started. I do not have DAQmx or any hardware so this has not been tested and may have errrors.

 

Changes:

1. Created DC Offset control on front panel. Terminal is inside while lop and event structure.

2. Added event structure so the program responds to changes in value.

3. Moved offset sum and DAQ Write inside loop. Note: I am not sure you need to rewrite. Does your device support regeneration?

4. Moved Stop into event structure.

5. Since you have the DAQ Write set to continuous samples, is the taks ever done? You are not using the task done? output so it may not matter.

6. Added error indicator on Chirp Pattern.vi.

7. Changed defaults on f1 and f2.

 

Lynn

0 Kudos
Message 10 of 17
(3,021 Views)