As far as compiler version, I think I have AVRGCC 3.4.1.95 that has GCC 4.6.2 for 8-bit AVR microcontrollers.
I am using Atmel Studio 6 for the IDE.
the max range that I need is from -20,000 to 20,000. So obviously I don't need signed long. Do you think switching to a smaller type like int16_t would be better and have less problems? I modified a code that I downloaded from the internet, but left the datatypes as it was since the code was suppose to be for a microcontroller board that was a PID controller for a motor.
Plain int is guaranteed to have at least the range [-32767, 32767], so that would cover the max range that you have in mind, though it wouldn't hurt to #include <limits.h> and check INT_MIN and INT_MAX just in case your compiler is non-standard in that respect.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
yeah so I checked this
It works with changing the variables to "INT" from "SIGNED LONG", so I'm not quite sure what the difference is causing the problem or if it's a compiler thing.Code:int setValue = 0; int feedbackValue = 0; static int errorValue = 0; static int prevError = 0; static int integral = 0; int derivative = 0; int output = 0;
Last edited by rcgldr; 04-25-2013 at 02:07 PM.