The online racing simulator
Searching in All forums
(31 results)
1
boycey10802002
S2 licensed
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.
boycey10802002
S2 licensed
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.
boycey10802002
S2 licensed
**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.
Last edited by boycey10802002, . Reason : updates
boycey10802002
S2 licensed
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.
boycey10802002
S2 licensed
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.
boycey10802002
S2 licensed
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
boycey10802002
S2 licensed
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
Last edited by boycey10802002, .
boycey10802002
S2 licensed
are you using python 2.X and a compatible version of pySerial?
boycey10802002
S2 licensed
When you're testing the connection to the arduino, do you have the Serial Com window connected as well as the python program? The Arduino Com Window blocks other connections to the software. If you're doing both at the same time that may be the problem.
boycey10802002
S2 licensed
Did that help you at all?
boycey10802002
S2 licensed
It looks as though it's not able to connect to the correct serial device.

Have you modified lines 14 and 82 of Outgauge_GUI.py to correspond to the name or index of the COM device your Arduino shows up as? i.e. switching "COM4" to be named "COM3" or, alternatively the index 2.

And do you have pySerial installed as well?


As a side note; now that I've had more experience with C++, I'm looking at possibly changing this outugauge program over to a single .exe file so that it runs faster and is easier to install.
boycey10802002
S2 licensed
Google is a handy brain-extender.

Arduino Board
SN74HC595N -> link
L293DNE -> link
breadboard -> link

The two jumbles of numbers and letters are special types of integrated circuits (micro chips) the first turns its output on or off in a special order (a shift register) the second is a motor controller, used for air-core motors, like the ones commonly used in older car dashboards. As for your e36 dash, you'd have to check how it's set up.

The way my dash works I pulled the air-core motors out of an old car and just mounted them to some foam core in an arrangement that I kinda like and all I've used are those

I'm sure you'll have more questions.
Cheers.
boycey10802002
S2 licensed
I did some detective work for the Tach and it seems it really depends on how you want it set up to work with the PWM outputs, I don't have that style controller pre-programmed, but I could add/modify some code to make it work.
As for the Turbo, it looks like a standard, 4-wire air-core. Those have been worked into the Arduino sketch and all you need to make that work is a SN74HC595N or similar shift-register and a L293DNE, or similar motor driver. I had been planning to take a bunch of pictures and make some wiring diagrams but I've been completely side-tracked with work. I'll see if I can find some free time and try to write up some documentation about how different pieces of the sketch relate to actual hardware on a board.

To recap you need:
Those gauges you want
1 x Arduino
1 x SN74HC595N
1 x L293DNE
Some extra wire, header pins a breadboard and patience.

Google is a good resource to check how to wire up the shift registers, you can also drive a 7-segment display with a shift-register, too; along with all the other dash lights and miscellaneous warnings that happen in LFS.

I'll do my best to help you out and answer any more questions you, or anyone else, may have.


And I'll work on getting some pics up tomorrow.
Cheers.
boycey10802002
S2 licensed
There shouldn't be any lag with the serial device.
I added in some code that reduces the number of updating serial calls to the bare minimum so all that is there would be is the lag imposed by your lfs.cfg file.
boycey10802002
S2 licensed
Haha. Sorry, my bad.
New files attached.
As a note to people trying to use my Python script, I'm using python v2.6
Last edited by boycey10802002, . Reason : more info
boycey10802002
S2 licensed
Hey Killer,
I'm sorry I totally forgot to include the python side of things.
It'll be attached to this message, along with the proper Arduino Sketch.

As for configuring COM ports; I'm trying to get it to automatically detect which COM ports are available and then have the user select from a list and let it connect that way, but right now it's hard-coded into a couple of lines in the OutgaugeGUI.py file
There are two lines that need to be changed:
Line 13 has (port = "COM4") at the end, change it to whatever port your arduino is set to.
Also, line 81; same deal. Change "COM4" to whatever port your Arduino is.
You also need pySerial to be able to run the serial connections required for the Arduino.

Just message me if you guys have any questions, or run into problems.

For January I'm on a tight deadline for a C++ project at work so I won't be free to update much code here, but if you need something fixed or clarified I'll try to get back to you ASAP.
Last edited by boycey10802002, . Reason : typo, formatting and Removed Obsolete Files
boycey10802002
S2 licensed
And finally the nut-and-bolt functions.
These are the ones that take the values ant mutate them into something usefull for the Arduino board to output to the hardware

Code:

=:REMOVED OLD CODE:=

I realize a some stuff is commented out, and my notes may be out of date at some parts, but It's still a work in progress and I'm trying to get 4 air core dials working simultaneously tonight.
Last edited by boycey10802002, . Reason : Formatting ( [CODE] Tags)
boycey10802002
S2 licensed
this is what I've got in another tab of the same sketch to take the value and apply the proper handling functions to it depending on what it is.

For example, rpm gets passed to a function that takes the string '1000' and turns it into an int; 1000.
This then gets passed to a remapping function to be mapped to an angle, let's say 45 degrees.
That value is then sent to a function that writes it out to arduino pins in a sin+/- & cos+/- way.

Another example is the Dash lights.
They are assigned to an output of a shift register and when a serial command like ÿshiftlight:1<null> get sent, it turns the 6th output of the shift register to 'HIGH' and the light hooked up to that output turns on.

if you're not clear about something please ask me to clarify.
Here's the code:

=:REMOVED OLD CODE:=
Last edited by boycey10802002, . Reason : Formatting
boycey10802002
S2 licensed
Thanks Willard, that's something along the line of what I've done with python.

Cursed, that's some wicked LCD display stuff.
If you're eager to pump some data into the Arduino I've got some serial parsing code right here:

=:REMOVED OLD CODE:=


This code takes a serial string formatted like this: ÿrpm:1000<null>
and parses it into values and that a different handler can take. I'm sorry if it's not really commented all that well, it's still in heavy development. The <null> is supposed to be a null. (0x00, chr(0), bin(00000000)) In debug mode the parser also takes a tilde(~) since I haven't figured out how to communicate a null over the serial monitor. When it's done you have two values, OutGaugeLable and OutGaugeValue. Lable is anything before the colon( In this example 'rpm' and Value is anything after, in this case, '1000' there's some extra code in a different section that takes the text version of '1000' and turns it into either a float, a double or int; depending on which version of the function is called.

Also, I've got the aircores working and I am trying to implement the polarity pins into another shift register to save pin space on the arduino board.

Cheers, guys.
Last edited by boycey10802002, . Reason : Formatting &amp; Typo
boycey10802002
S2 licensed
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.
boycey10802002
S2 licensed
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
Last edited by boycey10802002, . Reason : typo
boycey10802002
S2 licensed
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!
boycey10802002
S2 licensed
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
boycey10802002
S2 licensed
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.
Last edited by boycey10802002, .
boycey10802002
S2 licensed
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!
Last edited by boycey10802002, . Reason : typo
1
FGED GREDG RDFGDR GSFDG