I put 1,28 V to pin 9 in ADC. I didn't realise that Vref/2 really means that Vref value has to be divided...I found correct value for Vref through testing and datasheets, where 2,56 and 1,28 V were mentioned as Vref (or Vref/2) values. But bigger problem is that I don't know assembler language and I can't write the pice of code for activating relay. Could someone please help me with that?
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 org 0h RAM_ADDR EQU 30H COUNT EQU 3 hundreds equ 30h tens equ 31h ones equ 32h ACALL DELAY_200M ACALL ONETIME_LCDINIT STT: ACALL ADC ACALL Bin2Dec ACALL DEC_ASCI_CONVRT ACALL DELAY_200M ACALL DELAY_200M ACALL DELAY_200M sjmp STT ;================================================= ;this subroutine is used to take data from ADC and ;keep to Accumulator ;================================================= ADC: mov A,P0 nop nop ret Bin2Dec: mov b,#100d div ab mov hundreds,a mov a,b mov b,#10d div ab mov tens,a mov ones,b ret DEC_ASCI_CONVRT: MOV R0,#RAM_ADDR MOV R2,#3 BACKk: MOV A,@R0 ORL A,#30H ACALL DATA_DISPLAY INC R0 DJNZ R2,BACKk RET ONETIME_LCDINIT: MOV A,#38H ACALL COMMAND MOV A,#0EH ACALL COMMAND MOV A,#01H ACALL COMMAND MOV A,#06H ACALL COMMAND MOV A,#86H ACALL COMMAND RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; COMMAND: ACALL READY MOV P1,A CLR P2.0 CLR P2.1 SETB P2.2 CLR P2.2 RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA_DISPLAY: ACALL READY MOV P1,A SETB P2.0 CLR P2.1 SETB P2.2 ACALL DELAY CLR P2.2 RET READY: SETB P1.7 CLR P2.0 SETB P2.1 BACK: CLR P2.2 ACALL DELAY SETB P2.2 JB P1.7,BACK RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DELAY_200M: MOV R7,#30H L1_DELAY: MOV TMOD,#10 MOV TH1,#3CH MOV TL1,#0B0H SETB TR1 AGAIN: JNB TF1,AGAIN CLR TR1 CLR TF1 DJNZ R7,L1_DELAY RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DELAY: MOV R3,#50 HERE3: MOV R4,#255 HERE2: DJNZ R4,HERE2 DJNZ R3,HERE3 RET END
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 READY: SETB P1.7 ;To make P1.7 input port CLR P2.0 ;RS=0 to access command reg SETB P2.1 ;R/W = 1 to read command Reg BACK: CLR P2.2 ;E=0 to provide low to high pulse ACALL DELAY ; give some time(pulse time) SETB P2.2 ; low to high pulse ends JB P1.7,BACK ; stay till busy flag=0 RET
I can add that resistor easily, thank you for mentioning that!
But is the code I put here correct? I changed port/pin names to match my diagram, but I have no idea if should I change something else in that code?
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 org 0h RAM_ADDR EQU 30H COUNT EQU 3 hundreds equ 30h tens equ 31h ones equ 32h ACALL DELAY_200M ACALL ONETIME_LCDINIT STT: ACALL ADC CJNE A,#27, TRIPP ; If not equal to 27 go to TRIPP to show temperature SETB P1.3 ; If equal to 27 activate relay and show temperature TRIPP: ACALL Bin2Dec ACALL DEC_ASCI_CONVRT ACALL DELAY_200M ACALL DELAY_200M ACALL DELAY_200M SJMP STT ;================================================= ;this subroutine is used to take data from ADC and ;keep to Accumulator ;================================================= ADC: mov A,P0 // ACD output to P.0 nop nop ret Bin2Dec: mov b,#100d div ab mov hundreds,a mov a,b mov b,#10d div ab mov tens,a mov ones,b ret DEC_ASCI_CONVRT: MOV R0,#RAM_ADDR MOV R2,#3 BACKk: MOV A,@R0 ORL A,#30H ACALL DATA_DISPLAY INC R0 DJNZ R2,BACKk RET ONETIME_LCDINIT: MOV A,#38H ACALL COMMAND MOV A,#0EH ACALL COMMAND MOV A,#01H ACALL COMMAND MOV A,#06H ACALL COMMAND MOV A,#86H ACALL COMMAND RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; COMMAND: ACALL READY MOV P2,A // LCD D0 to D7 connected to P2 CLR P3.4 // LCD RS (pin4) to P3.4 CLR P1.4 // LCD R/W (pin5) to P1.4 (I took unused port for this) SETB P3.5 // LCD E (pin6) to P3.5 CLR P3.5 RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA_DISPLAY: // I changed port numbres here ACALL READY MOV P2,A SETB P3.4 CLR P1.4 SETB P3.5 ACALL DELAY CLR P3.5 RET READY: SETB P2.7 CLR P3.4 SETB P1.4 BACK: CLR P3.5 ACALL DELAY SETB P3.5 JB P2.7,BACK RET DELAY_200M: MOV R7,#30H L1_DELAY: MOV TMOD,#10 MOV TH1,#3CH MOV TL1,#0B0H SETB TR1 AGAIN: JNB TF1,AGAIN CLR TR1 CLR TF1 DJNZ R7,L1_DELAY RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DELAY: MOV R3,#50 HERE3: MOV R4,#255 HERE2: DJNZ R4,HERE2 DJNZ R3,HERE3 RET END
Code ASM - [expand] 1 2 3 4 RAM_ADDR EQU 30H COUNT EQU 2 tens equ 30h ones equ 31h
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Bin2Dec: mov b,#10d div ab mov tens,a mov ones,b ret DEC_ASCI_CONVRT: MOV R0,#RAM_ADDR MOV R2,#2 BACKk: MOV A,@R0 ORL A,#30H ACALL DATA_DISPLAY INC R0 DJNZ R2,BACKk RET
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?