Need help ...with this math. Please !
I use voltage divider ; R1=1000 ohms; R2= 50 to 3500 ohms.
I read the voltage :
I try to calculate the resistor(s) R2, assuming that I do not know values.Code:ADCON0 = %10000001 Pauseus 50 ' Wait for channel to setup ADCON0.1 = 1 ' Start conversion While ADCON0.1=1:Wend ' Wait for conversion advalue.HighByte=ADRESH ' Read variable from ADC and save advalue.LowByte=ADRESL
Formula is (?) :
R2= 1000 * advalue/(1024-advalue)
I wrote this code :
I want to display on Nokia 3310 :Code:dummy =1000 * advalue resistor = div32 10 resistor = (resistor / (1024-advalue)) * 100
But I can not to display the last digit (from right) of values of resistors ...I have "50" instead "54" ; "140" instead "147" ; "1030" instead "1036" ...Code:'~~~~~~~~~~~~~~~~~ setting cursor for display the advalue LcdReg = %10000000 + 5 ' cursor X call PrintCtrlLcd LcdReg = %01000011 ' cursor Y call PrintCtrlLcd '~~~~~~~~~~~~~~~~~ now display results Char = (advalue dig 3) call PrintChar Char = (advalue dig 2) call PrintChar Char = (advalue dig 1) call PrintChar Char = (advalue dig 0) call PrintChar ............. Char = resistor dig 4 call PrintChar Char = resistor dig 3 call PrintChar Char = resistor dig 2 call PrintChar Char = resistor dig 1 call PrintChar
Please, point me to the right direction ! Thanks in advance !




Bookmarks