; htr.a -- control of heaters ; There are 5 Heaters controlled by the DPU N_HTRS equ 5 ; Each heater has 5 bytes associated with it: H_STATUS ds 1 ; FF=inactive, 1=on, 0=off H_SERVICE ds 1 ; power service number H_CTR ds 1 ; decremented to zero, then state changes H_SECS_ON ds 1 ; how many seconds heater should be on H_SECS_OFF ds 1 ; how many seconds heater should be off H_SIZE equ 5 ; size of array element heater_table ds N_HTRS*H_SIZE ; The heater task checks the list of heaters ; every second. For active heaters, it decrements ; nsecs_left; if zero, it either turns the heater ; on or off, and stores either nsecs_on or nsecs_off ; in nsecs_left include htr.i include util.i include pwr.i include task.i include gbl.i include debug.i HTR_INIT: ; initialize heater array lxi h,heater_table mvi M,0FFh ; inactive inx h mvi M,1 ; heater 1 - power service 1 lxi d,H_SIZE-1 dad d mvi M,0FFh ; inactive inx h mvi M,2 ; heater 2 - power service 2 lxi d,H_SIZE-1 dad d mvi M,0FFh ; inactive inx h mvi M,3 ; heater 3 - power service 3 lxi d,H_SIZE-1 dad d mvi M,0FFh ; inactive inx h mvi M,4 ; heater 4 - power service 4 lxi d,H_SIZE-1 dad d mvi M,0FFh ; inactive inx h mvi M,5 ; heater 5 - power service 5 ; Start Heater Task lxi d,heater_task lxi h,GBL_HTR_STACK+stack_size call task_new ret S0 ds 1 hcount ds 1 heater_task: sloop: call task jmp sloop HTR_SET: ; A - which heater (1..5) ; B - 1=activate, 0=deactivate ; C - ON_SECS ; D - OFF_SECS push psw push b push d push h ; Locate heater element lxi h,heater_table mvi c,N_HTRS ll: dcr a jz gotit lxi d,H_SIZE dad d jmp ll gotit: mov a,b cpi 1 jz activate ; deactivate heater mvi M,0FFH ; status=deactivated lxi d,H_SERVICE-H_STATUS dad d mov a,M ; power service call PWR_SET_OFF jmp xit ; Activate Heater onsecs ds 1 offsecs ds 1 activate: mov a,c sta onsecs mov a,d sta offsecs ; setup heater to be turned on next cycle mvi M,0 ; state=off push h lxi d,H_CTR-H_STATUS dad d mvi M,1 ; counter=1 second ; set SECS_ON and SECS_OFF pop h push h lxi d,H_SECS_ON-H_STATUS dad d lda onsecs mov M,a pop h lxi d,H_SECS_OFF-H_STATUS dad d lda offsecs mov M,a xit: pop h pop d pop b pop psw ret