simracing gauges among other things - Page 1
Forum section: electronics / projects

author: ITman496
author_rank: Regular Contributor
timestamp: October 07, 2013, 01:23:05 am
content: Hey, new here! But I've been watching the blog for a very, very long time..Figured I'd register. Why not, right? I've been lurking around with no account for a long time, and got inspired by someone in the workbench thread to make my own. Came out rather well.anywho, I figure I'll just dump any interesting projects I've made into here.The first one I'm going to talk about is something I recently completed. Converting a set of porsche 997 gauges to work with rfactor/simtools. (racing game)Now for some reason, the gauges have steppers on each needle, and the board is 4 layer and I have no idea how it worked. Also, I tried to communicate with it via CAN bus but apparently porsche have their own unique flavor of canbus. I have zero knowledge in reverse engineering communications, (though in hindsight I probably could have asked around here) but too late now, already hacked the pcb up.So what I decided to do was to cut traces and isolate the steppers and led's I cared about, then solder bits of wire to them and make my own interface board.That's minus two gauges (the outer ones have separate boards, one of them very confusing)This is what the motors look like.As for that gauge, I don't have a picture of it, but its similar to this one,Except for one painfully important detail. The red led in the center on this image has a resistor to let it run on 12v. The other one does not, its resistor is on the main board. I figured that out when I plugged the power in and heard quite a loud bang of the ~2v led getting 12v.Anyway, so that was the gauge fully modded.Once that was out of the way, it was time for the interface board.Now unfortunately I have not followed the schematics directly, due to removing the need for input buttons, and thus I didn't need to use a shift register anymore to control stepper direction, so that circuit was removed as well. As well as backlight control via the microcontroller. It got a bit more basic, but easier to program. Keep in mind that my most complex programmed project before this was a solder-breadboarded arduino that listened to two rc radio channels and triggered lights or a relay to switch video.I made up a schematic, and sorta loosely followed it, too!https://dl.dropboxusercontent.com/u/4963246/zeos%20gauges/schematic%20V1.png(huge image)And after many many hours of assembly...finally.. ITS ALIVE!!Anyway, so that works now. =)Here is the code, if you are curious:Code:// To test in serial monitor , take comments out to see the output.// Need to send R000G000S000O000W000F000L00000000000 where xxx is 0 to 256 with padding ie 1 = 001int rpm;int gear;int speedo;int water;int oil;int fuel;int engineoverheat;int brakeoverheat;int tiredamage;int shiftup;int shiftdown;int partsdetached;int inpits;int yellowflag;int sector1flag;int sector2flag;int sector3flag;int flag;int bufferArray;int target1;int target2;int target3;int target4;int target5;int target6;int currentpos1;int currentpos2;int currentpos3;int currentpos4;int currentpos5;int currentpos6;int DIR1 = 2; // PIN 2 = DIRECTION 1 (DIR1)int STEP1 = 3; // PIN 3 = TRIGGER STEP 1 (STEP1)int DIR2 = 4; // PIN 4 = DIRECTION 2(DIR2)int STEP2 = 5; // PIN 5 = TRIGGER STEP 2 (STEP2)int DIR3 = 6; // PIN 6 = DIRECTION 3 (DIR3)int STEP3 = 7; // PIN 7 = TRIGGER STEP 3 (STEP3)int DIR4 = 8; // PIN 8 = DIRECTION 4 (DIR4)int STEP4 = 9; // PIN 9 = TRIGGER STEP 4 (STEP4)int DIR5 = 10; // PIN 10 = DIRECTION 5(DIR5)int STEP5 = 11; // PIN 11 = TRIGGER STEP 5 (STEP5)int DIR6 = 12; // PIN 12 = DIRECTION 6 (DIR6)int STEP6 = 13; // PIN 13 = TRIGGER STEP 6 (STEP6)int w;int latchPin = A0; //Pin connected to ST_CP of 74HC595int clockPin = A1; //Pin connected to SH_CP of 74HC595int dataPin = A2; //Pin connected to DS of 74HC595int lednumber;void setup(){pinMode(DIR1, OUTPUT); // set pin 2 to outputpinMode(STEP1, OUTPUT); // set pin 3 to outputpinMode(DIR2, OUTPUT); // set pin 4 to outputpinMode(STEP2, OUTPUT); // set pin 5 to outputpinMode(DIR3, OUTPUT); // set pin 6 to outputpinMode(STEP3, OUTPUT); // set pin 7 to outputpinMode(DIR4, OUTPUT); // set pin 8 to outputpinMode(STEP4, OUTPUT); // set pin 9 to outputpinMode(DIR5, OUTPUT); // set pin 10 to outputpinMode(STEP5, OUTPUT); // set pin 11 to outputpinMode(DIR6, OUTPUT); // set pin 12 to outputpinMode(STEP6, OUTPUT); // set pin 13 to outputpinMode(latchPin, OUTPUT); //set shift register pins to outputpinMode(clockPin, OUTPUT);pinMode(dataPin, OUTPUT);Serial.begin(57600);currentpos1 = 0;currentpos2 = 0;currentpos3 = 0;currentpos4 = 0;currentpos5 = 0;currentpos6 = 0;rpm = 0;speedo = 0;gear = 0;water = 0;oil = 0;fuel = 0;lednumber = 0;calibrate();}void loop(){//****************************** MAIN LOOP ******************************readdata();stepcalc1();stepcalc2();stepcalc3();stepcalc4();stepcalc5();stepcalc6();lights();delayMicroseconds(1500);//Serial.println("still alive");}//**********************//**********************CALC ROUTINES*****************************************void stepcalc1(){target1 = speedo;if (currentpos1 < target1) {stepper1(0);currentpos1++;}if (currentpos1 > target1) {stepper1(1);currentpos1--;}}void stepcalc2(){target2 = water;if (currentpos2 < target2) {stepper2(0);currentpos2++;}if (currentpos2 > target2) {stepper2(1);currentpos2--;}}void stepcalc3(){target3 = gear * 2.4;if (currentpos3 < target3) {stepper3(0);currentpos3++;}if (currentpos3 > target3) {stepper3(1);currentpos3--;}}void stepcalc4(){target4 = fuel;if (currentpos4 < target4) {stepper4(0);currentpos4++;}if (currentpos4 > target4) {stepper4(1);currentpos4--;}}void stepcalc5(){target5 = oil;if (currentpos5 < target5) {stepper5(0);currentpos5++;}if (currentpos5 > target5) {stepper5(1);currentpos5--;}}void stepcalc6(){target6 = rpm;if (currentpos6 < target6) {stepper6(1);currentpos6++;}if (currentpos6 > target6) {stepper6(0);currentpos6--;}}//************************************************************// **********************STEPPER ROUTINES*********************void stepper1(int x) {digitalWrite(DIR1, x);digitalWrite(STEP1, HIGH);delayMicroseconds(150);digitalWrite(STEP1, LOW);}void stepper2(int x) {digitalWrite(DIR2, x);digitalWrite(STEP2, HIGH);delayMicroseconds(150);digitalWrite(STEP2, LOW);}void stepper3(int x) {digitalWrite(DIR3, x);digitalWrite(STEP3, HIGH);delayMicroseconds(150);digitalWrite(STEP3, LOW);}void stepper4(int x) {digitalWrite(DIR4, x);digitalWrite(STEP4, HIGH);delayMicroseconds(150);digitalWrite(STEP4, LOW);}void stepper5(int x) {digitalWrite(DIR5, x);digitalWrite(STEP5, HIGH);delayMicroseconds(150);digitalWrite(STEP5, LOW);}void stepper6(int x) {digitalWrite(DIR6, x);digitalWrite(STEP6, HIGH);delayMicroseconds(150);digitalWrite(STEP6, LOW);}//**********************************************************************//*******************CALIBRATION****************************************void calibrate() {for( w = 0; w < 200; w++) {stepper1(1);stepper2(1);stepper3(1);stepper4(1);stepper5(1);stepper6(0);delay(5);}delay(500);for( w = 0; w < 200; w++) {stepper1(0);stepper2(0);stepper3(0);stepper4(0);stepper5(0);stepper6(1);delay(1);}delay(150);for( w = 0; w < 200; w++) {stepper1(1);stepper2(1);stepper3(1);stepper4(1);stepper5(1);stepper6(0);delay(1);}delay(150);for( w = 0; w < 38; w++) {stepper5(0);delay(2);}delay(300);for( w = 0; w < 45; w++) {stepper1(0);delay(2);}delay(300);for( w = 0; w < 23; w++) {stepper6(1);delay(2);}delay(300);for( w = 0; w < 48; w++) {stepper2(0);delay(2);}delay(300);for( w = 0; w < 37; w++) {stepper4(0);delay(2);}delay(300);for( w = 0; w < 27; w++) {stepper3(0);delay(2);}delay(300);currentpos1 = 0;currentpos2 = 0;currentpos3 = 0;currentpos4 = 0;currentpos5 = 0;currentpos6 = 0;ledcalibration(128);delay(100);ledcalibration(16);delay(100);ledcalibration(8);delay(100);ledcalibration(2);delay(100);ledcalibration(4);delay(100);ledcalibration(1);delay(100);ledcalibration(64);delay(100);ledcalibration(32);delay(500);ledcalibration(255);delay(100);ledcalibration(0);delay(100);ledcalibration(255);delay(100);ledcalibration(0);delay(100);ledcalibration(255);delay(100);ledcalibration(0);//Serial.print("Calibration complete");}//******************************************************************//*******************************LIGHT DATA*************************************void lights() {digitalWrite(latchPin, LOW);if (yellowflag + sector1flag + sector2flag + sector3flag > 0.5) {flag = 1;}if (yellowflag + sector1flag + sector2flag + sector3flag < 0.5) {flag = 0;}lednumber = ((shiftup) + (tiredamage * 2) + (shiftdown * 4) + (engineoverheat * 8) + (partsdetached * 16) + (flag * 32) + (brakeoverheat * 64) + (inpits * 128));shiftOut(dataPin, clockPin, MSBFIRST, lednumber);digitalWrite(latchPin, HIGH);}void ledcalibration(int x) {digitalWrite(latchPin, LOW);shiftOut(dataPin, clockPin, MSBFIRST, x);digitalWrite(latchPin, HIGH);}//****************************** READ DATA FROM SERIAL ******************************void readdata() {if (Serial.available() >= 36) { //if 24 bits available in the Serial buffer...int i;for (i=0; i<36; i=i+1) { // read and label each byte.bufferArray = Serial.read();}if (bufferArray == 'R'){rpm = ((bufferArray-48)*100) + ((bufferArray-48)*10) + (bufferArray-48);//Serial.print("You have set the Rpm to a Value of:");//Serial.println(rpm);}if (bufferArray == 'G'){gear = ((bufferArray-48)*100) + ((bufferArray-48)*10) + (bufferArray-48);//Serial.print("You have set the Gear to a Value of:");//Serial.println(gear);}if (bufferArray == 'S'){speedo = ((bufferArray-48)*100) + ((bufferArray-48)*10) + (bufferArray-48);//Serial.print("You have set the Speed to a Value of:");//Serial.println(speedo);}if (bufferArray == 'O'){oil = ((bufferArray-48)*100) + ((bufferArray-48)*10) + (bufferArray-48);//Serial.print("You have set the Oil to a Value of:");//Serial.println(oil);}if (bufferArray == 'W'){water = ((bufferArray-48)*100) + ((bufferArray-48)*10) + (bufferArray-48);//Serial.print("You have set the Water to a Value of:");//Serial.println(water);}if (bufferArray == 'F'){fuel = ((bufferArray-48)*100) + ((bufferArray-48)*10) + (bufferArray-48);//Serial.print("You have set the Fuel to a Value of:");//Serial.println(fuel);}if (bufferArray == 'L'){engineoverheat = bufferArray-48;brakeoverheat = bufferArray-48;tiredamage = bufferArray-48;shiftup = bufferArray-48;shiftdown = bufferArray-48;partsdetached = bufferArray-48;inpits = bufferArray-48;yellowflag = bufferArray-48;sector1flag = bufferArray-48;sector2flag = bufferArray-48;sector3flag = bufferArray-48;//Serial.print("You have set the lights to a Value of:");//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);//Serial.println( bufferArray-48);}}}Probably riddled with horrible things, but meh. It works, right?Anywho, the other thing that I made that's interesting are a few fpv planes and my workbench. The planes are a bit more involved, I'll post about them later. Here is the workbench, though.plan:thing in real life:Anyway, sorry for the huge first post. Figured I'd contribute with it? I dunno.

author: peter.mitchell
author_rank: Super Contributor
timestamp: October 07, 2013, 04:00:09 am
content: I like you already, your priorities are in the right place! A decent computer and electronics bench, and an air conditioner duct taped into the window!

author: ITman496
author_rank: Regular Contributor
timestamp: October 07, 2013, 06:27:53 am
content: Thanks! Yeah, I do love that AC unit. It's side seals kinda sucked, so I had to improvise..I also made this bench after buying one of these:http://www.lowes.com/pd_2218-55738-LWWB08-3D4563_0__and just realizing how much better I could have done it.

author: ITman496
author_rank: Regular Contributor
timestamp: October 08, 2013, 03:25:21 am
content: Woo, progress!

author: allen2688
author_rank: Newbie
timestamp: October 08, 2013, 04:02:53 am
content: Hey Really sick stuff man!! I'm too am into the Sim racing stuff and I'm planning on selling some pit-road speed limiter indicators lights for button boxes.Btw Have you seen revburnners being sold on the market There compatible with R Factor Iracing LFS exc.I mostly play LFS And IRacing and was on a drift team for quite some time before time got in the way, do you have a LFS account by any chance?

author: ITman496
author_rank: Regular Contributor
timestamp: October 08, 2013, 11:22:29 am
content: I've heard of those other racing games but personally haven't played them yet, only rFactor so far. Should try them at some point, I think!I haven't seen any of the other things you mentioned, but they sound cool!Are those games good, compared to rfactor?

author: allen2688
author_rank: Newbie
timestamp: October 09, 2013, 11:32:10 pm
content: Rfactor and LFS are almost the same, lfs is slightly older the Rfactor and were waiting for the big "S3" update that they have been promising. IRacing is the top of the top sim out there right now its used by most professionals (that there teams haven't made their own person sim yet) and they have a whole safety rating system, online races every 30 min. exc. I should try out Rfactor some time it seems really cool from what i have heard!

author: orbiter
author_rank: Frequent Contributor
timestamp: October 09, 2013, 11:41:46 pm
content: How does R factor compare to simraceway you guys?Also..Welcome Itman.. Awesome project ya did there.

author: ITman496
author_rank: Regular Contributor
timestamp: October 10, 2013, 07:08:45 am
content: doesn't simraceway hold addons for rfactor?I need to try rfactor two, possibly others. How are the addon cars for liveforspeed?and thanks orbiter!