電子工作85 – 3キー入力赤外線リモートON/OFFシステムの製作

Electronics Project 85 – 3-Key Infrared Remote ON/OFF System (Transmitter & Receiver)

 

概要    Introduction

   リモコンで離れたところにある装置の電源などをON/OFFさせるシステムは電子工作70(送信入力キー1個)で既に製作した。今回は送信側の入力キーの数を3個に増やし、それでも電源が1個の3Vボタン電池で十分かどうか検討した。さらに送信側から発生する3つのパルスパッターンが受信側の3つのプログラムでそれぞれ正確に受信出来て互いに干渉しないかを調べた。結果は予想どおり良好に動作することが分かった。

 

This is a 3-key infrared remote control system capable of turning ON/OFF the power switches (through SSR) of three different kinds of electrical appliances. The 1-key IR remote control system has already been built and described in Electronics Project 70 ‘Simple Infrared Remote Switch’. The point of this project is to prove that the 3-key IR transmitter still can operate for a long period of time with a single 3V coin battery and the three synthesized pulse patterns don’t interfere with each other. The results are satisfactory, that is, the power consumption while waiting a key entry is almost less than 0.1uA and no interference among the three pulse patterns is observed.

 

回路図   Circuit Diagram

Fig. 1はIRパルスの送信器で入力キーがSW1、SW2、SW3であり、3Vボタン電池 (e.g. 220mAh) 1個で駆動する。割込みなどを使ってプログラムで極力電流を消費しないように工夫した。入力のない待機時の電流消費は0.1uA以下である。GP5も空いているのでもう1個の入力キーを増やせそう。 Fig.2は送信器から送られて来るパルスを受信する回路図で、実験のため各入力SWに対応して同じ回路を3個並べてある。したがって、実際には個々の回路を別々の基板に載せSW1、SW2、SW3に対応する受信プログラムを組み込んで使うことになる。各回路でGP1 (ピン6) に900ohmの抵抗を介してSSR (Solid State Relay) の内蔵LEDをドライブしてAC100V電気器具の電源のON/OFFなどを行う。

 

Fig.1 shows the IR transmitter circuit with three keys. The number of keys may be increased to four by utilizing the unused GP5. As already mentioned above, the use of a 3V coin battery (220mAh) is sufficient for driving this transmitter. The three IR receiver circuits shown in Fig. 2 are identical, but the individual IR receiver circuit has a different IR receiver program. That is, the SW1, SW2 and SW3 Circuits must have SW1, SW2 and SW3 Receiver Programs in their 12F683s, respectively.

 

(Fig.1)

 

 (Fig.2)

 

(Photo 1) ボード上に組上げた送信器回路

IR Transmitter assembled on breadboard: You can see 3 entry SWs, 12F683, IR LED, DC3V coin battery and 1815 transistor.

 

(Photo 2)  受信器回路; 同じ回路が3個並んでいて12F683にはそれぞれSW1、SW2、SW3用の受信プログラムが入っている。

The same three IR Receiver circuits are mounted on the breadboard for experimental purpose, each of which has SW1, SW2 or SW3 IR receiver program in its 12F683.

 

波形パターンの合成   Synthesizing Pulse Patterns

 

Fig 3−Fig 6の波形パターンはすべて受信器のIR Receiver Moduleの出力端子Outでオシロによって得られたものである。Fig 3は既製のリモコン(Funai RC-7)の"電源"キーを押した時に得られたもので、この24ビットのパルスパターン (0 ー 23)を基準として(似せて)ソフト的にFig 4、Fig 5、Fig 6 に示すSW1, SW2, SW3パルスパターンを作成した。Fig  4は基準のパルスパターンを模して作成したもの。Fig 5とFig 6では、それぞれFig 4の22と21番目のパルスを幅広パルス('1') から幅狭パルス('0')に変えて作成したものである。従って、SW1、SW2、SW3の間の差はわずかである。この3つのパルスパターン間の干渉が懸念されたが問題がなかった。

 

Fig. 3 is the standard pulse pattern generated by pressing `Dengen` key of an old remote controller (Funai RC-7) and measuring its output at Out pin of IR receiver module in IR Receiver circuit. Here, the pulses 0 – 23 (24 bits) are used for the differentiation among these three pulse patterns. The pulse pattern of Fig. 4 is formed by a program so as to be almost equal to that of Fig. 3. In the pulse patterns of Fig. 5 and Fig. 6,  the pulses No.22 and 21 are changed to the narrow pulse (`0`) from the wide pulse (`1`).

 

(Fig 3)

(Fig 4)

下は実際のリモコンのキー(Funai RC-7の電源キー)の出力パルスパターンを模してプログラム(SW1)で作成したパルスパターン

This pulse pattern is prepared by imitating the above pulses pattern (Fig 3) generated from `Dengen` key of Funai RC-7 using SW1 Transmission Routine (shown below).

 

(Fig 5)

このパルスパターンでは22番目のパルスだけを幅広パルス(‘1’)から幅狭パルス(‘0’)にプログラム(SW2)で変えてある

In this pulse pattern, the No. 22 pulse is changed to the narrow pulse (`0`) from the wide pulse (`1`) using SW2 Transmission Routine.

(Fig 6)

このパルスパターンでは21と22番目のパルスだけを幅広いもの(‘1’)から幅の狭いもの(‘0’)にプログラム(SW3)で変えてある

In this pulse pattern, the No. 21 and 22 pulses are changed to the narrow pulse (`0`) from the wide pulse (`1`) using SW3 Transmission Routine

 


結果とコメント

1)    3個の入力キーを備えたIR送信器で、3つの別々のIR受信器をON/OFF出来た。

2)    24ビットをフルに利用すれば、2の24乘で16777215の組合せが可能。1111 1111 1111 1111 1111 1111 (24 binary bits) = 16777215 (decimal)

3)    今回は3個ともmomentaryにしたがlatchにするのもそんなに難しくない。

4)    ボタン電池1個で、送信器の入力キーの数を1個以上に出来ることが分かったのは大きい。ピン数の多いPICを使えば本格的なリモコンも出来る。

5)    送信と受信のプログラムをもっとコンパクトにしたい。

6)    送信器のSW1に対応する受信実用機は電子工作70で既に製作済み。


Results and Comments

1)      This experiment proved that it was possible to increase the number of transmitter’s entry keys to more than one using a single 3V coin battery and there was no interference among the three pulse patterns despite the small difference among them.

2)     Theoretically, a 24-bit binary sequence can produce as many as 16777215 combinations.

3)     Pulse width: wide pulse=about 2.5ms, narrow pulse=about 0.7ms

 

 

送信プログラム   IR Transmitter Program

このプログラム(IRTransmitter12F683PWMb.bas)3個の入力SWに対応して3個の互いに異なるパルスパターンを作成し受信側に送信するためのものである。割込みを使ってボタン電池でも十分持つように省エネが図っていることや、38KHzの搬送波を使って雑音にも強くなっている。

 

This IR Transmitter Program (IRTransmitter12F683PWMb.bas) generates three different pulse patterns according to the key entry of SW1, SW2 and SW3. Using 12F683’s interrupt function, the power consumption is very low and also the use of carrier (38KHz) along with 24-bit pulse pattern makes the system more resistant to optical noises.

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

'IRTransmitter12F683PWMb.bas 2016.1.8 works!

'This produces a PWM-based remote-control command sequence.

'Use of @Sleep command

'12F683 with internal clock 4MHz

'Combined with PWMtestBB1.bas (2009.6.5 Eproj33)

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

'Pin 1: Vdd (3.0V)

'Pin 8: Vss (GND)

'Pin 7: GPIO.0: input SW1 - from Transmission SW (Port level change detect)

'Pin 6: GPIO.1: input SW2 - from Transmission SW (Port level change detect)

'Pin 5: GPIO.2: output - PWM output driving IRLED via Transistor 1815

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

'Pin 3: GPIO.4: input SW3 - from Transmission SW (Port level change detect)

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

CMCON0=7             'Comparator OFF (Note: not CMCON=7)

ANSEL=0              'All pin digital

SW1 var GPIO.0       'SW1 input     151226added

SW2 var GPIO.1       'SW2 inout     151226added

SW3 var GPIO.4       'SW3 inout     151230added

TRISIO=%011011       'GP0,1,4 - Transmission SW inputs (level change interrupt)

PR2=25               'Set PWM for 38KHz (24:40KHz)

CCPR1L=13            'Set PWM for 50% duty cycle

CCP1CON=%00001100    '(=12 in dec) PWM mode selection

T2CON=%00000100      '(=4 in dec) Timer2 ON + 1:1 prescale

 

INTCON.7=1         'Use of interrupt GIE->1

INTCON.3=1         'Use of GPIO port level change interrupt

IOC.0=1            'GPIO.0 pin input change detect  Essential!

IOC.1=1            'GPIO.1 pin input change detect  Essential!

IOC.4=1            'GPIO.4 pin input change detect  Essential!

 

SleepLoop:

CCP1CON=0   'Essential!

INTCON.0=0  'Clear GPIF   important!

GPIO.2=0    'Essential to remove H-level tailing (save current) for Tr control

 

@sleep          'This is a key command

GPIO.2=0    'Essential!

INTCON.0=0  'Clear GPIF

GPIO.2=0    'Essential!

 

'*** Routine to be executed when wake up ***

SW1=1

SW2=1

SW3=1

Pause 2  '2ms

If SW1=0 then Plspattern1   ‘Jump to 3 different Pulse Pattern types

If SW2=0 then Plspattern2

If SW3=0 then Plspattern3

Goto SleepLoop

 

Plspattern1:   'SW1 Transmission Routine to produce a similar pulse pattern to that of "Dengen" key of Funai RC-7 remote controller

Gosub w40msH   '40-ms H pulse

Gosub w3p5msL  '3.50-ms L pulse

Gosub w3p35msH '3.35-ms H pulse + 1-ms L pulse

Gosub w0p85msH '1, 850-us H pulse + 1-ms L pulse - 1-24

Gosub w0p85msH '2, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '3, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '4, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '5, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '6, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '7, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '8, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '9, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '10, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '11, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '12, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '13, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '14, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '15, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '16, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '17, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '18, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '19, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '20, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '21, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '22, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '23, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '24, 850-us H pulse + 1-ms L pulse

Goto SleepLoop

 

Plspattern2:   'SW2 Transmission Routine

Gosub w40msH   '40-ms H pulse

Gosub w3p5msL  '3.50-ms L pulse

Gosub w3p35msH '3.35-ms H pulse + 1-ms L pulse

Gosub w0p85msH '1, 850-us H pulse + 1-ms L pulse - 1-24

Gosub w0p85msH '2, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '3, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '4, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '5, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '6, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '7, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '8, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '9, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '10, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '11, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '12, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '13, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '14, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '15, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '16, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '17, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '18, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '19, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '20, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '21, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '22, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '23, 850-us H pulse + 1-ms L pulse  Changed from 2.5ms to 850us

Gosub w0p85msH '24, 850-us H pulse + 1-ms L pulse

Goto SleepLoop

 

Plspattern3:   'SW3 Transmission Routine

Gosub w40msH   '40-ms H pulse

Gosub w3p5msL  '3.50-ms L pulse

Gosub w3p35msH '3.35-ms H pulse + 1-ms L pulse

Gosub w0p85msH '1, 850-us H pulse + 1-ms L pulse - 1-24

Gosub w0p85msH '2, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '3, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '4, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '5, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '6, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '7, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '8, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '9, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '10, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '11, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '12, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '13, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '14, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '15, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '16, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '17, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '18, 850-us H pulse + 1-ms L pulse

Gosub w2p5msH  '19, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '20, 2.5-ms H pulse + 1-ms L pulse

Gosub w2p5msH  '21, 2.5-ms H pulse + 1-ms L pulse

Gosub w0p85msH '22, 850-us H pulse + 1-ms L pulse  Changed from 2.5ms to 850us

Gosub w0p85msH '23, 850-us H pulse + 1-ms L pulse

Gosub w0p85msH '24, 850-us H pulse + 1-ms L pulse

Goto SleepLoop

 

'Subroutines ---

w40msH:

CCP1CON=0     '=%00000000  PWM disable

Low GPIO.2

Pause 40

CCP1CON=12    '=%00001100  PWM enable    

Return

 

w3p5msL:

CCP1CON=12

Pauseus 3500

Return

 

w3p35msH:

CCP1CON=0

Low GPIO.2

Pauseus 3350

CCP1CON=12

Pauseus 1000   '1-ms L pulse

Return

 

w0p85msH:

CCP1CON=0

Low GPIO.2

Pauseus 850    '0.85-ms pulse

CCP1CON=12

Pauseus 1000   '1-ms L pulse

Return

 

w2p5msH:

CCP1CON=0

Low GPIO.2

Pauseus 2500

CCP1CON=12

Pauseus 1000   '1-ms L pulse

Return

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

'Note:

   'melabs Engineering's Programmer's configurations: IMPORTANT!

   'Oscillator - INTOSCIO; Watch-dog Timer - Disable; Power-up Timer - Disable

   'MCLR - Reset; Brown-out Reset - Disable; Int-Ext SW-over - Enable;

   'Fail-Safe clock monitor - Enable; Code - Not protect; Data EEPROM - Not protect. 2011.2.6

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

 

 

受信プログラム - 3個    Three IR Receiver Programs

 送信側から送られてくるパルスパターンを読み取るプログラムである。3個のプログラム(IRRelayReceiver12F683SW1.bas、IRRelayReceiver12F683SW2.bas、IRRelayReceiver12F683SW3.bas)は1個づつ別の基板に載せSSR等と組合せて電気機器の制御などに使う。送られた来たパルスを受信側で1個づつ幅広パルス(‘1’)か幅狭パルス(‘0’)をチェックして24ビットのバイナリー列を構築し、それが送信側の理論的バイナリー列と一致すれば受信側12F683のGP1やGP2をON/OFFさせる。

 

Three independent receiver programs (IRRelayReceiver12F683SW1.bas, IRRelayReceiver12F683SW2.bas, IRRelayReceiver12F683SW3.bas) are shown below. The individual program is burned into each 12F683. The receiver program reads each bit (`1` for wide pulse, `0` for narrow pulse) of a 24-bit pulse pattern sent from the transmitter side, thereby forming a 24-bit binary sequence. If this sequence is equal to the theoretical one from the transmitter side, the GP1 and GP2 of 12F683 in the receiver side will be activated and drive SSR and LED.

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

SW1受信用プログラム     SW1 Receiver Program

'IRRelayReceiver12F683SW1.bas 2016.1.6 works OK!

'This program reads IR pulses from SW1 of 3-key IR Transmitter (based on "DENGEN" of FUNAI RC-7 remote control).

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

'12F683, 4MHz Internal Clock used

'Pin 1: Vdd (5.0V)

'Pin 8: Vss (GND)

'Pin 3: GPIO.4: input - connected to IR Receiver module

'Pin 5: GPIO.2: output - connected to SSR drive

'Pin 6: GPIO.1: output - connected to LED(R) SSR-ON/OFF indicator

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

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

CMCON0=7  'Comparator off Note: not CMCON=7 (for 12F629 etc)

ANSEL=0  'All pins are digitals

TRISIO=%011000  'all except GP3 and GP4 are outputs.

 

'PlsWidth var word

PlsW300 var word

PlsW var word

Code var word

Code1 var word

SSRdrive var GPIO.2

SSRonoffLED var GPIO.1

 

SSRdrive=0

SSRonoffLED=0

 

Loop:

PlsW300=0

PlsW=0

Code=0

Code1=0

Clear     'Clear the content of all variables - Essential!

 

 Pulsin GPIO.4,1,PlsW300  'Read the pulse with 3.3 ms

 If (300<PlsW300) and (400>PlsW300) then

 Goto Countpls

 Else                                  

 Goto Loop

 Endif

 

SSRdrive=0

SSRonoffLED=0

 

Countpls:  'Formation of Code and Code1

'Checking Bit0 - 0-15 (16 bits)

Pulsin GPIO.4,1,PlsW   'Read 24 working pulses

If 150>PlsW then Code.bit0=0  '0 is a small pulse (0.7 ms)

If 150<PlsW then Code.bit0=1  '1 is a large pulse (2.5 ms)

 

'Checking Bit1

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit1=0   '0

If 150<PlsW then Code.bit1=1

 

'Checking Bit2

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit2=0   '0

If 150<PlsW then Code.bit2=1

'Works till the above

 

'Checking Bit3

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit3=0

If 150<PlsW then Code.bit3=1    '1

 

'Checking Bit4

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit4=0    '0

If 150<PlsW then Code.bit4=1   

 

'Checking Bit5

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit5=0

If 150<PlsW then Code.bit5=1    '1

 

'Checking Bit6

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit6=0    '0

If 150<PlsW then Code.bit6=1   

 

'Checking Bit7

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit7=0    '0

If 150<PlsW then Code.bit7=1

 

'Checking Bit8

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit8=0    '0

If 150<PlsW then Code.bit8=1   

   

'Checking Bit9

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit9=0    '0

If 150<PlsW then Code.bit9=1   

 

'Checking Bit10

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit10=0   '0

If 150<PlsW then Code.bit10=1   

 

'Checking Bit11

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit11=0

If 150<PlsW then Code.bit11=1   '1

 

'Checking Bit12

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit12=0

If 150<PlsW then Code.bit12=1   '1

 

'Checking Bit13

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit13=0

If 150<PlsW then Code.bit13=1   '1

'Till here, OK  15:48

 

'Checking Bit14

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit14=0

If 150<PlsW then Code.bit14=1   '1

 

'Checking Bit15

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit15=0   '0

If 150<PlsW then Code.bit15=1   

 

'Code=30760 in first 16 bits =%0111100000101000

 

'Checking Bit16 - 16-23 (8 bits)

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit0=0

If 150<PlsW then Code1.bit0=1   '1

 

'Checking Bit17

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit1=0   '0

If 150<PlsW then Code1.bit1=1   

 

'Checking Bit18

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit2=0

If 150<PlsW then Code1.bit2=1   '1

 

'Checking Bit19

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit3=0

If 150<PlsW then Code1.bit3=1   '1

 

'Checking Bit20

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit4=0

If 150<PlsW then Code1.bit4=1   '1

 

'Checking Bit21

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit5=0

If 150<PlsW then Code1.bit5=1   '1

 

'Checking Bit22

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit6=0

If 150<PlsW then Code1.bit6=1   '1

 

'Checking Bit23

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit7=0   '0

If 150<PlsW then Code1.bit7=1   

 

'Code1=125 in last 8 bits =%01111101 (Power Key)

 

Pause 20

If (Code=30760) and (Code1=125) then SSRdriveON

Goto Loop

 

SSRdriveON:

Toggle SSRdrive

Toggle SSRonoffLED

Pause 500   '0.5 sec

Goto Loop

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

'Note:

   'melabs Engineering's Programmer's configurations: IMPORTANT!

   'Oscillator - INTOSCIO; Watch-dog Timer - Disable; Power-up Timer - Disable

   'MCLR - Reset; Brown-out Reset - Disable; Int-Ext SW-over - Enable;

   'Fail-Safe clock monitor - Enable; Code - Not protect; Data EEPROM - Not protect. 2011.2.6

 

SW2用受信プログラム     SW2 Receiver Program

'IRRelayReceiver12F683SW2.bas 2016.01.08 works OK!

'This program reads IR pulses from SW2 of 3-key IR Transmitter.

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

'12F683, 4MHz Internal Clock used

'Pin 1: Vdd (5.0V)

'Pin 8: Vss (GND)

'Pin 3: GPIO.4: input - connected to IR Receiver module

'Pin 5: GPIO.2: output - connected to SSR drive

'Pin 6: GPIO.1: output - connected to LED(R) SSR-ON/OFF indicator

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

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

CMCON0=7  'Comparator off Note: not CMCON=7 (for 12F629 etc)

ANSEL=0   'All pins are digitals

TRISIO=%011000  'All except GP3 and GP4 are outputs.

'PlsWidth var word

PlsW300 var word

PlsW var word

Code var word

Code1 var word

SSRdrive var GPIO.2

SSRonoffLED var GPIO.1

SSRdrive=0

SSRonoffLED=0

Loop:

PlsW300=0

PlsW=0

Code=0

Code1=0

Clear     'Clear the content of all variables - Essential!

Pulsin GPIO.4,1,PlsW300  'Read the pulse with 3.3 ms

If (300<PlsW300) and (400>PlsW300) then

Goto Countpls

Else                                  

Goto Loop

Endif

SSRdrive=0

SSRonoffLED=0

Countpls:  'Formation of Code and Code1

'Checking Bit0 - 0-15 (16 bits)                            

Pulsin GPIO.4,1,PlsW   'Read 24 working pulses

If 150>PlsW then Code.bit0=0  '0 is a small pulse (0.7 ms)

If 150<PlsW then Code.bit0=1  '1 is a large pulse (2.5 ms)

'Checking Bit1

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit1=0   '0

If 150<PlsW then Code.bit1=1

'Checking Bit2

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit2=0   '0

If 150<PlsW then Code.bit2=1

'Works till the above

'Checking Bit3

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit3=0

If 150<PlsW then Code.bit3=1    '1

'Checking Bit4

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit4=0    '0

If 150<PlsW then Code.bit4=1   

'Checking Bit5

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit5=0

If 150<PlsW then Code.bit5=1    '1

'Checking Bit6

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit6=0    '0

If 150<PlsW then Code.bit6=1   

'Checking Bit7

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit7=0    '0

If 150<PlsW then Code.bit7=1

'Checking Bit8

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit8=0    '0

If 150<PlsW then Code.bit8=1   

'Checking Bit9

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit9=0    '0

If 150<PlsW then Code.bit9=1   

'Checking Bit10

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit10=0   '0

If 150<PlsW then Code.bit10=1   

'Checking Bit11

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit11=0

If 150<PlsW then Code.bit11=1   '1

'Checking Bit12

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit12=0

If 150<PlsW then Code.bit12=1   '1

'Checking Bit13

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit13=0

If 150<PlsW then Code.bit13=1   '1

'Till here, OK  15:48

'Checking Bit14

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit14=0

If 150<PlsW then Code.bit14=1   '1

'Checking Bit15

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit15=0   '0

If 150<PlsW then Code.bit15=1   

'Code=30760 in first 16 bits =%0111100000101000

 

'Checking Bit16 - 16-23 (8 bits)

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit0=0

If 150<PlsW then Code1.bit0=1   '1

'Checking Bit17

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit1=0   '0

If 150<PlsW then Code1.bit1=1   

'Checking Bit18

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit2=0

If 150<PlsW then Code1.bit2=1   '1

'Checking Bit19

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit3=0

If 150<PlsW then Code1.bit3=1   '1

'Checking Bit20

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit4=0

If 150<PlsW then Code1.bit4=1   '1

'Checking Bit21

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit5=0

If 150<PlsW then Code1.bit5=1   '1

'Checking Bit22

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit6=0   '0

If 150<PlsW then Code1.bit6=1

'Checking Bit23

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit7=0   '0

If 150<PlsW then Code1.bit7=1   

'Code1=61 in last 8 bits =%00111101  '20160108

 

Pause 20

If (Code=30760) and (Code1=61) then SSRdriveON

Goto Loop

SSRdriveON:

Toggle SSRdrive

Toggle SSRonoffLED

Pause 500   '0.5 sec

Goto Loop

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

 

SW3用受信プログラム    SW3 Receiver Program

'IRRelayReceiver12F683SW3.bas 2016.1.9 works OK!

'This program reads IR pulses from SW3 of 3-key IR Transmitter.

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

'12F683, 4MHz Internal Clock used

'Pin 1: Vdd (5.0V)

'Pin 8: Vss (GND)

'Pin 3: GPIO.4: input - connected to IR Receiver module

'Pin 5: GPIO.2: output - connected to SSR drive

'Pin 6: GPIO.1: output - connected to LED(R) SSR-ON/OFF indicator

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

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

CMCON0=7  'Comparator off Note: not CMCON=7 (for 12F629 etc)

ANSEL=0   'All pins are digitals

TRISIO=%011000  'All except GP3 and GP4 are outputs.

'PlsWidth var word

PlsW300 var word

PlsW var word

Code var word

Code1 var word

SSRdrive var GPIO.2

SSRonoffLED var GPIO.1

SSRdrive=0

SSRonoffLED=0

Loop:

PlsW300=0

PlsW=0

Code=0

Code1=0

Clear     'Clear the content of all variables - Essential!

Pulsin GPIO.4,1,PlsW300  'Read the pulse with 3.3 ms

If (300<PlsW300) and (400>PlsW300) then

Goto Countpls

Else                                  

Goto Loop

Endif

SSRdrive=0

SSRonoffLED=0

Countpls:  'Formation of Code and Code1

'Checking Bit0 - 0-15 (16 bits)                            

Pulsin GPIO.4,1,PlsW   'Read 24 working pulses

If 150>PlsW then Code.bit0=0  '0 is a small pulse (0.7 ms)

If 150<PlsW then Code.bit0=1  '1 is a large pulse (2.5 ms)

'Checking Bit1

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit1=0   '0

If 150<PlsW then Code.bit1=1

'Checking Bit2

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit2=0   '0

If 150<PlsW then Code.bit2=1

'Works till the above

'Checking Bit3

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit3=0

If 150<PlsW then Code.bit3=1    '1

'Checking Bit4

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit4=0    '0

If 150<PlsW then Code.bit4=1   

'Checking Bit5

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit5=0

If 150<PlsW then Code.bit5=1    '1

'Checking Bit6

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit6=0    '0

If 150<PlsW then Code.bit6=1   

'Checking Bit7

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit7=0    '0

If 150<PlsW then Code.bit7=1

'Checking Bit8

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit8=0    '0

If 150<PlsW then Code.bit8=1   

'Checking Bit9

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit9=0    '0

If 150<PlsW then Code.bit9=1   

'Checking Bit10

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit10=0   '0

If 150<PlsW then Code.bit10=1   

'Checking Bit11

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit11=0

If 150<PlsW then Code.bit11=1   '1

'Checking Bit12

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit12=0

If 150<PlsW then Code.bit12=1   '1

'Checking Bit13

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit13=0

If 150<PlsW then Code.bit13=1   '1

'Till here, OK  15:48

'Checking Bit14

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit14=0

If 150<PlsW then Code.bit14=1   '1

'Checking Bit15

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code.bit15=0   '0

If 150<PlsW then Code.bit15=1   

'Code=30760 in first 16 bits =%0111100000101000

'Checking Bit16 - 16-23 (8 bits)

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit0=0

If 150<PlsW then Code1.bit0=1   '1

'Checking Bit17

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit1=0   '0

If 150<PlsW then Code1.bit1=1   

'Checking Bit18

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit2=0

If 150<PlsW then Code1.bit2=1   '1

'Checking Bit19

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit3=0

If 150<PlsW then Code1.bit3=1   '1

'Checking Bit20

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit4=0

If 150<PlsW then Code1.bit4=1   '1

'Checking Bit21

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit5=0   '0

If 150<PlsW then Code1.bit5=1

'Checking Bit22

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit6=0   '0

If 150<PlsW then Code1.bit6=1

'Checking Bit23

Pulsin GPIO.4,1,PlsW  

If 150>PlsW then Code1.bit7=0   '0

If 150<PlsW then Code1.bit7=1   

'Code1=29 in last 8 bits =%00011101  '20160109

 

Pause 20

If (Code=30760) and (Code1=29) then SSRdriveON

Goto Loop

SSRdriveON:

Toggle SSRdrive

Toggle SSRonoffLED

Pause 500   '0.5 sec

Goto Loop

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

 

Menu Pageへ戻る

Topへ戻る