IR detector


Closed Thread
Results 1 to 29 of 29

Thread: IR detector

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    You could use a 5.1v zenner diode to reduce the 9v down to 5v, but a small 5v regulator should be a better bet.

  2. #2
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    I guess this is where I get confused with electronics.
    I can take a 9V battery and use a resistor to run a 1.5V led without problem but I can't use a resistor the same way to run a 5V chip.

    This seems to make sense to everyone but me lol

    Ok on to the coding would this chip be able to handle the timer part of this or would I need a dedicated timer chip?

    My guess is that there will be about 100 breaks in the beam in a 30 second time.

    Currently I'm testing with this code and a led on RB1.
    Main:
    if PORTB.0 = 1 then
    high PORTB.1
    else
    low PORTB.1
    endif


    Now that looks like it will work fine but, if the loop happens more than once before the bean is brought back it could count 10 times for every break...

    Would this code work and only count once?

    broken var byte
    broken = 0
    Main:
    if PORTB.0 = 1 and broken = 0 then
    broken = 1
    high PORTB.1
    else
    low PORTB.1
    endif
    if PORTB.0 = 0 and broken = 1 then broken = 0

    goto Main
    Last edited by geckogrotto; - 16th August 2006 at 18:32.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi geckogrotto. Try something like this.
    START:
    LET BROKEN = 0
    LOW PORTB.1

    Main:
    IF PORTB.0 = 1 then ACTIVATE 'BEAM BROKEN
    GOTO MAIN 'BEAM NOT BROKEN

    ACTIVATE:
    IF PORTB.0 = 1 THEN ACTIVATE 'WAIT FOR BEAM TO RETURN
    LET BROKEN = BROKEN + 1
    IF BROKEN >= 10 THEN LIGHTUP 'BEAM NEEDS TO BE BROKEN 10 TIMES
    GOTO MAIN

    LIGHTUP:
    HIGH PORTB.1
    GOTO LIGHTUP

  4. #4
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Thanks for your suggestion.

    Can anyone tell me how to turn on a timer then turn it off and get the amount of time that was timed?

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Voltage divider

    Hi, yes you can reduce the voltage to any set level you choose.
    Using Ohm's Law
    V. out = V in X (r2 / r1 + r2)

    where r1 is the resistor closest to the power in
    and r2 is the resistor closest to ground

    Example v out = v in or 10 volts X r2, say 500 ohms . . . 5000
    divided by r2 + r1, so if r1= 500 ohms you would get 1000 ohms,
    so 5000 / 1000 = 5 volts. Simple huh? The problem here is if you lose the ground
    foe even an instant then your input sees full supply voltage, also a voltage divider uses power all the time, in this example .01 amp.
    OK the attachment didn't work so basicly two resistors in series, one end attached to + and the otherend to minus and you pull power from the connection in the center.
    Last edited by Archangel; - 16th August 2006 at 20:21. Reason: TRy to add BMP of schematic

  6. #6
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S.
    Hi, yes you can reduce the voltage to any set level you choose.
    Using Ohm's Law
    V. out = V in X (r2 / r1 + r2)

    where r1 is the resistor closest to the power in
    and r2 is the resistor closest to ground

    Example v out = v in or 10 volts X r2, say 500 ohms . . . 5000
    divided by r2 + r1, so if r1= 500 ohms you would get 1000 ohms,
    so 5000 / 1000 = 5 volts. Simple huh? The problem here is if you lose the ground
    foe even an instant then your input sees full supply voltage, also a voltage divider uses power all the time, in this example .01 amp.
    OK the attachment didn't work so basicly two resistors in series, one end attached to + and the otherend to minus and you pull power from the connection in the center.
    Ok I don't think these actually exist but lets say they do.

    If I had exactly 9V in and used
    R2 950
    R1 760
    That would give me exactly 5V out?

    About the connection what your saying is resistor to + and the other resistor connected to that and then to the negative and sandwiched in between the 2 would be my output of 5v?

    Also if you want shoot me over the attachment to [email protected]

    Thanks

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Yes

    That is correct as would 400/500 (notice it adds up to 900) or any variant of above say 1200 /1500 12k/15k what changes as you go upscale is the circuit impeadance (the ability to load the circuit without significant loss of voltage).
    If you only want to drive a PIC input pin and not light leds or run motors then use the larger (higher resistance) resistors, that way if you mess up your code and cause an input to become an output, set to low, you will not create a big short.

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. PIC10F200 Automated IR Light Switch
    By Bruce in forum Code Examples
    Replies: 7
    Last Post: - 3rd May 2007, 11:40
  3. Replies: 10
    Last Post: - 16th October 2006, 18:23
  4. how to get pic to pic communication
    By kinsiro in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th August 2005, 17:12
  5. IR for robot on 16F877A
    By Samuel in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 9th April 2005, 20:57

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