PDA

View Full Version : LDR sensitivity



jimbobjones
- 9th May 2007, 14:50
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





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

T.Jackson
- 9th May 2007, 15:34
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.

mackrackit
- 9th May 2007, 17:28
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.

jimbobjones
- 9th May 2007, 20:51
thanks for the replies

i think i will try to create some kind of shielding


cheers

jim