Shop OBEX P1 Docs P2 Docs Learn Events
Photoresistor — Parallax Forums

Photoresistor

TinCansAssocTinCansAssoc Posts: 9
edited 2008-03-17 09:29 in Propeller 1
How do I get a photoresistor to work with my propeller? I'm trying to make a program for pointing an object at the sun using light sensors and servos. What is a good approach to do this?

Comments

  • RaymanRayman Posts: 14,162
    edited 2008-03-14 23:06
    Well, I think the easy way would be to put your photoresistor in series with a regular resistor with one end of this series at ground and the other at Vdd. Then put a wire from between the resistors to a Prop pin.

    Using the Prop pin as an input, you'll get an ON/OFF state by monitoring the status of this PIN...

    If you want to measure the actual light level, you might try using my ADC object at www.rayslogic.com
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2008-03-14 23:21
    If you only have one sensor then it would have to hunt around trying to find the exact brightest spot assuming it can tell the difference between bright and blinding. You are better off to have an array of sensors spread out. The array can also deal with photo saturation as the elements in the center may have saturated yet the elements on the periphery can still detect shades of light levels. This way it's way easier for the servo software to find and smoothly maintain that sweet spot.

    Photoresistors are ok I guess, do you know that an ordinary green LED makes a great daylight sensor? (and they're cheap)

    Why don't you tell use more about your project, we all answer questions and share information about what we are doing because it's of interest to us and both educates and stimulates.

    *Peter*
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-03-15 00:30
    You can use four photodiodes with an X shaped baffle between them so that they only respond to light comming from a given quadrant, then move the servos to ensure that the light hitting them is equal. I recently found a demo like this in a guided weapons demonstration hall where I work, it follows a desk lamp, I think using IR photodiodes.

    Graham
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2008-03-15 00:41
    News headline "Propeller powered SAM intercepts and destroys hostile jets"

    *Peter*
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-03-15 08:45
    I guess my competition entry is out of the bag [noparse]:)[/noparse]
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2008-03-15 09:11
    Nah, you'll be right, I'm sure you will shoot down the competition.

    Heat seek and you will find.

    *Peter*
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-15 09:17
    So if Graham is doing the missile who is doing the plane?

    Sorry, its OT but it was too good to miss.

    There was someone else who asked a question about using LDRs. I think it may have been in the sandbox.
  • rjo_rjo_ Posts: 1,825
    edited 2008-03-15 11:09
    Great topic.

    How long do you have to find the sun? Are you going to use servos to search for it or do you want a monolithic 360 degree photoresistor solution?
    How much resolution do you need in your final answer?

    There is a big difference in the approach you would take if this were a solar powered submarine... vs. a smart bullet for shooting down micro-uavs, which also happen to have very bright head lights[noparse]:)[/noparse].

    There is a nice RC circuit in one of the education labs(PE-Kit-Counters-Lab)... For solar powered submarine type applications, this should work just fine.

    Since you are dealing with a fairly bright source, the RC circuit should be nice and snappy. You might want to try pin-hole optics to get yourself a nice field of view (http://www.ruf.rice.edu/~dodds/Files231/pinhole.pdf). The sun is about a half a degree.

    Of course, if you know roughly where your machine is pointing to begin with, the problem gets a lot easier... a 3D accelerometer(used as an inclinometer) and a compass would give you a really good starting point and let you zero in on the sun a lot faster.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-15 11:24
    One thing to watch out for is cloudy days. The light reflecting from different sources and clouds can really muck things up. You may want to consider some kind of filtering or averaging to prevent jiggling of the servos.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-03-15 11:46
    I think we have to assume a clear view of the sky as far as other sources go, you could actually masked fixed sources like the windows of buildings that might reflect with card (at the detector end on the window end, like blinkers on a horse), clouds are an issue but the best you will ever acheive would be to point in the brightest direction whatever method you use.

    I think Steve's idea about (temporal?) filtering is a good one, you know the sun doesn't move at high speed so neither should the servo. You could also add a certainty value to your measurements, with my suggested method you would be more certain of your direction when you have four equal signals from bright sources than from relatively weak ones.

    Another method would be to glue a ball bearing to a sheet of glass and place an array of photoresistors or photodiodes some distance behind it, you could create a sort of digital sundial, try to move it with the servos to keep the shadow in the middle of the array. This would also make finding the sun in the first place childs play but cloud will reduce the shadow considerably.

    Yet another method would be a 2D position sensitive detector and a pin hole, try to put the light that comes through said hole in the middle of the array. PSDs are easy to interface with and fairly cheap. In this case cloud will make the spot bigger.

    Graham
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-03-15 11:47
    Oh for the record I have nothing to do with weapons guided or otherwise.

    Other than my guns (kisses biceps) yeah.gif

    Graham
  • bambinobambino Posts: 789
    edited 2008-03-15 14:34
    This may sound childish but, has anyone tried using a magnifying glass on a servo and a temp sensor to calculate angle of tilt.

    Legal note: "No ant hills where harmed in the construction of my theory!"
  • RinksCustomsRinksCustoms Posts: 531
    edited 2008-03-15 15:29
    @TinsCans - Welcome to the forums. If you go into the main prop forum, you'll notice the PE kit LABs sticky, it has several labs including servos, counters (shows how to use an RC Time to act like an ADC getting a value from a variable resistance or capacitance).

    My theory on your design - you could take the LDR mount(spelled hot glue)·it at the bottom of a tube (~1/4-3/8"W X 1-2"L) and take that assembly and "mount" it to a servo arm. Now, i'm not sure just how big your object that needs to get pointed at the sun is, but if it's on the order of a few lbs, you'll probably want to look into one or two giant scale servos for it's control.

    The servo with the LDR mounted to it can be used like radar -but for light intensity. Producing a sweeping motion and sampling the LDR at the same time will give you a means of comparison which can be done with as little as two variables. Using the two variable compare method (bright_last_position, bright_current_position), will be·faster and less complex·than lookdown tables + math. It also has the advantage of a variable sky(clear, pt. cloudy..) not affecting your code possibly causing a bug. Then one the position of the sun has been determined and if the servos were all mounted on the same plane, ie- oriented in the same direction relative to one another, then posistioning your object will be as simple as passing your brightest position on your "light-dar" servo to the other servos. And if you wanted to get real fancy you could mount the light-dar servo to another servo's arm giving the ability to scan horizontally also. but for 100% acuracy, you'd need to take thoe two light-dar servos and·mount them to a third axis servo, giving·you the ability to track the arc also. It may not be cheaper than a whole array of·LDR's at different angles, but·i bet even a 3-axis servo setup would be easier to code·than a hemisphere's worth of LDR's.·Just thinking out loud, hope this helps a bit though.

    @Grahm - I got your heatseek and can't find missle covered! lol I have a base-ment full of planes, 25% Extra 300, 45% Pitts Special, a few ducted fan jets, and a few (10) 3D Heli's too. All in all about 30 craft to aim @.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
  • TinCansAssocTinCansAssoc Posts: 9
    edited 2008-03-15 17:30
    Haha, I didn't expect to get so many replies [noparse]:)[/noparse] I would have responded sooner but my internet was down.

    Well in more details I was thinking about making a solar generator using a parabolic reflector and a sterling engine, but before I get too far into the mechanical aspect I wanted to learn more about the propeller aspect. In reality it would be cheaper to use geared motors and a rotating framework, but I'm open to ideas on how to control the angles. Since I don't need a lot of accuracy, I was thinking about using 4 photoresistors in a circular array with something that projects in Z-axis to create a shadow. Then I have left/right, and up/down, but I agree it won't work too great in clouds, but maybe it wouldn't matter anyway, I could just have it position where it thinks it should be according to time of day/year. I like the idea of a sensor array and a ball-bearing glued to a cover

    however, I'm new at the propeller and i just want to figure out how to get the code to work with my hardware first. [noparse]:)[/noparse]
  • TinCansAssocTinCansAssoc Posts: 9
    edited 2008-03-15 17:58
    It sounds to me like you guys would rather be launching guided rockets rather that generating electricity. [noparse];)[/noparse] Well if one of you feels like shooting down your model planes, I recommend using either using an airsoft gun or model rockets, I like model rockets because the ones that work best are the home grown ones made from computer paper and recyclable plastics :P
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-15 21:26
    TinCansAssoc,
    If you are going to be using a parabolic reflector it is actually going to have to be fairly accurate. Is it going to be a trough or a dish? How most people do it these days is to simply program the controller with where the sun should be. This avoids all the problems with cloudy days and reflections.

    Geared motors (maybe a stepper motor) and a rotating frame are probably the way to go as you could get more accuracy than with a servo. You would also need some way detecting either where the reflector is or when it has reached its stops.

    For the OT part of this thread...
    Now forget the rockets and missiles, all we need is a few mirrors to reflect the sun onto the enemy and we can burn them upsmile.gif
  • SeariderSearider Posts: 290
    edited 2008-03-15 23:48
    You could use 4 small Solor Power Cells in a slightly convex flower pattern. Then monitor the power out put of each. Not only would you be able to aim at the highest available power you would also be able to power your circuit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Searider
  • TinCansAssocTinCansAssoc Posts: 9
    edited 2008-03-16 02:27
    Well most likely I'll be using a 36" circular reflector with a 18" focal point and my heat absorbing object will probably be a big metal pipe maybe 2" in diameter, so I don't expect to need high accuracy because it should be able to hit the pipe anywhere and still be a effective conductor + or - a few degrees.


    (update) I got my sensor to work, so now I just have to finish my code.

    Post Edited (TinCansAssoc) : 3/16/2008 5:24:54 AM GMT
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-03-16 16:32
    This is directly relevant to you:

    Design and construction of a system for sun-tracking

    You can buy the article but if you PM me with your email I might be able to help you out [noparse];)[/noparse]
  • TinCansAssocTinCansAssoc Posts: 9
    edited 2008-03-16 20:43
    Thanks for the article Graham, I got it off my university library's website, but I think right now I more concerned with actually building the heat collector since I started getting some code to work. For now I'm just going to focus on direct sun because it's always sunny in Southern California [noparse];)[/noparse] I need better data on how to build a good sterling engine. I found plans for how to build small ones out of tin cans and stuff, but I need data on the ones designed for running off candle flames. Those have long narrow pistons and are the shape I need since I already have a parabolic reflector.

    Anyone have plans for candle powered sterling engines?
  • TinCansAssocTinCansAssoc Posts: 9
    edited 2008-03-17 05:19
    Back to the question about photoresistors, can someone better explain to me how you measure the actual light level verses just on or off? is it as simple as using a different command other than "ina[noparse]/noparse" or do I need different hardware too to create a digital or analog input?
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2008-03-17 09:29
    All you need is a capacitor and a resistor to convert an analogue signal to digital using delta-sigma conversion methods. This is covered in the education kit labs , it's very simple to do.

    Graham
Sign In or Register to comment.