From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Level Control with PID Control & Pulse-Width Modulation

Hi all,

 

      I have attached my program which I'm having trouble wiring up in the block diagram.... I'm fairly new to labview, but basically I have a level control project with an analog input cistern arm turning a pot for my test tank (configured as DAQ assistant voltage analog i/p) and a pump working off a reservoir (configured as DAQ assistant voltage digital o/p). My electrical side of things is working correctly and I have tested both DAQ assistants I/O's successfully off a basic program, minus the PID & PWM... I found a simple PID control subvi which I think I have wired up correctly, apart from the output variable... I also found a bit of code for PWM using the square waveform vi (far right side of the program) which I have tried to include in the program, but I've been unsuccessful with that. The ideal operation i'm looking for with this project is to be able to enter different values for the setpoint, for the PID to kick in to find that setpoint each time using the PWM to drive the pump, which has a flow rate of 13L/min. I have a manual valve to release water from my test tank which I can set accordingly.

 

My questions are;

- How do I connect the 'output variable' of the PID subvi to my DAQ assistant digital output(both DAQ assistants are set at 1 sample on demand)?

I have a 'number to boolean array' function, but this gives an error saying that the number of tasks generated are not the same...

 

- How do I wire up the PWM bit of code? Do I need to include the 'error in & out' tabs?

 

-Am I on the right track with this program or am I way off the mark?!

 

Any feedback on this would be greatly appreciated. Thanks for your time,

 

Richie

 

 

 

 

0 Kudos
Message 1 of 4
(5,021 Views)

Hello Rich, I have had a look into your code and I think I may be able to help you out. Could you attach the subVI that you have used as well though? It would be helpful to see exactly what is going on in there.

0 Kudos
Message 2 of 4
(4,933 Views)

Hello,

I had a similar project with thee items I needed to control the temperature of (cooling) using solenoid valves.  I have attached the portion of code I used.

Steve

0 Kudos
Message 3 of 4
(4,926 Views)

 


Rich-MechatronicsStudent wrote:My questions are;

- How do I connect the 'output variable' of the PID subvi to my DAQ assistant digital output(both DAQ assistants are set at 1 sample on demand)?

I have a 'number to boolean array' function, but this gives an error saying that the number of tasks generated are not the same...

 

- How do I wire up the PWM bit of code? Do I need to include the 'error in & out' tabs?

 

-Am I on the right track with this program or am I way off the mark?!

 


You're a bit off track.  You need the output of the PID to go into the PWM generator, and the output of the PWM to be written to the digital output.  Right now you have the output of the PID connected directly to the Digital Output in a way that won't work, and the PWM generator hanging off the side not really connected to anything.  Also, the PWM generator isn't really going to work since you're generating it at the same frequency as your PID loop runs.  Try a simpler algorithm such as on/off control first and see if that works for your system.

 

0 Kudos
Message 4 of 4
(4,914 Views)