NEC IR Remote on 18M2

pleitch

New Member
Hi all

This is my first thread post.

I have a task to create an Air Conditioner Thermostat that turns an A/C on and off by IR. This is because the built in thermostat only turns the compressor off, leaving the fan running (pointless and costly). It's also noisy, so I'd like to be able to schedule it to turn off automatically at specific times (i.e. night) and turn on automatically at specific times (in the morning in summer).

The easy part is the temperature, and Real Time Clock so I won't go into that here. Instead I'll go into the bit I found really tough and took a lot of googling, a lot of searching on this forum and a lot of hacking.

The A/C is "Dimplex" which is likely to be a generic (no-name) brand or at least uses generic codes. I currently only have a 28x1 (with a 16 mHz resonator), several 18M2+ chips, one 20X2 AXE2000 with max freq of 32 mHz

The first task was to capture the signal from the air conditioner remote. I used a standard (TSOP1838) 38kHz IR reader. That required repeated pulsin for high, then repeated pulsin for low. I was using 18M2 for this, so given the limited variables I had to do this in stages (as well as using poke and peek). I found if I tried anything between pulsin reads, wither a check of a variable, a poke or anything would mean missing values. Even changing the direction of the pulsin seemed to miss values. I also repeated the process 10 or so times to make sure my results were consistent.

After getting the timings (remember - the attached code needs to be run for both high AND low) and doing some math in Excel I worked out the approximate time in ms using Excel.

Then I went searching via google and this forum and found NEC format matched the timing that I recorded. I looked at the document linked from this forum to find that the NEC format actually uses a 33% up time. So I used the PicAxe wizard to find that the "on" carrier wave for 32 mHz chip was: pwmout B.6, 210, 278

At this point my attempts failed time after time. The reason, the up time is 600 us between bits, with a pause for a zero bit of about 500 us. That converts to roughly a pause of 5 for up time and a pause of 4 for a zero bit for 32 mHz (I literally mean "Pause 4").

I found that these timings are so specific that even a call to a gosub will cause a delay too long for the transfer to work. Instead the code must be issued in one continuous flow (no gosubs). This worked!!!

I know that some might be asking why I didn't just upgrade the chip... and that was going to be the very next thing I was going to do but the code works as-is.

I'm attaching it here with three variations (button controlled for testing). The first is a one-time execution of the button (on button). The second is an execution of the code followed by a second "header" which indicates a repeat. The final uses a second header then 4 separate repeats.

For my purposes I couldn’t find any difference in the success of these, so I'm going to use the one that uses the least amount of code (the first one). However, the NEC code uses this process if a button is held, which might be important for volume based coding. I left it in this code because it shows all the timings.
 

Attachments

pleitch

New Member
Thanks - it was. If you look at the code I posted it was, in original form, taken from that thread. I had to switch out the gosubs to be direct executions, but it was based on the code posted in that thread.

Anyway - the point is it's all working now and I'm confident this code will controll any NEC code based remote controlled device from any 32 mHz PicAxe. Obviously there's just the limmitation of program size due to the number of lines required for each different signal. Since I only need 1 signal that's not a problem for me.
 
Top