電子工作114 – 12F629の割込み機能を使う省エネLED防犯ライト

Electronics Project 114 – Flashing LED Warning Light Using Interrupt Function of 12F629

 

概要    Introduction

   今回のプロジェクトは前述の電子工作112の続きで、明暗の検知にソーラーパネルを用い、12F629の割込み機能を使って省エネをはかることが目的である。結果は、かなり難解な割込み設定がうまく出来、省エネにもある程度成功した。すなわち、日中の明るい時のこの装置の消費電流は1uA以下、夜間の暗い時の電流消費は0.5mA程度であった。したがって、3Vのリチウムボタン電池(容量220mAh)2個を並列につなげて用いると、計算では約2ヶ月間持つことになる。

 

In this project, my main aim is to use the interrupt function of 12F629 for saving battery power. The result is reasonably good; the power consumption of this device lowered to less than 1 uA (micro Ampere) in bright daytime and 0.5 mA in dark at night. Therefore, two lithium button batteries used in parallel (3V, 440mAh) will be able to drive the device for approximately two months.

 

 

回路図   Circuit Diagram

下図のように回路は電子工作112と同じだが、実機では電源に単3電池2本の代わりに、3Vのボタン電池2個を並列で用いている。ソーラーパネルからの入力電圧が約0.8V以下になる(夜間)と割込みがかかって組み込んだ7色LEDが点滅を始める。0.8V以上では(昼間)はプログラムの@Sleepコマンドで装置がスリープ状態になり、消費電流はほぼゼロになる。実はこうゆう結果を得ることが割込み機能の活用の目的であった。

 

The following circuit diagram is almost the same as one in the previous Electronics Project 112. However, the practical device shown below uses two lithium button batteries instead of two AA batteries. The interrupt function of 12F629 begins to work when the input voltage from Solar Panel falls around about 0.8V. That is, below 0.8V, the 7-color LED starts to flash, while above 0.8V there will be no LED flashing and the device enters into the sleep mode, consuming least battery power.

 

 

実験中

Experimenting of the system on breadboard

 

完成した実用機

Completed device with two button batteries suitable for practical use, compact and tidy.

 

使用した市販のボタン電池

Button battery used

 

コメント

1) 12F629のGP0から読込むソーラーパネルの入力電圧を、0.8V以下をデジタル値の0(L)に、それより大きい値をデジタル値1(H)と解釈しているらしい。

2)      今回のプロジェクトは電子工作84 ‘振動センサ’を元にしている。導通/非導通を行う振動スイッチを、単純に電圧変化を行うソーラーパネルに置き換えても割込み部分のプログラムがほぼそのまま使えることが分かった。

3)      夜間に7色点滅LED(直径3mm)が点灯する時、装置は約0.5mAの電流を消費する。このLEDを単独で10K抵抗を介して3Vで点滅させる時の電流消費はわずか70−80uAなので、4MHzで動いているプログラムの中でかなり電流が消費されていることが分かった。プログラムの工夫でもっと低電流消費を実現できるかも。

4)      このCoronavirus Pandemicで日本を含め世界中が大騒ぎしているので、外出出来ない、地下鉄乗って秋葉原に行けない、ので電子工作三昧の毎日だ。いろいろ再勉強させて貰っている感じ。

 

 

 プログラム    Program

12F629には割込み機能が入っている。目的は夜間にはLEDが点滅するが、昼間は非点滅になり、12F629システムを動かす電流を最小限に留めるということである。 プログラムで、コマンド@Sleep を割込みの中に入れて使うと、この目的が達成出来る。プログラムの流れは概ねこうである: ソーラーパネルのGP0への入力電圧が昼間の2.7−3Vから夜間になって0.V以下(digital L)になると、割込み(GPIOピンのレベル変化)がかかって、If SolarPnlIn=0 then FlashLEDへ飛びLEDの点滅が始まり、夜間中続く。明るくなって、ソーラーパネルからの電圧入力が0.8V以上(digital H)になると、また、割込みがかかって、@Sleepを読込んで、システム全体がスリープモードに入り、電流消費がほぼゼロになる。 Configuration設定で、WDT BODENDisableにすると、電流消費がちょっと良くなる感じがするが、不確か。ただ、両者Disableでも特に、動作に不都合は起きなかった。

 

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

'Purpose: Power saving using interrupt of 12F629  works OK!

'Name of program: 629Interrupttest.pbp                                    

'12F629 and PicBasic Pro 3.1 used.

'2020/4/10                                      

'Internal clock 4MHz used

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

'Pin 1: Vdd (3V) coin battery

'Pin 8: Vss (GND)

'Pin 7: GPIO.0 - Solar panel input

'Pin 6: GPIO.1 - LED light output

'Pin 4: GPIO.3 - Reset

'********Program************

SolarPnlIn var GPIO.0  'SolarPnlIn is 2.7-3V(H) in daytime, and below 0.8V (L) at night

LEDlamp var GPIO.1  LED output

 

TRISIO=%001001

CMCON=7  'Comparator not used, making all pins digital.

IOC.0=1    'Detect input at GPIO.0

INTCON.3=1  'Enable port input-level change interrupt

SleepLoop:

LEDlamp=0

INTCON.0=0  'Clear GPIF

@Sleep  'Assembler command, making the system sleep when there is no interrupt.

INTCON.0=0  'Clear GPIF

'*******Routine to activate the flash LED when an interrupt occurs********

FlashLEDLoop:

If SolarPnlIn=0 then FlashLED   '0 means dark at night where input voltage is below 0.8V.

Goto ReturnA

FlashLED:

High LEDlamp

Pause 500  '0.5 sec

Goto FlashLEDLoop

ReturnA:

Goto SleepLoop

'*****End of Program******

 

'Note:

'melabs U2 Programmer's configurations for 12F629:

'Oscillator - INTOSC, WDTE - Disable, PWRTE - Disable, MCLR - Reset, BODEN - Disable, CD - Disable, CDP - Disable

 

Menu Pageへ戻る     (Return to Menu Page)

Top of Pageへ戻る   (Return to Top of Page)