It's a remote controllable light switch that comes with an RF remote. The only light switch is across the room from my PC and it's a pretty large room. (The building's basically a 1-room apartment) so this works out great with the remote. Of course since I'm using the remote to cut the lights when I go to bed I'm basically using the remote from two places which brings with it the unavoidable annoyance of the remote being in the wrong place all the time. Which means I have to get up and look for it which is effectively as much of an annoyance as it was meant to solve. So I wanted a second controller that would basically be a stationary switch by my bed so I could leave the portable remote around the desk.
After some research I concluded that LP801B is a PT2262 clone which is a remote control encoder chip. Has a few address and data pins and generates a signal on the output pin based on the configuration of those at the time the enable pin is connected to ground.
At first I didn't think much of it and ordered some PT2262s and made a PCB which is basically a clone of the original remote adapted for components I had lying around (or just stupidly large pads where I had no idea what I was going to use when I made the board)
Not being patient enough however I started looking around to see if anyone's emulated this chip on a microcontroller before. Turns out, several people did.
So I took the code at http://www.mikroe.com/forum/viewtopic.php?f=13&t=10832 and ported it over to BASCOM for the ATTINY13.
I think that code has a bug though as the logic low component of the syncbit should be 31 times the short-pulse duration according to the datasheet not 7. (He's basically divided the datasheet units by 4 in case anyone actually looks into this) The decoders may not care as It seems to have worked for him. When I got mine to work I was using the datasheet-correct count so I didn't test with that. It took several modifications to my original board to get it working with the attiny. Had to put in 3 zeners as the PT2262 operates directly from 12v which the attiny can't do. I actually fried an ATTINY2313 the first time around because I forgot the two selector/power buttons that were still at 12v. If I knew in advance that I'd be able to do this I would've designed a much smaller board.
PCB made with PnP Blue, the 12v battery is soldered.
Parts:
D6, D3, VCCZNR = 5.1V Zeners
R1 = 100ohm 1k
R3,R4 = 2.2k
R5,R7 = 10K
R11 = 10K
Q1 = some small RF transistor (I used MPSH10)
C1 = 1pF
C2= 2pF (these are not critical)
C3 = Trimmer cap ideally 1-5pF
C4= 2200pF
D1,D2 = 1n4148 or similar
L1 = 1uH
L2 = swapped out for 4pF cap
ATTINY13 source: set framesize:8, softstack:16 in bascom compiler settings, fusebits configured to 9.6mhz internal OSC
$regfile = "attiny13.dat"
$crystal = 9600000
Declare Sub Sendbit(byval A As Byte)
Declare Sub Alpha()
Declare Sub Longa()
Declare Sub Synca()
Dim T As Integer
Dim D As Integer
Dim Number As Byte
Number = 10
Dim X As Byte
Dataout Alias Portb.2
Dataout = 0
Config Dataout = Output
Config Portb.0 = Input
Config Portb.1 = Input
If Pinb.0 = 0 Then
Do
Sendbit 1 'a0
Sendbit 0 'a1
Sendbit 0 'a2
Sendbit 2 'a3
Sendbit 2 'a4
Sendbit 2 'a5
Sendbit 2 'a6
Sendbit 0 'a7
Sendbit 0 'btn0 (not on my unit)
Sendbit 0 'btn1
Sendbit 1 'btn2
Sendbit 0 'btn3 (not on my unit)
Sendbit 3
Loop
End If
If Pinb.1 = 0 Then
Do
Sendbit 1 'a0
Sendbit 0 'a1
Sendbit 0 'a2
Sendbit 2 'a3
Sendbit 2 'a4
Sendbit 2 'a5
Sendbit 2 'a6
Sendbit 0 'a7
Sendbit 0 'btn0 (not on my unit)
Sendbit 1 'btn1
Sendbit 0 'btn2
Sendbit 0 'btn3 (not on my unit)
Sendbit 3
Loop
End If
End
Sub Alpha()
Waitus 261
End Sub
Sub Longa()
Alpha
Alpha
Alpha
End Sub
Sub Synca()
Local Y As Byte
For Y = 1 To 31
Alpha
Next Y
End Sub
Sub Sendbit(a As Abyte)
Select Case A
' 0 bit
Case 0:
Dataout = 1
Alpha
Dataout = 0
Longa
Dataout = 1
Alpha
Dataout = 0
Longa
' 1 bit
Case 1:
Dataout = 1
Longa
Dataout = 0
Alpha
Dataout = 1
Longa
Dataout = 0
Alpha
' FLOAT bit
Case 2:
Dataout = 1
Alpha
Dataout = 0
Longa
Dataout = 1
Longa
Dataout = 0
Alpha
' SYNC bit
Case 3:
Dataout = 1
Alpha
Dataout = 0
Synca
End Select
End Sub
Download Eagle board below.