Numeric value for Photoresistor/LDR value


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2007
    Posts
    18

    Default Numeric value for Photoresistor/LDR value

    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..

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


    Did you find this post helpful? Yes | No

    Default

    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.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Apr 2007
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    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

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tech View Post
    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.

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


    Did you find this post helpful? Yes | No

    Default

    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
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Apr 2007
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    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..

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


    Did you find this post helpful? Yes | No

    Default

    The ADC example will do it.
    If you use 10 bit resolution for the ADCthe value can be 0 to 1024.
    Dave
    Always wear safety glasses while programming.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tech View Post
    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)

  9. #9
    Join Date
    Apr 2007
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    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..

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


    Did you find this post helpful? Yes | No

    Default

    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.

    Code:
    '#####################
    '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
    Dave
    Always wear safety glasses while programming.

  11. #11


    Did you find this post helpful? Yes | No

    Default

    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

  12. #12
    Join Date
    Apr 2007
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by peterdeco1 View Post
    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..

Similar Threads

  1. DT's instant interupts compile problem
    By comwarrior in forum General
    Replies: 4
    Last Post: - 18th October 2009, 19:30
  2. Formating numeric values to text
    By Andre_Pretorius in forum General
    Replies: 2
    Last Post: - 1st August 2009, 08:39
  3. EDTP Ethernet MINI PICBASIC PRO DRIVER
    By edtp in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 1st May 2008, 22:00
  4. Saving numeric data to eeprom from array
    By joseph Degorio in forum Serial
    Replies: 5
    Last Post: - 14th December 2007, 05:18
  5. Numeric Values
    By Armando Herjim in forum General
    Replies: 8
    Last Post: - 28th June 2006, 01:54

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