[Menu]>[Circuits Gallery]>[Room temperature controller]


Process explanation of temperature controller

Software processing outline
This software consists of three blocks, base level processing, TMR0 interruption processing, and TMR1 interruption processing.

On a base level processing, display control of six 7 segments LEDs, reading of three BCD switches, and reading of a UP/DOWN switch are performed.
At the beginning, interruption processing was planed to be used in order to keep the operational stability time of LED device. However, this processing does not require strict time. Therefore, waiting time is made by the subroutine which executes NOP instruction two or more times. Processing is interrupted by interruption processing of TMR0 and TMR1, and time is extended. However, there is no influence in the operation of the equipment.

TMR0 interruption processing is used in order to display change of temperature at intervals of 2 seconds. This is for avoiding that a temperature display changes quickly.
The interruption time obtained by TMR0 is not so long. In the case of 4MHz clock, even if the prescaler is set as 256, the maximum time is 65.5 milliseconds. The TMR0 interruption time in this equipment is 10 milliseconds, and the time for 2 seconds is made by software. Temperature detection and the display are performed in the interval of 2 seconds.
In this processing, reading of TEST mode and temperature comparison processing are performed in addition to reading of temperature sensor and setup of display data. An A/D converter is used for reading of TEST mode and reading of temperature sensor.
TEST mode reading can be performed also on a base level. However, in order to share the 25µs timer subroutine for A/D converter, it is carried out by TMR0 interruption processing.
The temperature comparison conditions for controlling external equipment are shown below. When room temperature is higher than expected temperature, it is in UP mode. When room temperature is lower than expected temperature, it is in DOWN mode. It is somewhat incomprehensible.
UP modeON condition:( Inside > Preset ) and ( Inside > Outside )

OFF condition:( Inside =< Preset ) or ( Inside =< Outside )

DOWN modeON condition:Inside < Preset

OFF condition:Inside >= Preset

TMR1 interruption processing is used in order to obtain comparatively long time to control external equipment. This is to suppress the operation frequency of external equipment.
After turning ON external equipment by the temperature comparison result of TMR0, it may become OFF conditions after 2 seconds by the fall of temperature. In such a case, external equipment will repeat ON/OFF frequently and may get damage. Therefore, if external equipment is turned ON once, it is made to continue operating for several minutes. This time can be changed from 1 minute to 10 minutes with the interval switch.
This equipment can control external equipment in two sets. Please refer to "TMR1 interruption processing" about the control conditions of external equipment.

The use of memories (GPR)
The use of General Purpose Registers are shown below.
out10:BCD data for 10th of Outsideseg_ha:Head address of Segment pattern
out1:BCD data for 1st of Outside
seg0:"0" display pattern
in10:BCD data for 10th of Inside
seg1:"1" display pattern
in1:BCD data for 1st of Inside
seg2:"2" display pattern
preset10:BCD data for 10th of Preset
seg3:"3" display pattern
preset1:BCD data for 1st of Preset
seg4:"4" display pattern
out_temp1:Binary data of Outside( 0.25°C )
seg5:"5" display pattern
in_temp1:Binary data of Inside( 0.25°C )
seg6:"6" display pattern
out_temp2:Binary data of Outside( 1°C )
seg7:"7" display pattern
in_temp2 :Binary data of Inside( 1°C )
seg8:"8" display pattern
preset2:Binary data of Preset( 1°C )
seg9:"9" display pattern
interval:BCD data for Interval timer
sega:Display off pattern
mode:UP/DOWN mode ( 1:up/0:down )
w_save:W register save area
test_mode:TEST mode ( 2:OFF/1:IN/0:OUT )
s_save:STATUS register save area
scan_cont:Device scan counter
temp_check:2 seconds counter
rc_cont: Input parameter for led_on subroutine
RC port control data

presetb: Binary conversion counter
For Preset
rb_data: Input parameter for led_on subroutine
RB port data

presetw: Binary conversion counter
For Preset
t25us_cnt:Counter for 25µs subroutine
cont_flag:External device control flag
t200us_cnt:Counter for 200µs subroutine
repeat:Counter for reading check
t1ms_cnt:Counter for 1ms subroutine
presetlk:Preset last look




interval_h:Interval counter ( Higher )




interval_l:Interval counter ( Low )

Initialization processing
The following processings are performed in initialization processing.
Port initialization:I/O mode of Port A, B, and C is set up.

TMR0 initialization:Prescaler is set to 64 and interruption is set up for 10ms.

TMR1 initialization:Prescaler is set to 8 and interruption is set up for 500ms.

A/D initialization:A/D mode of each port is set up.

LED pattern setup: Display pattern of 7 segment LED is set up.
In LED control, '1' is always set to RB7.

Work area initialization:The value of various work memories is initialized.

Interruption setup:TMR0 interruption, Peripheral interruption (TMR1), and Global interruption are set up.

LED and switch scan processing
This processing is processing of a base level. When interruption processing is not performed, it always performs. LED lighting processing and switch reading processing are performed in order.
Process
The contents of execution
Ex time
1 Lighting control of 10th of Outside LED is executed.
Device specification of LED is stored in "rc_cont", display data is stored in "rb_data", and LED lighting control subroutine "led_on" is called.
1.22ms
2Lighting control of 1st of Outside LED is executed.1.22ms
3Lighting control of 10th of Inside LED is executed.1.22ms
4Lighting control of 1st of Inside LED is executed.1.22ms
5Lighting control of 10th of Preset LED is executed.1.22ms
6Lighting control of 1st of Preset LED is executed.1.22ms
7 Reading of 10th of Preset switch is executed.
LED is turned off in order to prevent the malfunction by PORTB data at the time of a device change. It may be unnecessary.
RB0 to RB6 is changed to input mode.
The change waiting time of a device is 200 milliseconds. Even if shorter, I think it is satisfactory.
On account of the circuit, as for the read BCD data, 0 and 1 are reverse. It is made reversed by "xorlw" instruction. 4 bits (BCD) of low ranks are stored.
0.21ms
8 Reading of 1st of Preset switch is executed.
Data is read 200 milliseconds later after switching a device. It is changed into binary data using the value of the 10th read by process 7.
A changed value is temporarily saved in "presetlk". The value of Preset is judged effective when the same value is continuously read three times. After the confirmation, the value is saved in "preset2".
This is because to be abnormal occurred to the reading value by the performance test. Refer to "Troubleshooting"
0.33ms
9 Reading of an interval switch and reading of a UP/DOWN switch are executed.
Only when reading an interval switch, RB7 is set as '0'. Data is read 200 milliseconds later. Because the timer value is equal to or more than 1, when the data is '0', it is converted into 10.
RB0 to RB6 is changed to output mode.
Finally a UP/DOWN switch is read and data is set into "mode" according to the state of the switch. ( 1:up/0:down )
0.22ms

led_on subroutine
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
;--------------------------------------------------------
;                  LED ON subroutine
;--------------------------------------------------------
led_on
        movlw   b'11111111'
        movwf   portb           ;LED OFF
        movfw   rc_cont         ;Read RC control data
        movwf   portc           ;Set PORTC
        call    t200us          ;Wait 200 microseconds
        movfw   rb_data         ;Read disp digit
        addwf   seg_ha,w        ;HA + Digit
        movwf   fsr             ;Set address
        movfw   indf            ;Read 7seg data
        movwf   portb           ;Set PORTB
        call    t1ms            ;Wait 1 millisecond
        return
LED is turned OFF first. This is for preventing displaying previous data on the following LED, when a device is changed.
Changing by the device is done by the data of "rc_cont" and the setting of display data is done 200 milliseconds later.
An LED display pattern is picked out from the pattern table stored in the work area. The binary data of a display number is added to the head address of a table, and the pattern data in the address is read. This is indirect address processing. After outputting pattern data to PORTB, it waits for 1 millisecond. This is for making the continuation lighting time of one LED. Flickering of a display can be prevented by making LED continuation lighting time longer than the reading time of a switch. It may be satisfactory even if shorter. The display state when changing time is not checked.

The above-mentioned execution time is a reference value. Since a BCD conversion process step changes with the value of reading data, some processing time changes. By the simulator, the time of one cycle was about 8.33ms. This is the value which set up a break point at the head of process 1 and measured.

Interruption processing
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
;********************************************************
;                 Interruption Process
;********************************************************
int
        movwf   w_save          ;Save W register
        movfw   status          ;Read STATUS reg
        movwf   s_save          ;Save STATUS reg
        bcf     status,rp0      ;Change to Bank0
        btfsc   intcon,t0if     ;Check TMR0
        goto    temp_detect     ;TMR0 time-out
        btfsc   pir1,tmr1if     ;Check TMR1IF
        goto    out_control     ;TMR1 time-out

;********************************************************
;              END of Interruption Process
;********************************************************
int_end
        movfw   s_save          ;Read saved STATUS reg
        movwf   status          ;Recover STATUS reg
        swapf   w_save,f        ;Read saved W register
        swapf   w_save,w        ;Recover W register
        retfie

If TMR0 or TMR1 carry out a timeout, an interrupt will occur. It is not known at which time of base level processing interruption processing occurs. If the contents of the register currently used on the base level are rewritten by interruption processing, processing of a base level cannot be continued. Therefore, before beginning interruption processing, it is necessary to save the contents of the registers shared with base level. These registers are resaved to the original contents, when interruption processing is completed. The contents of W register and the STATUS register are saved in this processing.
In the saving process, the important thing is not to change the contents of the STATUS register. The various flags of a processing result are stored in the STATUS register. The example by "btfss" instruction is shown below.
Base level process
Interruption process
     Explanation
 movfw   xyz
;Read xyz for the process judgement
Interruption generating
;Execute from address 0004

        goto    int
         :
int
        movwf   w_save
        movfw   status
        movwf   s_save
         :
         :
         :

int_end
        movfw   s_save
        movwf   status
        swapf   w_save,f
        swapf   w_save,w   
        retfie
;
;
;
;
;STATUS reg contents before movfw exec
;STATUS reg contents by the base level
;
;W and STATUS reg can be used
;
;
;
;
;STATUS reg contents by the base level
;swapf doesn't change STATUS reg
;
;
Interruption end
;Execute before interrupt
 btfss   status,z
;STATUS is based on "movfw xyz"

The "movfw"( directive of movf ) directive is used when a STATUS register is saved. If this directive is used, the flag of a STATUS register will change. However, the timing from which a flag changes is after executing a command. Therefore, the contents before executing "movfw" are stored in the W register. It is the contents executed on the base level.
The "swapf" instruction is used when restoring W register. If the contents of the W register are restored by "movf" instruction, the flag of the STATUS register will change. Therefore, W register is restored by the "swapf" instruction which does not affect a flag.

In this interruption process, after save of the registers are completed, a judgment of interruption type is made. It is the judgement of TMR0 or TMR1. Each processing is executed by the interruption type.

TMR0 interruption processing
419
420
421
422
423
424
425
426
427
428
429
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;         Temperature detection Process (10ms)
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
temp_detect
        bcf     intcon,t0if     ;Clear T0IF
        movlw   100             ;Set Time value
        movwf   tmr0            ;Write TMR0 register
        decfsz  temp_check,f    ;count - 1
        goto    int_end
        movlw   200
        movwf   temp_check      ;Set 2 seconds
The "t0if" interruption flag of "intcon" register is cleared first. If this flag is not cleared, an interruption state will continue and if "retfie" instruction is executed when interruption processing is ended, although it is not in a timeout state, either, TMR0 interrupt will occur.
Next, TMR0 value is set up. TMR0 counts up a value, and when a counter overflows, an interrupt generates it. Therefore, when an interrupt occurs, the value of TMR0 is "0."In order to generate the next interruption after the time of a schedule, the value of TMR0 is set up again.
This time, interruption of TMR0 is set as 10 milliseconds. The process to execute by TMR0 interruption is every 2 seconds. Therefore, 10 milliseconds is counted 200 times with the counter (temp_check) of software, and 2 seconds is made. In fact, 200 is set to "temp_check" and the method of subtracting is taken. This is because a count-out judgment can be made simultaneously with subtraction and the process can be simplified, if "decfsz" instruction is used. In interruption in 2 seconds, interruption processing is ended only by subtracting a counter.

TEST mode check processing
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
;------------------ TEST mode check ---------------------
mode1
        movlw   b'01011001'     ;ADCS=01 CHS=AN3 ADON=ON
        movwf   adcon0          ;Set ADCON0 register
        call    t25us           ;Wait 25 microseconds
        bsf     adcon0,2        ;Start A/D conversion
mode2
        btfsc   adcon0,2        ;Conversion end ?
        goto    mode2           ;No.
        movlw   168             ;Set 3.3V
        subwf   adresh,w        ;AN3 - 3.3V
        btfss   status,c        ;AN3 >= 3.3V
        goto    mode3           ;No.
        movlw   2               ;Yes.
        movwf   test_mode       ;Set TEST OFF
        goto    temp0
mode3
        movlw   87              ;Set 1.7V
        subwf   adresh,w        ;AN3 - 1.7V
        btfss   status,c        ;AN3 >= 1.7V
        goto    mode4           ;No.
        movlw   1               ;Yes.
        movwf   test_mode       ;Set IN TEST
        goto    temp0
mode4
        clrf    test_mode       ;Set OUT TEST
The output of a temperature sensor is amplified by the OP amplifier and digital conversion is carried out by an A/D converter. Usually, a temperature display is displayed in °C unit. However, the more detailed temperature display is convenient for gain adjustment of an OP amplifier. As for an A/D converter, 10-bit digital output is obtained. 6 bits of higher ranks of them are made to correspond to °C with this equipment. Therefore, if the 4 bits of the remaining low ranks are used, 1/16°C(0.0625°C) information can be acquired. If it uses to Preset, the display of 4 figures below decimal point is possible. However, with this equipment, the display of 0.25°C unit is realized using 2 bits of higher ranks of the 4 bits.
The information of TEST mode is taken in by an A/D converter. +5V is as TEST OFF, +2.5V is as IN TEST and 0V is as OUT TEST.
The judgment in the mode is performed with the value which divided 5V into three equally. 0V to +1.7V is as OUT TEST, over +1.7V to 3.3V is as IN TEST and Over +3.3V is as TEST OFF.
The information of TEST mode, Outdoor temperature sensor and Indoor temperature sensor is converted in the digital in the order by A/D converter. With the specification of A/D converter, it is required to make time until it takes analog information into PIC after changing an input port. In the case of a 4MHz clock, time of necessity is (1/4)*8 = 2µs in 1-bit conversion. In the case of PIC16F873, the output is 10 bits. However, every 1 bit processing time is added forward and backward, and the time for 12 bits is required. Therefore, after changing a port before starting an A/D converter, it is necessary to make the waiting time of 12b x 2us/b = 24µs. The waiting time in this subroutine is 25µs. The A/D converter is started after passing for 25µs. Completion of A/D conversion supervises and checks after starting that the "GO/DONE" bit of "adcon0" register is set to "0."
8 bits of higher ranks of the output of an A/D converter are the value which divided 5V into 255. It is about 0.0196V. So, +1.7V is 1.7/0.0196 = 87 and +3.3V is 3.3/0.0196 = 168.

Temperature data reading processing
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
;------------ OUT-SIDE temperature detection ------------
temp0
        movlw   b'01001001'     ;ADCS=01 CHS=AN1 ADON=ON
        movwf   adcon0          ;Set ADCON0 register
        call    t25us           ;Wait 25 microseconds
        bsf     adcon0,2        ;Start A/D conversion
temp1
        btfsc   adcon0,2        ;Conversion end ?
        goto    temp1           ;No.
        movfw   adresh          ;Read result
        addlw   8               ;Add 2deg-c
        movwf   out_temp1       ;Save (unit:0.25deg-c)
        movwf   out_temp2       ;Set data
        rrf     out_temp2,f     ;Rotate Right
        rrf     out_temp2,f     ;Rotate Right
        movlw   b'00111111'     ;Set mask
        andwf   out_temp2,f     ;Save (unit:1deg-c)

Digital conversion of the information on a temperature sensor is carried out by an A/D converter. With this equipment, 8 bits of higher ranks of the converted value are used. 1 bit is made equivalent to 0.25°C. 6 bits of higher ranks correspond to 1°C.
The output of a temperature sensor is 0V at 2°C. Therefore, it is necessary to add 2°C to a conversion result. Since 1 bit is 0.25°C, 8 is added to adding 2°C.

Temperature display processing
Three kinds of displays can be performed by TEST mode. Usually, outdoor temperature and indoor temperature are displayed per 1°C in the state of TEST OFF.


TEST OFF

IN TEST

OUT TEST

When indoor temperature is 25.50°C and outdoor temperature is 24.75°C, a display becomes as it is shown in the above figure by TEST mode.
Since the data obtained by an A/D converter is binary, it is necessary to separate the 10th place and the 1st place. The number of times which subtracted 10 from binary data is the 10th place, and remainder is the value of the 1st place. The end of conversion is judged because the subtraction result became negative. Therefore, when it becomes negative, 10 is added and it is made normal remainder value.
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
temp43
        btfss   in_temp1,1      ;1X ?
        goto    temp45          ;No. 0X
        btfss   in_temp1,0      ;11 ?
        goto    temp44          ;No. 10
        movlw   7               ;Set .75 deg
        movwf   in10
        movlw   5
        movwf   in1
        goto    comp0           ;Jump to comparison
temp44
        movlw   5               ;Set .50 deg
        movwf   in10
        movlw   0
        movwf   in1
        goto    comp0           ;Jump to comparison
temp45
        btfss   in_temp1,0      ;01 ?
        goto    temp46          ;No. 00
        movlw   2               ;Set .25 deg
        movwf   in10
        movlw   5
        movwf   in1
        goto    comp0           ;Jump to comparison
temp46
        movlw   0               ;Set .00 deg
        movwf   in10
        movlw   0
        movwf   in1
        goto    comp0           ;Jump to comparison

In IN TEST mode and OUT TEST mode, the value of 1°C unit is displayed on an outdoor display part, and the value below a decimal point is displayed on the indoor display part. 2 bits of low ranks of 8-bit binary data are used for the display below a decimal point. The number of states is four. 00 = 0.00°C, 01 = 0.25°C, 10 = 0.50°C, 11 = 0.75°C. Since the number of states is four, a state is judged and the indicated value is written in the area for an indoor display.

Temperature comparison processing
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
;---------- Temperature comparison processing -----------
comp0
        movfw   mode            ;Read mode(1:up 0:down)
        btfsc   status,z        ;Up ?
        goto    comp2           ;Jump to down mode

;***(Up mode)
        movfw   in_temp2        ;Read in-side
        subwf   preset2,w       ;preset - in-side
        btfsc   status,c        ;preset >= in-side ?
        goto    comp1           ;(>=)
        movfw   in_temp2        ;(<)Read in-side
        subwf   out_temp2,w     ;out-side - in-side
        btfsc   status,c        ;out-side >= in-side ?
        goto    comp1           ;(>=)
        bsf     cont_flag,flag  ;(<)Set control flag
        goto    int_end         ;Jump to int end
comp1
        bcf     cont_flag,flag  ;Clear control flag
        goto    int_end         ;Jump to int end

;***(Down mode)
comp2
        movfw   preset2         ;Read preset
        subwf   in_temp2,w      ;in-side - preset
        btfsc   status,c        ;in-side >= preset ?
        goto    comp1           ;(>=)
        bsf     cont_flag,flag  ;(<)Set control flag
        goto    int_end         ;Jump to int end
This is important processing of this equipment. But processing is simple. First, UP/DOWN mode is checked and it jumps to each processing.
UP mode : The mode which controls external equipment when indoor temperature is higher than preset temperature.
An indoor temperature and a preset temperature are compared first. When the indoor temperature is higher than preset temperature, it corresponds to the conditions which control external equipment. Indoor temperature and outdoor temperature are compared before that. External equipment is not operated when outdoor temperature is higher than indoor temperature. When the outdoor temperature is lower, it becomes the control conditions of external equipment. If it becomes the conditions which control external equipment, "1" will be set as the "flag" bit of "cont_flag". If this bit is set to "1", processing of TMR1 will operate external equipment.
DOWN mode : The mode which controls external equipment when indoor temperature is lower than preset temperature.
Only indoor temperature and preset temperature are compared. When the indoor temperature is lower than preset temperature, it becomes the control conditions of external equipment, and "1" is set as the "flag" bit of "cont_flag".

TMR1 interruption processing
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;           Output control Process (500ms)
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
out_control
        bcf     pir1,tmr1if     ;Clear TMR1IF
        movlw   h'0b'           ;
        movwf   tmr1h           ;Set TMR1H register
        movlw   h'dc'           ;
        movwf   tmr1l           ;Set TMR1L register
        movfw   cont_flag       ;Read all control flags
        btfsc   status,z        ;All flags OFF ?
        goto    int_end         ;Yes. Jump to int end

        btfsc   cont_flag,o1    ;OUT1 control flag ON ?
        goto    cont1           ;Yes.
        btfsc   cont_flag,o2    ;OUT2 control flag ON ?
        goto    cont1           ;Yes.
;***(1st control)
        bsf     cont_flag,o1    ;Set OUT1 control flag
        bsf     porta,o1        ;OUT1 ON
        call    time_set        ;Set timer value
        goto    int_end         ;Jump to int end

cont1
        decfsz  interval_l,f    ;time -1
        goto    int_end         ;Not time-out
        movlw   1
        subwf   interval_h,f    ;Higher value check
        btfss   status,c        ;Value >= 1 ?
        goto    cont2           ;Value = 0 (Time-out)
        movlw   h'ff'
        movwf   interval_l      ;Set Lower value
        goto    int_end         ;Not time-out
cont2
        btfss   cont_flag,flag  ;Control flag ON ?
        goto    cont3           ;No.
        bsf     cont_flag,o2    ;Set output2 flag
        bsf     porta,o2        ;OUT2 ON
        call    time_set        ;Set timer value
        goto    int_end         ;Jump to int end
cont3
        btfss   cont_flag,o2    ;Output2 flag ON ?
        goto    cont4           ;No.
        bcf     cont_flag,o2    ;Clear output2 flag
        bcf     porta,o2        ;OUT2 OFF
        call    time_set        ;Set timer value
        goto    int_end         ;Jump to int end
cont4
        bcf     cont_flag,o1    ;Clear output1 flag
        bcf     porta,o1        ;OUT1 OFF
        goto    int_end         ;Jump to int end
The "tmr1if" interruption flag of "pir1" register is cleared first. TMR1 is counted by 16 bits with two counters, "tmr1h" and "tmr1l". The value of prescaler is a maximum of 8. Therefore, with a 4MHz clock, it is countable to 1us x 8 x 65536 = 524,288us. In this time, the initial value of the counter is set to 3036, and interruption is generated in 62,500counts x 8us = 500 milliseconds.
The "flag" bit of "cont_flag" is checked in every 500 milliseconds. Therefore, the external device control demand performed by temperature comparison processing is detected by processing of TMR1 after 500 milliseconds at the latest. The drive situation of external equipment is managed by "o1" bit and "o2" bit of "cont_flag". A management bit is discontinuous. o1 is the 2nd bit and o2 is the 5th bit. This is because the circuit 1 port for external equipment is RA2 and circuit 2 port is RA5. A label called o1 and o2 is shared with bit specification of PORTA.
When both of bits are "0", the external circuit is in the state which is not driven. In this state, the circuit 1 will be driven if the flag bit of cont_flag is set to "1". "o1" bit of "cont_flag" is set to "1" and RA2 of PORTA is turned ON. Thereby, relay 1 drives and external equipment 1 begins to operate. An interval timer is set up after it. An interval timer is a timer which manages the time when external equipment is operating. A preset value is changed with the value of an interval switch.
When "1" is detected for "o1" or "o2" with the check in a cycle of 500 milliseconds, subtraction of an interval timer is performed. Driving external equipment is continued until an interval timer carries out a timeout, even if the "flag" bit of "cont_flag" is set to "0", before an interval timer carries out a timeout.

Please refer to the following table for the external equipment drive conditions in each state.
flago1o2Control state

000Nothing is driven.

10 -> 10External equipment 1 is driven.

110 -> 1External equipment 1 and 2 is driven.

111External equipment is continuation-driven.

011 -> 0External equipment 2 is stopped.

01 -> 00External equipment 1 is stopped.

X01This condition does not happen.