Weather Simulation for Dimming expansion module

Share you PDE file with our community

Posts: 12471
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Wed Jun 27, 2012 11:26 am
No need to change anything in the code.
The convertion is done by hardware components.
Roberto.

Posts: 293
Joined: Tue Oct 25, 2011 7:39 am
PostPosted: Wed Jun 27, 2012 11:43 am
AWESOME! Thanks!

Posts: 65
Joined: Fri May 25, 2012 12:22 am
PostPosted: Thu Jun 28, 2012 1:03 am
rufessor wrote:But... if your asking... could the PWM module comm to the controller to tell it there is a storm... causing the controller to tirgger a storm mode for wavemaker functionality.... thats EXACTLY what I am working on now. So if thats the Q... Absolutely yes 100% will work. BUT ITS NOT ENABLED NOW. I will post new code here with comm when its fully fleshed out on the development thread where I have a few people sacrificing their systems to help me test this code on multiple builds... when we get it all figured out I will update the tutorial and post the code here.

Yes that is EXACTLY what I'm looking for :) I have analog dimmers on my main so I intend to plug that into Tunze streamers. Would be sweet if the weather could trigger different states of the pumps (ofcourse without overriding feed mode, night mode etc). I'm gonna head over to the dev thread and read up some more on your Weather sim.

Posts: 293
Joined: Tue Oct 25, 2011 7:39 am
PostPosted: Thu Jun 28, 2012 7:14 am
One word of caution on the development thread.... I started that with a vague idea that I wanted to use latitude and longitude to calculate sunrise but I had never coded in c++ before so its FILLED with starts, stops, errors, mis-statements, and most of all.... BAD code :lol: If your want to know what its doing in terms of where its at today the tutorial is *much* better and informative. If you want to watch, in slow motion, the train wreck of learning C++ and working on an increasingly complex project spread over 20 pages- its all there. Just beware that much of the first 1/2 of that thread is just me finding my way with no real clear idea what I was working on other than to learn C++ and get a library working that someone else wrote and that we ended up deciding was very good but not needed as a "library" so I just stuck the required code in the .INO rather than having to distribute .h and .cpp files... so IGNORE completely that part of the discussion.

Finally- to everyone... can you let me know how close your tank lights (those with a ZERO ChOffset) rise and set to the real sun. My tank was running within literally a minute or two and lately its more like 5-10 minutes... I know the functions error can be somewhat significant and this error increases with latitude and day length... so for me were at the ABSOLUTE MAX day length of the year and I suspect its just the same 1-2% error but instead of a 40,000 second day its so much longer that it just is more obvious.

Posts: 50
Joined: Sun Mar 18, 2012 8:22 pm
PostPosted: Thu Jun 28, 2012 8:55 pm
Ok I have my code for the lights ready to go, but I have not yet implemented it because I am not sure on how to set up the fans and drivers? Currently I have them set to come on when my lights come on through the "standard lights" channel on my 8 outlet RA box, but since with this code I am guessing that time will change daily is there a way to program the outlet to come on/off when it is "Sunrise"/ "Sunset" as I don't really want/ need my drivers or fans running 24/7

Posts: 293
Joined: Tue Oct 25, 2011 7:39 am
PostPosted: Fri Jun 29, 2012 7:32 am
I am going to assume your North of the equator and thus your day length is now at or very near its maximum. Until I get the comm module up, which would then allow your head unit to see that the lights are on and automatically turn on the fans (this should be like 3 lines of code on the Head unit).... what I would do is just instruct the head unit to turn on the fans at your local sunrise corrected to the earliest offset you have running and turn off after sunset + the latest offset you have running. Then... as we move to fall your fans will come on increasingly earlier than the lights but its no big deal... and really- the Comm should be fairly easy to implement and I was hoping to get some time on that this weekend (doubt its that fast... but it really should not take very long all the code to do this exists and I have expert help).

This will get your lights up on the new code and ensure they stay cool.. I need to get this working for myself as my fans have been on 24/7 for a few months now (but really... they are case fans for a computer and this is pretty normal for them). The other option is just to leave them on (if this is easier) I doubt it will matter one iota as we should have comm up very soon.


Curious... did you use the tutorial and did it have enough information to do this configuration easily? Does it make sense?

Posts: 50
Joined: Sun Mar 18, 2012 8:22 pm
PostPosted: Sat Jun 30, 2012 9:19 pm
rufessor wrote:I am going to assume your North of the equator and thus your day length is now at or very near its maximum. Until I get the comm module up, which would then allow your head unit to see that the lights are on and automatically turn on the fans (this should be like 3 lines of code on the Head unit).... what I would do is just instruct the head unit to turn on the fans at your local sunrise corrected to the earliest offset you have running and turn off after sunset + the latest offset you have running. Then... as we move to fall your fans will come on increasingly earlier than the lights but its no big deal... and really- the Comm should be fairly easy to implement and I was hoping to get some time on that this weekend (doubt its that fast... but it really should not take very long all the code to do this exists and I have expert help).

This will get your lights up on the new code and ensure they stay cool.. I need to get this working for myself as my fans have been on 24/7 for a few months now (but really... they are case fans for a computer and this is pretty normal for them). The other option is just to leave them on (if this is easier) I doubt it will matter one iota as we should have comm up very soon.


Curious... did you use the tutorial and did it have enough information to do this configuration easily? Does it make sense?


Well, no rush for me on the comm, I managed to knock out my blues on 2 of 3 panels (the two I haven't already replaced lol), so I am waiting on uploading this code and making any other changes anyways until I can get the new ones and replace them... however I did follow the tutorial and get the code set (before my mishap) and ready to be implemented and it was straightforward and easy to follow! And thats coming from a guy who has 0 coding knowledge! I left the code at the Utah location as I figure it will give me a later rise/set and I like to run my lights late (they currently shut off at 11:59 pm ;) ).

Thanks for taking the time to not only get this put together but for taking the time to explain it as well! I can't wait to actually get to see it in action lol
User avatar
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa
PostPosted: Sun Jul 01, 2012 10:17 am
This code has nw been runningin my tank for over a month, and I must say its the best natural light simulation I have seen to date.

The YouTube video woth the lightning and clouds is on my tank, and even my crals look healtier with the natural sunrise/sunset.

I must agree, taking the time to set this up is no small ting, if there were award buttons or something i'd click it a few times!

Posts: 293
Joined: Tue Oct 25, 2011 7:39 am
PostPosted: Mon Jul 02, 2012 10:29 am
Thanks! Glad its working out and your liking the effects.


With respect to using a different latitude and longitude to achieve a day length that is offset from your local times. Lets say you live in New York City and your time zone is 4 hours ahead of someone living off the coast of california.... so you input their latitude and longitude and expect that the sun would then rise at 11 am local to you (because that would be the correct time for it to rise at 7 am over the eastern pacific using their local time)... seems like this is how it would work. But ITS NOT.

I correct all times such that the local rise and set time of any latitude and longitude on the planet is converted to your local time. E.G. If its supposed to rise at 8 am and set at 10 pm (in local time for the latitude and longitude you entered) its going to rise and set at 8 am and 10 pm according to YOUR clock. This makes it VERY EASY to get the yearly day length variation you desire for your tank without having to convert time zones. It makes it impossible to do what you had asked. Trust me when I say that you do NOT want to try messing with all the conversions to get it to do what you want... its just too hard and then we could only realistically use locations very close to our house. This way, we can use anywhere on the planet and its like you actually MOVED there and are living at that point using your local times as their local times.

To make it rise or set later in the day, just use the ChOffset array and add 3 hours (or whatever to all the values)... this is the only way to shift the day... but its also very easy.

ONE THING. The DAY ends or starts (depending on how you look at it) at MIDNIGHT. So... if you use ChOffset values to push sunset past midnight... it aint gonna work. At MIDNIGHT, a new day worth of rise and set times are calculated and everything starts again. So, at 12:01 am, its going to see that the sun is not yet risen and your tank will go dark regardless of the fact that you may have told it to set 5 hours late which should have been 1 am... its a new day and all calculations are reset. I keep track of time ONLY as elapsed seconds since the new day... so if your set value is greater than 84600 (24 hours) the counter will RESET to ZERO at midnight and the tank will go immediately dark (or to MoonPhase lighting) and wait for the elapsed seconds to count up to the rise time... and then rise... and then when midnight hits again... rinse and repeat.

The ONLY way you could know that your set value was greater than 84600 is to put in some serial debugging and figure it out... or (much easier) simply look up what the local rise and set times are for the latitude and longitude you choose, check what the LATEST set time is for the year and make sure that your ChOffset does not push that value to greater than 24 hours for ANY channel.

The even easier way to know this is when I get the serial comm up and you can display rise and set for every channel given the offset you used, on the main... but I am kinda trying to figure out if we have enough room to do this... cause with 8 channels that pretty much maxes out the portal in terms of custom display... and if we use all 8 for individual channel values we cannot do cool stuff like tell us if its currently cloudy, stormy, a severe storm, tell us how many clouds are left, etc etc... so I am working on kinda coming up with the optimal 8 things to show. Probably we will end up with Rise (actual calculated), Set, #Clouds Remaining, is Storm (yes/no), is SevereStorm (yes/no), MoonPhase, and then probably some way of MAKING a cloud or a storm on demand.

I think people will probably want different things... so I will get together the stuff I WANT... and release the code when its working for me. I will release the .INO for my controller (relevant display and comm parts) and the .INO for the dimming module. My guess is that you will want it to be different than mine... so that part will be up to you, but I should be able to provide a working frame work. When we get there... I am going to have to back off a tiny bit in terms of helping people customize this as its also new to me... so if your going the custom route just realize that your in fact going to have to work it out. I am sure that help will come if your post questions but once we get there, people with far more experience than I in terms of integrating wave makers with a storm etc will have to chime in cause I will just cause confusion and delay at that point. It appears that we will have a decent number of users some assuredly have experience here that I lack.
Last edited by rufessor on Mon Jul 02, 2012 9:55 pm, edited 1 time in total.

Posts: 293
Joined: Tue Oct 25, 2011 7:39 am
PostPosted: Mon Jul 02, 2012 2:15 pm
One quick proviso...

I *think* this is working as intended.. the whole part about converting everything to local times... but please LET ME KNOW if things are acting weird. I got it working and heard from others in very different locations that it was working... so I would bet its 100% robust but I would not bet much :mrgreen:

Finally- I edited the tutorial to include a more condensed (and perhaps even easier to understand) summary of the above discussion. Please re-read that if your *at all* confused about how the Lat Lon calculations are set up. Its actually easy, everything gets converted to YOUR TIME. But its all there in the tutorial now.
PreviousNext

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 1 guest