6. Power-off sequence. Save all the settings to the EEPROM, and turn off the display and standby relay. Since the output of the IR sensor is connected to pin 12 (INT0) of the microcontroller, an external interrupt occurs whenever a code is received. The algorithm for decoding the IR stream is completely implemented in the ‘external interrupt 0’ handler routine. This routine sets NEW_COM (02H in bit memory) if a new command is available. The decoded command byte is stored in ‘Command’ (location 021H in the internal RAM). The main routine checks for NEW_COM bit continuously in a loop. Timer 0 is exclusively used by this routine to determine the pulse timings.
Decoding the IR stream involves the following steps:
- Since every code is transmitted twice, reject the first by introducing a delay of 85 milliseconds (ms) and start timer 0. The second transmission is detected by checking for no-overflow timer 0. In all other cases, timer 0 will overflow.
- For second transmission, check the timer 0 count to determine the length of the leader pulse (9 ms). If the pulse length is between 8.1 ms and 9.7 ms, it will be recognised as valid. Skip the following 4.5ms silence.
- To detect the incoming bits, timer 0 is configured to use the strobe signal such that the counter runs between the interval periods of bits. The value of the counter is then used to determine whether the incoming bit is ‘0’, ‘1’ or ‘Stop.’ This is implemented in the RECEIVE_BIT routine.
- If the first bit received is ‘Stop,’ repeat the last command by setting the NEW_COM bit.
Else, receive the rest seven bits. Compare the received byte with the custom code (C_Code). If these don’t match, return error.
- Receive the next byte and compare with the custom code. If these don’t match, return error.
- Receive the next byte and store in ‘Command.’
- Receive the next byte and check whether it is complement value of ‘Command.’ Else, return error.
- Receive ‘Stop’ bit.
- Set NEW_COM and return from interrupt.
Other parts of the source code are relatively straightforward and self-explanatory.
The micro-controller can accept commands from any IR remote that uses NEC transmission format. These remote controllers are readily available in the market and use μPD6121, PT2221 or a compatible IC. Here, we’ve used Creative’s remote handset.
All the functions of the system can be controlled fully using the remote or the on-board keys. By default, the display shows the volume setting and LEDs indicate the channel selected. LED9 glows momentarily whenever a command from the remote is received or any key is pressed.
Function adjustments are detailed below:
- Volume: Use Vol+/ Vol- key to increase/ decrease the volume. The volume settings are shown on the two-digit, 7-segment display. Steps can be varied between ‘1’ and ‘80.’
- Mute and Standby: Using ‘Mute’ and ‘Standby’ buttons, you can toggle the mute and standby status, respectively. If ‘Mute’ is pressed, the display will show ‘00.’ In ‘Standby’ mode, the relay de-energises to switch off the main amplifier. All the LEDs and displays, except LED9, turn off to indicate the standby status.
- Input Select: To select the audio input source, press ‘Channel’ key until the desired channel is selected. The LED corresponding to the selected channel turns on and the input gain setting for that channel is displayed for five seconds. Thereafter, the volume level is displayed on the 7-segment display.
- Input Gain set: Press ‘Gain’ key. The LED corresponding to the channel will start blinking and the gain value is displayed. Use Vol+/ Vol- key to increase/ decrease the gain for that channel. Note that the gain can be varied from ‘1’ to ‘15.’ If you press ‘Gain’ key once more, and no key is pressed for five seconds, it will exit the gain setting mode and the volume level is displayed.
- Audio: Press ‘Audio Set’ (Menu) key to adjust bass, middle, treble and attenuation one by one. Each time ‘Audio Set’ key is pressed, the LED corresponding to the selected function turns on and the function value is displayed. Once the required function is selected, use Vol+ and Vol- to adjust the setting. Bass, middle and treble can be varied from ‘07’ to ‘7.’ Values ‘0’ through ‘7’ indicate ‘Boost’ and ‘00’ through ‘07’ indicate ‘Cut.’ Attenuation can be varied from ‘0’ to ‘40.’
The circuit can be easily assembled on any PCB with IC base. Before you install the microcontroller, memory and audio processor in their sockets and solder the IR receiver module, make sure that the supply voltage is correct. All parts, except the audio processor (TDA7439), require 5V DC supply. The audio processor is powered by 9V DC.
Download PCB and component layout PDFs: click here
Download source code: click here