Saturday, September 20, 2014

Setting up RetroPie on Raspberry Pi with USB gamepad

Every since it started I've watch the development with RetroPie a Raspberry Pi image that includes a number of console/computer emulators optimised for the Raspberry Pi.

I'm not a major gamer but sometimes a bit of nostalgia is worthwhile so I decided to install RetroPie

A few things to note. RetroPie is built on Raspbian, so the foundation is solid.
You can even use raspi-config to expand the SD partitions and set overclocking and GPU memory split.

The easiest way to use RetroPie is to download the pre-made image from the website http://blog.petrockblock.com/retropie/

Use your tool of choice to burn the SD card.  I did it on Windows 7 so I used Win32DiskImager

Once install in the Pi and all cables attached I added power.
Up comes the lovel RetroPie splash screen and it boots straight into Emulation Station which is a great front end giving access to the emulators where roms are available.
Splash Screen

On first boot Emulation Station prompts you to configure your controller/gamepad to operate the menus in Emulation Station. This confused me a little as I thought it was asking to configure the gamepad for the games.

But once I got a few roms on it became clear the this setup was only for Emulation Station and for that it worked perfectly.


I quit Emulation Station and ran raspi-config to expand the partition, split the memory 256MB/256MB as I read the PSX emulator may need it and also to do some minor over clocking (it can't hurt to have a bit more speed)

Then to get RetroPie setup correctly.

From the home directory do:

cd RetroPie-Setup
sudo ./retropie_setup.sh

This brings up the RetroPie configuration menu.
I selected Option 1 to do the Binaries-based INSTALLATION.
RetroPie comes with the bare minimum to get going in the image so you have to do this to get the other emulators.
As expected this can take a bit of time. 
Main Menu for retropie_setup

Once this finished I then selected option 3. SETUP (only if you already have run one of the installations above)

This is where you get the extra options to customize RetroPie.
If you are building a cabinet or want that genuine old school feeling of using original controllers there are a number of tools in the SETUP menu to make it a lot easier.  I was not interested so the only thing I enabled here is 310 SAMBA ROM Shares.
This enables SAMBA shares so you can drag and drop files from your computer to the Raspberry Pi making it much easier to get ROMs into RetroPie

SETUP menu 
At this stage RetroPie has all the emulators installed and the menus works but there are no ROMs and the games (once ROMs are copied across) will only work with the keyboard.

I mentioned I enabled SAMBA above so I could copy ROMs across. In the end I didn't use this. I used WinSCP which allows you to login to the Pi and drag and drop files from your computer onto the Pi in a nice GUI tool 

You have to copy the ROMs to the relevant folders for the different emulators.
Really simple. Reminded me of the olf Windows 3.11 FileManager with 2 panes to drag and drop between.

Last item was to get the gamepad working with the games and not just the Emulation Station menu.
This took a bit of hunting online as I have a feeling the method may have changed in the last update of RetroPie to v2.3.

In the end the method I found that work for me with my gamepad was from a reply on the following webpage.  http://blog.petrockblock.com/forums/topic/how-to-configure-a-controller-on-retropie/ from user flipbug

sudo chown pi /opt/retropie/configs/all/retroarch.cfg

cd /opt/retropie/emulators/RetroArch/installdir/bin

sudo ./retroarch-joyconfig -j 0 >> /opt/retropie/configs/all/retroarch.cfg

The first command gives the user pi the right to change the retroarch.cfg file.
The second goes to the directory where the retroarch-joyconfig command is located
The final command rund retroarch-config and outputs its results to retroarch.cfg 

I found the tool to be a bit sensitive when dealing with the analog sticks so ended up having to do it a few times.

In case my configuration matches some elses here is the configuration I use.

input_player1_joypad_index = "0"
input_player1_b_btn = "2"
input_player1_y_btn = "0"
input_player1_select_btn = "8"
input_player1_start_btn = "9"
input_player1_up_btn = "h0up"
input_player1_down_btn = "h0down"
input_player1_left_btn = "h0left"
input_player1_right_btn = "h0right"
input_player1_a_btn = "3"
input_player1_x_btn = "1"
input_player1_l_btn = "4"
input_player1_r_btn = "6"
input_player1_l2_btn = "5"
input_player1_r2_btn = "7"
input_player1_l3_btn = "10"
input_player1_r3_btn = "11"
#input_player1_r3_axis = "+3"
input_player1_l_x_plus_axis = "+0"
input_player1_l_x_minus_axis = "-0"
input_player1_l_y_plus_axis = "+1"
input_player1_l_y_minus_axis = "-1"
input_player1_r_x_plus_axis = "+3"
input_player1_r_x_minus_axis = "-3"
input_player1_r_y_plus_axis = "+2"
input_player1_r_y_minus_axis = "-2"

It was a bit of a trial and error session getting RetroPie working but in the end I have a fantastic emulator system set up on a model B+ that looks well and performs brilliantly.  I am really impressed at how well it runs PSX games as from a raw CPU power I always though the PSX and the Raspberry Pi would be quite similar.

Now all I have to do is actually be better at the games to fully enjoy them.


Thursday, July 3, 2014

Paper Marble Run - something different no electronics

I'm a big fan of encouraging creativity with low cost resources. I previously hacked a £6.00 remote control car to control it from a Raspberry Pi using Scratch and used a low cost eBay robot vehicle deck and wheels with a clone Arduino Pro Mini (all in for <£15.00).

Well some people aren't that into electronics and programming but are still looking for creative solutions.

I came across Marble Runs/Roller Coasters that you can buy and did a search online and found you can make you own from copper wire and also from stiff paper (200gsm). Never one to miss a chance to try something new I looked at the videos and made up templates for the paper marble run sections and began construction


After a fair few iterations and a lot of really small pieces of tape to put the bits together I finally had a set of templates that can be used to make a paper marble run.

This is the first video of the marble run. I really like the funnel and also that the marble comes off the end just below the funnel and because the moment is right it drops into the next channel/track section.


There is a fair bit of work in getting it stable and modifying the length of the straights and the curves so they work.  This is real tinkerer construction as the parts are not perfect and the design is evolving so regularly pieces need to be shortened, or bits added or the angle of the track needs to be modified to make it work.
Great fun going through all of this and learning about the properties of the paper, how strong the tape is and how to keep the marble going.

I then extended the run another bit. I like this view. There is something pleasing to me about the curves on the left section.


Finally I added a bumpy track and also a 'ladder' (no idea if that's it's name but it's the name I use) and more curves. This made the whole think a lot taller and works well. It does kind of unbalance the look and style of the overall marble run, so I think it is less pleasing to the eye than the earlier version.  Feels like when a skyscraper adds a large antenna to the top to officially be taller.

Here's the final video of the current Marble Run.




Overall I'm happy with the results and plan to make more runs.  A nice way to spend an afternoon/evening being creative.

Getting back to electronics I'm trying to design a simple marble lift using mainly paper (will need a motor). Onward and upward.


NOTE: If you want a copy of the templates (UK A4) just leave a comment and I'll message back a link.  They were done with Inkscape and my skills aren't the best, so they are a bit rough.

Sunday, April 6, 2014

HC-06 Bluetooth Slave Only

I bought a Bluetooth adaptor from eBay a while back and configured it allow me to login to the Raspberry Pi over Bluetooth.
As part of this I changed some of the settings on the adaptor and like a proper hacker didn't write down the changes anywhere and then lost my code when the Raspberry Pi SD got corrupted and I installed Lubuntu on my netbook (was XP).

After doing a lot of searching online I found details for the HC-05 and how to reset it by setting the Key pin HIGH and putting it into command mode.

After about 5 hours of messing with the adaptor and even noting the Key breadboard pin wasn't connect to the Key pin on the board, so shorted the pads on the back of the board. Then desoldered again

Nothing worked.

Then checked if what I really had was a HC-06. The Slave only version of the HC-05 board and guess what it is an HC-06 board and so the Key HIGH method doesn't work.

Note the little transistor near the header
Haven't seen this on any of the HC-05 modules
Also, on the back of the board there are 2 sets of pads not populated.

But from reading the following Google DOC (https://docs.google.com/document/d/1GPVqL9jlnIKFUL0lRGdRNrYFvxKRR-yjNSRYhlr1j84/edit) discovered you can reset the HC-06 by setting PIN 11 to LOW on the module.
I did this, cycled the power and now I could connect at 9600.  All good.

I downloaded the Sketch from here: http://www.plastibots.com/index.php/2013/12/31/hc-06-bluetooth-module-getting-this-sucker-into-at-command-mode/
And it worked.

So, no Master mode (cannot initiate pairing) but it's now working so I can have some proper fun with it.