MH light on

Do you have a question on how to do something.
Ask in here.
Post Reply
trentdingo
Posts: 14
Joined: Sun Jul 17, 2011 1:43 pm

MH light on

Post by trentdingo »

Hey all, if I wanted to customize the screen on the unit to have a MH light on option, real quick what would the function to add in be?
also, did we ever figure something out to get scrolling menus or pages for our menu?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: MH light on

Post by rimai »

Are you using RAGen?
Roberto.
trentdingo
Posts: 14
Joined: Sun Jul 17, 2011 1:43 pm

Re: MH light on

Post by trentdingo »

No I am not...
Ideally, I would like to just switch this line from MH Light off to MH Light on
ReefAngel.Relay.RelayMaskOn=B00000110;

I just dont know what code to put in there to specify for on instead of off...?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: MH light on

Post by rimai »

Can you post your code?
Roberto.
trentdingo
Posts: 14
Joined: Sun Jul 17, 2011 1:43 pm

Re: MH light on

Post by trentdingo »

*/
#include <avr/pgmspace.h>

prog_char menu0_label[] PROGMEM = "Feeding Mode";
prog_char menu1_label[] PROGMEM = "Water Change Mode";
prog_char menu2_label[] PROGMEM = "MH Lights On";
//prog_char menu3_label[] PROGMEM = "Cancel Override On";
//prog_char menu4_label[] PROGMEM = "Override ATO On";
prog_char menu3_label[] PROGMEM = "Clear Overheat";
prog_char menu4_label[] PROGMEM = "PWM Percentage 100%";
prog_char menu5_label[] PROGMEM = "PWM Percentage 60%";
prog_char menu6_label[] PROGMEM = "PWM Percentage 35%";
prog_char menu7_label[] PROGMEM = "PWM Percentage 10%";
prog_char menu8_label[] PROGMEM = "Restore PWM";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label, menu4_label, menu5_label, menu6_label, menu7_label, menu8_label};

byte SavedPWMValue = 255;

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
This block runs only once at start-up. It's called setup() function.
It initializes the controller, builds the menu system and turns on the pumps/powerheads
A couple of assumptions were made in this code:
Temp1 is water temperature sensor readings
Temp2 is lights temperature sensor readings
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.LoadMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items)); // Load Menu items from above
ReefAngel.Relay.On(ATO); //Turn on ATO at startup
ReefAngel.Relay.On(Sump); //Turn Sump on at startup
ReefAngel.Relay.On(LEDs); //Turn on LED at startup
ReefAngel.Relay.On(WM1); //Turn WM1 on at startup
ReefAngel.Relay.On(WM2); //Turn WM2 on at startup
//ReefAngel.Timer[0].Interval=10; // Uncomment to override feeding timer. Default is 900 seconds
//ReefAngel.Timer[3].Interval=5; // Uncomment to override screen saver timer. Default is 600 seconds
//ReefAngel.Timer[3].Start(); // Uncomment to start screen saver timer if you uncommented line above
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
This block runs forever, over and over again. It's called loop() function.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
void loop()
{
ReefAngel.StandardGUI(); //Draw the Standard GUI



/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
This block is where you setup your main functions
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
ReefAngel.MHLights(MHlight,11,30,22,15,15); // Setup Daylight to turn on at 11:30AM and off at 10:15PM / Delay 15mins in case of power failure
ReefAngel.StandardHeater(Heater,789,803); // Setup Heater to turn on at 78.9F and off at 80.3F
ReefAngel.StandardFan(Chiller,797,811); // Setup Chiller to turn on at 81.1F and off at 79.7F
//ReefAngel.StandardATO(AutoTopOff,60); //Setup ATO to turn on at ATOlow and off at ATOhigh / Timeout set to 60s
ReefAngel.Timer[1].Interval=170; // set timer to x seconds - Timer 1 is used for wavemaker 1
ReefAngel.Timer[2].Interval=245; // set timer to x seconds - Timer 2 is used for wavemaker 2


/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
If the controller is on default mode and it is showing the default screen, the value of SelectedMenu will be 255.
So, we check to see if the value is 255 and if it is, it'll check whether or not it should toggle the wavemaker powerheads WM1 and WM2 on or off.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==255) // Default Mode - Main Screen
{
if (ReefAngel.Timer[1].IsTriggered()) // If timer 1 expires
{
ReefAngel.Timer[1].Start(); // start timer
ReefAngel.Relay.Toggle(WM1); // toggle relay
}
if (ReefAngel.Timer[2].IsTriggered()) // If timer 2 expires
{
ReefAngel.Timer[2].Start(); // start timer
ReefAngel.Relay.Toggle(WM2); // toggle relay
}
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
If the controller is on "Feeding Mode", the value of SelectedMenu will be 0. This is based according to the menu created above
So, we check to see if the value is 0 and if it is, it'll turn Sump, WM1 and WM2 off. It will then display the feeding mode screen
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==0) // Feeding Mode Selected
{
//ReefAngel.Relay.Off(Sump); //Turn Sump off
ReefAngel.Relay.Off(WM1); //Turn WM1 off
ReefAngel.Relay.Off(WM2); //Turn WM2 off
ReefAngel.FeedingModeGUI(); // Draw FeedingModeGUI
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
If the controller is on "Water Change Mode", the value of SelectedMenu will be 1. This is based according to the menu created above
So, we check to see if the value is 1 and if it is, it'll turn Sump, WM1 and WM2 off. It will then display the water change mode screen
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==1) // Water Change Mode Selected
{
//ReefAngel.Relay.Off(Sump); //Turn Sump off
ReefAngel.Relay.Off(WM1); //Turn WM1 off
ReefAngel.Relay.Off(WM2); //Turn WM2 off
ReefAngel.WaterChangeModeGUI(); // Draw WaterChangeModeGUI
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
If the controller is on "Override Lights On", the value of SelectedMenu will be 2. This is based according to the menu created above
So, we check to see if the value is 2 and if it is, it'll set the relay mask to override the outlet 2 and 3 to always on, which are the MHlights and Actinic
It will also set the pwm channels to 50%, in case you are using LEDs.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==2) //Override Lights On Selected
{
ReefAngel.Relay.RelayMaskOn=B00000110; //Override Lights On;
ReefAngel.PWM.SetActinic(90); // Set PWM value
ReefAngel.PWM.SetDaylight(50); // Set PWM value
ReefAngel.LCD.DrawText(19,255,10,10,"Override Lights On");
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
If the controller is on "Cancel Override On", the value of SelectedMenu will be 3. This is based according to the menu created above
So, we check to see if the value is 3 and if it is, it'll set the relay mask to override the outlet 2 and 3 back to auto, which are the MHlights and Actinic
It will also set the pwm channels to 0%, in case you are using LEDs.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/

/*
if (ReefAngel.SelectedMenu==3) //Override Lights Off Selected
{
ReefAngel.Relay.RelayMaskOn=B00000000; //Override Lights Off;
ReefAngel.PWM.SetActinic(0); // Set PWM value
ReefAngel.PWM.SetDaylight(0); // Set PWM value
ReefAngel.ReturnMenuFunction(); // Return from menu function;
}
*/

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
If the controller is on "Clear ATO Timeout", the value of SelectedMenu will be 4. This is based according to the menu created above
So, we check to see if the value is 4 and if it is, it'll clear the ATO timeout flag and turn the status LED off
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/

/*
if (ReefAngel.SelectedMenu==4) //Clear ATO Timeout Selected
{
ReefAngel.LED.Off();
ReefAngel.ATO.topping=false;
ReefAngel.ReturnMenuFunction(); // Return from menu function;
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
If the controller is on "Clear Overheat", the value of SelectedMenu will be 5. This is based according to the menu created above
So, we check to see if the value is 5 and if it is, it'll clear the Overheat
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==3) //Clear Overheat Selected
{
ReefAngel.LED.Off();
ReefAngel.Relay.RelayMaskOff=B11111111; //Override MHlight Auto;
ReefAngel.ReturnMenuFunction(); // Return from menu function;
}



/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
The LED PWM signal 100% percentage will be defined here.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==4) // PWM signal 100% selected
{
// save the value if it's not currently stored
if ( SavedPWMValue == 255 )
SavedPWMValue = ReefAngel.PWM.ActinicPWMValue;

ReefAngel.PWM.SetActinic(100);
}



/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
The LED PWM signal 50% percentage will be defined here.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==5) // PWM signal 50% selected
{
// save the value if it's not currently stored
if ( SavedPWMValue == 255 )
SavedPWMValue = ReefAngel.PWM.ActinicPWMValue;

ReefAngel.PWM.SetActinic(60);
}



/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
The LED PWM signal 35% percentage will be defined here.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==6) // PWM signal 35% selected
{
// save the value if it's not currently stored
if ( SavedPWMValue == 255 )
SavedPWMValue = ReefAngel.PWM.ActinicPWMValue;

ReefAngel.PWM.SetActinic(35);
}


/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
The LED PWM signal 0% percentage will be defined here.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.SelectedMenu==7) // PWM signal 10% selected
{
// save the value if it's not currently stored
if ( SavedPWMValue == 255 )
SavedPWMValue = ReefAngel.PWM.ActinicPWMValue;

ReefAngel.PWM.SetActinic(13);
}


/*
___________________________________________________________________________________
Restore PWM percentage menu
___________________________________________________________________________________
*/


if ( ReefAngel.SelectedMenu == 8) // this is the restore PWM menu
{
// restore the value
if ( SavedPWMValue >= 0 && SavedPWMValue <= 100 )
{
ReefAngel.PWM.SetActinic(SavedPWMValue);
SavedPWMValue = 255;
}
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
The Timer[0] is used as feeding mode timer.
When Timer[0] is triggered, it will turn the Sump on.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/

if (ReefAngel.Timer[0].IsTriggered()) // If feeding timer runs out
{
ReefAngel.ReturnMenuFunction(); // Return from menu function;
ReefAngel.Relay.On(Sump); //Turn Sump off
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
If Temp2 sensor reachs 150.0F, it will consider an overheat and will turn the lights off
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
if (ReefAngel.Params.Temp2>=835 && ReefAngel.Relay.RelayData & 0x6 == 0x6) // It Temp2 >= 83.5F
{
ReefAngel.LED.On();
ReefAngel.Relay.RelayMaskOff=B11111001; //Override MHlight 1 & 2 Off;
}

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
Writes the updated value to the relay box.
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
ReefAngel.Relay.Write(); // Make relay changes effective

/*contrast*/
{
ReefAngel.LCD.SetContrast(50); // Set contrast to 50
}

/*time*/
/*
{
setTime(1282404765); // Unix time
//Just make sure you comment or remove this function after you run it once, otherwise every time it is executed, it will set the clock
//to that time over and over again.
//After you force the RTC to update, you have to sync Reef Angel's time to the RTC with these functions:
now();
ReefAngel.RTC.set(now());
}
*/

/*pH*/
{
ReefAngel.PHMin=970;// 540=PH7.0 after it went weird min=100 and max=800 was 8.25pH...
ReefAngel.PHMax=740;// 980=PH10.0
}


Also, when I am uploading I keep throwing this error... any ideas on that?

Binary sketch size: 28368 bytes (of a 30720 byte maximum)
processing.app.SerialException: Serial port '/dev/cu.usbserial-FTF0GMBP' not found. Did you select the right one from the Tools > Serial Port menu?
at processing.app.Serial.<init>(Unknown Source)
at processing.app.Serial.<init>(Unknown Source)
at processing.app.debug.Uploader.flushSerialBuffer(Unknown Source)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(Unknown Source)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(Unknown Source)
at processing.app.Sketch.upload(Unknown Source)
at processing.app.Sketch.exportApplet(Unknown Source)
at processing.app.Sketch.exportApplet(Unknown Source)
at processing.app.Editor$DefaultExportHandler.run(Unknown Source)
at java.lang.Thread.run(Thread.java:680)
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: MH light on

Post by rimai »

The error is wrong com port.
The code is missing the beginning of it, which is where the ports are defined.
Can you also post that?
Roberto.
trentdingo
Posts: 14
Joined: Sun Jul 17, 2011 1:43 pm

Re: MH light on

Post by trentdingo »

//Library headers. Necessary if you are using Reef Angel Controller
#include <Wire.h>
#include <EEPROM.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <NokiaLCD.h>
#include <ReefAngel.h>

/*
----------------------------------------------------------------------------------------------------------------------------------------------------------
Give labels to your outlets
----------------------------------------------------------------------------------------------------------------------------------------------------------
*/
#define Sump 8
#define Heater 7
#define Chiller 6
#define WM1 5
#define WM2 4
#define MHlight 3
#define LEDs 2
#define ATO 1
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: MH light on

Post by rimai »

Hey Trent,

Code: Select all

ReefAngel.Relay.RelayMaskOn=B00000110; //Override Lights On;
This line already turns LEDs and MHLight on.
I'm confused on what you want to do exactly.
Roberto.
trentdingo
Posts: 14
Joined: Sun Jul 17, 2011 1:43 pm

Re: MH light on

Post by trentdingo »

Oh, my mistake then... I thought that was the code to turn them off. Thanks for the help.

So about the port issue. I am very confused because I was connecting just fine 2 days ago and then this error randomly threw last night. Where would i define which port exactly
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: MH light on

Post by rimai »

On the menu, go to Tool->Serial Port
Roberto.
trentdingo
Posts: 14
Joined: Sun Jul 17, 2011 1:43 pm

Re: MH light on

Post by trentdingo »

ok, it was just a one time thing then... not sure why it selected a different port yesterday but it was back to the correct port tonight. Thank you for your help
Post Reply