 Heckler511
		
			Heckler511
		
		
		
		
		
		
		
		
	
			02-11-2010 03:49 PM
Hello Labviewers,
I'm trying to figure out how to control my system... there are various elements I need to write control code for, but they all basically work the same way, which is, I can turn things on or off by toggling relay switches.
For example, I have a heat pump / chiller with water being pumped through it into tanks where the temperature sensor is. I can either turn the chiller 100% on, turn the heat pump 100% on, or turn everything off. If my current temperature is 15 and I want my temperature to be 10, LabVIEW would toggle the relay which turns on/off the chiller. As the temperature cools, LabVIEW would turn the chiller on less. Finally, the setpoint would be reached and LabVIEW would maintain this value by toggling the relays for both the heater and the chiller.
Most of the PID control examples I've found deal with producing a specified output (like in volts) to a specified setpoint input. This isn't exactly what I want to do. I need my output to toggle relays on and off for various times.
Does anyone have any idea where I should start and how my code should look if trying to use PID to toggle relays? I have the control and simulation toolkits but just don't have any clue on how to get starting using PID for this application.
Thanks!!
 DavidMaidman
		
			DavidMaidman
		
		
		
		
		
		
		
		
	
			02-12-2010 02:24 AM
Hi,
you need to look at Pulse Width Modulation (PWM). You can convert your PID output (as a %) to a PWM signal to vary the on off time of your relays; for example if your PID outputs 100% your PWM duty cycle would be 1 (permanently on), if the output of the PID was 50% your PWM duty cycle would be 0.5. This assumes you are operating between 0-100%. You also need to select a suitable frequency for the PWM signal
hope this helps
03-01-2010 05:06 PM
Hi David,
Thanks for the Reply. I'm still looking for a solution to my problem and thought maybe you'd be able to help some more. How do I convert PID output to PWM signal - is there a VI for this? Also, is there a PWM VI or set of VI's?
Where (how) do I set the frequency for the PWM signal?
Thanks a lot for the help so far.
-Mike
 mooseo
		
			mooseo
		
		
		
		
		
		
		
		
	
			03-01-2010 07:26 PM
Mike,
I'm sure that there are other, better ways to do this, but I've implemented a really crude version of what you describe that may be of some use.
What I did was take the output from a PID routine and converted it to a % of the next second that it should turn the relay on. I had 24 possible levels (so pretty coarse proportional control, and kluge-ily set by the number of channels in my system).
The routine runs through, checks a channel, computes the proportional output for the next second and writes that to a row of a 2-D square array... if it's 50%, then it writes 8 elements T and 8 F. It then takes the column of that array (which represents 1 point in time for all channels) and writes that to the relays. THen it cycles to the next channel. About every second, it would cycle through all channels. Thus, a channel might get turned on at step one and then turned off at step 2 (representing 1/24 duty cyle) or turned on at step 1 and off at step 12 (12/24 duty cycle). I made it run fairly slowly to reduce the cycles on the mechanical relays.
It was slow, made the mechanical relays click like mad, and held temp really well.
I've attached the code which might show you something or might just be confusing. Unfortunately, I was using Measurement Computing boards when I wrote this, so you will get errors when you try to open it. If you ignore them all, the missing vi's are pretty self explanatory. Another thing this code is doing that may be confusing is using a multiplexer to read 8 thermometers... that's the DIG OUT and READ TEMP vis... this version only controlled 8 chambers using the parallel port for output.
Hope this helps for something. Anyone who knows of better ways to do this, chime in.
cheers,
mike
 troglodyte
		
			troglodyte
		
		
		
		
		
		
		
		
	
			03-01-2010 10:58 PM
This doesn't answer your question, and assuming you are using a chiller based on a compressor, may I suggest that switching it on/off frequently (as in PWM) will reduce the chiller's life.
Regards,
Trog.