PDA

View Full Version : Numeric value for Photoresistor/LDR value



tech
- 24th January 2008, 00:03
Is there a way to get the value of the LDR/Photoresistor which in OHM cahnged it to numeric value.

I knew theres kit set together with a lcd which can find out the numeric value and from there it can be used for the programming.

I dont have that kit set. Is there a way to get those value..example.
Reading of 50kohms on the multimeter - what will the numeric value then..?

anyone could help..

thanks..

mackrackit
- 24th January 2008, 11:36
You could use the POT command, RC TIME, or an ADC.
When the resistance changes the value from either one will change. The resolution the ADC is set at will determine the value given, The capacitor used with POT will determine the value.

tech
- 24th January 2008, 14:36
You could use the POT command, RC TIME, or an ADC.
When the resistance changes the value from either one will change. The resolution the ADC is set at will determine the value given, The capacitor used with POT will determine the value.


I still dont get it.. where do i get the value from?

can send me an example of the programm?
Pm me or send it to [email protected]

thanks

skimask
- 24th January 2008, 14:41
Is there a way to get the value of the LDR/Photoresistor which in OHM cahnged it to numeric value.
I knew theres kit set together with a lcd which can find out the numeric value and from there it can be used for the programming.
I dont have that kit set. Is there a way to get those value..example.
Reading of 50kohms on the multimeter - what will the numeric value then..?
anyone could help..
thanks..

I find the question a bit cryptic...
"Reading of 50kohms on the multimeter - what will the numeric value then..?

50,000 if I read the question right.

Are you trying to determine the resistance of the LDR? The relative amount of light falling on the LDR? The price of a good pizza in Sau Paulo? :) And display those results on an LCD?

Maybe something is getting lost in translation.
Hook us up with a bit more info.

mackrackit
- 24th January 2008, 14:51
If I am understanding correctly, you want to display a number on a LCD corresponding to the resistance measured.

If an ADC is used you would display the value from the ADC channel.

This may help
http://www.rentron.com/PICX2.htm

tech
- 24th January 2008, 15:13
I find the question a bit cryptic...
"Reading of 50kohms on the multimeter - what will the numeric value then..?

50,000 if I read the question right.

Are you trying to determine the resistance of the LDR? The relative amount of light falling on the LDR? The price of a good pizza in Sau Paulo? :) And display those results on an LCD?

Maybe something is getting lost in translation.
Hook us up with a bit more info.

Actually i want to know the reading of resistance of the LDR...

I came across an experimental board with an LCD onboard.
so here it stated with the programm..

pot portb.1,255,v1 'read resistance of cds photocell.

"along the programm it writen display information to the lcd."

so the lcd will give a value example 37 under certain light condition from the LDR.

Hence it can be compared by a value..
example:
the ldr is set to variable V1.

If v1 <= 100 then skp 'compared the value from the LDR with 100.

My question here..if i do not have this experimental board, is there a way to know the actuall reading of the LDR?

pot portb.1,255,v1 -------- does the value 255 will be the maximum. and comparison will be from 0 - 255.?

thanks alot..

mackrackit
- 24th January 2008, 15:21
The ADC example will do it.
If you use 10 bit resolution for the ADCthe value can be 0 to 1024.

skimask
- 24th January 2008, 15:52
Actually i want to know the reading of resistance of the LDR...
....
so the lcd will give a value example 37 under certain light condition from the LDR.
....
My question here..if i do not have this experimental board, is there a way to know the actuall reading of the LDR?
pot portb.1,255,v1 -------- does the value 255 will be the maximum. and comparison will be from 0 - 255.?
thanks alot..

You do realize that this number that you read from the ADC will be a 'relative' number, not an actual resistance value from the LDR, i.e. 10 doesn't mean 10K or 10M or 10 ohms, it just means that 10 is less than 11 and more than 9.
You'll have to do your own math, scaling, etc. and probably end up using a lookup table of some sort to get actual resistance values. (unless you use trial and error, read a load of numbers, plug them all into a spreadsheet and find a non-linear equation that just happens to fit the curve)

tech
- 26th January 2008, 00:54
actually im trying to used pic to switch led at a different light falling to the ldr.

now im connecting portb1 with an ldr(other end of the ldr leg to the portb1 and the other to the ground), portb6 and 7 will be the output led.

v1 var byte

main:
pot portb.1,255,v1

if v1 < 100 then lmp1
if v1 > 100 then lmp2
goto main


lmp1:

high 6
pause 500
low 6
pause 500

return


lmp2:

high 7
pause 500
low 7
pause 500

return

is this the way to programm? or i got a wrong connection on the circuit..
need help..thanks..

mackrackit
- 29th January 2008, 18:10
Do not use high ?. Use PORT?.? instead, works much better.
Here is some code to look at. My LCD is on PORT B so the pins are different than yours but you can get the idea.



'#####################
'16F877A

DEFINE OSC 20

'####################
'LCD SET UP
DEFINE LCD_DREG PORTB
define LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 0
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50

'#####################
V1 VAR BYTE
LED VAR PORTD.2

PAUSE 1000

RUN:
LCDOUT $FE,1,"POT"
LCDOUT $FE,$C0,DEC V1
PAUSE 100
POT PORTC.7,127,V1
IF V1 < 100 THEN
GOTO LMP1
ELSE
GOTO LMP2
ENDIF
GOTO RUN

LMP1:
HIGH LED
GOTO RUN

LMP2:
LOW LED
GOTO RUN

END

peterdeco1
- 29th January 2008, 18:29
Hi Tech. I've used the LDR's in the past but read them with the ADCIN command. I've found ADCIN is easier & more accurate to work with. Also, your "if V1" statements have a slight glitch. If the value is exactly 100, the PIC will do nothing.

v1 var byte
portb = 0 'all off

main:
adcin 0,v1
if v1 < 100 then lmp1
if v1 >= 100 then lmp2 'added if equal to
goto main

lmp1:
high portb.6
pause 500
low portb.6
pause 500
goto main 'return is for GOSUB's
lmp2:
high portb.7
pause 500
low portb.7
pause 500
goto main

tech
- 16th February 2008, 00:54
Hi Tech. I've used the LDR's in the past but read them with the ADCIN command. I've found ADCIN is easier & more accurate to work with. Also, your "if V1" statements have a slight glitch. If the value is exactly 100, the PIC will do nothing.

v1 var byte
portb = 0 'all off

main:
adcin 0,v1
if v1 < 100 then lmp1
if v1 >= 100 then lmp2 'added if equal to
goto main

lmp1:
high portb.6
pause 500
low portb.6
pause 500
goto main 'return is for GOSUB's
lmp2:
high portb.7
pause 500
low portb.7
pause 500
goto main

im using picf16f84a..
Found out ADCIN did not work for pic16f84..