Gas bottle pressure sensor

If doesn't fit into any other category ....
User avatar
Electroguard
Posts: 885
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 284 times
Been thanked: 329 times

Gas bottle pressure sensor

Post by Electroguard »

Vehicles have shock-absorbers (dampers) to absorb and smooth out bouncy surfaces while still following changing ground contours.
However, I need a software equivalent for an Annex ADC input which reads regulated gas pressure of external gas bottles.
https://www.aliexpress.com/item/1005002 ... ot help).
Annex needs to filter out bouncy ADC 'noise' which is outside of acceptable limits, except for subsequent changes which follow the same trend.
In particular it needs to filter out transient 'dips' below the threshold level, which would trigger false alarms.
But it needs to monitor when the mean level does actually drop below the threshold, in order to give early 'out of gas' warning, otherwise too much heat can be lost before becoming aware that the central heating boiler is out of gas and no longer working.

I tried unsuccessfully to use a capacitor.
I expect I can eventually bully some code into doing what it needs to by using half a page of IF THEN barbed wire to restrict it.
But perhaps someone can think of more elegant solution ?
User avatar
cicciocb
Site Admin
Posts: 2092
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 448 times
Been thanked: 1384 times
Contact:

Re: Gas bottle pressure sensor

Post by cicciocb »

Hi Robin,
I have some questions :
- What is the voltage range of the signal coming from the sensor (I mean the voltage when is within the working range (i.e. bottle full=2V, bottle lower limits = 0.5v).
- Are you able to define the transitory in terms of amplitude and time ?

It should not be hard to just apply a filter on the signal and get the average on a long period of time and then compare this value against some thresholds.
User avatar
Electroguard
Posts: 885
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 284 times
Been thanked: 329 times

Re: Gas bottle pressure sensor

Post by Electroguard »

Hi Francesco,

The sensor Is actually 30PSI (was all that was available at the time) - it was originally going direct on the bottle before the regulator, but the situation was later changed to be after the regulator (on the regulated side).

I'm using an esp32 dev module which has 3v ADC input, and I developed the simple adc script using a pot across the 3.2v supply, which showed full scale of 4095 at full pot rotation (script is included below).

The sensor is 5v, giving 0 to 5v output at max30psi. I originally planned to use a reducer trimpot to avoid full 5v, but then realised that the regulated gas pressure is much less than 30 psi so will never give anywhere near 5v output. The sensor does work fine at 3.3v supply, but output is correspondingly lower.


So to summarise, adc is 4095 max scale, but full gas bottle only reads about 700, usable gas reads 400+, but drops down to about 350 when the regulator shuts off the empty bottle (residual gas pressure still shows 330 for the empty bottle).

gas.jpg

So if the adc reading was stable, I would set the empty bottle threshold alarm to just under 400 (would be regularly tweaked towards optimum).

Code: [Local Link Removed for Guests]

'Gas Pressure Sensor - 400 empty, 630 full
title$="Gas pressure"
showtitle = 1
gas=0
'oldgas=gas
gaspin=36
threshold=400
gosub webpage
timer0 1000, getgas
wait


getgas:
'oldgas=gas
gas=adc(gaspin)
if gas>threshold then
 css cssid$("level", "color:white;background:green;") 
else
 css cssid$("level", "color:white;background:red;") 
endif
return

webPage:
cls
autorefresh 1000
a$ = ""
a$ = a$ + "<br><br>"
a$ = a$ + "<div id='div' style='display: table; margin-right:auto;margin-left:auto;text-align:center; '>"
a$ = a$ + cssid$("div", "xfont-sizex:1.5em; xtransform: scale(1.3);")
if showtitle = 1 then a$ = a$ + "<h2>" + title$ + "</h2>" + "<br>"
a$ = a$ + "<br>"'
a$ = a$ + textbox$(gas,"gas") + "<br>"
a$ = a$ + "<br>" 
a$ = a$ + cssid$("gas", "color:red;font-size:2.8em;width:100px; text-align: center;")
a$ = a$ + "<br>" 
a$ = a$ + meter$(gas,0,750,"meterpos")
a$ = a$ + cssid$("meterpos", "color:Darkblue;width:420px; text-align: center;")
a$ = a$ + "<br><br>"
a$ = a$ + "<br>" 
a$ = a$ + "Threshold "
a$ = a$ + slider$(threshold,100,700,"threshold")
a$ = a$ + " " + textbox$(threshold,"level") + "<br>"
a$ = a$ + cssid$("level", "color:white;background:green;font-size:1.5em;width:50px;height:30px;  text-align: center;border-radiusx: 35px;paddingx:4px;height;:20px;")
a$ = a$ + "<br><br>"
html a$
a$ = ""
return

'----------- END ------------
You do not have the required permissions to view the files attached to this post.
User avatar
Electroguard
Posts: 885
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 284 times
Been thanked: 329 times

Re: Gas bottle pressure sensor

Post by Electroguard »

And there is no regularity or consistency to the reading BTW.
It is currently nominally around 550, but every reading is usually at least plus or minus 10 different, and occasionally flicks down into the 400+ and up into 600+.
It is being sampled 1 per sec for dev purposes, and no two readings are ever the same... probably not helped by the several meters of utp connecting cable to outside.
User avatar
cicciocb
Site Admin
Posts: 2092
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 448 times
Been thanked: 1384 times
Contact:

Re: Gas bottle pressure sensor

Post by cicciocb »

try this code

I replaced the sensor with a slider; you can play with the acquisition rate and the number of samples in the filter.

To reduce the noise on the reading, you should use twisted cables (maybe is already the case) and put a capacitor on the ADC pin).

Code: [Local Link Removed for Guests]

'Gas Pressure Sensor - 400 empty, 630 full
title$="Gas pressure"
showtitle = 1
my_pressure = 500
gas=my_pressure
'oldgas=gas

gaspin=0
threshold=400
gosub webpage
timer0 100, getgas
wait


getgas:
'oldgas=gas
'gas=adc(gaspin)

' do a simple filter integration
gas = gas + (my_pressure - gas) / 50  ' filter on last 50 values
if gas>threshold then
 css cssid$("level", "color:white;background:green;") 
else
 css cssid$("level", "color:white;background:red;") 
endif
return

webPage:
cls
autorefresh 100
a$ = ""
a$ = a$ + "<br><br>"
a$ = a$ + "<div id='div' style='display: table; margin-right:auto;margin-left:auto;text-align:center; '>"
a$ = a$ + cssid$("div", "xfont-sizex:1.5em; xtransform: scale(1.3);")
if showtitle = 1 then a$ = a$ + "<h2>" + title$ + "</h2>" + "<br>"
a$ = a$ + "<br>"'
a$ = a$ + textbox$(gas,"gas") + "<br>"
a$ = a$ + "<br>" 
a$ = a$ + cssid$("gas", "color:red;font-size:2.8em;width:100px; text-align: center;")
a$ = a$ + "<br>" 
a$ = a$ + meter$(gas,0,750,"meterpos")
a$ = a$ + cssid$("meterpos", "color:Darkblue;width:420px; text-align: center;")
a$ = a$ + "<br><br>"
a$ = a$ + "<br>" 
a$ = a$ + "Threshold "
a$ = a$ + slider$(threshold,100,700,"threshold")
a$ = a$ + " " + textbox$(threshold,"level") + "<br>"
a$ = a$ + cssid$("level", "color:white;background:green;font-size:1.5em;width:50px;height:30px;  text-align: center;border-radiusx: 35px;paddingx:4px;height;:20px;")

a$ = a$ + "Pressure Sensor"
a$ = a$ + replace$(slider$(my_pressure,0,800,"threshold"), "onchange", "oninput")
a$ = a$ + " " + textbox$(my_pressure, "my_pressure") + "<br>"
a$ = a$ + cssid$("my_pressure", "color:white;background:green;font-size:1.5em;width:50px;height:30px;  text-align: center;border-radiusx: 35px;paddingx:4px;height;:20px;")

a$ = a$ + "<br><br>"
html a$
a$ = ""
return

'----------- END ------------

User avatar
Electroguard
Posts: 885
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 284 times
Been thanked: 329 times

Re: Gas bottle pressure sensor

Post by Electroguard »

Thanks for trying, but the value is still bouncing around, even if it integrates between changes now.

Yes, am using a capacitor, and I am using twisted cables.

The problem is probably because of working with such a small change of the adc signal... 100 may seem a big number, but is an insignificant part of 4095.

I will concentrate on dampening the dancing numbers rather than trying to stabilise the dancing voltages they represent.
So each change of sampled direction will only be allowed minimal change, whereas successive changes in the same direction can multiply their change.
Worth a try, anyway.
User avatar
cicciocb
Site Admin
Posts: 2092
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 448 times
Been thanked: 1384 times
Contact:

Re: Gas bottle pressure sensor

Post by cicciocb »

If you have too much noise, probably you must shield and put capacitors also on the sensor power supply.

You can increase the value that I fixed at 50 to smooth more
And try to supply the sensor with 5V with a separate stabilized power source
bugs
Posts: 146
Joined: Mon Feb 08, 2021 10:10 pm
Location: Scotland
Has thanked: 48 times
Been thanked: 56 times

Re: Gas bottle pressure sensor

Post by bugs »

The specification is reads a bit weird:-
"Output signal
0.5-4.5V or 0-5V or 1-5V or 0.4-2.4V(Low power consumption)"

Does it depend on a supply voltage?
User avatar
cicciocb
Site Admin
Posts: 2092
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 448 times
Been thanked: 1384 times
Contact:

Re: Gas bottle pressure sensor

Post by cicciocb »

With 5V you'll have a greater value in output and this should reduce a little bit the impact of the noise.

Using a separate and clean 5V for the supply, you'll have less noise on the output as the sensor is simply a wheatstone bridge
User avatar
Electroguard
Posts: 885
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 284 times
Been thanked: 329 times

Re: Gas bottle pressure sensor

Post by Electroguard »

Yeah, I'll tidy things up and improve the sensor supply when I can.

I was fed up climbing steps every few months to reboot the Annex matrix smartclock supply above a suspended ceiling (the smartclock also reads the bluetooth temp senders). So I extended its usb supply through the wall and down into the boiler room - no more steps, cos now just open the boiler-room door to toggle the mains off and on... (but I must remember to make the smartclock reboot itself nightly).
That's when I noticed the pressure sensor cable still laying unused from over a year ago since I redid the outside gas supply.
So was being sidetracked from a sidetrack, but need to get back on main track for some more immediate priorities first.
But at least I've made some small progress, and have added some reminders to my ToDo list.
Post Reply