Page 1 of 1

Expansion hub and PWM Expansion hub coding

Posted: Mon Nov 14, 2011 2:36 pm
by divingdon
Attached is my current code thanks to Roberto with a few little mods that I added. But I'm having problems coding the 2nd relay box. Do I just add the relays as relay 9-16 or do I have to call them out as something else? Also I have 2 expansion modules one for the relays and one of the LEDs but the PWM expansion module doesn't have dip switches so do I put that module into slot one and set the Dip switch in the relay box expansion module to position 2?

Any sort of guidance would be great!!

Don

Re: Expansion hub and PWM Expansion hub coding

Posted: Mon Nov 14, 2011 3:26 pm
by rimai
On the relay expansion module, use ID #1.
Then you can just call relays 11 through 18.
If you use ID#2, you would use relays 21 through 28. And so forth for the other IDs.
The order and position where you place them on the hub is irrelevant. You can place them in whichever port you wish.
Make sure to have the following line on the ReefAngel_Features.h file:

Code: Select all

#define RelayExp

Re: Expansion hub and PWM Expansion hub coding

Posted: Mon Nov 14, 2011 7:10 pm
by divingdon
I had the line in both the sketch and the ReefAngel_features.h file and when i try to compile it tells me the port 11-18 have not been declared.

Re: Expansion hub and PWM Expansion hub coding

Posted: Mon Nov 14, 2011 7:17 pm
by rimai
My bad.
You have to use either of this:

Code: Select all

ReefAngel.Relay.On(11);
or

Code: Select all

ReefAngel.Relay.On(Box1_Port1);

Re: Expansion hub and PWM Expansion hub coding

Posted: Mon Nov 14, 2011 7:18 pm
by binder
divingdon wrote:I had the line in both the sketch and the ReefAngel_features.h file and when i try to compile it tells me the port 11-18 have not been declared.
you either use the number 11 through 18 or you use the defines which are Box1_Port1

Code: Select all

 ReefAngel.Relay.On(Box1_Port1);

the additional boxes use the format Box#_Port# for reference.

curt

Re: Expansion hub and PWM Expansion hub coding

Posted: Mon Nov 14, 2011 7:32 pm
by divingdon
Great that work my last question is can I just add 1 and 0's to feed, water change, lights on port and over temp

Re: Expansion hub and PWM Expansion hub coding

Posted: Tue Nov 15, 2011 5:32 am
by binder
divingdon wrote:Great that work my last question is can I just add 1 and 0's to feed, water change, lights on port and over temp
In order to do them, you need to use the variables for them. They work exactly like the ones for the main relay except the variable is named a little different.

FeedingModePortsE[]
WaterChangePortsE[]
OverheatShutoffPortsE[]
LightsOnPortsE[]

They are arrays that you can assign the 0 & 1's to just like the main relay. The index starts at 0 for the first expansion relay box.

So this will be the code you can use for the first expansion relay:

Code: Select all

FeedingModePortsE[0] = B00000000;
WaterChangePortsE[0] = B00000000;
OverheatShutoffPortsE[0] = B00000000;
LightsOnPortsE[0] = B00000000;
As you can tell, those will not toggle any ports but you can adjust as needed.

curt

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Nov 16, 2011 3:14 pm
by divingdon
So if I understand correctly I would code like this

FeedingModePortsE[0] = B10011100;
WaterChangePortsE[0] = B10111111;
OverheatShutoffPortsE[0] = B00000011;
LightsOnPortsE[0] = B00000011;

FeedingModePortsE[1] = B11111111;
WaterChangePortsE[1] = B11111111;
OverheatShutoffPortsE[1] = B00101010;
LightsOnPortsE[1] = B00000000;

With 0=on and 1= off

Correct?
I now get this error "FeedingModePortsE not declared in this scope" when I try to complie did I miss something

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Nov 16, 2011 6:42 pm
by binder
you must have define RelayExp in your features file for it to compile.

what i described will work for the expansion relays only. you still use the default way for the main relay. so the first relay box is index 0. in your post it looks like you have 2 expansion relays, is that correct?

curt

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Nov 16, 2011 7:53 pm
by rimai
I think what you are trying to do is:

Code: Select all

FeedingModePorts = B10011100;
WaterChangePorts = B10111111;
OverheatShutoffPorts = B00000011;
LightsOnPorts = B00000011;

FeedingModePortsE[0] = B11111111;
WaterChangePortsE[0] = B11111111;
OverheatShutoffPortsE[0] = B00101010;
LightsOnPortsE[0] = B00000000;

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Nov 16, 2011 7:56 pm
by divingdon
yes i have 2 relay box and i did define RelayExp in my sketch and feature file. The 2nd relay box is current controlling heaters, fans and a few other things correctly

Roberto that didnt work either??

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Nov 16, 2011 7:58 pm
by rimai
What ID did you use on the relay expansion module?

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Nov 16, 2011 8:02 pm
by divingdon
We didnt add the ReefAngel. in front of the command now it works I left the expansion module with the your default I believe it was set to 1

So would I have to change the command to this???

ReefAngel.FeedingModePortsE[1] = B11111111;
ReefAngel.WaterChangePortsE[1] = B11111111;
ReefAngel.OverheatShutoffPortsE[1] = B00101010;
ReefAngel.LightsOnPortsE[1] = B00000000;

Re: Expansion hub coding

Posted: Mon Jun 25, 2012 7:05 pm
by rossbryant1956
rimai wrote: You have to use either of this:

Code: Select all

ReefAngel.Relay.On(11);
or

Code: Select all

ReefAngel.Relay.On(Box1_Port1);
Trying to learn how to address the ports on my relay expansion box..is it as simple as this?

Re: Expansion hub and PWM Expansion hub coding

Posted: Mon Jun 25, 2012 7:11 pm
by rimai
2nd method is prefered

Re: Expansion hub and PWM Expansion hub coding

Posted: Tue Jun 26, 2012 9:02 am
by rossbryant1956
Hi roberto;

What would be the best method to turn a port on for a hour or so, then off for an hour or so and then toggle off and on forever. I am using a powerhead to just stir some chemicals in my top off bucket. Thx

Re: Expansion hub and PWM Expansion hub coding

Posted: Tue Jun 26, 2012 9:05 am
by rimai
Try this:

Code: Select all

ReefAngel.Relay.Set (Port1,(hour()%2==0));

Re: Expansion hub and PWM Expansion hub coding

Posted: Tue Jun 26, 2012 7:52 pm
by rossbryant1956
I installed this code tonite and it doesn't appear to be working. You can see on the portal where it came on and has not yet turned off. LMK what I can try next. Thx

Code: Select all

//stir chemicals in water top off unit
     ReefAngel.Relay.Set (Box1_Port1,(hour()%2==0));
this is how I wrote the line

Re: Expansion hub and PWM Expansion hub coding

Posted: Tue Jun 26, 2012 9:16 pm
by rimai
Looks like Box1_Port1 is on override on mode.
Can you turn into auto mode and try again?

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Jun 27, 2012 3:42 am
by rossbryant1956
rimai wrote:Looks like Box1_Port1 is on override on mode.
Can you turn into auto mode and try again?
Did that this morning over coffee. Went back to portal couple of minutes later and it had switched back to "on." Thx

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Jun 27, 2012 5:01 am
by rossbryant1956
looked again a few minutes later and is now back to auto. Device is now off, but is showing as auto and green (on) on the portal screen. Expansion box is currently not showing up in the relay charts but does show up on the main dashboard. thx

And finally device just turned back on at the top of the hour... so, I will monitor today and let you know how it goes, but wanted to report in. Thx

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Jun 27, 2012 6:06 am
by rossbryant1956
Update: device is working as expected, turning off and on top of each hour; however when the device is on the portal is showing activity in relay activity charts, yet when the device is off, it shows nothing from any of the ports on box1. Thx

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Jun 27, 2012 7:39 am
by rimai
The portal by design doesn't store anything when something is off to save space on the database.
What that does is it thinks that your controller doesn't have any expansion module because there is nothing on.
If you use the code below, your relay activity in th Portal will show properly until you get some of those other ports used up.

Code: Select all

ReefAngel.Relay.On(Box1_Port8);

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Jun 27, 2012 9:48 am
by rossbryant1956
thx, so this is just going to set that port on even if not used so it will keep up the charts? I'll use this until I am thru testing and then remove, I don't need it once I understand what I'm seeing. Thx

Re: Expansion hub and PWM Expansion hub coding

Posted: Wed Jun 27, 2012 10:05 am
by rimai
Correct, it will keep the charts updated :)