Time-Lapse


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 43

Thread: Time-Lapse

  1. #1
    Ted's's Avatar
    Ted's Guest

    Default Finding out whether a led is on or off using a phototransistor

    I own a L730

    Picture1:

    Picture2:



    This digital camera consists of a green LED next to the T on Picture2. I want the PIC to figure out whether the LED is on or off without opening the device(the camera). How can I do that - technically and in PBP?

    Thanks
    Ted's
    Last edited by Ted's; - 13th May 2008 at 03:02.

  2. #2
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    You could use an LDR (light dependant resistor) to check whether the LED is on. Use black tape or other stuff to make sure only the light from the LED reaches the LDR. Connect the LDR between an input pin of the PIC and ground, and a say 1 MOhm resistor between the same input pin and +5V (pull up). As soon as the LED lights the resistance of the LDR will go down, pulling the pin low. You might have to experiment a bit to get the right value for the resistor.

  3. #3
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    Fair enough.
    How fast can a ldr react? Is a light sensitive diode/transistor suitable aswell?

  4. #4
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    An LDR might be a little slow, depends on the speed you need. Photo transistor might work well too, again, you'll have to experiment a bit.

  5. #5
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Ted's,
    I'm a rooky at electronics, so what the other guys are suggesting is probably better, but here's how I use a CDS cell for detecting day and night on my circuit, and I think it would work here to, as long as no outside light can get to it. The part number is from digikey: PDV-P9203-ND The specs say:

    Rise Time (Typ) 70ms
    Fall Time (Typ) 15ms

    I don't know, but I'll bet that would work for ya.
    I connect one side directly to the +5V of my board, and the other side to a pin on the PIC. This is the code that I use, and it has worked really well. What I have found using this code, is that it works with pretty much any CDS cell. I had 5 different ones, and they all detected dark at about the same light level with this code. For really good measurement of changes in light level, I'm sure there are better, and more complicated, ways to do this, but this is great for detecting day or night (or light on/off). After reading how RC time works, I'm not real sure why the value of about 46 to 49 is consistently dark on all of the cells I tested, but hey it works.
    DayNight VAR BYTE
    DayOrNot VAR BIT

    Low PORTB.5 'Pin Connected to CDS Cell
    Pause 10
    RCTime PORTB.5,0,DayNight 'Read rctime value into DayNight variable

    If Daynight > 46 Then 'It's dark
    DayOrNot = 0
    Else 'It's Daylight
    DayOrNot = 1
    End If

    Gary

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    FYI g-hoot,
    http://en.wikipedia.org/wiki/Photoresistor
    Now Ted has code for his project too and what speed to expect.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    FYI g-hoot,
    http://en.wikipedia.org/wiki/Photoresistor
    Now Ted has code for his project too and what speed to expect.
    Dave,
    Thanks for the link. I think the sentence below may explain why several different cells produce basically the same results:

    "Many commercially available CdS cells have a peak sensitivity in the region of 500nm - 600nm (green light)."

    Gary

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Yeah, that green light thing nailed me a few years ago. Had a project working the way I wanted in the shop and never thought about how sun light has a different spectrum until I took it out side. All of my setting were off.
    Dave
    Always wear safety glasses while programming.

  9. #9
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    I like the symbol

    I am going to use a device that looks similar to a CDS cell and a ldr, maybe it is a ldr. It is very flat and it's dimensions are 4mm x 4mm. Do you have an idea on how to keep the LDR on the led even though the camera is moving?

  10. #10
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ted's View Post
    Do you have an idea on how to keep the LDR on the led even though the camera is moving?
    Well, I'm from OK, so tape is an obvious choice. :-) You could just use some long wires on the light sensor and tape it, or for a more permanent solution, maybe a clear glue on the face of the cell, then glue around the outside with something black to block light out. Black caulking would work. For the clear glue, use GOOP. It sticks to everything, is clear, and peels right off if you need to clean it off later.
    Gary

  11. #11
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Question

    What is OK?

  12. #12
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Sorry, the abbreviation for the state of Oklahoma in the US. We're kinda rednecks down here. Well at least some of us are. ;-)
    Gary

  13. #13
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    So "Well, I'm from OK, so tape is an obvious choice." is an insider joke, tell me what it is about

    Back to topic: I like your ideas. But you are fishing in the dark and that is my fault. So I am going to create some light:

    The camera is rotating and is taking photos to be combined in a time-lapse-movie. After that I take it from the retainer to connect it to my pc or to take some photos freehand. Then I want to put it in again.

    When the photos are taken there is rapid movement being applied to the camera.

    I thought about using a clamp, see picture, but I haven't managed to find out a suitable material yet. The problems arise because of the force being applied to the edges of the material(at the sharp angles of the clamp). I would have to subtly bend it over and over again which will sooner or later weaken the material to a critical degree.
    Attached Images Attached Images  
    Last edited by Ted's; - 14th May 2008 at 23:00.

  14. #14
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    So "Well, I'm from OK, so tape is an obvious choice." is an insider joke, tell me what it is about

    Well, people in the Southern US states have a reputation of "repairing" (rigging) things with tape and wire, instead of really repairing them. :-)

    Sounds like a cool project that you are working on. Will the camera rotate completly around? If so, how many rotations?

    Gary

  15. #15
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Duct Tape and Bailing Wire.
    You forgot Bubble Gum.
    Dave
    Always wear safety glasses while programming.

  16. #16
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Duct Tape and Bailing Wire.
    You forgot Bubble Gum.
    And a B.F.H.
    and a left handed counter clockwise metric philips screwdriver

  17. #17
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Metric Crescent Wrenches are always good to have around too.
    Dave
    Always wear safety glasses while programming.

  18. #18
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    And a B.F.H.
    and a left handed counter clockwise metric philips screwdriver
    HAHA..."If it don't fit, get a bigger hammer!"

    OK, Ted's, we'll try to get back on track....
    Gary

  19. #19
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by g-hoot View Post
    HAHA..."If it don't fit, get a bigger hammer!"
    Gary
    Sorry, I'm in N.D. We need those BFH's to knock off the ice...

  20. #20
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    A little friendly chat is never a bad idea. After all it was me who asked for a description, remember?

    Re "Cool idea": Well I don't know what you mean, maybe because I am not the youngest. Please explain.

    I just added the ldr and unfortunately the +5V->LDR->IO-Pin-idea does not work. The voltage levels are not within the specified High/Low-Levels of the PIC. I found that Light means 1kOhms and None means from 8-16kOhms.

    So I added a resistor of 4.7kOhms:

    +5V->LDR->IO-Pin->4.7kOhms->Mass. Now there are voltage levels of about 3.2 and 2.3 Volts, which is still not within the specification.

    Now I am planning to use the integrated Comparator but I do not know how, yet. What are the fuses?

    On a 16f628 I guess it is CMCON=%11001010 for the PIN on RA2 but what about VREF. How to activate that in the high range?

  21. #21
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Try the RCTIME code I posted. It should work since it sounds like the resistance values for your ldr are bascally the same a the CDS Cell I am using. I have no resistor though, just connected directly between the pin and 5V.

    "cool" is a slang term that sort of means "neat" or "interesting". Again, sorry about that. I'm not used to being on a forum that has so much input from different countries. It is really "cool"! ;-)
    Gary

  22. #22
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Talking

    I succeeded simply by using a check whether the PIN is High or Low - without the comparator.

    I am using BluTak to connect the ldr to the led and it works.......marvelously.

    Silent movement of the servo coming closer to the button. Then the servo softly moves forward and as soon as the camera reacts it stops. No matter in which position the cam is, it always stops gently. Simply awesome. I am excited.
    Last edited by Ted's; - 15th May 2008 at 06:11.

  23. #23
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ted's View Post
    I succeeded simply by using a check whether the PIN is High or Low - without the comparator.
    Hey there you go. Keeping it simple. Makes sense since you don't need to sense a gradual change in the light. Good job!
    Gary

  24. #24
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by g-hoot View Post
    Hey there you go. Keeping it simple. Makes sense since you don't need to sense a gradual change in the light. Good job!
    I would think a person would want to read that pin a number of times though, a kind of 'software hysteresis', just to make sure the pin isn't jumping 0 to 1 to 0 to 1, and causing something to go a bit flakey......unless of course the jumping around is what you're looking for!

  25. #25
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Arrow

    Quote Originally Posted by g-hoot View Post
    Hey there you go. Keeping it simple. Makes sense since you don't need to sense a gradual change in the light. Good job!
    Gary
    The 16F628a does not have a ADC. The difference between using the IO pin vs the comparator-module is the non-defined space between about 2,5 and 4 volts.

    That means that within this area the PIC could percieve a high as a low and vv. This problem does not occur when using the comparator, so in the long run the comparator is better. I guess this is what skimast said aswell.

    So let us come back to the comparator. The LDR is connected to RA2. Which fuses are needed to make RA2 connect to the (non-)inverting input, the other input to vref and to disable the other comparator? I am adressing all of you.

  26. #26
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ted's View Post
    So let us come back to the comparator. The LDR is connected to RA2. Which fuses are needed to make RA2 connect to the (non-)inverting input, the other input to vref and to disable the other comparator? I am adressing all of you.
    No fuses, just set the right registers to the right value.

  27. #27
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    I thought the word for VRCON, CMCON etc. is fuses. Good to know better.

    So what I want to know: Which numbers are to be used for VRCON and CMCON for the effect wanted?

  28. #28
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ted's View Post
    I thought the word for VRCON, CMCON etc. is fuses. Good to know better.
    Generally speaking - the 'FUSES', specifically CONFIG fuses are set a programming time by the programmer.
    Anything else that can be set at run time (including ram used for variables) are called registers.

    So what I want to know: Which numbers are to be used for VRCON and CMCON for the effect wanted?
    Hate to say it, but it's all in the datasheet for your PIC.

  29. #29
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    I know, skimask. But I would not ask if I could filter out the useful information myself. If you do not want to tell me, fine.

    Can you help me out here aswell, g-hoot?

  30. #30
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Duct Tape and <font color=red>Bailing Wire.</font color>
    You forgot Bubble Gum.
    and when it fails . . . hence the term " it went haywire" . . . Look at how much tape gets used in NASCAR . . . BFH Big Friendly Hammer . . . CMCON = 7 turn off comparators, look at pp 68 of the data sheet try vrcon = 0 shuts vrcon down
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  31. #31
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    and when it fails . . . hence the term " it went haywire" . . . Look at how much tape gets used in NASCAR . . . BFH Big Friendly Hammer . . . CMCON = 7 turn off comparators, look at pp 68 of the data sheet try vrcon = 0 shuts vrcon down
    Please reread the thread.

  32. #32
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

  33. #33
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ted's View Post
    I know, skimask. But I would not ask if I could filter out the useful information myself. If you do not want to tell me, fine.
    It's not that I don't want to tell you (like it's some sort of state secret or something). I mean, look at the project. You obviously have a clue as to what you're doing and how to get there from here. It's just that I would've led you to the right piece of information sooner or later, then you could've figured it out for yourself....that whole 'give a fish, teach to fish' thing...

  34. #34
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ted's View Post
    Can you help me out here as well, g-hoot?
    Ted's,
    I think I understand this less than you, so don't put too much faith in mu help. I still don't understand what a comparator does?... The idea of checking for high or low is what I like best (cause it's simple), but I guess there can be some issues with in bouncing like skimask mentioned. Maybe you could use a weak pull-up resistor to keep the pin high to prevent the bouncing problem. Or, you could simply cut and paste the RCTime code I posted and be done. ;-) I agree with skimask that all the info is in the data sheet, but I still have a hard time understanding what the data sheet says! They sure aren't written for people that are using PBP! That's why I posted my exact RCTIME code for you. I know to most here, that it is day one basics, but for us new guys, it's like learning a new language, and a little spoon feeding is nice and helps in understanding what's going on. :-)
    Gary

  35. #35
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    I agree, the manual is not written for people using basic. And on the right site in the pdf manual the pictures of comparator configurations don't show the configuration I need.

  36. #36
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ted's View Post
    I agree, the manual is not written for people using basic. And on the right site in the pdf manual the pictures of comparator configurations don't show the configuration I need.
    The PIC datasheet and the PBP manual are 2 different worlds, connected by a common purpose...True. It's not like a car owners manual vs. an engine overhaul manual. Agreed. But...PICs ain't cars and cars ain't PICs. And you can't reconfigure a car to haul satellites into orbit.
    As far as the comparator goes...if the right configuration isn't in the datasheet, it probably can't be configured the way you want to be....
    Which is what again? Maybe we can come up with a workaround for ya...

  37. #37
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    And you can't reconfigure a car to haul satellites into orbit.
    With my wire and duct tape, and your BFH, we can do anything! HA

    I understand your analogy about the car owners manual vs. an engine overhaul manual, and you are right....but, Look at the attched pic for an exaple of what I'm talking about though. When I wanted to use EEPROM, that is the example in the datasheet for my chip. I guess that's assembly language? It don't look anything like that in my program. It almost makes sense in PBP. :-) Would be nice if they offered examples in the common languages. I like stuff like "Read, Write, If, Then" that makes sense. I mean no disrespect. I'm just whining cause I'm a rooky an don't really understand what's under the hood! ;-)
    Gary
    Attached Images Attached Images  

  38. #38
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Did anyone read the links up in post#32?
    If you did here is another.
    http://www.melabs.com/resources/samp...p/cmp877Ax.bas

    I agree, the manual is not written for people using basic.
    Maybe you are reading the wrong manual
    http://www.melabs.com/resources/pbpmanual/
    Dave
    Always wear safety glasses while programming.

  39. #39
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by g-hoot View Post
    When I wanted to use EEPROM, that is the example in the datasheet for my chip. I guess that's assembly language? It don't look anything like that in my program. It almost makes sense in PBP.
    That's why RTFM is such a common answer to a lot of problems. PBP handles all that low level eeprom stuff for you.
    You'll find that PBP can handle a lot of low level stuff for a lot of things. And a lot of things that aren't handled by PBP, can more than likely be found on the forums...practically prewritten. Once you get used to it, it's all good..

    And I like twine, duct tape, bubble gum, JB Weld...

  40. #40
    Ted's's Avatar
    Ted's Guest


    Did you find this post helpful? Yes | No

    Default

    ...twine, duct tape, bubble gum...

    Speaking of which I am using Blutak and I do not like this plasticine at all. I think it is disgusting. Unfortunately I have not found another method of connecting the ldr to the cam....

Similar Threads

  1. I don't understand this code!
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 13th February 2008, 02:55
  2. Measuring time
    By AugustoPedrone in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th July 2007, 23:46
  3. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  4. Alarm Time
    By Santana in forum Code Examples
    Replies: 1
    Last Post: - 8th December 2006, 13:58
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14:24

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