Arcade Control Board

I’ve finally got round to posting about the raspberry pi arcade.   I’ve build an ATMega based board to convert all the controls to SPI for the raspberry pi, modded the ada-friut retro arcade library to use the SPI based control inputs and etched a PCB for the control board.

I home etched the PCB using the toner transfer method which I find to be a bit of a pain to get a decent result.  The best way I’ve found is to print on magazine paper, then iron on for 5 minutes and finally run through a laminator four or five times.  Here is the result:-

 

board

The board does a few thing.   It has 2 9-Pin D connectors for the player 1 and player 2 controls.   The layout is the same as an old atari joystick (in theory you could plug in old Atari comparable joysticks).   The unused pins on the D connector are used for the extra buttons and the player 1/2 buttons.  The joystick axis connect to analogue inputs on the ATMega to save a few pins.  There is also an input for a coin mech to add credits, at the coin mech requires 12v the board requires a 12v and 5v supply.   The 5v supply goes thorough a regulator so that the board runs at 3.3V (8Mhz) this removes the need for logic level conversion between the board and PI.

The above pictured board had a few issues (it also had a zener for the coin op mech which has been removed).   I put a few jumper wires on the bottom to correct the issues, most of which were due to eagle not connecting nodes so I should probably pay more attention to the ERC check.  An updated design is checked int github at https://github.com/markpudd/PiArcadeBoard.  Here is the populated board connected up:-

Boardsfixes

The other thing I’ve done is sprayed the cabinet black, added the coin mech and stated to put on the plexi glass:-

Arcade

Only a couple of more things to finish (bevel and marquee) so will post later in the week with the finished result!

 

Advertisements

Arcade Controls

The Raspberry Pi arcade now has controls!

Internals

The controls have been connected to an Arduino which then uses SPI to connect to the Raspberry Pi.   The following hardware design was used:-

PI-Arduino-SPI-lc

Its important to use a logic level converter for the 5v to 3.3v conversion.

After hunting around for good ways to simulate key presses on the Pi I stumbled across the Adafruit retrogame code which uses GPIO as inputs.   I’ve forked this on github and changed it to request the state of the buttons over SPI and update the presses.  It currently polls and doesn’t seem to be using much CPU, although it would be possible to use a separate GPIO pin to tell the Pi that there is a change in state.   The code is available at https://github.com/markpudd/Adafruit-Retrogame.   This also includes the Arduino code to connect the inputs too.

The SPI protocol basically send an 0xFF command to the Arduino which returns 3 byte, which are P1 status,P2 Status and Aux Status.   The Aux status is used for P1/P2 button and the coin mech.

I’m currently building an input board to replace the Arduino which is basically the ATMega broken out with some connector for P1/P2 and aux.   I’ll publish this at the end of the week.

I also added some audio amplifier and speaker this week.  There is still a bit to do on this project such as getting some artwork printed, painting the cabinet and fixing up the monitor mounts!

 

 

Back from Holiday!

I’m back from holiday and have updated the gate opener code.  I’ve changed my github username so the code is now at https://github.com/markpudd/gate_opener.   There is a few changes:-

  • Added an iOS client.  This is pretty basic (no design) but has a button to open and a geo-fenced area to allow the opening to happen automatically as you get near to the gate.  In the setup you can add the shared secret for the Arduino and set the centre of the geo fence.  The fence is set to 8 meters at the moment but I’ll look to add a slider to widen this in the future (a non round geofence would also be cool).
  • Fixed up the Arduino code.   On review of the Arduino code today there was a lot of issues.  These included invalid checking, not reading the post parameters correctly and few other issues.   I’ve fixed these up now however the code needs tidying up.  The code was originally based on the example web server for the Arduino Ethernet shield which I think has caused some issues, if I have some time I’m going to re-write from scratch…..

I’ll post the hardware pictures in a future post.

 

Gate Opener

I’ve posted a new project to github (https://github.com/markmoro/gate_opener).   The aim of this project is to make my driveway gate open as I drive up to it.   It works by using geo fencing on my phone to detect that I am close to my house and then send a message to an Arduino with ethernet shield to open the gate.   The opening it self is done with a spare gate remote that has had the switch replaced with a MOSFET.   This project is still in progress.

The key thing about this project was to make sure that only some one with a correct code can open the gate.   To do this there is a few steps:-

  1. Both the Arduino and the phone have a shared secret key
  2. The phone requests a token from the Arduino
  3. The token is appended with the command (‘open’ string) and an HMAC digest is created with the token
  4. The digest is sent as a POST parameter to the Arduino
  5. The Arduino re-creates the digest and verifies the received digest matches
  6. The gate is open (sends a 500ms pulse to the MOSFET gate to open the switch).

The above scheme should prevent any replay attacks as all of the requests are unencrypted (there is no SSL for Arduino).    There is also a test Python bottle server and test bash scripts to test both sides of the communications (in the webapp folder).

There has been a few issues with the MOSFET circuit which I will fix in the next few days and post!

GardenStation Intro

This project is simple ATMega based plant watering system.    This automatically monitors the soil and water when necessary.

The current prototype is built on a through hole PCB (made at seed studio).  There was a couple of issues withe the prototype build.   The 74HC595 shift register was wired slight wrong and the display interface had a couple of issues.   These have been fixed in the SMD version (I will go and fix up the through whole version).

The moisture sensor uses a couple of nails and the water valve are made from an off the shelf hobby servo and a manual valve.  There is also provision for a temperature sensor and using the ICSP and a couple exposed pins it should be possible to add a simple SSD card for logging or ethernet module for networking.

I will post a more complete description in the next couple of days. The circuit,PCB and code is available on github – https://github.com/markmoro/garden_station.

Car Lights

Got a kids ride-in car with no lights or battery indicator?   If so this is the project for you.

The goal of this project was to create a simple microcontroller board that will control  some indicator lights, hazard lights and battery monitor for the kids ride on car below.

Kids car

Kids car

Circuit

The project uses an ATTiny84 micro controller to control all the lights an monitor the battery level.  This can be build on a simple piece of stripboard.  Here is the original circuit diagram and stripboard layout. There was a couple of minor change in the final version which we’ll discuss later.

circuit_layoutstrip_layout

Firtzing was used to create the circuit and stripboard layout.  The circuit diagram was created first which caused some issues when trying to layout the stripboard.

Design

The build was started with a breadboard layout of the LEDs and a potentioner to simulate the battery level.

breadboard

This was connected to a standard Arduino UNO board in order to write the firmware for the ATTiny.  The firmware  (and circuits) are available from github (https://github.com/markmoro/carelec).   The firmware is super simple as its basically blinking some lights so it should be easy for anyone to follow and makes a great introduction to Arduino coding.

Once the firmware was complete it was time to build the ATTiny version.   The first thing to do was to write the firmware to the ATTiny.   To do this we used the Arduino as an ISP.  There is an excellent tutorial on instructables on how to do this here.  There were some issues with pin mapping with the Arduino pin numbers.  The actual pin numbers are shown in the diagram below:-

ATTiny84 Arduino Pin map

ATTiny84 Arduino Pin map

Build

Once the stripboard layout was built and the ATTiny programmed the the build into the car can be done.

Circuit on Board

Circuit on Board

We soldered the LEDs on to wires and ran them back to the main board were we had header connectors to plug the in to the board.   The following section were made:-

  • Left Indictor
  • Right Indicator
  • Hazard Lights
  • Battery indicator lights
  • Switches

We’ve simply taped all the wire runs in the short term but will probably secure them up more in the future.

Issues

The majority of this build went pretty smoothly, however there were a couple of issues.

The first issue was that when plugged into the main car battery the ATTiny kept reseting.  We had previously tested using a 8 AA cell battery back so the power was the main suspect.  A small value capacitor was placed across the ATTiny’s power and this solved the issue.  Its important to note this need so be as close to the ATTinys power pins as possible.

The second issue we had was wiring the power on/off to the cars on/off button.  The cars on off button seem to have so strange ground wiring (I assume this is for the motor to run back and forward) and it turned out we couldn’t wire the circuit on/off to this.   As a simple solution a second switch was added.  The main switch could be replaced with a dual-pole version however we will probably not do this.