電子工作71 – ガス元栓閉め忘れ警報器

 

 

概要

   炊事場の小型ガス湯沸器が古く、使い方にコツが要る。まず水道の栓を開けて水を通し、ガスの元栓を開け、最後に湯沸器のコックをねじって種火を点け、さらにコックを開けてガスの強さを調整する。湯沸器を止める時は、コックを完全に閉じてガスの火を消し、ガスの元栓を閉じ、最後に水道の栓を閉じる。もし、ガスの火がある状態で水道の栓を止めると、所謂空炊き状態になって一発で湯沸器が使用不能になる。古いものはかくも注意深い取扱いが必要なのである。では、このIT百花繚乱の時代になぜ使う。物を大事にしたいのと愛着があるからである。元栓を開けたままで寝てしまうことが年に2、3回あり、ガス検知器が設置してあるとはいえ危険。安眠のためにもと、今回簡単なガス元栓閉め忘れ警報器を製作することにした。

 

製作にあたって考えていたこと

1)    電池で最低3ヶ月位動作すること。

2)    出来るだけ簡単で安価にできる。

3)    12F629とPicBasic Proを使う。

 

回路図

ガス元栓の開閉をセンシングさせるのにリードスイッチなる部品と磁石を初めて使ってみることにした。回転するガス元栓の外縁部に小さい磁石を貼り付け、開栓時にその磁石がガスのホースの上部に取付けてあるリードSWを磁力で閉じさせる。これによってシステムの電源をONにする。さらにもう1個のリードSWを最初のリードSW上に重ねて設置し、同時に磁力で閉じさせる。これによって12F629のGP0 (Pin7)がL (0V)からH (3V)に変わる。この変化をプログラムで捕らえてLED (R)を点灯させ、電子ブザーを鳴らさせる。ガス元栓が開いている限り、この警告はほぼ1分間隔で繰り返し続く。システムの電流消費を調べてみた。ガス元栓が閉じている状態(2個のリードSWが開いている)では電源が入っていないので電流消費はゼロ、ガス元栓が開いている状態、つまり2個のリードSWが磁力で閉じている時は1.09mA(点滅LEDとLED (G)が点灯)位、そしてLED (R)が点灯し、ブザーが鳴っている状態では最大2.6mA位に達する。ガスを使用する時間は日に15分ほど、殆どの時間はガス元栓が閉じた状態なので1日の電流消費はほんの僅かと考えられる。 したがって、ボタン電池(CR2032、220mAh)で充分実用になりそう。下の写真のように一応予備実験で使った単三アルカリ電池用の端子は残して置いた。2個のリードSWが閉じている時はLED (G)が点灯し、点滅LEDが赤く点滅してが警報器が動作していることを知らせてくれる。リセットSWは暴走時のために設置した。

 

プラスチックケース(L70XW46XH20mm)に組込んだ回路、電源は3Vのボタン電池1個、上方に2本重ねたリードSWが見える。右側の端子は予備実験で使った単三電池用、後で使用するかもと残した。

 

ガス元栓の外縁部に貼り付けた磁石(ここでは見えない)と対面する2本重ねたリードSW。リードSWを少しづつ動かしながら点滅LEDが安定して点灯する位置を探し、固定する。この位置合わせは結構微妙。間隔は5mmほど。

 

左が2本重ねた長さ15mmのリードSW、これらが外部からの磁力で電気的に接続する。2個のリードSW中のリード(金属片)の向きは互い同じになるように重ねる。右が直径7mmの永久磁石で回転するガス元栓の外縁部にテープで貼り付け。

 

参考資料(マニュアルよりコピー) 強磁性体リードと外部からの磁石(磁力)との作用が動作のポイント。外部磁石によってリードの両端がS-N、N-Sなどと磁化され内部接点が引合って接続する。

 

結果&コメント

1)     正常に動作することが確認された。ただ、1度ブザーが鳴り続ける誤動作が起こった。理由は不明、リセットSWで復帰させた。

2)     リードSWをもう1個使って、電源SWとして動作させることを思いついた(後日、2月26日)。これでガス元栓を閉じてる時の電流消費をゼロにすることが出来た。これは大きい。煩わしい割込みが必要なくなった。

3)     したがって、ボタン電池(CR2032、220mAh)で充分持ちそうである。

4)     リードSWの磁石による開閉は対面させる角度、距離などが微妙で、実際に点滅LEDの点滅を観察しながらセットすることが必要

5)     リードSWを1個使う前の状況(待機時(ガス元栓が閉じている)の電池の電流消費が0.54mAほどあり、@sleepを使う割込み操作でもっと下げようとしたが、この時点でロジックが思いつかない。それでも単三アルカリ電池2本で5ヶ月間ほど持ちそうである。)

6)     点滅LEDは22Kの大きい抵抗を電流消費を下げる目的で入れても、その赤色の点滅がしっかり可視できる。動作中(リードSWが閉じている)は点滅が続くので、これでシステムが正常に動いていることが確認できる。

7)     今回使用したリードSWに関し調べて見ると結構興味深い電子工作向きの部品であることが分かった。いろんな種類(感温リードSWなど)や使い方があるようだ(2014.3.6)。

8)     制作費は500円ほど。

 

プログラム

  プログラムの流れは簡単である。このプログラムでは、ガス元栓が開けられ、リードSWが磁力で閉じたのを検知してから、ほぼ1分間待ち、次いでLED(R)を点灯させながら、ブザーを100mS間隔で10回鳴らす。このルーチンはリードSWが閉じられている間繰り返される。ガス元栓が閉じられ、リードSWが開くとWaitLoopに入ってガス元栓が再び開かれるのを待つ。プログラムのフローチャートを下に示す。

'********************************************

'GasvalveAlarmBuz.bas 2014.2.21 Works OK!

'Electronic buzzer used.

'************** Pin connection **********************

'12F629, 4MHz Internal Clock used

'Pin 1: Vdd (5.0V)

'Pin 8: Vss (GND)

'Pin 3: GPIO.4: output- to buzzer

'Pin 4: GPIO.3: input - to MCLR via 10K resistor

'Pin 6: GPIO.1: output - to LED (R)

'Pin 7: GPIO.0: input - from reed SW

'Pin 2: GPIO.5: NC

'Pin 5: GPIO.2: NC

'*************** Main program ***********************

CMCON=7  'Comparator off

TRISIO=%001001  'all except GP3 and GP0 are outputs.

 

ReedSW var GPIO.0

Buzzer var GPIO.4

LED var GPIO.1

m var byte

 

Loop:

ReedSW=0

Buzzer=0

LED=0

 

WaitLoop:           ‘ここでリードSWが閉じられる(ガス元栓が開く)の待つ

If ReedSW=1 Then

Goto Timer

Else

Goto WaitLoop

Endif

 

Timer           ‘ここで1分間時間をつぶす:

For m=1 to 60

Pause 1000  '1 sec

Next m

High LED        ‘LED(R)を点灯 

Gosub BuzzerON   ‘BuzzerONへ飛んでブザーを鳴らす

Goto Final

 

BuzzerON        ‘BuzzerONルーチンで100mS間隔で10回鳴らす:

For m=1 to 10

High Buzzer

Pause 100

Low Buzzer

Pause 100

Next m

Return

 

Final:

LOW LED   ‘LED(R)を消灯   

Goto Loop   ‘Loopに戻る

End

'*******End of program*************

'Note:

   'melabs U2 Programmer's configurations for 12F629:

   'Oscillator - INTOSC; WDTE – Eable; PWRTE - Disable

   'MCLR - Reset ; BODEN - Enable; CD - Disable; CDP – Disable

 

 

改良、簡易化したガス元栓閉め忘れ警報器(2014.3.19)

. 上記で製作した警報器を使っている内に不必要な部分が出てきたので、それらを省き簡易化した。2個重ねたリードSWを1個にし、リセットSWも除いた。電子ブザーと点滅LEDでガス元栓が開いていることを知らせるだけにした。結局12F629をブザーが鳴る時間を遅らす目的だけに使うことになった。後になってガスの元栓は2個あり、比較的安全と思われるガスコンロにつながるもう一方の元栓の締め忘れ時もブザー音が出るようにするため、もう一個のリードSWを回路に加えた(図の右上の点線で示した部分 2014.4.30)。

 

実験中(元栓1個の場合、2個以上の場合もリードSWを簡単に増やせる)

 

プログラム

  不要になった部分を前のプログラム(GasvalveAlarmBuz.bas)から除き、ブザーの音声発生モードを400mS間隔で10回(合計4sec) 繰返す様に変えた。

'********************************************

'GasvalveAlarmBuzSimle.bas 2014.3.19 Works OK!

'Electronic buzzer used.

'************** Pin connection **********************

'12F629, 4MHz Internal Clock used

'Pin 1: Vdd (5.0V)

'Pin 8: Vss (GND)

'Pin 3: GPIO.4: output- to buzzer

'Pin 4: GPIO.3: input - to MCLR via 10K resistor

'Pin 6: GPIO.1: NC

'Pin 7: GPIO.0: input (+3V)

'Pin 2: GPIO.5: NC

'Pin 5: GPIO.2: NC

'*************** Main program ***********************

CMCON=7  'Comparator off

TRISIO=%001001  'all except GP3 and GP0 are outputs.

 

ReedSW var GPIO.0

Buzzer var GPIO.4

m var byte

 

Loop:

ReedSW=0

Buzzer=0

 

WaitLoop:

If ReedSW=1 Then

Goto Timer

Else

Goto WaitLoop

Endif

 

Timer:

For m=1 to 60

Pause 1000  '1 sec

Next m

Gosub BuzzerON

Goto Final

 

BuzzerON:

For m=1 to 10

High Buzzer

Pause 200

Low Buzzer

Pause 200

Next m

Return

 

Final:

Goto Loop

End

'*******End of program*************

 

Gas-Tap Open Alarm with Flashing LED and Buzzer Sound (English version of the above Electronics Project 71 in Japanese)

  I made this gadget, which can inform me with flashing LED and buzzer sound that the gas tap is kept open to supply or be ready to supply the gas to my old instantaneous water heater installed in the kitchen. Because the heater is old fashioned and not equipped with sufficient safety devices, I need to pay utmost attention to its handling. So whenever it is not in use, especially before going to bed, I want to make sure that the gas tap is shut off. If the gas tap is still open even after the use of heater ends, I can know it with flashing LED and buzzer sound.

 

Circuit Diagram.

  As shown below, in this system a permanent magnet (7mm in outer diameter) and two reed switches (SW, 15mm long, normally open and close when magnetic force applied) are used to sense the opening and closure of the gas tap. That is, the magnet is attached to the outer surface of the gas tap in such a way that when the gas tap is opened the magnet comes close (about 5 mm) to the position of a unit of the two reed SWs, in which one reed SW is directly connected to the 3V coin battery (working as power switch) and the other connected to GP0 of 12F629 (changing the state of GP0 from L (0V) to H (3V) when magnetic force is applied). When the magnet comes close to the unit of two reed SWs by turning the gas tap by 90 degrees, both the reed SWs are electrically connected and the power supply to 12F629 starts, sending H (3V) signal to its GP0 port and implementing the program sequence. I measured the power consumption. When the gas tap is closed, the power consumption of the system is zero because the reed SWs are electrically disconnected. When the gas tap is opened, the power consumption is about 1.09mA that is consumed by flashing LED, LED (G) and 12F629. And when flashing LED, LED (G), 12F629, LED (R) and the buzzer are functioning, the power consumption increases up to 2.6mA. Buzzer beeps for about 1 second every minute. Judging from these figures, a 3V lithium coin battery (CR2032, 220mAh) is considered sufficient for diving this system for at least a couple of months.

 

The circuit is assembled and packed in a plastic case (L70XW46XH20mm). Reed SWs unit is seen in the upper section. The connector in the right hand is for backup AA batteries which were used in the preliminary experiment. The yellow button is for resetting the program in case the system is out of control.

 

The alarm system is installed around the gas tap (black-colored one). At the present gas-tap position the permanent magnet is facing two reed SWs, so that LED (G) lights up and flashing LED blinks. This facing adjustment & fixing job between the magnet and two reed SWs is delicate and it must be fixed firmly at the right position while watching the continuous blinking of flashing LED as an indicator.

 

The photo on the left shows the unit of two reed SWs (one on the top of the other), in which each reed SW has two reeds – frontal and rear reeds in its glass tube. When two reed SWs are piled up like the photo below, the frontal reeds of both reed SWs must be positioned on the same side. This is important because the opening and closure of reeds of both reed SWs need to take place at the same time when magnetic force is applied. The photo on the right shows a small but powerful permanent magnet with an outer diameter of 7mm.

 

Program

  In the program, after the level at GP0 changes from Low (0V) to High (3V) as a result of the closure of two reed SWs by magnetic force, the continuous lighting of LED (G) and flashing LED begins, followed by the 1-minute wait sequence (doing nothing). Then, the buzzer beeps 10 times with an interval of 200mS and LED (R) lights up for about 1 second. This routine lasts as long as two reed SWs are closed. A simple program flowchart is shown below.

'********************************************

'GasvalveAlarmBuz.bas 2014.2.21 Works OK!

'Electronic buzzer used.

'************** Pin connection **********************

'12F629, 4MHz Internal Clock used

'Pin 1: Vdd (5.0V)

'Pin 8: Vss (GND)

'Pin 3: GPIO.4: output- to buzzer

'Pin 4: GPIO.3: input - to MCLR via 10K resistor

'Pin 6: GPIO.1: output - to LED (R)

'Pin 7: GPIO.0: input - from reed SW

'Pin 2: GPIO.5: NC

'Pin 5: GPIO.2: NC

'*************** Main program ***********************

CMCON=7  'Comparator off

TRISIO=%001001  'all except GP3 and GP0 are outputs.

 

ReedSW var GPIO.0

Buzzer var GPIO.4

LED var GPIO.1

m var byte

 

Loop:

ReedSW=0

Buzzer=0

LED=0

 

WaitLoop:     'Wait until the closure of two reed SWs

If ReedSW=1 Then

Goto Timer

Else

Goto WaitLoop

Endif

 

Timer:       '1-minute timer

For m=1 to 60

Pause 1000  '1 sec

Next m

High LED

Gosub BuzzerON

Goto Final

 

BuzzerON:    'Buzzer beeping subroutine, 10 times at interval of 100mS

For m=1 to 10

High Buzzer

Pause 100

Low Buzzer

Pause 100

Next m

Return

 

Final:

Low LED

Goto Loop

End

'*******End of program*************

'Note:

   'melabs U2 Programmer's configurations for 12F629:

   'Oscillator - INTOSC; WDTE – Enable; PWRTE - Disable

   'MCLR - Reset ; BODEN - Enable; CD - Disable; CDP – Disable

.

Conclusions and comments

1)       It works well. You can know with both flashing LED and buzzer sound that the gas tap is open.

2)       The most important feature of this system is that the power consumption is zero when the gas tap is closed, making it possible to use a single 3V coin battery for diving the system.

3)       Idea to use two reed SWs and a permanent magnet for tuning on the power switch of system and starting the program sequence was the key factor.

4)       The total cost of components was approximately 500 yen.

 

 

Gas-Tap Open Alarm with Flashing LED and Buzzer Sound – Simpler version (modified from the previous version 2014.3.19)

  After several weeks'use of the above-mentioned device, it was found that a device based on a new simpler circuit as shown below virtually could do the same job. The new circuit uses one reed SW instead of two, and only an electronic buzzer and a flashing LED to indicate that the gas tap is open.

 

Program

  The program became slightly simpler. This time, the buzzer beeps 10 times at an interval of 400 mS after about 60-seconds wait.

'********************************************

'GasvalveAlarmBuzSimle.bas 2014.3.19 Works OK!

'Electronic buzzer used.

'************** Pin connection **********************

'12F629, 4MHz Internal Clock used

'Pin 1: Vdd (5.0V)

'Pin 8: Vss (GND)

'Pin 3: GPIO.4: output- to buzzer

'Pin 4: GPIO.3: input - to MCLR via 10K resistor

'Pin 6: GPIO.1: NC

'Pin 7: GPIO.0: input (+3V)

'Pin 2: GPIO.5: NC

'Pin 5: GPIO.2: NC

'*************** Main program ***********************

CMCON=7  'Comparator off

TRISIO=%001001  'all except GP3 and GP0 are outputs.

 

ReedSW var GPIO.0

Buzzer var GPIO.4

m var byte

 

Loop:

ReedSW=0

Buzzer=0

 

WaitLoop:

If ReedSW=1 Then

Goto Timer

Else

Goto WaitLoop

Endif

 

Timer:

For m=1 to 60

Pause 1000  '1 sec

Next m

Gosub BuzzerON

Goto Final

 

BuzzerON:

For m=1 to 10

High Buzzer

Pause 200

Low Buzzer

Pause 200

Next m

Return

 

Final:

Goto Loop

End

'*******End of program*************

 

Menu Pageへ戻る

Topへ戻る