Raspberry Pi Serial Port Uart Sanded
If you are running Raspbian or similar then the UART will be used as a serial console. Using a suitable cable, such as the TTL-232R-3V3-WE, you can connect it to your PC and using some simple terminal software set to 115200-8-N-1 use the command line interface to the Raspberry Pi in the same way as if you we're using. [ 0.189373] Serial: AMBA PL011 UART driver [ 0.189565] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 83, base_baud = 0) is a PL011 rev2 [ 0.665364] console [ttyAMA0] enabled [ 0.669793] bcm2708_vcio 3f00b880.mailbox: mailbox at f300b880 [ 0.743319] bcm2708-dmaengine 3f007000.dma: DMA.
USB to TTL UART Cable, FTDI Chip The FTDI Chip TTL-232x USB to Serial UART (TTL level) converter cables provide a simple and fast way to convert microcontroller UART serial I/O to USB. The TTL-232R contains a small circuit board which includes the FT232x chip. Encapsulated in a USB-A connector, making the cable easy and straight forward to use. The circuit is powered from the USB +5 V power pins, and any Vcc connection is always at +5 V dc. However products are available with signal TTL logic levels of either +3.3 V or +5 V. These cables are supported with Microsoft WHQL certified VCP drivers for Windows, Apple Mac, and Linux.
All of which are available, royalty-free from the FTDI website. The product detailed below complies with the specifications published by RS Components. Where applicable it provides assurance that electrostatic discharge sensitive devices have been handled and packed under conditions that meet the administrative and technical requirements of the ANSI/ESD S and BS EN 61340-5-1:2007 Electrostatic Control Standards. 429-307 Description FTDI Chip, 3.3 V TTL USB to UART Cable, TTL-232R-3V3 Manufacturer/Brand: FTDI Chip Mfr.
The internet hosts lots and lots of online radiostreams, most of them with a certain theme, ranging from old time classics to Tibetian riverdancing. I must admit that I love to listen to them while I'm building stuff, as I can choose the music I like without listening to the same cd's over and over again. The only problem is that I always needed to have a computer neaby to get an internet connection.
So I looked around to buy one, but they are quite expensive and besides that, it is a lot more fun to make your own. As I had no clue at all about how to do the wifi and internet part of the project, I searched the net for clues and I stumbled upon. This site belongs to and he has an excellent step by step tutorial on it for hacking a wifi router into a wifi radio. If you follow his instructions, you will end up with a working radio but I decided to build my own graphical interface for it and my own case. I really wanted this project to look as nice as possible, so I invested a lot of time in designing and building the case.
I hope that this build is awesome enough to have a chance in the lasercutter contest or the makerbot contest as I would love to have one of these machines. They would allow me to make even nicer looking and more intricate cases and parts and I wouldn't have to bother my friends to mill parts for me;) ( in fact I might be able to help them out then). I would like to thank Jeff Keyzer for helping me with setting up the router correctly, Izaak for helping me with out with the CNC part and my wife for helping me with the veneer. Step 1: What Do We Need for This Project? As you can imagine, we'll need a lot for this project. First of all, we'll need an ASUS WL-520gu wireless router.
This router will handle the internet connection and also play the music. Secondly, we'll need a RS232 to usb converter (3,3V version).
We will need that to hack the router. I used a couple of xbees to do this as they are 3,3V and a few wires less on my desk is always handy. If you don't have those you can buy converter cables all over the net ( for instance). We'll also need a USB sounddevice. I used a creative SB0270 external soundcard that I had lying around for years but you can buy very cheap small thingies everywhere.
If you're not sure whether the sounddevice you have will work, then you can go to the forum on. There is a list there with working devices. Amplifier There are 2 options to make the sound audible. You can either use an external amplifier or you can use an internal one. I actually combined the 2 options. I used a kit (K-VOTI-003 on ) for the internal amplifier but I also added audio output ( stereo cinch) on the back for an external amplifier.
Ofcourse you can build you own amplifier too but I was a bit short in time If you use an internal amplifier, then you will need some speakers too. I also added a headphone connector to the front. Interface For the interface we'll need: • A graphical LCD: I used a monochrome 240*128 LCD ( LCD-21 on ) • An ATmega16 or 32: The size is depending on the amout of graphics you want to display. I used an smd version but ofcourse you can make your project with thru-hole components. • A DS1307 Real Time Clock • Battery holder + 3V battery: CR2032 in my case • A 32.768kHz quartz crystal • A rotary encoder: I used an alps encoder with pushbutton • A 10K potentiometer • A bunch of resistors: 3 x 1K5, 2 x 4K7, 4 x 10K • BSS138: 2 x for the level converter • Some male and female headerpins • A connector for your programmer • 3 double switches • 5 led's The Case For the case we'll need a lot of 18mm MDF and some real wood veneer. The front and the backpannel are made of alucobond which is a sheet of poylethylene sandwitched between two 0.8mm layers of aluminium.
We'll also need 5 holders for the LED's and a powerconnector. Step 2: Hacking the ASUS Router. I won't go into much detail on how to do the hacking of the Asus WL-520gu, as it is fully explained on the.
You only need to follow it until part 5 because after that we'll build a different interface and case. Jeff Keyzer deserves all the credits for this part an I also want to thank him for helping me out with the problems that occured. I'll give a quick summary here of the 5 steps: Steps 1 and 2 are a general introduction but it is nice to read them as they contain some interesting information. The fun begins in step 3! Void the warranty (Yay!!) by opening the case of the ASUS. When it is opened you need to locate where you can solder a 4 pin male header. It is located near the silkscreen ASUS logo.
Soldering the headerpins was a bit tricky. Best way to do it is to remove all the solder that is in the holes before you even try. In step 4, you'll install OPENWRT on the router.
Follow this step very closely as it is possible that you break your router forever when you do something wrong. If you succeed in installing OPENWRT, you can continue with setting up your internetconnection in the second part of step 4. In step 5 you will install mpd (music player deamon) and configure it.
If you have completed step five, you should hear some music! After completing these 5 steps, you can carry on with this instructable. Alvarez Guedes Disco Grafia. Step 3: Add an External Mpd Client. At this stage, you could close the router again and use an external mpd client to control your radio. In this instructable we will also build an interface but having a way to acces the player while testing is always good.
You can download a lot of mpd clients, even for you Iphone. I downloaded and installed the Ario client. To do so, I needed to install GTK+ too ( ). When you have installed the program, you need to set up the connection. By host you add the ip-address of your router and by port 6600.
When done click the connect button and you should be able now to control your radio from your pc. Step 4: Building the Interface (hardware).
Building up the interface is not very difficult. It can be done on a piece of veroboard or you can make your own PCB. Connect the LCD to the microcontroller I would love to tell you what pins need to be connected to what but every LCD has it's own pinout. You can find the right way to do it in your datasheet. When working with graphical LCD's, I'll always us port A for the data pins and the higher part of port C for the control pins. That leaves me portc.0 and portc.1 for I2C communications. Don't forget to add the 10K potentiometer between Vee, V0 and Vss for brightness adjustment.
My LCD had an internal resistor for the LED so I just hooked it up to 5V and GND. You could ofcourse connect the LED with one of the PWM pins on your microcontroller to controle the brightness, but I didn't opt for that.
Connect the DS1307 to the microcontroller Connect pin 5 of the DS1307 to portc.1 of the microcontroller ande pin 6 to portc.0. Don't forget to add the two 4K7 pullup-resistors to those lines. Add the crystal to pin 1 and pin 2 of the DS1307 and add the batteryholder between pin 3 (positive) and pin 4 (negative). Then hookup pin 8 to 5V and pin 4 to GND.
Connect the rotary encoder to the microcontroller The pushbutton will have 2 pins on your rotary encoder and the encoder itself will have 3 pins. Connect one pin of the pushbutton to INT0 or portd.2 on the microcontroller and the other pin to GND. Then connect the middle of the 3 other pins to GND, one to INT1 or portd.3 and the last one to portd.4.
All the lines to the microcontroller need a 1K5 pullup-resistor. Connect your microcontroller to the RS232 pins on the router If you look at the pins on the router, you will notice that one of them is connected to a thick diagonal trace. That pin is 3,3V and lets call it pin 1. Pin 4 is GND, pin 2 is RX and pin3 is TX. Connect RX to TDX on your microcontroller (portd.1) and TX to RDX (portd.0).
But because our microcontroller needs 5V and the router 3,3V, We'll need a level converter. You can learn how to build one in one of or you can one online. Don't forget to add your programming link.
That is all we need to start programming the interface. Before we can start to communicate with our router, we need to change its baudrate. The routers baudrate is 115200 and we want it to be 9600 (I was told that 19200 works fine too). Another thing we should change is the echo. Now the router echos back every charater that we sent to it and that would make our Uart-buffer a mess, so we need to turn that off. I tried to write a script for the router to change those 2 things and to make that script autostart when the router starts up.
The script was working fine but it just wouldn't start by itself (most probably something caused by my inexperience). So I decided to look for a script that was running for sure at startup and add a few lines to that. I found a script named diag.sh in the etc/ folder. It drives the LED's in front of the router.
So I added my code to that script and it worked like a charm. To do that yourself, telnet or shh to router and type vi etc/diag.sh into your console. Now you should see the code. Press I to edit and add stty 9600 -echo. Communication with the router may seem a bit daunting (well it did to me), especially when you are new to it. But it isn't as difficult as it seems. Sending commands to the router First we need to decide what we want the radio to do.
We basically want it to: • play • pause • stop • change station • change volume If we look into the list of commands for mpc we see that: • the command for play = mpc play • the command for pause = mpc pause • the command for stop = mpc stop • the command for volume = mpc volume [+/-] num (numeric value) The changing of the station is a bit more difficult. To be able to change to another station, mpc needs to know it's address. Easiest way to do so is to preload all our favorite stations into a playlist on the player. So at the beginning of our code we will add the command: mpc add address for each station we want to preload into the router. Before we start to add stations, we could issue a mpc clear command. This will clear all previous lists, just in case we made any changes to our list. After all this is done, we can change the station with the mpc play num command, where num is the position of the station in our added playlist.
In Bascom, sending these commands to the router is very easy. Everything is done with PRINT: PRINT 'mpc play' or PRINT 'mpc volume +5' There is no need to add a Carridge Return (CR or ascii 013) to the command as the PRINT statement adds that by itself. So as you can see, sending commands to the router isn't difficult at all! Requesting and receiving info from the router Requesting and receiving info from the router is a bit more difficult. Again, we'll need to decide what info we want to receive from the router. All input in this project is done by a rotary encoder. It is basically the same as your mousewheel including the push-function.
However, where your mousewheel is most likely an optical encoder, I used a mechanical encoder for my project. A rotary encoder on A and B channel (both a pin) with one common pin that can be either connected to GND or Vcc. As we use it with interrupts, we'll connect it to GND. The A and B channel open and close in a fixed patern and by reading this pattern, we know in what way the encoder is turning. By adding one channel to and interrupt, we are able to trigger the read subroutine automatically when the encoder is turned. In bascom, that will give us: A Alias Pind.3 B Alias Pind.4 Config A = Input Config B = Input Config Int0 = Falling Dim Counter As Integer Set B On Int0 Getencoder Counter = 0 Enable Interrupts Enable Int0 Do Your code here Loop Getencoder: Waitms 1 If A = 0 Then If B = 0 Then Incr Counter Else Decr Counter End If Return End The pushbutton on the rotary encoder works just like a normal button, so nothing much to explain there.
Step 8: Graphics in Bascom. When having a graphical LCD, it's always nice to have some graphics on it. So you can either draw everything pixel by pixel (good luck!) or you can import premade graphics. The way to do it in Bascom is as follows: • Draw an image in your favorite program.
Don't forget the maximum dimensions (in my case 240*128) • Save it as a monochrome bitmap. • Run Bascom, goto Tools ->Graphic converter.
• A window opens, set the dimentions of your LCD, load your image and save it in the.bgf format. Don't forget to set the font to the type you are using. Once you have converted the bitmap, can use it in your code. You need to include the bgf file to be able to use it. Cls Showpic X, Y, Image End Image: $bgf 'image.bgf' The X and Y parameters specify where the picture must be displayed. X and Y must be 0 or a multiple of 8. The picture height and width must also be a multiple of 8.
Step 9: Code. I'll just add the full code here. It is a bit messy as I didn't have any time left to clean it up. When I've cleaned it up (and improved it), I'll post the new code. I'll also add the pictures here that I used so that you can use them too. When you program your Atmega, you should also disable JTAG in the fusebits and set the internal oscillator to 8MHz.
The code will fit into an Atmega16 but I used an Atmega32 as I want to add some extra features later. The case is build out of multiple layers of 18mm MDF and a 12mm layer of MDF for the front. The layers where CNC-milled into their shape, but not entirely cut out (about 1mm remained). This way they were stronger and easier to glue and clamp. Three holes were milled through the plates to serve as guides: I could add dowels to make positioning the layes on top of each other easier. When everything was dry the layers where cut out with a sharp knife and the front layer was glued on.
When this layer was dry and cut out, everything was cleaned up and sanded to give it a smooth shape. The case is finished in a white veneer. Step 11: The Front and Back Panel. The front and back panels where CNC-milled out of alucobond. Three switches and five LED's (in LED holders) were inserted into the frontpanel.
The switches are for: • Main power • Amplifier power • Toggle front or back output The LED's are for: • Main power • Amplifier power • Air (wifi connected) • Router ready • Soundcard playing There is also a headphone output in the front, which cuts all other outputs when a headphone is inserted. After all these devices were added to the front panel, the panel was glued to the the body. After that the rotary encoder was added and finished off with a nice knob. The back panel had an audio output and a programming connector inserted and glued to it, a powerconnector was screwed to it and the router was added.
The panel is screwed to the body so that it can be removed easely. Step 12: Bringing Everything Together. So now it is time to bring everything together.
First the speakers and the LCD (with on its back the PCB for the interface) are screwed into place. Fitting the amplifier As I said before, I used an amplifier that I bought as a kit, so I soldered that together.
That is going in next but first of all we need to solder the wires that come from the Amplifier Power - LED to the place where the led should normally sit on the board. We also need to connect the audio coming from the soundcard to this amplifier.
This is a bit more complicated as it runs from the soundcard to the headphone connector, then to a switch from where it goes either to the amplifier or to the connector in the back. Once everything is connected and the speakers are also connected to the amplifier, then the amplifier is screwed into the case. Fitting the router and soundcard I removed the USB-connectors from both devices and soldered them together with wires instead of connecting them via a USB cable. I had to do that because otherwise the router would't fit in the back panel. So I also had to remove the power connector of the router and solder that directly to the powerboard too. I removed the Air and Power LED from the router and wired the LED's in the front panel to those pads. I also removed the Play LED from the soundcard and wired that to an LED in the front. Sic Alps Napa Asylum Rarity more.
Then the soundcard was screwed into the case and the router was fitted into the back panel. Wiring the last things up The rotary encoder and the RS232 from the router are connected to the interface board via a flatcable and the last remaining LED is connected to the powerboard.
Connect all the devices to the powerboard too. The powerboard The powerboard is a little piece of veroboard with two 78S05 (2A), and a bunch of capacitors soldered to it.
One of the regulators is for the screen and interface and one for the router. You really need to cool the regulator of the router. The amplifier uses 12V directly from the main power. I used an external 12V DC 6A powersupply for this project. When everything is hooked up, you can screw the backpannel in place and enjoy the music!
Step 13: What Now? Although the radio works and everything does what it should do, there are some improvements to make. First of all I need to clean up the code a bit and I would like to make an even more graphical interface.
I also have to look to the rotary encoder as it works to slow and has a to big deboucetime. Secondly, when you look at the schematics, you'll see that there is an I2C connector of optional devices. I intend to add a weatherstation to the radio with weather info gathered via sensors in the radio as well as info that comes from the internet. It would also be nice to be able to show an RSS feed on the LCD. So lots of things to do and to look.
And maybe you have some ideas too, so let me know. Step 14: Why I Would Love to Win the Lasecutter. I really wanted this project to look as nice as possible, so I invested a lot of time in the overall design and building the case. I hope that this build is awesome enough to have a chance in the lasercutter contest as I would love to have one of these machines.
They would allow me to make even nicer looking and more intricate cases and parts. Also making gears would be a lot easier, so I would be able to make complex mechaninical movements. A lasercutter would be the ideal solution, as I work a lot with acrylate and other plastics. It would enable me to make designs that that a CNC-router can't make and I wouldn't have to bother my friends all the time to use theire machines. It would ofcourse also be great for my friends, who also happen to build a lot of stuff, to have access to such a device. So it would surely boost the creativity of those people around me too ( they would surely pay me a lot more visits;) ). I have no commercial intensions with the machine, just building stuff and helping people build theire projects and ofcourse sharing everything on Instructables.
I am not shure whether those LCDs are compatible. I am guessing that your display is more intented to display characters and not graphics. Also the amount of pixels is different so you will have to rewrite the code to design your own grafics which fit your display. Anyhow: you have to drive your lcd in parallel mode. D0 to D7 can be connected to the same pins WR is RW in your case Can't remeber what RS was CE = E in your case If you have an atmega with multiple serial connections you can also use 2 lines for the serial communication and them you don't have to mess wit all teh wires. This is the most incredible project - beautiful design, professional-looking execution, clever use of cheap materials, CNC!, all it needs is a jacob's ladder on top and to be able to bake cookies and you have achieved every instructable all rolled into one!
A thought regarding further expansion (as if it didn't do enough already); How about a USB port or SD card reader so that it could play music from an external source also? A SNTP sync-ed clock on the display is also handy on nearly anything and you might make that the display when it's on but not playing. This really is a top project.