First off, it's been a long time since I have been to this most excellent forum! I ran across a problem yesterday that cried PICAXE and sure enough it responded! I sure hope Hippy is still around!
The issue was lightning struck a long ago client's house and the equipment we used in the whole house audio system is no longer made (Niles RVL-6) and they wanted something much simpler, specifically a volume control knob in each room with speakers. Since the speaker wires don't go through the room's control box that isn't easy. Additionally they are not interested in using their phones/pads to turn speaker volume up or down. The only wire available at the control locations is 22/2 with shield. BIG house, running more wire is cost prohibitive. (I got involved AFTER the wire was run. I'd always run cat5...)
So anyway some of the older Xantech amps were IR controlled and fairly easy to find. (a ZPR68 could do in a pinch) So all I needed to do is transmit a few (vol+ vol- vol0) IR commands in relationship to the position of a potentiometer. Naturally this forum is where I looked! I found quite a few examples of code including some excellent Hippy code that I don't understand BUT got me started! The other invaluable resources were NEC Infrared Transmission Protocol and AnalysIR.
Hardware wise this is a piece of cake. The 22/2 ws cable has grnd, +12VDC and a conductor for the IR signal to go back on to the amp. I'll likely have to make a buffer circuit but for testing I'm using a IR LED. AND IT WORKS! Tested with a ZPR68 and while I'll have to make some clean up when the amp arrives it's real close!
As normal I hate the code I have written! While it works and fits I know better could be done and hopefully someone here can help me (and others in the future) out.
NEC protocol is fairly simple and is built around 562.5us. A big start burst of 16x562.5us is followed by a space of 8x562.5us then data. While it would be nice to do that math I didn't. Data 0's are a burst of 562.5us followed by a space of 562.5us. Data 1's are a burst of 562.5us followed by a space of 3x562.5us.
The data consists of a 8bit device address and a 8bit command. Each are sent followed by their logical inverse making a 32 bit string followed by a final burst of 562.5us. I didn't get into repeat codes but they are the big start burst, space and the final burst.
Still with me? The most excellent IRtoy coupled with AnalysIR software are amazing! I used to do this stuff with a scope but that has changed! In any case it identified the protocol, modulation and decoded the commands! So what I needed to send was device code 38 and commands 38 (off), F0 (vol+) and C8 (vol-) (for actual use there will be different ones). After trying to understand Hippy's method I gave up and just hard coded it. I, along with those interested, am sure something better is possible! Hippy's code was for RC6 which is built differently but his method is VERY solid! Build a bunch of bits, iterate through and then transmit. I , and others, have found timing is too critical to go dinking back and forth once transmission starts.
The parts of Hippy's code I don't understand are;
I don't know if an explanation would be more useful or simply some example code that is applicable to NEC protocol. Specifically I can't figure out how to manipulate the space after the big start burst. That is where I gave up and went the LONG way...
Attached is my code and a screen shot of AnalysIR when I was halfway through the string. Hope this interests, helps or provides amusement for someone!
View attachment XantechControl1.bas
P.S. AnalysIR has come a long was since that screenshot but I don't have the new version up and running. I'm sure the PICAXE Programming Editor has too but...
The issue was lightning struck a long ago client's house and the equipment we used in the whole house audio system is no longer made (Niles RVL-6) and they wanted something much simpler, specifically a volume control knob in each room with speakers. Since the speaker wires don't go through the room's control box that isn't easy. Additionally they are not interested in using their phones/pads to turn speaker volume up or down. The only wire available at the control locations is 22/2 with shield. BIG house, running more wire is cost prohibitive. (I got involved AFTER the wire was run. I'd always run cat5...)
So anyway some of the older Xantech amps were IR controlled and fairly easy to find. (a ZPR68 could do in a pinch) So all I needed to do is transmit a few (vol+ vol- vol0) IR commands in relationship to the position of a potentiometer. Naturally this forum is where I looked! I found quite a few examples of code including some excellent Hippy code that I don't understand BUT got me started! The other invaluable resources were NEC Infrared Transmission Protocol and AnalysIR.
Hardware wise this is a piece of cake. The 22/2 ws cable has grnd, +12VDC and a conductor for the IR signal to go back on to the amp. I'll likely have to make a buffer circuit but for testing I'm using a IR LED. AND IT WORKS! Tested with a ZPR68 and while I'll have to make some clean up when the amp arrives it's real close!
As normal I hate the code I have written! While it works and fits I know better could be done and hopefully someone here can help me (and others in the future) out.
NEC protocol is fairly simple and is built around 562.5us. A big start burst of 16x562.5us is followed by a space of 8x562.5us then data. While it would be nice to do that math I didn't. Data 0's are a burst of 562.5us followed by a space of 562.5us. Data 1's are a burst of 562.5us followed by a space of 3x562.5us.
The data consists of a 8bit device address and a 8bit command. Each are sent followed by their logical inverse making a 32 bit string followed by a final burst of 562.5us. I didn't get into repeat codes but they are the big start burst, space and the final burst.
Still with me? The most excellent IRtoy coupled with AnalysIR software are amazing! I used to do this stuff with a scope but that has changed! In any case it identified the protocol, modulation and decoded the commands! So what I needed to send was device code 38 and commands 38 (off), F0 (vol+) and C8 (vol-) (for actual use there will be different ones). After trying to understand Hippy's method I gave up and just hard coded it. I, along with those interested, am sure something better is possible! Hippy's code was for RC6 which is built differently but his method is VERY solid! Build a bunch of bits, iterate through and then transmit. I , and others, have found timing is too critical to go dinking back and forth once transmission starts.
The parts of Hippy's code I don't understand are;
Code:
SkyChanUp:
Gosub ForSky
bits = 48
bitx = %1000001011000000 : Gosub SetToggleTime
bitx = %0000000000000000 : Gosub SetToggleTime
bitx = %0000011000000000 : Gosub SetToggleTime
Goto SendIr
SetToggleTime:
For bitCount = 0 To 15
If bits <> 0 Then
If bitx >= $8000 Then
@ptrInc = set1
Else
@ptrInc = set0
End If
bitx = bitx << 1
bits = bits - 1
End If
Next
@ptr = 0
Return
SendIr:
High C.0
ptr = 0
Do
Toggle C.0
PauseUs time
time = @ptrInc
Loop Until time = 0
High C.0
ptr = 0
Return
Attached is my code and a screen shot of AnalysIR when I was halfway through the string. Hope this interests, helps or provides amusement for someone!
View attachment XantechControl1.bas
P.S. AnalysIR has come a long was since that screenshot but I don't have the new version up and running. I'm sure the PICAXE Programming Editor has too but...