LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID Control of two out of phase sine waves

    Hello

Ive been struggling with this problem for a while. If someone could help me I would greatly appreciate it. The code is attached

Application: I need to drive two different loads with the same current that is out of phase with each other. Im working in AC regime and the loads will change impedance with frequency. So i need to set a constant current setpoint and based on the output the PID controller should try and change the amplitude of the AC signal

Problems: Im using the DAQ acquisition tools and have set it to read one sample from the output. But to generate the sine wave I use the signal generator function with a default sampling rate and 1000 samples. How do I get the device to read all 1000 samples find the peak and feed that information to the PID control so that it can tweak it. If I set the DAQ read to acquire N samples, it takes a long time to display on the chart. I would ideally like to see the waveform displayed on the chart. If I set the signal generator to generate one sample at a sample frequency of 1Hz I keep getting the same value as expected.

Please help.
Thanks
S



0 Kudos
Message 1 of 3
(2,953 Views)
Hey Shah,
 
Thanks for posting on the NI forums.  I've been examining your VI for a while now and when I run it, it locks up my computer Smiley Happy.  Besides that, I think you may be able to get better operation if you move part of your program to another parallel loop (the function generation).  I'm not sure what would cause your chart to be slow to update unless you are writing an array to it at the end of your loop execution, which doesn't appear to be the case.  Possibly moving the waveform chart into another loop with the function generators could potentially fix your problem.  I hope this helps you out.  Let me know how it works out for you!
 
Take Care,
 
Evan D.
Installer R&D
National Instruments
0 Kudos
Message 2 of 3
(2,926 Views)
Hi Evan

Thanks for the reply. I managed to fix this problem by using the DAQ assistants. I am aware that the DAQ assistants start and stop the tasks on every call and might slow the data acquisition. I was hoping to solve this problem using the previous code where the start and stop tasks are outside the loop.
For now this seems to work and meets my requirements but Im still curious how it could be fixed with the previous arrangement.
Please let me know if this isnt clear.
Thanks for your help
Shahriar
0 Kudos
Message 3 of 3
(2,902 Views)