How to code a Lights on feature
How to code a Lights on feature
I would like to code a lights on and add it to my simple menu. The only snag is I use the PWM expanision module to control my LEDs. I tried tonight to just change the time using client 2.2 to a time when the lights would normally be on but the time only changed in client and it didnt change on the RA and then I couldnt change the time back and I ran into a client lockup and had to reboot everything to make it.
If anyone has any quick ideas that would be great and the addition will have to be small in size because my current sketch uses about 28k out of 30k
Thanks in advance
Don
If anyone has any quick ideas that would be great and the addition will have to be small in size because my current sketch uses about 28k out of 30k
Thanks in advance
Don
Re: How to code a Lights on feature
Can a fixed PWM value be used?
I know you use the PWMSlope function.
We could use the internal memory for the standard channels as the value for when you override the lights on.
So, all you would need to do, is instead of using RA menu item, you would use the Client or built in server to mask the relay on, which would feed the power to the drivers and set PWM to whatever is stored on the internal memory.
Would that work?
I know you use the PWMSlope function.
We could use the internal memory for the standard channels as the value for when you override the lights on.
So, all you would need to do, is instead of using RA menu item, you would use the Client or built in server to mask the relay on, which would feed the power to the drivers and set PWM to whatever is stored on the internal memory.
Would that work?
Roberto.
Re: How to code a Lights on feature
As long as I could choice which function I would be using that would work for me. The PWMslope function works really well but the are times like tonight when i was doing tank maintance and the white LEDS went out and I was working under blue light which made it hard to see. One day soon I will have to try the optiboot for more memory so I can add more features. I made up the diy cable ive just been cautious about try to load the memory.
Re: How to code a Lights on feature
Try this code:
Place it after the slope, but before the PWMExpansion commands.
You can change the Port4 and LEDPWM0 in the code to match your setup.
Then, go to Client and use the Memory tab to change the Daylight PWM value.
Now, everytime you mask Port4, in this example, the LEDPWM0 channels of the PWM expansion module will output the value you set on the internal memory.
Let me know if it works.
Code: Select all
if ((ReefAngel.Relay.RelayMaskOn & (1<<Port4)) == (1<<Port4))
{
PWMChannel[LEDPWM0]=LEDPWMDaylight_read();
}
You can change the Port4 and LEDPWM0 in the code to match your setup.
Then, go to Client and use the Memory tab to change the Daylight PWM value.
Now, everytime you mask Port4, in this example, the LEDPWM0 channels of the PWM expansion module will output the value you set on the internal memory.
Let me know if it works.
Roberto.
Re: How to code a Lights on feature
If using this from the InternalMemory, you will probably need to make it:rimai wrote:Try this code:Code: Select all
if ((ReefAngel.Relay.RelayMaskOn & (1<<Port4)) == (1<<Port4)) { PWMChannel[LEDPWM0]=LEDPWMDaylight_read(); }
Code: Select all
InternalMemory.LEDPWMDaylight_read();
curt
Re: How to code a Lights on feature
Would I have to place this line into the command 6 times for each channel and just change it to match my channel names?? and would the command look something like this??
if ((ReefAngel.Relay.RelayMaskOn & (1<<Port7)) == (1<<Port7))
{
PWMChannel[WhitePWM1]=LEDPWMDaylight_read();
PWMChannel[BluePWM1]=LEDPWMDaylight_read();
PWMChannel[WhitePWM2]=LEDPWMDaylight_read();
PWMChannel[BluePWM2]=LEDPWMDaylight_read();
PWMChannel[WhitePWM3]=LEDPWMDaylight_read();
PWMChannel[BluePWM3]=LEDPWMDaylight_read();
if ((ReefAngel.Relay.RelayMaskOn & (1<<Port7)) == (1<<Port7))
{
PWMChannel[WhitePWM1]=LEDPWMDaylight_read();
PWMChannel[BluePWM1]=LEDPWMDaylight_read();
PWMChannel[WhitePWM2]=LEDPWMDaylight_read();
PWMChannel[BluePWM2]=LEDPWMDaylight_read();
PWMChannel[WhitePWM3]=LEDPWMDaylight_read();
PWMChannel[BluePWM3]=LEDPWMDaylight_read();
Re: How to code a Lights on feature
yes. you got it...
Make sure to change the function to what Curt has corrected me
I missed something.
Also, you can even you both internal memory channel settings to assign actinic and daylight values differently.
So, just like this:
Make sure to change the function to what Curt has corrected me
I missed something.
Also, you can even you both internal memory channel settings to assign actinic and daylight values differently.
So, just like this:
Code: Select all
if ((ReefAngel.Relay.RelayMaskOn & (1<<Port7)) == (1<<Port7))
{
PWMChannel[WhitePWM1]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM1]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM2]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM2]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM3]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM3]=InternalMemory.LEDPWMActinic_read();
}
Roberto.
Re: How to code a Lights on feature
Thanks Roberto and Curt
I will try it as soon as I get home tonight.
Don
I will try it as soon as I get home tonight.
Don
Re: How to code a Lights on feature
I placed the code in the in my skecth as in below.
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.StandardFan(Port4);
ReefAngel.StandardHeater(Port5);
ReefAngel.StandardHeater(Port6);
// Setup relay 7 to turn on at 06:00aM and off at 10:05PM
ReefAngel.StandardLights(7,11,45,22,05);
// Setup relay 8 to turn on at 18:00PM and off at 00:00AM
ReefAngel.StandardLights(8,18,0,00,00);
//This section calculates the slope
//calculate slope for 0 to 50% starting at 12:30pm with duration of 60min, then from 50% to 0 from 17:00pm with duration of 60min
PWMChannel[WhitePWM1]=2.55*PWMSlope(11,00,21,00,0,40,60,PWMChannel[WhitePWM1]);
PWMChannel[BluePWM1]=2.55*PWMSlope(11,00,21,15,0,45,60,PWMChannel[BluePWM1]);
PWMChannel[WhitePWM2]=2.55*PWMSlope(11,01,21,00,0,40,60,PWMChannel[WhitePWM2]);
PWMChannel[BluePWM2]=2.55*PWMSlope(11,01,22,00,0,45,60,PWMChannel[BluePWM2]);
PWMChannel[WhitePWM3]=2.55*PWMSlope(11,02,21,00,0,40,60,PWMChannel[WhitePWM3]);
PWMChannel[BluePWM3]=2.55*PWMSlope(11,02,21,15,0,45,60, PWMChannel[BluePWM3]);
if ((ReefAngel.Relay.RelayMaskOn & (1<<Port7)) == (1<<Port7))
{
PWMChannel[WhitePWM1]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM1]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM2]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM2]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM3]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM3]=InternalMemory.LEDPWMActinic_read();
}
// this section sends the data to the PWM expansion module
PWMExpansion(WhitePWM1,PWMChannel[WhitePWM1]);
PWMExpansion(BluePWM1,PWMChannel[BluePWM1]);
PWMExpansion(WhitePWM2,PWMChannel[WhitePWM2]);
PWMExpansion(BluePWM2,PWMChannel[BluePWM2]);
PWMExpansion(WhitePWM3,PWMChannel[WhitePWM3]);
PWMExpansion(BluePWM3,PWMChannel[BluePWM3]);
}
void PWMExpansion(byte cmd, byte data)
{
Wire.beginTransmission(2); // transmit to device #2
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send(cmd); // sends a value
Wire.send(data); // sends 255
Wire.endTransmission(); // stop transmitting}
}
But now I can even mask off the LEDs did I do something wrong.
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.StandardFan(Port4);
ReefAngel.StandardHeater(Port5);
ReefAngel.StandardHeater(Port6);
// Setup relay 7 to turn on at 06:00aM and off at 10:05PM
ReefAngel.StandardLights(7,11,45,22,05);
// Setup relay 8 to turn on at 18:00PM and off at 00:00AM
ReefAngel.StandardLights(8,18,0,00,00);
//This section calculates the slope
//calculate slope for 0 to 50% starting at 12:30pm with duration of 60min, then from 50% to 0 from 17:00pm with duration of 60min
PWMChannel[WhitePWM1]=2.55*PWMSlope(11,00,21,00,0,40,60,PWMChannel[WhitePWM1]);
PWMChannel[BluePWM1]=2.55*PWMSlope(11,00,21,15,0,45,60,PWMChannel[BluePWM1]);
PWMChannel[WhitePWM2]=2.55*PWMSlope(11,01,21,00,0,40,60,PWMChannel[WhitePWM2]);
PWMChannel[BluePWM2]=2.55*PWMSlope(11,01,22,00,0,45,60,PWMChannel[BluePWM2]);
PWMChannel[WhitePWM3]=2.55*PWMSlope(11,02,21,00,0,40,60,PWMChannel[WhitePWM3]);
PWMChannel[BluePWM3]=2.55*PWMSlope(11,02,21,15,0,45,60, PWMChannel[BluePWM3]);
if ((ReefAngel.Relay.RelayMaskOn & (1<<Port7)) == (1<<Port7))
{
PWMChannel[WhitePWM1]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM1]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM2]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM2]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM3]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM3]=InternalMemory.LEDPWMActinic_read();
}
// this section sends the data to the PWM expansion module
PWMExpansion(WhitePWM1,PWMChannel[WhitePWM1]);
PWMExpansion(BluePWM1,PWMChannel[BluePWM1]);
PWMExpansion(WhitePWM2,PWMChannel[WhitePWM2]);
PWMExpansion(BluePWM2,PWMChannel[BluePWM2]);
PWMExpansion(WhitePWM3,PWMChannel[WhitePWM3]);
PWMExpansion(BluePWM3,PWMChannel[BluePWM3]);
}
void PWMExpansion(byte cmd, byte data)
{
Wire.beginTransmission(2); // transmit to device #2
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send(cmd); // sends a value
Wire.send(data); // sends 255
Wire.endTransmission(); // stop transmitting}
}
But now I can even mask off the LEDs did I do something wrong.
Re: How to code a Lights on feature
I'm sorry, I think I forgot something...
Try this:
Try this:
Code: Select all
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.StandardFan(Port4);
ReefAngel.StandardHeater(Port5);
ReefAngel.StandardHeater(Port6);
// Setup relay 7 to turn on at 06:00aM and off at 10:05PM
ReefAngel.StandardLights(7,11,45,22,05);
// Setup relay 8 to turn on at 18:00PM and off at 00:00AM
ReefAngel.StandardLights(8,18,0,00,00);
//This section calculates the slope
//calculate slope for 0 to 50% starting at 12:30pm with duration of 60min, then from 50% to 0 from 17:00pm with duration of 60min
PWMChannel[WhitePWM1]=2.55*PWMSlope(11,00,21,00,0,40,60,0);
PWMChannel[BluePWM1]=2.55*PWMSlope(11,00,21,15,0,45,60,0);
PWMChannel[WhitePWM2]=2.55*PWMSlope(11,01,21,00,0,40,60,0);
PWMChannel[BluePWM2]=2.55*PWMSlope(11,01,22,00,0,45,60,0);
PWMChannel[WhitePWM3]=2.55*PWMSlope(11,02,21,00,0,40,60,0);
PWMChannel[BluePWM3]=2.55*PWMSlope(11,02,21,15,0,45,60, 0);
if ((ReefAngel.Relay.RelayMaskOn & (1<<Port7)) == (1<<Port7))
{
PWMChannel[WhitePWM1]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM1]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM2]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM2]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM3]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM3]=InternalMemory.LEDPWMActinic_read();
}
// this section sends the data to the PWM expansion module
PWMExpansion(WhitePWM1,PWMChannel[WhitePWM1]);
PWMExpansion(BluePWM1,PWMChannel[BluePWM1]);
PWMExpansion(WhitePWM2,PWMChannel[WhitePWM2]);
PWMExpansion(BluePWM2,PWMChannel[BluePWM2]);
PWMExpansion(WhitePWM3,PWMChannel[WhitePWM3]);
PWMExpansion(BluePWM3,PWMChannel[BluePWM3]);
}
void PWMExpansion(byte cmd, byte data)
{
Wire.beginTransmission(2); // transmit to device #2
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send(cmd); // sends a value
Wire.send(data); // sends 255
Wire.endTransmission(); // stop transmitting}
}
Roberto.
Re: How to code a Lights on feature
I paste in your changes and now I can turn mask on and off but the LEDs dont light. Any ideas?
Re: How to code a Lights on feature
Sorry Don,
I don't have an RA to test right now.
I'm running a 2.5hr long simulation of the Vortech RF module and can't test your code, so bear with me.
I think the problem is on the port number.
Try this:
I don't have an RA to test right now.
I'm running a 2.5hr long simulation of the Vortech RF module and can't test your code, so bear with me.
I think the problem is on the port number.
Try this:
Code: Select all
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.StandardFan(Port4);
ReefAngel.StandardHeater(Port5);
ReefAngel.StandardHeater(Port6);
// Setup relay 7 to turn on at 06:00aM and off at 10:05PM
ReefAngel.StandardLights(7,11,45,22,05);
// Setup relay 8 to turn on at 18:00PM and off at 00:00AM
ReefAngel.StandardLights(8,18,0,00,00);
//This section calculates the slope
//calculate slope for 0 to 50% starting at 12:30pm with duration of 60min, then from 50% to 0 from 17:00pm with duration of 60min
PWMChannel[WhitePWM1]=2.55*PWMSlope(11,00,21,00,0,40,60,0);
PWMChannel[BluePWM1]=2.55*PWMSlope(11,00,21,15,0,45,60,0);
PWMChannel[WhitePWM2]=2.55*PWMSlope(11,01,21,00,0,40,60,0);
PWMChannel[BluePWM2]=2.55*PWMSlope(11,01,22,00,0,45,60,0);
PWMChannel[WhitePWM3]=2.55*PWMSlope(11,02,21,00,0,40,60,0);
PWMChannel[BluePWM3]=2.55*PWMSlope(11,02,21,15,0,45,60, 0);
if ((ReefAngel.Relay.RelayMaskOn & (1<<(Port7-1))) == (1<<(Port7-1)))
{
PWMChannel[WhitePWM1]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM1]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM2]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM2]=InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM3]=InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM3]=InternalMemory.LEDPWMActinic_read();
}
// this section sends the data to the PWM expansion module
PWMExpansion(WhitePWM1,PWMChannel[WhitePWM1]);
PWMExpansion(BluePWM1,PWMChannel[BluePWM1]);
PWMExpansion(WhitePWM2,PWMChannel[WhitePWM2]);
PWMExpansion(BluePWM2,PWMChannel[BluePWM2]);
PWMExpansion(WhitePWM3,PWMChannel[WhitePWM3]);
PWMExpansion(BluePWM3,PWMChannel[BluePWM3]);
}
void PWMExpansion(byte cmd, byte data)
{
Wire.beginTransmission(2); // transmit to device #2
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send(cmd); // sends a value
Wire.send(data); // sends 255
Wire.endTransmission(); // stop transmitting}
}
Roberto.
Re: How to code a Lights on feature
you nailed it that time.... Thanks for your help once again!!!!
Re: How to code a Lights on feature
Roberto,
Just one more quick question if you dont mind? When I set the PWM percentage in client to 25 % for both channels my leds didnt correctly and I didnt see the correct light pattern until I was at 50 %. So my question is does the client package do calulate the voltage differently the the standard PWMSLOPE command. It's not a problem I can just adjust to a different %.
Just one more quick question if you dont mind? When I set the PWM percentage in client to 25 % for both channels my leds didnt correctly and I didnt see the correct light pattern until I was at 50 %. So my question is does the client package do calulate the voltage differently the the standard PWMSLOPE command. It's not a problem I can just adjust to a different %.
Re: How to code a Lights on feature
My bad...
I forgot to multiply the value by 2.55
I forgot to multiply the value by 2.55
Code: Select all
PWMChannel[WhitePWM1]=2.55*InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM1]=2.55*InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM2]=2.55*InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM2]=2.55*InternalMemory.LEDPWMActinic_read();
PWMChannel[WhitePWM3]=2.55*InternalMemory.LEDPWMDaylight_read();
PWMChannel[BluePWM3]=2.55*InternalMemory.LEDPWMActinic_read();
Roberto.
Re: How to code a Lights on feature
Prefect how it works properly... Thanks Again