I got my Arduino connected to an AD7730 chip for reading load cell with 24 bit A/D. I am trying to scale and offset for calibration and zero. Since I'm using 24 bit A/D all the math is done in long integers 32bit. My zero routine takes the average reading of 16 samples at zero and uses that as the input zero in the map() function. Then I put my calibration weight on and average 16 readings, subtract the zero number and am left with the in span. I am using fixed point with the 32bit longs, for example if I want to calibrate 60 lbs to .001 lb I enter 60000. Map doesn't work with the numbers I'm using if the out final number is too large. For example when I calibrate an object and enter that it weight 500 for a half pound, it displays 500 just fine. I can set it to read 5000 and it's still OK, but mostly noise. But if I set it to a large number, like maybe 20,000, the number will go negative or go to a smaller value. I'm guessing map with all
32 bit numbers is being messed up somehow.
Any ideas on how to work with larger numbers without getting the goofy numbers I'm getting from map()? Signed 16 bit numbers will go up to +32767 but I can't map to a number even that big using all longs. The A/D seems to have a few lsb's of noise, maybe I'll divide my readings by 32 or something and try again, I'm getting some 50,000 counts with a 1/2 lb on a 30kg load cell. I'm thinking the map function is overflowing the 32 bit longs that it's using and thought maybe someone has a better idea.
Thanks
RogerN