LDR sensitivity


Closed Thread
Results 1 to 4 of 4

Thread: LDR sensitivity

  1. #1
    Join Date
    Apr 2007
    Posts
    12

    Default LDR sensitivity

    i' using the following code to read 2 LDRs' and change the direction of a small robot. The code is based on the tutorial: http://www.rentron.com/Micro-Bot/CDS.htm


    Code:
    eyes:
    
    gosub check_LDR ' get LDR RC values
    
    select case light_state
    
    case 1
    
        IF LDR_Right_Val > LDR_Left_Val THEN	   'if right brighter than left  	 		
    			
    				if panic_flag = 1 then		   'is it in hide mode?
    				    eyes_output = right  	   'yes - right
    				else
    					eyes_output = left 		   'no - left
    				end if		
    	  	 'ENDIF
       else
     	 	 light_state = 2		  			   'goto next state
       end if
     
    case 2 
    
       if LDR_Left_Val > LDR_Right_Val THEN	   	   'if left brighter than right
    		 
    				if panic_flag = 1 then		   'is it in hide mode?
    				    eyes_output = left         'Yes - left
    				else
    					eyes_output = right        'No - right
    				end if		
       else
     	 	 light_state = 3		  			   'goto next state
       end if
     
     case 3
     	   	 light_state = 1					   'goto the first state
    		 eyes_output = idle	 				   'idle
    end select
      
    return	  			   						   'return to start
    
    
    
    
    
    
    check_LDR:
    
      HIGH portb.6 'Right_LDR               	  'Make right CDS pin high
      PAUSE 3                      	 	  		  ' Let cap charge
      RCTIME portb.6, 1, LDR_Right_RCdata 		  ' Time & record discharge time 
    
    
      HIGH portb.7 'Left_LDR                	  'Make left CDS pin high
      PAUSE 3                      				  ' Let cap charge
      RCTIME portb.7, 1, LDR_Left_RCdata   		  ' Time & record discharge time
    
    
    LDR_Right_Val = NCD LDR_right_RCdata
    LDR_Left_Val =  NCD LDR_left_RCdata
    
    return

    i'm using a 220ohm resistor, with 0.1uF caps. The LDRs rated 27k - 94k.


    The code works in that if one LDR is covered the the robot turns as required.

    However In ambient light it doesnt find the brightest source of light.

    Can anyone help with sugestions to improve the sensitivity..


    any help is greatly apriciated


    thanks

    jim

  2. #2
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    Good site www.rentron.com, I managed to learn a lot from there a few years back. Your code looks quite different from the example shown. As for it searching for the brightest source of light under ambient conditions, I think you're expecting just a bit too much from it. LDR's don't really respond to minor variations in light. But not only that, there's not enough goods in the project to make it go searching to begin with. The brightest area of a room might be on the left hand side - while the robot is stuck on the right hand side in a World full of unchanging light levels.
    Last edited by T.Jackson; - 9th May 2007 at 16:05.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    At the rentron site, read on to the next section. Uses IR to help with navigation. Even IRs will give trouble in bright light.

    You might try lasers, pulse at a high frequency and the receiving circuit set to only respond when the magic frequency is seen.

    FREQOUT and COUNT

    You could also try shielding the LDRs with a tube of some sort so light can only come from one direction. I tried something like this on a solar tracker. Used a cigar tube. At least the cigar was good.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Apr 2007
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    thanks for the replies

    i think i will try to create some kind of shielding


    cheers

    jim

Similar Threads

  1. Newbie with photoresistor problem
    By Karthik in forum Off Topic
    Replies: 10
    Last Post: - 26th March 2015, 19:53
  2. 12F629 LDR - Light Dependant Resistor
    By Dennis in forum Schematics
    Replies: 15
    Last Post: - 18th February 2010, 22:33
  3. LDR to 16F877A
    By azmax100 in forum Schematics
    Replies: 4
    Last Post: - 2nd May 2009, 06:06
  4. POT with LDR
    By stu746 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th March 2005, 18:37

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts