Shop OBEX P1 Docs P2 Docs Learn Events
Need Help with rctime and photocells — Parallax Forums

Need Help with rctime and photocells

jmevansjmevans Posts: 22
edited 2007-01-18 18:36 in General Discussion
I am wanting to connect three photocells up on three pinewood derby lanes to monitor the finish line.
I have tested this with the BS2 but thought that the SX would be better with the Interupt capabilitys,
my question is what is the best way to do this using the interupt?

On the BS2 i used rctime to measure the ambiant light level then contuiualy checked for substantial changes on each of the three photocells.

A simple example would be of great help.

Thnx.
Mark

Comments

  • BeanBean Posts: 8,129
    edited 2007-01-16 22:07
    You could propbably do it the same way you did on the BS2.
    A photocell does not lend itself very well to interrupts. You would have to adjust them for different light levels.

    You "may" be able to use a capacitor to sense a rapid change in light levels.
    
    
            Photo        R1 (same value as photocell in normal light)
    Gnd-----/\/\/\--+--/\/\/\----Vdd(+5)
                    |
                    |  10uF      100K
                    +--|(--+---/\/\/\---Gnd
                           |
                           +---------------> Input Pin
    

    These values are just guesses, you might have to play around with them.
    This should read as LOW until the photocell is darkened, then it should go HIGH for a short time.
    If you want to use INTERRUPTS you would have to use one of the RB pins. But interrupts sound awfully complicated for this application. (Unless it's just as a learning exersice).

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman

    Post Edited (Bean (Hitt Consulting)) : 1/16/2007 10:15:38 PM GMT
  • JonnyMacJonnyMac Posts: 9,214
    edited 2007-01-17 00:19
    If you can get a copy of this month's (January 2007) Nuts & Volts magazine you'll find that the project for my column is... (drum roll, please) a pinewood derby lane timer. It uses an SX28 to time the car, detect the finish, and display the running time (in milliseconds) on five, 7-segment displays. I've attached the schematic and code (get the magazine for an explanation of everything).

    My circuit uses the comparator with a calibration resistor to set the sensitivity of the photo-detector (part of an IR LED/transistor pair from RadioShack).

    In the SX/B help file, under the INTERRUPT keyword, there is a demo that uses port B edge triggered interrupts to determine which button (of four) was pressed first. If you can adapt your detection circuit this may be the best way to go. The project discussed above is really designed to aid in fine-tuning the performance of a pinewood derby racer by measuring its "lap" time.

    Post Edited (JonnyMac) : 1/17/2007 12:25:03 AM GMT
  • jmevansjmevans Posts: 22
    edited 2007-01-18 15:33
    Here is what I have working so far, It is very Crude but any input would be welcome.

    I would like to be able to get more accuracy in the timer (Maybe by using the Interupt)

    and if it is possible to get more accuracy in the reading of the photocells that would be nice.

    Thanks for any of your input.

    Mark
    1500 x 1004 - 335K
    1500 x 1004 - 273K
  • BeanBean Posts: 8,129
    edited 2007-01-18 16:02
    Mark,
    You have a couple things working against you:
    1st photocells are just slow reacting by nature (probably milliseconds)
    2nd each RCTime command takes an uncertain amount of time to complete

    If you look at Jon's schematic, you will see that he is using phototransistors. These react almost instantly (microseconds).

    Also he is using a calibration pot so that he gets a digital signal (either on or off) from the phototransistor by using the SX28 built in comparitor.

    You could probably get away with just using a pot instead of the 10K pull-up resistor in Jon's schematic, and adjust it for the threshold level of the pins (1.4V or 2.5V). It will be tricky though (If someone moves and their shadow goes over the track, it may think a car has passed over the sensor).

    A better way to go might be to use a "break-beam" sensor. Each track would have a IR transmitter and IR receiver on each side of the track. When the car reaches the IR beam, it breaks it and creates a digital signal for the SX. The 38KHz frequency could be generated by the SX, and IR receiver modules are very common (these give a digital signal). This type of system would be accurate to more than 1millisecond.

    Good luck,

    P.S. What do you think about using one of my video display boards for a display ? It would be large enough for everyone to see. I'll donate one to you if your interested. They are 6 lines of 16 characters.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman

    Post Edited (Bean (Hitt Consulting)) : 1/18/2007 4:06:29 PM GMT
  • jmevansjmevans Posts: 22
    edited 2007-01-18 18:35
    Thanks, I will give the·IR transmitter and IR receiver a try.

    P.S. I·would love to·try one of your video display boards, it·would be nice if everyone could see the results.

    Thanks again

    Mark
  • BeanBean Posts: 8,129
    edited 2007-01-18 18:36
    Send me a private message with your address and I'll send you one.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
Sign In or Register to comment.