Regolatore di  temperatura con ADC TLC548 e scheda 8051

Schema elettrico

Software

;Etichette
CS = P1.0
CLK = P1.1
DATA = P1.2
RISC = P1.3
VENT = P1.4
TRef = (40-20)*255/50
cont = 11h

org 8200h
init:
  setb CS
  clr CLK
  setb DATA 
  clr RISC
  clr VENT
  call IniAcqTemp

main:
  call lettadc
  mov 10h,a
  call AcqTemp
  call RegTemp
  call RitReg
  jmp main

;++++++++++++++ Subroutine lettura ADC seriale TLC548 ++++++++++++++++++++++++
;Il valore letto ritorna sul registro A
lettadc:
  mov r0,#8
  clr CS
  loopcv: 
  mov c,DATA
  rlc a
  setb CLK
  clr CLK
  djnz r0,loopcv
  setb CS
  ret
;++++++++++++++++++ Subroutine regolazione temperatura  ++++++++++++++++++++++++
RegTemp:
  clr c	  
  subb a,#TRef
  jz U_Reg
  jc riscalda
  clr RISC
  setb VENT 
  jmp U_Reg	
riscalda:	
  setb RISC
  clr VENT 	
U_Reg:
  ret
;++++++++++++++++++ Subroutine di acquisizione temperatura ++++++++++++++++++++++++
IniAcqTemp:
  mov cont,#250
  mov dptr,#9000h
  ret
AcqTemp:
  djnz cont,DoAcq
  call IniAcqTemp
DoAcq:
  movx @dptr,a
  inc dptr   
  ret
;++++++++++++++++++ Subroutine ritardo regolazione temperatura ++++++++++++++++++++++
RitReg:
  mov r0,#0
  mov r1,#0
loop:
  djnz r1,$
  djnz r0,loop  
  ret
end