Tag Archives: GCL+ programming tips

Common Pitfalls in GCL+ Programming (Part 2 – Using And, Or)

In a recent post, we introduced boolean logic and the AND, OR, and NOT operators.  Now we will show some common ways in which these can be accidentally misused in a GCL+ program, and how to correct these errors.

AND

As we saw previously, the AND operator compares two boolean (true or false) statements.  If and only if BOTH statements are true, the entire statement will be true.  This is very commonly used in GCL+ programs.  There are some important things to watch out for, however!

For example, this bit of programming looks just fine, but actually won’t work the way you would expect:

If AHU1_LOW_LIMIT And AHU1_SMOKE = Normal Then

      // Commands we want to execute would be here

End If

Here’s what’s happening.  When you use “And”, GCL+ will evaluate what’s on either side and compare the two things.  If they’re both true, the whole condition will be true.  When it sees AHU1_LOW_LIMIT all by itself, it evaluates it.  In this case, “Normal” is OFF and “Alarm” is ON. In GCL+, ON is the same as true and OFF is the same as false.  So the equivalent is:

If AHU1_LOW_LIMIT = On And AHU1_SMOKE = Normal Then

      // Commands we want to execute would be here

End If

This is the same as:

If AHU1_LOW_LIMIT = Alarm And AHU1_SMOKE = Normal Then

      // Commands we want to execute would be here

End If

As you can see, this is not the intended result.  Here is the correct way to do it:

If AHU1_LOW_LIMIT = Normal And AHU1_SMOKE = Normal Then

      // Commands we want to execute would be here

End If

OR

The same thing applies if you’re using “Or”.  The OR operator compares two boolean statements.  If either of the two statements is true, the overall statement is true.  This is the correct way to do it:

If AHU1_LOW_LIMIT = Alarm Or AHU1_SMOKE = Alarm Then

      // Commands we want to execute would be here

End If

Common Pitfalls in GCL+ Programming (Part 1 – Boolean Logic)

Setpoint Systems has been providing FREE training to our customers for over 25 years, and in that time we’ve learned as well… how to best serve our customers.  We’ve also learned to recognize some of the most common technical challenges our customers face.  I’d like to highlight a few GCL+ programming challenges and solutions.  This post will lay the foundation for future discussions.

We need to start with a brief introduction of boolean logic.  You can follow the embedded link to see the definition in more detail, but in a nutshell here’s what it is:

Boolean logic (boolean algebra), is all about statements being either true or false.  This is fundamental to how computers and programming work.  True can also be thought of as 1 and false as 0.  A question can be asked and the answer is either true or false.

Courtesy of Sue's Blog Spot: http://suesauer.blogspot.com/

Courtesy of Sue’s Blog Spot: http://suesauer.blogspot.com/

For example, we might want to know if the weather is nice outside.  We can’t ask a computer or DDC controller if the weather is “nice” though–it would have no idea what we mean.  We must ask specific questions with true or false answers, like “Is the outside temperature above 60°F ?”  But the way boolean logic works, we represent our question in the form of a statement that can be evaluated as true or false.  This would look like “Outside Air Temp > 60”.  So far so good, right?

But what if it gets too hot?  We need to add more criteria to our question.  Perhaps we’d like to ask “Is the outside temperature is between 60°F and 85°F ?”.  What would that look like if we wanted to ask a DDC controller?  We now have TWO criteria that both have to be true.  It has to be above 60°F AND below 85°F.  This introduces the boolean operator “And”.  When we use “And”, the statements on either side must both be true in order for the whole statement to be true.  If either statement is false, the whole thing is false.  Our statement would now look like “(Outside Air Temp > 60) AND (Outside Air Temp < 85)”  I’m using parentheses to emphasize the two statements that are being compared by AND.

Another commonly used boolean operator is OR.  If you want EITHER statement to be able to make the overall statement true, this is what you use.  For example, we might ask “Is the outside temperature is between 60°F and 85°F OR is the outside relative humidity below 75% RH ?”  This would be shown as “((Outside Air Temp > 60) AND (Outside Air Temp < 85)) OR (Outside Relative Humidity < 75)”.  Again, note the use of parentheses to indicate the order of operations.  This is especially important if you mix AND along with OR in the same statement.

Finally there’s NOT.  This one is fairly simple–it reverses true to false and false to true.  For example, if I wanted to know if it wasn’t raining outside, I could ask “Is it NOT raining?” which would be shown as “Not(Raining)” where “Raining” is a boolean true/false value that lets me know when it IS raining.  Making sense or NOT(making sense)…?

I hope this has been informative.  It lays the foundation for upcoming discussions of GCL+ programming tips.  Stay tuned for more!

Saving Energy with Psychrometric Calculations

Saving Energy with Psychrometric Calculations By: John Becker

Hands up, who’s heard of psychrometrics?  You may think you haven’t, but if you’ve ever listened to a weather forecast I guarantee you have… Psychrometrics are the way engineers (and weather forecasters) describe a mixture of air and water vapor.  The air all around us contains some water vapor, which makes certain calculations a little complicated.  So why do we need to calculate these things?  Read on to find out…

One of the ways a building automation system can save you energy is by using cool outside air at certain times of the year instead of mechanical cooling.  This is called economizing or free cooling.  There are two types of economizers, dry bulb and enthalpy (a.k.a. wet bulb).  This is where psychrometrics come into play.

A typical dry bulb economizer would bring in outside air below a certain dry bulb temperature.  But this doesn’t account for the total heat energy contained in the air.  By measuring only the dry bulb temperature, the heat energy resulting from the presence of water vapor is ignored.  This can make a significant difference.  For example, you might inadvertently bring in cool but very humid outside air, causing your building to feel muggy and uncomfortable.  Or you could miss out on using some very dry outside air that’s a little warmer but could help remove heat and moisture from your building.

Psychrometric Chart

This psychrometric chart illustrates the benefit of using an enthalpy economizer.

If you look at the chart on the left, you can see the difference.  The area shaded blue represents conditions that a dry bulb economizer would consider adequate for cooling.  The area shaded green represents the ADDED conditions that an enthalpy economizer would consider adequate.  In this example it doubles the available conditions for economizing.  This can result in higher energy savings than with a dry bulb economizer.

Implementing an enthalpy economizer requires measurement of outdoor relative humidity in addition to temperature.  The GCL+ program below illustrates how to calculate Enthalpy, Dew Point, and Wet Bulb Temperature given Dry Bulb Temperature and Relative Humidity (all temperatures in °F).

This GCL+ program calculates various psychrometric properties of air.

This GCL+ program calculates various psychrometric properties of air.

Here is a version of the program you can see better and copy into one of your own Delta controllers:

// Calculates psychrometric properties based on Dry Bulb Temp (deg. F) and Relative Humidity.

Variable A As Real
Variable B As Real
Variable P As Real

A = (‘Outside Temp‘ – ‘Dewpoint‘) / 10
B = (A1)
P = 12.2 // Atmospheric pressure in psi (Denver)

Enthalpy‘ = Enthalpy (‘Outside RH‘, ‘Outside Temp‘, °F)
Dewpoint‘ = DewPoint (‘Outside RH‘, ‘Outside Temp‘, °F)

// Equation from Naval Weather Service Technical Note #7
If ‘Outside Temp‘ >= 0 Then
Wet Bulb‘ = ‘Outside Temp‘ – (0.034 * A0.00072 * A * B) * (‘Outside Temp‘ + ‘Dewpoint‘ – 4 * P + 108)
Else
Wet Bulb‘ = ‘Outside Temp‘ – (0.034 * A0.006 * 2) * (0.6 * (‘Outside Temp‘ – ‘Dewpoint‘) – 4 * P + 108)
End If

This is just one example of what you can learn by attending our free Delta Controls training classes.  We’ll be adding new session soon, so stay tuned!