Lets say I measure a frequency of 42,325 Hz and read this on my LCD display as 42325. If I divide the 42,325 by 1000 and send it to the LCD, I read 42 on the display.
Is there any way I can show the .325 decimal part, i.e have the display read 42.325 kHz? (Display a Real number not an Integer)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi,
Some times ago I create a sub I named "printdec" . So you can display on LCD any number you want to divide by 10,100,1000 or 10000 .
' factordiv may be 100,1000,10000
Sub PrintDec (number as word , facteurdiv as word )
dim wholenumber , remainder , temp as word
select case facteurdiv
case 10
nop
case 100
nop
case 1000
nop
case 10000
nop
case else
exit sub 'to avoid other divisions , even by zero
end select
wholenumber= number / facteurdiv
remainder=number %facteurdiv
print wholenumber
print "."
' to avoid false displays you must add following lines
'ie : if number is 10003 and you want display 10,003
'10003/1000=10 remainder=3 if you write 10,3 , your display is false but your result is OK
select case facteurdiv
case 100
if remainder < 10 then
print "0"
end if
case 1000
if remainder <100 then
print "0"
end if
if remainder < 10 then
print "0"
end if
case 10000
if remainder <1000 then
print "0"
end if
if remainder <100 then
print "0"
end if
if remainder< 10 then
print "0"
end if
end select
print remainder
end sub
Regards .GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using a PIC 16F627.
Lets say I measure a frequency of 42,325 Hz and read this on my LCD display as 42325. If I divide the 42,325 by 1000 and send it to the LCD, I read 42 on the display.
Is there any way I can show the .325 decimal part, i.e have the display read 42.325 kHz? (Display a Real number not an Integer)
hi,
Some times ago I create a sub I named "printdec" . So you can display on LCD any number you want to divide by 10,100,1000 or 10000 .
' factordiv may be 100,1000,10000
Sub PrintDec (number as word , facteurdiv as word )
dim wholenumber , remainder , temp as word
select case facteurdiv
case 10
nop
case 100
nop
case 1000
nop
case 10000
nop
case else
exit sub 'to avoid other divisions , even by zero
end select
wholenumber= number / facteurdiv
remainder=number %facteurdiv
print wholenumber
print "."
' to avoid false displays you must add following lines
'ie : if number is 10003 and you want display 10,003
'10003/1000=10 remainder=3 if you write 10,3 , your display is false but your result is OK
select case facteurdiv
case 100
if remainder < 10 then
print "0"
end if
case 1000
if remainder <100 then
print "0"
end if
if remainder < 10 then
print "0"
end if
case 10000
if remainder <1000 then
print "0"
end if
if remainder <100 then
print "0"
end if
if remainder< 10 then
print "0"
end if
end select
print remainder
end sub
Regards .GC
Thanks GC!