Regarding the subtraction of the term 2n1n2, you can keep the structure of your program same as above, except, in the case of 2n1n2, use SUB/SUBB instead of ADD/ADDC
3. The term 2n1n2 is to be added to the table value after MUL by 100 and then to be subtracted from the basic term. I also did not notice this error earlier.
Hi,regarding of this 2n1n2 error term, as it should be minus from the basic term.
as
Rh=0.01[4(Rdh-100D)]-[2.8X10^-6(n1.256)^2 - 2n1n2x10^-2]
but i take it out and the negative sign equal to positive sign
Rh=0.01[4(Rdh-100D)]-[2.8X10^-6(n1.256)^2 ] +2n1n2X10^-2
and i could be bring to front
Rh=0.01[4(Rdh-100D)+2n1n2]-[2.8X10^-6(n1.256)^2 ]
Rh=0.01[4(Rdh-100D)+2n1n2-2.8X10^-4(n1.256)^2 ]
So my code work for this formula.
Below is the update i double checked :
ORG 0000H ;initially store the sensor reading LSbyte in R3 ,MSbyte in R2
MOV R3,A
SWAP A
ANL A,#0FH
MOV R7,A
CLR C
MOV A,R3
SUBB A,#64H
MOV R4,A
MOV A,R2
SUBB A,#00H
MOV R5,A
;now n1 in R2, n2n3 in R3 , R4 hold LSbyte value after -100D , R5 hold MSbyte value after - carry if there are carry, R7 hold n2
MOv B,#4D ;multiply 4 for Rdt-100D
MUL AB
MOV R5,A
MOV A,R4
MOV B,#4D
MUL AB
MOV R0,A
MOV R1,B
MOV A,R5
ADD A,R1
MOV R5,A
;now R0 hold the LSbyte after x4 , R5 hold the MSbyte after x4
MOV B,R7 ;getting 2n1.n2
MOV A,R2
MUL AB
MOV B,#2
MUL AB ;A store LSByte of 2n1.n2 ,B store MSByte of 2n1.n2
CLR C
ADD A,R0
MOV R0,A
MOV A,B
ADDC A,R5
MOV R5,A
;So until now i had calculated this part [4(RDh-100D)+2n1n2], with MSbyte stored in R5 and LSbyte store in R0
MOV DPTR,#1EFFH
MOV A, R2
MOVC A,@A+DPTR ; A will get the data corresponding to value of n1 (2.8x10^-6[n1.256]^2
MOV B,#100D ;getting (2.8x10^-4[n1.256]^2
MUL AB
MOV R1,B ;R1 hold MSbyte
MOV R4,A ;R4 hold LSbyte
CLR C
MOV A,RO
SUBB A,R4
MOV R0,A
MOV A,R5
SUBB A,R1
MOV R5,A ;R5 hold MSbyte and R0 hold LSbyte for [4(Rdh-100D)+2n1.n2-2.8x10^-4(n1.256)^2]
CSEG AT 1EFFH
DB 0D,0D,0D,2D,3D,5D,7D,9D,12D,15D,18D,22D,26D,31D,36D,41D
END