This blog covers the build of my first ‘large’ and what I would consider to be ‘proper’ robot. It came about due to several factors, firstly because for a very long time I had been considering building a DALEK and decided it was time to start. Around about the same time I was (and at the time of writing, still am) in the middle of a British Computer Society Certificate in Computing part of which is a coding project for which I wanted to build a robot. Also just as I started the initial stages of the build Robot Wars was on TV and in school, where I teach, several of the children were talking about how to build a robot. So after realising that my DALEK would be too big and expensive, let along I lacked the woodworking tools required, I settled on a large robot chassis that could later be used for the DALEK.
Setting Up The Pi
The microprocessor chosen for the Robot was a spare Raspberry Pi 2. I decided to wipe a spare SD Card and start from scratch. Once the SD card was setup I did the following:
Installed the latest Rasbian Jessie OS.
Setup the WLAN to connect to my WiFi.
Downloaded and installed WebIOPi.
You need to install a patch to get WebIOPi working with Pi2 Model B.
Use the installation instructions from the WebIOPi web page for detailed instruction on how to use WebIOPi.
To use WebIOpPi you have to start the webio service, after which WebIOPi is accessible on any other device connected to your LAN by entering the following as a URL in your web browser:
You will then be asked for the user name and password for WebIOPi which is ‘webiopi’ and ‘raspberry’ by default.
Next to test that WebIOPi is installed and working correctly I wired up an LED to GPIO 27 and using the GPIO header GUI available when you access the WebIOPi URL above. Set the GPIO pin to OUT by clicking on it and the click on the pin number itself to activate it. If everything is working correctly your LED should illuminate 🙂 I found quite a good guide here showing most of the steps above.
The aim of this project is to create an In Car Entertainment (ICE) system with the ability to utilise additional technology such as web browsing, voice control, satellite navigation etc. The project is being designed for and will be installed in a classic Mini that I have recently finished rebuilding. The project build thread for the Mini is here if your interested.
Microprocessor – The main computing hardware for the project will be a Raspberry Pi 3.
Display – The display was going to use an In Car DVD player as a display however I have since bought a 7 inch touch screen display specifically for this system.
Power Supply – The power supply will be provided by a dedicated car 12v PSU.
SD Card – In order to handle large data files such as video a music a Class 10 is SDHC SD Card should be used.
At the time of writing there were several solutions of Media Centre software that could be used for this kind of project. RaspBMC, a version of XBMC for the Raspberry Pi, Open Elec, OSMC, a custom image of Rasbian and Kodi (formally known as XBMC) or Kodi installed on Raspbian Jessie.
Microprocessor and Display
The first step of the build was to setup the Raspberry Pi using a mains PSU, Keyboard, Mouse, Ethernet and standard display etc. This would ease the software installation process before fitting the touch screen. Once I had installed and configured the operating system I took the RPi out of its case and fitted it to the touch screen and then put the touch screen and RPi in the touch screen case.
Whilst looking for audio solutions for my project I found out that the audio out of the Pi 3.5mm Audio Out socket is pretty rubbish quality. The audio carried by the HDMI may be better but needs to be separated from the video signal using an HDMI splitter. When using the Display Serial Interface (DSI), which is used for the touchscreen that I am using, I do not think a HDMI will be present. You can run dual displays (I found a thread discussing it here) but I did not want to overcomplicate things. The single best solution to improving the audio is to use a Digital to Analogue Converter or (DAC) this outputs much better quality audio.
So, after doing lots of research, I decided to invest in a Digital to Analogue Converter DAC, which is designed to provide quality sound output. I opted for a pHAT DAC which is designed for a Raspberry Pi Zero but is compatible with all Raspberry Pi’s with a 40 pin header.
pHAT DAC (after soldering on the 40 Pin Header)
After the pHAT arrived I unpacked it and had a look at how it would fit. I had envisaged that it would fit inside the 7 Inch Touchscreen case but on looking I realised that this would be a problem because (a) the pHAT should sit on the GPIO headers but 3 of these are already in use and (b) if it was connected to the GPIO header the audio outputs would be difficult to access. I decided that a way to resolve this issue by connecting the pHAT to the Raspberry Pi using some ‘dupont’ header cables.
First the 40 pin header needs to be soldered onto the pHAT DAC. To help with this I followed this guide.
After soldering on the header pins and RCA socket, before connecting the pHAT DAC to the Pi using fly leads, I needed to work out which pins to connect. I managed to find information on the header pins that the pHAT uses from this post. Details on the pHAT DACE header pins can also be found here.
Here’s the pHAT DAC after soldering on the RCA connector.
Once everything was in place I connected the Raspberry Pi to the touchscreen and fired it up. However before using the pHAT DACE it needs configuring so that the Raspberry Pi uses it for sound as opposed to the built in audio. Details of how this is done can be found here.
Once everything was configured I fired up Kodi but no sound seemed to be coming out of the pHAT DAC but soon found that you had to select the DAC as an audio output device from within Kodi. BINGO High Resolution Audio (24-bits at 192KHz) booming out of my ‘Jam Touch’ speaker (the speaker I was using for testing)!! Also when a DAC is fitted such as this one the sound control options on the Desktop are disabled.
The audio output from the Pi (covered earlier) would need to be amplified and I was hoping to achieve this using the Pioneer DEH-1600R radio that came with the car. It turned out however that this model radio did not have an Aux In. I searched and found some hacks. Generally the hacks involve using the radios ability to be plugged into a CD changer but my model had no such luxury. The other hacks hack into the CD player sound output but require a CD to be inserted and played with a blank sound file. I was not a fan of this and then luckily I found another hack which uses the un-amplified sound output from the onboard Radio Tuner.
Basically this hack involves finding the pins on the PCB where the radio tuner module is fitted and then poking around to find a suitable Gnd pin (some work better than others) as well as the Left and Right channel audio. Sounded like a great idea so I gave it a go.
After reading up about the hack linked above I set about dismantling my Pioneer radio.
After removing the outer casing and CD deck I removed the main PCB. I then located the radio module and turned it over to have a look at the radio module pins. To my delight these are all labeled and clearly visible.
Back of PCB
Radio Module Pin Labels
In the picture above you can see that the bottom pin (let’s call it pin 1) is labelled Rch. This will be the Right Audio Channel. and pin 2 is the Left Audio Channel. Labelled Lch.
After temporarily wiring up the radio with only the radio and main PCB and checking that it worked I set about wiring in a 3.5mm auxiliary audio connector. I managed to pull a 3.5mm audio connector from an old CD Rom Drive and after tinning three wires I soldered them to the audio connector.
In order to have a sound source I decided to wire up the Mausberry 3A Car Switch that I had bought to intelligently turn the Pi on and off, so that I could use the Raspberry Pi. Details on how to set it up can be found here.
It all powered up fine so I connected the Raspberry Pi and played a music video. With one of the audio channel wires touching Rch an the Gnd wire touching BEGND the audio came out of one of the speakers. I also tried DGND and that worked as well.
I then soldered the aux audio connector to the back of the PCB and as there was not a lot of space I used DGND. I then re-assembled the radio with the aux audio leads trailing out of the rear and cable tied in place.
When I powered everything up again and played a video I had audio coming out of both speakers, HOORAH, but there was a heck of a lot of ground noise, possible caused by a ‘Ground Loop’.
After some more poking around and help from RetroRides Forum I found that the ground loop problem was probably caused by either using DGRND as my ground point. I disassembled the radio again and this time I soldered the Gnd wire to BEGND. This turned out to be the correct Audio Gnd and solved the ground loop problem.
After making the above changes it sound pretty good but I had to have the volume cranked up to 20/30 and when there is no audio coming from the audio source you can here the white noise of the untuned radio station in the background. There is also some slight interference which seems to be caused by the wireless keyboard?
Here is a video showing the audio quality using this hack.
CD Audio Hack
With the noise from an untuned radio station using the Radio Module Hack I opted to backtrack and try the CD audio hack. I removed the radio and disassembled it AGAIN! Once it was all apart I had a look on the main PCB where the ribbon cable from the CD mechanism connects. Sadly the audio tracks are not clearly marked. I then had a look on PCB that is mounted on the CD mechanism and low and behold the audio tracks are labelled but not particularly clearly. I then identified the correct pins and following the ribbon cable back to the main PCB identified where the corresponding lines are on the this part of the device.
I then stripped, tinned and clipped the leads from my 3.5mm audio socket and using a magnifying glass mounted on a helping hands I managed to solder on my three leads. I checked for shorts using a multimeter, cable tied the leads to the PCB and with the leads routed through the radio I re-assembled it all again.
Once it was back in the car it powered up OK (at least I hadn’t broken it). To test the Aux you need an Audio CD filled with silent music tracks. With this CD in the CD player and the unit playing the CD I connected the external audio source and it worked fine. There is still some interference but it is only noticeable when there is no sound playing. This noise interference may also be caused by the Logitech wireless keyboard that I am using as the sound increases when the mouse moves.
If like me you get really annoyed when searching for help for a project you are working on, finding what you think is a solution to your particular problem and then part way through the guy has dropped what he was doing and gone off in a different direction. Well if that’s you then I apologise because yes that’s what I have done. Although the CD hack does work fine I decided to buy a second hand radio with Aux In. So after cruising eBay looking at radios, amplifiers and speakers I ended up bidding on and winning a Sony CDX-GT26 CD / Radio. It is capable of a similar output as the Pioneer (4 x 45w) but like most Aux Inputs its on the front. Only expensive radios seem to have an Aux Input on the rear. I am not sure if I want a cable hanging out of the front so maybe I’ll hack into the aux socket from inside and run a cable out of the rear?
Whilst researching audio I have also been looking at Amplifiers and Speakers, specifically the XPLOD range, this amp and these speakers. UPDATE ended up ordering the XPLOD XM1004 but opted for some better Pioneer Coaxial Speakers. I bought the Pioneer TS-A6923i 6x9s
Here is the Amp:
And here are the speakers:
The photos are for reference only as I am not allowed to have them until Christmas!! The speakers are a lot larger than I had anticipated. I should have realised this as they are 6 x 9 inches after all!! I could fit them to the parcel shelf but this would involve chopping out some more metal. In the end I have decided to make up a speaker board and fit them under the rear seat. The amp is also quite large (34cm x 23cm) and will probably also go under the rear seat on a separate board either fixed to the floor or the underside of the seat (if there is enough room)?
Installing the Speakers
Well it turned out that the only suitable location for the speakers was under the rear seat. So I set about making a speaker board.
Installing the Amp
After trying various locations to best place I found to fit the amp was in the boot, to keep it out of the way I decided to mount it upside down under the rear parcel shelf.
There is quite a lot to consider when wiring in a system such as this with an amplifier into a Car and in order to ensure that I went in with some sort of an idea I did lots of reading on Car Audio Electronics.
Whilst you could buy all of the wiring parts individually I opted to go for a complete wiring kit (of which there are many to choose from). Being a perfectionist at heart I opted for a kit with high quality products which meant that the wiring had to be 100% Oxygen Free Copper. After lots of research looking at many of the kits on the market I eventually came across one that fitted the bill without breaking the bank. The Rockford Fosgate 8 Gauge Complete Amplifier Installation Kit. This came with power, ground and remote cables, speaker wire and RCA signal connectors as well as an inline AGU fuse.
Setting Up The Touchscreen
For this project I used the official Raspberry Pi 7 Inch Touch screen. A good guide can be found here and the PiMoroni one can be found here .
I also bought an official case for the touchscreen:
In hindsight whilst the case is really good for a stand alone inside the car it may not be a good idea. I had real trouble working out a way to secure the screen in my custom dash and after installing the system for the first time it failed and I needed to remove it. This was a real pain so I think the best option would be to fit the screen in the dash and have an extra long video cable and have the Pi mounted somewhere more accessible. This would help with things like changing SD cards and general troubleshooting etc more later in this blog.
For the software side of things, first I downloaded the latest version of Raspbian Jessie. Then I flashed the image to the SD card, as I am a Mac OSX person I used terminal to do this.
Once Rasbian (Jessie) was on the SD Card I fired up the Pi and saw for the first time the Sept 2016 edition of Jessie. Mmm not sure if I like the way this has gone, seems a little Microsoft Windows 10 for my liking!! Anyway first task with any new installation is to update it. To do this I did an update and upgrade by running the following at the terminal:
sudo apt-get update
sudo apt-get upgrade
This took about 20 minutes to complete after which it is always advisable to reboot the system so that any changes take effect. There are several ways to reboot but whilst in terminal you can simply enter:
After the reboot in the new version of Raspbian you will see a message telling you that some of your config files may have been overwritten. The message also tells you were backups of your original config files are located.
I installed netatalk to ease transfer of media files as follows:
In Terminal type – sudo apt-get install netatalk
On a Mac click the Go menu / Connect to Server
Enter afp://<ip address of your Pi>.
Click connect and you will be prompted for a user name and password, this will be the user name and password for your Pi not your Mac.
A finder window will open showing the contents of the RPi.
Rotating the screen
If you need to rotate the screen you need to edit /boot/config.txt and add the line: lcd_rotate=2 to the top.
You can do this in Terminal by entering the following:
In Terminal, type “sudo nano /boot/config.txt”
Add the line “lcd_rotate=2” to the top of the file.
Next up was the installation of Kodi which, according to the Wiki can be achieved in Raspbian by simply installing it in terminal by entering:
sudo apt-get install kodi
After Kodi was installed again it is a good idea to reboot the system as above.
Setting Up Kodi
Once kodi is installed it needs to be configured to work with your setup however, the pre car setup may be different to the incar setup (Internet access using 3g or WiFi) Hot Spots, media file locations etc). As this was my first ever build I decided to set it up to work on my LAN get to know how it works, tweak it and then make any changes necessary for use as an ICE.
You can either start Kodi from terminal or from the start menu, I used the start menu in case I missed any options?
When it first fires up it will check for updates etc. Quite often messages will appear saying XXX is broken do you want to remove it (or something like that) for now I just declined. Kodi will also do a version check and complain that you are using v15.2 when v16.1 is available. At the time of writing from what I have read Rasbian is limited to v15.2.
It all fired up fine first time however as I had no media it was a bit of a non test? Another problem is when exiting Kodi it seems to power off the Pi. This may have been due to opening Kodi from the start menu in full screen and not from the terminal as a windowed program (if this is indeed possible)?
After some looking around on the Internet I found some interesting information that I had not come across before on using Kodi in the fashion that I wanted as an ICE. The blog can be found here. However whilst I was waiting for answers to some of my enquiries I had a look at Kodi and found a skin designed for use with a Touch Screen. The skin is called re-Touched and is easily installed in the system settings.
One issue I found was that the touchscreen mouse click was not responding. After a quick search on the internet this was fixed by changing the mouse click speed in system settings.
After everything was setup there where still a few problems. After a specified time period, the screen will sleep, it can easily be woken up by touching the screen however when Kodi is running there is no such luxury, once its asleep it cannot be woken up!! I searched for a solution for ages and found that this was an issue when using Kodi on a Raspberry Pi. Kodi opens in full screen and not in a window. Eventually I was pointed to this potential solution, It worked a treat – no more sleeping.
Music and Video
As this is an entertainment system it needs some media to play. I already had loads of videos and music and to transfer it I installed netatalk on the Pi. On a Mac having netatalk installed on the Pi allows you to open an AFP connections which opens a window allowing access to folders on the Pi. You could of course simply transfer files using a USB stick.
As this is an in car system I needed a wireless setup. For this system I used Logitech wireless keyboard and mouse combination, perfect for use in the car (by the passenger of course).
As mentioned earlier in this blog I had some issues when it came to installing my setup in the custom dash that I was building. At first I tried to install the screen with the Pi fitted however this proved to be an error as after a couple of days due to a wiring problem the SD Card became corrupted and I had to remove the dash to get at it – school boy error!!!
Here is the first attempt with the Pi fitted in the touchscreen case:
And then I removed everything and fitted the extra long ribbon cable:
Plan B I decided to remove the Pi and mount it in the glove compartment making it accessible. To achieve this I bought a 75cm ribbon cable for the screen a USB to 2 x Micro USB splitter cable (one for the Pi and one for the screen) and a USB cable with a switch. The switch is needed to turn off the Pi after it has shutdown otherwise as soon as the ignition is switched on it would fire up. Sorry no pics 😦
The Finished Article
Well it’s not actually finished but it is in and working. Here is a video showing the interior with the entertainment system working (sorry more Ironman themed AC/DC!!). Oh the engine was running that’s why the rev counter was at 1500 rpm but you can’t hear it – probably due to the music 🙂
As this is based on Raspberry Pi there are endless possibilities for addons, these could include voice control, GPS mapping etc? The voice control will be developed alongside Pi Central, which is another of my projects. The only issue I have at the moment is that I have installed the pHAT DAC using a stacking header but as the header pins have been soldered onto the pHAT DAC I cannot use any of the GPIO. I may have to go back to my original option and connect the pHAT using fly leads. I would also like to build a custom case to fit everything in.
Useful Links and Bibliography
In researching and building this project I found information from the following web sites or forum posts useful and I would like to thank everyone involved for their help.
This is an additional placeholder post. Click the Edit link to modify or delete it, or start a new post. If you like, use this post to tell readers why you started this blog and what you plan to do with it.