Example: stock market

TCP/IP Networking Internet Radio Using OLED Display and ...

2009 Microchip Technology 1AN1128 INTRODUCTIONI nternet Radios are defined as a hardware device thatreceives and plays audio from Internet Radio stationsor a user s PC . The audio is streamed to the radiousing MPEG-1 Audio Layer 3 (MP3), Windows MediaAudio (WMA) or Advanced Audio Coding (AAC)compressed audio formats. The Radio stations rangeanywhere from public AM or FM Radio stations thatbroadcast over the air as well as on the Internet , toUniversity Radio stations down to any individual wishingto create their own Radio idea of an Internet Radio is not a new idea. You canbuy commercially available Internet Radios, ranging inprice from $129 US to $400 US, from companies suchas Barix , Logitech /Slim Devices, Roku Labs andPhilips . Most of these make the connection usingwired Ethernet; some have a wireless focus of this application note is to show how tocreate a low-cost Internet Radio that connects toSHOUT cast servers and plays MP3 audio.

The audio is streamed to the radio using MPEG-1 Audio Layer 3 ... compressed audio formats. The “radio stations” range anywhere from public AM or FM radio stations that broadcast over the air as well as on the Internet, to University radio stations down to any individual wishing ... TCP/IP Networking: Internet Radio Using OLED Display and ...

Tags:

  Using, Radio, Internet, Networking, Delo, Ip networking internet radio using oled, Ip networking, Internet radio using oled

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of TCP/IP Networking Internet Radio Using OLED Display and ...

1 2009 Microchip Technology 1AN1128 INTRODUCTIONI nternet Radios are defined as a hardware device thatreceives and plays audio from Internet Radio stationsor a user s PC . The audio is streamed to the radiousing MPEG-1 Audio Layer 3 (MP3), Windows MediaAudio (WMA) or Advanced Audio Coding (AAC)compressed audio formats. The Radio stations rangeanywhere from public AM or FM Radio stations thatbroadcast over the air as well as on the Internet , toUniversity Radio stations down to any individual wishingto create their own Radio idea of an Internet Radio is not a new idea. You canbuy commercially available Internet Radios, ranging inprice from $129 US to $400 US, from companies suchas Barix , Logitech /Slim Devices, Roku Labs andPhilips . Most of these make the connection usingwired Ethernet; some have a wireless focus of this application note is to show how tocreate a low-cost Internet Radio that connects toSHOUT cast servers and plays MP3 audio.

2 Thehardware uses the PIC18F67J60 microcontroller withintegrated 10 Base-T MAC and PHY and an externalMP3 audio decoder. The software uses the standardMicrochip TCP/IP Stack with external serial SRAM buff-ering to ease the streaming of compressed audio data tothe MP3 decoder. Figure 1 shows a picture of the Inter-net Radio Demonstration Board (DM183033) that isavailable for purchase on MicrochipDirect or throughone of Microchip s distributors. Figure 2 shows the blockdiagram for the Internet Radio design used in thisapplication 1: Internet Radio DEMONSTRATION BOARDA uthor:Howard SchlunderRodger RicheyMicrochip Technology 2 REAL ICE EthernetJackOLEDD isplayPush ButtonSwitchesTCP/IP Networking : Internet Radio Using OLED Display and MP3 Audio DecoderAN1128DS01128B-page 2 2009 Microchip Technology 2: Internet Radio BLOCK DIAGRAMMAKING THE CONNECTIONThe heart of this design is the PIC18F67J60 micro-controller. This MCU has an integrated 10 Base-T MACand PHY peripheral in addition to the standard periph-eral set of 64-pin PIC18 MCUs.

3 It controls the entireprocess, from making the connection to the audioserver, to streaming the data to the MP3 decoder, todisplaying status on the LEDs and OLED Display andreading user input on the push button this particular application does not use many ofthe resources on the PIC18F67J60, it does have a fullcomplement of peripherals. Table 1 shows the featureset for all PIC18 FXXJ60 1:PIC18 FXXJ60 MICROCONTROLLER FAMILY FEATURES23K256 x 232-KbyteSerialSRAM32-KbyteSerialSRAMH eadphoneConnectorMP3 AudioConnectorVS1011 OLED Display128 x 64 MCP1703+5V to +9 VRJ45 MagJack I/O PinsSPIPIC18F67J6010 Base-TMAC/PHYI/O PinsI/O PinsCSCSD eviceFlash Program Memory (bytes)SRAM Data Memory (bytes)Ethernet TX/RX Buffer (bytes)I/O10-Bit A/D (ch)CCP/ECCPMSSPEUSARTC omparatorsTimers8/16-BitPSPE xternal Memory BusSPIM aster I2C PIC18F66J6064K3808819239112/31YY122/3 NNPIC18F66J6596K3808819239112/31YY122/3 NNPIC18F67J60128K3808819239112/31YY122/3 NNPIC18F86J6064K3808819255152/31YY222/3 NNPIC18F86J6596K3808819255152/31YY222/3 NNPIC18F87J60128K3808819255152/31YY222/3 NNPIC18F96J6064K3808819270162/32YY222/3 YYPIC18F96J6596K3808819270162/32YY222/3 YYPIC18F97J60128K3808819270162/32YY222/3 YY 2009 Microchip Technology 3AN1128 The second crucial piece of this application is theMicrochip TCP/IP Stack.

4 The Stack is what makes theconnection to the audio server and then receives theaudio stream for deployment to the MP3 decoder. TheStack is a suite of programs that provides services to allTCP/IP-based applications. You don't need to know allof the intimate details of the TCP/IP specifications touse the Stack. Microcontrollers Using embedded TCP/IP Stacks can be used to enable a myriad ofapplications, such as those shown in Figure 3:EMBEDDED ETHERNET ENABLED APPLICATIONSB ased on the TCP/IP reference model, the Stack isdivided into multiple layers, where each layer accessesservices from one or more layers below it. Per thespecifications, many of the TCP/IP layers are live , inthe sense that they not only act when a service isrequested, but also when events like time-outs or newpackets arrive. The Stack is modular in design andwritten in the C programming language. Typicalimplementations will use 30-60 Kbytes of code,depending on which modules are included, leavingplenty of code space on the PIC18 FXXJ60 2 shows many of the supported protocols.

5 Thesize of each protocol is not listed here in the applicationnote but is available in the help files that come with theTCP/IP MonitorLightsSecuritySprinklerSystemTher mostatGamesPowerOffice PhoneCell PhoneFire/SmokeDetectorPoolLeveler10 MbpsEthernetAN1128DS01128B-page 4 2009 Microchip Technology 2:MICROCHIP TCP/IP STACK SUPPORTED PROTOCOLSThe Microchip TCP/IP Stack software provides manyessential services to implement the Internet Radio ,including protocols, such as TCP, UDP, DHCP, DNS, IPand ARP. The Transmission Control Protocol (TCP)transports the main MP3 audio and metadata while pro-viding flow control to prevent the SHOUT cast serverfrom sending more data than can be held in the InternetRadio RAM at any given User Datagram Protocol (UDP) transports DHCPand DNS packets. The Dynamic Host ConfigurationProtocol (DHCP) automatically provides the board s IPaddress, gateway address, subnet mask and otherconfiguration parameters when the Ethernetconnection is first established.

6 These configurationparameters tell the board how the network is organizedand how to reach the Internet . The Domain NameSystem (DNS) is used whenever the user changes thecurrent Radio station. It converts the Radio station sstatic host name (ex: )into a potentially dynamic IP address ( ) which the rest of the TCP/IP Stackprotocols Internet Protocol (IP) transports both TCP and UDPpackets across the Internet to the correct , before the IP transport can be used, the Stackuses the Address Resolution Protocol (ARP) to obtainthe Ethernet MAC address (ex: 00-04-A3-BE-EF-1E)associated with the local Internet gateway. All of theseservices work simultaneously, or in tandem, to establishthe connection to the Radio server and then ensure arobust user listening experience. These protocols allwork in the background without requiring any manualuser configuration or this application is based on the PIC18 FXXJ60devices, the Stack has been optimized for use on anyPIC18, PIC24, dsPIC or PIC32 device with enoughprogram memory.

7 It includes support for the ENC28J60 Stand-Alone Ethernet Interface Controller for each ofthese device platforms. The best part is that the Stackis royalty-free and requires a no fee license agreement,restricting use to Microchip microcontrollers and digitalsignal controllers. The Stack can be downloaded The files for the InternetRadio are part of this that we have the embedded application defined,we need to have the audio source. There are manysources of audio available off the Internet Using file for-mats described previously. For this application, we willfocus on the SHOUT cast protocol and is a freeware audio streaming technologydeveloped by Nullsoft . SHOUT cast only uses MP3 orAAC audio encoding and an HTTP-like protocol totransfer files from the server to the client. SHOUT castis available in both server and client forms on Windows95/98/ME/NT/2000/XP, Macintosh OS X, FreeBSD ,Linux and Solaris at make the connection from the PIC18F67J60 deviceto the SHOUT cast server, we must send it a following example shows a typical data structurewithin the Internet Radio code used to establish 1:The structure, stations[ ], holds the information forthe various Radio stations that are preprogrammed intothe microcontroller.

8 Metadata refers to informationabout the data. In the case of a SHOUT cast stream,metadata refers to the song name and artist. If meta-data is not enabled, the human readable name of theradio station that is provided in the structure can bedisplayed. With metadata enabled, the station namecan be automatically obtained from the SHOUT castserver during the initial connection phase. In the cur-rent application, the HumanName string is not used. Weuse the Radio station name provided in the metadatafrom the SHOUT cast server. The remote DNS HostName is provided, specifyingwhere on the Internet the SHOUT cast server islocated. The TCP port through which the connectionis made follows. Normally, the port is 80, but can varydepending on the setup of the SHOUT cast serveryou are connecting to. ApplicationHTTPFTPSMTPT elnetDHCPDNSSNMPNetBIOSB ootloaderPingTransportTCPUDPICMPI nternet and Network AccessIPv4, ARPP hysicalEthernet ENC28J60 or PIC18F97J60 Familystations[0].

9 HumanName = " Top Hits, 96K";stations[0].HostName = " ";stations[0].port = 80;stations[0].Message ="GET /stream/1014 \r\n""Host: \r\n""Accept: */*\r\n""Icy-MetaData:1\r\n""Connection: close\r\n\r\n"; 2009 Microchip Technology 5AN1128 The last piece is the Message to initiate the connectionto the SHOUT cast server. The GET command specifiesthe name of the audio file or stream on the server. TheHost specifies which target server we want to connectto. In some cases, there are multiple servers runningthrough a single Internet IP address, and in mostcases, the Host parameter is always identical to theHostName field. The Accept field indicates that weare interested in receiving any audio data type, not lim-ited to MP3s alone. In addition to MP3s, the InternetRadio can also play uncompressed PCM WAVstreams. Icy-metadata determines if song metadatashould be inserted into the stream. The most commondata inserted is artist name and song title.

10 In the currentapplication, we enable metadata and parse the incom-ing stream. Typically, the SHOUT cast server sends avariable length block of metadata after every8192 bytes of audio. We must continuously check thelocation in the stream and extract the metadata. If themetadata was not filtered out of the stream, the audiodecoder would play it, resulting in an audio glitch. TheConnection: close field notifies the server that itshould immediately disconnect our TCP client if theserver runs out of data to send us. This generallyoccurs only during the initial connection phase if weprovide an invalid GET string, or the server isoverloaded and cannot handle another Radio immediately disconnecting, we can attempt to auto-matically reconnect or give up and switch to a differentradio typical response from the SHOUT cast server isshown below. Each of the tags in this response starts withan Icy prefix. This is part of the SHOUT cast 2:The main information used by the Internet Radioapplication is the following: icy-name Radio station name icy-metaint the interval at which metadata arrives in the audio stream icy-br the bit rate in kbps of the audio stream; the bit rate can also be read out of the MP3 decoder chipIf the Radio receives the icy-name SHOUT castresponse, the MP3 client task will execute a callbackfunction, allowing the main application to save theresult.


Related search queries