IR detector


Closed Thread
Results 1 to 29 of 29

Thread: IR detector

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Posts
    91

    Default IR detector

    Hi all I'm really new to picbasic and to electronics in general.
    So please don't be too harsh on me.

    I bought this
    http://www.radioshack.com/product/in...entPage=search

    Here is the back of the package should give more info


    What I want to do is basically start a timer when the beam is broken and count every time the beam is broken till its broken 100 times then report back the time.

    Lets start with the basics.

    So far I have 9V in to a 510 Ohm resistor to the IR led then to ground.
    Across from that I have 9V to 10K resistor to the collector side and emitter side to ground.
    (connecting a led in series I have been able to get the led to light when the beam is broken
    What I'm not sure how to do is get a signal off the detector to a 16F628A input so when the beam is broken I can detect it.

    Anyone offer any assistance?

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hello Geckogrotto,

    Well you're almost there. First you will need to get a 5 volt regulator to drop your 9 volts down to 5 volts for the PIC. Then connect the 10K resistor between 5 volts and the collector of the phototransistor. You can then connect the junction of the 10K resistor and the collector to the input of your PIC. Your program should "see" a low (ground) condition when the "beam" is being detected and a high (5volts) when the beam is broken.

    Hope this helps you!

    BobK

  3. #3
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help Bob. Like I said im really new to electronics even but is there a way to use resistors instead of a voltage regulator?

  4. #4
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    WOOT Thanks again Bob I dropped the voltage down to like 4.5V using 3AA batteries instead of a 9V, reduced the resistor on the LED and connected like you said... It works perfect! thanks I would like to know if there is a way with resistors to do the same thing and use a 9v if possible.

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

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

  7. #7
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default LCD Screen

    Due to all the help I have gotten here I have everything worked out. I decided to buy a lcd screen so I could output the results to it but I have no idea how to hook it up.

    LCD Display 16 characters with 2 rows LCD its Hitachi HD44780 compatible LSI controller

    It has 16 pins.
    1 GND Ground
    2 +5v Power
    3 Vcont Contrast voltage
    4 RS Select
    5 R/W Read/Write
    6 EN Enable
    7 DB0 Data bus
    8-14 .......
    15 LED K Backlight cathode
    16 LED A Backlight anode

    Ok 1 and 2 are pretty simple
    Im not sure what pins I would hook up to my 16F628A chip. just data bus?
    going to do some searching around to see what I can find was just so excited had to post Any help would be appreciated.

  8. #8
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Ok looks like mine is almost exactly like the olympic timer
    http://www.picbasic.co.uk/forum/atta...4&d=1091819883

    So it looks like 7-10 should be data..?

    Man I still have so much to learn

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


    Did you find this post helpful? Yes | No

    Default

    I decided to buy a lcd screen so I could output the results to it but I have no idea how to hook it up.
    Free schematic in PBP manual in the LCDOUT section.
    Steve

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

  10. #10
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Free schematic in PBP manual in the LCDOUT section.

    Thanks lol
    Good old fashion case of RTFM!

    I have one questions about it tho, pin 3 on the lcd connects to the middle of the 20K resistor? I don't understand that part.

    also I don't have a 20K resistor should I use 18K , 22K , 18K and 2K in series, or wait till I can get a 20K?

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    It's a 20K potentiometer or trimmer. It's there to adjust the LCD contrast. You can use lower value. 1-10K still work. You can also use two resistor to make a fix contrast. Wich value... ARRRGGH close to be impossible to tell, no lcd work the same way.

    You can still use HPWM to make a software controlled LCD contrast... for now, just plug-it and display on it.
    http://www.picbasic.co.uk/forum/show...light=contrast
    Last edited by mister_e; - 20th August 2006 at 22:15.
    Steve

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

  12. #12
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Ok last question

    I have read all over about floating points and I still can't figure out how to do this.

    My calculation is

    shotspersecond = count / seconds
    shotsperminute = shotspersecond * 60

    with floating points this would work fine and tell me shots per minute avg.

    Without FP if the seconds > count then I get 0 as shotspersecond and a number of other problems.

    I know this can't be too hard but I can't seem to wrap my brain around it.


    Any help would be very appriciated as once I get this I should be able to finish off my project.

    Any help would be very appriciated as once I get this I should be able to finish off my project.

    This is what I have so far... It may be accurate enough for what I am doing.
    SPS = 5 / TotalTime
    if sps = 0 then
    SPS = 5 // TotalTime
    SPM = sps * 60 / 100
    else
    SPM = SPS * 60
    endif

    Better way to do it?
    Last edited by geckogrotto; - 21st August 2006 at 20:38.

  13. #13
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    My calculation is

    shotspersecond = count / seconds
    a) Declare your variables as WORDS

    b) Multiply count by something like 100 or 1000. This shifts the decimal place to the right. Pick a multiplier that will keep the result below 65536.

    b) Now, do the divide: shotspersecond = count / seconds.

    c) Display shotspersecond with something like:

    LCDOUT DEC shotspersecond/100, ".",DEC2 shotspersecond//100

    The key is to shift the decimal place prior to the division, then adjust the display to account for the shift.

    For more reading (and a better example of integer math), take a look at These threads from Darrel Taylor:
    Retrieving 32bit Multiply Result
    Retrieving Div32 Remainder
    32-bit Variables and DIV32, Hourmeter 99999.9.

    You might also try a search for integer math.

    HTH,
    Steve

  14. #14
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Ohhh thanks Steve I was multiplying x 100 after the divide not before thanks I got it now

  15. #15
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Ok really this time last question. This has more to do with eagle but figured you guys would know.
    I'm trying to find a LCD like the one on page 94 in the manual to use with eagle and I can't seem to find one.

    I downloaded all the LBR files I could find that said LCD on them but still no luck.

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


    Did you find this post helpful? Yes | No

    Default

    Mat,

    Just select one of the connectors / Pin Headers that suit the number of connections on the LCD. This will allow you to either plug the LCD into your board if you use a suitable pin and header block, or solder wires directly to the pads if the LCD is remote from the board

  17. #17
    Join Date
    Jan 2006
    Posts
    31


    Did you find this post helpful? Yes | No

    Question Infra Red Detection in PICBAsic

    Hi, i'm building a simple remote controlled project consisting of 8 12v Relays. I'm using TSOP1738 IR receiver from Vishay Telefunken. I'm using PIC16F84A microcontroller and PICBasic Compiler. I got it from a junked VCD player. Is there anyone who knows how to intercept the coded signal from any IR transmitter? How do i control individual relays independently.

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


    Did you find this post helpful? Yes | No

    Default

    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