The online racing simulator
#1 - FW-05
Building up a Tachometer with the Arduino テつオController
Hi there!

Iツエm working for some time on a way to make the Arduino Duemilanove ツオC handle a real tachometer. But i am still in the beginning, so only the ツオC is bought, tachometer comes up in some days or so, depending on my income.

But letツエs start in the beginning. Some weeks ago I was browsing uTube and some vids catched my eye. People had a real tachometer connected to LfS or rFactor. Looked great so I checked out some electronics forums and a user from a german LfS-Board recommended the Arduino ツオC (see the datasheet http://www.atmel.com/dyn/resou ... rod_documents/doc8161.pdf). I was impressed because it can handle six PWM channels.

Now my lack of programming skills comes up. I have no clue how to get out the values of speed, RPM, Temp, pressure, fuel out of LfS in a form so I can feed the ツオC with it. I know, that thats the part of OutGauge.

Has anybody an idea how it could make it work? Maybe there is another way, without using OutGauge but X-Sim, but I want to try it first with the build-in LfS feature.

I think the worst problem is to adress the data from LfS over USB-port to the Arduino. The output of the values should be realized by (depending on the kind of tachometer I could get) using the internal motors (which are infact ammeters I guess) or some RC-servos I have here laying around.

Well guys, thats what I am working now on. Progress will be updated.


PS: sorry for language, if there are any missunderstandings, please ask...
Outgauge + Arduino = Awesome
Hello FW-05,

I'm working on an outgauge project myself that uses an Arduino and data from outgauge. I'm creating a program in python that parses the UDP packet information into readable data and then sends it over the USB connection to the arduino, that then sends it to an instrument cluster and/or an LCD display panel mounted in a steering wheel. The hard thing about you learning outgauge right now is that all of the documentation seems to have disappeared from the internet.

Instruments:
As for getting the tachometer to work it really depend on how it is constructed. If it is a true air-core instrument you'll need 4 PWM terminals to run it. otherwise the servor may be a better solution, it all depends on your hardware though. I have an arduino sketch that runs an air-core gauge if you'd like to have a look at my code let me know.

USB
Python doesn't have native support of using the USB interface, but there is a small extension called pyUSB that allows USB port connections and data transmission. There are certain methods for encoding the data to make sure that data isn't lost, but for my first tests I'll just use some sort of character delimitation to split up the values for the arduino.

I hope this helps. post if you have any other questions.
#3 - FW-05
Hello boycey,

Iツエm quite happy, that someone else wants to connect an Arduino to LfS.
Your post makes me feel sick, because I canツエt deal with any programming language. But it is not a reason for me to quit my project. Iツエm studying with a lot of nerds in programming so maybe they could help me.

How far is your sourcecode? Is something working right now. Maybe you could pass your code, because I wanted to work through some tutorials and maybe in a while, I could help you out.

Concerning the instrument you said, that a true air-core instrument could be driven by the PWM channels. How could I check out whether its a air-core or just a ammeter. Is it depending on model and year?

I guess the option with the servos should be more easier, becaue the servo library is already written and there is no additional hardware (h-bridges, transistors, potentiometers; and of course soldering) needed, just the servos.

Iツエll let you know if I got any progress.


Kind regards, Tomasz


PS: nice to see, that my thread moved you to write your first post! =)
Quote from boycey10802002 :
The hard thing about you learning outgauge right now is that all of the documentation seems to have disappeared from the internet.

All the OutGauge documentation you'll need is at the bottom of /your_lfs_directory/docs/insim.txt
#5 - FW-05
Quote from Degats :All the OutGauge documentation you'll need is at the bottom of /your_lfs_directory/docs/insim.txt

Yeah right! This is what is written in the InSim.txt:
(just to have quick access to the content)

Quote :// OutGauge - EXTERNAL DASHBOARD SUPPORT
// ========

// The user's car in multiplayer or the viewed car in single player or
// single player replay can output information to a dashboard system
// while viewed from an internal view.

// This can be controlled by 5 lines in the cfg.txt file :

// OutGauge Mode 0 :0-off 1-driving 2-driving+replay
// OutGauge Delay 1 :minimum delay between packets (100ths of a sec)
// OutGauge IP 0.0.0.0 :IP address to send the UDP packet
// OutGauge Port 0 :IP port
// OutGauge ID 0 :if not zero, adds an identifier to the packet

// Each update sends the following UDP packet :

struct OutGaugePack
{
unsigned Time; // time in milliseconds (to check order)

char Car[4]; // Car name
word Flags; // Info (see OG_x below)
byte Gear; // Reverse:0, Neutral:1, First:2...
byte SpareB;
float Speed; // M/S
float RPM; // RPM
float Turbo; // BAR
float EngTemp; // C
float Fuel; // 0 to 1
float OilPressure; // BAR
float OilTemp; // C
unsigned DashLights; // Dash lights available (see DL_x below)
unsigned ShowLights; // Dash lights currently switched on
float Throttle; // 0 to 1
float Brake; // 0 to 1
float Clutch; // 0 to 1
char Display1[16]; // Usually Fuel
char Display2[16]; // Usually Settings

int ID; // optional - only if OutGauge ID is specified
};

// OG_x - bits for OutGaugePack Flags

#define OG_TURBO 8192 // show turbo gauge
#define OG_KM 16384 // if not set - user prefers MILES
#define OG_BAR 32768 // if not set - user prefers PSI

// DL_x - bits for OutGaugePack DashLights and ShowLights

enum
{
DL_SHIFT, // bit 0 - shift light
DL_FULLBEAM, // bit 1 - full beam
DL_HANDBRAKE, // bit 2 - handbrake
DL_PITSPEED, // bit 3 - pit speed limiter
DL_TC, // bit 4 - TC active or switched off
DL_SIGNAL_L, // bit 5 - left turn signal
DL_SIGNAL_R, // bit 6 - right turn signal
DL_SIGNAL_ANY, // bit 7 - shared turn signal
DL_OILWARN, // bit 8 - oil pressure warning
DL_BATTERY, // bit 9 - battery warning
DL_ABS, // bit 10 - ABS active or switched off
DL_SPARE, // bit 11
DL_NUM
};

//////

I know about the insim.txt file, but there used to be a ton of info on the LFS wiki and a trove in the forums.

An air-core 'motor' uses positive voltage to align the needle toward the positive pin. so an 8-bit PWM value of 255 at the north pole of the dial will give you up, and the same at the west pole of the air-core will give you west. but a value of 128 at the west and north pole will give you North-west.

I know I'm not doing a very good job of explaining it and I'd love to stay on and figure out a better way to explain it but I've got a very busy day tomorrow so here's a forum that has some explanations and links on it; http://www.x-simulator.de/foru ... -with-air-core-t1074.html and I promise to show you an arduino sketch later this week. as well as answer any questions you may have.

~Dustin
#7 - FW-05
Hi Dustin,

the InSim.txt file explains everything that has to do with LfS concerning OutGauge. All other documentations should be made, imho, by the developers of the OutGauge tools. Regarding my abilities in programming, I would favour a transscripted source code, so I can reconstruct the steps a programm makes...

The link you posted is very usefull, if it comes so far that I have to drive some air-cores.

Do you have any progress? I have to write some exams, after that I can spend more time for the project.


Kind regards,
Tomasz
#8 - FW-05
Hi there,

just made a small step ahead. Bought a dashboard from a ツエ97 Mitsubishi Galant.
Makes 8000RPM and 160mph. In a few days I will start some hardware testing, if possible.
Maybe someone of you has a clue how to connect to the dash. At the moment I havent coped with that...

If anything else happens, Iツエll write soon as possible!


Kid regards, Tomasz
#9 - FW-05
Hey guys,

progress is made. I have now a Code to feed the Arduino with data from LfS and parse it through to the cluster.
When my cluster will be delivered, I will make a vid and post the link.

At this point I can just say, that it is possible to drive parts of the cluster directly, other air-cores need a h-bridge. Depends all on thecluster ant the internal hardware used.

Regards,
Tomasz
#10 - SJB
Could u publish the python scripts which reads the outgauge data from LFS and feeds the Arduino?

I have a Diecimila and i will use a BMW E30 Tachometer

MfG SJB
At the moment it's kind of broken. I've been trying to modify some parameters to send the data to a GUI as well and I haven't got it returning the proper data objects. If you're half-decent with python you can fix it no problem, I've just been coding 10 hours a day at work and haven't had the energy to finish fixing it. I will hopefully get around to having it fully functional in a couple weeks.

To run the files you put them all in one folder and run the Outgauge_GUI.py file in an python interpreter. I recommend KomodoEdit (which is free) from Active state and create a command that will run it in python.

if (komodo.view) { komodo.view.setFocus() };
komodo.doCommand('cmd_save')
ko.run.runEncodedCommand(window, '%(python) \"%F\" {\'cwd\': u\'%D\'}');



That is the command I use, it's java so you'll have to select that in the command options. I think there was one more thing I wanted to tell you, but I forget it at the moment. If I think of it, I'll post later. Send me another message if you have any questions.
Don't despair
I have been updating the code (I know the stuff I gave you didn't work as it was still work-in-progress being re-purposed, but now I have working (again) code that can take data and out-put it to the python Command Output. I'm going to change some code that I've made perviously and set it up to output a data string through USB to the Arduino. That code will be happening a little later, but for now if you want some badly commented, but functioning code message me on this thread!
#13 - SJB
Hi!

Yeah it would be really cool when u upload the working code

Regards,
SJB
Quote from SJB :Hi!

Yeah it would be really cool when u upload the working code

Regards,
SJB

Removed obsolete attachment, Typos
Hey Sorry.
Busy couple of days & nights at work.
I got the GUI to put values on separate lines, but there are still some bugs to work out.

Don't exit or pause LFS before closing the GUI program, otherwise it'll freeze.
The reason for this is because the GUI won't refresh until it gets new data. The fix is to restart or unpause LFS, then my program starts getting data again and you can exit it properly.

There are some other data values like 'pit_limiter' that show weird, incorrect values, but that's because Scawen modified the Outgauge UDP packets after Nilo wrote the UDP Packet parser for LFS in 2008.

But I'll get around to fixing those. Once that's up it should be easy to get the program to send the data over USB (I've got some code I've already written for something else laying around)

Cheers
Hey there. I need an answer from you guys
I'm facing a design branch; creating the design for the instrument cluster is going to take some interface circuitry. Would you guys want some mildly complex microchips, or a lot of bulky transistors in the design if you're going to make it yourself? Or, if I make something that's more compact would you buy it? I don't know where to go with this so I'm looking for your input.

Cheers,
d
#17 - SJB
At the moment i'm playing with a TLC5940 (4Pins from Arduino -> 16 PWM outputs) and transistors (as amplifiers) for dimming 4 RGB-LED strips.

I'm planning to use the same layout for the tachometer (and have some cool light effects e.g. white background light for RPM and when i'm at the red RPM range, fading to red background light)

But for the intruments only, i think transistors would be enough

Regards,
SJB
Hey guys.
Got LFS working tonight with an Arduino and the RPM values on a Servo.
Working on making it flexible with other data streams (Speed, Turbo, etc.) and to get it working with Aircore Instruments.

Woot!
Quote from boycey10802002 :Hey guys.
Got LFS working tonight with an Arduino and the RPM values on a Servo.
Working on making it flexible with other data streams (Speed, Turbo, etc.) and to get it working with Aircore Instruments.

Woot!


I want to see it
today I ordered a arduino uno - insim, i coming!
Hey sorry for not posting for a bit. I've got two huge deadlines coming up at the end of October for both my Full-time job and freelance work. I will continue to develop the USB-parsing protocol for the Arduino at the start of November.
just a quick update. My extreme work schedule ended with an extreme cold/flu and I've been down for a little while and lacking energy. But now I feel I'm back at full strength and can finish this stuff of for you guys and create a wiring diagram so you can hook up some air-core gauges as well.

Right now the only thing holding me back is a small bug in the Arduino that is causing it not to compile so I'm working on a fix.
I hope to update soon with awesome working code.

Cheers
Hey!
Update!
I've got the more robust USB protocol working with gauges. I'm ordering a shift register and a TLC5940 because SJB mentioned it. Right now I'm working on expanding the python script to properly handle the not-so-new updates to the dash light system and then it will be awesome!
I'm very interested to see how this progresses.

I've just picked up a mega 2560 and a 128x64 graphical LCD panel that I'm hoping to use along side (or instead of) my Bodnar SLI-M. I have a few ideas on how I would implement this thing, but I'd be keen to see how you've done it.
That sounds awesome.
I've created the USB protocol to be as versatile as possible when it comes to LFS-formatted packets, so you could potentially pull OUTSIM or INSIM data as long as you had a function to handle and display the data on your graphic LCDs.

I've also got the indicator lights working now, I'm waiting for some shift-registers and that TLC594 to create the handling functions for that for you guys.

Cheers
Happy New Years!
The shift registers are working. They arrived just as I was leaving for the holidays and while I've had some time off work I've gotten them working.
When I finished the with the air core ICs I'll post a wiring schematic and the code for you guys.

FGED GREDG RDFGDR GSFDG