Software
Home
Introduction
Overall Design
Software
Hardware
Results
Future Ideas
Code Listing
Schematics

Software Design

The software is comprised of four main functions. These functions are IR transmission, UART communications, keypad control, and LCD scrolling output.

In order to transmit IR signals, a 40 KHz wave must be generated to modulate the output signal. The transmission is more complicated than simply sending a logic 1 or 0. First, the receiving system must synchronize to the incoming IR wave. Then, the data is transmitted from the sender using the Pulse-Coded signal coding scheme. The is 12-bits long and transmitted using a 40 KHz wave. The scheme requires that the bits be spaced on multiples of time T, where T is 600 us. To begin the message, a header sequence is transmitted. This consists of 4T of 40KHz signal followed by a T of no transmission. Following this header is the command itself. Logic 0 is represented by a T 40 KHz pulse followed by a T period of no transmission. Logic 1 is represented by a 2T 40 KHz signal followed by a T period of no transmission. For commands such as fast forward, the signal repeats itself until the user releases the button.

The 40 KHz wave generation is driven by the Timer 1 output PortD.5 toggle on compare A match and clear. The compare A register value and the timer 1 settings are hardcoded within the main initialization block. In order to activate the wave, the timer 1 control register A (TCCR1A) is set to toggle the OC1X output line on a compare A match. In order to disable the wave, TCCR1A is set so that the OC1X output line is set to 1 on a compare match (ie it is always set to 1). Because the IR LED is connected between this pin and Vdd, the LED is only active when the pin is low.

UART communications involves both transmission and reception. Transmission from the base station to Winamp involves translating a button press to a Winamp code. This character is then transmitted to the PC using a putchar call.

UART reception cannot be blocking due to the multitasking nature of the software. As a result it must be interrupt driven. The only information Winamp communicates is the track title and total time of the current track. Therefore, when a character is received from the Winamp plugin, it is written to the title buffer. This continues until a carriage return is received, indicating the end of the title. A flag is then set which causes the title to be written to the LCD.

The keypad control uses a state machine to debounce the keypresses. The state is evaluated every 5 msec using the timer 0 overflow interrupt. It begins in state reset where the keypad is scanned for a valid button press. If one is registered, it moves to the count key state. This state counts 30 msec and moves to state pressed which then performs another keypad scan. If the same button is still pressed, then the button has been “officially” pressed and its action is executed. The state machine then moves to state released. Here, the keypad is continually scanned. If the key pressed is a fast forward, reverse, volume up, or volume down, the action will be repeated. This allows for signals that require constant IR transmission to function. If a button press is not detected, then the state machine moves to state countrel which again counts to 30 msec and moves to stillrel. This state checks the keypad and if no button is pressed returns to state reset.

The keypad buttons are mapped to the following functions:

Single Key Press:
1 Stop
2 Pause
3 Play
4 Rewind
5 Fast Forward
6 Mute
7 Previous Track
8 Next Track
9 Display
0 Record
A Select Source 1
B Select Source 2
C Select Source 3
D Select Source 4
* Shift
# Power
Shifted keypresses:
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
0 10
A Volume +
B Volume -
C Shuffle
D Continue
* Unused
# Repeat

The software is designed to flash three of the input instructions to the LCD screen. This feature is included for relevant instructions that last beyond the press of the button, such as pause, record, and mute. The software handles this task by setting flags for the relevant button pushes in the command execution function. This code checks the current states of the flags and takes appropriate action. The software uses the timing flag from title scrolling to time the flashing of the instructions every 500 msec.

Due to the number of commands required by the different audio equipment, more than 16 buttons are needed. As a result, a shift key is available. This is done by expanding the array of valid Port pin inputs for a pressed button. In addition, the shift key is not a command and is treated alone as an invalid button push. However, when pressed along with another button, a valid command is issued.

LCD scrolling is performed by manipulating the input title character array from Winamp. The LCD panels have a addressing problem that prevents all 16 characters from being written within the same instruction. Instead, two 8 character chunks must be written. The scrolling is controlled by a flag set within the timer 0 overflow interrupt routine every 500 msec. When the flag is set, a title exists is the title buffer, and the active device is PC Winamp, then the scrolling function is activated. To scroll the title, it begins by printing the first 16 characters of the title to the LCD and incrementing the scrolling index. After the next 500 msec, it prints the next 16 characters, starting at the scrolling index. This continues until the scrolling index reaches the end of the string, where it is reset to 0. This allows the title to continue to scroll indefinitely.

The Atmel 8515 source code as well as the Winamp Plugin code are both available within Code Listing.