djsfantasi
- Joined Apr 11, 2010
- 9,237
Ok, we’re getting into the details of mikroC. In your scaling statement, you are mixing int and float values. Sometimes the compiler will make this work. Other times, it doesn’t and you see unusual results.
I’d try the following statement:
Vinp=((float)volt*5.0)/1024.0
The (float) says convert the value of volt from an integer to a float before calculating anything.
You might print out the values after each step to confirm your calculations are working as designed.
I’d try the following statement:
Vinp=((float)volt*5.0)/1024.0
The (float) says convert the value of volt from an integer to a float before calculating anything.
You might print out the values after each step to confirm your calculations are working as designed.