|
|
|
|
Thread Tools | Display Modes |
06-14-2018, 10:39 AM | #176 |
Scooby Newbie
Member#: 403592
Join Date: Oct 2014
|
Bump... anyone try making a DIY pressure sensor also? Lol
* Registered users of the site do not see these ads.
|
06-24-2018, 03:32 PM | #177 |
Scooby Specialist
Member#: 435142
Join Date: Nov 2015
Chapter/Region:
MWSOC
Location: Commerce Twp, MI
Vehicle:2004 STi Java Black Pearl |
I finally got around to giving this a go. I kept my rear O2 in place, so I made a pigtail for it, using the left TGV for the signal, and the same ethanol sensor posted by the OP. My voltages are as follows:
Battery voltage with the key on: 11.9v (low, I know its been a while lol) Board power/gnd (where the 8v reg is): 11.7v The 8v regulator (and/vin): 7.9v Board 5v: 5.0v (score!) Signal from E sensor at board: 4.2v Power at E sensor: 11.7v TGV signal wire: 0v I think I may have used the wrong pin from the TGV, and that is why my values are incorrect. My TGV voltage on my AP was reading 0.00 with the car running (no surprise considering the measured voltages at the pins). If someone could confirm for me the signal pin for the TGVs in the 04-07 STi I'd appreciate it! P.S. I'm using Barge's code, but I don't think this is a coding issue EDIT: For anyone else having this issue, the signal wire is the yellow/red wire on the 04-07 STi, my TGV voltage is now reading 0.9v, which seems about right for pump 93 (~10% corn) Last edited by brecks; 06-24-2018 at 04:05 PM. |
07-09-2018, 11:57 AM | #178 |
Scooby Newbie
Member#: 488121
Join Date: Jul 2018
|
I came up with my own version of this, using this thread as well as a few others for inspiration. I did things slightly differently. I used an Arduino Beetle, a .96 inch LCD and a 5 volt regulator instead to power the Beetle since it doesn't have any voltage protection. I also used interrupts vs pulseIn for the measurements. In the display I have the top line showing ethanol percent and the bottom line showing temp in a bit smaller font.
Code: Code:
#define EI_ARDUINO_INTERRUPTED_PIN #include <EnableInterrupt.h> #include <GOFi2cOLED.h> GOFi2cOLED LCD; #define SENSOR_PIN 10 #define OUTPUT_PIN 9 volatile unsigned long previousTime = 0; volatile unsigned long highTime = 0; volatile unsigned long lowTime = 0; void stateChanged() { unsigned long currentTime = micros(); // high -> low if (arduinoPinState == 0) { highTime = currentTime - previousTime; } else { // low -> high lowTime = currentTime - previousTime; } previousTime = currentTime; } void setup() { LCD.init(0x3C); LCD.setTextWrap(false); LCD.clearDisplay(); LCD.setTextSize(2); LCD.println("Ethanol"); LCD.println("Analyzer"); LCD.display(); delay(2000); pinMode(SENSOR_PIN, INPUT); enableInterrupt(SENSOR_PIN, stateChanged, CHANGE); // Setup for analog out, pin 9 to fast mode. pinMode(OUTPUT_PIN, OUTPUT); TCCR1B = TCCR1B & 0b11111000 | 0x01; } void loop() { unsigned long pulsetime = highTime + lowTime; // 20000 uS = 50 HZ - ~6667 uS = 150 HZ if (pulsetime > 200000 || pulsetime < 6667) { // If the value falls outside the range just skip it for this iteration. return; } LCD.clearDisplay(); LCD.setCursor(0, 0); // 50 HZ = 0% ethanol, 150 HZ = 100% ethanol long eContent = int((1000000 / pulsetime) - 50); // These should never hit due to the check above. if (eContent < 0) { eContent = 0; } else if (eContent > 100) { eContent = 100; } // 1 millisecond = -40°C, 5 milliseconds = 125°C float frequency = float(1000000 / pulsetime); float dutyCycle = 100 * (highTime / float(lowTime + highTime)); float totalTime = float(1.0 / frequency); float period = float(100 - dutyCycle) * totalTime; int temperature = 40.25 * 10 * period - 81.25; int temperatureF = temperature * 1.8 + 32; // Analog out, 0 volts = 0%, 5 volts = 100% float desiredVoltage = mapf(eContent, 0, 100, 0, 5); int analogOut = 255 * (desiredVoltage / 5); analogWrite(OUTPUT_PIN, int(analogOut)); LCD.setTextSize(4); LCD.print("E:"); LCD.print(eContent); LCD.println("%"); LCD.setTextSize(1); LCD.println(""); LCD.setTextSize(2); LCD.print("Temp:"); LCD.print(temperatureF); LCD.print((char)247); LCD.println("F"); LCD.display(); delay(1000); } double mapf(double x, double in_min, double in_max, double out_min, double out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } Last edited by NickInMN; 07-09-2018 at 10:47 PM. |
07-11-2018, 08:06 PM | #179 |
Scooby Specialist
Member#: 188132
Join Date: Aug 2008
|
Best location for the E85 sensor...on the return line.
|
07-20-2018, 08:49 AM | #180 |
Scooby Newbie
Member#: 393782
Join Date: Jun 2014
Chapter/Region:
MWSOC
Location: Saint Paul, MN
Vehicle:2004 WRX EWG E85 2006 RPW STi |
I am experiencing an issue with my sensor voltage dropping to 0 during startup. I am in the process of switching over to Accessport from OS and it is causing the eth content to be locked at 10% during the voltage drop @ start. Any ideas on what can be done?
Datalog of condition - https://datazap.me/u/pearson222/log-...data=4-8-16-17 |
07-20-2018, 03:36 PM | #181 | |
Scooby Specialist
Member#: 435142
Join Date: Nov 2015
Chapter/Region:
MWSOC
Location: Commerce Twp, MI
Vehicle:2004 STi Java Black Pearl |
Quote:
Since all of this is custom, and varies person to person, its a hard issue to diagnose. |
|
11-28-2018, 06:34 PM | #182 |
Scooby Newbie
Member#: 408813
Join Date: Dec 2014
|
I would love to make a video on how to do this if I understood the process better
|
12-09-2018, 02:50 PM | #183 |
Scooby Specialist
Member#: 236464
Join Date: Jan 2010
Chapter/Region:
E. Canada
Location: Ontario, Canada!
Vehicle:2005 Forester XT Blue Regal Pearl |
Just to get everything at the same place:
https://www.bmotorsports.com/shop/product_info.php/products_id/2343 The gm sensor connector with pigtail. |
12-11-2018, 06:53 PM | #184 |
Scooby Newbie
Member#: 490539
Join Date: Aug 2018
|
Do we need a different harness to make the Flex Fuel kit work on the SG5 (05 FXT) Forester? On Cobb's website the harness is listed as 3 pin but everything else seemed universal across their different kits.
Thanks to all that have contributed here. Very nice write ups with links etc. Good looking out!! |
12-11-2018, 06:58 PM | #185 | |
Scooby Specialist
Member#: 236464
Join Date: Jan 2010
Chapter/Region:
E. Canada
Location: Ontario, Canada!
Vehicle:2005 Forester XT Blue Regal Pearl |
Quote:
I can't see it being any different. Most of the wires are for power and sending signal. Can't see it being any different. B |
|
12-11-2018, 09:25 PM | #186 | |
Scooby Specialist
Member#: 435142
Join Date: Nov 2015
Chapter/Region:
MWSOC
Location: Commerce Twp, MI
Vehicle:2004 STi Java Black Pearl |
Quote:
Bryce |
|
12-11-2018, 09:28 PM | #187 |
Scooby Newbie
Member#: 490539
Join Date: Aug 2018
|
I thought it would be similar but I was checking to see if someone has done it yet. I figured someone on here may have done the DIY for the FXT. I think the ECU should be the same as I think only the 04 is different.
|
12-13-2018, 08:56 PM | #188 |
Scooby Newbie
Member#: 62941
Join Date: May 2004
Chapter/Region:
MWSOC
Location: @brgperformance
Vehicle:2004 #LesboRacer #TunedbyBarge |
If you're hooking into the TGV you do need to make sure you have the right connector. The later cars have a different connector. i'm not sure when it switched over.
I did my original project stuff on an 04 FXT so that may be a good starting point. All the connectors i used are posted up there somewhere. |
12-16-2018, 12:42 PM | #189 |
Scooby Newbie
Member#: 484081
Join Date: Apr 2018
|
Anyone tried this on a 15+ or knows the fuel connectors
|
12-16-2018, 01:36 PM | #190 | |
Scooby Newbie
Member#: 490539
Join Date: Aug 2018
|
Quote:
|
|
12-16-2018, 02:13 PM | #191 |
Scooby Specialist
Member#: 257231
Join Date: Sep 2010
Chapter/Region:
Tri-State
Location: Hudson Valley, NY
Vehicle:2011 STI ShinjiTuned DGM |
|
12-28-2018, 04:48 PM | #192 |
Scooby Specialist
Member#: 236464
Join Date: Jan 2010
Chapter/Region:
E. Canada
Location: Ontario, Canada!
Vehicle:2005 Forester XT Blue Regal Pearl |
I used this OLED screen:
https://universal-solder.ca/product/...-library-3-5v/ I suggest using the l2c scanner that's linked with the part # above. I get "inf" for the C (degrees) Sucks, but that might change once it's in the car. The text might require some rearranging, but I can't do that until I test it in the car. As it stands, it's 'working' with the computer. Code:
/******************************************************* This program will sample a 50-150hz signal depending on ethanol content, and output a 0-5V signal via PWM. The OLED (for those using an Arduino Nano + OLED) will display ethanol content, hz input, mv output, fuel temp Connect PWM output to TGV. 3.3kOhm resistor works fine. Input pin 8 (PB0) ICP1 on Atmega328 Output pin 3 or 11, defined below ********************************************************/ // include the library code: #include <Adafruit_SSD1306.h> // OLED #include <splash.h> #include <SPI.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // END OF GRAPHIC CALLS // // 'The Wife's Knockers', 104x62px const unsigned char LNClogo [] PROGMEM = { 0x00, 0x00, 0x35, 0x54, 0x20, 0x00, 0x00, 0x00, 0x11, 0x00, 0x2a, 0x55, 0x57, 0x55, 0x60, 0x00, 0x00, 0x0a, 0x91, 0x48, 0x4a, 0xaa, 0xaa, 0xa4, 0x82, 0x09, 0x55, 0x56, 0x95, 0xc0, 0x00, 0x00, 0x6a, 0xa0, 0xa9, 0x20, 0x08, 0x92, 0x92, 0x48, 0x02, 0xaa, 0xab, 0xaa, 0x70, 0x00, 0x00, 0x94, 0x8e, 0x90, 0x0a, 0xa5, 0x24, 0xa4, 0x80, 0x05, 0x55, 0x55, 0xaa, 0xd0, 0x00, 0x01, 0x75, 0x11, 0x20, 0x52, 0x52, 0xa9, 0x15, 0x00, 0x50, 0xaa, 0xaa, 0xca, 0xb8, 0x00, 0x01, 0x49, 0x64, 0xaa, 0x84, 0x94, 0x94, 0xa2, 0x22, 0x82, 0xa5, 0x55, 0xea, 0xbe, 0x00, 0x01, 0xb5, 0x2a, 0x88, 0x52, 0x4a, 0x52, 0x94, 0x08, 0x22, 0x59, 0x55, 0x75, 0x57, 0x00, 0x01, 0x49, 0x48, 0xa1, 0x15, 0x52, 0x95, 0x28, 0x82, 0x89, 0x52, 0xaa, 0xf2, 0xbf, 0x00, 0x06, 0xf2, 0xa5, 0x28, 0x49, 0x14, 0xaa, 0x52, 0x2a, 0xa1, 0x54, 0xab, 0x3d, 0x6b, 0x00, 0x05, 0x8d, 0x29, 0x42, 0x92, 0x55, 0x49, 0x49, 0x24, 0x49, 0x4a, 0xaa, 0xf9, 0x5e, 0x00, 0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0x25, 0x10, 0x2d, 0x55, 0x28, 0xaa, 0x89, 0x55, 0x25, 0x2a, 0xaa, 0xd0, 0x00, 0x4a, 0x00, 0x09, 0x48, 0x15, 0x54, 0xa5, 0x12, 0xa1, 0x55, 0x54, 0x92, 0xab, 0x68, 0x00, 0x24, 0x00, 0x02, 0x91, 0x2d, 0xaa, 0x95, 0x54, 0xa1, 0x55, 0x49, 0x25, 0x56, 0xd0, 0x00, 0x49, 0x00, 0x01, 0x40, 0x0a, 0xaa, 0x52, 0x4a, 0x89, 0x55, 0x54, 0xaa, 0x55, 0xb8, 0x00, 0x12, 0x00, 0x00, 0x9d, 0x76, 0xa9, 0x49, 0x25, 0x20, 0xaa, 0x42, 0x92, 0xab, 0x60, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x85, 0x55, 0x24, 0x92, 0x44, 0xaa, 0xaa, 0x55, 0x55, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x54, 0x95, 0x54, 0x91, 0x55, 0x24, 0x92, 0x55, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xaa, 0x52, 0x22, 0x04, 0x14, 0x89, 0x4a, 0x95, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x52, 0x89, 0x4a, 0xa1, 0x52, 0x52, 0x52, 0xa5, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x55, 0x24, 0x94, 0x88, 0x09, 0x25, 0x4a, 0x55, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xa9, 0x49, 0x25, 0x22, 0xa5, 0x49, 0x29, 0x55, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x54, 0x92, 0x48, 0x88, 0x14, 0x94, 0xa4, 0x92, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x55, 0x24, 0x92, 0x22, 0xa2, 0x45, 0x12, 0xa5, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x92, 0x4a, 0x94, 0x09, 0x28, 0x4a, 0x4a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xa4, 0x91, 0x21, 0x52, 0x92, 0xa4, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x09, 0x24, 0x94, 0x09, 0x24, 0x89, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x52, 0x49, 0x22, 0xa2, 0x49, 0x32, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x24, 0x4a, 0xa8, 0x92, 0x4a, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x24, 0x92, 0x94, 0x92, 0x24, 0x91, 0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x52, 0x4a, 0x52, 0x54, 0x89, 0x24, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xaa, 0x91, 0x55, 0x4a, 0x52, 0x4a, 0xaa, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xaa, 0xa5, 0x25, 0x55, 0x4a, 0x95, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x55, 0x54, 0xa9, 0x25, 0x51, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x55, 0x2a, 0xaa, 0xa9, 0x2a, 0xaa, 0xaa, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x55, 0x4a, 0x95, 0x55, 0x54, 0x95, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x54, 0xaa, 0xaa, 0x4a, 0xaa, 0xaa, 0xaa, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x55, 0x54, 0xa5, 0x52, 0xaa, 0xaa, 0xaa, 0x80, 0x00, 0x00 }; // Here We Go int inpPin = 8; //define input pin to 8 int outPin = 11; //define PWM output, possible pins with LCD and 32khz freq. are 3 and 11 (Nano and Uno) // Define global variables volatile uint16_t revTick; //Ticks per revolution uint16_t pwm_output = 0; //integer for storing PWM value (0-255 value) int HZ; //unsigned 16bit integer for storing HZ input int ethanol = 0; //Store ethanol percentage here float expectedv; //store expected voltage here - range for typical GM sensors is usually 0.5-4.5v int duty; //Duty cycle (0.0-100.0) float period; //Store period time here (eg.0.0025 s) float temperature = 0; //Store fuel temperature here int fahr = 0; int cels = 0; static long highTime = 0; static long lowTime = 0; static long tempPulse; void setupTimer() // setup timer1 { TCCR1A = 0; // normal mode TCCR1B = 132; // (10000100) Falling edge trigger, Timer = CPU Clock/256, noise cancellation on TCCR1C = 0; // normal mode TIMSK1 = 33; // (00100001) Input capture and overflow interupts enabled TCNT1 = 0; // start from 0 } ISR(TIMER1_CAPT_vect) // PULSE DETECTED! (interrupt automatically triggered, not called by main program) { revTick = ICR1; // save duration of last revolution TCNT1 = 0; // restart timer for next revolution } ISR(TIMER1_OVF_vect) // counter overflow/timeout { revTick = 0; // Ticks per second = 0 } void setup() { Serial.begin(9600); // OLED Screen // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Serial.println(F("SSD1306 allocation failed")); for (;;); // Don't proceed, loop forever } display.clearDisplay(); display.drawBitmap(0, 0, LNClogo, 120, 62, WHITE); // Update the display display.display(); delay(2000); // 2 Second Pause display.clearDisplay(); display.display(); // END OLED pinMode(inpPin, INPUT); setPwmFrequency(outPin, 1); //Modify frequency on PWM output setupTimer(); } void loop() { getfueltemp(inpPin); //read fuel temp from input duty cycle if (revTick > 0) // Avoid dividing by zero, sample in the HZ { HZ = 62200 / revTick; // 3456000ticks per minute, 57600 per second } else { HZ = 0; //needs real sensor test to determine correct tickrate } //calculate ethanol percentage if (HZ > 50) // Avoid dividing by zero { ethanol = (HZ - 50); } else { ethanol = 0; } if (ethanol > 99) // Avoid overflow in PWM { ethanol = 99; } expectedv = ((((HZ - 50.0) * 0.01) * 4) + 0.5); //Screen calculations pwm_output = 1.1 * (255 * (expectedv / 5.0)); //calculate output PWM for ECU // OLED Code display.clearDisplay(); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0, 0); display.print("Ethanol: %"); display.setCursor(0, 20); display.print(" Hz C"); display.setCursor(70, 0); display.print(ethanol); display.setCursor(0, 20); display.print(HZ); display.setCursor(40, 20); display.print(temperature); //Use this for celsius display.display(); //PWM output analogWrite(outPin, pwm_output); //write the PWM value to output pin delay(100); //make screen more easily readable by not updating it too often Serial.println(ethanol); Serial.println(pwm_output); Serial.println(expectedv); Serial.println(HZ); Serial.println(temperature); delay(1000); } void getfueltemp(int inpPin) { //read fuel temp from input duty cycle highTime = 0; lowTime = 0; tempPulse = pulseIn(inpPin, HIGH); if (tempPulse > highTime) { highTime = tempPulse; } tempPulse = pulseIn(inpPin, LOW); if (tempPulse > lowTime) { lowTime = tempPulse; } duty = ((100 * (highTime / (double (lowTime + highTime))))); //Calculate duty cycle (integer extra decimal) float T = (float(1.0 / float(HZ))); //Calculate total period time float period = float(100 - duty) * T; //Calculate the active period time (100-duty)*T float temp2 = float(10) * float(period); //Convert ms to whole number temperature = ((40.25 * temp2) - 81.25); //Calculate temperature for display (1ms = -40, 5ms = 80) int cels = int(temperature); cels = cels * 0.1; float fahrtemp = ((temperature * 1.8) + 32); fahr = fahrtemp * 0.1; } void setPwmFrequency(int pin, int divisor) { //This code snippet raises the timers linked to the PWM outputs byte mode; //This way the PWM frequency can be raised or lowered. Prescaler of 1 sets PWM output to 32KHz (pin 3, 11) if (pin == 5 || pin == 6 || pin == 9 || pin == 10) { switch (divisor) { case 1: mode = 0x01; break; case 8: mode = 0x02; break; case 64: mode = 0x03; break; case 256: mode = 0x04; break; case 1024: mode = 0x05; break; default: return; } if (pin == 5 || pin == 6) { TCCR0B = TCCR0B & 0b11111000 | mode; } else { TCCR1B = TCCR1B & 0b11111000 | mode; } } else if (pin == 3 || pin == 11) { switch (divisor) { case 1: mode = 0x01; break; case 8: mode = 0x02; break; case 32: mode = 0x03; break; case 64: mode = 0x04; break; case 128: mode = 0x05; break; case 256: mode = 0x06; break; case 1024: mode = 0x7; break; default: return; } TCCR2B = TCCR2B & 0b11111000 | mode; } } |
01-04-2019, 04:36 PM | #193 | |
Scooby Newbie
Member#: 428541
Join Date: Aug 2015
Chapter/Region:
MWSOC
Location: Tinley Park, IL
Vehicle:2016 STi Base Lapis Blue Pearl |
Quote:
I'll have to add a photo with the 3D printed case I just finished for it yesterday. I have the 4 pins at the back for I2C OLED Screen too. https://photos.app.goo.gl/HvWPBM4sW3q85yES8 |
|
01-05-2019, 02:15 AM | #194 | |
Scooby Newbie
Member#: 428541
Join Date: Aug 2015
Chapter/Region:
MWSOC
Location: Tinley Park, IL
Vehicle:2016 STi Base Lapis Blue Pearl |
Quote:
Try this, worked for me and even blowing through the tube the fuel would go through resulted in temp going up and then back down to room temperature. Code:
/*--------------------------------------------------- * Function: getFuelTemp() * * Description: Calculates fuel temp * * Notes: This can be calculated by looking at the pulse width * of the output signal from the sensor with * 1ms = -40°C (-40F) * 5ms = 125°C (257F) * * Parameter: * In: inpPin - Pin to connected to the signal output of * the ethanol content sensor. * * */ void getFuelTemp(int inpPin) { // Change tempPulse to a static unsigned long // Per arduino reference for pulseIn function // Returns - The length of the pulse (in microseconds) // or 0 if no pulse started before the // timeout (unsigned long) tempPulse = pulseIn(inpPin, LOW); // Changed fahr to a float fahr = map(float(tempPulse), 1000.0, 5000.0, -40.0, 257.0); fahr = constrain(fahr, -40.0, 257.0); } Last edited by goldfingerfif; 01-05-2019 at 02:21 AM. |
|
01-05-2019, 02:39 AM | #195 | |
Scooby Specialist
Member#: 236464
Join Date: Jan 2010
Chapter/Region:
E. Canada
Location: Ontario, Canada!
Vehicle:2005 Forester XT Blue Regal Pearl |
Quote:
|
|
01-05-2019, 04:19 AM | #196 |
Scooby Newbie
Member#: 428541
Join Date: Aug 2015
Chapter/Region:
MWSOC
Location: Tinley Park, IL
Vehicle:2016 STi Base Lapis Blue Pearl |
|
01-05-2019, 11:04 AM | #197 |
*** Banned ***
Member#: 492861
Join Date: Oct 2018
Location: Arizona
Vehicle:18 WRX Stg 2 tuned Silver |
Will this work for MY18 WRX/STI and other cars in general that use the Cobb AccessPort?
I am seriously considering making one vs dropping 600$ for same thing. Also, where can the fuel connectors be bought to make replacement fuel line kit for plug and play like cobbs kit. |
01-05-2019, 11:34 AM | #198 | |
Scooby Specialist
Member#: 236464
Join Date: Jan 2010
Chapter/Region:
E. Canada
Location: Ontario, Canada!
Vehicle:2005 Forester XT Blue Regal Pearl |
Quote:
|
|
01-05-2019, 11:35 AM | #199 |
Scooby Newbie
Member#: 366602
Join Date: Aug 2013
|
I take it nobody has attempted the pwm converter method?
|
01-05-2019, 02:20 PM | #200 |
Scooby Specialist
Member#: 236464
Join Date: Jan 2010
Chapter/Region:
E. Canada
Location: Ontario, Canada!
Vehicle:2005 Forester XT Blue Regal Pearl |
I followed Jeff's original build.
12v from O2, and ground. This powers the flex fuel sensor, too. Proper grounds. My car is two hours away from me, so I really hope this works when I bring it down for testing. |
Thread Tools | |
Display Modes | |
|
|