Humidity sensor interfaced with 8051

Discussion in 'The Projects Forum' started by Mahdieh, May 26, 2015.

  1. Mahdieh

    Thread Starter New Member

    May 26, 2015
    7
    0
    I am interfacing an 8051 (AT89C5131A-M) with a humidity sensor (htf3226lf) which has a linear frequency output. Can someone please write a code (in embedded C) to display the humidity on the LCD display? It would be very helpful. I know what to do ( I think it involves interrupts).. I just don't know how to...
    The relation between humidity(%, RH) and output frequency of the sensor is:
    [9595 - Fout(Hz)]/14.8= RH
    PS: This is just a small part of my project and I have no experience in embedded C (just a first year).
    PPS: I am using Keil
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    I don't think you have provided anywhere near enough information for us to help you. For starters we need a schematic and some links to datasheets for the various parts of the project. If this is a project you intend to summit for academic credit, then you're not likely to find anybody willing to do the work for you so you can claim the credit. In some quarters that might be considered cheating.

    My personal preference would be for you to try to solve your problem in a series of steps, show us what you have, and let us guide you in the right direction. It will be harder for you and it will take longer, but you will derive more benefit from doing it this way.

    Divide et impera!
     
  3. Mahdieh

    Thread Starter New Member

    May 26, 2015
    7
    0
  4. Mahdieh

    Thread Starter New Member

    May 26, 2015
    7
    0
    On second thoughts.. never mind.. clearly we are just going to go back and forth here with no results. I'll just put this project on hold until maybe second year. And as I said, I know what to do.. I have a vague idea.. just implementation is not in my scope right now..

    This was my first post here as a member... just a first year engineering student asking for a piece of code because of my time limit here
     
    Last edited: May 26, 2015
  5. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,771
    971
    Google.. "8051 humidity lcd".. done
    Code/schematic/videos all right there.. Learning how to use Google properly is better than anything any educational institute could teach you. :)
     
  6. Mahdieh

    Thread Starter New Member

    May 26, 2015
    7
    0
    I have already done that.. and I already finished making it too.. its just the coding!
    All the codes online are for sensors with analog outputs(95%). This sensor has a "linear frequency output" and hence the code for it will include timers and interrupts
     
  7. Mahdieh

    Thread Starter New Member

    May 26, 2015
    7
    0
    Its okay.. if I had the choice I would have deleted this thread.. because its really getting me nowhere. And obviously I have googled everything I could. The problem is, sensors with frequency outputs are hardly ever used..so yeah..you know my problem.
    And "interrupts and timers" are my main problem here.
    The answers have made me feel nothing but like an internet noob. Clearly this not the place for me..at-least not right now
     
  8. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,771
    971
    Typically people on internet forums will not just spend their time on a new users who comes in with sparse details and that "write all the code for me" attitude..
    This is a great forum though so don't run away yet..
    Through your other posts you have provided more information and narrowed the scope quite a bit...
    Now its just the small portion dealing with the handling the sensor instead of us thinking you wanted everything from start to finish...

    This question is out of my scope (Keil/8051/freq to whatever) but others may come along and offer help now that more details are out in the open..
    Post that schematic...post the code you have and see if you get lucky.. But without those details you don't have a chance :)
     
  9. Mahdieh

    Thread Starter New Member

    May 26, 2015
    7
    0
    Okay I will try, but based on the question provided and the answers that I have gotten so far I don't feel that optimistic :(
    As far as the schematic goes, its similar to the gif image I have uploaded (credits: EngineersGarage).
    Mine is similar but only without the ADC interfacing. I cannot upload my own schematic right now because its kind of private and I kinda want to keep it that way. But I will be happy to answer questions regarding it..
    My reference code is again from the same website:
    http://www.engineersgarage.com/microcontroller/8051projects/interface-humidity-sensor-circuit
    The problem is their code is only for registered users and I don't think its in my position to post it on a public forum...

    So far till now, the datasheets of the microcontroller used and the sensor have been uploaded and a similar schematic along with a reference code that needs to be slightly edited. I think this is enough for starting..
     
  10. Mahdieh

    Thread Starter New Member

    May 26, 2015
    7
    0
    The code needs to be modified in such a manner that instead of converting the analog output into digital, we have to convert the output frequency(digital) into percentage relative humidity (I have already mentioned the formula in the question) and this part includes timers and interrupts. So atleast if someone could tell me how to go about that modification I would be really happy!

    PS: The crystal frequency is 24Mhz in my case
     
    Last edited: May 26, 2015
  11. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    If I understand what you need correctly, you can eliminate the A/D converter since it serves no useful purpose. Then you can take the digital output of the sensor and measure the period of the output. Since the period is the reciprocal of frequency you can use a table lookup to get the frequency and then just substitute into your formula. Many microcontrollers have what is known as an input capture module which is designed specifically for measuring the period of a waveform. Sorry about your time crunch, but I don't have a Kiel Compiler so I can't help you there.
     
  12. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,394
    497
    lol
     
Loading...