The online racing simulator
Quote from boycey10802002 :Haha. Sorry, my bad.
New files attached.
As a note to people trying to use my Python script, I'm using python v2.6

I'm trying to use this but always i have an error when im going to run it

python says: invalid syntax

then shows me where is the error, but i see all ok.



I don't know how to solve it. I just want to comunicate lfs with my arduino :weeping:
Are you using the correct version of Python? That code was written for Python 2.6, so you will need to have either Python 2.6 or 2.7 installed to run it. From that error it looks like you're probably using Python 3.0, which is why it won't work. You can download Python 2.7 here.
DarkTimes is correct. It looks like you may be using the wrong version of python.

Also you should undefine DEBUG once you get it running because all the tesing communications overload the available bandwidth on the serial bus

**EDIT**
By undefine I mean make DEBUG = 0, instead of 1
Quote from DarkTimes :Are you using the correct version of Python? That code was written for Python 2.6, so you will need to have either Python 2.6 or 2.7 installed to run it. From that error it looks like you're probably using Python 3.0, which is why it won't work. You can download Python 2.7 here.

That's it


Now when I run "Outgauge_GUI.py" i can see the GUI. If I push start, the program crashs.

Which order have i open the programs?
1-Python
2-Arduino
3-LFS

is it ok?
I've not tried this, but I'd imagine you should start the Python program last, after LFS and Arduino are running. Otherwise the program might try to connect to LFS or Arduino before they are ready and cause an error.
i have started Arduino and LFS first then python. Now GUI doesn't open and python shows me this:



If i run arduino and python with out LFS, error doesn't appear but when i press start, program freezes.
If memory serves I think this is how you do it.

Before you open LFS or the python script:
Ensure you configured LFS's cfg.txt settings to match what is expected from the python script.
Quote :
OutGauge Mode 2 <-- Can be 1 for just your car
OutGauge Delay 10 <-- Set this so your dials don't lag; it's set to '2' on my pc
OutGauge IP 127.0.0.1 <-- Very Important
OutGauge Port 12024 <-- Very Important
OutGauge ID 0 <-- packet ID, not used here

Also ensure that the script is looking for the correct serial device. (i.e. substitute "COMx" where ever it says "COM4" in the code, the 'x' in 'COMx' being the COM number of the Ardiono you want to control.

Step #1
Start LFS and the Python script (it doesn't matter which is first at this step)

Step #2
Click the 'Start' button. If you've got a solid connection all of the parameters being sent for Out Gauge will start updating.

Step #3
Click the enable USB Connection checkbox

That will start streaming the data you see in the GUI to your Arduino.

I think this is the way I designed it to work.

Let me know if you run into any more errors
I'd followed ur steps and it's the same. The cfg is ok.

I'd tryed some test...

- Test 1
If I run Python alone, it shows me this:
http://i43.tinypic.com/wkp7uq.png

- Test 2
I plug my arduino, then i run python. It shows me interface, when i press start, the program crashes. If i run lfs before i press start, the result is the same.
http://i40.tinypic.com/drc7zp.png

- Test 3
The same as test 2 but at beginning i'd started LFS. When i press start the program crashes
I'm assuming you've installed a compatible version of pySerial?
if not you can nab it from here: http://pypi.python.org/pypi/pyserial.

If you have and it's still not working I'll see if I can rework something over the weekend.
any instructions
any instructions how to wire it all up an what arduinos can be used ?
I had installed pyserial 2.5 Now i have installed 2.6 version but it's not working... same problem


Thx to waste ur time with me
I'm sorry it's not working properly, I'll try to cleanup the python code this weekend and see if I can't get it working again.

As for hooking up Arduinos; I think that every Arduino can listen to output from the python script. It's all about how you tell the Arduino to interpret that information that gets sent to it.

What the script sends is packaged like this:

|--- START BYTE ---|--- Parameter Tag ---|--- SEPARATOR ---|--- Value ---|---END BYTE---|

I believe the start byte is set as a null Character ( ASCII value of 0 ), the end byte is the character represented by the ASCII value of 255. the separator is a colon ( : ) and the Parameter and values are char arrays. After that you can get as simple or as complicated as you want.

If you want to be really complicated you can run all the gauge data to real air-core gauges as well as have a seven-segment display read the current gear and have all the dash lights light up some LEDs. For that you'd need to interface some bit-registers and some motor controllers ( L293Ds work great as simple motor controllers )

If you want to go the medium-complexity route, You can hook up an LCD and read out all the available data, or graph it or whatever.

A dead-simple way to do it, without any hardware, is to map the Shiftlight to pin13 on the Arduino which lights up the little, on-board LED.

If you have any specific questions please ask.
**EDITED**
Now at V0.2

Quote from clunk1986 :what exactly would i need circuit wise to hook up air cores to a arduino currently i have a l293d an sn74hc595n arduino uno thanks in advance

I've uploaded a couple of pictures demonstrating the test setup that I have. I know it looks like a jumble of wire, but don't freak out and think it's impossible. What it is is a couple of little systems copied and distributed around some breadboards.
Close Up of the Motor Controller
A wide shot of my testing rig

As an example I've also attached an image explaining how I have hooked up the wiring for the L293DNEs. Clearly this isn't what Texas Instruments calls the pin-outs on their chips, but this is how, conceptually, they are connected to other hardware
L293DNE as an air-core driver
SN74HC595N as a controller for 8 LEDs
While searching for some SN74HC595N spec I happened across a google books sample of "Beginning Arduino" By Michael McRoberts. Chapter 6 is entirely devoted to hooking up shift registers to an Arduino (using only 3 control pins) and with resistors for the LEDs. I would recommend reading that chapter, it has great explanations about how bit registers work and has good diagrams and some code samples to go along with it.

A note to Scoundrel:
I am currently fixing up the python code so that it works properly and is more manageable. I have all of the sub-components working and am just pulling everything together in the UI. It will hopefully be done soon.
Quote from boycey10802002 :
A note to Scoundrel:
I am currently fixing up the python code so that it works properly and is more manageable. I have all of the sub-components working and am just pulling everything together in the UI. It will hopefully be done soon.

Thanks for ur time :laola:
Reviving this thread, as I want to do this too. For me, the code to grab the UDP data from LFS and send it out of any port on the PC is the most complex part, since I've been out of touch with PC development for over a decade now. Once I have that data, I can build anything with arduinos, PICs, etc.

Boycey, do you have any updated code for this that you can share? Also, how do I run this? Do I just start up the python interpreter on my PC and run this program, and I'll see data out the port?

Also, if anyone needs help with the electronics and microcontroller firmware, LMK.

Cheers,
-Neil.
Hey Dude,

So unfortunately I haven't updated things, I was getting pretty busy with a new job at the time so it got pushed to the back burner and forgotten about. No one has asked any questions anyway so I assume they've moved on to something else. If you want this to follow through please keep asking me stuff and bugging me so it stays in the forefront of my mind.

Anyway I do have an half-done c# version of the code that would run in just a simple .exe when it's finished.

I saw in another post you mentioned something about trade shows? Could you tell me a little bit about this project of yours you are planning?

Cheers.
Yep -- what I'm trying to do is to build a race-car sim for a trade show, but with actual physical gauges. I can get LFS running, and do everything from taking gauge data out the serial/USB port and converting using microcontrollers to be displayed on the physical gauges. It's that little piece of code in the middle that takes the LFS UDP data and converts it to data out the serial port that is holding me back. It looks like others (such as you) have done this, but I am so out of touch with PC programming that I am not even sure what interpreters or compilers, libraries, etc I need to run to get this part working.

It seems others are having issues with taking the external/serial data and modifying it with arduinos etc to convert to analog for the physical gauges, but that's what I can do easily, so once I get this running I can project-ize that for others to follow, with source code etc.
Do you mean the part of the code that gets the UDP data and makes it usable variables in a programming language?

If you are talking about that, lfs manual has a working python code doing exactly this:

http://en.lfsmanual.net/wiki/OutSim_/_OutGauge

at the bottom.
Okay, this clears up a lot and gets me mostly there. Until now, I thought outgauge was something written by another person, and did not realize it was a feature of LFS directly. That explains why I could not find the source for it .

I haven't used Python in probably a decade, but it shouldn't be too difficult to figure out the interpreter to run this. I now need to modify this to send the data out serially. I found pyserial, which should be all I need ... I think. I'll go read up on that.

Thank you!!!
-Neil.
Yeah. that code looks pretty straight forward. You will probably want to implement some UI or something so you can turn on and off your serial connection and re-bind the packet stream coming in.

As for pyserial, that's what I used to kick stuff out to the Arduino and it is fairly simple to use as well.

FGED GREDG RDFGDR GSFDG