follow ft86club on our blog, twitter or facebook.
FT86CLUB
Ft86Club
Speed By Design
Register Garage Community Calendar Today's Posts Search

Go Back   Toyota GR86, 86, FR-S and Subaru BRZ Forum & Owners Community - FT86CLUB > Technical Topics > Software Tuning

Software Tuning Discuss all software tuning topics.


User Tag List

Reply
 
Thread Tools Search this Thread
Old 07-29-2016, 04:47 PM   #71
DustinS
Senior Member
 
DustinS's Avatar
 
Join Date: Apr 2014
Drives: 2013 Ultramarine FR-S
Location: Springfield, MO
Posts: 1,948
Thanks: 2,538
Thanked 1,412 Times in 804 Posts
Mentioned: 31 Post(s)
Tagged: 3 Thread(s)
Quote:
Originally Posted by KoolBRZ View Post
Will this work with the OpenFlash Tablet without disabling emissions controls.
Shiv Based his kit off of this. So I assume he is using the same pin, which may not pass emissions.
__________________
DustinS is offline   Reply With Quote
Old 07-29-2016, 07:46 PM   #72
steve99
Banned
 
Join Date: Dec 2013
Drives: FT86
Location: Australia
Posts: 7,998
Thanks: 1,035
Thanked 4,987 Times in 2,981 Posts
Mentioned: 598 Post(s)
Tagged: 2 Thread(s)
Quote:
Originally Posted by KoolBRZ View Post
Will this work with the OpenFlash Tablet without disabling emissions controls.

Im pretty sure the openflash guys are just using ztans flex rom coded A01G rom and flashing that directly into USA 700C to B01C ecus. The ECU hardware is likely same and the A01G roms dont have evap code enabled as we dont have evap system here . So unlikly you will pass emissions in some states depending on tests done as evap will show failed.

I think any auto guy will be out of luck at present as their is no auto flex coded roms although wayno is close on that, but again it will be A01I rom, and its a crap load of work to port code to other roms and test.
steve99 is offline   Reply With Quote
Old 07-29-2016, 09:07 PM   #73
Wayno
Senior Member
 
Wayno's Avatar
 
Join Date: Apr 2014
Drives: Toyota 86 GTS
Location: Australia
Posts: 1,129
Thanks: 453
Thanked 895 Times in 424 Posts
Mentioned: 211 Post(s)
Tagged: 0 Thread(s)
Quote:
Originally Posted by ztan View Post
Having seen the E85 at the station yesterday, I went back home and pored over the wiring diagrams and the car.

The two commonly used sensor inputs are the rear oxygen sensor (O2S2) and the Evap pressure sensor. ECU pins as per diagram below (the wiring manual has the connectors as if you were looking end on at the harness plug - they are mirror-imaged when you look at them plugged in to the ECU.

I had a look at the connector AD2 (which is more accessible than the ECU) which joins the ECU to the fuel pump and Evap cannister harness: the wires were not there for the Evap cannister (A01G ROM). It turns out that I am in luck and the ECU does not interrogate Evap Pressure in my A01G car, so I don't need to compensate for losing the signal.

Moving on to connector A35 on the ECU, pin 20 was empty and I decided to hook a wire up to it. Pulled the connector out - it turns out that I could use the Molex pin from a scrap IDE type ribbon cable on this. To do this, lift the retainer on the IDE plug with a pick and pull the connector out. The A35 connector has a horizontal locking tab in the middle - that needs to be pulled out about 2mm, then the IDE Molex pin slides all the way down the barrel and does not come out when the locking tab is replaced. See last picture for new wire placement.
Lol, i haven't owned any ide cables for years. It looks like a usb or firewire plug though.



Wayno is offline   Reply With Quote
Old 07-29-2016, 09:38 PM   #74
KoolBRZ
Senior Member
 
KoolBRZ's Avatar
 
Join Date: May 2014
Drives: Silver 2013 BRZ Ltd Auto 45,000 mi
Location: Vancouver, WA.USA
Posts: 965
Thanks: 86
Thanked 450 Times in 277 Posts
Mentioned: 60 Post(s)
Tagged: 2 Thread(s)
Garage
Quote:
Originally Posted by steve99 View Post
Im pretty sure the openflash guys are just using ztans flex rom coded A01G rom and flashing that directly into USA 700C to B01C ecus. The ECU hardware is likely same and the A01G roms dont have evap code enabled as we dont have evap system here . So unlikly you will pass emissions in some states depending on tests done as evap will show failed.

I think any auto guy will be out of luck at present as their is no auto flex coded roms although wayno is close on that, but again it will be A01I rom, and its a crap load of work to port code to other roms and test.
I'd be willing to try, but I'd still have to do a lot of hand coding. I'd need to know the right memory addresses, and which code to put where. I'd also have to use the e-brake safety code, since I don't have a clutch, and I want to make sure I could disconnect the code without bricking my ECU.

I'm going to fill with E85 for the first time tomorrow using the OFT ESC E85 tune. Let me know if you want to help me port this to a US A/T rom.

Edit; I'm NOT going to switch to E85 yet. All my local stations closed. I'm not driving 30 miles round trip just to fill up, then constantly worry whether or not I have enough fuel to get back to the station again. Plus, it's in Oregon where I can't pump my own gas.
__________________
If I say yes, will that make you think I understand?

Last edited by KoolBRZ; 07-30-2016 at 03:10 PM. Reason: All closed
KoolBRZ is offline   Reply With Quote
Old 07-29-2016, 09:46 PM   #75
steve99
Banned
 
Join Date: Dec 2013
Drives: FT86
Location: Australia
Posts: 7,998
Thanks: 1,035
Thanked 4,987 Times in 2,981 Posts
Mentioned: 598 Post(s)
Tagged: 2 Thread(s)
Quote:
Originally Posted by Wayno View Post
Lol, i haven't owned any ide cables for years. It looks like a usb or firewire plug though.




if they are no good let me know i think we have some old ide stuff somewhere.
steve99 is offline   Reply With Quote
Old 08-21-2017, 02:13 AM   #76
Wayno
Senior Member
 
Wayno's Avatar
 
Join Date: Apr 2014
Drives: Toyota 86 GTS
Location: Australia
Posts: 1,129
Thanks: 453
Thanked 895 Times in 424 Posts
Mentioned: 211 Post(s)
Tagged: 0 Thread(s)
Anyone who wants a flex tune for any AU/EU/US MY12-MY16 can message me.
Not for free. And do not message me for MY17.
Calibrations:
A01G
A01G as 700G
A01G as A00G
A01G as A02G
A01G as D00G
A01G as F10G
A01G as F20P
A01I
A01I as 700I
A01I as A00I
A01I as A02I
A01I as E00I
A01I as F20Q
A01G as 500C
A01G as 700C
A01G as 900C
A01G as A00C
A01G as A01C
A01G as B00C
A01G as B01C
A01G as D00C
A01G as F00C
A01G as F40C
A01I as 500D
A01I as 700D
A01I as 900D
A01I as A00D
A01I as A01D
A01I as B00D
A01I as B01D
A01I as D00D
A01I as F00D
A01I as F40D
Wayno is offline   Reply With Quote
The Following 2 Users Say Thank You to Wayno For This Useful Post:
Chimera (08-21-2017), Vin (08-21-2017)
Old 07-30-2018, 12:01 PM   #77
mato2sk
Junior Member
 
Join Date: Dec 2017
Drives: Toyota GT86
Location: Slovakia
Posts: 9
Thanks: 0
Thanked 2 Times in 2 Posts
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
I want to share with you about the adaptation of Ztan flex fuel analyzer.
I designed the PCB, and instead of the PLX display, used the small OLED SSD1306, because it is cheaper.
I also added fuel temperature and sensor frequency measurement.
Is not yet connected to Evap pin A35-20, because I have a not modified ROM (01G), as instructed by Ztan.
The voltage at the output is the same as for Ztan.
You can also use Arduino Nano or Uno, and use Ztan wiring diagram, but instead of the PLX display, plug in the A4 and A5 OLED SSD1306.
Wiring Diagram with Eagle software.
https://drive.google.com/file/d/1KJb...ew?usp=sharing
List of parts
C1, C2, C4 = 100nF
C6, C7 = 22pF
C5 = crystal 16mhz
C8, C9 = 330nF
C3 = 10uF
C10 = 100uF
R2, R5 = 3k3
R4, R6, R7 = 1k8
R1 = 10k
R3 = 6k8
T1 = BC547
E_SENSOR = 13577429 flexfuel sensor
Code:
#include <Arduino.h>
#include <Wire.h>
#include <EEPROM.h>
#include <U8glib.h>
U8GLIB_SSD1306_128X64 mujOled(U8G_I2C_OPT_NONE);

uint16_t pwm_output  = 0;      //integer for storing PWM value (0-255 value)
int HZ = 0;                  //unsigned 16bit integer for st
int inpPin = 8;
int V_out_int;
float V_out, V_out_avg, E_scalar;



//Define global variables
volatile uint16_t revTick;    //Ticks per revolutionoring 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
uint16_t voltage = 0;              //store display millivoltage here (0-5000)
//temperature variables
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;
int celstemp = 0;
float fahrtemp = 0;
static long highTime = 0;
static long lowTime = 0;
static long tempPulse;

//EEPROM store
int EE_V_addr = 0;
float V_out_default = 147;
long Elast, Enow, Edelta;

//TRAC switch double click
bool TRAC_buttonMonitor = HIGH;
int debounce = 20;
int doubleClick = 200;
int longClick = 3000;
int TRAC_initializeDelay = 5000;
int TRAC_buttonState = 4; //initialize to 0 for normal operation, 4 for on by default after delay
long TRAC_buttonCounter = 0;

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() {

  pinMode (3, OUTPUT);
  pinMode (10, OUTPUT);
  digitalWrite (10, LOW);
  pinMode (6, INPUT);

  EEPROM.get(EE_V_addr, V_out_avg); //load last V_out_avg
  if (isnan(V_out_avg))
  {
    V_out_avg = V_out_default;
  }
  V_out_int = (int)V_out_avg; //convert to integer for analogWrite
  analogWrite(3, V_out_int); //output V_out as PWM voltage on pin 3
  
  setupTimer();
  Serial.begin(9600);


}

void loop() {
   getfueltemp(inpPin); //read fuel temp from input duty cycle
  
  if (revTick > 0) // Avoid dividing by zero, sample in the HZ
     {HZ = 62700 / revTick;}     // (62200)  3456000ticks per minute, 57600 per second 
      else                        // 62200 calibrated for more accuracy
      {HZ = 0;}                   
  
    //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;}

  

 {
    V_out = 255 - (2.73 * ethanol);
      V_out_avg = V_out_avg + (0.1 * (V_out - V_out_avg)); //V_out_avg as moving average
      V_out_int = (int)V_out_avg; //convert to integer for analogWrite

      analogWrite(3, V_out_int); //output V_out as PWM voltage on pin 3
    }
  

  //Store EEPROM data every 5 minutes

  Enow = millis();
  Edelta = Enow - Elast;
  if (Edelta >= 300000)
  {
    Elast = Enow;
    EEPROM.put(EE_V_addr,  V_out_avg ); //store V_out_avg to EEPROM
  }

 
  

    mujOled.firstPage();
  do {
    mujOled.setFont(u8g_font_helvB08);
    
    //Printing the data on the OLED
mujOled.drawStr(0, 15, "Eth: ");
mujOled.drawStr(0, 30, "Temp: ");
mujOled.drawStr(0, 45, "Freq: ");
mujOled.setPrintPos(72, 15);         //setting the dimensions to print the ethanol
mujOled.print(ethanol, 10);
mujOled.println("%"); 
mujOled.setPrintPos(72, 30);   //setting the dimensions to print the temperature fuel
mujOled.print(cels, 10);     
mujOled.println("C");
mujOled.setPrintPos(72, 45);   //setting the dimensions to print the frequency
mujOled.print(HZ, 10);     
mujOled.println("Hz");

    } 
    while( mujOled.nextPage() );


  
 
    
    delay(250);
}

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)
  celstemp = int(temperature);
  cels = celstemp;
  fahrtemp = ((temperature*1.8)+32);
  fahr = fahrtemp;

//TRAC switch doubleclick

  TRAC_buttonMonitor = digitalRead(6);
  switch (TRAC_buttonState)
  {
    case 0: //inactive

      if (TRAC_buttonMonitor == LOW)  // button pressed
      {
        digitalWrite (10, HIGH); //Transistor on
        TRAC_buttonState = 1; //increment state
      }
      break;

    case 1: //check for release
      if (TRAC_buttonMonitor == HIGH) //if button released
      {
        TRAC_buttonCounter = millis(); //start counter
        TRAC_buttonState = 2; //increment state
      }
      break;

    case 2: //wait for doubleClick
      if (TRAC_buttonMonitor == LOW && (millis() - TRAC_buttonCounter) > debounce && (millis() - TRAC_buttonCounter) < doubleClick) //second click registered
      {
        TRAC_buttonState = 3; //increment state
      }
      else if ((millis() - TRAC_buttonCounter) > doubleClick)
      {
        digitalWrite (10, LOW); //Transistor off
        TRAC_buttonState = 0; //reset state
      }
      break;

    case 3: //doubleClick made
      if ((millis() - TRAC_buttonCounter) > longClick)
      {
        digitalWrite (10, LOW); //Transistor off
        TRAC_buttonState = 0; //reset state
      }
      break;

    case 4: //initialize after delay by default
      if (millis() > TRAC_initializeDelay)
      {
        digitalWrite (10, HIGH); //Transistor on
        TRAC_buttonCounter = millis(); //start counter
        TRAC_buttonState = 3; //set state to doubleClick
      }
      break;
  }
  }








Last edited by mato2sk; 08-01-2018 at 11:37 AM.
mato2sk is offline   Reply With Quote
The Following User Says Thank You to mato2sk For This Useful Post:
steve99 (07-30-2018)
Old 07-30-2018, 08:31 PM   #78
steve99
Banned
 
Join Date: Dec 2013
Drives: FT86
Location: Australia
Posts: 7,998
Thanks: 1,035
Thanked 4,987 Times in 2,981 Posts
Mentioned: 598 Post(s)
Tagged: 2 Thread(s)
Quote:
Originally Posted by mato2sk View Post
I want to share with you about the adaptation of Ztan flex fuel analyzer.
I designed the PCB, and instead of the PLX display, used the small OLED SSD1306, because it is cheaper.
I also added fuel temperature and sensor frequency measurement.
Is not yet connected to Evap pin A35-20, because I have a not modified ROM (01G), as instructed by Ztan.
The voltage at the output is the same as for Ztan.
You can also use Arduino Nano or Uno, and use Ztan wiring diagram, but instead of the PLX display, plug in the A4 and A5 OLED SSD1306.
Wiring Diagram with Eagle software.
https://drive.google.com/file/d/1KJb...ew?usp=sharing
List of parts
C1, C2, C4 = 100nF
C6, C7 = 22pF
C5 = crystal 16mhz
C8, C9 = 330nF
C3 = 10uF
C10 = 100uF
R2, R5 = 3k3
R4, R6, R7 = 1k8
R1 = 10k
R3 = 6k8
T1 = BC547
E_SENSOR = 13577429 flexfuel sensor









Message me if you need modified rom


Nice work :-)
steve99 is offline   Reply With Quote
Old 07-30-2018, 10:17 PM   #79
ZZT86
Senior Member
 
ZZT86's Avatar
 
Join Date: Jul 2012
Drives: BR86
Location: Location
Posts: 841
Thanks: 310
Thanked 146 Times in 114 Posts
Mentioned: 5 Post(s)
Tagged: 0 Thread(s)
Great stuff although I would rather a bigger display = easier to read.
ZZT86 is offline   Reply With Quote
Old 07-31-2018, 11:50 AM   #80
mato2sk
Junior Member
 
Join Date: Dec 2017
Drives: Toyota GT86
Location: Slovakia
Posts: 9
Thanks: 0
Thanked 2 Times in 2 Posts
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quote:
Originally Posted by ZZT86 View Post
Great stuff although I would rather a bigger display = easier to read.
It is also possible to use LCD 20x2, or larger Oled 1.5 ".
I can also change the font size.
mato2sk is offline   Reply With Quote
Old 08-01-2018, 06:00 AM   #81
mato2sk
Junior Member
 
Join Date: Dec 2017
Drives: Toyota GT86
Location: Slovakia
Posts: 9
Thanks: 0
Thanked 2 Times in 2 Posts
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
I changed the font size, and the individual data is rotated every 5 seconds on the OLED display.
Recovery time can be changed
Quote:
delay(3000); // recovery time Oled
Code:
#include <Arduino.h>
#include <Wire.h>
#include <EEPROM.h>
#include <U8glib.h>
U8GLIB_SSD1306_128X64 mujOled(U8G_I2C_OPT_NONE);

int p;

void pageEthanol();     // Page-1
void pageTemp(); // Page-2
void pageFreq();    // Page-3
void (*pages[])() = { pageEthanol, pageTemp, pageFreq } ;

uint16_t pwm_output  = 0;      //integer for storing PWM value (0-255 value)
int HZ = 0;                  //unsigned 16bit integer for st
int inpPin = 8;
int V_out_int;
float V_out, V_out_avg, E_scalar;
long int prepis = 0;


//Define global variables
volatile uint16_t revTick;    //Ticks per revolutionoring 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
//uint16_t voltage = 0;              //store display millivoltage here (0-5000)
//temperature variables
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;
int celstemp = 0;
float fahrtemp = 0;
static long highTime = 0;
static long lowTime = 0;
static long tempPulse;

//EEPROM store
int EE_V_addr = 0;
float V_out_default = 147;
long Elast, Enow, Edelta;

//TRAC switch double click
bool TRAC_buttonMonitor = HIGH;
int debounce = 20;
int doubleClick = 200;
int longClick = 3000;
int TRAC_initializeDelay = 5000;
int TRAC_buttonState = 4; //initialize to 0 for normal operation, 4 for on by default after delay
long TRAC_buttonCounter = 0;

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() {

  pinMode (3, OUTPUT);
  pinMode (10, OUTPUT);
  digitalWrite (10, LOW);
  pinMode (6, INPUT);

  EEPROM.get(EE_V_addr, V_out_avg); //load last V_out_avg
  if (isnan(V_out_avg))
  {
    V_out_avg = V_out_default;
  }
  V_out_int = (int)V_out_avg; //convert to integer for analogWrite
  analogWrite(3, V_out_int); //output V_out as PWM voltage on pin 3
 
  mujOled.setFont(u8g_font_fub25);
  mujOled.setColorIndex(1);
  p = 0;
  setupTimer();
  Serial.begin(9600);

}

void loop() {
   getfueltemp(inpPin); //read fuel temp from input duty cycle
  
  if (revTick > 0) // Avoid dividing by zero, sample in the HZ
     {HZ = 62700 / revTick;}     // (62200)  3456000ticks per minute, 57600 per second 
      else                        // 62200 calibrated for more accuracy
      {HZ = 0;}                   
  
    //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;}

  
    
 {
    V_out = 255 - (2.65 * ethanol);
      V_out_avg = V_out_avg + (0.1 * (V_out - V_out_avg)); //V_out_avg as moving average
      V_out_int = (int)V_out_avg; //convert to integer for analogWrite

      analogWrite(3, V_out_int); //output V_out as PWM voltage on pin 3
    }
  

  //Store EEPROM data every 5 minutes

  Enow = millis();
  Edelta = Enow - Elast;
  if (Edelta >= 300000)
  {
    Elast = Enow;
    EEPROM.put(EE_V_addr,  V_out_avg ); //store V_out_avg to EEPROM
  }

 mujOled.firstPage();
  do {  
    (*pages[p])();
  } while( mujOled.nextPage() );
    delay(3000); // recovery time Oled 
  p = p+1;
  if (p == 3)
    p=0;
}

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)
  celstemp = int(temperature);
  cels = celstemp;
  fahrtemp = ((temperature*1.8)+32);
  fahr = fahrtemp;

//TRAC switch doubleclick
  TRAC_buttonMonitor = digitalRead(6);
  switch (TRAC_buttonState)
  {
    case 0: //inactive

      if (TRAC_buttonMonitor == LOW)  // button pressed
      {
        digitalWrite (10, HIGH); //Transistor on
        TRAC_buttonState = 1; //increment state
      }
      break;

    case 1: //check for release
      if (TRAC_buttonMonitor == HIGH) //if button released
      {
        TRAC_buttonCounter = millis(); //start counter
        TRAC_buttonState = 2; //increment state
      }
      break;

    case 2: //wait for doubleClick
      if (TRAC_buttonMonitor == LOW && (millis() - TRAC_buttonCounter) > debounce && (millis() - TRAC_buttonCounter) < doubleClick) //second click registered
      {
        TRAC_buttonState = 3; //increment state
      }
      else if ((millis() - TRAC_buttonCounter) > doubleClick)
      {
        digitalWrite (10, LOW); //Transistor off
        TRAC_buttonState = 0; //reset state
      }
      break;

    case 3: //doubleClick made
      if ((millis() - TRAC_buttonCounter) > longClick)
      {
        digitalWrite (10, LOW); //Transistor off
        TRAC_buttonState = 0; //reset state
      }
      break;

    case 4: //initialize after delay by default
      if (millis() > TRAC_initializeDelay)
      {
        digitalWrite (10, HIGH); //Transistor on
        TRAC_buttonCounter = millis(); //start counter
        TRAC_buttonState = 3; //set state to doubleClick
      }
      break;
  }
  }
  
void pageEthanol() {
    mujOled.drawStr(0, 28, "Ethanol ");
    mujOled.setPrintPos(32, 64);         //setting the dimensions to print the ethanol
    mujOled.print(ethanol, 10);
    mujOled.println("%");

}
void pageTemp(){
     mujOled.drawStr(10, 28, "Temp: ");
     mujOled.setPrintPos(33, 64);   //setting the dimensions to print the temperature fuel
     mujOled.print(cels, 10);     
     mujOled.println("C");
  
}
void pageFreq() {
 mujOled.drawStr(20, 28, "Freq: ");
mujOled.setPrintPos(12, 64);   //setting the dimensions to print the frequency
mujOled.print(HZ, 10);     
mujOled.println("Hz");

}

Last edited by mato2sk; 08-07-2018 at 06:15 AM.
mato2sk is offline   Reply With Quote
Old 08-01-2018, 01:54 PM   #82
T0rt0r0
Member
 
Join Date: Jun 2017
Drives: European gt86
Location: France
Posts: 92
Thanks: 36
Thanked 23 Times in 14 Posts
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quote:
Originally Posted by mato2sk View Post
I changed the font size, and the individual data is rotated every 5 seconds on the OLED display.
Recovery time can be changed
Code:
#include <Arduino.h>
#include <Wire.h>
#include <EEPROM.h>
#include <U8glib.h>
U8GLIB_SSD1306_128X64 mujOled(U8G_I2C_OPT_NONE);

uint16_t pwm_output  = 0;      //integer for storing PWM value (0-255 value)
int HZ = 0;                  //unsigned 16bit integer for st
int inpPin = 8;
int V_out_int;
float V_out, V_out_avg, E_scalar;



//Define global variables
volatile uint16_t revTick;    //Ticks per revolutionoring 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
uint16_t voltage = 0;              //store display millivoltage here (0-5000)
//temperature variables
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;
int celstemp = 0;
float fahrtemp = 0;
static long highTime = 0;
static long lowTime = 0;
static long tempPulse;

//EEPROM store
int EE_V_addr = 0;
float V_out_default = 147;
long Elast, Enow, Edelta;

//TRAC switch double click
bool TRAC_buttonMonitor = HIGH;
int debounce = 20;
int doubleClick = 200;
int longClick = 3000;
int TRAC_initializeDelay = 5000;
int TRAC_buttonState = 4; //initialize to 0 for normal operation, 4 for on by default after delay
long TRAC_buttonCounter = 0;

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() {

  pinMode (3, OUTPUT);
  pinMode (10, OUTPUT);
  digitalWrite (10, LOW);
  pinMode (6, INPUT);

  EEPROM.get(EE_V_addr, V_out_avg); //load last V_out_avg
  if (isnan(V_out_avg))
  {
    V_out_avg = V_out_default;
  }
  V_out_int = (int)V_out_avg; //convert to integer for analogWrite
  analogWrite(3, V_out_int); //output V_out as PWM voltage on pin 3
  
  setupTimer();
  Serial.begin(9600);

}

void loop() {
   getfueltemp(inpPin); //read fuel temp from input duty cycle
  
  if (revTick > 0) // Avoid dividing by zero, sample in the HZ
     {HZ = 62700 / revTick;}     // (62200)  3456000ticks per minute, 57600 per second 
      else                        // 62200 calibrated for more accuracy
      {HZ = 0;}                   
  
    //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;}

  
    
 {
    V_out = 255 - (2.73 * ethanol);
      V_out_avg = V_out_avg + (0.1 * (V_out - V_out_avg)); //V_out_avg as moving average
      V_out_int = (int)V_out_avg; //convert to integer for analogWrite

      analogWrite(3, V_out_int); //output V_out as PWM voltage on pin 3
    }
  

  //Store EEPROM data every 5 minutes

  Enow = millis();
  Edelta = Enow - Elast;
  if (Edelta >= 300000)
  {
    Elast = Enow;
    EEPROM.put(EE_V_addr,  V_out_avg ); //store V_out_avg to EEPROM
  }

   //Printing the data on the OLED
   mujOled.firstPage();
  do {  
    mujOled.setFont(u8g_font_fub25); 
    mujOled.drawStr(0, 28, "Ethanol ");
    mujOled.setPrintPos(40, 64);         //setting the dimensions to print the ethanol
    mujOled.print(ethanol, 10);
    mujOled.println("%");
     
  } while( mujOled.nextPage() );
  delay(5000); //Data ethanol Recovery Time
  
  mujOled.firstPage();
  do {  
     mujOled.setFont(u8g_font_fub25);
     mujOled.drawStr(10, 28, "Temp: ");
     mujOled.setPrintPos(40, 64);   //setting the dimensions to print the temperature fuel
     mujOled.print(cels, 10);     
     mujOled.println("C");

  } while( mujOled.nextPage() ); 
 delay(5000); //Data temperature Recovery Time


    mujOled.firstPage();
  do {
    mujOled.setFont(u8g_font_fub25);

mujOled.drawStr(20, 28, "Freq: ");
mujOled.setPrintPos(30, 64);   //setting the dimensions to print the frequency
mujOled.print(HZ, 10);     
mujOled.println("Hz");

    } 
    while( mujOled.nextPage() );  
    delay(5000);  // Data freq Recovery Time
}

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)
  celstemp = int(temperature);
  cels = celstemp;
  fahrtemp = ((temperature*1.8)+32);
  fahr = fahrtemp;

//TRAC switch doubleclick

  TRAC_buttonMonitor = digitalRead(6);
  switch (TRAC_buttonState)
  {
    case 0: //inactive

      if (TRAC_buttonMonitor == LOW)  // button pressed
      {
        digitalWrite (10, HIGH); //Transistor on
        TRAC_buttonState = 1; //increment state
      }
      break;

    case 1: //check for release
      if (TRAC_buttonMonitor == HIGH) //if button released
      {
        TRAC_buttonCounter = millis(); //start counter
        TRAC_buttonState = 2; //increment state
      }
      break;

    case 2: //wait for doubleClick
      if (TRAC_buttonMonitor == LOW && (millis() - TRAC_buttonCounter) > debounce && (millis() - TRAC_buttonCounter) < doubleClick) //second click registered
      {
        TRAC_buttonState = 3; //increment state
      }
      else if ((millis() - TRAC_buttonCounter) > doubleClick)
      {
        digitalWrite (10, LOW); //Transistor off
        TRAC_buttonState = 0; //reset state
      }
      break;

    case 3: //doubleClick made
      if ((millis() - TRAC_buttonCounter) > longClick)
      {
        digitalWrite (10, LOW); //Transistor off
        TRAC_buttonState = 0; //reset state
      }
      break;

    case 4: //initialize after delay by default
      if (millis() > TRAC_initializeDelay)
      {
        digitalWrite (10, HIGH); //Transistor on
        TRAC_buttonCounter = millis(); //start counter
        TRAC_buttonState = 3; //set state to doubleClick
      }
      break;
  }
  }
Nice !

You may want to look at this if you wanna plug it to the obd: http://www.ft86club.com/forums/showthread.php?t=123339
(So you can show oil temp, intake temp, etc.)

If you make a plugin using this project I'll be glad to add it to the git hub sources
T0rt0r0 is offline   Reply With Quote
Old 08-03-2018, 01:37 PM   #83
mato2sk
Junior Member
 
Join Date: Dec 2017
Drives: Toyota GT86
Location: Slovakia
Posts: 9
Thanks: 0
Thanked 2 Times in 2 Posts
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
In winter I want to upgrade to a turbo.
I want to integrate other functions in this device (temperature and pressure oil, turbo pressure, etc.)
Or I will build a separate device on the arduino platform.
When I have this device built, I like to share it.
mato2sk is offline   Reply With Quote
Old 08-03-2018, 02:08 PM   #84
Aussie
Member
 
Join Date: Nov 2014
Drives: 2013 Scion FR-S 6MT
Location: South Bay
Posts: 71
Thanks: 23
Thanked 40 Times in 21 Posts
Mentioned: 6 Post(s)
Tagged: 1 Thread(s)
Garage
Quote:
Originally Posted by mato2sk View Post
In winter I want to upgrade to a turbo.
I want to integrate other functions in this device (temperature and pressure oil, turbo pressure, etc.)
Or I will build a separate device on the arduino platform.
When I have this device built, I like to share it.
This is what I did when I went turbo.

http://www.ft86club.com/forums/showt...ht=instruments
Aussie is offline   Reply With Quote
 
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open source Over Boost Fuel Cut ztan Software Tuning 18 07-05-2023 08:30 AM
Open Source Electric Supercharger neutron256 Forced Induction 913 08-22-2021 05:16 PM
open source software question GeeTee86 AFRICA 15 02-15-2015 06:52 PM
The Retrofit Source summer open house! soundman98 Southeast 0 06-23-2014 08:41 PM
ECUtek Flex Fuel REVOLUTION: World's First Flex Fuel Factory ECU GTR - BRZ soon! Visconti Engine, Exhaust, Transmission 356 05-20-2013 09:36 AM


All times are GMT -4. The time now is 04:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
User Alert System provided by Advanced User Tagging v3.3.0 (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.

Garage vBulletin Plugins by Drive Thru Online, Inc.