2
\$\begingroup\$

I have a project where I want to add a flex fuel sensor to a car that doesn't have one. I have the flex fuel sensor installed and wired. My plan is to use an Arduino to read the signal from the sensor and convert the frequency to the ethanol percentage. I purchased an Arduino clone with the ATMega34U4 chip.

This is the documentation on the flex fuel sensor:

The fuel sensor uses a microprocessor to measure the ethanol percentage and fuel temperature, which it uses to produce and output signal. The fuel sensor signal is a square-wave voltage signal. The signal varies in both frequency and pulse width:

The frequency of the signal indicates the ethanol percentage. The output frequency is linear with respect to the percentage of ethanol content in the fuel. The PCM provides an internal pull-up to five volts on the signal circuit, and the fuel sensor pulls the 5 volts to ground in pulses. The normal range of operating frequency is between 50 and 150 Hertz:

50 Hertz indicates 0% ethanol

150 Hertz indicates 100% ethanol

The pulse width indicates the fuel temperature. The normal pulse width is between 1 and 5 milliseconds:

1 millisecond indicates -40°C (-40°F)

5 milliseconds indicates 125°C (257°F)

I know next to nothing about electronics, so what confuses me is the pull-up resistor. I have read about the internal pull-up resistor but the value on that seems too high, according to this (http://nefariousmotorsports.com/forum/index.php?topic=9168.0) the resistor should be 1.2 to 3k whereas the internal is closer to 30k.

So my question is how would I solder the pull-up resistor? I tried soldering one end of the resistor to pin 10 and the other end to the VOUT wire on the flex fuel sensor but that gave inconsistent readings at best. Here is a pinout for a similar product (https://www.sparkfun.com/products/12640. How do I solder this pull-up resistor into this system?

Below is my code. I see mostly zeroes after H: and L:

int inputPinNumber = 10;
double sum = 0;
int count = 0;
unsigned long pulseTime = 0;
int frequency = 0;
unsigned long high = 0;
unsigned long low = 0;

void setup()
{
    Serial.begin(57600);
    pinMode(10, INPUT);
    LCD.init(0x3C);
    LCD.clearDisplay();
    LCD.setTextWrap(false);
    LCD.setTextSize(2);
}

void loop()
{
    high = pulseIn(inputPinNumber, HIGH);
    low = pulseIn(inputPinNumber, LOW);
    pulseTime = high + low;

    LCD.clearDisplay();
    LCD.setCursor(0, 0);
    LCD.print("H: ");
    LCD.println(high);
    LCD.print("L: ");
    LCD.println(low);
    LCD.print("C: ");
    LCD.println(count);
    LCD.display();
    if (pulseTime > 0)
    {
        sum += ((1000000 / pulseTime) - 50);
        count = count++;
    }

    if (count > 50) {
        LCD.clearDisplay();
        frequency = (sum / count);
        Serial.println(frequency);
        LCD.setCursor(0, 0);
        LCD.print(" E");
        LCD.println(frequency);
        LCD.display();
        sum = 0;
        count = 0;
    }
}
\$\endgroup\$
1
  • \$\begingroup\$ My understanding is that pin mode enables the internal pull-up resistor which is about 10 times higher than the recommended resistance value. Again, I don't know enough about electronics to know if that will cause a problem but the documents indicate that would cause a slow rise time (again I don't know if that would be an issue). \$\endgroup\$
    – Nick
    Commented Aug 21, 2017 at 2:38

2 Answers 2

1
\$\begingroup\$

You need to connect the Output from the sensor to pin 10 of the processor board then also connect one end the resistor to the same pin 10.

The other end of the resistor should connect to +5V(VCC), such as pin 4.

It is called a pull-up because it pulls the signal pin up to 5v when the source isn't driving it low.

Some types of signal sources only work in one direction. In this case the sensor can force the signal to ground but does nothing in the other state. It relies upon the pull-up to set the signal level - hence the need for the pull-up resistor.

\$\endgroup\$
3
  • \$\begingroup\$ Thank you for the clear explanation! I will give this a try. One question. By putting from VCC to pin 1 do I have 5 volts at all of the pins? The reason I ask is because eventually I might use one pin as a voltage output to a datalogger. Here is a direct link to the pinout image cdn.sparkfun.com/assets/9/c/3/c/4/523a1765757b7f5c6e8b4567.png \$\endgroup\$
    – Nick
    Commented Aug 21, 2017 at 3:36
  • \$\begingroup\$ I don't understand your questions. Why is pin 1 involved? \$\endgroup\$ Commented Aug 21, 2017 at 3:55
  • \$\begingroup\$ In your answer it says "...then also connect one end the resistor to pin1." Did you mean to type pin10 there? \$\endgroup\$
    – Nick
    Commented Aug 21, 2017 at 12:11
0
\$\begingroup\$

The description of the sensor that you quote indicates, if I read it correctly, that the sensor output has an internal pull-up resistor (inside the sensor), so you should not need to add another pull-up resistor at the Arduino input.

A link to the sensor datasheet would help to clarify things...

\$\endgroup\$
1
  • \$\begingroup\$ I don't, but when the sensor info mentions PCM it is referring to the one of the computer modules in the car, which is where I understand the pull-up to be. \$\endgroup\$
    – Nick
    Commented Aug 21, 2017 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.