RANet Cloud and Lightning

Do you have a question on how to do something.
Ask in here.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

Screenshot 2015-02-05 14.24.00.png
Screenshot 2015-02-05 14.24.00.png (119.53 KiB) Viewed 6384 times
rebooting reef angel controller
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

Are you using MacOSX?
Let's enable verbose. I think it must be disabled.
File->Preferences
Check "upload" in "Show verbose output during"
Upload again. It should show a bunch of stuff now.
I just want to make sure that it is indeed being uploaded.
Does it show "Done uploading" or "Error uploading"?
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

Code: Select all

# | 100% 2.44s

avrdude: verifying ...
avrdude: 7262 bytes of flash verified
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

Yeap. It is confirmed that it has been uploaded then.
No error was generated, which is good.
So, I'm not so sure why this is not working for you.
Everything is just pointing out to "it should work".
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

Here is video of only channel one taken after the last upload
https://www.youtube.com/watch?v=AGVO2QumTa0

I just attempted to change it to only do the lighting on channel 2 by changing the code

From this

Code: Select all

if (!FireInTheHole)
{
  ReefAngel.PWM.SetChannel(1,DaylightPWMValue);    // Whites are on channel 1
  ReefAngel.PWM.SetChannel(2,DaylightPWMValue);    // and channel 2
}
To this

Code: Select all

if (!FireInTheHole) ReefAngel.PWM.SetChannel(2,DaylightPWMValue);    // Whites are on channel 2
I was not able to get lightning on channel 2
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

I don't think the code you changed would change the lightning channel.
The lightning is handled in the receiver code.
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

so this would be changed to 0x16?

Code: Select all

 Wire.write(0x8+(4*1));             // 0x8 is channel 0, 0x12 is channel 1, etc.  I'm using channel 1.
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Cloud and Lightning

Post by cosmith71 »

No, that would ONLY flash on channel 2.

Was that line in the code you uploaded? If so, it's not the correct code. That line is different in the updated version.

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

Re: RANet Cloud and Lightning

Post by jegillis »

I'm just trying to figure out why my mine is not working. Could it be a problem with the dimming channel itself?
Image
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

cosmith71 wrote:No, that would ONLY flash on channel 2.

Was that line in the code you uploaded? If so, it's not the correct code. That line is different in the updated version.

--Colin
I was proposing to change it to flash only on channel 2 and see if it was an issue with the channel.


EDIT* the line of quoted code is in all three versions posted here as far as I can tell
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Cloud and Lightning

Post by cosmith71 »

What kind of drivers on your LED's? From that video it looks like they are a slow response type which don't work well with lightning effects. That could very well be the problem. Check the video in the second post. That's what it's supposed to look like.

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

Re: RANet Cloud and Lightning

Post by jegillis »

Im using the RANet as the driver which I desired to use instead of the meanwell drivers for the better response.
Last edited by jegillis on Thu Feb 05, 2015 3:01 pm, edited 1 time in total.
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Cloud and Lightning

Post by cosmith71 »

jegillis wrote: EDIT* the line of quoted code is in all three versions posted here as far as I can tell
Here's that section. It was changed to Wire.write(0x8+(4*n)).

Code: Select all

 for (int n=1; n<3; n++)
    {
      int newdata=4095;
      Wire.beginTransmission(0x40);      // Address of the dimming expansion module
      Wire.write(0x8+(4*n));             // 0x8 is channel 0, 0x12 is channel 1, etc.  I'm using channel 1.
      Wire.write(newdata&0xff);          // Send the data 8 bits at a time.  This sends the LSB
      Wire.write(newdata>>8);            // This sends the MSB
      Wire.endTransmission();
    }

    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

    // Flash off
    for (int n=1; n<3; n++)
    {
      int newdata=0;
      Wire.beginTransmission(0x40);    // Same as above
      Wire.write(0x8+(4*n));
      Wire.write(newdata&0xff);
      Wire.write(newdata>>8);
      Wire.endTransmission();
    }
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

cosmith71 wrote:
jegillis wrote: EDIT* the line of quoted code is in all three versions posted here as far as I can tell
Here's that section. It was changed to Wire.write(0x8+(4*n)).

Code: Select all

 for (int n=1; n<3; n++)
    {
      int newdata=4095;
      Wire.beginTransmission(0x40);      // Address of the dimming expansion module
      Wire.write(0x8+(4*n));             // 0x8 is channel 0, 0x12 is channel 1, etc.  I'm using channel 1.
      Wire.write(newdata&0xff);          // Send the data 8 bits at a time.  This sends the LSB
      Wire.write(newdata>>8);            // This sends the MSB
      Wire.endTransmission();
    }

    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

    // Flash off
    for (int n=1; n<3; n++)
    {
      int newdata=0;
      Wire.beginTransmission(0x40);    // Same as above
      Wire.write(0x8+(4*n));
      Wire.write(newdata&0xff);
      Wire.write(newdata>>8);
      Wire.endTransmission();
    }

Ok I see that now. Are you running drivers separate from the RANet?
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Cloud and Lightning

Post by cosmith71 »

Yes, I'm using the RANet dimming expansion with LDD drivers. Roberto can chime in, but I think the RANet LED drivers should work as well.

Do you just get the slow blink as in your video?

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

Re: RANet Cloud and Lightning

Post by jegillis »

cosmith71 wrote:Yes, I'm using the RANet dimming expansion with LDD drivers. Roberto can chime in, but I think the RANet LED drivers should work as well.

Do you just get the slow blink as in your video?

--Colin
Yes I am using the RANet led drivers and I just get the slow blink
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

Do they ramp up and down as they should on the slope or parabola?
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

rimai wrote:Do they ramp up and down as they should on the slope or parabola?

Yes they do, channel 2 even dims with the cloud it just doesn't flash.


What drivers are used? Should the response be better than what was in my video on the channel 1 that is working?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

No, your video is showing a mediocre effect at best.
It is much faster than that.
Here is a video of the code posted below:
http://forum.reefangel.com/viewtopic.php?p=41050#p41050

Upload this code and connect LEDs to channel 2.
Do you get similar effect?

Code: Select all

#include <Wire.h>
#include <avr/eeprom.h>

#define BLUE_LED    9
#define WHITE_LED   10

#define BLUE_INTENSITY   255
#define WHITE_INTENSITY  255

#define RANET_MAX_SIZE  64
#define DISCONNECT_TIMEOUT  2000

#define LastFallback0  100 // Memory location for fallback storage

#define RANet_Down    0
#define RANet_OK      1

byte buffer_index;
byte buffer[128];
char buf[3];
byte bufint, bufsize;
byte RANetData[RANET_MAX_SIZE];
byte RANetCRC;
byte BlueChannel=0;
byte WhiteChannel=0;
byte RANet_Status=RANet_Down;
boolean cable_present=false;

unsigned long lastmillis=millis();
unsigned long lastcablecheck=millis();
int newdata;

void setup()
{
  pinMode(BLUE_LED,OUTPUT);
  pinMode(WHITE_LED,OUTPUT);
  Serial.begin(57600);
  Wire.onReceive(NULL);
  Wire.onRequest(NULL);
  Wire.begin();
  for (int a=0;a<RANET_MAX_SIZE; a++) // Clear array
    RANetData[a]=0; 
  Wire.beginTransmission(0x68);
  Wire.write(0);
  int a=Wire.endTransmission();
  cable_present=(a==0);
  // setup PCA9685 for data receive
  // we need this to make sure it will work if connected ofter controller is booted, so we need to send it all the time.
  Wire.beginTransmission(0x40);
  Wire.write(0);
  Wire.write(0xa1);
  Wire.endTransmission();
  newdata=4095;
  Wire.beginTransmission(0x40);
  Wire.write(0x8+(4*0));
  Wire.write(newdata&0xff);
  Wire.write(newdata>>8);
  Wire.endTransmission();
  newdata=2048;
  Wire.beginTransmission(0x40);
  Wire.write(0x8+(4*1));
  Wire.write(newdata&0xff);
  Wire.write(newdata>>8);
  Wire.endTransmission();
  
}

void loop()
{

  int a=random(5);
  for (int i=0;i<a;i++)
  {
    newdata=4095;
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*2));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    delay(20+random(50));
    newdata=0;
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*2));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    delay(30+random(20));
  }
  delay(random(1000));
}

void UpdateWhiteChannel()
{
  WhiteChannel=sin(radians((millis()%7200)/40))*255;
  BlueChannel=255-(sin(radians((millis()%7200)/40))*255);
  analogWrite(WHITE_LED,WhiteChannel);
  analogWrite(BLUE_LED,BlueChannel);
}
//00301200000000000000050000000000000000000000000047
//01301200000000000000050000000000000000000000000048
//02301200000000000000050000000000000000000000000049
//0330120000000000000005000000000000000000000000004a
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

That worked the way it should

https://www.youtube.com/watch?v=90Sk-sqA0DU
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Cloud and Lightning

Post by cosmith71 »

That's how it's supposed to look! What do you think the problem is, Roberto?

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

Re: RANet Cloud and Lightning

Post by rimai »

Looks awesome!!!
We just need to figure out what's up with the code or module.
Let's do this for all channels, so you can see if any channel is not responding well.
The code below should cause the strikes on all 3 of your channels.

Code: Select all

#include <Wire.h>
#include <avr/eeprom.h>

#define BLUE_LED    9
#define WHITE_LED   10

#define BLUE_INTENSITY   255
#define WHITE_INTENSITY  255

#define RANET_MAX_SIZE  64
#define DISCONNECT_TIMEOUT  2000

#define LastFallback0  100 // Memory location for fallback storage

#define RANet_Down    0
#define RANet_OK      1

byte buffer_index;
byte buffer[128];
char buf[3];
byte bufint, bufsize;
byte RANetData[RANET_MAX_SIZE];
byte RANetCRC;
byte BlueChannel=0;
byte WhiteChannel=0;
byte RANet_Status=RANet_Down;
boolean cable_present=false;

unsigned long lastmillis=millis();
unsigned long lastcablecheck=millis();
int newdata;

void setup()
{
  pinMode(BLUE_LED,OUTPUT);
  pinMode(WHITE_LED,OUTPUT);
  Serial.begin(57600);
  Wire.onReceive(NULL);
  Wire.onRequest(NULL);
  Wire.begin();
  for (int a=0;a<RANET_MAX_SIZE; a++) // Clear array
    RANetData[a]=0; 
  Wire.beginTransmission(0x68);
  Wire.write(0);
  int a=Wire.endTransmission();
  cable_present=(a==0);
  // setup PCA9685 for data receive
  // we need this to make sure it will work if connected ofter controller is booted, so we need to send it all the time.
  Wire.beginTransmission(0x40);
  Wire.write(0);
  Wire.write(0xa1);
  Wire.endTransmission();
}

void loop()
{

  int a=random(5);
  for (int i=0;i<a;i++)
  {
    newdata=4095;
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*0));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*1));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*2));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    delay(20+random(50));
    newdata=0;
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*0));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*1));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*2));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    delay(30+random(20));
  }
  delay(random(1000));
}

void UpdateWhiteChannel()
{
  WhiteChannel=sin(radians((millis()%7200)/40))*255;
  BlueChannel=255-(sin(radians((millis()%7200)/40))*255);
  analogWrite(WHITE_LED,WhiteChannel);
  analogWrite(BLUE_LED,BlueChannel);
}
//00301200000000000000050000000000000000000000000047
//01301200000000000000050000000000000000000000000048
//02301200000000000000050000000000000000000000000049
//0330120000000000000005000000000000000000000000004a
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

that worked on all the channels and they all flashed together.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

Ok, so we confirmed that it is nothing related to the channels.
It's got to be the code.
I'll have to look at it again.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

Ok, so here is what I found out what is happening.
I think the lightning is too short to be noticed.
It's at less than 1 second with the code you posted. I think that's why you think nothing is happening.
How long do you want to have it going on?
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

What you had posted for the test look pretty realistic in terms of the flash but a little to often and not random. Would the trigger be sent to much? I notice the trigger being sent several times per actual flash

Instead should it be sent no more than once per second then the receiver code chooses a random number of flashes per trigger?


I have no idea how to do any of this just thinking out loud...

And would that explain why channel 2 is not working?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

I think your idea is the correct path.
We should just send the trigger once and let the receiver choose the random number of flashes, but what is a good number of flashes? and how long should the entire lighting duration be in order to be realistic looking?
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

Could an variable be set as to how long the duration can be or a min and max so that we can play with it as it is right now for example the duration of a storm is set in my code to be random between 7 and 15 minutes?

If I had to pick a number though it would be 15 minutes for the duration

As for the amount of flashes it looks good as it operates on Colin's but would not necessarily want lightning with every cloud.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Cloud and Lightning

Post by rimai »

For sake of making it simple to use, I think we should lock it to a fixed random duration.
What do you think of a random duration from 5 to 10 seconds?
The trigger mechanism is actually changed already by cosmith71 in the new libraries.
He made it so it is only sent once.
In other words, your code that you haven't even used yet is already deprecated :( lol
I already merged it this morning and pushed it to our github repository, so if you want to help us test this new mechanism, we should get you in the newest dev libraries. This way, you will already have your libraries and code updated and won't have to change your code again when we release the libraries.
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: RANet Cloud and Lightning

Post by jegillis »

No problem I will get it switched over as soon as I clean up an orange juice spill.

So lightning would always happen in a cloud for between 5 & 10 seconds?

Personally given that choice I would rather have the lightning random throughout the cloud and not have as many clouds. The point would be as realistic to a storm as possible but mostly just to show off my controller.
Image
Post Reply