MP3 wireless remote control automatic jukebox based on AT90S2313-4PC

This article refers to the address: http://

We have entered the era of CD and MP3 from the era of record and eight-track recording. Converting music to MP3 has become very popular, and how to store MP3 files is an interesting topic. This design will teach you how to store MP3s, so that you can enjoy MP3 music in a wide range of indoors.

Small MP3 players are vying for dominance in mobile applications with CD and tape players. With the continuous promotion of computer users and the increase in the number of Internet users, it would be great if my computer could become a server with no MP3 remote control.

Let me slowly introduce you to my implementation. This program allows you to enjoy MP3 music in any place in your home with an FM radio (such as a WALKMAN Walkman). Specifically, it is realized by connecting a low-power FM transmitter to the audio output port of the computer. In addition, a mobile unit is used to display the contents of the MP3 folder on the server, so that you can browse your favorite music from beginning to end.

For ease of use, you can scroll up and down to up to 4 folders containing different song lists. The selection, start, stop and jump are controlled by a general infrared remote control. The infrared remote command is sent to the computer that is the MP3 server through the 433MHz connection. Photo 1 shows all the equipment of the system.

Photo 1, MP3 wireless remote control automatic jukebox system equipment

On the server side I designed two modules, a 433MHz receiver and an FM transmitter. The receiver receives the command sent from the remote control. It is input to the computer through the serial port. The dedicated application running in the background receives the instructions. It is distributed to Windows Media Player. After receiving the command, Windows Media Player plays the on-demand track. The module FM transmitter takes the audio signal from the computer sound card output and transmits it.

To reduce costs and simplify design, the 433MHz wireless connection works only in a simplex mode. That is to say, after you select a function, the corresponding command is sent to the MP3 computer server via the wireless connection. If the transmitter does not send it to the server, you will not hear anything. You can issue the command again. In order to avoid false instruction interrupt operations, a dedicated codec chip is used in the design, which implements all the necessary functions to ensure that only legitimate packets can be transmitted to the MP3 server.

In order for the remote control unit to display the contents of the MP3 folder on the server, the contents of the folder must be downloaded to the remote control unit before use. This can be sent to Windows Media Player using the same application software via the serial port on the MP3 server. The firmware in the remote unit can control up to 4 different music folders.

In order to avoid frequently updating the flash memory of the remote unit, it is recommended to select 4 stable folders for remote playback, and Other folders for storing newly downloaded music or frequently changing collections. The remote control unit has 32K x 8 flash memory, and each folder can hold 200 song titles (800 song names in total). Because flash memory is a non-volatile memory, song name data is saved even if the remote unit power is turned off, which is important for Battery-powered remote units.

The core of the remote control unit system is the remote control unit, as shown in Figure 1. The remote control unit is mainly composed of Atmel AT90S2313-4PC. The Atmel AT90S2313-4PC provides 15 I/Os (12 of which are used) with a built-in hardware UART. Because the unit consumes a small amount of power, I used 4 AA batteries to pass the LM2936CZ5 low-dropout rectifier.



Figure 1 MP3 remote control unit

Obviously, if you can't display the entire song title and the name of the singer, the song name display is useless. Since there may be a lot of songs for you to browse, you will be able to display 4 song names at the same time, using a 4×40 LCD panel as the display. Compared to most common LCDs, the LCD is controlled in a different way, controlled by two HD44780 LSI controllers, one of which controls two lines of characters on the LCD and the other controls the next two lines.

The LCD is connected to the microcontroller through a 7-port B port in a normal 4-bit data interface. Control? consists of one RS? and two ENABLE?, two of which are ENABLE? One for each LSI controller. Because the LCD only receives instructions and does not need to read the status, R/*W? is tied low.

In terms of the user interface, I did not take the method of placing buttons and switches on the panel to control, but instead used an infrared decoding module and a universal infrared remote control. The infrared remote control uses the common and easily available RCA CRCU410 model, which has the same remote control code as the Quasar TV (code 054). I chose this code because it is simple and it is easier to decode it in software. The various keys and corresponding functions are shown in Table 1.



Table 1, remote control keys and corresponding functions

The non-volatile storage of the song list uses a continuous flash EEPROM. I chose Mcrochip's 24LC256I/P8EA because it is more common and easy to buy. The chip is an I2C device, so the connection to the microcontroller AT90S2313 requires only a dual interface. However, the AT90S2313 does not have a hardware circuit with an I2C port built in, so I2C functions must be implemented in software. Fortunately, Atmel provided an I2C read/write timing application note for the AT90S2313 as the master chip.

It must be noted that both SDA and SCL? in the I2C specification require a 2.2KΩ pull-up resistor. According to the A0~A2? settings, the 24LC256I can be set to 8 different I2C addresses, so the flash memory can be expanded to 256KB. In this design, only one chip is used, so all three addresses are set to low level.

The 24LC256I is used by the user to know that the device requires 5ms of flash write time, and data is written from the AT90S2313 UART to the flash memory. I designed the download protocol only from the server PC to the remote control unit, so there is no need to "handshake" mode, so I choose 1200bps data transfer rate, and process the input data characters every 8.3ms. This interval provides enough time to send data to the I2C flash memory. Even with software implementation of the I2C function, there is still 5ms of free time to write to the EEPROM.

Instead of using a mature RS-232 interface such as the MAX232, I used a 2N3904 NPN transistor and some passive components to convert the RS-232 level of the host to a TTL level.

Abacom's AM-RT5-433 is used as a transmitterless module, and its small SIP package is easy to assemble. Abacom generously sent me a sample of the transmitter and receiver. These inexpensive modules are designed for distances of around 100 yards, using simple carrier-switching modulation to achieve data transmission.

My other experience with small transmission modules comes from the more expensive Linx HP-II series (900 MHz). The Linx HP-II series uses FSK modulation and the transmitter can be driven directly by the UATR.

Abacom's technicians said that the cheaper module I chose could not interface directly with the UART port. However, Abacom designed a composite chip NKM2401-N, which can be used as an encoder or decoder depending on the mode connection. In this design I used this device at the end of every data connection.

In the remote unit, the NKM2401 receives 8-byte packets from the AT90S2313 UART port (at 2400 bps data rate), plus synchronization, pre-buffer/post-buffer bytes and CRC before Manchester encoding the final data. Because the packet format of the NKM2401 is 8 bytes, but my instruction is only 2 bytes long, I add the sync byte and the supplementary byte myself to become an 8-byte packet. The data output of the NKM2401 is directly connected to the AM-RT5-433 transmitter. As for the sky?, I used a 1/4 wavelength whip.

I want to cancel the NKM2401 in the remote control unit and use the AT90S2313 firmware program to implement the corresponding functions. The firmware of the remote unit is written in assembly language, using only about 1/3 of the space in the AT90S2313 2KB flash memory, so you can leave a lot of space for other programs you need. However, I don't plan to use a microcontroller at the receiving end, so I have to use the NKM2401 to decode it. I failed to get a detailed communication protocol from Abacom (their protocol is easier to understand) so I can't write a program to implement the encoding of the packet. If you give me some time, I might use an oscilloscope or a program on my computer to capture the data stream. Reverse engineering it and finally implement the encoding process. Unfortunately, there is no time.

I will add a few points before proceeding. The AT90S2313 uses a ceramic oscillator operating at 4MHz, which is sufficient for a lower serial data communication rate. I have to set the UART rate to 1200 bps (data download period) to receive the data, but set the rate to 2400 bps (transmit commands via the NKM2401 and the transmitter). I have to do this because the NKM2401 only works at 2400 bps and 1200 bps is the highest rate available for download (considering the write time of the serial flash).

Finally, there is a jumper marked J1 Link Test on the remote control unit. If loaded, the NMK2401-N will continuously send "ABACOM" information, which can be used to detect no connection.

No? Receiver Module <br> None? The role of the receiver is to receive the 433MHz signal transmitted by the MP3 remote control unit. The signal is converted to the RS-232 level and sent to the server PC.

Abacom's AM-HRR3-433 receiver is shown in Figure 2. The receiver module uses the same 1/4 wavelength whip as the transmitter.



Figure 2 Abacom's AM-HRR3-433 receiver

When there is no signal received, the output of the receiver module is full of glitch and noise. I used an oscilloscope to observe that there was no signal at all, because I lived in rural areas. For this reason, Abacom's NKM2401-N chip must be used. The mode (4th?) of the NKM2401-N in the receiver is grounded to operate in the decode mode. A virtual P232 triode inverter is used to provide a virtual RS232 level signal to the server PC.

LM2936CZ5 low dropout rectifier? The receiver provides 5V DC. Most of the time the receiver module is connected to the serial port of the MP3 server computer. However, for work, sometimes the remote unit must be connected to the PC (for example when downloading the song list), so I make a short cable to the PC. The upper DB9 socket is connected to a 5pin DIN plug, and the receiver and remote unit are paired with a 5pin DIN socket so you can connect the unit as needed.

Abacom's receiver/transmitter modules are extremely reliable for use with the NKM2401-N. No? Sending a command is a highlight of this design. The only thing that is lacking is that the 433MHz receiver and FM transmitter module cannot be installed in the same chassis. When the FM transmitter is placed next to the receiver, the RF output of the transmitter has a slight impact on the receiver sensitivity, resulting in a no-connection that can only operate within 20 yards, and the launch distance is too close to my intended target. It is. However, when I put the FM transmitter into the chassis and put it a few yards away from the 433MHz receiver, the problem of the near launch distance was solved, and the launch distance increased to about 50 yards (note that this is still indoor).

FM transmitter
When I envisioned this design, I expected that there would be some difficulties in design or programming problems. At first I always recognize that it is very easy to make a small FM transmitter, so I will leave this work to the end. However, as Murphy's Law says, I recognized the simplest thing to the end and became the most difficult and time-consuming part of the design.

It has been rumored that the FM stereo transmitter kit based on the Rohm BA1404 IC is often unusable due to unstable operation, but I still bought this kit. Oh, rumor is true - its frequency stability is so bad that it doesn't work with modern digitally tuned FM receivers. Even if I replaced the original bargain with high quality RF tuning components, the problem still exists. I have only gotten this psychological balance. I think this IC was designed before the invention of the digital FM receiver. It can't work with the digitally tuned FM receiver. The old analog FM receiver has an automatic frequency control circuit that may overcome the frequency drift of this transmitter kit.

I found a PLL-stabilized FM transmitter kit, but its price of up to $200 is too uneconomical for this design. I have done several PLL frequency generators in the 10-400MHz range a few years ago, so I want to try to make my own FM transmitter.

But that is the beginning of a nightmare. The PLL chip I used in the past is not available now. Most of the current PLL ICs are specifically designed for mobile phones and they do not work stably below 100 MHz. Although I have also found some ICs for FM transmission, their packaging is too small to be soldered.

In this situation, I will make another rumor. Because I have to use a microcontroller to control the PLL chip, so I don't completely lose the PLL chip and use the microcontroller to measure and control the oscillation frequency? What I think can be recognized is an automatic frequency Stabilizer.

My thoughts can be described in Figure 3. The oscillation frequency is mainly determined by the inductance and variable capacitance. In this design, I set the tuning range to about 88-92MHz. The reasons for these two reasons are as follows: First, there are fewer commercial low-end FM stations; more importantly, 96MHz is the highest frequency that the circuit can measure.



Figure 3 FM transmitter block diagram

For stability and FM modulation purposes, the oscillator is controlled by a varactor diode to fine tune the frequency. The capacitance of the varactor is determined by the bias voltage applied to it. This bias voltage is controlled by two components. The DC level provided by the 12-bit DAC and an AC signal act on the varactor to achieve frequency modulation. The initial value of the output voltage of the DAC is set at the middle value (2V). The oscillator is adjusted to the specified frequency by manually adjusting the variable capacitor (fine adjustment). The microcontroller then adjusts the output voltage of the DAC slightly up and down to stabilize the frequency.

To measure the frequency of the oscillator with a microcontroller, it must be prescaled by 16. This can be done by the normal 74F161 4-bit divider. The prescaler output is approximately in the 5 to 6 MHz frequency range, which can be counted using the microcontroller's 16-bit counter/timer.

To determine the oscillation frequency, first clear the 16-bit counter, and then read its value after a set time interval. The set time interval is programmed by another counter/timer in the microcontroller and is interrupted every 5.461ms cycle. Thus the value in the 16-bit counter can be calculated as follows:

Counter/timer Value=(fosc/16)×(5.461×10-3)

In actual operation, the microcontroller reads the value of the 16-bit timer and compares it to a constant calculated by the above equation using the frequency of your choice. If the oscillation frequency is too low, the value of the DAC will increase by 1 and try again; conversely, if the oscillation frequency is too high, the DAC value will be ?1. This is repeated until the frequency of the oscillator falls within a very narrow bandwidth around your chosen frequency.

This circuit may generally be in the search state for two reasons. First, because the oscillator signal changes during the sampling time, the counter/timer will always have one count error. Second, due to the oscillation. The device is frequency modulated by the audio signal and its frequency varies with this modulation voltage.

We don't want to have a search all the time, because this will cause the receiver to receive music with a modulated sound. In order to avoid this situation, once the frequency is set, the microcontroller enters the "sleep" state for 10 minutes, and then detects the frequency after 10 minutes. Unless there is a large change in the room temperature, the oscillator will hardly be corrected, and this circuit will ensure normal operation.

AVR AFC

Before I elaborate on how to implement an automatic frequency control FM transmitter, please take a look at Figure 4 to have a perceptual understanding. First I need a microcontroller that can count the 6MHz frequency. The microcontroller must also have another timer to issue an interrupt to the read counter and the clear counter. I chose the Atmel AT90S2313-10PC because it contains all the features I need. However, I have to let it work at 12MHz beyond its rated frequency of 10MHz to get the counting power of 6MHz. By the way, there is no problem with the "overclocking" of the Atmel AT90S2313 to the present.



Figure 4 Automatically fine-tuned transmitter unit

When the transmitter is completed, the FM oscillator frequency can be determined after setting a channel. Therefore, the simplified operation, at the beginning of the program I entered the required transmission frequency as a constant, the program is compiled and downloaded to the AT90S2313 to make a fixed frequency FM transmitter.

A 256-way prescaler chip with a frequency of up to 1 GHz can be easily obtained 10 years ago, but these chips are now listening, so I used the 74F161 counter to achieve a divide-by-16. The device operates at frequencies greater than 100MHz and costs less than $1 and is readily available.

I made a VCO with 2N5485. The oscillation frequency of the VCO is mainly taken from the values ​​of L1 and C12. C12? Fine-tuning the capacitor. When the transmitter is powered on for the first time, it is used to fine-tune the frequency to make the transmitter work at the specified frequency. The fine adjustment can only be done when J1 is installed so that the microcontroller sets the DAC output to the middle value, and then the jump is removed. When the transmitter is powered up again, the automatic frequency stabilizer circuit begins to operate and the oscillator is trimmed to the specified frequency by the varactor diode D1. The 74F161 requires a few volts for the clock, which can be implemented with a FET oscillator (other forms of oscillators do not have this capability).

The RF output of the oscillator is taken from the tap of L1 to the effect of a small load. The RF output is capacitively coupled to the clock input of the first stage of the 74F161 prescaler. Adjust the voltage divider R7? The clock input provides the appropriate bias so that the oscillating signal triggers the input divider stage. It is better to set it between 2 and 2.5V. It is best to adjust the setting with an oscilloscope to make the 11F output of the 74F161 get a clean 5-6MHz waveform.

The 12-bit DAC U14 that controls the fine-tuning of the VCO uses TI's DAC7611 with SPI interface. Although the AT90S2313 does not have a user SPI port (its SPI port only works strictly with flash programming), the ability to send SPI data to the DAC can be easily implemented with PB1 to PB4 I/O.

In Figure 4, the jumper J1 below the AT90S2313 is connected to the PD6 port. When reset, the microcontroller detects the state of the port. If J1 is connected, it simply sets the DAC to the middle value and then waits. At this point you can adjust the trimmer capacitor to set the oscillator frequency to the nearest specified frequency to minimize the error. All FM broadcasts in North America set the frequency to an odd multiple of 100KHz, just pick one.

After doing this, then remove the jump and power up the transmitter. At this time, the transmitter should repeatedly adjust the DAC voltage within a few seconds. The pre-scaler repeatedly measures the oscillator output frequency to return it to the specified frequency. This is the normal operating mode that is then used as the FM transmitter module.

The stereo audio signal output from the host sound card is first mixed into a mono signal through a pre-emphasis network (each channel), which is applied to the DC control voltage of the DAC to frequency the output of the oscillator.

The RC value in the pre-emphasis network is determined by the output of the stereo receiver to achieve a flatter frequency response. The set value in Figure 4 is reasonable. Don't expect the selected component value to reach the de-emphasis constant standard value of 75us in North American FM broadcast. Consider that there are still many factors in the VCO that will affect the modulation characteristics. The parameter values ​​I set can make the transmitter get flat. The frequency response. Note that there is no mention of the sky in Figure 4. If the device is placed in a plastic case and its emission distance can reach 50 yards, it is very good, because the government regulations prohibit the use of transmitters with emission radius greater than 50 yards.

I made the VCO part of the circuit with a small 1.5x1 square inch single-sided PCB (as shown in the virtual part of Figure 4). The rest of the circuit is manually connected to a Simm-Stick breadboard. The VCO PCB is designed to be mounted vertically on a Simm-Stick breadboard in a SIP package.

Software and firmware

The application software includes applications running on the computer and client firmware running on the remote. The PC-side service software is written in Visual Basic 6 language.

The remote control firmware is written in AVR assembly language. The FM transmitter is additionally stabilized with a piece of AT90S2313. The software used now is a trial version, so I temporarily use the BASCOM-AVR compiler instead of the AT90S2313.

Client application software

The client application running on the PC has two main functions: most of the time it is detecting the COM1 port to search for commands sent to it by the remote: Another function is to use it to browse the file directory? Specify 4 folders Make? Auto-on-demand folder. The file names in these folders are then converted to data records, which are sent to the remote using the transmit portion of the COM1 port. Unless the contents of the folder change, only download once, because the data is stored in the song list flash memory in the remote control, see photo 2.



Photo 2 PC application to control the playback of MP3 files on the media player

Let me introduce the first function in detail. As mentioned earlier, the 433MHz connection between the computer and the remote control, the RF signal received at the PC 433MHz receiver at 2400bps is converted to serial data, and then sent to the COM1 port. All data formats and data corrections are done by hardware circuits consisting of the NKM2401 encoder/decoder chip. This ensures that the instructions received by the client application are legal.

The NKM2401 uses an 8-byte packet format. All instructions sent by the remote control consist of 2 bytes of synchronous data (0xAA, 0x55) followed by a 16-bit instruction word and 4 additional bytes. The 2-byte instruction word is used to distinguish between 4 types of instructions: play (stop), play the next track, play the previous track, play all and pause. The other 14-bit data is used to select some additional information about the current folder and the song name in that folder.

When you select the folder you want to use, the folder opens, then analyzes the folder and displays the length information of the album. In the application I followed this function and applied it to the transmitter and remote control. This allows you to see all the song names on the LCD of the remote control. In addition, it means you can order songs by simply sending the corresponding number of song locations in the database file.

The client program determines which song to play and how to make the computer play the song? If the song is in WAV format, it is very simple, because Visual Basic's built-in multimedia support features include WAV file playback, however it does not support MP3 file playback, at least the version I use. I looked around for controls that could play MP3 files but couldn't find free or affordable.

In this regard, I have a nail. I just downloaded Microsoft's free Windows Media Player V.7. This versatile program can play MP3 files very well? There are a lot of additional features you need. Like many Windows programs, it has the advantage of supporting shortcuts. My idea is to run my MP3 jukebox client program and Windows Media Player at the same time, and then use my client software to control Windows Media Player. This can be done with a series of Visual Bsic commands.

The second function, select the desired music folder (up to 4)? Download the content to the flash memory of the remote control. This function is only used occasionally. Simply select the folder and click on one of the four number buttons on the left side of the form. There is a window that records the remaining space in the list of song names. If the flash memory is not used up, each folder can hold nearly 200 songs.

To simplify the firmware of the remote control, I assume that all 4 folders will be used, so download them all. If you don't have that many folders, then the insufficient folders will be replaced with a copy of the folder you selected.

Before pressing the download button, the remote control must first be plugged into the COM1 port of the PC to temporarily replace the 433MHz receiver. I used the cable I made myself to plug it into the PC. The other end of the cable is a 5pin DIN plug that matches the receiver and the remote control. This makes it easy to connect. The download time is determined by the write time of the flash memory in the remote control. In all four directories containing a limit of about 200 songs, the download time is about 4 minutes. The download process is displayed by the test box, and the test box is displayed next to the list of client programs, and related information is also displayed on the LCD screen of the remote control.

AVR firmware

I have probably introduced the principle of automatic frequency control of FM transmitters. The program that implements this function is very simple, so it is written in Basic language and compiled with the BASCOM-AVR compiler.

The firmware of the remote control is tricky. Initially I tried to program the Basic program with the BASCOM-AVR compiler but the generated program code was too long, and the flash space in the AT90S2313 could not be loaded. Later, I implemented the remote control function in assembly language, using less than half the program space of the AT90S2313 flash memory.

Like the PC client software, the remote control unit has two functions, one of which is not commonly used. When turned on, it displays the first 4 songs in folder 1, and then loops through the infrared commands issued by the RCA universal remote control and the commands received by the infrared receiver module. The IR signal enters the INPUT CAPTURE?D6 port of the AT90S2313 and is then decoded by the input capture feature of Timer 1 (16-bit Timer/Counter). I chose a relatively simple infrared command structure (Quasar TV code 054) to reduce the workload. The beginning of this instruction structure is a fixed-length initial burst followed by 8-bit data, and the data bits are represented by two different time intervals between the impulse and the impulse. After confirming the initial length of the fixed length, there are only two things you need to do: capture the timing of the next 8 strokes; distinguish them according to the time interval? Assign the appropriate values. Just as the remote control unit described above continuously detects incoming commands and then performs the corresponding functions, the navigation function only limits browsing the song list and jumping from one folder to another. This is done by adjusting the pointing flash to read the song name and sending these ASCII characters to the LCD display.

The corresponding command is sent through the UART transmit port of the AT90S2313 to play, play the next one, play the last one and pause. Similarly, at this time the NKM2401 uses the 8-byte packet format, and the sync byte and the supplemental byte must also be added to the 16-bit instruction word as needed.

Designed with dedicated download function buttons. When it is pressed, the program function becomes a character that is sent from the UART port of the AT90S2313, and the data generated by the PC is transferred to the song flash memory using this function.

Atmel 24C256 flash memory chip? 32K×8 memory of I2C interface, its 5ms write time is a bit slow but it is not harmful to this design, because the data sent from the server computer is 1200bps, which is equivalent to one transmission every 8.3ms. character. The AT90S2313 does not have a dedicated I2C port, so this feature must be implemented in firmware. The main program directly applies the program in Atmel's application notes, which works well.

LCD? A 4 x 40 dot matrix device using the popular Hitachi HD44780 controller. The controller actually contains two LSI controllers and a common data/control interface plus two ENABLEs. I have to rewrite my original 4-digit LCD driver to handle LCD1, 2 line characters controlled by controller 1, and 3, 4 lines of characters controlled by controller 2.

Conclusion

I think this design is very interesting, maybe because it uses no transmission. Abacom's receive/transmit modules work well with the company's encoding and decoding device applications. In addition, the Flash programming capability of the AVR device close to the user makes it easy to write to the assembler.

I am basically satisfied with this design, but still feel some shortcomings. I used to? I don't plan to spend that much time to make a satisfactory FM transmitter module. It may be a bit late now. Recently I have seen Rohm's BH1416F audio-free IC on the market. It is packaged in SOP22 and contains a complete PLL frequency-amplified FM transmitter and FM stereo modulator. I bought this chip and I plan to try it later. If you are not a super music fan, you can use some of the ideas mentioned here to design something better.

Harmonics Filter& Power Factor Correction

Jingkesai Electric Co., Ltd. , http://www.hobaoelec.com

This entry was posted in on