PDA

View Full Version : Time-Lapse



Ted's
- 12th May 2008, 23:15
I own a L730

Picture1:
http://www.letsgodigital.org/images/artikelen/47/samsung-l730-zoom1.jpg
Picture2:
http://www.letsgodigital.org/images/artikelen/47/samsung-l730-zoom2.jpg

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

eggman
- 13th May 2008, 13:09
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.

Ted's
- 13th May 2008, 13:55
Fair enough.
How fast can a ldr react? Is a light sensitive diode/transistor suitable aswell?

eggman
- 14th May 2008, 12:00
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.

g-hoot
- 14th May 2008, 19:51
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

mackrackit
- 14th May 2008, 20:09
FYI g-hoot,
http://en.wikipedia.org/wiki/Photoresistor
Now Ted has code for his project too :) and what speed to expect. :)

g-hoot
- 14th May 2008, 20:32
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

mackrackit
- 14th May 2008, 20:53
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.

Ted's
- 14th May 2008, 21:06
I like the symbol http://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Light-dependent_resistor_schematic_symbol.svg/128px-Light-dependent_resistor_schematic_symbol.svg.png

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?

g-hoot
- 14th May 2008, 21:20
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

Ted's
- 14th May 2008, 21:48
What is OK?

g-hoot
- 14th May 2008, 22:02
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

Ted's
- 14th May 2008, 22:31
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.

g-hoot
- 14th May 2008, 23:46
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

mackrackit
- 15th May 2008, 01:00
Duct Tape and Bailing Wire.
You forgot Bubble Gum. :)

skimask
- 15th May 2008, 01:36
Duct Tape and Bailing Wire.
You forgot Bubble Gum. :)

And a B.F.H.
and a left handed counter clockwise metric philips screwdriver

mackrackit
- 15th May 2008, 01:41
Metric Crescent Wrenches are always good to have around too.

g-hoot
- 15th May 2008, 01:42
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

skimask
- 15th May 2008, 02:13
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...

Ted's
- 15th May 2008, 02:34
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?

g-hoot
- 15th May 2008, 03:36
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

Ted's
- 15th May 2008, 05:55
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.

g-hoot
- 15th May 2008, 13:58
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

skimask
- 15th May 2008, 14:00
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! :)

Ted's
- 16th May 2008, 00:33
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.

skimask
- 16th May 2008, 00:58
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.

Ted's
- 16th May 2008, 01:15
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?

skimask
- 16th May 2008, 01:19
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.

Ted's
- 16th May 2008, 04:46
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?

Archangel
- 16th May 2008, 05:50
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

Ted's
- 16th May 2008, 08:35
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.

mackrackit
- 16th May 2008, 13:26
Read all.
http://www.picbasic.co.uk/forum/showthread.php?t=922
http://www.picbasic.co.uk/forum/showthread.php?t=3771
http://list.picbasic.com/forum/messages/3064/3607.html?1020960642
http://www.picbasic.co.uk/forum/archive/index.php/t-109.html

skimask
- 16th May 2008, 14:07
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...

g-hoot
- 16th May 2008, 16:29
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

Ted's
- 16th May 2008, 20:55
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.

skimask
- 16th May 2008, 21:19
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...

g-hoot
- 16th May 2008, 21:45
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

mackrackit
- 16th May 2008, 22:44
Did anyone read the links up in post#32?
If you did here is another.
http://www.melabs.com/resources/samples/x1/pbp/cmp877Ax.bas


I agree, the manual is not written for people using basic.
Maybe you are reading the wrong manual :D
http://www.melabs.com/resources/pbpmanual/

skimask
- 17th May 2008, 14:16
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...

Ted's
- 17th May 2008, 18:22
...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....

g-hoot
- 17th May 2008, 20:16
Did anyone read the links up in post#32?

I finally did...very good reading and explanation on the comparators. I am going to have to try Melanie's tutorial when I get a chance...very well written and explained! Thanks for those links Dave!
Gary

mackrackit
- 17th May 2008, 20:25
I am going to have to try Melanie's tutorial when I get a chance...very well written and explained!
If/when you run across stuff from Melanie, save it. Always good instructions.

Ted's
- 4th June 2008, 10:20
I am using blutak now and a suitable resistor forming the voltage divider. It is working well enough by using a simple I/O-Pin.

I am proceeding here (http://www.picbasic.co.uk/forum/showthread.php?p=57160#post57160).