Heater and Thermostat

Heater and ThermostatOpen a browser window or tab containing the microcontroller simulator.

Copy and paste the example program into the code editing area. Press F8 to assemble the code.

Click the HEATER button on the highlighted "A" to connect the heater to PORTA.
If necessary, drag the heater to a more visible position.

Step the program and watch the heater. Answer the reviseOmatic questions on this task.

This program should run analtered on the PICAXE 28X1 chip if you are able to interface a heater and a thermostat.
Time delays to slow the program down might be needed too.


  • MOVW     0X1
    This line stores a number into W that will be used to set TRISA.
    TRISA controls whether PORTA pins are inputs or outputs.
     
  • MOVWR    TRISA
    This line copies from W into TRISA
     
  • MOVRW    PORTA
    This line READS PORTA. It copies from PORTA into W.
     
  • ANDW    0x1
    This is a bit mask. All the bits apart from bit zero will be masked to zero.
     
  • SUBW    0x1
    If W contains 1, this line will set W to zero and the Z flag will be set.
     
  • JPZ     TOOHOT
    This jump only happens if the Z flag is set. This happens if the temperature is above 22C.
     

TASK:
Add four lines to this program to make the temperature steady at about 22 C.
Convert the flow chart into assembly code commands.
Flow Chart

; ===== CONNECT THE HEATER TO PORTA =====
        MOVW    0X1     ; OOOOOOOI
        MOVWR   TRISA   ; SET PORTA I/O
LOOP:
        MOVRW   PORTA   ; READ HEATER PORT
        ANDW    0x1     ; IGNORE BITS 2 TO 7
        SUBW    0x1     ; SEE IF W CONTAINED 1
        JPZ     TOOHOT
        JMP     TOOCOLD

TOOHOT:
; ===== Add two lines here ==============
                        ; HEATER OFF
                        ; WRITE TO HEATER
        JMP     LOOP

TOOCOLD:
; ===== Add two lines here ==============
                        ; HEATER ON
                        ; WRITE TO HEATER
        JMP     LOOP