電子工作104 – USB扇風機用の3-スピードリモコンの製作

Electronics Project 104 – 3-Speed IR Remote Controller for USB Fan

 

 

概要   Introduction

   また、暑い季節がやって来た。今回は街に200−500円位の価格で出回っているUSB扇風機の回転速度を赤外線リモコンで3段階にコントロールする装置を製作してみることにした。

Hot and humid summer has come again. This time, I tried to make a 3-speed controller for inexpensive USB fans using Infrared Remote Control ICs.

 

回路図   Circuit Diagram

このプロジェクトでは、赤外線信号の送受信に専用のICを使ったのが大きな特徴である。すなわち、Fig. 1の送信回路にPT2262-IRを、Fig. 2の受信回路にSC2272-L4を使った。Fig. 1の送信回路でPT2262-IRに接続した4個の入力スイッチSW1- SW4 (SW1は停止、SW2、SW3、SW4の順に回転速度が上がる)のいずれかを押すと、対応するIC本体のD3 - D0のいずれかに電流が流れ、赤外線LEDから赤外線ビームが発射される。このビームをFig. 2の受信モジュールが受取り、SC2272-L4の4個のLEDs(色Y、R、R、R)の内、送られて来た信号に対応する1個が点灯する。このICはL4が示すようにLatchといって4個の内の1個だけが常時選択されるもので、例えば、送信側のSW1を押すと、受信側のLED(Y)が点灯し、次いでSW2を押すと、LED(Y)のすぐ上のLED(R)が点灯し、LED(Y)は消灯する。LEDが点灯しているD3 - D0の内の1つの信号が12F629のGP4、GP2、GP1、GP0のいずれかに‘H’信号として取り込まれ、プログラムの中で処理されて、GP5から停止信号や3つのPWM信号としてMosfetを経由してUSB扇風機に送られ駆動される。

 

As shown in Fig. 1  and Fig. 2,  two IR Remote Control ICs PT2262-IR and SC2272-L4 are used for the simplification of system. In Fig. 1 (IR Signal Transmitter), four input switches SW1, SW2, SW3, SW4 are connected to D3, D2, D1, and D0 of PT2262-IR via diodes. When any of these four SWs is pressed, power (6V) is supplied to the IC and the corresponding Dx pin, producing an Infrared LED signal for IR Signal Receiver. This IC is also addressable by connecting A0 - A7 to H(6V here), L(0V) or leaving these pins floating (that is, not connecting to H or L).  This time, I selected 'Floating' to simplify wiring.  The combined use of H, L, Floating states can produce a large numbers of addresses. In Fig. 2 (IR Signal Receiver), meanwhile, when a SW input signal from Transmitter side is received by IR Receiver Module, one of 4 LEDs Y (SW1), R (SW2), R (SW3), R (SW4) lights up.  The uppermost LED (G: green) lights up while any of the above-mentioned four SWs is kept pressed. This SC2272-L4 is also addressable like PT2262-IR, and the address of both ICs must be the same. This time, 'Floating' mode (or not connecting to H or L) is chosen for SC2272-L4. The same DC5V from USB AC adaptor is supplied to SC2272-L4, 12F629 and USB fan. When the power SW is turned on for the first time, none of 5 LEDs lights up. Here, if SW1 in IR Signal Transmitter is pressed, LED(Y) – D3 lights up but the fan does not revolve. Pressing SW2 turns off LED(Y) – D3 and turns on LED(R) - D2. Similarly, pressing SW3 turns off LED(R) - D2 and turns on LED(Y) - D1. Finally, pressing SW4 turns off LED(R) – D1 and turns on LED(Y) – D0. At this stage, SW1works as stop switch, that is, pressing SW1 stops the fan revolving at any of the three speeds, turning on LED(Y). A 3.3uF capacitor will reduce the adverse effects by the fan.

 

Fig. 1

 送信側の回路図    IR Signal Transmitter

電源には3Vのコイン電池2個(計6V)を用いた。電源5V時に測定したシステムの消費電流は待機時0.1uA以下、SWを押している時約6.5mAで、コイン電池で充分持つことが分かった。電池の節約目的で、いずれかの入力SWを押した後の電源SW切り忘れ防止ため点滅LEDを組込んだ。このシステムはSWを押して、はじめてPT2262-IRに電流が流れるように出来ている。

 

 

Fig.1a (2020.4.23改良)

改良版送信側の回路図(電源SW除去):常時電源ONの設定になり、いずれかのSWを押さない時の電流消費は0.1uA(マイクロ)以下、1個のSWを押した時15mAである。従って、電池(220mAh)は1年以上持つはず。

   Modified IR Signal Transmitter (2020.4.23 without power SW): When none of 4

SWs is pressed, power consumption is found to be less than 0.1uA (micro ampere), while pressing one SW at a time consumes about 15mA. Therefore, two batteries (3Vx2, 220mAh) should last more than one year.

 

Fig. 2

受信側の回路図    IR Signal Receiver

外付電源のDC5VUSBアダプタから、SC2272-L4、12F629とUSB扇風機に電流が供給される。図の中で5個のLEDが上から、G(緑)、R(赤)、R、R、Y(黄)と並んでいるが、この受信部の電源SWをはじめてONにすると、5個のLEDsは全て消灯している。送信側のSW1- SW4のいずれかを押して信号を送ると対応するLEDが1個だけ点灯する。例えば、SW1を押すとLED(Y)だけが点灯し、扇風機は回転しない。SW2を押すと、LED(Y)が消灯して、図中の下から2番目のLED(R)が点灯し、一番遅い速度で扇風機が回る。SW3を押すと、下から3番目のLED(R)だけが点灯し、中間の速度で扇風機が回る。そして、SW4を押すと、下から4番目のLED(R)だけが点灯し、最速で扇風機が回る。停止させるにはSW1を押す、同時にLED(Y)が点灯する。いずれかのSWを押している間、一番上のLED(G)は点灯する。扇風機のモーターからのノイズの影響を避けるため、3.3uFのコンデンサを入れた。

 

Fig. 3

 実験に使ったブレッドボード、右が送信用、左が受信用である。

Under experiment, the right board is for IR signal transmission while the left one for IR signal reception.

 

Fig. 4

 完成した赤外線送信ボード。右端の4個のSW(スイッチ)は、下からSW1,SW2、SW3、SW4である。ボタン電池は3Vを2個重ねて用いている。左端中央部に赤外線LEDが見える。中央部に見える18ピンのICはPT2262-IR。その下にあるのがスライド式電源SWである。

The completed IR Signal Transmission Board; I used two button cells (3Vx2=6V) so as to cover distance. You can see 4 push buttons (SW1-SW4), 18-pin PT2262-IR, a small slide power SW, two transistors, and IR LED in the leftmost part of the board. To save power consumption, a blinking LED is installed, which keeps blinking while the power SW is ON.

 

Fig. 4a (2020.4.23改良)

改良版赤外線送信ボード: 上の写真と比べて分かるように、基板の下方中央部にあった電源スイッチ(SW)と点滅式LEDが除かれている。この回路に常時電流を流しても、その消費が極わずかなことが分かったためである。

Modified IR Signal Transmission Board: Both Power SW and LED installed in the center of the bottom of Fig. 4 are removed as the power consumption is extremely low even in the always-powering-on state.

 

Fig. 5

完成した赤外線受信ボード。左上部の青色のターミナルブロックに外部のUSB ACアダプターからDC5Vが供給される。その右が電源SW。中央部に並んでいる2個のICsは左の8ピンのものが12F629、右の18ピンのものがSC2272-L4である。その上にMosfetが見える。中央部の右端にはUSBコネクタ(Aタイプ、メス)が見える。ここからUSBケーブルでUSB扇風機につながる。5個のLEDsの中で、左端から色別でY、R、R、R、Gと並んでいるが、送信側のSW1、SW2、SW3、SW4にそれぞれ対応する。5番目のG(Green)のLEDは送信側の4つのSWのいずれかが押されている間点灯する。

The completed IR Signal Receiver Board; The power (DC5V from USB AC adaptor) is supplied to the Terminal Bloch that is connected to Power SW, from which the power is supplied to 8-pin 12F629 and 18-pin SC2272-L4. Five LEDs from the left to right: Y(SW1) are R(SW2), R(SW3), R(SW4) and G(SW pressing indicator). You can see IR receiver module on the lower left side of Board.

 

Fig. 6

上の受信ボードの裏側。配線の様子が分かる。これぐらいの規模だと誤配線を1ヶ所くらいしてしまう。ICsを壊すのが怖いので、ICsを挿す前にテスターで配線を充分チェックした。

The backside of IR Receiver Board. Pardon me for my messy wiring.

 

Fig. 7

以下に示すような組み合わせで使う。このUSB扇風機はDC5Vで、電流は最大で0.5A位流れる。受信ボードのMosfetの容量は大きいので、ヒートシンクを付ければ5V、2A位のUSB扇風機も回せると思われる。また、赤外線受信ボードのUSBコネクタ(Aタイプ、メス)にUSB二又コネクタを付ければ、扇風機を同時に2台使用出来る(実験済み)。

The two completed transmission and receiver boards are used together with a USB fan like shown below, which works with DC5V while consuming normally 0.3 to 0.5 A.  Because the capacity of the Mosfet is claimed to be 25A (at 60V), more powerful USB fans can be used. It is possible to use more than one USB fan if a multi-terminal connector is used. Using a bifurcated USB connector I made, I succeed in running two USB fans at the same time.

 

 

材料     Components and cost

1)   PT2262-IR ¥100、 SC2272-L4 ¥100、12F629 ¥100、 Mosfet ¥100、 USBコネクタ ¥120、 受信モジュール ¥100、 その他基板、スイッチ、LEDsなど含め合計¥1500以下。

Total cost of components etc. was a little less than 1500 yen.

 

結果&コメント  Comment

1)     結構大変だったが、何とか動作するようになった。

2)     入力SW数を4個以上にしたかったが、PT-2272-L6など国内では入手出来ても割高。

3)     送受信のアドレス設定が簡単なのが良い。

4)     2020.4.23に改良版の送信器回路とその基板の写真を新たに加えたFig.1a とFig. 4aである。4つのSWを押す時、いちいち電源SWを入れるのが面倒なので、常時電源ONの状態で、どれぐらい電流が消費されているか計ってみたら、0.1uAか、それ以下。驚いて早速常時ONにする改良にかかった。このICの省エネ設計の良さに感心させられる。それと、電子工作112から115までの省エネプロジェクトがきっかけとなった。

 

 

プログラム   Program

 プログラムの概要: 入力スイッチSW1、SW2、SW3、SW4に対応する12F629のGP4、GP2、GP1、GP0の4つピンの状態がが‘H’(5V)になっているか、’L’(0V)になっているかを調べる。そこで、あるピンが‘H’ならば、それに対応するルーチンに飛び、出力するPWMパルスの形を決め、GP5よりMosfetを駆動して、外付のUSB扇風機を動かす。プログラムのLoop – Goto Loopの中でジャンプ先が決まる。 入力がSW1の時は、ONOFFというルーチンに飛び、LED(Y)が点灯し、扇風機は回転しない状態でLoop – Goto Loop内との間をぐるぐる回る。SW2が押されると、LED(Y)は消え、PWM50というルーチンに飛び、一番遅い速度で扇風機を回す。供給電流が小さ過ぎて、扇風機が回転しない可能性があるので、サブルーチンを使って電流量を100ms間だけ上げてスムースに起動するようにしている。ルーチンPWM75(SW3)とPWM100(SW4)では、回転速度がPWM75<PWM100になる。プログラムの中で‘PWM GPIO.5,245,100’の意味は、Picbasic Proのユニークなコマンドを使っていて、GPIO5のポートから、Duty比 245(0が0%で、255が100%)のパルスを100回出力せよ、ということ。PICは4MHzで動いているので、cycle timeは5ms、従って、5x100=500ms長さのDuty比 245のパルスが繰返し出力されることになる。?

 

Outline of the program: Reading the 'H' or 'L' state of 4 pins - GP4, GP2, GP1 and GP0 of 12F629 that correspond to the entry of SW1, SW2, SW3, SW4 of IR Transmission Board, the program jumps to one of 4 different routines - ONOFF, PWM50, PWM75 and PWM100. TheONOFF routine takes care of turning off the fan when it is running at one of three speeds. PWM50, PWM75 and PWM100 routines are used for controlling the rotation speed of fan using Picbasic Pro's software command 'PWM'. The order (from slow to fast) of speed generated with them is PWM50 < PWM75 < PWM100. In PWM50, a kind of trick is applied to the routine for the smoother running of fan, that is, more current is supplied to the fan during the first 100ms because sometimes the fan does not start running even after SW1is pressed. In PWM100 (PWM GPIO.5,255,100), the supply power to the fan is the same as that when a DC5V USB AC adaptor is directly connected to the fan. 

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

'USBFanSpeedControllerA.bas  2018.6.13

'Using 12F629 and PicBasic Pro V2.50A

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

'Pin 1: Vdd(5V)

'Pin 8: Vss(GND)

'Pin 7: GPIO.0 - SW4 Input

'Pin 6: GPIO.1 - SW3 Input

'Pin 5: GPIO.2 - SW2 Input

'Pin 3: GPIO.4 - SW1 Input    SW=SW-Key Input

'Pin 4: GPIO.3 - Reset Input

'Pin 2: GPIO.5 - Mosfet Drive Output

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

CMCON=7  'Comparator off

SW1input var GPIO.4

SW2input var GPIO.2

SW3input var GPIO.1

SW4input var GPIO.0

MosfetDrv var GPIO.5

TRISIO=%011111

n var Byte

n=0

 

SW1input=1

Pause 2  '2 ms

SW2input=0

Pause 2

SW3input=0

Pause 2

SW4input=0

Pause 2

MosfetDrv=0

 

Loop:

If SW1input=1 Then Goto ONOFF

IF SW2input=1 Then Goto PWM50

IF SW3input=1 Then Goto PWM75

IF SW4input=1 Then Goto PWM100

Goto Loop

 

ONOFF:

Pause 10   '10 ms

Goto Loop

 

PWM100:

SW2input=0

SW3input=0

PWM GPIO.5,255,100

Goto Loop

 

PWM75:

SW2input=0

SW4input=0

PWM GPIO.5,245,100

Goto Loop

 

PWM50: 'For easier startup rotation of fan

SW3input=0

SW4input=0

n=n+1

If N=1 Then Gosub Startup

PWM GPIO.5,235,100

n=n+1

Goto Loop

 

Startup:   'Allowing 'GPIO.5,248,100' rotation for 100 ms

PWM GPIO.5,248,100

Pause 100  '0.1 sec

Return

 

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

 

 

Menu Pageへ戻る    (Return to Menu Page)

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

 

.