Internet radio on WRT54G-TM

Discussion about my Wifi Radio project at http://mightyohm.com/wifiradio/ or my WL-520gU talk at NOTACON.
Loslobos
Posts: 11
Joined: Wed Sep 29, 2010 10:43 am

Internet radio on WRT54G-TM

Post by Loslobos »

After several days of activity in my scrapyard and soft punishment from Jeff's side (I'm sorry, Jeff - there will be no more waste in project side) I decided to describe my project.
It will be also opportunity to keep summary of accomplished objectives in one place.
So...
Hardware base: Linksys WRT54G-TM
Objectives:
1) Hack router to DD-WRT - done
2) Add 2 USB ports to the router - done
3) Add SD card reader - done
4) Hack the router to OpenWRT - done
5) Add packages to utilize sound layer on 2.4 core - done
6) Add USB sound card - done (first card i bought was able only to beep, second one started to reproduce sound just from the firts moment I launch mpd/mpc)
7) Add small mini-jack as an audio output to the router - done
8) Summary: I can play internet streams. This part is completelly done.

To be fixed: when router is on-line - my wife's laptop can not reach Wi-Fi network (probably I need to check /etc/config/network and /etc/config/wireless - it looks like running WRT54G-TM is acting as "only possible receiver" and any other device even can not get IP address from DHCP running on my "master router"). When moded WRT54g-TM is off - my home network is working fine.
Just for the info purposes: my home gateway is running on another WRT54G-TM. DD-WRT is loaded to this device.

To be done:
1) To write some simple program on ATmega8 (I'm using Bascom AVR as programming environment).
2) Make a prototype board for uP. As peripherials uP will have:
- LCD 16x2
- TSOP1736 (IR receiver for 36kHz carrier)
- 4-6 pushbuttons
- no external oscillator - internal 8MHz RC osc. will be used.
Objective:
- Use smallest possible count of discret parts.
- Every 2 second ATmega8 will request router to get title/name (different than Jeff did - I dont want to have an automated procedure which will send this info to router every second). Collected info will be displayed on LCD (with scroll - if necessary)
- When IR code (in RC5 system) will be received - ATmega8 will send to router requested command (mpc next, mpc prev, mpc volume xx... etc). Every command will be tailed by Chr(13) as CR command. Maybe also LF command will be necessary - time will tell. For volume settings xx will be calculated by uP. I want to have steppings 0, 1, 2, 3,...10, 12, 14, 16, 18, 20, 25, 30, 35... 50, 60, 70... up to 100. Let it be a quasilogarythmic regulation ;)
- Another thing I wonta for uP to do is power cut-off when on/off commands will be received from IR. A small relay will cut the power from the router, but ATmega will be still powered up (via 7805 voltage regulator from router's power suply). When router will go to sleep, LCD will serve as a regular clock (PCF8583 connected to uP via I2C interface).
- Eventually I also want to be abie to remotelly dimm LCD backlight - independently of router's activity status.

What I need at this time: just to digg into Jeff's script and change this script to only set router's UART port baudrate at the startup to 19200.

In case of any change in my project - I'll report it in hope this will be usefull for others.
User avatar
mightyohm
Site Admin
Posts: 1064
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Internet radio on WRT54G-TM

Post by mightyohm »

Thank you very much for sharing your project here. :D
Loslobos
Posts: 11
Joined: Wed Sep 29, 2010 10:43 am

Re: Internet radio on WRT54G-TM

Post by Loslobos »

Eventually! MAC problem solved.
1) I decided to use Kamikaze 8.09.2 and change MAC by uci command. Worked fine but... Kamikaze has no stty command implemented to this was dead end.
2) Once again Jeff's precompiled firmware was installed. To omit MAC problem I started to think :) I came up with an idea: why I'm still fighting with "radio router" whilest my home router has comfortable http GUI? Is it possible to change MAC od this one? Of course - this was an bull's eye shot! After first router MAC is changed, I have no problems with network using Jeff's precompiled TRX on my WRT54G-TM.

So current status of project is (it is woth to be mentioned / emphasized, that I'm here thanx to Jeff's suggestions):
+ network problem
+ "radio" router LAN/WAN config
+ UART set to 19200 baud (ATmega8 will operate at this speed, not at 9600 baud like Jeff's interface)
+ mpd config made persistant (mpd.conf - option "state_file")
+ very rough version of ATmega software is working (can detect when router is ready to work, can send mpc prev/next commands after proper button is pressed)
- make ATmega software smarter (request to get title/name from mpc, deal with replay to this request)
- add 2x16 LCD display procedures to ATmega
- add IR remote routines to ATmega software (question is if there will be no problem with interrupts - UART needs one, IR procedure needs one too, ATmega has two interrupts available, but challenge is to deal with timings)
- start dealing with WRT54G-TM case mod - how to join its blue box with LCD display... Hm... any suggestons?
Unfortunatelly during week I'm not expecting I'll have a free time, so project have to wait till next weekend.

Regards
Loslobos
Posts: 11
Joined: Wed Sep 29, 2010 10:43 am

Re: Internet radio on WRT54G-TM

Post by Loslobos »

Well... Last time I had no chance to deal with my device. Changes in professional life, skill transfer at new company...
Since yesterday's evening things are lokking better so I can sacrifice some time to my device.
Report is
+ network problem
+ "radio" router LAN/WAN config
+ UART set to 19200 baud (ATmega8 will operate at this speed, not at 9600 baud like Jeff's interface)
+ mpd config made persistant (mpd.conf - option "state_file")
+ very rough version of ATmega software is working (can detect when router is ready to work, can send mpc prev/next commands after proper button is pressed)
+ make ATmega software smarter (request to get title/name from mpc, parser is working so I can determine station name and song title, and then display them)
+ commands supported by ATmega8: mpc volume (0-100: step 10), mpc play (1-10). seems no other commands are necessary
+ add 2x16 LCD display procedures to ATmega
+ add IR remote routines to ATmega software (interrupts can not be used here - proc moved to main loop). Supported functions: volume change, station change, mute/unmute.

- turn router on/off by additional relay
- real time clock (DS8535), maybe with alarm (either turn router on or play bzzzzz... ) ;)
- start dealing with WRT54G-TM case mod - how to join its blue box with LCD display... Hm... any suggestons?

Remark: as new Bascom AVR became available - I decided to change my environment from version 1.12.0.0 to newest 2.0.1.0.
Loslobos
Posts: 11
Joined: Wed Sep 29, 2010 10:43 am

Re: Internet radio on WRT54G-TM

Post by Loslobos »

+ IR remote routine improvement. Supported functions: volume change, station change, mute/unmute, on/off
+ turn router on/off by additional relay, with detection when OpenWRT is ready
+ real time clock (DS8583), when router is off - time/date is being displayed
+ store / rocover last played station / volume level after router turned on/off (DS8383 is acting as external non-voilaile memory)
- routines to setup clock / alarm (at this time only reading time from Dallas chip)
- alarm (either turn router on or play bzzzzz... )
- start dealing with WRT54G-TM case mod - how to join its blue box with LCD display... Hm... any suggestons?
- 2x16 LCD Display backlight driving
- code optimozation, comments & remarks to source
Last step planned: prepare schematics, publish Bascom AVR source code / compiled HEX file (due to code size after compilation, source can not be compiled with using BascomAVR Demo - licenced version is necessary). Maybe someone is thinking about doing things my way, which in fact is a bit "ortogonal" to Jeff's one ;)

One mistake was made in all descriprions above: Dallas DS 8583 is used (not DS 8535). Silly digits...

Evidence of current status - below. Iniversal board is quite enough...
DSC07266.JPG
DSC07264.JPG
User avatar
mightyohm
Site Admin
Posts: 1064
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Internet radio on WRT54G-TM

Post by mightyohm »

Looking good! That is a tiny board you have there, and a tiny LCD too!

I'd like to see someone do a radio with an LCD like this one, which is beautiful:

http://jeelabs.org/2010/11/15/meet-the-graphics-board/
Loslobos
Posts: 11
Joined: Wed Sep 29, 2010 10:43 am

Re: Internet radio on WRT54G-TM

Post by Loslobos »

Yep - graphic LCD would be nice thing. I always wanted to start dealing with these LCDs. Maybe someday...

My project status:
- as I'm using an external amplifier - function of alarm will not be implemented (OK - router can be started at any time, but what is the reason to have amplifier still powered on? OK#2 - Additional relay could help but... Nah, I don't want this anymore)
- any other planned functions are working.
- Bascom source code -
2010.12.19 OpenWRT LCD 2.9.zip
(7.26 KiB) Downloaded 870 times
- schematics - I had no time to prepare something like this.
- files (.conf) from the router will be added later - sorry, no time this time.
- photos - same as above

Regards
User avatar
mightyohm
Site Admin
Posts: 1064
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Internet radio on WRT54G-TM

Post by mightyohm »

It sounds like you are done with hardware and software then!

Are you still planning to build a case of some kind to hold everything?

Congratulations on getting everything working. :D
Loslobos
Posts: 11
Joined: Wed Sep 29, 2010 10:43 am

Re: Internet radio on WRT54G-TM

Post by Loslobos »

Congratulations should go to You, Jeff. Your project is the basis for my one. I only added a bit smarter circuit to recognize strings from router, drive LCD display, deal with remote controller and 5 keys keyboard. Nothing more - so I'm still thankful to You.

I have a case done for this project. It is taken from old analogue SAT receiver (I don't remember his brand at this moment and I'm at work so no chance to take a look at my device ;)). Maybe some amplifier will be added in the future to this case... There is still a lot of empty space in it.
I plan to add screenshots and schematics this week so You will be able to see the result.

What I plan more is, to prepare some simple program to read remote codes and store them into PCF8583 memory. Idea is to publish compiled code (not a Bascom source - because not all here have license for BascomAVR and can not compile this code) + this small program for RC codes recognition. Everyone would be able to load this small code into ATmega8, receive / store proper RC5 codes into real time clock's memory, then load compiled code of "main" program into ATmega and have this working with chosen remote controller. This would be a bypass because I have no spare area and can not add this functionality to main code - second program is necessary as I don't want to jump from ATmega8 to ATmega644 or ATmega16. With assumption that this learning should be done once - I think this is not a hard constrain. Routines for store/restore RC5 codes to/from PCF8583 are already included into source I attached previously, but are not used by program, so I commented them to inform compiler that they shouldn't be compiled.
Added Dec 27th:
Schema.jpg
Schematics...
BTW: I asked You about how to play MP3 from SD card (as I have two USB ports + SD mod). I think the simpliest solution for me will be to add simple MP3 player and drive this device with my ATmega (play, next, previous, stop, on/off). I know this is not elegant solution, but I really do not want to touch my OpenWRT software as I'm afraid once screwed - I'll have a lot of problems to have this software working again.
janw
Posts: 10
Joined: Sun Nov 28, 2010 1:46 pm

Re: Internet radio on WRT54G-TM

Post by janw »

mightyohm wrote:Looking good! That is a tiny board you have there, and a tiny LCD too!

I'd like to see someone do a radio with an LCD like this one, which is beautiful:

http://jeelabs.org/2010/11/15/meet-the-graphics-board/

I am trying to build one with this 240*128 graphic LCD. I'm also writing the code in bascom but I will use an Atmega16 as I need a lot of pins to drive the LCD. I'll use a rotary encoder as inputdevice.

Radio is working fine and the LCD is working fine too, I just need to bring the two together now.

I'm still figuring out how to add extra webcontent to the display

Jan
Attachments
lcd.jpg
Post Reply