Volume Pressure Sensor

The Homebrew Forum

Help Support The Homebrew Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

bobsbeer

Well-Known Member
Joined
Apr 13, 2011
Messages
118
Reaction score
15
Location
Milnthorpe, Cumbria
This thread is about an idea to use pressure sensors to measure volume in the HLT and Boiler with a Arduino controller. My idea is similar to the Flow Controller thread but using a different approach to volume measurement. This isn't my idea, as it is a method adopted by BrewTroller to take measurements in their system. But as I don't have a BrewTroller I wanted to emulate the measuring system and incorporate this into a slightly simpler system. This post might get quite long so bear with me.

As I see it the reading of the sensor is the same as that of Analog In example on the Arduino Forum

so to change this to read litres instead of a percentage:
Code:
sensorValue = analogRead( TANK_SENSOR_PIN ); //
constrainedValue = constrain( sensorValue, TANK_EMPTY_SETTING, TANK_FULL_SETTING );
tankLevel = map( constrainedValue, TANK_EMPTY_SETTING, TANK_FULL_SETTING, 0, 100 ); //change these values to tank lt volume

Would be:
Code:
// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = A0;  // Analog input pin that the pressure sensor is attached to
[b]const int analogOutPin = 9; // Analog output pin that the LCD is attached to[/b]

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)
constrainedValue = constrain( sensorValue, TANK_EMPTY_SETTING, TANK_FULL_SETTING )
tankLevel = map( constrainedValue, TANK_EMPTY_SETTING, TANK_FULL_SETTING, 1, 30) //
void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
}

void loop()
 {
  // read the analog in value:
  sensorValue = analogRead( TANK_SENSOR_PIN );    // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 30);    // change the analog out value: Where 30 is max volume
  analogWrite(analogOutPin, outputValue);           

  // print the results to the serial monitor:
  Serial.print("sensor = " );                       
  Serial.print(sensorValue);      
  Serial.print("\t output = ");      
  Serial.println(outputValue);   

  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(2);                     
}

It does need editing but posted so I didn't lose it. But please chip in if you can help.
 
looks ok but without the context sensitive colour coding of the text its a bit tricky to read.

Whats the type of constrainedValue ?


How are you setting the max and min values TANK_EMPTY_SETTING, TANK_FULL_SETTING ?
thats gotta be pretty crucial..


is this bubbler system going to be able to read during a drain or fill or will it require a still pool for a measurement?
 
The sensor should read any level whether going up or down. The reading is based on the pressure exerted by the volume so it shouldn't matter which way the level is going or the rate of fill or drop.

The TANK_EMPTY_SETTING and TANK_FULL_SETTING will need to be inputted based on the the low pressure setting and the high pressure setting. On my first test of the unit it was showing a reading of 42 as ambient atmospheric pressure. So if the vessel has a max capacity of 30 lt, then we need to take the pressure reading by filling to max volume, minus the ambient pressure and divide that by 30, to give a per lt reading. As the arduino has a range of 0-1023 , that should divide 1023/30 = 1/34th of a lt or 29.3255ml graduations. So each digitalRead value = 29.3255ml of water in the vessel. As the difference between empty and full should be the same, we can say the difference would be say 200 points. I haven't been able to check the pressure on a full vessel yet so I don't know what that figure would be. But it will be different for each vessel so needs to be tested and then the figure inputted into the code. The sensor is a compensated one, but ambient pressure varies on a day to day basis so we can't just say a set figure for ambient pressure. It will have to read the ambient pressure first and take that value as zero. The 0-1023 won't change as it represents 0-30lt, or whatever the max vessel volume is. and we can say the difference in pressure would be x value. I did try to look at the brewtroller code, but it is a huge program with bits all over the place. For a totally inexperienced (and probably inept) coder it is impossible for me to fathom.

So we could put TANK_EMPTY_SETTING as a variable based on the initial sensor reading and TANK_FULL_SETTING as a variable of TANK_EMPTY_SETTING + (the pressure difference reading taken from testing). Does that make sense?
 
Sounds like its just the h/w delays holding you up then..

taking a base pressure reading makes sense, might even be worth having a seperate air only pressure sensor running for an actual base reading as the brewday can be long and a pressure change can occour during the day?, or engineer it so u always have one empty pot to use as the base reading.

checking the type of constrainedValue before any casting errors are thrown up might be worthwhile

And just be careful where you put your delay statements, as the complexity grows. dont stick any delay commands in functions you call keep em in the main control loop, if u start calling a function in a loop and it has an embedded delay you could stall the system easily taking a while to track down..

whats nore anoying than the wait for bits from china is the 'friendly cute' messages the send you, one seller i have recently used is sending me messages along the lines of
"We have heard whisper mr pigeon is 25%/50%/75%... on his way to you carrying your item.."

talk about taking the P*ss..
 
Back
Top