Dear piclist guru's, I have to do an automatic calibration procedure for a transducer. This will be read by pic internal 10bit AD converter. Assuming the whole AD range is 1024 and the transducer characteristic is linear one, I need to read 2 points to determine the correct slope. Zero will be between 300...400 and full scale between 950 and 1023 and depends by transducer characteristics and biasing. No external scaling device like operational amplifiers will be used. I need interchangeability between various transducers which will match condition above. I'm new in pic maths so I was thinking to the following procedure exemplified with one transducer values, all numbers are in decimal representation: 1. measuring zero calibration value cal_zero = 376 at cal_zero, displayed value must be tmin=0 2. measuring full scale calibration value full_scale = 978 at full_scale, displayed value must be tmax=98.9 3. determine real scale real_scale = full_scale - cal_zero real_scale = 602 4. compute slope slope = real_scale/tmax slope = 602/98.9 = 6.08 I want to use only fixed point unsigned math routine so I need some trick for this division: integer_slope = 10*602/989 = 6, remainder_lo=86 I will use 16bit division routine and check: if remainder_hi = 0 then 100*remainder_lo/tmax = fraction_slope_lo fraction_slope_hi = 0 100*86/989 = 8; new_remainder is not important elsif remainder_hi > 0 then 10*remainder_hi:lo/tmax = fraction_slope_hi:lo end if At this moment I know 100*slope = 608 5. determine real displayed value real_value = 100*(measured_value-376)/100*slope real_value_t_max = 100*602/608 = 99.1 (full scale display) real_value_t_min = 100*1/608 = 0.16 ( first display greater than 0 ) This division will be computed in same way like above one. I will have an error of about 0.2% at full scale which is enough. Now the question: could be done this computation into an easy way ? Here I must use 16b substraction, 16b multiply, 16b division and some conversion from hex to decimal. Thank's for your existence, Vasile -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu