Add to demo code

Do you have a question on how to do something.
Ask in here.
Post Reply
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Add to demo code

Post by Adam »

I like the demo code that came with my new RA, its the newest one with bootloader. The only other options I need are a heater and chiller, and two dosing pumps. I want to keep the demo code but slide in the extra code. I was thinking of using the RAgen to make the code and then pull out the parts for the functions I want to add, and stick it in the demo. Oh and by the way I have no clue what I 'm doing. Any input would be welcome or if there are any premade codes for this that I haven't seen please let me know.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Add to demo code

Post by rimai »

Won't work.
Just use RAGen to replicate the demo code. You will get something almost the same with a whole lot more goodies in it though :)
Roberto.
User avatar
jsclownfish
Posts: 375
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Add to demo code

Post by jsclownfish »

Adam, I can tell you I was right at this same place a couple months ago, http://forum.reefangel.com/viewtopic.php?f=19&t=387 but I can tell you now I am getting much more out of my RA today due to taking advantage of the flexibility of the system. You can keep all the functionality of the preloaded code and get so much more.


-Jon
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Add to demo code

Post by rossbryant1956 »

rimai wrote:Won't work.
Just use RAGen to replicate the demo code. You will get something almost the same with a whole lot more goodies in it though :)
How do you do that? I pulled up "reefangelsimple" and a sketch I built and it had hundreds of lines of code difference...is that because I didn't have all the checkboxes and options selected?
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Add to demo code

Post by rimai »

The reefangelsimple.pde is too old and ijust meant to be an out-of-the box demo code. It is actually the very first code ever created for the RA.
Ever since its creation, there has been many and many updates for the better that doesn't make sense to modify the reefangelsimple anymore.
You can use RAGen to assign the same functions on each socket and it will act just like the reefangelsimple code.
Roberto.
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

I tried using RAGen but when it gets to the Void loop it finds a error " no matching function ReefAngel class standard lights". I used the internal memory writer first uploaded it and then use the PDE writer. When I try to up load the PDE is when the error happens. I know I'm missing something I watch the walk through, but is there some way of putting the 2 codes togeather that I haven't done?
// Autogenerated file by RAGen (v1.1.0.127), (01/31/2012 08:42)
// RA_013112_0842.pde
//
// This version designed for v0.8.5 Beta 17 or later

/* The following features are enabled for this PDE File: 
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define SaveRelayState
#define SIMPLE_MENU
*/


#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>


void setup()
{
    ReefAngel.Init();  //Initialize controller

    // Ports that are always on
    ReefAngel.Relay.On(Port1);
    ReefAngel.Relay.On(Port3);
    ReefAngel.Relay.On(Port8);
}

void loop()
{
    // Specific functions
    ReefAngel.StandardLights(Port2);
    ReefAngel.DosingPump1(Port4);
    ReefAngel.DosingPump2(Port5);
    ReefAngel.StandardFan(Port6);
    ReefAngel.StandardHeater(Port7);

ReefAngel.ShowInterface();
}
Seedlessone
Posts: 132
Joined: Tue Jan 24, 2012 6:20 pm

Re: Add to demo code

Post by Seedlessone »

Are you using the standard libraries?
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

No the standard libraries dont give me all the options I want. I need PWM control, 2 dosing pumps, a timer for lights, and heater/chiller function.
User avatar
jsclownfish
Posts: 375
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Add to demo code

Post by jsclownfish »

hmmm. I tried your code and it compiles fine when I tried it. I am currently using https://github.com/curtbinder/ReefAngel ... /v0.8.5.19 libraries.

So maybe there is something off in the locations of the library folders or something.

Hope that helps a bit...
-Jon
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

404 on that link lol. I'm using the RAGen downloaded off the RA site and Its the Arduino ReefAngel coming up with the error. It has said there is a update for it to 1.0 .
User avatar
jsclownfish
Posts: 375
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Add to demo code

Post by jsclownfish »

Don't upgrade to 1.0 just yet. I know it is being worked on, but the code isn't ready for that upgrade today. Sorry about the bad link, it was a copy error. Try it from here http://forum.reefangel.com/viewtopic.php?f=7&t=376.

-Jon
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Add to demo code

Post by rimai »

You can also use the libraries update utility:
http://forum.reefangel.com/viewtopic.php?f=8&t=2
Just make sure to convert to Development libraries.
The latest version is 0.8.5.19
Roberto.
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

Yes sir that did the trick it uploaded with no errors. Now I need to play with the program to get all the options I need on it .
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

Ok now that I can up load to the controller I need to make the code with the options and menu I want. Here is what I have, feel free to tell me what else I need or even fill in the blanks. I think if I had a example it would help with the learning curve.
// Autogenerated file by RAGen (v1.1.0.127), (01/31/2012 10:32)
// RA_013112_1032.pde
//
// This version designed for v0.8.5 Beta 17 or later

/* The following features are enabled for this PDE File: 
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define SaveRelayState
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES  9
*/


#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "1. Date & Time";
prog_char menu1_label[] PROGMEM = "2. Dawn & Dusk";
prog_char menu2_label[] PROGMEM = "3, LED PWM Control";
prog_char menu3_label[] PROGMEM = "4. Lights";
prog_char menu4_label[] PROGMEM = "5. Dose Cal";
prog_char menu5_label[] PROGMEM = "6. Dose Alk";
prog_char menu6_label[] PROGMEM = "7. Heater";
prog_char menu7_label[] PROGMEM = "8. Fan";
prog_char menu8_label[] PROGMEM = "9. Calibrate PH";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label, menu4_label, menu5_label, menu6_label, menu7_label, menu8_label  };

void MenuEntry1()
{
ReefAngel.DisplayMenuEntry("Item 1");
}
void MenuEntry2()
{
ReefAngel.DisplayMenuEntry("Item 2");
}
void MenuEntry3()
{
ReefAngel.DisplayMenuEntry("Item 3");
}
void MenuEntry4()
{
ReefAngel.DisplayMenuEntry("Item 4");
}
void MenuEntry5()
{
ReefAngel.DisplayMenuEntry("Item 5");
}
void MenuEntry6()
{
ReefAngel.DisplayMenuEntry("Item 6");
}
void MenuEntry7()
{
ReefAngel.DisplayMenuEntry("Item 7");
}
void MenuEntry8()
{
ReefAngel.DisplayMenuEntry("Item 8");
}
void MenuEntry9()
{
ReefAngel.DisplayMenuEntry("Item 9");
}


void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

    // Ports that are always on
    ReefAngel.Relay.On(Port1);
    ReefAngel.Relay.On(Port3);
    ReefAngel.Relay.On(Port8);
}

void loop()
{
    // Specific functions
    ReefAngel.StandardLights(Port2);
    ReefAngel.DosingPump1(Port4);
    ReefAngel.DosingPump2(Port5);
    ReefAngel.StandardFan(Port6);
    ReefAngel.StandardHeater(Port7);

ReefAngel.ShowInterface();
}
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Add to demo code

Post by binder »

Custom Menu creation...check this tutorial and guide out.
http://forum.reefangel.com/viewtopic.php?f=14&t=311
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Add to demo code

Post by binder »

Can you elaborate more on what you want each menu item to do? I don't follow with what "Heater" means or the others. I will say that with the Custom menu, some of the setup screens are not available. Simply because they take up LOTS of program space.
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

I was thinking and it may be to much but,
1 date & time= set date and time
2 dawn & dusk= ramp up leds, ramp down leds
3 led pwm control= this may be the same as menu 2 time on and power
4 lights= time to turn on 110v for lights
5 Dose cal= control seconds to run dosing pump 1
6 Dose alk= control seconds to run dosing pump2
7 Heater= change temp on 110v control for heater
8 Fan= change temp on 110v control for fan
9 calabrate PH= calabrate ph probe

I will look at the tutorial again but I have no programming knowledge, so a example I could use as a step by step for what I'm trying to do. Then again I might be asking to much and will just have to change these settings with the internal memory.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Add to demo code

Post by binder »

Adam wrote:I was thinking and it may be to much but,
1 date & time= set date and time
2 dawn & dusk= ramp up leds, ramp down leds
3 led pwm control= this may be the same as menu 2 time on and power
4 lights= time to turn on 110v for lights
5 Dose cal= control seconds to run dosing pump 1
6 Dose alk= control seconds to run dosing pump2
7 Heater= change temp on 110v control for heater
8 Fan= change temp on 110v control for fan
9 calabrate PH= calabrate ph probe

I will look at the tutorial again but I have no programming knowledge, so a example I could use as a step by step for what I'm trying to do. Then again I might be asking to much and will just have to change these settings with the internal memory.
1. Simple. There is a SetupDateTime() function available. In fact, this is shown and demonstrated in the Custom Main Screen tutorial / guide.
2. The dev libraries don't reference a dusk/dawn. They just use on / off times. The setup menus are not available with the custom menu.
3. same as 2
4. if you are wanting to change the times, it's the same as 2.
5 & 6. if you are wanting to change the number of seconds, then the same as 2. if you are wanting to force a run to manually dose for a specified amount of time, that can be done.
7 & 8. same as 2
9. Simple. There is a SetupCalibratePH() function available. This is used practically the same as the SetupDateTime() function. So duplicating the code to be like #1 will work for you.

Sounds like a lot of the things you want to do will require the setup screen. The main setup screen does require a fair amount of space which is why there is such a huge reduction when that code is removed. Plus, you have to load the values from the internal memory into the function and then when the display screen is exited you have to save the values back to the internal memory. There is definitely more work involved. If you have WIFI enabled, it's much more "feasible" to change everything using one of the graphical apps. It's quicker and you have no additional code overhead beyond the addition of the wifi code. Not saying that it couldn't be done, just that it currently cannot be done without additional modifications to the libraries.

If you don't have WIFI enabled (no Android, Client Suite, iPhone, or Status app), then like I said, we could figure something out for you to get you going.
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

No, I didn't order the WIFI just yet. I will play with it some more and see if I can figure it out. I think its more of the termonolgy that is getting me at them moment. I think the hard one is going to be the leds, ramping up each channel at diffrent times. Thanks for the input.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Add to demo code

Post by binder »

Adam wrote:No, I didn't order the WIFI just yet. I will play with it some more and see if I can figure it out. I think its more of the termonolgy that is getting me at them moment. I think the hard one is going to be the leds, ramping up each channel at diffrent times. Thanks for the input.
Ramping up the LEDs should be quite simple. There is a function called PWMSlope. That handles all the computations for you. You just give it a start and end time plus a percentage range to ramp. It does the rest. Just do a search for PWMSlope on here and you should find it quite simple. If not, somebody can help you out with more. :)
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

Cool thanks for the tip. I will look into it .
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Add to demo code

Post by rimai »

Roberto.
Adam
Posts: 38
Joined: Sun Jan 29, 2012 8:03 am

Re: Add to demo code

Post by Adam »

Thanks for all the help guys. I have my RA on my tank and it seems to be working. I still need to test the dosing pumps and fine tune my code but so fare so good.
Post Reply