theironspud:
I'm reading "value" from a sensor over comms.
float value_1 = value_total + (value / 1000);
What is the type of value? Here (value / 1000) could well be an integer expression, since 1000 is an integer -- that would mean any fractional result is lost. If you are expecting a float result from (value / 1000) then best ensure 'value' is a float and divide by 1000.0 (float constant) for good measure. Assuming that this division is the issue -- which I can't tell for sure since you've left out too much critical code, then something like this could be all you need:
Thanks for the replies... all of the code is below (I am using Serial.print()s). Sorry for the omissions- I was just trying to minimize the amount of code to look through.
All of my live readings for the gyroscope appear to be correct, however- they are not totalizing properly and I can't figure out what I've done wrong. This code is meant to function as a 600 ppr encoder. Right now, however, it's just acting like a 4-state angular velocity limit switch.
That's half of what we need to see to help you. Either send us the hardware, now, so we can generate the output that you see, or show us the output. PM me, and I'll give you a mailing address.
If Gyro is something like -1200.2185 and then you add something like Gyro += 45 / 1000, you are adding -1200.2185 + .045.
Since the float type only has 5 significant figures of accuracy, the 0.045 is rounding noise and -1200.2185 + .045 is going to basically just yield 1200.2, no matter how many times you add it on.
That makes a lot of sense. This helped a lot- I slowed down the communications and watched it update per scan. As you pointed out- it wasn't the program, it was my math.