FreqMeasure Library - Smooth it out

Status
Not open for further replies.

Dogbone06

Well-known member
Hello fellow Teensy friends,

I just tried the FreqMeasure library, where I have a continental Ethanol sensor hooked up, it pulses from 50 - 150hz, but the average values I get fluctuates allot.
I'm using the example from here: https://www.pjrc.com/teensy/td_libs_FreqMeasure.html haven't changed anything at all from that code. As you may see, it takes 30 samples and averages them out.

test.png

Any ideas?
 
Apparently there are counterfeits of this sensor around. Do you have an indepedent means to check the output frequency
such as a 'scope (some multimeters can do frequency too)?

I believe its 5V output so is not directly safe to use with T4.x for instance.

And which sensor is it exactly? (link please).
 
Apparently there are counterfeits of this sensor around. Do you have an indepedent means to check the output frequency
such as a 'scope (some multimeters can do frequency too)?

I believe its 5V output so is not directly safe to use with T4.x for instance.

And which sensor is it exactly? (link please).

I don’t have a scope I’m afraid.

Interesting! This should be a legit one. I bought it from a Motorsport company in my country. Here it is: https://www.streetpower.se/givare-och-tillbehor/2762-etanol-givare.html

EDIT: Here is what I did today, I skipped the average stuff alltogether to just get the real time HZ from the sensor. Without any filtering code it's fluctuating like crazy. I have IPA (99% Alcohol) in the sensor now, I have also tried with no alcohol, there is a difference so something is happening atleast.
I would say that any value above 200hz can be ignored completely. But it will still not be reliable.

values.png
 
Last edited:
IPA is not the alcohol it is designed for, it is for ethanol, not isopropanol - the clue really is in the name!!

Reading a bit more it seems these sensors actually measure permittivity so its probably not going to work if any moisture
is present (about the highest permittivity of any liquid).
 
That’s not entirely true tho. Ofc I’m going to buy E85 and test with. But Ethanol is alcohol made from Corn or Wheat. An ethanol sensor measures the percentage of alcohol in the fluid given to it. In my case it should show 99% as that’s what IPA is.

We will see what difference I get with E85.
 
Might be interesting to get a look at the actual waveform this sensor creates, ideally using an oscilloscope, but even a logic analyzer which hides analog problems would be interesting.
 
Might be interesting to get a look at the actual waveform this sensor creates, ideally using an oscilloscope, but even a logic analyzer which hides analog problems would be interesting.

I'm going to try E85, I have also ordered a glass E85 tube tester, so that I can see what's going on. I should get myself a logic analyser or oscillioscope, alltho not one of those super expensive ones. Any ideas for a fair priced one? :)

I'd say that these high values are ghost values, this sensor outputs a maximum of 200hz. And I know the Teensy is very aquare after watching you on youtube going to 65mhz.
 
IPA is not the alcohol it is designed for, it is for ethanol, not isopropanol - the clue really is in the name!!
Reading a bit more it seems these sensors actually measure permittivity so its probably not going to work if any moisture
is present (about the highest permittivity of any liquid).
Right, found this page.
Ethanol [C2H5OH] has a relative permittivity of ~25, IsoPropylAlcohol [C3H8O] of ~18.
Interesting to see what the E85 and tube tester will show.

I should get myself a logic analyser or oscillioscope, alltho not one of those super expensive ones. Any ideas for a fair priced one?
Depends on what purpose you see for your scope. Just to get a fair indication of a waveform and its properties or more advanced stuff?
Perhaps check out this page first, to get an idea on what you want/need and what you want to spend.

Paul
 
Right, found this page.
Ethanol [C2H5OH] has a relative permittivity of ~25, IsoPropylAlcohol [C3H8O] of ~18.
Interesting to see what the E85 and tube tester will show.


Depends on what purpose you see for your scope. Just to get a fair indication of a waveform and its properties or more advanced stuff?
Perhaps check out this page first, to get an idea on what you want/need and what you want to spend.

Paul

Yesterday I got myself a liter of E85 from the pump into a clean bottle. I deal with chemicals on a daily basis so rest asured, this bottle is okay with the E85.

Got a looped hose to and from the sensor with E85 filled up. These are the readings I get. I took the code straight out of Speeduino, the logic is pretty simple.
Most likely the E85 I got is E71, that's not at all unusual, specially now when it's getting colder. But the other two values is obviously an issue.

Any ideas?

eth.png

Code:
  if (FreqMeasure.available()) {
      float HZ = FreqMeasure.countToFrequency(FreqMeasure.read());

      // SPEEDUINO CODE START
      if (HZ < 50) {
        ethanol = 0; //Standard GM Continental sensor reads from 50Hz (0 ethanol) to 150Hz (Pure ethanol). Subtracting 50 from the frequency therefore gives the ethanol percentage.
        HZ = 0;
      } else
      if (HZ > 151) { //1 pulse buffer
        if (HZ < 169) {
          ethanol = 100;
          HZ = 0;
        } else {
          //This indicates an error condition. Spec of the sensor is that errors are above 170Hz)
          ethanol = 0;
          HZ = 0;
        }
      } else {
        ethanol = HZ - 50; //Standard GM Continental sensor reads from 50Hz (0 ethanol) to 150Hz (Pure ethanol). Subtracting 50 from the frequency therefore gives the ethanol percentage.
      }

      //Off by 1 error check
      //if (ethanol == 1) { ethanol = 0; }

      Serial.println(ethanol);
      // SPEEDUINO CODE END
  }
 
Could it be that the amplitude of the output signal of the sensor is just too low such that Teensy is missing pulses?
By the way, which Teensy model are you using?
And did you perhaps receive the glass E85 tube tester?

Paul
 
No, according to the flex fuel sensor PDF. Using a 1.2k resistor is perfect for 3.3V. So that’s not a problem.
 
Ah OK, the sensor has an open-collector output. So you used a pullup resistor of 1K2 to 3V3?

Paul
 
Allright.
On the 0, 9 & 10 values you see: is the sensor 100% filled with E85 fuel? I mean no airbubbles?
 
With E85 that I got from the gaspump, I see 0, 10, 11 and 71. The 71 value is most likely correct. There is a little air in the hose but I’m turning the sensor to make sure that the bubble is in the other side of the hose. I also have the hose twisted sort of upwards and the sensor is standing in the table. Hose is stiff and 46 degrees in the air. This makes the little bubble stay there. I have tried turning the sensor in all kinds of directions while looking at the screen. I see no change in the behavior.
 
I'm afraid it's now time to connect an oscilloscope to the sensor output to see what's going on...
 
Time to buy one I guess. It’s also a nice tool to have to check what’s going on. I don’t know much about them, I know what they do roughly but not much about functions.

Any ideas what a good one could be? Checking waveforms and HIGH/LOW state is the basics id need it for atleast.
 
But Ethanol is alcohol made from Corn or Wheat. An ethanol sensor measures the percentage of alcohol in the fluid given to it. In my case it should show 99% as that’s what IPA is.
I'm pretty sure the sensor measures permittivity, not alcohol content directly - in other words its using permittivity as a
proxy for ethanol content. Since petrol is non-polar it has a low and predictable permittivity, but anything with an OH group
(very polar) will have higher permittivity (water especially as it entirely OH groups). The ratio of the permittivities
of ethanol to isopropanol will give a guess at the conversion factor, but any moisture is going to be a major confounding
factor due to its very high permittivity.

ethanol : 24.5
isopropanol: 17.9
water: 80.1
gasoline: 2.0

I reckon 100% (dry) isopropanol will read as 75% ethanol given those figures.

(ethanol also comes from barley BTW, notably in Scottish distilleries :)
 
Interesting data indeed. Unfortunately I haven’t gotten the sensor to stop being so volatile.

In Sweden, we have an energy and pollution sticker on each pump. Ethanol here is made from Wheat or ”Vete” in Swedish. I think the Americans make it from Corn.
 
Status
Not open for further replies.
Back
Top