temperature control not working

Related to the development libraries, released by Curt Binder
Post Reply
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

temperature control not working

Post by ahmedess »

Hi,

I m using RAgen to generate my code and i m having two problems.

Problem number one:

Temperature control is not working properly. I have the fan/chiller on port 2 and the heater on port 3. After I uploaded the code to the controller port 3 turned on and stayed on no matter what the temperature is and port 2 never turned on also no matter what the temperature is. I have chosen temperature display to be in Celcius.

Problem number two:

I have used the code for pwmslope to simulate sunrise and sunset and i have it conflicting with the led pwm control feature that i have checked in RAgen. meaning that after sunsets the lights go to zero then it comes back on to the 50% setting stored in the ledpwm settings

Does that mean that i need to uncheck the ledpwm feature and just include the pwmslope code I have found here on the forum? or does it mean that i adjust the the led pwm setting to zero?

HERE IS MY CODE:

Code: Select all

// Autogenerated file by RAGen (v1.0.4.92), (05/30/2011 23:56)
// RA_053011_2356.pde
//
// This version designed for v0.8.5 Beta 12 or later

/* The following features are enabled for this PDE File: 
#define DosingPumpIntervalSetup
#define WavemakerSetup
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
*/


#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>

// Labels for the web banner
#include <avr/pgmspace.h>
prog_char id_label[] PROGMEM = "ahmedess";
prog_char probe1_label[] PROGMEM = "Water";
prog_char probe2_label[] PROGMEM = "Room";
prog_char probe3_label[] PROGMEM = "LEDTemp";
prog_char relay1_label[] PROGMEM = "Sump";
prog_char relay2_label[] PROGMEM = "Fan/Chiller";
prog_char relay3_label[] PROGMEM = "Heater";
prog_char relay4_label[] PROGMEM = "Dosers";
prog_char relay5_label[] PROGMEM = "Wavemaker";
prog_char relay6_label[] PROGMEM = "Universal";
prog_char relay7_label[] PROGMEM = "Universal";
prog_char relay8_label[] PROGMEM = "TunzeATO";
PROGMEM const char *webbanner_items[] = {
    id_label, probe1_label, probe2_label, probe3_label, relay1_label, relay2_label,
	relay3_label, relay4_label, relay5_label, relay6_label, relay7_label, relay8_label};


void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.SetTemperatureUnit(1);  // set to Celsius Temperature
    // Initialize and start the web banner timer
    ReefAngel.LoadWebBanner(pgm_read_word(&(webbanner_items[0])), SIZE(webbanner_items));
    ReefAngel.Timer[4].SetInterval(180);  // set interval to 180 seconds
    ReefAngel.Timer[4].Start();

    ReefAngel.FeedingModePorts = B10000001;
    ReefAngel.WaterChangePorts = B10000001;
    ReefAngel.OverheatShutoffPorts = B00000000;
    ReefAngel.LightsOnPorts = B00000000;

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

void loop()
{
    ReefAngel.ShowInterface();

    // Specific functions
    ReefAngel.StandardFan(Port2);
    ReefAngel.StandardHeater(Port3);
    ReefAngel.DosingPumpRepeat1(Port4);
    ReefAngel.Wavemaker2(Port5);

// Have PWM on from 4p to 1a, with gradual 60 minute ramp up and down starting at the given times
    // From 4p to 5p, the PWM will slowly ramp from 20% to 100%
    // From 12a to 1a, the PWM will slowly ramp from 100% to 20%
    ReefAngel.PWM.SetActinic(PWMSlope(16,0,1,0,20,100,60,ReefAngel.PWM.GetActinicValue()));
    ReefAngel.PWM.SetDaylight(PWMSlope(16,0,1,0,20,100,60,ReefAngel.PWM.GetDaylightValue()));

    // Web Banner stuff
    if(ReefAngel.Timer[4].IsTriggered())
    {
        ReefAngel.Timer[4].Start();
        ReefAngel.WebBanner();
    }
}
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: temperature control not working

Post by binder »

ahmedess wrote: Problem number one:

Temperature control is not working properly. I have the fan/chiller on port 2 and the heater on port 3. After I uploaded the code to the controller port 3 turned on and stayed on no matter what the temperature is and port 2 never turned on also no matter what the temperature is. I have chosen temperature display to be in Celcius.
What are the values that you have programmed / set in the internal memory? Did you go through and upload the Memory PDE first to set the values in the memory?
What does the controller have in the menus as the values for your fan to turn on and off at?
What does the controller have in the menus as the values for your heater to turn on and off at?

The Fan/Chiller and Heater are all dependent on Temperature 1 (T1). So that is the temperature value that you will need to focus on.

These values are stored in Fahrenheit, so you will have to manually convert the values when setting them but the controller will properly display and monitor in Celsius.

ahmedess wrote: Problem number two:

I have used the code for pwmslope to simulate sunrise and sunset and i have it conflicting with the led pwm control feature that i have checked in RAgen. meaning that after sunsets the lights go to zero then it comes back on to the 50% setting stored in the ledpwm settings

Does that mean that i need to uncheck the ledpwm feature and just include the pwmslope code I have found here on the forum? or does it mean that i adjust the the led pwm setting to zero?
I would suggest adjusting the PWM settings to be 20% (the lowest value that you are ramping from). Make sure you set both Actinic and Daylight PWM values from the menu system.

If you are referring to the "Display LED PWM" feature on the Features tab, then you will want to leave that one alone. If you uncheck that, then the LED PWM values will not be displayed on the screen and you will not be able to manually change the values (if you ever wanted to). So it's up to you on what you want to do with this one.

curt
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

I have used the default values in RAgen to generate the internal memory code. then I uploaded it to the controller. then I uploaded the generated program code to the controller and from the temperature menu I've changed the temperature settings to the following values:

For the heater I have the turn on temp = 77 and the turn off temp = 78 as read from the menu on the controller.

For the chiller I have the turn on temp = 80 and the turn off temp = 78.8 as read from the menu on the controller.

Currently T1=80 Fahrenheit and the heater port is on. when the MH was on his morning the temperature rose to 81 Fahrenheit and the chiller port never came on and the heater port stayed on.

Its very weird because there seems to be nothing wrong with the code and the settings. I've unplugged the controller from the power and rebooted it but it didn't help. May be I need to reload the code again to the controller?

If i upload the code again to the controller will i need to recalibrate the pH probe?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: temperature control not working

Post by binder »

PH calibration should be fine. The values are stored in the memory and do not get updated unless you re-calibrate.

You can reload the code and give that a try.
I also have a suggestion to try. Try to switch the heater to a different port, say 5 and the chiller to port 5. Then reload the controller code. I'm just curious if the ports are working properly. Changing to a port that you know has been working will help confirm that.

Are the other ports working as desired?

curt
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

i've reloaded the internal memory code after updating the temperature settings and then i've reloaded the program code but no luck port3 is still on when it should be off. i ll try to change the ports as you say and will see. everything else is working fine
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

i ve changed the ports as you said to port 6 and 7 still the same problem the heater port is on when it should be off
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: temperature control not working

Post by binder »

ahmedess wrote:i ve changed the ports as you said to port 6 and 7 still the same problem the heater port is on when it should be off
Humor me please with this one. I want you remove the SetTemperatureUnit line that enables Celsius temperatures. Then re-upload only the program code and see if that works. I've got an idea and I'm not sure if it is correct or not. If you would try it for me, that would be good.

curt
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

Okay I removed the line that converts the temprature to celsius and it turns out that this is the problem. the controller is working fine now. i guess this means that the controller used to compare celsius to fahrenheit without converting to the same units before comparing. thats why a temperature of 26 was always lower than 78 in value and thats why the heater was on all the time.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: temperature control not working

Post by rimai »

Nice catch of the bug :)
Roberto.
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

How can i change the temperature to Celsius in both the settings and the display?
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

i'm guessing not a lot of people are using celsius thats why no one reported this bug earlier.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: temperature control not working

Post by binder »

ahmedess wrote:Okay I removed the line that converts the temprature to celsius and it turns out that this is the problem. the controller is working fine now. i guess this means that the controller used to compare celsius to fahrenheit without converting to the same units before comparing. thats why a temperature of 26 was always lower than 78 in value and thats why the heater was on all the time.
That's what I was afraid of, which was why I was having you check it for me. I'm surprised nobody else has caught this before because several people are using celsius and these libraries. It's on my list of things to fix now too, so patience with the fix.

You can still set the display to use Celsius but you won't be able to use the simplified function calls. You won't be able to use the StandardFan(port) function, you will have to manually give the temperature ranges:

Code: Select all

ReefAngel.StandardFan(Port2, 250, 270);  // port, low temp (off temp), high temp (on temp)
// turn on at 27.0C and off at 25.0C
The heater code is the same way:

Code: Select all

ReefAngel.StandardHeater(Port3, 240, 250);  // port, low temp (on temp), high temp (off temp)
// turn on at 24.0C and off at 25.0C
Then you can add in the SetTemperatureUnit(1). The only drawback with using these functions is that the internal memory is not going to be set.

You could also change the SetInternalMemory (or Memory) PDE to have the Celsius values in it, but that won't make a difference with menu option. The menu options will still not work until I get it fixed.

Changing the internal memory would be the ideal thing to do especially if you are using the Client Suite software. If not, the simplest thing to do would be to hard code the values in the PDE file (like I mentioned above).

curt
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

I have changed the temprature values in the internal memory file to the celsius values and loaded the code to the controller and its working fine. The only thing that needs to be changed now is the Fahrenheit "F" sign available next to the value in the temperature settings menu displayed on the controller
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: temperature control not working

Post by binder »

ahmedess wrote:I have changed the temprature values in the internal memory file to the celsius values and loaded the code to the controller and its working fine. The only thing that needs to be changed now is the Fahrenheit "F" sign available next to the value in the temperature settings menu displayed on the controller
This is on my list of things to fix up. I would caution against using this menu though. The reason why is the values from 70.0 to 90.0 F are hard coded in. If you goto those screens, you will not be able to get back to using the C values that you programmed into the internal memory.

I think I have a solution (not implemented yet) that would change the menu display based on what the user selects as their temperature setting/value. When I get a working copy of it, I will post and let you know it's available for you to try/test out (of course I would have tested it first to make sure it works). :)

So in the meantime, use caution when going to those menus unless you wanted to change the menu stuff yourself in your own copy of the libraries. It's a pretty simple fix if you want to have it always be C. Let me know and I can send you the simple fix.

curt
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

I opened the temperature menu settings and it had the celsius values that i have put in the internal memory file. I havent tried to change them. So if I try to change them I will not be able to change them to the celsius value again, thats what you say,corret?

yes please send the fix
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: temperature control not working

Post by binder »

ahmedess wrote:I opened the temperature menu settings and it had the celsius values that i have put in the internal memory file. I havent tried to change them. So if I try to change them I will not be able to change them to the celsius value again, thats what you say,corret?

yes please send the fix
Yes, what will happen is this:

You can open up the screen and it will display the proper value only it will have the F next to it. If you change the temp up or down, it will correct it and make sure that it is within the range of 70.0 to 90.0. It will not let you go below or above those values. You should be able to cancel out of the screen and be ok but if you click OK you will have your value reset to the F values and have to manually edit it again.

The temporary fix (until I get a permanent one inside the libraries) is as follows:
Look for this function inside ReefAngel.cpp

Code: Select all

void ReefAngelClass::ProcessButtonPressTemps()
{
    showmenu = true;
    ClearScreen(DefaultBGColor);
    switch ( SelectedMenuItem )
    {
        case TempsMenu_Heater:
        {
            int v = InternalMemory.HeaterTempOn_read();
            int y = InternalMemory.HeaterTempOff_read();
            /*
            Change the 700 (70.0) F to 211 (21.1) C
            Change the 900 (90.0) F to 323 (32.3) C
            Change the F to C
            */
            if ( SetupOption(v, y, 211, 323, 3, "C", ".", "Setup Heater", "On @", "Off @") )
            {
                InternalMemory.HeaterTempOn_write(v);
                InternalMemory.HeaterTempOff_write(y);
            }
            break;
        }
        case TempsMenu_Chiller:
        {
            int v = InternalMemory.ChillerTempOn_read();
            int y = InternalMemory.ChillerTempOff_read();
            /*
            Change the 700 (70.0) F to 211 (21.1) C
            Change the 900 (90.0) F to 323 (32.3) C
            Change the F to C
            */
            if ( SetupOption(v, y, 211, 323, 3, "C", ".", "Setup Chiller", "On @", "Off @") )
            {
                InternalMemory.ChillerTempOn_write(v);
                InternalMemory.ChillerTempOff_write(y);
            }
            break;
        }
/// ... continues on with function
The changes are made to the code section above. You just need to mimic them yourself. There are only 6 total changes that I made and they are just 3 different changes made 2 times. Change 700 to 211, change 900 to 323 and change F to C. It's commented above.

Make sure you have Arduino closed when you update the libraries. Save the file and then reopen Arduino and upload to your controller. You should be able to display everything like you want.

Now, I will say that any time you upgrade the libraries, this fix will have to be applied until I get the permanent solution created. This is not a complex change which is why I'm not as skeptical about telling you. But I do want you to know that it will be replaced any time you upgrade the libraries (yes, I know I said it twice but it's worth saying twice).

curt
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: temperature control not working

Post by ahmedess »

I ve also changed the overheating temperature menu

Code: Select all

#ifdef OverheatSetup
        case TempsMenu_Overheat:
        {
            int v = InternalMemory.OverheatTemp_read();
            int y = -1;
            if ( SetupOption(v, y, 266, 933, 4, "C", ".", "Setup Overheat", "", "") )
            {
                InternalMemory.OverheatTemp_write(v);
            }
            break;
        }
#endif
What does the number 4 correspond to, in the SetupOption() function?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: temperature control not working

Post by binder »

ahmedess wrote:I ve also changed the overheating temperature menu

What does the number 4 correspond to, in the SetupOption() function?
The overheat temperature menu is only available if you enable it. It's disabled by default. So changing that there won't affect anything unless you enable the menu entry. Also, if you enable it, make sure you set your internal memory value appropriately to C.

The 4 is the maximum number of digits in the option. The overheat menu goes up to 150.0 F, which is 4 digits. With your changes to C, the number of digits is smaller so you should change it to 3. This isn't necessary but will help ensure the formatting / displaying on the screen is consistent with the rest of the menus.

Here's the complete options for SetupOption()
  • v - Initial/stored value for the first option
  • y - Initial/stored value for the second option (if any)
  • rangemin - minimum value of the range
  • rangemax - maximum value of the range
  • maxdigits - maximum number of digits that can be displayed for an option
  • unit - Unit for the options (can be empty string)
  • subunit - Any subunits, typically a . (period) for the decimal point (can be empty string)
  • title - Screen title (can be empty string)
  • prefix1 - Prefix for first option (can be empty string)
  • prefix2 - Prefix for second option (can be empty string)
That's just some additional explanation of that function. You will most likely not need it at all, but sometimes it's good to know.

curt
Post Reply