Notices
E85 / Ethanol This section is dedicated to tuning with ethanol.

E85 Gauge w/ output for under $100

Thread Tools
 
Search this Thread
 
Old Oct 29, 2016, 07:40 AM
  #1  
Evolving Member
Thread Starter
 
mrb00st's Avatar
 
Join Date: Jan 2008
Location: Ohio
Posts: 122
Received 15 Likes on 6 Posts
E85 Gauge w/ output for under $100

**First things first. I would like to thank Ant_Turbo for all the help with working some of the bugs out to make it easier on everyone when building this little project**

Things you’ll need
- Arduino Uno Here
- (optional) Arduino l2c LCD Screen Here
- 4.7k ohm resistor $1
- 3.3k ohm resistor $1
- USB Car Charger (5v 1amp) $1-$5
- Dorman 800-082 3/8” quick fuel connects
- Flex Fuel Sensor
Here Here
Pigtail
Here Here

**Library's needed to program the code**
LCD library Drop these into your arduino library. make sure arduino is not open when you do!


Evoscan
Adding request 83 with (5/256)*(x) will display voltage giving the ability to have automatic map switching


Wiring Credit to @ant_turbo for the pic! thanks!


Here is where i mounted my LCD. Had to trim slightly to get it to fit, but im very happy with it.





Code

/************************************************** *****
This program will sample a 50-150hz signal depending on ethanol
content, and output a 0-5V signal via PWM.
The LCD will display ethanol content, hz input, mv output, fuel temp
************************************************** ******/

// include the library code:
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27 // <<- Add your address here.
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(0x27,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin ,D7_pin);

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 (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
uint16_t voltage = 0; //Store display millivoltage here (0-5000)
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);
pinMode(inpPin,INPUT);
setPwmFrequency(outPin,1); //Modify frequency on PWM output
setupTimer();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);
// Initial screen formatting
lcd.setCursor(1, 0);
lcd.print("Ethanol: %");
lcd.setCursor(0, 1);
lcd.print(" Hz F");
}

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.11 * (255 * (expectedv/5.0)); //calculate output PWM for NEMU

lcd.setCursor(12, 0);
lcd.print(ethanol);

lcd.setCursor(2, 1);
lcd.print(HZ);

lcd.setCursor(12, 1);
lcd.print(fahr); //Use this for celsius

//PWM output
analogWrite(outPin, pwm_output); //write the PWM value to output pin

delay(1000); //make screen more easily readable by not updating it too often

Serial.println(ethanol);
Serial.println(pwm_output);
Serial.println(expectedv);
Serial.println(HZ);
delay(1000);


}

void getfueltemp(int inpPin) { //read fuel temp

tempPulse = pulseIn(inpPin, LOW, 25000); // Measure the low pulse time (timeout after 25ms if no pulse is detected)
if (tempPulse > 0) { // If we get a pulse then update the temperature measurement
lowTime = tempPulse;
float celsius = ((41.25 * (float(lowTime) / 1000)) - 81.25); // Calculate temp in celsius from lowTime pulse
float fahrenheit = ((celsius * 1.8) + 32); // Convert to fahrenheit
temperature = fahrenheit; // Update temperature with specified unit
}
}

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;
}
}



I have modified my own code for a lcd screen output. If you would like the code to have a 16x2 display, please let me know.

Originally Posted by ant_turbo
Ok tested and working 100% thanks,, mrb00st,, My problem was 1st I had the wrong libraries,, NOTE,,, My second problem was when testing and plugged in the laptop via USB to power the ARDUINO up u have to ground the arduino I DID NO KNOW THAT,,, I had it all set up on in my garage and hooked up to my spare car battery and set the FF sensor in a small container of E85 and some E85/98 MIX just to make sure it was working properly
So remember to ground the arduino when testing with the laptop via the USB.
To do that all I did was used my circuit tester clipped to the battery negative and just touched the metal top part where the USB plugs into the arduino,,
To test and make sure everything is running and your getting the correct readings or if you have to LCD hooked up to the arduino,, When you have everything hooked up open the arduino software and go to tools then serial monitor and a window will pop up and it will start to show readings,, it will show 4 readings ,
In order and keep repeating,,
1.pulse width modulated
2.Voltage
3.Hz
4.E85 content
VIDEO LINK
https://www.youtube.com/watch?v=DKKIKcE7abw

Last edited by mrb00st; Jul 21, 2018 at 09:22 AM.
The following 10 users liked this post by mrb00st:
deylag (Jan 11, 2017), dr_latino999 (Oct 29, 2016), evo8tanner (Nov 27, 2016), hokiruu (May 8, 2017), huzzle101 (Dec 20, 2018), lancerrally45 (Nov 3, 2016), N1MR0D (Jul 5, 2017), SoSoEVO (Oct 30, 2018), wizzo 8 (Jan 29, 2017), _des_ (Nov 13, 2016) and 5 others liked this post. (Show less...)
Old Oct 29, 2016, 05:04 PM
  #2  
EvoM Guru
iTrader: (7)
 
CDrinkH2O's Avatar
 
Join Date: Nov 2006
Location: San Francisco
Posts: 1,142
Received 152 Likes on 116 Posts
Thanks for you contribution. Can you post a picture of the finished project so we can see how you packaged the Arduino and LCD display?
Old Nov 1, 2016, 07:44 AM
  #3  
Evolving Member
Thread Starter
 
mrb00st's Avatar
 
Join Date: Jan 2008
Location: Ohio
Posts: 122
Received 15 Likes on 6 Posts
*updated
Old Nov 3, 2016, 12:11 PM
  #4  
Evolved Member
iTrader: (22)
 
lancerrally45's Avatar
 
Join Date: Apr 2007
Location: MI
Posts: 1,044
Received 21 Likes on 20 Posts
Dang, I love you people.
What are the chances we could find a 52mm gauge for the output?
Old Nov 3, 2016, 12:40 PM
  #5  
Evolving Member
Thread Starter
 
mrb00st's Avatar
 
Join Date: Jan 2008
Location: Ohio
Posts: 122
Received 15 Likes on 6 Posts
you could. could use a 1.5" rbg screen and put it in a gauge. Which was honestly what i was going to work on next
The following users liked this post:
lancerrally45 (Nov 4, 2016)
Old Nov 3, 2016, 02:27 PM
  #6  
Evolved Member
iTrader: (41)
 
heel2toe's Avatar
 
Join Date: Jul 2007
Location: Massachusetts
Posts: 4,690
Received 126 Likes on 121 Posts
That's friggin sweet, well done! Might have to give this a shot at some point. But of course until I go with a true flex fuel setup Im still testing my fuel prior. Still a slick gauge love the DIY aspect and the cleanliness of it all.
Old Nov 3, 2016, 05:20 PM
  #7  
Evolved Member
iTrader: (18)
 
Klaiceps's Avatar
 
Join Date: Nov 2014
Location: Honolulu, HI
Posts: 508
Received 28 Likes on 28 Posts
Awesome job!
Old Nov 4, 2016, 06:26 AM
  #8  
Evolved Member
iTrader: (22)
 
lancerrally45's Avatar
 
Join Date: Apr 2007
Location: MI
Posts: 1,044
Received 21 Likes on 20 Posts
Originally Posted by mrb00st
you could. could use a 1.5" rbg screen and put it in a gauge. Which was honestly what i was going to work on next
If you need help, feel free to shoot me a PM.
Old Nov 4, 2016, 07:59 AM
  #9  
Evolved Member
iTrader: (22)
 
lancerrally45's Avatar
 
Join Date: Apr 2007
Location: MI
Posts: 1,044
Received 21 Likes on 20 Posts
Something I found
https://forums.adafruit.com/viewtopic.php?f=47&t=67958
https://forum.arduino.cc/index.php?topic=308808.0

Not sure if it will make someones life easier, haha.
Old Nov 4, 2016, 08:10 AM
  #10  
Evolving Member
Thread Starter
 
mrb00st's Avatar
 
Join Date: Jan 2008
Location: Ohio
Posts: 122
Received 15 Likes on 6 Posts
i came across that last night too. i saw people asking him if he wanted to sell them. but never saw any kind of responce
Old Nov 12, 2016, 08:26 AM
  #11  
Evolving Member
 
butte's Avatar
 
Join Date: Oct 2013
Location: Phoenix, AZ
Posts: 175
Received 8 Likes on 8 Posts
Where along the fuel line did you find it most convenient to put the ethanol sensor?
Old Nov 13, 2016, 05:23 PM
  #12  
EvoM Guru
iTrader: (7)
 
CDrinkH2O's Avatar
 
Join Date: Nov 2006
Location: San Francisco
Posts: 1,142
Received 152 Likes on 116 Posts
I put mine in the return line and mounted it on the firewall. It works perfectly in this position.
The following users liked this post:
butte (Nov 16, 2016)
Old Nov 15, 2016, 01:19 PM
  #13  
Evolved Member
iTrader: (49)
 
06RedRalli's Avatar
 
Join Date: Jul 2007
Location: Killeen,Tx
Posts: 869
Likes: 0
Received 3 Likes on 3 Posts
So where exactly does the pink line go to?

Also, how does the lcd get wired in to the whole scenario?
Old Nov 16, 2016, 12:02 PM
  #14  
Evolving Member
Thread Starter
 
mrb00st's Avatar
 
Join Date: Jan 2008
Location: Ohio
Posts: 122
Received 15 Likes on 6 Posts
Originally Posted by 06RedRalli
So where exactly does the pink line go to?

Also, how does the lcd get wired in to the whole scenario?
it CAN be wired into ADC input for automatic map switching, just depends if you want to use that or not.

the lcd depends on what kind you want you use.
This is the lcd i used, its the easiest to wire. Here
Old Nov 26, 2016, 08:18 PM
  #15  
Newbie
iTrader: (1)
 
evo8tanner's Avatar
 
Join Date: Jul 2013
Location: Long Beach, Ca
Posts: 79
Received 0 Likes on 0 Posts
Wow I have been looking into doing my own content display recently and I'm glad that I stumbled upon this post. Thanks a lot I will be looking into this once I go FF with my aem infinity. Is that flex fuel sensor that you have linked on amazon the same one/place that you purchased yours?


Quick Reply: E85 Gauge w/ output for under $100



All times are GMT -7. The time now is 06:07 AM.