long x_axis(void)// roll
{
return ((analog1 - 511l) * 9000l) / ir_max;
}
long y_axis(void)// pitch
{
return ((analog0 - 511l) * 9000l) / ir_max;
I basically get all of the other stuff about reading the thermopile's
I get that the analoge port reads a value between 1 and 1022 or something, and that 511 would imply horizontal.
But I don't understand where the multiplication of the number 90001 comes from.
I think i understand that the ir_max is for calibration or to make the readings more accurate, but is this by finding the maximum difference between ground and sky? Idealy using the z sensor when angle <10 deg
Thanks
Replies
I have been doing some more studing of the code, and once again don't quite understand this line.
analog2 = ((float)analogRead(2) * 0.01) + ((float)analog2 * .99);
why breaking it down into two float values, and not taking the reading from just one analogRead(2) ? I am guessing this is for some accuracy and rounding errors?
I think if some-one could recommend a good book/ website that I can consult about programming micro controllers it would probably help as I can try work it out on my own instead of asking 100's of questions :P I have been working through all of the arduino.cc help on the site, but it doesnt always go into much detail about these technical things
That bit had me confused for a while because on my text editor the default font has like 1 pixel difference between l and 1. It can be very easy to confuse 90000l and 90001
The ir_max is the maximum difference, say 200. If we are at 100 then we divide and multiply that times 90 to get 45°. I do it in this order to preserve accuracy in the calculation.
Floats are great but for Lat and Long they aren't accurate enough on AVRs.
for example the location -1223811835 is actually -122.3811835, but in AVR world the last two numbers 35 will get rounded off to who knows what. That's almost a 10 meter difference I believe.