Lab 3 - Interrupts - “Remote Control Decoding”

You have already seen serial communication in Lab 2, but you will see it again here. This time, instead of sending the signal across a wire, we will send it through the air as modulated light.

Your task for this lab is to reverse engineer (hack) an IR remote control so you can get it to light up some LEDs for you. Unfortunately, IR remotes don’t really follow much of a standard, but they tend to operate similar to each other. We will exploit that to learn how they work.


WARNING: This lab has been around for a while, but I have changed it this semester. If I see your code looks like work from previous years, I will assume you are cheating and you will loose a lot of points. Depending on how bad it looks, it could result in an honor case.


Objectives

Handy References

Given code

Directions

You will need to use the timer interrupt and the general purpose pin interrupt to decode a remote control. Be sure to pick one remote for the whole lab, as remote codes vary between manufacturer.

Daily Milestones

This lab will be completed in 3 steps:

If you finish a day early, move on to the next day’s work

Please do the prelabs, they will help you meet the above deadlines

Day 1

Prelab 1

I will not check these, but you need to do them to stay on track.

Connecting the IR sensor

Do Not Power Your Board When You Are Wiring It Up!

Insert the IR receiver module into the protoboard. Look at the datasheet and make sure you are wiring up the receiver module correctly. When you are looking at the sensor ball on your IR receiver module, the pin on the left is your signal pin; the pin in the middle is your ground pin; and the pin on the right is your Vcc.

IR Sensor Datasheet excerpt
IR Sensor Datasheet excerpt

Hook up your Launchpad to the IR module as shown in either picture:

On your MSP430, connect:

Connecting to the Logic Analyzer

When hooking up to the logic analyzer, remember to connect the MSP430 ground to the logic analyzer ground. Also, hook the signal from the IR sensor to one of the POD1 inputs bits.

Following the picture above:

Measure Timer Counts

  1. Build a project around your modified test3.c and then download it onto your LaunchPad. Make sure to open the variables tab (View -> Variables).
    • I also like to clear memory from the Memory Browser tab (View -> Memory Browser), Fill Memory from 0x200 to 0x400 with 0’s.
  2. Set the Logic analyzer to “Run Single”
  3. Run the program and then press a button on a remote.
  4. Pause the program and look at the variables. You should see something like the following. The values are the captured wave form from the remote.
array screen shot
array screen shot

The values in Timer0 are how long the signal was at zero for and the Timer1 was how long it was high for.

The logic analyzer should look sort of like the following:

WARNING: On my remote control, the full remote control signal was about 80ms. Please note that remote control data packets are not standardized, so the remote that you use to perform these experiment will almost certainly generate results different from those that your neighbor’s remote will generate.

Also, different remotes do different things. It appears remotes send the same command multiple times (~ x3). However, they do it differently.

The above remote sends one good packet and 2 empty packets immediately following one button press.

This remote however, appears to send 3 copies of the same button press.

Due day 1:

Use the logic analyzer to measure the following information for your remote. Show your instructor these:

Pulse Duration (ms) Timer A counts
Start: logic 0 half pulse
Start: logic 1 half pulse
Data 1: logic 0 half pulse
Data 1: logic 1 half pulse
Data 0: logic 0 half pulse
Data 0: logic 1 half pulse
Stop: logic 0 half pulse
Stop: logic 1 half pulse

Day 2

Prelab Day 2

IR data packets

Connect your MSP430 back to the logic analyzer as you did during day 1. Now that you know the characteristics of your remote, we want to capture the packets now.

Write the codes (in hex) for at least 5 remote control buttons. Make sure you know both the button and the hex code. You should be able to identify the start of the message and from there identify the logic 0/1 half pulse.

Day 2 Turn-in

Show your instructor the following table

Button Button name Hex code (not including start and stop bits)
1
2
3
4
5

Day 3

Prelab Day 3

Main

Each of the above actions are independent. Do not hit multiple buttons at the same time or hit remote buttons to interrupt button 4 blinking lights.

Port 2 Vector Data Collection

For the IR remote data, you only need to detect the data’s logic high as either a 0 (should be short time) or a 1 (should be a long time)

Falling Edge

  1. Read TAR
  2. Classify logic 1 half-pulse and shift bit into irPacket
  3. Shift the 0 or 1 bit into the irPacket
  4. Turn Timer A off
  5. Enable rising edge interrupt

Rising Edge

  1. set TAR = 0
  2. Turn Timer A on
  3. Enable Timer A interrupt
  4. Enable falling edge interrupt

After both rising/falling edge, clear the P2IFG

Timer 0 Vector

  1. Turn off Timer A
  2. Turn off Timer A interrupt
  3. Clear TAIFG

Day 3 Turn-in

Rubric

WARNING: This lab has been around and I have made changes to it. When I review your code, if I see code from the old way to do the lab you will receive 0 pts for your code. Please do not cheat.