Shop OBEX P1 Docs P2 Docs Learn Events
Making an allowance for 3 mismatched photoresistors — Parallax Forums

Making an allowance for 3 mismatched photoresistors

PannPann Posts: 6
edited 2011-01-24 07:05 in BASIC Stamp
Hello everyone, first post here.

I am working on a project that involves a laser beam hitting a 4 inch by 2 inch surface. I need to be able to detect exactly where the laser beam is hitting (from left to right horizontally along the greater length, vertically is not important).

So far I have constructed a 4 inch by 2 inch open-top box that is 1 inch deep. On the bottom of the box I have placed 3 photoresistors, one in the center and the other two at the far left and right. A piece of plexiglass has been placed on the opening of the box and 4 sheets of wax paper under the plexiglass. The wax paper diffuses the laser enough so that it can be detected by the photoresistors even if the laser is not pointed directly at one of them.

This works very well. As I move the laser from left to right, the RCTIME associated with the left photoresistor steadily increases, the middle RCTIME steadily decreases until the center is reached and then increases, and the right RCTIME steadily decreases. So far so good.

The problem is that even in a situation where all 3 photoresistors are receiving the same light, the RCTIME for all three is different, and not just by a little bit. I need to be able to tell when the laser is hitting dead center, and if it's not dead center, how far to the left or right it is. If the photoresistors all acted the same, this would almost be a no brainer, but I can't figure out how to account for the variances.

Any suggestions would be appreciated. Is there a way to do this? Am I "barking up the wrong tree" and there is another way to do what I need to do using different sensors?

Thanks in advance for any and all help.

Pann

Comments

  • bsnutbsnut Posts: 521
    edited 2011-01-23 03:15
    Welcome to the forums.

    You have the right idea for what are doing. I would suggest using a resistor across the leads of the photoresistor if you haven't done so. What this does for you is keeps the photoresistor at known value, since the stamp likes resistor values around 5 - 50K.

    Another way is do it in your code, were you set min and max values.

    I hope this helps you.
  • PannPann Posts: 6
    edited 2011-01-23 11:33
    Thank you for the reply, bsnut. I'll try the resistor and see what happens. What value would you suggest? Right now I have three 0.01 microfarad capacitors, one each in parallel with each photoresistor. One lead of each photoresistor is connected to a pin through a 220 ohm resistor and the other lead of each photoresistor goes to VSS.

    Just to be clear, you are suggesting that a resistor be placed in parallel with each photoresistor. Correct?
  • bsnutbsnut Posts: 521
    edited 2011-01-23 11:59
    Yes, that is what I am suggesting, a resistor around 25K or so in parallel with the photoresistor. After, you do that, I would run the RC test code, to see what values you have.
  • PannPann Posts: 6
    edited 2011-01-23 21:30
    Eureka!! Problem solved.

    Thank you bsnut for your advice. However, I've taken a different path from what you suggested. I placed two dividers in the box, one immediately to the left of the center photoresistor and one immediately to the right, leaving just enough room for the photoresistor itself. This effectively divides the plexiglass into three sections, a left section, a very narrow center section, and a right section. The RCTIME shows little to no change from the ambient light value unless the laser is hitting that particular section.

    From this point, it will be a fairly simple matter to do what I need to do.

    On a more general note, I'm still unclear about how to compensate for different readings from two sensors when the conditions they are sensing are the same. Bsnut's suggestion of placing resistors across the leads of the photoresistors helped immensely, but didn't completely solve the problem. Being relatively new to PBASIC, (only about 3 months or so) I have absolutely no idea how to implement bsnut's other suggestion which was to take care of it in the code by setting maximum and minimum values. If any one could help with my understanding, I will be grateful.

    Thanks,
    Pann
  • bsnutbsnut Posts: 521
    edited 2011-01-24 07:05
    I am glad that you got it working. I didn't think about suggesting to use a divider between the photoresistors.

    My idea for preset resistor came from a Nuts&Volts article dated on July 1995 called Checking Battery Condition and Multiplexing I/O Lines written by Scott Edwards.

    What, we are doing is setting the photoresistor at a preset limit or "clamping" with the resistor, because the photoresistors are known to have high resistance above 100Kohm when no light shining on it. When light is on the photoresistor the resistance decreases below the preset resistor value and when light the photoresistor is dark the resistance increases up to the preset resistor value.

    If you do it with the code it would look something like this.
    IF preset >= rcval OR preset <= rcval THEN Go_somewhere
    

    I hope this gives you some idea what I am talking about.
Sign In or Register to comment.