Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/05/05 17:04
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#98892 - The simplest solution would be...
Responding to: ???'s previous message
Karim said:
Only if it`s daylight or dark. No intensity detection.
The solution from Andy sounds interesting because I have some light resistors left. I want to build it realy simple and cheap.. at only one I/O pin. I will look out for a good schematic.

The simplest solution for your application would be to connect a suited LDR (light dependant resistor) directly from a free Port1 pin (standard 'C51 derivative assumed) to GND. It works!
Due to the special topology of the standard quasi-bidirectional port circuitry, which provides a current feedback resulting in a strong hysteresis when emitting "logical high", resistors can directly be connected to this port pin, without any danger of oscillation!

How does it work?
Assume there's a resistance connected from Port1.x pin to GND. When now setting Port1.x, first a strong internal active pull-up turns-on, which actually is more a current source than a voltage source. For two oscillator periods it tries to drive a strong current into the resistance.
Afterwards, a weak internal active pull-up, which again is a current source actually, tries to drive a smaller current through the resistance. If the resistance does allow it, up to about 200µA (depends on derivative of course) can flow. So, if the resistance is 7.5kOhm, then at Port1.x pin a voltage of 200µA x 7.5kOhm = 1.5V will be observed. If the resistance is 20kOhm, then the voltage at Port1.x pin will be 200µA x 20k = 4V.
If the resistance is higher than about 25kOhm, then the current through it decreases accordingly, because maximum voltage drop can only be 5V (Vcc). So, a resistance of 100kOhm would cause a current of weak internal active pull-up of about 50µA.

This means: When a resistance or more than 7.5kOhm is connected to Port1.x pin, then voltage drop is bigger than 1.5V, means voltage at this port pin is higher than 1.5V. The micro of our example will read this voltage as "logical high".

If the resistance is smaller than about 7.5kOhm, means if the resulting port voltage is less than 1,5V (this actual turn-over voltage also depends on derivative of course) then something interesting happens: Internal port pin read buffer will no longer interpret port voltage as "logical high", but as "logical low". As result the weak internal active pull-up is turned-off and only the remaining very weak internal active pull-up, which is also a current source, stays on. It tries to drive a current of about 10µA (depends on derivative) into the resistance.

The interesting fact is now, that this turn-over implies a strong hysteresis: If in our example a resistance of slightly less than 7.5kOhm is applied, then the voltage suddenly falls from 200µA x 7.5kOhm = 1.5V to 10µA x 7.5kOhm = 0.075V!
To make the internal read buffer interpreting the port voltage as logical "high again", the resistance would have to be increased to 1.5V / 10µA = 150kOhm. This is an enormeous hysteresis!

So, decreasing resistance to less than 7.5kOhm results in "logical low", increasing it to more than 150kOhm results in "logical high", decreasing it to less than 7.5kOhm again results in "logical low", a.s.o.

If you aren't interested in such a huge dead band (7.5kOhm to 150kOhm), means if you only want to detect whether the resistance is smaller or bigger than 7.5kOhm, then just set Port1.x and read this port pin with the next instruction: In this case, always the weak pull-up is turned-on, trying to drive current through the resistance: If the resistance is bigger than 7.5kOhm, then the voltage stays above 1.5V and "logical high" can be read. But if the resistance is smaller than 7.5kOhm, then the voltage drop falls to less than 1.5V and "logical low" can be read.

The only you have to do now, is to find a suited LDR, which provides a resistance change that matches to your micro. In our example an intensity between "daylight" and "dark" should result in 1.5V port voltage, with the weak internal active pull-up (200µA) turned-on.

Well, it's not clear, whether the scheme above will provide you the best and most reliable solution. But as you only need to distinguish between "daylight" and "dark" this simplest solution might be acceptable.

And remember, you asked for the simplest solution...

Kai

List of 33 messages in thread
TopicAuthorDate
Detecting Light with 8051            01/01/70 00:00      
   detecting light            01/01/70 00:00      
      Too specific            01/01/70 00:00      
   have a peek            01/01/70 00:00      
   TAOS inc            01/01/70 00:00      
      simple and cheap            01/01/70 00:00      
         Twilight Switch?            01/01/70 00:00      
         possible schematic            01/01/70 00:00      
            Add            01/01/70 00:00      
               re:add            01/01/70 00:00      
                  NO !            01/01/70 00:00      
                     updated schematic            01/01/70 00:00      
            possible, but not goog            01/01/70 00:00      
               Consensus!            01/01/70 00:00      
                  a comparator with hysteresis constitutes            01/01/70 00:00      
                     Better with            01/01/70 00:00      
                        a 555 ....            01/01/70 00:00      
                           555...            01/01/70 00:00      
         The simplest solution would be...            01/01/70 00:00      
            and...            01/01/70 00:00      
   Try this, It works and it's cheap            01/01/70 00:00      
      how do you know?            01/01/70 00:00      
         OT - you are fully right erik            01/01/70 00:00      
            that is not the issue            01/01/70 00:00      
               What is diddelysquat            01/01/70 00:00      
                  http://wordwebonline.com/en/DIDDLYSQUAT            01/01/70 00:00      
         Because I build it            01/01/70 00:00      
            nobody disputes that, but that does not            01/01/70 00:00      
            re:you built it            01/01/70 00:00      
               and thus Kai states "it's not clear, wh            01/01/70 00:00      
                  re:            01/01/70 00:00      
                     Yes-ish            01/01/70 00:00      
                     Isn't it funny...            01/01/70 00:00      

Back to Subject List