Energy Management System

New2PLCs

Guest
N
Hi, I'm a computer geek that got thrown a PLC programming problem. Ladder logic is confusing me a bit and although if I work through it slowly I can understand what's going on, I often end up going in circles with problems in my programs.

The problem is to design a program (for a MicroLogix 1500) to cycle a number of outputs (compressors) according to inputs from thermostats, restricted by a maximum load limit and certain priority overrides (input on = that compressor runs until the thermostat is satisfied, no matter what.)

After working with it a while, I think the problem is a lot more challenging that it first seems. If you let "more important" compressors shut off less important ones, then you have the problem that the less important ones might never run. If you give every compressor an equal shot at running, then both ways you do it yield potential problems: 1.) You can give each compressor a chance to run, but don't let the first run again until every compressor has had a chance to run. In this scenario, you have the potential for a small compressor at the end of the cycle to be running by itself (inefficient because, if the thermostats are calling for cooling, you obviously want as many on at the same time as possible within the max load restrictions) for some time before the cycle starts over. 2.) You can let the cycle "loop" around and start picking up more units so as to avoid the potential problem in #1, but then you run into potential of some smaller units coming on, filling up your available "load space", and keeping the larger units from running, potentially indefinitely.

This problem is a pain. Any comments or advice on designing it "nicely" would be greatly appreciated. Less specifically, I would love for some guru to explain how PLCs differ from the microprocessors I'm used to dealing with. It seems like I could program this thing a lot easier in an assembly-like language (and I've been told that you have this ability with some Siemens processors.)

Thanks,

Don
 
First of all, a PLC is a micro controller with specialized operating system and Input/Output I/O capability. (Terry, where are you?) I still think the easiest way to understand ladder logic is to go back to the roots - it is essentially a "relay replacer" where the Boolean logic is written in a form that emulates physical relays and their contacts. If you have circuit continuity on the left side because contacts are closed (true, or conducting) then the items to the right will operate. Just as closing a switch to a relay coil will cause the contacts to change state. Any devices wired to the normally open contact of that relay will then receive power and operate.

Ladder logic is just a series of "if, then" statements. The normally open contacts "| |" say "If this state is true", and the devices to the right say "Then this will operate". Contacts in series are "And if" statements and contacts in parallel are "Or if" statements. Normally closed contacts "|/|" are "If NOT" statements.

Try reading Phil's tutorial again, with this in mind. (Then buy his book for reference - we have to keep this site going!)

As far as your main problem goes, consider dividing your compressors into "classes" based on size, importance of service, etc. Use your logic to call on an appropriate class of compressor to start or stop. Then have separate logic groups for each class to call for individual compressors in that class to run. You can make this decision based on number of accumulated run hours, first on first off alternation, or any other appropriate scheme.

The first step is to write out the list of compressors, the classes, and the rules for stopping and starting in English. Then you can easily convert these rules to ladder logic.
 
Last edited:
To continue what Tom was saying....

You program PLC (or anything else, for that matter), based on algorithms, or rules. You need to come up with a definate and complete set of rules for starting and stopping the compressors.
You use the word "important". What makes a compressor "important"? It's size? It's run time? It's location relactive to the thermostat that's calling for it?

You talk about "load space", and how too many small units can fill it up, preventing a big unit from running. Aren't multiple small units equivalent to one big one? Why or why not?

There's an expression around here that may help:

"Be the PLC"

Imagine yourself trapped inside a black box. The only thing you know about the outside world comes from the sensors wired to the PLC (in your case, the thermostats). You only can influence the outside world by the devices wired to the PLC (the compressors).

If a thermostat reports that it is 1ºC above the number that it should be (which ou have written on the wall), what do you do? Start all the compressors? Start the smallest? The one with the least run time (you've got a large collection of stopwatches in the box)? Which one?

Once it's started, when do you shut it off? When the thermostat is in the OK range again? When it's 2 ºC above?

I think you know what the correct strategy should be - you're just having trouble expressing it. Forget about how you are going to code it for now, and just write up what the sequence is.

Perhaps when 2 small compressors are running and you still need cooling, that's the time you bring on one of the big ones. Or maybe the rule for the big ones is that two zones have to be out of range. Whatever. Only you can decide.

If you post your rules, I'll try to find any holes in them.
 
While I'm new to ladder logic and don't have much experience working with systems like this, I understand (from writing PC applications) the necessity of outlining the criteria and rules of the problem in extensive detail. If I could do that, then I could most likely come up with the ladder logic to do it. However, the problems I'm running across are in the design itself. I was hoping someone in the forum might have had experience with a similar system and might be able to steer me in the right direction setting it up. I will try to make the system clearer.

There are N (in this case N is actually 11) compressors controlled by N thermostats. These units cool separate zones (not entirely true--six compressors are actually in three two-stage units--but if I can get the basic problem down I think I can handle this difference.) These zones are ranked in order of importance. However, you can't really give the "more important" compressors free reign to shut down the less important ones, or on a hot day it might happen that the less important zones never get any cooling. Assume each compressor must run for no less than a set minimum time and no longer than a set maximum time (if other units want to run). Now the problem becomes (I think) creating a cycle in which each compressor has a chance to run if the associated thermostat is calling for cooling. The only inputs the PLC sees are the ones from the thermostat that indicate that the associated zone wants cooling. Now, by "load space" I mean that I know what current each of these compressors will draw and when the system is running, I don't want to exceed say 50 percent of that maximum load (all compressors running.) For example, if the max current of all the compressors totalled is 150 amps, I don't want to exceed 75 amps at any particular time. So, yes, a few small compressors is the same as a big one in that respect.

To make things more challenging, when the bosses have their conference room meetings or when customers are there for training, I have 2 zones (relatively small compressors) that need to come on and run until cool.

Hopefully, with this added detail the potential problems (1 and 2) that I was talking about in the orginal post will be clearer. If not, I'll be happy to try to explain better. The issue (I think) is that the problem itself makes either 1 or 2 inevitable, and I'm looking for a "patch" to the design.

My initial thoughts on design were as follows. Store a MAX_LOAD value. When any given compressor wants to run (input from thermostat on), first check to see if turning it on would exceed this value. If not, it's allowed to come on and run for a predetermined minimum time, before it needs to time out and let other units have the chance to come on. (Designing it this way I think will make it easy enough to handle the cases in which the 2 priority zones can override--I'll just turn those two compressors on and adjust my MAX_LOAD value accordingly.) Now, if I'm running through this cycle continuously, I need some way to check (and fix the situation) if some big compressor is consistently getting skipped because smaller compressors are filling up that load space.

The problem seems fairly complex and took me some time to see why each of the potential pitfalls would happen. Your help is very much appreciated. Thank you,

-Don
 
Do you have a way of reading the temp in the 11 zones on the plc?
If you can read the temps let the one that has the most deviation from set-point take priority. That way all compressors have an equal chance. Also the hottest area will be cooled. Just be sure to allow the zone(s) with the high temp. come down to set-point before releasing thier ability to run.

Drewcrew6
 
It looks like you've almost got it.

One improvement I'd make: Rather than just having the compressor shut down after a time, "to give someone else a turn", have each compressor set a flag if they need a turn but can't get one due to MAX_LOAD. Keep a timer for each compressor to see how long they've been running "this turn". If their "time is up", they go off, the one with the flag goes on. And since they need to run, but can't due to MAX_LOAD, they'd set the flag, and when the next one times out, they'll get their turn.

Also, you might want to set up a FIFO with the load of each system that is "waiting in the wings". And it wouldn't be until there was enough Load timed-out that the old ones dropped out, the new one comes on, and the old ones go to the bottom of the FIFO.

The two priority zones would be exempt from "timing out", and may even have the ability to advance the "Next to turn off" timer.

This way, as zones cool down, and don't set that flag and enter the FIFO, they'll make room for units that need the Load Space.

You say that you understand the need to spec out the design before coding, but you also say that you could code it, if only it was in Assembly. I think you contradict yourself.
 
I think I understand the issues you have. You have 11 compressors, 6 of which are 2 stage ie dual compressor units. You didnt mention (or I didnt see) how many zones but that may not be an issue. Due to Energy restrictions placed on the system you dont want to exceed a certain power consumption rate...ie only so many compressors may be on at one time.

BTW Tom I wonder where Terry is too, this is fodder for him.

I am going to offer what I think is a way to do what is needed. Each compressor must have its own output (this I think you know). To get started with this project dont worry about rotating the compressors, use a lead/lag or follower system...ie each motor is used according to priorities. You can adjust it to rotate them later when you understand more.

Where this gets tricky (to me ) is using thermostats that only offer on/off ..ie need cooling or dont cool. To be more efficient you should use analog inputs...ie temp sensors so you can create a deadband..ie a range of values(temperatures) that will allow the 2 stage compressors to drop one motor or a small compressor to drop out if a higher zone has more need. This will also give you a more accurate way to cycle on demand...if zone 1 is not within preset range then zone 2 is cut back or zone 6 that part is up to you. The conference room you could use a motion detector(or something to show its active) to set a priority that moves it from last to first if thats what is needed. Another way to do this without using analog is add more thermostats to each zone, matched values of course...then cycle according to how many are calling.

Working with cooling systems there are always hot and cold spots, the more sensors/thermostats the more accurate you can mantain an average.

To put this in perspective lets say zone 1 uses compressor 1 (a dual stage unit), designated comp 1 and comp 2. Use 2 thermostats (if possible ( in the hot and cold zones if this can be determined). If both are calling for cooling then use both compressors. Lets say zone 6 (the lowest zone) and you have the motion detector (or something to say that zone is not used) then it can run both compressors. I am sure you understand using AND functions so can see how this is done. Lets say the conference room is being used now (zone 6 as stated above) and it has a demand, zone 1 ( what zone(s) I leave to you) loses a motor. The thing here is imagination (which you probably have more than I do), you arent limited on which zone drops off first, dont worry about cycling for specified times at first. The idea is use the demand factor and zone priority to maintain within a certain range. You can add timer functions later to cycle between zones if below the minimum range.

I think I have rambled enough for now. Here is the deal, write code to make the system run ( at any efficiency point you can that is less than max) then fine tune it to reach your goals. Even the best programmers normally have to see what the system does in action to see what is needed to match conditions.
 
Just a few thoughts. Do you have feed back telling you a compressor is on when you call it? If it fails, there must be rules to deal with it. Having one compressor out of the loop changes the calling rules. Do the compressors have Hand-Off-Auto switches? Do you have feedback telling you what state the switches are in?
 
Hi Guys... (I've been through a week in Hell and the show ain't over yet!)

With respect to the Energy Management System...

This is NOT a PLC problem.

While I'm very fond of saying "BE the Computer" in order to help a lot of guys come to grips with a programming problem, this is not a case where you need to do so.

In this case, you need to "BE THE FACILITIES GUY".

So... you are an under-paid Facilities Guy, fearful for your job, and you have this problem...

More Demand than Capacity! (Why does this sound like such a familiar problem???)

If this was a fair world and, if you said your prayers every night, then maybe, just maybe, there would be plenty of capacity to satisfy the demands. You might be able to slip off for a cup of coffee or fix that broken window you've been thinking of.

Well, life ain't fair, working for a living sucks, and you hate your A-hole of a boss!
So?... Tell me something new!

Let's say the situation is as bad as it can be...

You DO NOT have a computer to help you.
You DO NOT have thermostats to control the compressors.

HOW WOULD YOU DO IT?

As the Facilities Guy, you would have to go to each room, now and then, and check the temperature. If you're lucky, you'd find at least some of the rooms too cold. Then you would go shut down the compressors for those rooms. You might have found that some other rooms were hot and needed some cooling. Because the other rooms were cold enough, you'd be able to use some of the available energy to cool them down.

But, as sure as the sky is blue (now and then, that is - I'm in Oregon, we don't get blue skies too often!), that damned Murphy Guy is messin' with your peace of mind!

So, as you go from room to room you find that some rooms are hot and some are not.

As the Facilities Guy, you have some questions to ask yourself...

Is anybody using any of those rooms? (or, will anyone be using any of those rooms soon?)
If so, are those rooms hot? Are they cool?

WORST CASE SCENARIO:
ALL ROOMS ARE BEING USED!
YOU'RE IN THE LOW PLAINS OF NEW MEXICO IN AUGUST!
And there is a President or Vice-President of your company in each room!!!

POP-QUIZ A-HOLE! What the hell are ya gonna do?????????
You have that big mortgage, a new car and maybe a boat to pay for, so ya gotta keep your job!
So what are ya gonna do? Hmmmm?

In a reasonable situation, subject to the aforementioned constraints, you can only provide a fair share of the available cooling energy on an as needed basis.

So, you make decisions based on need! As you walk from room to room you can tell which room really needs cooling (open collars and sweating brows are pretty good indicators) and which can wait a bit.

But then, you see that some of your friends are in one particular room and you would like to appease their pleas for greater than sub-tropic temperatures....

At the same time, you see that one of the rooms contains a VP that has a particular disdain for you...

All of these things become value-judgements. So how, in your mind, are you able to make decisions about which room to cool and which to let over-heat a bit? All the while, maintaining your capacity constraints!

For us Facilities Guy's it's just a judgement game... how do we get a PLC to play the same game?

FUZZY LOGIC !

The primary requirement in this particular situation is to know how badly any room needs cooling RELATIVE to how badly any other room needs cooling. This absolute need value can only be determined if you know the difference between the demanded temperature value and the current temperature value AND the relative value of the current temperatures in the other rooms.

This can be determined only by means of an analog signal indicating the actual temperature and the difference between actual temp and demanded temp.

Using FUZZY LOGIC RULES, you can then determine which rooms to apply cooling to while still staying within the constraints of the capacity of the system!

You can find a tutorial on FUZZY LOGIC here...

http://www.seattlerobotics.org/encoder/mar98/fuz/flindex.html

The "A"-answer requires that you have the analog signals. If you insist on doing it without the analog signals, I'll have to do a little more thinking, but it won't be nearly as good!
 
Last edited:
Allen:

"Rather than just having the compressor shut down after a time, "to give someone else a turn", have each compressor set a flag if they need a turn but can't get one due to MAX_LOAD."

Yes, this is what I had planned. No matter which scenario you use for this program, there is always a seemingly tough-to-handle potential problem that crops up as a result of the nature of the problem itself. The problem with the way (I think) you are suggesting handling the thing is that there is the potential for the compressors, in a worst-case scenario, to "queue up." You can get into the situation where more and more units have the "I need to run next round" flag, and eventually they are all waiting on enough load space to free up so that each can run, in which they'll run in FIFO order if I use that to keep track. Is this bad? Will worst-case scenario ever happen? I don't know, probably not (I think the units are sized well enough to cool the zones in a reasonable amount of time.) But now this problem has been bugging me for a couple weeks, and I would really like to understand the best way to handle it.

And the only reason I said it seemed like it might be easier to do in an assembly-like language, is that this "forced-loop" style of ladder logic is new to me. Now that I've played around with subroutines a bit, I'm having a little better luck with bending the PLC to my will (still doesn't seem "natural" but I'll live.) Now, it could very possibly be that I'm "missing something" important that would make me feel more comfortable with this style of programming--keep in mind, I've only been messing with this PLC stuff for two weeks, and my "tutor" has been the AB MicroLogix 1500 manual.

Thanks,

-Don
 
Terry:

YES! You know exactly what the problem entails! In worst-case scenario it's a no-win-so-try-to-make-everybody-as-happy-as-possible type of problem. I've only come across game theory in mathematics, but I'm guessing this fuzzy logic stems from that. I've never seen it work in a real world application and if possible, would love to utilize it here.

We don't have temperature sensors, but I understand how they would help. There's a chance the people I'm doing this for will be receptive to the idea of adding them, so I'll definitely mention it. I'm wondering if there's any good way to do it without, though. What problems do you see with setting a timer to keep track of how long a particular zone's request for cooling goes unanswered, and using that as a measure of "relative need." I can see that it could well be invalid to assume a proportional relationship there, but maybe there's a way to "smooth it out"??

Again, I have only the vaguest notion of how fuzzy logic works, and as soon as I post this am headed off to check out that link. But here are some initial thoughts I've had. If I have a min timer and a max timer to determine the minimum and maximum lengths of time a compressor can run for without being forced off, it seems to give me the most flexibility in terms of being able to "tweak" the system. I'm thinking that I could bump up the max time for units that consistently get forced off while still calling for cooling. Now that I'm thinking about it again, I forget why I concluded I needed a minimum timer at all, because obviously if the thermostat isn't calling for cooling, you're not going to run the compressor. In my craze to do this "the right way" I've also thought about (somehow) keeping track of how the system performs over time, and adjusting MAX_LOAD if necessary, but that's easy enough to do manually.

Also, the people who explained the problem to me didn't forsee the trouble it would pose (ha. they're on the brink of just having me split the units into 2 groups, and giving each a 15 minute turn--probably not a bad alternative when given the programming challenge of handling the problem properly.) But in the original spec, they did give me a list of which zones (compressors) had priority over the others, it's just that when you say every compressor has to have a turn, you throw that priority out the window at least partially.

Now I'm off to read about fuzzy logic. Thanks so much for your help! I look forward to hearing any other comments or suggestions.

-Don
 
This requires optimal control techniques not a PLC.

Terry, fuzzy logic is not the answer here. I agree this is not a PLC problem.

New2PLC, you need to change your name to New2Matlab or New2AdvancedCollegeDegree.

This is a optimization/minimization problem. A formula is required that calculates the undesirablity of the temperature errors and energy usage and then take the derivitive of that to find the minimum. This calculation is not the sort of thing you want to do in a Micrologix.
This problem also requires very advanced techniques called optimal control.

Here is an example

U = Undesireable Index. Minimize this value for optimal results.
W(n) = Weight for temperature errors for zone or compressor n. Some zones may be more important than others.
K = Weight for engergy usage. This would be the same for all zones.
Energy(delta temp) is a function that computes the power required to obtain a temperature

E(n) = Temperature Error for zone or compressor n. This error may be such as
If Temp(n) > HiSetPoint(n) then E(n) = Temp(n) - HighSetPoint(n)
else
If Temp(n) < LoSetPoint(n) then E(n) = LowSetPoint(n) - Temp(n)
else
E(n) = 0

U = Sum of ( W(n) * E(n) + K*Energy(AmbientTemp-Temp(n)) )

Now just minimize U. If it were only that easy.

New2PLC, you need to determine exactly what this formula is. Then you need to determine how to minimize U. Now, are you sure you want to do this in a MicroLogix?

When you understand how to do this you will quality for at least a MS degree, and you will be able to slice pickles with the best. This problem makes calculating a low pass filter coefficent look trivial.

See optimal control. You will need to know how to read Greek to get through all the symbols. Just joking. There are a lot of Greek symbols and one first looks a this stuff it may as well be Greek.

See Matlab.

OT, I don't like the way this new forum doesn't make it clear to whom I am responding unless I specifically mention a name.
 
Peter,

While your "optimization/minimization" method will certainly provide good instantaneous answers, it certainly is, as you indicate, a head-bender.

Sometimes it's damned hard (if not near impossible) to describe a problem in such a way that Differential Calculus can be applied to produce a solution.

Just as Algebraic approximations are often used instead of real-time-calculus solutions, so too Fuzzy Logic can be used in place of your "optimization/minimization" solution.

Rock-Paper-Scissors ?

All too often, programmers get locked up in the circle-logic situation associated with the Rock-Paper-Scissors game. It is hard to come to a stable condition (equilibrium) in that game because of the absolute relationship between each pair of members. That is, Rock always loses to Paper, Paper always loses to Scissors and Scissors always loses to Rock.

The logic behind which loses to which is based on the assumed physical attributes of each. A scissors will cut paper, but it will break if it tries to cut a rock. A paper will cover a rock, but it will be cut by a scissors. A rock will break a scissors but it will be covered by a paper.

If all three elements are played at the same time, the situation will never stabilize. Now, what happens if you can dictate the relative value of each attribute?

For instance,
the paper can range from sheer/light to opaque/heavy
the rock can range from hardened steel to soft gold leaf
the scissors can range from a kids' safety scissors to industrial pickle slicer.

With the right combination of "weights", each pair can be brought to a condition where neither wins. All three can be brought to a condition where none win - equilibrium.

Once equilibrium is established, the actual result can be varied by adjusting the relative strength of a particular attribute.

Applying Fuzzy Logic allows you to find equilibrium and then allows you to control the result according to the relative importance of any and all conditions.

All of this can be done in any PLC that has REAL NUMBER capabilities. You do not need a Fuzzy Logic Module!

Don,

I'm still considering how to accomplish reasonable control without knowing actual temperature.
 
Peter,

Thanks for getting so detailed there. I am going to happily show your response to the people that looked at me like I was crazy and said "What do you mean it's not a simple problem?" :)

However, I do have only a MicroLogix to work with. And I think it will be challenging but possible to come up with a system like what Terry has mentioned.

Anyways, thanks.

-Don
 
I fear no matter what you do, based on the scenarios that have been posted, you are fighting a "No win situation". Not that I'm trying to sound defeatist. I have witnessed more than once company's that spend huge dollars for energy management systems to control peak demand. The downfall to those systems is there are bypass switches. After all the carefull consideration which zones may be shut down during peak demand, over time it becomes obvious that all the areas are needed & soon all the switches are in the bypass mode. The result is a huge loss of capitol resources & a very impressive looking panel that does nothing. Unfortunately for New, he will become the bypass switches & constantly trying to compensate for conditions that are beyond the limitations of PLC programming.
 

Similar Topics

I would like to build a system using my home as the pilot project. I have a thermostat that uses Modbus for communications with 8 analog inputs...
Replies
3
Views
1,735
I am working on a job where the specification calls for a "factory energy management system" to control the Heating, Ventilaion, Air Conditioning...
Replies
26
Views
5,127
Hi, i cant establish communication between fatek plc with an energy meter, both capable for modbus tcp, i did with modscan but fatek plc does not...
Replies
1
Views
119
I want to calculate the energy consumed from instantaneous power. Can this be done using the TOT block with timebase set to Hour?
Replies
2
Views
655
Hi All, We are planning Establish communication between Power Energy Meter (Schneider PM5320) with Rockwell PLC. I am unable to get the Assembly...
Replies
4
Views
700
Back
Top Bottom