Saturday, March 20, 2010

Connected and Alive

This is probably one of the most important moments in my project's life so far.

In a few words, the dashboard now reflects the exact state of the simulation in Live For Speed, covering for the moment only the control lights.

So, this is what I've done recently.
First, I've ported the original software to the Arduino language and flashed it to the new board. Hooked it up to the dash interface, and voila! The lights were flashing in sequence just as before.
This encouraged me to go to the next step, so I modified a C# code that I had previously found on the web, which connects to LFS using OutGauge, to acquire live data on a UDP connection. I modified this program to send all the data through a serial port to the Arduino board.
The updated Arduino software continously reads data from the serial port (simulated over USB), interprets it, and sends the corresponding signals to the dash interface in order to light up whichever control lights are on in the game.
All of the lights are working, such as turn signals, hazard lights, full beam, traction control, parking brake, shift light, and red line.

Here's the thing in action.

New Grounds

Browsing around the www, I came across this simple, easy to use development board, which seemed just right for my project. As I've said in an earlier post, I want to reduce my efforts as much as possible, so this Arduino MEGA board was just what I was looking for, as it is built around a powerful enough microcontroller, the ATMega1280, it exposes all I/O pins (analog, digital, PWM etc), and has a simple, open-source programming language, as well as a pretty bare IDE which also allows you to upload the software via USB.


Could I ask for more?
Yes. I could wish for ready-made libraries for working with the serial port, PWM and such, but they are already there. And, as an open-source project, it benefits from continuous improvement from all over the world.

I forgot to mention that it's pretty cheap, too.

Friday, March 19, 2010

It's Working!!! (ish)

I've just written a basic software to be flashed to the ATMega chip, which lights up the control lights in the dashboard, one by one.

After some struggling and debugging, I got it working just fine. Except for the needles, which for some reason won't budge.


Interfaces, Interfaces...

Once I figured out the inputs this instrument cluster needs in order to light up control lights and move needles, I started working on the interface board between the ATMega board and the cluster itself.





I need this interface board for the following purposes.
1. Converting the 5V TTL signals coming from the microcontroller, to 12V as expected by the instrument cluster.
2. Because some of the lights come on when their corresponding pin is high (12V), while others when it's low (Ground), I had to provide "source" of current for the first ones, and "sinks" for the others. This meant using two different kinds of buffers (integrated circuits outputting 12V when 5V are being input): the ULN2803 and the UDN2981.

The board features 2 connectors to hook up the ATMega board, and 3 to connect to the dash. A power connector was also installed to bring 12V and 5V voltages from the ATX source.





Controlling Things


I have some experience with AVR microcontrollers, having built an autonomous robot from scratch in my university years, but I've come to a point where I got lazy enough to search for ready-made things rather than building them myself, if it wasn't essential to the "fun factor".

So I got this development board, the "AVR-MT-128" from OLIMEX, built around the ATMega128 chip. It has a LCD display and serial port, which I am going to use to acquire data from the computer. It also appears to have just enough pins to connect it to the dashboard (of course, I'm going to build an interface board).



The Beginning

The saga begins...

... with this instrument cluster which I've just bought, stripped right down from a '92 BMW 325i (E36 model).


I have already figured out the pinout (thanks to some googling), and hardwired it to an ATX power source donated by my late PC.

The Idea

It was one of my childhood dreams to build a hardware racing simulator.

In my dreams it was of course, all high-tech and stuff, just like the ones I could see on TV built by NASA to train their astronauts... but who knows what may come out. All I know is, it's going to be something really challenging and relaxing to work on, no strings attached.