Rustic Engineering

My Mind working on…

Archive for the ‘hack’s’ Category

Infrared Room Control (with Samsung IR protocol)

with 36 comments

I had ear some time ago that laziness sometimes is the best thing for inspiration. That week I discover that’s true.  Some nights,  I  lay on my bed to watch some thing on TV and doing some electronic research, before sleep. And, I don’t like to put off the lights (effficient ilumination is the best friend for a good reading) . Then, obviously, before sleep, I need to stand up to turn lights off. At my side, on bed, always resides a great remote control TV, with a set of unused buttons, telling “use us to turn the lights off“.

My remote

That’s a project that I was retarding because other, but now I decide to initiate and finish it.

The Basic Idea

The first step is recognize what my remote control is send to TV. It’s a Samsung remote control, with TV, VCR, DVD and STB specific and shared functions. My basic idea is: use some of this unused buttons to turn the lighst ON and OFF. But, why not dimmer the lamp? Why not doing some other useful thing? (Yes, thats because some projects growing up…)

So, the basic idea now is:

  • Make a device that recognize when a command is addressed to it self or not;
  • Recognize different commands;
  • Save usuful states (dimmer regulation);

Samsung Protocol

The Internet has a lot of information about RC5, NEC and Sony IR protocols, but not the same for Samsung. After some search at Google, I found this usefull page with some information about Samsung IR protocol. Resuming Samsung protocol:

  • 37.9KHz carrier wave (ON state is a burst of carrier with some duration, OFF is absense of it);
  • 1 Start bit (4.5ms ON, and 4.5ms OFF);
  • 32 data bits stream (data + address?);
  • bit “1” (590μs ON, 1690μs OFF) (thanks to Islam qabel,  for the more precise bit duration);
  • bit “0” (590μs ON, 590μs OFF);
  • 1 Stop bit (590μs ON, 590μs OFF);

I think that more information only with a test.

Test Circuit

The test circuit is very simple, consisting on a IR receiver (with filter, carrier demodulation and output). My only device available at home is a TSOP2236. Well, let’s go see what hapens.

TSOP2236 is a dedicated IR receiver with PIN diode and preamplifier, assembled on lead frame. The epoxy
package is designed as IR filter, to improve sensibility. The demodulated output signal can directly be
decoded by a microprocessor, but it’s logical reversed:

  • ON state (carrier presence): TSOP output LOW;
  • OFF state (carrier absence): TSOP output HIGH;

To make measures and confirm my suspects, I had use my Logic Analyzer from Saleae on the follow circuit:

Test Circuit

That’s the results for press button “1”:

Received data after pressing “button 1” on remote

Signal stream

Start bit identification (9ms total)

Bit “1” representation

Bit “0” representation

The process to gathering all this information is very easy with Logic Analyzer. The measured times differs a little bit, but this isn’t a problem. I count the transitions after the START bit and there’s 32 bits in.

Look again at the sequence of high and down states. Remember that we have a reversed version of the original IR wave from remote, because TSOP OUT signal is inverted. But actually it’s really doesn’t matter. What I need is: pressing “1” differs from pressing “2” or other buttons on remote. I don’t wanna to create a compatible device.

Decoding the data stream

To decode the data stream I used a PIC18F2520 MCU. I already has working on 16bits and 32bits MCU, but this project is much simple to require a great MCU. My design goals are:

  • Use internal clock (8Mhz, Instructiom Time TCy = 4/8MHz = 500ns);
  • Use Timer0 as counter with 1us increment (Timer0 prescaler to 1:2);
  • Use External Interrup 0 (INT0) to handle incoming IR waves and get the building IR code (final version);

That’s the circuit:

Decoding Test Circuit

Coding

The code (for Microchip C18 compiler) consist in a set of functions to detect when the signal change it’s state from DOWN to UP or UP to DOWN. See the sequence (basic):

Basic Algorithm

Note that for data bit identification, only HIGH time is important. It’s the difference between logic “1” and “0”, so you don’t need to be very precise in that differentiation. The red right program branch, needs to run 32 times, for all 32 bits.

I get…

The test was a success! After all, I have a 32bits unique data, that contains (probably) a Address Part and a Data Part. Again, I don’t worry about what is address or data. Only need unique 32 bits codes. If address part repeats (because you are send codes to one device), data should be unique. Ok to me.

The stream is read as it is delivered from TSOP to MCU, from left to right (START BIT to right). I’m considering from LSB to MSB, so when you see the analyzer stream signal, you are viewing the reversed version. See:

IR Data Stream Mapping

After some nights adjusting some things, the code works great!  I’ll publish it here in the next week.

As I think, some codes changes if you are using TV, DVD, VCR or STB buttons. See the codes for VCR function:

Some codes

If you observe the first pictures, about button “1” stream, you can see the sequence of 1110000 (reverse order, 0x07).

Proof of concept

To test my concept, I programing the device to waiting VCR signal functions (ended with ….0505) as you can see:

  • Buttons 1,2 and 3 turn ON color RED, GREEN and BLUE;
  • Buttons 4,5 and 6 turn OFF color RED, GREEN and BLUE;
  • Button 9 turn ALL ON;
  • Button 0 turn ALL OFF;
  • VOLUME+ increase LED power (PWM duty cycle);
  • VOLUME- decrease LED power (PWM duty cycle);

See my video:

Next Step

Now I need to design a transformerless power supply and the power control circuitry (TRIAC, etc) to control the real lights. Some nice ideas to next version:

  • Store dimming states on internal PIC EEPROM, so you can save desired conditions every time;
  • TV Remote now can act in others projects too (robots, toys, other home automation, etc);
  • With a small LCD, create a small menu, some configuration options, to more advanced projects;

I hope yours enjoy this project. From the first paper to here, I took one week to get it working properly. In a few weeks, I’ll share all the files here, in downloads page. Thank’s!

Written by forrequi

February 9, 2011 at 00:40

Posted in hack's, projects

Tagged with , , , , , , , ,

MP4 Powerpack – LiPoly Charger Hack – Part 2 (and final)!

leave a comment »

In this post, i show that in many cases, the solution is just a simple change, without any new circuit. I was surprised with the solution… and maybe you be too. The circuit of the power and charger stay above, end the first thing that pay attention is that the diode arrange in the first stage has a function of isolate the USB power and the wall adapter power.

MP4 Power Circuit

Then, I put a jumper between the pins of D202 diode and test it…..Shazam! Worked!

MP4 green wire hack

Now, see the MP4 sign charge:

Final test with USB - Shazam!

The one issue is that’s not possible to connect both USB and DC wall adapter, because now, we have a direct connection between it’s. Maybe in the version 2.0 of the hack, i really change the MP4 circuit to fix it 🙂

For now, the solution it’s OK!

Written by forrequi

November 20, 2007 at 12:29

Posted in electronic, hack's

Tagged with , , ,

MP4 Powerpack – LiPoly Charger Hack – Part 1!

leave a comment »

In my last travel to São Paulo, i bought a MP4. It’s a “MP4 with 1GB internal flash, SD expansion slot, Aux. Input and… FM radio“.

It’s a great gadget, and now it’s my iPod best friend. The only issue is that the USB mini B port in the back is for data access only. Don’t charge the battery !!! Bad design, bad…

I don’t understand why the hell they make a device like it without this primary feature, but i understand that it’s a great opportunity to hack it!

Let’s dissect it:

Inside MP4

And now, a amputation:

Secundary board

First items to highligh:

  • 1700mAh Polymer Lithium Ion Battery (LiPoly);
  • TPS61032 Boost Converter;
  • TPA2008D2 Stereo Audio Amplifier;

The next step (Party 2) is obtain the schematic from the board.

Enjoy!

Written by forrequi

November 13, 2007 at 13:03

Posted in electronic, hack's

Tagged with ,