IR detector


Closed Thread
Results 1 to 29 of 29

Thread: IR detector

Hybrid View

  1. #1


    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

  2. #2
    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?

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

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

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

  6. #6
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Thanks again Joe.

    Now I just need the most basic code I can find to start / stop the timer and get the results and I will be able to finish the rest.

    I searched around the forums but I'm not sure how to implement the code with my chip.

    There are internal timers right that you can turn on or off or am I thinking this whole thing wrong and I need to figure out how fast the chip is running then make my own count loop?

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    one way in my mind now... Use HPWM on your led emitter, place the IR receiver on RA.4/T0CKI. Use Timer0 to count, Timer1 or Pause to do your sample time. The read the TMR0 register.

    Another wich i don't really like but i saw many times... Led emitter directly to Battery via resistor, IR detector to RA.4/T0CKI. Jump in a interupt routine on a TMR0 overflow. Easy neat... may kill the IR Led soon.. battery too.

    Do a search for T0CKI, you should find some tips to begin.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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