using this:
sub Bin2ascii2 (LCDValue)#NR
SERCEN = 0
SERDEC = 0
SERUN = 0
LCDValueTemp = 0
'If LCDValue >= 100 Then
if sertho = 51 then
LCDValueTemp = LCDValue + 768
end if
if sertho = 49 then
LCDValueTemp = LCDValue + 256
end if
if sertho = 50 then
LCDValueTemp = LCDValue + 512
end if
if sertho = 48 then
LCDValueTemp = LCDValue
end if
lcdvaluetemp = lcdvaluetemp *10
lcdvaluetemp = lcdvaluetemp - 255
lcdvaluetemp = lcdvaluetemp * 18
lcdvaluetemp = lcdvaluetemp / 10
lcdvaluetemp = lcdvaluetemp + 16
I have to make the modifications to the number to make adjustments that involve decimals and the pic does not seem to handle decimals, so i have to multiply the numbers then divide them back down, but when the number gets too large it loses the high byte of the number and gives a false result. how can i get get by this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
using this:
sub Bin2ascii2 (LCDValue)#NR
SERCEN = 0
SERDEC = 0
SERUN = 0
LCDValueTemp = 0
'If LCDValue >= 100 Then
if sertho = 51 then
LCDValueTemp = LCDValue + 768
end if
if sertho = 49 then
LCDValueTemp = LCDValue + 256
end if
if sertho = 50 then
LCDValueTemp = LCDValue + 512
end if
if sertho = 48 then
LCDValueTemp = LCDValue
end if
lcdvaluetemp = lcdvaluetemp *10
lcdvaluetemp = lcdvaluetemp - 255
lcdvaluetemp = lcdvaluetemp * 18
lcdvaluetemp = lcdvaluetemp / 10
lcdvaluetemp = lcdvaluetemp + 16
lcdvaluetemp = lcdvaluetemp / 100
SERCEN = LCDValueTemp + 48
Xmit_RS232(SerCen)
LCDValue = LCDValue - LCDValueTemp * 100
'end if
'IF LCDValueTemp > 0 OR LCDValue >= 10 then
LCDValueTemp = LCDValue / 10
SERDEC = LCDValueTemp + 48
Xmit_RS232(Serdec)
LCDValue = LCDValue - LCDValueTemp * 10
'end if
SERUN = LCDValue + 48
Xmit_RS232(Serun)
end sub
I have to make the modifications to the number to make adjustments that involve decimals and the pic does not seem to handle decimals, so i have to multiply the numbers then divide them back down, but when the number gets too large it loses the high byte of the number and gives a false result. how can i get get by this?
Are you using word variables?
yes
I think it should work if you use:
Dim lcdvaluetemp as word
And LCDValue > 26 to avoid negatives