Hi all.
Here is a thing that has been bugging me for the last few days.
What I am making is an arduino NANO/ATMega328 project that I have put on an experiment board.
Project is a "shake-meter" for beer that works like this.
- Put beer in a small vessel/can (like ml) - fill it gently to avoid foaming.
- When full close all valves and shake it until pressure on manometer doesn't increase anymore.
- on an analogue manometer read the pressure (my meter is in bar).
- use a potentiometer to let the arduino know the pressure that you read on the manometer (0.2 bar to 2.0 bar) the LCD shows the value that you enter.
- I convert bar to PSI and a DS18B20 sensor that is in a probe inside the can gets the temp in celsius that is converted to fahrenheit Depending on the temp in F (30-50) I know what array (Temp30....Temp50 arrays) and the pressure in PSI (-1) i use as the Index to get the VolCO2% values that I have collected from a chart. http://www.backfire.se/images/stories/tutorial/kolsyresttning.png
(So 34F and 5 PSI would get the record in Temp34[4] = "2.06")
On the LCD I display the data that I am after.
Now to the problem.
When I only used the temp 30-40F it worked fine, but then I decided to change to 30-50F. After that I got weird chars on the LCD and on Serial.print.
So I have tried to clean the code and simplify it. I even changed the float fahrenheit to an int instead (since I only am after F in integer).
In the code section:
//
// DEBUG
//fahrenheit = fahrenheit - 40;
fahrenheit = 44.2; // as fahrenheit now is an integer this means it will be 44
// END DEBUG
Then it works and presents correctly on the LCD display
and the function:
void presentonLCD (float tempCin, float tempFin, float prePSIin, float preBARin, float coLevel)
writes the following on the serial print (Note that I in debug purposes have provided the 44 F manually)
ROM = 28 D2 C2 CD 4 0 0 2F
Chip = DS18B20
Data = 1 6F 1 4B 46 7F FF 1 10 67 CRC=67
Temperature = 22.94 Celsius, 73 Fahrenheit44.00F
22.94C
25.91PSI
1.78bar
3.41CO2%
No more addresses.
If I comment out the following ie. tries to get fahrenheit from the DS18B20 it will not work and I will not get anything on display or serial print.
//
// DEBUG
//fahrenheit = fahrenheit - 40;
//fahrenheit = 44.2; // as fahrenheit now is an integer this means it will be 44
// END DEBUG
Will post the full code in the next post