Its possible to control PWM channels with Iphone App?

Request new hardware or ideas for the controller
Post Reply
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Its possible to control PWM channels with Iphone App?

Post by Bo0sted_Rafi »

I just hooked up my drivers to the pwm dimming ports but i need to know if i can change the parameters without change the code. For example, if i need to gets the lights on for something to work with the tank or if i got visit in my house in the hours i dont get programed my lights. My sketch its in code, not in the iternal memory. Any option if i want to do this in case if i need to get lights on?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Its possible to control PWM channels with Iphone App?

Post by rimai »

You need to assign a port for Lights On. Even if it its a moonlight port.
When you override that port, it will also override the PWM channels.
Roberto.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Bo0sted_Rafi »

Sorry rimai, I don't use any relay ports for the lights, my meanwell drivers are connected to another power source, i just hook the dimming cables. I don't know if I understand well.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Its possible to control PWM channels with Iphone App?

Post by rimai »

You can use your moonlight as a trigger.
It would override the moonlight, but I think it would be ok, right?
Roberto.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Bo0sted_Rafi »

How can i do that? I will post my code in minutes
Image
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Bo0sted_Rafi »

here its my code
#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 | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port6Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
// 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 );
ReefAngel.Relay.On( Port5 );

////// 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 <= 643) ReefAngel.Relay.Off(Port3);
if (totalavgph >= 656) ReefAngel.Relay.On(Port3);

ReefAngel.Relay.DelayedOn( Port2 );
// ReefAngel.CO2Control( Port3,644,655 );
ReefAngel.StandardFan( Port4,780,788 );
ReefAngel.WavemakerRandom( Port6,1200,240 );
ReefAngel.StandardLights( Port7,0,30,12,30 );
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,45,3,ReefAngel.PWM.GetDaylightValue()));
ReefAngel.PWM.SetActinic( PWMSlope(15,0,1,0,9,60,60,9) );
////// 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;
byte y = 2;
char text[7];

// IF the code size is too big, delete all the lines between the
// next line and the //****** line below (the lines in reference to TempColor
// *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
int TempColor; // Color for drawing temperature
boolean FanOn = ReefAngel.Relay.Status(Port4); // Get the status of the fan relay
boolean HeatOn = ReefAngel.Relay.Status(Port7); // Get the status of the heater relay
if (HeatOn)
{
TempColor = COLOR_NAVY; // Blue text, too cold, heater is on
}
if (FanOn)
{
TempColor = COLOR_RED; // Red text, too warm, fan is on
}
if (!HeatOn && !FanOn)
{
TempColor = COLOR_GREEN; // Green text, no fan or heater on
}
// ***********************************************************************************

// Put a banner at the top
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Rafi's Reef");
// Put the date and time at the bottom
ReefAngel.LCD.DrawDate(6, 119);
// Draw a black line under the banner
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
x = 12;
// MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
y += MENU_START_ROW+1;
ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp CA pH");
// Get pH reading and convert
ConvertNumToString(text, ReefAngel.Params.PH, 100);
// Put pH on the screen
ReefAngel.LCD.DrawText(PHColor, DefaultBGColor, x+75, y+18, text);
// Get T1 temp and convert
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
y += MENU_START_ROW*2;
x = 10;

// Draw the temperature
// IF you removed the other lines mentioned, you need to uncomment out
// this next line in order to display your temperature on the screen
// Do so by removing the double // in front of ReefAngel
//ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x, y, text);

// Draw the temperature, white numbers on a colored background
// IF the code size is still too big, comment out the next line by placing
// 2 forward slashes in front of the ReefAngel or delete the line completely
ReefAngel.LCD.DrawText(COLOR_WHITE, TempColor, x, y, text);

// Code for drawing the relay box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
}
void DrawCustomGraph()
{
}
just let me know what i need to do and how to do it! im still a noob with this things of coding
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Its possible to control PWM channels with Iphone App?

Post by rimai »

This line already sets all ports as light ports:

Code: Select all

ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port6Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
If you override any port to always on, your PWM channels will be overwritten too.
Roberto.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Bo0sted_Rafi »

rimai wrote:This line already sets all ports as light ports:

Code: Select all

ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port6Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
If you override any port to always on, your PWM channels will be overwritten too.
Then when I need to get the lights on in any moment, how I do it? I'm still a little lost
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Its possible to control PWM channels with Iphone App?

Post by rimai »

Override the port to always on with portal, android app or client.
Roberto.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Bo0sted_Rafi »

ok i override the code but now i got a problem, the port6 its a randomwavemaker and now dont turn on. when i tried to get it on with the iphone app, the lights go off. when i put again in auto mode, the lights goes on but the wavemaker never gets the random timer to on
Image
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Bo0sted_Rafi »

Rimai, i dont know why when I toggle some ports with the iPhone app, the lights goes off. It's that normal?
Image
Elevatorguy1
Posts: 42
Joined: Wed Apr 17, 2013 6:21 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Elevatorguy1 »

Hmm.. I have the same problem. When I use the lights on/off function on the head unit to turn on my sump light the main display lights dim. Is there a way to fix this?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Its possible to control PWM channels with Iphone App?

Post by rimai »

It will always override the dimming channels.
The alternative is to turn on/off by using a smart phone app.
Roberto.
Elevatorguy1
Posts: 42
Joined: Wed Apr 17, 2013 6:21 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Elevatorguy1 »

Same thing happens when I use the iPhone app
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Its possible to control PWM channels with Iphone App?

Post by rimai »

Oh, you must remove the sump from your LightsOnPort
Roberto.
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Its possible to control PWM channels with Iphone App?

Post by Bo0sted_Rafi »

i dont understand about this. can you explain me better how i do it?
Image
Post Reply