1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

READING A PUSHBUTTON & display on LCD

Discussion in 'Microcontrollers' started by fantabulous68, Sep 9, 2009.

  1. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    I don't think it will vary with the type. The tweaking is needed to get the reflection from the liquid surface exactly into the sensor receiver. I just used a bit of stiff wire that held the sensor then bent the wire a bit so the angle was right and it started reading the surface.
     
  2. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    You see....i did fix the sensor & "tried" to get it as perpendicular as possible.....
    & i used it in that position for the measuring the 3 different liquids....

    & it did read the surface of the liquid BT only for the thick white liquid...and it gave accurate readings whilst i varied the level....

    However when i changed the liquid type....
    to the thick green liquid and later to water( with the sensor in the same position as b4)...
    the readings were inaccurate....

    for water....it was reading the bottom of the glass vessel...
    for the thick green liquid it was a couple cm off....

    I have enough stiff wire around:)ill give it a try
    {my sensor was mounted on a long piece of wood which i kept on the table}
     
    Last edited: Oct 2, 2009
  3. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    6,076
    Likes:
    524
    Location:
    Cleveland, OH, USA
    ONLINE
    That is a possibility, but you have not characterized the problem well enough to say with certainty. That is not a criticism, only a fact.

    First off, from the nature of this and related threads, I gained the impression that the most important aspect of the project was the programming and electronic aspects. The requirements specified in the problem with respect to using IR and reflection did not leave a lot of room for experimentation and change, e.g., using TOF. With respect to the programming, it appears you are almost finished.

    As for the problems you are having with reflection, I suspect you have studied Snell's Law and know that the angle of the light rays relative to the normal will change dependent on the refractive index of the liquid. If not, see here: Mystery of reflection

    In sum, with an IR-opaque material like your white liquid or hard surface, you detect reflection from the surface only and the apparatus works. If the liquid is not opaque, you are getting reflections from other surfaces/interfaces and your measured values vary. If you trace some hypothetical light rays, you will see how your results could vary with different container dimensions and liquid refractive indices. In fact, with a little design and use of a slit, you could probably use your detector to measure refractive index.

    Suggestions:

    1) Talk with the lecturer/professor and describe what you are observing. Find out whether the apparatus is actually supposed to work or whether the programming and electronic part is all you need to get done.

    2) If it must work, then find out whether a "floater" would violate the rules. I mentioned on another forum that I think a plate will work better than ping pong balls.

    3) If it must work, and you cannot use a floater, then play with the geometry. Do some pencil and paper drawings or use one of the programs on the Internet for ray tracing. My guess is that you may be able to get it to function by defining a minimum diameter for the vessel and placing the IR-emitter and detector further apart. That may not be practical because of the unitized construction of your detector. However, you still might be able to use your current detector, if you add some front-surface mirrors. For example, you could bounce the beam obliquely off the liquid surface to get total reflection within a range of reasonable values of refractive index, THEN use one or more front-surface mirror(s) to reflect the beam back to the detector side of the module. As a rough guess, one mirror would be virtually on the opposite side of the small tank and the others would reflect the beam from that mirror to the detector.

    In any event, #3 is clearly the most difficult option and may not be necessary, if the lecturer agrees with #1 or #2.

    John
     
    Last edited: Oct 2, 2009
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0

    Thanks Jpanhalt, The design has to work. I like your idea:
    I got 5 days till exams start.....I will look into this more after & try to implement it......
    Ill find out if I am allowed to use a floater...
     
  6. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    Emailed my lecturer & waiting for a reply
     
    Last edited: Oct 3, 2009
  7. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    6,076
    Likes:
    524
    Location:
    Cleveland, OH, USA
    ONLINE
    In the meantime, you might want to play with the geometry that would be involved to exceed the critical angle with water. It is not going to be that easy, particularly if you want to use relatively small diameter containers.

    Another option is to try the reflection with vodka. The alcohol should absorb IR at 940 nm, thus cutting down secondary reflections. Then, tell the examiners it is just water and prove it by drinking it. :D

    John
     
  8. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    lol very funny....:D The lecturer replied...I'm going to university tomorrow cz he wants to see me in person. Uhmmm & i write on the 7th & 8th THATS this Wednesday & Thursday:eek:...
     
  9. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    6,076
    Likes:
    524
    Location:
    Cleveland, OH, USA
    ONLINE
    I said very early on that I didn't think the problem, as written, has a proven solution. For example, if you took the critical angle approach, the diameter of the container would be on the order of 200 cm to give you that angle at 80 cm with water.

    Frankly, I think with the programming you developed with Atomsoft and The RB, assuming it works as you intend, plus a demonstration with milk or other IR absorbing liquid would be sufficient. If it is not, then I would append a list of known "unknowns" or non-suitable liquids and potential solutions to those problems (such as changing the wavelength of the IR emitter, changing the container diameter, etc.) as have been discussed in you threads.

    It is simply too late to develop those alternatives, and I believe it is far better to present something that works with known limitations than to present something that just doesn't work.

    Good luck, and please let us know the outcome.

    John
     
  10. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    I spoke to my lecturer today:

    in the specifications i had posted...it stated that the project is:
    NON-CONTACT....hence NO FLOATERS ALLOWED...

    He said that the detector should be able to measure AnY TYPE of liquid....&
    i must find a way of TWEAKING it to work with all liquids including transparent liquids....

    He said that the DESIGN comes in when THERE iS a problem & i have to design to solve that problem.

    He said there has to be a solution to reading the surface of the water...& he wants the project to read water...its a basic liquid...& i must get that to work.

    He says water has to have some reflection from the surface of the liquid...& the intensity from the surface will be less than the reflection intensity from the bottom of the container.

    & i should find a way to get the "lesser intensity".....maybe by using a filter.

    He is happy that it works with dense liquids....he said now i must concentrate on getting it to work on water. If it works on water it will work on any transparent liquid.

    How can i overcome the problems i get when i measure the liquid level of water?Any MORE Solutions?

    problems:

    1. detector does not ALWAYS read the surface of water(usually reads the bottom of container)

    2. measurements fluctuate often


    AND how can i implement the tweaking coz the GP2 is constrained by its structural design?


    He said he wants to make it difficult lol because if he doesn't then that would mean im complete...& it is a final year project & it cant be that simple

    I got to be going now....I'm writing my exam tomorrow & Thursday....Going to study more.....
     
    Last edited: Oct 6, 2009
  11. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    6,076
    Likes:
    524
    Location:
    Cleveland, OH, USA
    ONLINE
    Tweaking the electronics will not solve the reflection problem per se.

    Shooting from the hip, consider these options:

    1) Differentiate bottom reflection from top reflection by the time difference. That gets back to a TOF method, and you simple do not have the time or devices to do it. NOT PRACTICAL

    2) Some "filter": 1) The wavelength of the reflected light is not affected by the surface from which it reflects. 2) Could one look at polarization differences with a filter? Reflected light from the liquids is partially polarized relative to incident light.

    Can you in the time remaining determine IR polarization? Do you have a pair of polarized sun glasses to experiment with? You could polarize the IR emitter with a filter and then look only at light where the polarization is rotated. That is, set the receiver filter to block light of the same rotation as the emitter? EDIT: Oops. Foggy thinking. The underlined sentences are wrong. Reflection should polarize the light, not rotate the the plane. So all you need to do is put the filter over the receiver and rotate for maximum signal from the surface. MAYBE

    3) Use a different wavelength -- one that is absorbed. Possible. Might be done with a near IR fluorescent material over the emitter. I don't know off-hand whether such materials are available. Near IR photochemistry was not a subject we studied when I was in school. There would be a lot of work to do to make it work. PROBABLY NOT PRACTICAL

    4) Increase top surface reflection relative to reflection from other interfaces. We have briefly touched on that possibility here. Geometry could be a killer, but the lecturer did not mention that as a restriction. So you might look at a design based on a relatively large, minimum diameter for the container. The critical angle for water is: 48.6°. Therefore, the minimum diameter for 80 cm distance with sensor in the center is = 2X92cm= 184 cm (i.e., 2X80Xtan(48.6)). If it were placed asymmetrically, then the diameter could be smaller. However, you need to exceed the critical angle to get the beam to emerge from the surface. I believe this is an option, but it leads to some possibly implausible constraints on the vessel, will be hard for you to test at home, and will require carefully aligned mirrors and different math in your program. HARD TO GET A WORKABLE MODEL IN THE TIME AVAILABLE

    5) Assume that the unwanted reflections will always give a larger apparent distance (premise). If that is the case, and if your detector gives various sampled values over time, you might choose to write code that would only consider the lowest value in, say, 10 determinations. I am not sure the premise is true, because there are multiple reflection paths. How will you know that the reported set of values includes at least one from the surface? Ripples will kill this method. PREMISE PROBABLY NOT TRUE

    So, I vote for #2 or #4 with #2 being the more elegant, if you have the polarizers and if they pass the near IR that you are using.

    Other ideas? I'm stumped.
    John
     
    Last edited: Oct 7, 2009
  12. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    6,076
    Likes:
    524
    Location:
    Cleveland, OH, USA
    ONLINE
  13. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    Well i never start with my report yet. I am waiting complete my exams. That will be this Thursday. Anything I include in PHASE2 report...is binding....& i will have to demonstrate it in the Final phase3.


    Thanks for taking your time Jpanhalt to provide me with alternative solutions......
    I do not have polarizers...I will have to get them. Its 20:17 at the moment....
    I need to go over a few more things for my exam...will be here often from Thursday
     
    Last edited: Oct 6, 2009
  14. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    6,076
    Likes:
    524
    Location:
    Cleveland, OH, USA
    ONLINE
    There is a chance that polarized sun glasses will work. Otherwise, that link I gave gives some commercial sources. So-called photography gels and some crystals might also work.

    I think it might be the best option and is most consistent with the response you got from the lecturer.

    John
     
  15. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    Thanx...I will look into it
     
  16. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    6,076
    Likes:
    524
    Location:
    Cleveland, OH, USA
    ONLINE
    See edit to post #170, option #2. John
     
  17. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    Have you tried making the bottom of the container CLEAR?? Technically that's non-contact because you are not putting something foreign in the water. The clear plastic bottom of the container when wetted with the water will probably not reflect much IR at all but instead pass it through.

    Also the chance of detecting the bottom of the container is reduced as it nears the end of the range. I was using a 4-30cm range device and with the bottom of the container close to 30 it was much more likely (much easier to find the positioning sweet spot) to detect the water. If you are using a 10-80cm device and the bottom of the container is near 40cm the bottom of the container then the BOTTOM of the container is in it's optimal zone for detection.

    You might also look into using both a 4-30cm sensor and a 10-80, and interpreting both results with the PIC. You could set each sensor up to work in its sweet spot where it detects the water. Or maybe use 2 sensor both 4-30 and mount at different heights.

    Ie if the bottom of the container is 40cm in my tests the 4-30cm sensor always got the surface reflection, ie much better reliability, as the bottom of the container reflection was outside the focal/geometry range of the sensor lens.

    If you are finding it hard to get the reading reliable I think you might be using the 10-80cm sensor with the bottom of the container much closer than 80cm....
     
    Last edited: Oct 7, 2009
  18. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    Well not with the latest code for the detector. I did most of the testing with a glass container....
    Yeah, the bottom is usually 27-37 cm from the sensor

    I will use a longer plastic container and test the detector....
     
  19. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    Just more info on polarizing sunglasses and reflection of light:





     
  20. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    Last edited: Oct 9, 2009
  21. fantabulous68

    fantabulous68 Member

    Joined:
    Feb 20, 2007
    Messages:
    323
    Likes:
    0
    The polarizing glasses don't work..........:(

    I used a bigger container this time as suggested by MR RB and moved the sensor until the LCD measurement reading was = the level of water in the container......

    Then i fixed the sensor at that angle & position & varied the liquid level and took more readings.....

    The sensor does detect the water surface....& the liquid level measurement is right BUT ,thereadings fluctuate quite a bit whilst varying the liquid level even after averaging 4 readings..................



    i know it fluctuates because the water is not still whilst i vary the liquid level...is there a better way to prevent fluctuations ???
     

Share This Page