PDA

View Full Version : moonlights that dim to a 29.5day cycle with a PIC microcontroller


jent46bow
01/17/2006, 09:37 PM
This is a thread that was started on:
http://archive.reefcentral.com/forums/showthread.php?s=&threadid=753363
and then moved to:
http://archive.reefcentral.com/forums/showthread.php?s=&threadid=753533
and I am not posting here, since I was recomended to try here.

I want to DIY some LED lights that dim based on the 29.5 day lunar cycle. The easiest/cheapest way I can think of doing this is by using a Microcrontroller. I think a PIC controller is the way to go. I found this site:
http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=1031&mid=10&lang=en&pageId=74
But I am not sure what unit would best suit my needs. I have very little experince working with these, but there seems to be quite a bit of documentation for compiling. So any help on telling me what would unit best suite my needs would be excellent. Also I am not sure what else I would need to do this. If you look at my first post you see that I thought LM555 to dim the LED's since obviously you can't just change the power to them. But with more thought and research I think that if I get the right microcontroller it will be up to the task.

If anyone has done this before please post what you did and how. I have never done any embeded programing but I am a Computer Science student and quite tech friendly. I am mostly using this project as a way to learn and expand my skills. I need lots of info and I hope you guys can help. Thanks

jent46bow
01/19/2006, 10:13 PM
A coworker at work loaned me a stamp to test out. So I got it today and have been messing around with it. I was able to get it so the LED's brigten and dim based on 59 diffrent intensitys (so it would adjust twice in a 24hour period) All that seems to work down to a tee. Right now I have it doing the whole cycle in under 30 seconds for testing. But I have hit a snag, one I do not think I can get beyond. Inorder for the LED to dim it has to be on for .0001 seconds and off for .00035 seconds....And in the brightest setting it is just on for .0001 seconds and off for 0 seconds....Well each time it makes a loop through to keep the LED's flashing it takes a diffrent amount of time based on how bright the led is. So the dim days would last forever and the full moon days would go by very quickly. I can not find a way to get around this without some sorta outside clock to tell it how long it has been running. So it pretty much died there. If anyone wants to see my very VERY ruff code here it is:
http://pastebin.com/514051

this post is more of a documentation of how it all ended, than looking for help. I personaly can not see anyway to get around this with the limitations of the hardware. The only thoughts I had are maybe a PIC would be able to do this (i have no idea what they are capable of).....or maybe I would be able to do this with an LM555.....I am just not sure....so any input would be nice, but I don't expect any :-)

ronc98
01/22/2006, 05:08 PM
Sounds like you are making some progress. Keep in mind that the moon's intensity is not a true linear function it is more of a sin wave that peaks at full more Day15 and then ramps down to day 29. do a goodle search to get the intensities. You could easly make a look up table to do this. That is what I did on my controller.

BeanAnimal
01/25/2006, 11:52 PM
LEDs are not linear devices, so you will have to measure the output and come up with about 15 brigtness settings and put those in yoru table to corrolate with the output on any given day.

ronc98
01/26/2006, 08:43 AM
All of this is easy if you had the right tools. :)

afex
02/08/2006, 01:07 PM
were you using built in PWM capabilities on the PIC?

i'm also an embedded noob but have recently begun researching.

PM325e
02/11/2006, 05:53 PM
Graph on the intensity of moonlight from a web site thought you might like. It shows how the intensity of moon light from earth changes over a 29 day period.

http://reefcentral.com/gallery/data/500/95586moon_light_intensity.jpg

BeanAnimal
02/11/2006, 06:32 PM
The easiest way to do this is to use a lookup table and PWM to vary the intensity of an LED array. You can use 29.5 if you want to be close, however over time the tanks monn cycle and the real moon cycle will drift apart.

Instead of trying to program a bunch of floating point math (I already did it once for VB and lost the DLL in my filesystem someplace) you can simply copy 10-20 years worth of data into a lookup table and use it to determine the intensity on any given day. 365 entries per year isnt so bad considering the size of todays eeproms and flash memory.

AfAqua
01/08/2007, 01:55 PM
Have you thought about using your PIC to trigger a digital potentiometer. Don't know if this would work as I'm not "PIC literate".

marco_UK
01/09/2007, 01:25 PM
The PIC would work great. Try one of the motor controller types PIC18F1230, they have PWM's built in. You would just need to stick a small MOSFET on the PWM output and connect your LED's to that. BeanAnimal is right it would not be linear. The PWM would go from 0 to 100%, but you may find there is no light until say 25% and from then on it would not be a linear relationship. Then if you really want a sine curve, use a look up table to keep the numbers all integers or just approximate it into a ramp up / ramp down. My only worry would be drift of the timing but that PIC has a nice clock system to help with that.

indexfree
06/05/2007, 05:23 AM
<a href=showthread.php?s=&postid=6541845#post6541845 target=_blank>Originally posted</a> by jent46bow
I personaly can not see anyway to get around this with the limitations of the hardware. The only thoughts I had are maybe a PIC would be able to do this (i have no idea what they are capable of).....or maybe I would be able to do this with an LM555.....I am just not sure....so any input would be nice, but I don't expect any :-)

A RTC (real time Clock) would help here, you could try here
Dontronics (http://www.dontronics.com/rtc.html) but google basic stamp RTC will bring up a lot of results.

easttn
06/16/2007, 07:57 AM
You could also use your pic to control a stepper motor. LEDs full on from time X and off at time Y. These would be in a light tight enclosure. The stepper would control a disk that has cutouts of waning and waxing moons. Just control the disk to match that of the moon at some log/lat you choose from various net sits. I did this using a plc, worked great.

Hopeful Reefer
11/23/2007, 06:52 PM
Not to dampen anyone's spirits, but wouldn't it be cheaper to buy one from Fishbowlz off eBay?

http://stores.ebay.com/Fishbowl-Innovations