Weather Library Beta

Related to the development libraries, released by Curt Binder
Post Reply
avionixx
Posts: 20
Joined: Thu Apr 25, 2013 10:12 pm

Re: Weather Library Beta

Post by avionixx »

Thanks for the reply and the clarification! I was confused on what to put there, however, even after I've changed it to the proper value (initially 62 for the clouds, and then I tried 255) I'm still not seeing the effect.

Personally, I think the current implementation for specifying which channels should be used for clouds and lightning is pretty standard, I tried rufessor's weather sim previously so there wasn't much of a learning curve.

EDIT: After setting both channels to 255, did notice all of the lights dim suddenly and then after a few minutes, the intensity ramped up (kinda choppily) to full brightness. Was that the cloud effect or something else?
thekameleon
Posts: 137
Joined: Sat Feb 16, 2013 7:44 am

Re: Weather Library Beta

Post by thekameleon »

Sounds like it... not sure on the choppily part. I will have to look at the transitions. I am using a reverse PWM slope and varying the time the transition between cloud and sun occur. The code is based off of rufessor's code, but I tried simplifying some of it, while adding the ability to have greater control of certain aspects such as transitions.

You said setting both channels to 255. do you mean the LightningChannel and CloudChannel properties?
avionixx
Posts: 20
Joined: Thu Apr 25, 2013 10:12 pm

Re: Weather Library Beta

Post by avionixx »

Yes, I set both the LightningChannel and CloudChannel to 255. I tried setting them to their appropriate values to my setup: PWM 0-4 for the clouds (byte value 62) and 2+4 for lightning (byte value 10) but never saw any effects with it.
thekameleon
Posts: 137
Joined: Sat Feb 16, 2013 7:44 am

Re: Weather Library Beta

Post by thekameleon »

Correct me if I am wrong but should the values be 31 and 20... For the clouds 1 + 2 + 4 + 8 + 16 for 0- 4 and 0 + 0 + 4 + 0 + 16 for lightning 2 and 4?... In my next release, I will make the Init<channel> functions automatically define the channels so we don't have to play with the binary values.

EDIT: OK just relooked at the code the actually does the cloud and it is similar to this:

Code: Select all

if (CloudChannels & 1 == 1 && WeatherPWM.DaylightPWMValue >= MinPWM.DaylightPWMValue) WeatherPWM.DaylightPWMValue = 
			ReversePWMSlope(cloudStart, cloudStart + cloudDuration, WeatherPWM.DaylightPWMValue, MinPWM.DaylightPWMValue, cloudTransition);
So Daylight and Actinic are the first and seconf bits then come the PWM Expansion modules. So PWM Channel 0 is actually the 3rd bit or byte 4.

Now someone please check this:

Code: Select all

CloudChannels & 8 == 8
Will that statement return true if the fourth bit is 1? I think it does, but please correct me if I am wrong.
avionixx
Posts: 20
Joined: Thu Apr 25, 2013 10:12 pm

Re: Weather Library Beta

Post by avionixx »

How do you test that? lol
thekameleon
Posts: 137
Joined: Sat Feb 16, 2013 7:44 am

Re: Weather Library Beta

Post by thekameleon »

In C# it works fine. I am still learning C++ though. It's not so much about testing it, as making sure I am trying to do the thing for the platform.
thekameleon
Posts: 137
Joined: Sat Feb 16, 2013 7:44 am

Re: Weather Library Beta

Post by thekameleon »

I would like some ideas on something... One of the challenges with the Weather Library is trying to figure out when clouds should happen and when they shouldn't.. For instance, if it is suppose to be 40% cloudy how do you distribute the clouds through out the day. It shouldn't be predictable, because nature is not (like 30 minutes for each hour), however it should be evenly distributed so all the cloud cover does not happen at once.

One idea, I had was to create a "pool" of minutes so if 20% of clouds are to happen that day there would be a pool of 288 minutes (24 hours x 60 minutes x 20%). Then when a cloud ended, I would subtract the amount of time the cloud occurred from the pool. Based on the duration of the cloud that just ended and the probability of clouds in this case 20%. I would slowly increase a number over time (subtracting 20% from 100% and then multiplying that by the last cloud duration, so if the duration was 10 minutes, it would be 4 times 10 or 40 minutes) Over this 40 minutes I would start from zero and slowly work back to 20. All along retesting to see if clouds should occur. I think this would allow for evenness and yet look natural

Thoughts? Or other ideas.
Amos Poh
Posts: 107
Joined: Sun Jul 22, 2012 4:51 am
Location: Singapore

Re: Weather Library Beta

Post by Amos Poh »

thekameleon wrote:Correct me if I am wrong but should the values be 31 and 20... For the clouds 1 + 2 + 4 + 8 + 16 for 0- 4 and 0 + 0 + 4 + 0 + 16 for lightning 2 and 4?... In my next release, I will make the Init<channel> functions automatically define the channels so we don't have to play with the binary values.

EDIT: OK just relooked at the code the actually does the cloud and it is similar to this:

Code: Select all

if (CloudChannels & 1 == 1 && WeatherPWM.DaylightPWMValue >= MinPWM.DaylightPWMValue) WeatherPWM.DaylightPWMValue = 
			ReversePWMSlope(cloudStart, cloudStart + cloudDuration, WeatherPWM.DaylightPWMValue, MinPWM.DaylightPWMValue, cloudTransition);
So Daylight and Actinic are the first and seconf bits then come the PWM Expansion modules. So PWM Channel 0 is actually the 3rd bit or byte 4.

Now someone please check this:

Code: Select all

CloudChannels & 8 == 8
Will that statement return true if the fourth bit is 1? I think it does, but please correct me if I am wrong.

Thank You so much for this! Question, do I have to manually add this to the library or will it be automatically updated when I startup my arduino ?
thekameleon
Posts: 137
Joined: Sat Feb 16, 2013 7:44 am

Re: Weather Library Beta

Post by thekameleon »

You have to add it manually, but it should be no more than copy and paste
Post Reply