Another Alternative to get PWM Ports On

Do you have a question on how to do something.
Ask in here.
Post Reply
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Another Alternative to get PWM Ports On

Post by Bo0sted_Rafi »

I got a port in my relay box without use and i need to know if i can do something in the code to get lights on when i turns on the port in the portal or my iphone app.


My Leds are hooked and programed in the code but if i need to verify something in the tank, i needs to get the lights on or something and i dont have how to do it.

Something like,

If port5 gets on, get pwm channels at 100%

That relay its always off, just get that in the code if i need it like make mantenance or move corals or get out a fish!! Thanks
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Another Alternative to get PWM Ports On

Post by rimai »

Try adding port5 to the lights on ports:

Code: Select all

  ReefAngel.LightsOnPorts = Port5Bit;
Roberto.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Another Alternative to get PWM Ports On

Post by Bo0sted_Rafi »

I do that but the ports only shuts off when they are on but when are off, they dont turns on back.

Code: Select all

   #include <ReefAngel_Features.h>
    #include <Globals.h>
    #include <RA_Wifi.h>
    #include <Wire.h>
    #include <OneWire.h>
    #include <Time.h>
    #include <DS1307RTC.h>
    #include <InternalEEPROM.h>
    #include <RA_NokiaLCD.h>
    #include <RA_ATO.h>
    #include <RA_Joystick.h>
    #include <LED.h>
    #include <RA_TempSensor.h>
    #include <Relay.h>
    #include <RA_PWM.h>
    #include <Timer.h>
    #include <Memory.h>
    #include <InternalEEPROM.h>
    #include <RA_Colors.h>
    #include <RA_CustomColors.h>
    #include <Salinity.h>
    #include <RF.h>
    #include <IO.h>
    #include <ORP.h>
    #include <AI.h>
    #include <PH.h>
    #include <WaterLevel.h>
    #include <ReefAngel.h>

    ////// Place global variable code below here
    int avgph[10];
    unsigned long totalavgph=0;
    byte avgindex=0;

    ////// Place global variable code above here


    void setup()
    {
       // This must be the first line
       ReefAngel.Init(); //Initialize controller
       // Ports toggled in Feeding Mode
       ReefAngel.UseFlexiblePhCalibration();
       ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port3Bit;
       // Ports toggled in Water Change Mode
       ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port3Bit;
       // Ports toggled when Lights On / Off menu entry selected
       ReefAngel.LightsOnPorts = Port5Bit;
       // Ports turned off when Overheat temperature exceeded
       ReefAngel.OverheatShutoffPorts = Port7Bit ;
       // Use T1 probe as temperature and overheat functions
       ReefAngel.TempProbe = T1_PROBE;
       ReefAngel.OverheatProbe = T1_PROBE;
       // Set the Overheat temperature setting
       InternalMemory.OverheatTemp_write( 830 );

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

       ////// Place additional initialization code below here

       for (int a=0;a<10;a++) avgph[a]=analogRead(PHPin);

       ////// Place additional initialization code above here
    }

    void loop()
    {
       totalavgph=0;
       avgph[avgindex]=analogRead(PHPin);
       avgindex++;
       if (avgindex==10) avgindex=0;
       for (int a=0;a<10;a++)
       totalavgph+=avgph[a];
       totalavgph/=10;

       totalavgph=map(totalavgph, ReefAngel.PHMin, ReefAngel.PHMax, 700, 1000); // apply the calibration to the sensor reading
       totalavgph=constrain(totalavgph,100,1400);

       if (totalavgph <= 644) ReefAngel.Relay.Off(Port3);
       if (totalavgph >= 655) ReefAngel.Relay.On(Port3);

       ReefAngel.Relay.DelayedOn( Port2 );
       //    ReefAngel.CO2Control( Port3,644,655 );
       ReefAngel.StandardFan( Port4,798,811 );
       ReefAngel.StandardLights( Port7,0,30,14,0 );
        ReefAngel.WavemakerRandom( Port6,600,120 );
       ReefAngel.StandardLights( Port8,12,0,2,0 );
       ReefAngel.PWM.SetDaylight(PWMSlope(17,0,0,3,0,12,3,0));
       ReefAngel.PWM.SetDaylight(PWMSlope(18,30,22,33,12,50,3,ReefAngel.PWM.GetDaylightValue()));
       ReefAngel.PWM.SetActinic( PWMSlope(15,0,1,0,0,70,60,0) );
       ////// Place your custom code below here
       ////// Place your custom code above here

       // This should always be the last line
       ReefAngel.Portal( "Bo0sted_Rafi" );
       ReefAngel.ShowInterface();
    }
    void DrawCustomMain()
   {
  byte x = 6;
  byte y = 2;
  byte t;
  char text[7];
 

  ReefAngel.LCD.DrawDate(6, 2);
  ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
  pingSerial();
 
  ReefAngel.LCD.DrawText(0,255,3,17,"    Rafi's 75 Reef");
 


  pingSerial();

  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 6, 90, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 6, 126, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 2, 93, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 2, 103, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 2, 113, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 2, 123, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 126, 93, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 126, 103, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 126, 113, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 126, 123, "|");
 


  ReefAngel.LCD.DrawText(0,255,10,30,"Display");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawText(COLOR_BLACK, 255, 10, 40, text);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,90,30,"CA pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawText(COLOR_BLACK, 255, 95, 40, text);
 
  pingSerial();

  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 77, TempRelay);

  pingSerial();
 
  ReefAngel.LCD.DrawText(0,255,8,100, "White"); 
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,15,119, ReefAngel.PWM.GetDaylightValue());
 
  ReefAngel.LCD.DrawText(0,255,88,100, "Blue"); 
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,90,119, ReefAngel.PWM.GetActinicValue());
 

}
    void DrawCustomGraph()
    {
    }


Image
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Another Alternative to get PWM Ports On

Post by Bo0sted_Rafi »

bump
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Another Alternative to get PWM Ports On

Post by rimai »

Sorry, I didn't understand what you meant.
Did you try using the wizard?
Roberto.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Another Alternative to get PWM Ports On

Post by Bo0sted_Rafi »

rimai wrote:Sorry, I didn't understand what you meant.
Did you try using the wizard?
When I start with this controller I used the wizard but now I modify the same code.

My LEDs ares hooked to the pwm channels but they are preprogrammed to gets on at 3pm to 1am, I want to get the alternative to get the lights on if I need it before the preprogrammed timer for maintenance or something.

I put the code you recommended and when the lights are on, they turns off when I toggle the port in the portal or the iPhone app but when the lights are off, I toggle the port to try to gets the lights on without luck
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Another Alternative to get PWM Ports On

Post by rimai »

What values for AP and DP does the screen show when you override port5 on?
Roberto.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Another Alternative to get PWM Ports On

Post by Bo0sted_Rafi »

rimai wrote:What values for AP and DP does the screen show when you override port5 on?
When the lights are on, if I override (toggle ports on my app) they shut down the lights and in the screen, they show the 00% in the lights. But I needs to get the lights on when they're off, then I tried to override (app or portal toggle) and the % don't change in the screen and lights don't gets on like I want/need!

Thanks Roberto for your time with my code. How you can understand my words
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Another Alternative to get PWM Ports On

Post by rimai »

You probably have the wrong settings in internal memory then.
You must have changed it to 0% at some point in time.
Try adding this to setup() section:

Code: Select all

InternalMemory.LEDPWMDaylight_write(100);
InternalMemory.LEDPWMActinic_write_write(100);
Make sure it is in the setup and not loop
Roberto.
Post Reply