pin high. When the module is available, it will set the Ready
The first piece of information transmitted is the current
temperature. Remember that the current temperature
control in the VCP was first; hence, it has an index value of
0. When we address controls in the VCP, the address used
by I2CIN and I2COUT will be the control index (0 – n).
This keeps us from having to know the location of data
within the module.
Storing the temperature may take a moment, so we’ll
monitor the clock (SCL) line. The FlexiPanel module uses
“clock stretching” (pulls the clock line low) to indicate
that it’s busy, so waiting for the clock line to go high
before moving to the next control is a good idea after
The next control is the current system status text. For
me, the cleanest implementation was the use of the
SELECT-CASE structure. To be honest, I’m not a big fan
of this structure for embedded control (it’s a code hog),
but, in this case, it just makes good sense. Note that each
string is terminated with a 0 — this is a requirement of the
Next, we read in the setpoint, mode, and fan controls
from the VCP.
At this point, all the information has been exchanged,
so we can release the module and apply the air conditioning
The processing logic is very simple. We start by
checking the mode, and if it’s in an active mode (cool
or heat), check the current temperature against the
setpoint. Here’s a case where you might be inclined to use
SELECT-CASE, but there is so much code involved that it
can become a bit unwieldy. No problem — BRANCH
works really well here.
BRANCH sysMode, [System_Off, Cool_On, Heat_On]
IF (fanCtrl = FanAuto) THEN
status = StatOff
Fan = IsOff
status = StatFan
Fan = IsOn
Cool = IsOff
Heat = IsOff
As you can see, BRANCH selects the code segment
that corresponds with the operating mode. Off is
the easiest to deal with; turn off the control outputs —
unless the user has placed the fan in manual mode for
The logic for cooling and heating is identical, so we’ll
just look at cooling. Really, this code is so easy that I
didn’t even put comments in my original listing.
EASY TO USE CAD TOOLS
Schematic and PCB Layout
• Powerful and flexible schematic capture.
• Auto-component placement.
• Rip/entry PCB routing.
• Polygonal gridless ground planes.
• Library of over 8000 schematic and 1000 PCB foot prints.
• Bill of materials, DRC reports and more.
Mixed Mode SPICE Circuit Simulation
• Berkeley SPICE3F5 simulator with custom extensions for true
mixed mode and interactive simulation.
• Six virtual instruments and 14 graph based analysis types.
• 6,000 models including TTL, CMOS and PLD digital parts.
• Fully compatible with manufacturers’ SPICE models.
Proteus VSM - Co-simulation & debugging for popular Micro-Controllers
• Supports PIC16 & PIC12, AVR, 8051, HC11 and ARM micro-controllers.
• Co-simulate target firmware with your hardware design.
• Includes interactive peripheral models for LED and LCD displays,
switches, keypads, virtual terminal and much, much more.
• Provides source level debugging for popular compilers and
assemblers from Hi Tech PICC, Crownhill, IAR, Keil and others.
MicroChip PIC 18
• Supported models of the PIC 18 includes PIC18F242, PIC18F252,
PIC18F442, PIC18F452, PIC18F248, PIC18F258, PIC18F448 and
Basic Stamp BS1 and BS2
• Proteus VSM for BASIC Stamp contains everything you need to
develop and simulate designs based around the BASIC Stamp.
• See examples in downloadable Demo at
“I finished my first design, schematic and PCB in one day.”
“What a great tool! I love it.” DAN GILL
“For the cost of the software compared to the productivity gains, I consider Proteus to be
pivotal in the commercial viability of my company and by far represents the best value
for money of anything Tempus possesses.” ROB YOUNGS, Tempus Consulting
“PROTEUS stands out as the best all-round program in this review. Other programs
reviewed have strengths in the pcb design process, Proteus maintains a constant high
level of capability throughout. Whether a schematic, user-friendly interactive routing,
configurable autoplacing, competent autorouteing, or a combination of the above,
PROTEUS handles everything very well.” Electronic & Wireless World CAD Review Roundup
Save Time. Save Money.
Proteus Starter Kit – $199 • Full System – $1899
“This is clearly superior in every respect.”
R4 SYSTEMS INC.
www.labcenter-electronics.com Tel: 905•898•0665 firstname.lastname@example.org
Circle #131 on the Reader Service Card.