Newby question about coding and efficiency
Archiver
Posts: 46,084
Am undertaking a project where I will monitor three temperatures, and
perform actions based upon the temperatures returned. Every night I
read the Parallax Industrial Control text, towards a end result of PID
temperature control of two chambers. Don't know if I will turn off the
group, but I am a craft beer brewer, and need to control the temperature
of my fermenting chamber (anywhere from 32 degrees to 65 degrees +/- 1
degree - depending upon which beer I am fermenting) and a serving
chamber (approx. 45 degrees +/- 1 degree). The ambient temperature is
the determining factor as to whether I use an air conditioner or the
outside environment to cool, and if below freezing, to use a heater. I
plan on utilizing on/off control for the air conditioner, PID for muffin
fans, PID for ceramic heaters. I know, they make refrigerators, but I
must build my own, darn the cost!!!
Each temperature will be compared to a constant (i.e.. measure temp#1,
compare against above or below 32), and an action taken depending upon
the logical answer of "Above/Below". The other two comparisons are
similar to temp#1, just different temperatures.
With regards to CPU affiance, and code generation efficiency, is it
better to compare to the Above or Below to form the decision: i.e.; is
the construct "Is temp#1 greater than 32" more efficient than "Is temp#1
less than 32"?
Thank you,
Walt
[noparse][[/noparse]Non-text portions of this message have been removed]
perform actions based upon the temperatures returned. Every night I
read the Parallax Industrial Control text, towards a end result of PID
temperature control of two chambers. Don't know if I will turn off the
group, but I am a craft beer brewer, and need to control the temperature
of my fermenting chamber (anywhere from 32 degrees to 65 degrees +/- 1
degree - depending upon which beer I am fermenting) and a serving
chamber (approx. 45 degrees +/- 1 degree). The ambient temperature is
the determining factor as to whether I use an air conditioner or the
outside environment to cool, and if below freezing, to use a heater. I
plan on utilizing on/off control for the air conditioner, PID for muffin
fans, PID for ceramic heaters. I know, they make refrigerators, but I
must build my own, darn the cost!!!
Each temperature will be compared to a constant (i.e.. measure temp#1,
compare against above or below 32), and an action taken depending upon
the logical answer of "Above/Below". The other two comparisons are
similar to temp#1, just different temperatures.
With regards to CPU affiance, and code generation efficiency, is it
better to compare to the Above or Below to form the decision: i.e.; is
the construct "Is temp#1 greater than 32" more efficient than "Is temp#1
less than 32"?
Thank you,
Walt
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
>Am undertaking a project where I will monitor three temperatures, and
>perform actions based upon the temperatures returned. Every night I
>read the Parallax Industrial Control text, towards a end result of PID
>temperature control of two chambers. Don't know if I will turn off the
>group, but I am a craft beer brewer, and need to control the temperature
>of my fermenting chamber (anywhere from 32 degrees to 65 degrees +/- 1
>degree - depending upon which beer I am fermenting) and a serving
>chamber (approx. 45 degrees +/- 1 degree). The ambient temperature is
>the determining factor as to whether I use an air conditioner or the
>outside environment to cool, and if below freezing, to use a heater. I
>plan on utilizing on/off control for the air conditioner, PID for muffin
>fans, PID for ceramic heaters. I know, they make refrigerators, but I
>must build my own, darn the cost!!!
>
>Each temperature will be compared to a constant (i.e.. measure temp#1,
>compare against above or below 32), and an action taken depending upon
>the logical answer of "Above/Below". The other two comparisons are
>similar to temp#1, just different temperatures.
>
>With regards to CPU affiance, and code generation efficiency, is it
>better to compare to the Above or Below to form the decision: i.e.; is
>the construct "Is temp#1 greater than 32" more efficient than "Is temp#1
>less than 32"?
Hi Walt -
IF comparison statements will generate the same code size regardless of the
operation in a simple comparison like you have indicated. This may not be true
of compound conditions or those involving complex mathematical operators.
Some of the Dallas/Maxim temperature chips have window comparators built-in to
the unit, so you can set a high and low temperature (thermostat mode) and leave
this comparison to the chip. An alarm is indicated when it falls outside the
range, and an indication is made as to over-limit or under-limit so you can take
the appropriate action. Offloading this kind of task to the hardware, leaves you
all the more room in your program for more important things like keeping the
proof of the beer up to par :-) Here is a typical example of one of the chips
they offer:
http://www.maxim-ic.com/quick_view2.cfm?qv_pk=3728&ln=
Regards,
Bruce Bates