Gas bottle pressure sensor

If doesn't fit into any other category ....
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Gas bottle pressure sensor

Post by Fernando Perez »

Code: [Local Link Removed for Guests]

items = 23
dim N(items)
dim C$(items)

for i = 0 to items
  N(i) = rnd(1000)
  c$(i) = str$(i)
next i

wlog "Messy: ----------------"
for i = 0 to items
  wlog N(i), c$(i)
next i

bubbleSort N(), C$(), items
wlog
wlog "Tidy: -------------------"
for i = 0 to items
  wlog N(i), C$(i)
next i
  
END

' ----------------------------------------
SUB bubbleSort(arrayN(), arrayC$(), items)
LOCAL count, counter
LOCAL p, h$

  for count = 0 TO items
    for counter = 0 TO items
      if arrayN(counter) < arrayN(count) then
       
        p = arrayN(count)
        arrayN(count) = arrayN(counter)
        arrayN(counter) = p
       
        h$ = arrayC$(count)
        arrayC$(count) = arrayC$(counter)
        arrayC$(counter) = h$
        
      endif
    next counter
  next count
END SUB
Last edited by Fernando Perez on Mon Nov 06, 2023 4:44 pm, edited 2 times in total.
User avatar
cicciocb
Site Admin
Posts: 2092
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 448 times
Been thanked: 1385 times
Contact:

Re: Gas bottle pressure sensor

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon Nov 06, 2023 3:55 pm Software allows quick and easy changes and improvements, and especially leverages the benefits of editing Annex from a chair via wifi connection.
Was thinking of how to create a filter by using an array.
Two arrays, actually, one to hold the sampled data, and one to hold a sorted order of the sample array.
Don't want to keep shuffling the actual sampled data, just want to sort the array index of the data in a separate array.
Thinking of reading about a dozen samples, then creating a sort_order() array of the sample array in order of sample similarity.
Probably dump any ridiculous extremes, then average the remaining reasonable similarities, to add to the main gas pressure average.
Need to work out a usable sort routine to sort by similarity, and some form of yardstick for testing reasonable similarity.
Aint got a clue of how to do it yet - just have a fairly clear picture in my minds eye of where I want to get to, but not the foggiest of how to get there.
Robin, you just need to have a clean signal from the sensor :lol:
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 the bubblesort Fernando, that saves me a lot of hassle.

Yep, in an ideal world Francesco, but I installed the pressure sensor on 'a vague whim' when re-routing the gas supply to new bottles location when I was building a balcony. The balcony is done and the sensor cabling is no longer accessible, so I must work with what I've got.

That sensor would not even have been needed with the original plan, which was to have 2 individual pressure sensors on the dual gas bottle system to notify when either bottle became empty and the automatic changeover valve had switched over to the other bottle.
It would always have given notification of an empty bottle BEFORE the other gas bottle ran out.
But without the sensors, if the valve switches over from empty to full bottle without being noticed, both can run out.

I still have the other 2 sensors somewhere, and cable routed ready for fitting them, but the neighbour pointed out that if there was ever a fire the sensors would invalidate the insurance... so I didn't fit them. But I may as well try to get the existing inaccessible regulated sensor working if possible.
User avatar
cicciocb
Site Admin
Posts: 2092
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 448 times
Been thanked: 1385 times
Contact:

Re: Gas bottle pressure sensor

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon Nov 06, 2023 5:03 pm Thanks for the bubblesort Fernando, that saves me a lot of hassle.

Yep, in an ideal world Francesco, but I installed the pressure sensor on 'a vague whim' when re-routing the gas supply to new bottles location when I was building a balcony. The balcony is done and the sensor cabling is no longer accessible, so I must work with what I've got.

That sensor would not even have been needed with the original plan, which was to have 2 individual pressure sensors on the dual gas bottle system to notify when either bottle became empty and the automatic changeover valve had switched over to the other bottle.
It would always have given notification of an empty bottle BEFORE the other gas bottle ran out.
But without the sensors, if the valve switches over from empty to full bottle without being noticed, both can run out.

I still have the other 2 sensors somewhere, and cable routed ready for fitting them, but the neighbour pointed out that if there was ever a fire the sensors would invalidate the insurance... so I didn't fit them. But I may as well try to get the existing inaccessible regulated sensor working if possible.
Ok, I understand..
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 all the input, and I am glad to say that I have got something that is actually working ok for now.
Basically I ended up ignoring the magnitude of the samples, and just used their relative direction to count towards the true value.
I can choose to work up from threshold as a starting point, or just use a first initial pressure sample, and it's nice to see it smoothly stabilising.
I will optimise it for sure, and increase the number of samples for the average when done, but it actually works fine as it is:
It's been quite an eye-opener to see the gas pressure dropping a degree at a time as the bottle gets colder, and it makes me suspect I may eventually need to add threshold temperature compensation, but Annex will easily provide a solution for that (and just about anything else).

getgas:
oldgas=gas
newgas=adc(gaspin)
if newgas<oldgas then
if sign>0 then count=1: sign=-1 else if count<max then count=count+1
newgas=oldgas-(pkt*count)
else if newgas>oldgas then
if sign<0 then count=1: sign=1 else if count<max then count=count+1
newgas=oldgas+(pkt*count)
endif
gas=int(gas+(newgas-gas)/10) ' average



Edit: BTW Francesco, I did notice, and am using, the excellent responsive REPLACE$( slider from your example... thanks for that.
a$ = a$ + replace$(slider$(threshold,0,800,"threshold"), "onchange", "oninput")
Post Reply