Sunday, 3 November 2013

Driving Game Pedals and 6 Speed Gear Stick - Made from scrap

Pedals and gear sticks for computer games are quite expensive, so I made my own out of some scrap wood offcuts, rubber bands, string, an old screwdriver, a Teensy 3 micro-controller and potentiometers.

They work with any game that supports a normal USB joystick by using the Teensy 3 in joystick mode.


Photo of peddles
Driving Pedals

Photo of gear stick
6 Speed Gear Stick

The Teensy 3 is very good for this project as it takes care of all the USB communication and provides a simple API to send the data.

The devices I built do have a number of short-comings: the peddles pivot on the potentiometers which are weak, the gear stick is sometimes unreliable at shifting if it doesn't make contact.

The upside is that it only cost the price of the Teensy (£21) and three potentiometers (£1.50). Rather than £150 for a commercial set.

If making your own set, when programming the micro-controller, you can compensate for some of the unreliability of the hardware in software. The pedals gave a much smoother response when I added took a five point moving average of the samples. The gear stick is de-bounced in software using the Arduino Bounce library.

Sunday, 22 September 2013

Euro Truck Simulator 2 - Prototype Real Dashboard


The game Euro Truck Simulator 2 (ETS2) has a telemetry API to allow plugins access to the data about the in-game vehicle. I've created a plugin to send the data down a serial port to an Arduino microprocessor, which then controls the servos, LEDs and an LCD screen.

 This initial prototype is made from cardboard, with the components just pushed through from the back.

This is the back of the dashboard, showing the Arduino board (blue) connected to the other components.

Video of it working is here:

Update:
You can download a copy of the plugin source and a pre-built plugin here:
http://downloads.silasparker.co.uk/dashboard_plugin_2.zip
http://downloads.silasparker.co.uk/ets2_dashboard_v3.zip (New version of code)
The code is now up on Github here: https://github.com/skyhisi/ets2_dashboard

Photo of final device made from MDF, the paint finish is terrible in bright light !
Update:
Video of how it works it here:

Update:
Fixed plugin built in wrong mode. Note, you may also need to install the Visual Studio 2010 Re-distributable package from here: http://www.microsoft.com/en-gb/download/details.aspx?id=26999
 

Saturday, 9 March 2013

Building Qt 4.8 Embedded for the Raspberry Pi

These are the steps I went through to build Qt 4.8 for Embedded Linux for the Raspberry Pi.

Build a cross compiler

Follow the instructions on using CrossTool-NG. I used the latest version of CT-NG and chose the GCC, Binutils and Kernel Headers to match the tools on the RasPi. I also had to adjust the compiler support libraries to match, via a process of build, change versions, build, etc. It is also important to enable C++ under language support, as by default only the C compiler is built.
 Once you have built a cross compiler, I strongly recommend testing it by compiling a test program such as:

#include <iostream>
int main(int, char**)
{
  float a = 2.0f * 2.0f;
  std::cout << "Test " << a << std::endl;
  return 0;
}
 Once you have a cross compiler working, edit your ~/.bash_profile file and add the directory containing the tools to your PATH.

Build zLib and OpenSSL

If you want to be able to use SSL sockets, or access https websites, you will need to build zLib and OpenSSL. The instructions below are slightly modified from a post on StackOverflow about this.

  1. Download zLib and OpenSSL source packages and extract them.
  2. Set the following environment variables:
    export CC=`/bin/which arm-unknown-linux-gnueabi-gcc`
    export AR=`/bin/which arm-unknown-linux-gnueabi-ar`
    export RANLIB=`/bin/which arm-unknown-linux-gnueabi-ranlib`
    
  3. Build zLib
    cd zlib-1.2.7
    ./configure --prefix=/opt/raspi
    make
    sudo make install
    
  4. Build OpenSSL
    cd openssl-1.0.1e
    ./Configure linux-elf zlib -L/opt/raspi/lib -I/opt/raspi/include --prefix=/opt/raspi no-asm
    make
    sudo make install
    

Build Qt

Download and extract Qt for Embedded Linux.

Edit the file in  mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf and change the names of the tools to match (mine had built with 'unknown' and not 'none' in the name).

Run the following to build it:

./configure -embedded arm -qt-freetype -prefix /opt/raspi -xplatform qws/linux-arm-gnueabi-g++ -I/opt/raspi/include -L/opt/raspi/lib -no-cups -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-javascript-jit -no-qt3support -qt-gfx-linuxfb -qt-gfx-transformed -plugin-gfx-vnc -qt-kbd-tty -qt-kbd-linuxinput -qt-mouse-pc -qt-mouse-linuxinput -openssl

make -j 8
sudo make install

Whilst building I encountered the following problems:
  • Error message:
    fatal error: .pch/release-shared-emb-arm/QtGui: No such file or directory

    This can be fixed by running:
    touch src/gui/.pch/release-shared-emb-arm/QtGui
    
  •  Error message whilst compiling SerializedScriptValue.o This can be fixed by going in to the directory where it is building (src/3rdparty/webkit/Source/WebCore) and re-running the failed call to g++ but with the -O2 flag changed to -O1
Once it has built, you can copy the /opt/raspi directory on to the RasPi, make sure you put it in the same place.

Testing

On the RasPi, before running the demo programs, you need to set the keyboard driver to use with:
export QWS_KEYBOARD=linuxinput

You can then run the demo browser with:
/opt/raspi/demos/browser/browser -qws