Author Topic: Arduino Astronomical Clock for Automatic Light Control  (Read 4681 times)

0 Members and 1 Guest are viewing this topic.

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Arduino Astronomical Clock for Automatic Light Control
« on: November 10, 2013, 11:00:40 pm »
Here's a project I just finished. My first Arduino experiment and got to say I had fun with it:
http://paulorenato.com/joomla/index.php?option=com_content&view=article&id=125&Itemid=4
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: Arduino Astronomical Clock for Automatic Light Control
« Reply #1 on: November 11, 2013, 10:00:33 am »
 :-+
An actually useful project that most likely taught you how to handle a lot of practical implementation details. Not to mention the nontrivial programming part. So, well done.

Have you already considered (or solved) some things that come to my mind:
-How to handle power outages. The lights will be out of course, but how will you ensure that he clock keeps running in order not to miss the timing? Ahh, i checked and you have integrated a RTC with battery backup. Excellent.
-Have you planned a feature that appears in some light controllers (some Steinels for example) where you can define a period during the night when the lights are off? Sometimes you only want the lights on to make moving in the dark easier during late evening and early morning, and sometimes you want to keep the lights on through the night to make the premises less inviting to undesirable visitors.
-You maybe had something abut it in your web page, but an auxilary feature might be handy to e.g. signal an entry gate closure when the lights go on in the evening and again opening when the lights go off in the morning. OK, i checked again and you have this Xmas light control feature. Same thing.

A couple of observations about the physical construction:
-You have a fuse in the power circuit controlled by the relay. This is good. Although the supply wiring is of course supposed to be fused in the panel where this device is powered from. But the fuse there might be rated much higher that the relay you have on board the device (it was 10 amps, right?)

-You have taken steps to protect the mains input to the AC adapter embedded in the device housing. 2 things come to mind here: the wall plug prongs are obviously dangerous as they are exposed with mains voltage on them. You have protected those with tape and it is of course better than nothing (are the prongs actually there still?). I would have considered tearing the casing away and just soldering the mains wires directly on board. Then fix a simple piece of plastic (polycarbonate or similar nonflexing stuff) in front to keep fingers out and that would take care of safety. Of course all of this is inside the main plastic eclosure but that is anyway what i would have considered.

-A good practice is to plan the internal layout so as to avoid physically mixing signals and mains wiring. That means the signaling modules will be kept separate from those handling line voltages, and the signal and power wires don't share any routing, openings, bundles etc.
This is largely in order but i would pay attention to what happens when you close the enclosure. It looks like the mains voltage wiring that exits from the bottom will be in direct physical contact with the display board on the front cover of the enclosure. That would be a no-no. Conceivably there is the possibility that sharp cut edges of wires soldered on the board could chafe through the line voltage wiring causing the display board to jump to line potential. Probably won't happen here but i suggest you get into the habit of designing this kind of thing away during layout design phase. Anyway, it is a lesson best learned in theory because the practical demonstration can be somewhat dramatic.

-As it is this enclosure is suitable for indoors mounting. While that works, outside lights need to have their supply cables to eventually exit the house. Unless you have the house wiring prepared this way, there is a need to decide how you will arrange the wiring. Where i live, sockets for outside power are commonly available in the entry panel to the house (on the outer wall, i.e. outside the house). It is a simple matter to plug the timer there and then wire to the lamps. But this way everything is outdoors and this enclosure is not suitable for that.
Of course it is purely a practical implementation question but this kind of installation precludes the use of IEC style sockets and USB openings since they are not waterproof. Maybe not relevant to you at all in your application, but will be in many installation scenarios.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Arduino Astronomical Clock for Automatic Light Control
« Reply #2 on: November 11, 2013, 03:40:12 pm »
Hi Kremmen,

Thanks for your feedback. You make some very good points. The battery backup is already handled by the RTC battery cell as you noted. I actually tested that quite a bit and worked well...
Good idea regarding soldering the AC input directly to the AC adapter pcb board instead of the tabs (what I did in this case). The isolating tape protects somehow, but your approach would be more robust.
I definitely do not recommend exposing this system to the elements/outdoors. I'm lucky enough that in my application the box sits in an enclosed space, protected from the elements. If someone wants to use this outdoors, then I would recommend a very different, weather sealed enclosure. I would also worry about the Arduino temperature range etc, depending on how "extreme" your climate is :)

Thanks again for your comments/suggestions,

Paulo
Paulo
Professional Tinkerer,
www.paulorenato.com
 

Offline VintageTekFan

  • Regular Contributor
  • *
  • Posts: 82
  • Country: us
Re: Arduino Astronomical Clock for Automatic Light Control
« Reply #3 on: November 12, 2013, 04:32:01 pm »
I made a code block for an Industrial PLC that does a similar function, calculating sunrise and sunset.

One issue I ran into was the limited precision of an IEEE-754 float value, which was throwing the calculation off by up to 15 minutes.  I ended up keeping some offsets out to keep the relative precision of the numbers in the same magnitude, but I was limited to 32bit float values.

Unfortunately, after some quick research, Arduinos allow for the Double float, but only in name, as it defaults to a 32bit float anyway.  I'm sure there is a library for that, however, that would expand it.
The three laws of thermodynamics:
1. You can't win.
2. You can't even break even.
3. You can't get out of the game.
 

Offline prenatoTopic starter

  • Regular Contributor
  • *
  • Posts: 116
  • Country: us
    • paulorenato.com
Re: Arduino Astronomical Clock for Automatic Light Control
« Reply #4 on: November 12, 2013, 04:52:27 pm »
Hi VintageTekFan,

I used the "TimeLord" library. According to the author's documentation online, it is accurate to about 5 minutes. Not sure if other users can confirm that. Another source of inaccuracy (perhaps greater?) is the RTC oscillator. If you assume say, a 10 ppm accuracy, that can amount to close to 5 minutes a year... There's a better RTC out there based on a DS3231 temperature compensated RTC from Maxim that is much more accurate (google "chronodot") .  I toyed with the idea of using this chip but the added expense didn't seem justified for this application. One of the reasons I added the +/- time adjustment buttons was so I could easily adjust the time once in a while if needed (without having to re-program the RTC via USB). Literally, "time will tell" how accurate the whole thing is ;)
Paulo
Professional Tinkerer,
www.paulorenato.com
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf