Re: RANet Cloud and Lightning
Posted: Thu Feb 05, 2015 12:21 pm
rebooting reef angel controller
Community discussion about Reef Angel Controllers and reefing related subjects
https://forum.reefangel.com/
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.
Code: Select all
if (!FireInTheHole)
{
ReefAngel.PWM.SetChannel(1,DaylightPWMValue); // Whites are on channel 1
ReefAngel.PWM.SetChannel(2,DaylightPWMValue); // and channel 2
}
Code: Select all
if (!FireInTheHole) ReefAngel.PWM.SetChannel(2,DaylightPWMValue); // Whites are on channel 2
Code: Select all
Wire.write(0x8+(4*1)); // 0x8 is channel 0, 0x12 is channel 1, etc. I'm using channel 1.
I was proposing to change it to flash only on channel 2 and see if it was an issue with the channel.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
Here's that section. It was changed to Wire.write(0x8+(4*n)).jegillis wrote: EDIT* the line of quoted code is in all three versions posted here as far as I can tell
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();
}
cosmith71 wrote:Here's that section. It was changed to Wire.write(0x8+(4*n)).jegillis wrote: EDIT* the line of quoted code is in all three versions posted here as far as I can tell
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(); }
Yes I am using the RANet led drivers and I just get the slow blinkcosmith71 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
rimai wrote:Do they ramp up and down as they should on the slope or parabola?
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
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