電子工作119 – 光を検知してAC100V機器をON/OFFさせる光タイマースイッチの製作

Electronics Project 119 – Optical Timer Switch For Turning ON/OFF AC100V Appliances By Sensing Input Light

 

概要    Introduction

   よくこの値段で販売出来るなあ、という電気製品の小物にやたら興味があって、気づいたら2個、3個と同じものを買いだめしてしまうことがよくある。今回はそんな中に、秋月電子のLED人感センサーライト」250円と、ダイソーの「リモコンライト」300円がある。前者は人が近づくと内蔵の人感センサーが動きを検知して、2個のLEDライトを20秒間点灯させるもので、普通人感センサー単体だけでもこの値段では買えない。一方、後者の「リモコンライト」は、付属のリモコンで最大5m離れたライト本体を光らせることができ、4段階調光、4段階タイマー付きと多機能で驚くほどコスパが高い。ただ、両者ともライトの電源は単4電池3本なので明るさは限定的。そこで今回、これら2個のライトの発する光を検知してAC100Vで動作し、LED電球を含めた電気製品を動かせる、3種のタイマーを組込んだ光検知アダプタ「光タイマースイッチ」を製作してみることにした

 

Recently I found two interesting electrical items. One is iEye LED Light that can sense the motion of human and turn on its LED lights. The other is Remote Controlled Light that is composed of a remote controller and an IR-receiving light-emitting body. It can change the strength of light in 4 stages and is equipped with 4 changeable timers. They are very bargain, respectively priced at 250 yen and 300 yen. However, the strength and lighting time of light emitted from both the items are limited because they use three AAA batteries. So, I built an optical timer switch equipped with 3 internal timers, capable of driving AC100V electrical appliances by sensing the lights from these two items and some other sources.

 

 

回路図    Circuit Diagram

 以下に「光タイマースイッチ」の回路図を示す。電源はUSB5V、光の検知にはCdSセンサーを使う。AC100V入出力は機械式リレーで行う。タイマーの設定は3接点スライドスイッチが担当。そして、マイクロコントロ−ラ12F629が全体を制御する。LED人感センサーライト(または、リモコンライト)からの光がCdSセンサーを通して、発光している時はデジタルL(0、約1.0V以下)、そうでない時はデジタルH(1、約4.0V以上)としてGP0から12F629の中に読込まれる。 タイマー設定5、15、30分は3接点スライドスイッチから読込まれ、プログラムの中で処理されてリレーのON/OFF出力どなる。なお、CdSセンサーの感度はボリュームVR=20Kで調整する。機械式リレーをより簡便なSSR(Solid State Relay)の代わりに用いた理由は、例えば、SSR使用してAC100VのLEDランプを点灯させようとすると動作が不安定になることがあるためである。

 

As shown in the circuit diagram Fig. 1, USB 5V powers the entire system. The CdS sensor takes in the light emitted from iEye LED Light or Remote Controlled Light, and puts it into 12F629 through GP0. When the light is in full strength, the voltage at GP0 is below approx. 1.0V or digital L. Meanwhile, when there is no input light, the voltage at GP0 is over approx. 4.0V or digital H. The program reads this L/H difference to examine if the light is entering the CdS sensor or not. The selection of 3 software timers is achieved by adjusting 3-contact Slide Switch. A mechanical relay instead of SSR (Solid State Relay) is used for driving AC100V appliances because SSR often does not work properly with some appliance such as LED lamp.

 

Fig. 1

 

 

Photo 1

完成した光タイマースイッチ、黒い縦長のものがリレー。

Completed Optical Timer Switch.

 

 

Photo 2

光タイマースイッチ基板の下方に光発生源となるLED人感センサーライトリモコンライトが設置されている。 二つのライトのほぼ中央に垂れ下がっているのはCdSセンサーで、この位置で両者の光を検知出来る。現在LED人感センサーライトは点灯中である。右上の黒いものはUSB5Vアダプタ電源である。

The Optical Timer Switch is now in workable state. Two light sources (iEye LED Light and Remote Controlled Light) are installed on the lower part of the wood plate. A 2-wire cable of which tip is CdS sensor is placed over between the two light sources so that the sensor can catch the light from both the light sources.

.

 

 

Photo 3

左がLED人感センサーライト、本体の中央に人感センサー、左右にLEDライト、下の小さい黒い部分に、周りの明るさを測るCdSセンサーが組込まれている。単4電池3本内臓、周りが薄暗い/暗い状態で、人が近づいて動くと20秒間LEDが点灯する。一方、右側はリモコンライトのセットである。輝度調整、タイマー付きの多機能リモコン(右側)のONボタンをライト本体に向けて押すと点灯し、他にもいろんな機能が使える。今回は光タイマースイッチを動かすのが目的なので、リモコンのONを押してライト本体を点灯させ、光タイマースイッチが動作したら、リモコンのOFFを押してライト本体を消灯させる。リモコンの赤外線ビームはライト本体の裏面以外のどの部分に照射しても反応するようだ。

The left photo shows iEye LED Light. A round bulge in the center is the motion sensor, two LEDs are positioned both sides of the bulge. In the small black opening, installed is a CdS sensor for sensing the surrounding brightness. The right photo shows Remote Controlled Light, composed of a remote controller and an IR-receiving light-emitting body.

 

 

Photo 4

左が今回使ったCdSセンサーで、直径5mm、型番MI527/MI5527, 明抵抗10−20K (10Lux時)、暗抵抗1M。一方、右が機械式リレー、DC5Vで動作し、5A 250Vまで使用可。

The photo shows CdS sensor used (left); diameter 5mm, bright resistance 10-20K (under 10 Lux), dark resistance 1M. The right item is a mechanical relay with Input DC5V and Output 5A AC250V.

 

 

プログラム    Program

 周辺の光の強さに応じてCdSセンサーから12F629のピンGP0に入ってくるデジタル値は明るい時はL(0、<約1.0V)、周りが暗いと時はH(1、>約4.0V)と見なされる。さらに、5,15,30分タイマーのため、スライドスイッチのピン位置情報が取り込まれ、プログラムの中で3種のタイマーが動作する。各タイマーの設定値と実測地値は、5分―>5分4秒、15分―>15分11秒、30分―>30分21秒 で、大体、2%未満のエラーだった。プログラムの流れは、CdSセンサーが光を検知すると、GP0 Lが入る、するとIf CdSIn=0 Then Goto Loop1Loop1に飛び、その中で、スライドスイッチの位置に応じて各タイムルーチンに飛んで所定の時間を費やす、終了後LoopCdSに戻ってGP0からの新しいデジタルL信号の入力を待つ。

 

First, the program examines if the signal from CdS sensor arrived at GP0 of 12F629 is L (0, below approx.1.0V) or H (1, over approx.4.0V). If it is L, then the program checks the position of Slide Switch for three software timers (5, 15, 30 min). After the individual timer executed its timer routine, it returns to LoopCdS for waiting the arrival of a new L signal. While each timer routine is being executed, the relay stays in ON position, driving an AC100V appliance. The accuracy of these software timers is found to be about 98%.

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

'Motionsensor100VCdSp.pbp. 2020.10.112 works OK!                                 

'Using 12F629 and PicBasic Pro V3.1                                      

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

'Pin 1: Vdd (5V) - USB adaptor

'Pin 8: Vss (GND)

'Pin 7: GPIO.0 - Input CdS light via divider

'Pin 6: GPIO.1 - Input 30-min timer (S.SW3)

'Pin 5: GPIO.2 - Output Relay drive for AC100V devices

'Pin 4: GPIO.3 - Input for Reset

'Pin 3: GPIO.4 - Input 15-min timer (S.SW2)

'Pin 2: GPIO.5 - Input 5-min timer  (S.SW1)

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

CdSIn var GPIO.0

RelayOut var GPIO.2

T5minIn var GPIO.5

T15minIn var GPIO.4

T30minIn var GPIO.1

TRISIO=%111011

CMCON=7  'Comparator disabled

 

m var Byte

n var Byte

 

LoopCdS:

RelayOut=0                   'Check if CdSIn is 0 or 1

If CdSIn=0 Then Goto Loop1

Goto LoopCdS

 

Loop1: 'Check the position of Slide Switch

If T5minIn=0 Then Goto Timer5min

If T15minIn=0 Then Goto Timer15min

If T30minIn=0 Then Goto Timer30min

Goto LoopCdS

 

Timer5min: '5-min waiting routine

High RelayOut

For m=1 to 5

Gosub Timer1minunit

Next

Low RelayOut

Pause 300  'Time allowance for the next execution

Goto LoopCdS

 

Timer15min: '15-min waiting routine

High RelayOut

For m=1 to 15

Gosub Timer1minunit

Next

Low RelayOut

Pause 300

Goto LoopCdS

 

Timer30min: '30-min waiting routine

High RelayOut

For m=1 to 30

Gosub Timer1minunit

Next

Low RelayOut

Pause 300

Goto LoopCdS

 

Timer1minunit: '1-min waiting subroutine

For n=1 to 65  '65 - 20.10/1 experimentally decided,  'n' must be used here instead of 'm'

Pause 1000  '1 sec

Next

Return

 

End

 

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

'Note:

'melabs U2 Programmer's configurations for 12F629:

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

'Under PicBasic Pro 3.1, 'Loop' cannot be used. Use 'Loop1' or other form.

 

 

コメント      Comments

1)    機械式リレーと違って、SSRを使った場合、SSRがOFFの状態でも、接続したAC100VLED電球のあるものは点滅を繰り返す現象が起きる。

2)    この光タイマースイッチは、他のいろんな光を発する装置のスイッチに使える。

3)    今回のソフトウエアタイマーの数は3個だが、ピン数の多いPICを使えば、プログラム上でタイマーの数をいくらでも増やせる。

 

 

Menu Pageへ戻る   (Return to Menu Page)

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