Cloud and Lightning Code

Do you have a question on how to do something.
Ask in here.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

I've been working on some upgrades to the lightning engine. Stay tuned!

--Colin
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

Update to OP

Improved lightning engine.

New option for increased Mega Lightning.

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post by lnevo »

Cool, but by making the rate a define, we can't modify it on the fly through mem or variable changing. So, let's get away from using #defines for this... :) At some point I'll be making them all properties of the Cloud class.

My recommendation though would be to make it a separate mode... so Mega1 Mega2. This way we maintain one variable to choose which mode we want. Very cool updates though, keep em coming...
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

lnevo wrote:Cool, but by making the rate a define, we can't modify it on the fly through mem or variable changing. So, let's get away from using #defines for this... :) At some point I'll be making them all properties of the Cloud class.

My recommendation though would be to make it a separate mode... so Mega1 Mega2. This way we maintain one variable to choose which mode we want. Very cool updates though, keep em coming...
Done. Went with Mega and Mega2, since Mega1 looks like Megal. :mrgreen:

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post by lnevo »

Did you see that chalice encrusted on the Megaladon tooth? :)
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

New mode:

Calm

No lightning at all. Good for putting into a random sequence so there isn't lightning every time there is a cloud. OP updated.

--Colin
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: Cloud and Lightning Code

Post by jegillis »

Is there a version of this code for the dimming expansion?
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

No. I'm sure it could be adapted, but I don't have a dimming expansion. :(

--Colin
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

RANet dimming expansion on the way! :D

Lee, have you done any work on putting this into a library? If not, I may start as a learning experience.

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post by lnevo »

I haven't had time yet.. feel free to give it a try and I can certainly help :)
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

Awesome! I've always thought that the best way to learn something was to do it. I'm sure I'll have questions.

--Colin
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Cloud and Lightning Code

Post by rimai »

The lightning will have to be incorporated in the slave side. The cloud should be fine.
The RANet bandwidth is not fast enough.
It sends data every 100ms.
Roberto.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

rimai wrote:The lightning will have to be incorporated in the slave side. The cloud should be fine.
The RANet bandwidth is not fast enough.
It sends data every 100ms.
Slave side? Esplain please.

--Colin
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Cloud and Lightning Code

Post by rimai »

Every RANet-Ready Wireless Module has a microcontroller in it to receive and process the wireless data.
The current firmware can only process data for relays and dimming channels.
We will need to create a firmware that can accept commands, so you can trigger remotely.
For example, a command to trigger the lightning effect on the dimming module.
You are not the only one that will want this.
The person using the dimmable LED driver wants this too.
I just need to find some time to put something together, but I'd like to release the next libs first.
The RANet requires some changes on the core libraries released from Arduino, specifically the SoftwareSerial library and I'd like to have at least the base communication working and released before we start adding functionality to it.
We have been getting some help from Sacohen, lnevo, AlanM, binder and others to see if any other minor bug is found.
Hopefully, we get a release soon.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Cloud and Lightning Code

Post by rimai »

I updated the previous post.
I meant to say RANet-Ready Wireless Module and not RANet-Add On.
Roberto.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

Ah, I see. Load the sequence and then trigger when needed. I understand.

--Colin
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: Cloud and Lightning Code

Post by jegillis »

And I thought that just coding this for the dimming expansion would work. I don't know how to code much of anything but would be happy to test anything you come up with.
Image
TheMikey
Posts: 4
Joined: Wed Sep 25, 2013 9:15 am

Re: Cloud and Lightning Code

Post by TheMikey »

I feel like a bit of an idiot, but I can't seem to find this line:

byte LightningModes[] = { Slow, Fast, Mega };

To even start this programming. Is there an updated full code I need to find somewhere before attempting to customize this?
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

The updated code is in the first post.

Do a search for this:

Code: Select all

 byte LightningModes[] = { Mega, Mega, Mega2, Calm, Calm };
And change it to your liking.

--Colin
TheMikey
Posts: 4
Joined: Wed Sep 25, 2013 9:15 am

Re: Cloud and Lightning Code

Post by TheMikey »

Found it! Thanks!
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Cloud and Lightning Code

Post by TanksNStuff »

Has anyone had any luck modifying this code to work on the dimmer expansion module yet?

I'm getting ready to redo my entire coding for my tank upgrade and was hoping to incorporate clouds/lightning.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post by lnevo »

Not yet
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

Is there a way to write values directly to the dimming expansion? That's key. Otherwise it won't be fast enough for the right effect.

--Colin
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Cloud and Lightning Code

Post by rimai »

Actually the wired dimming has a fast enough connection. The wireless one is the one that doesn't.
Roberto.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Cloud and Lightning Code

Post by TanksNStuff »

Lee, is that because you haven't had time to try or because you ran into issues/errors that still need to be worked out? If it's simply a matter of changing just the PMWValue variables, maybe I'll try to take a stab at it.

In fact, I'll take a look at it now and see if I can figure it out. I'll report back here if I get it working.

I have wired connection dimmer expansion, so I should be good to go.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

The obstacle is here, in the analogWrite statement. That bypasses the RA libraries to write directly to the daylight pin. It's the only way to get fast enough flashes.

Code: Select all

 int a=random(1,5);    // Pick a number of consecutive flashes from 1 to 4.  
          for (int i=0; i<a; i++)
          {
            analogWrite(daylightPWMPin,random(DaylightPWMValue*2.55,255));    // Flash on
            int randy=random(20,80);    // Random number for a delay
            if (randy>71) randy=((randy-70)/2)*100;    // Small chance of a longer delay
            delay(randy);                // Wait from 20 to 69 ms, or 100-400 ms
            analogWrite(daylightPWMPin,DaylightPWMValue*2.55);      // Flash off
            delay(random(30,50));                // Wait from 30 to 49 ms 
            wdt_reset();
          }
If you want to convert it, you'd need to find an equivalent way to write to the expansion module.

--Colin
JTMBTech
Posts: 6
Joined: Fri Feb 28, 2014 9:11 am

Re: Cloud and Lightning Code

Post by JTMBTech »

Sorry if this is a dumb question. Can i use this code to add lightning and cloud to my main white and actinic channels with the output from the relay box dimming ports, and then use the channels 0-3 on dimming expansion (using 4-5 for dc pumps) with the wizard generated code for the my other colored leds, green red uv and 2700k white? i have a diy led with steves led drivers and 6 different color leds over my 180 currently controlled by a typhoon. or would it not get the same effect because the other channels won't have the effect. I was hoping this might work because the main number of leds is white and actinic leds. i didnt realize when i ordered the dimming module and plus upgrade last week that the custom lighting codes had not been written for dimming module because the design had changed. I have very high hopes with the dimming module and just want to use my leds to their full potential! or is the code getting close to be finished for the new dimming module?
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Cloud and Lightning Code

Post by Sacohen »

From what I understand this code only works on the relay dimming channels, it hasn't be ported over to the dimming hub yet. So I will work on your white and actinic lights only.
The dimming channel 1-3 will be normal dimming only.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Cloud and Lightning Code

Post by rimai »

Colin has already ported and made it even better when used with the dimming module.
Let's have him pitch in
Roberto.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

It's ported to the RANet Dimming Expansion, but that code could be adapted. The issue noted a few posts above has been solved. It's just a matter of putting it all together.

I don't have a standard dimming expansion, so there may be some trial and error. I'll see if I can come up with something over the next week or so.

--Colin
Post Reply