How to code a Lights on feature

Do you have a question on how to do something.
Ask in here.
Post Reply
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: How to code a Lights on feature

Post by divingdon »

I paste in your changes and now I can turn mask on and off but the LEDs dont light. Any ideas?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How to code a Lights on feature

Post by rimai »

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:

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.
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: How to code a Lights on feature

Post by divingdon »

you nailed it that time.... Thanks for your help once again!!!!
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How to code a Lights on feature

Post by rimai »

Nice :)
Glad to help
Roberto.
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: How to code a Lights on feature

Post by divingdon »

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 %.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How to code a Lights on feature

Post by rimai »

My bad...
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.
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: How to code a Lights on feature

Post by divingdon »

Prefect how it works properly... Thanks Again
Post Reply