Capacitive fuel level sensor - Unstable output in arduino analog read

Discussion in 'Analog & Mixed-Signal Design' started by saifudeen rizal, Jul 4, 2018.

  1. saifudeen rizal

    Thread Starter Member

    Jun 5, 2018
    36
    2
    Hai.,

    I have used a combination of LM331 and 555 timer circuit to measure the Capacitive value that i get across the sensor ,The output i get from the sensor comes with a variation Difference of around 1.8V (Level 0 to 70)and the Output voltage i am getting is in multimeter is Constant with the variation on fuel level.,

    My issue i am facing is.,

    1)when i connect the output voltage to Arduino(Analog) to read it in serial monitor i am not getting the exact value as i am getting in Multimeter?
    I get a constant value in multi meter where as i don't get that value in the Arduino.,IT shows the wrong voltage and it keeps on oscillating(It even Drops to 0 certain times)
     
    Last edited: Jul 4, 2018
  2. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    8,611
    1,957
    Sounds like a coding error, or an intermittent connection.
     
  3. Sensacell

    Moderator

    Jun 19, 2012
    1,899
    572
    Did you check that the output voltage is DC, not jumping around?
    The ADC input is faster than the meter response, the meter might be lying to you.

    Divide and Conquer:

    Disconnect your sensor, connect a battery to the MCU in place of the sensor, run the code.

    This will tell you where the problem lies.
     
    Last edited: Jul 4, 2018
    saifudeen rizal likes this.
  4. saifudeen rizal

    Thread Starter Member

    Jun 5, 2018
    36
    2

    I jst used the basic example program from the arduino examples .,so that cant be wrong...!
     
  5. saifudeen rizal

    Thread Starter Member

    Jun 5, 2018
    36
    2
    yes.,i have checked the output voltage and that didnt jump around in meter..!

    But At-least The ADC value should be in linear ri8?The value jumps around the difference of 400 bits in serial monitor ..!


    and i dont understand how did u mean that the meter is lying?
     
  6. jpanhalt

    Expert

    Jan 18, 2008
    6,279
    1,166
  7. saifudeen rizal

    Thread Starter Member

    Jun 5, 2018
    36
    2
    hey hai.,

    well it just went to another colleges and i dont know wat was that issue i was facing on cav IC and ri8 now he s also in that state dont know wat was the problem in that.,

    Ya thats purpose made but i That circuit didnt work properly and can u help me build a gud one with That IC.,

    and ya we have changed to other circuit cause we just have to bilud one sensor within this month so jst changed to the other one rather than sitting in that same problem.,..!
     
  8. saifudeen rizal

    Thread Starter Member

    Jun 5, 2018
    36
    2
    Ya u r ri8....!

    now the value comes correctly.,but can u say what would be the problem in my O/P?
    and what may be the reasons that could cause this kind of issues...?
     
  9. ebeowulf17

    Well-Known Member

    Aug 12, 2014
    2,271
    390
    Could you upload a schematic of your "LM331 and 555 timer circuit" so that we can see what you're working with?

    Based on the evidence so far, it sounds like your circuit is putting out high frequency AC of some sort, maybe a pulse train which is essentially PWM? A multimeter in DC mode will read the AVERAGE value of AC voltages, it won't tell you about the rapid, instantaneous changer. So your meter will read the average output, while your Arduino reads a series of wildly varying instantaneous voltages.

    If this is actually what's happening, you can filter, either with hardware or with code, to see average results on the Arduino much like you see on your multimeter.
     
    saifudeen rizal likes this.
  10. saifudeen rizal

    Thread Starter Member

    Jun 5, 2018
    36
    2
    The circuit that i am working with is.,
     
  11. saifudeen rizal

    Thread Starter Member

    Jun 5, 2018
    36
    2
    Thanks for the reply.,
    and i have attached my circuit i am working .,Check that out., and You said "you can filter, either with hardware or with code, to see average results on the Arduino much like you see on your multimeter" can you help me out to filter the output either in harware side or through software?
     
  12. ebeowulf17

    Well-Known Member

    Aug 12, 2014
    2,271
    390
    Hardware would be an RC low pass filter, where you have a resistor in series between 331 output and Arduino input, plus a capacitor from Arduino pin to ground. Values would be chosen based on frequency of 555 pulse train vs. required response time.

    Software would be a matter of taking many, many "raw" ADC readings and averaging them together to get an output reading. This can be done based on a sample count (number of readings) or a sample time (need to refresh output once/second, so simply average however many ADC readings you get per second.) Search for descriptions of over-sampling techniques and you'll find lots of info. Just like with the hardware filter, your choice of averaging methods and sample rate depends on incoming pulse frequency and required response time.

    Having said all that, the above thoughts were very general solutions to one hypothetical problem scenario. I haven't worked through the details of your circuit yet, and I'm not very familiar with 331s, but from what I've found so far, I think maybe the 331 output could be ramping up and down like a sawtooth due to a potential mismatch in timing values.

    The solution might be as simple as tweaking values of existing circuit components to either increase 555 frequencies or increase pulse length and slow down response time of the 331. No time now to do the calculations - still just brainstorming... don't hold me to this!

    I'm traveling this morning, so may be unresponsive for a while.
     
  13. danadak

    Well-Known Member

    Mar 10, 2018
    1,440
    294
    No bypass caps at power pins of 555 and 331 ?
    Recommend .1 uF ceramic and a tant, preferably a polymer tant.

    [​IMG]

    Regards, Dana.
     
    ebeowulf17 likes this.
  14. saifudeen rizal

    Thread Starter Member

    Jun 5, 2018
    36
    2
    Tried and still the value doesnt come constantly and correctly
     
  15. drc_567

    Senior Member

    Dec 29, 2008
    354
    39
    Pin 6 on the lm331 is shown on the design webpage as a threshold value of some sort. ... Your problem might be something to do with that pin.
     
Loading...