Expansion hub and PWM Expansion hub coding

Do you have a question on how to do something.
Ask in here.
Post Reply
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Expansion hub and PWM Expansion hub coding

Post 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
Attachments
force_cloud_ato_modify11_8_11.pde
(15.56 KiB) Downloaded 395 times
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Expansion hub and PWM Expansion hub coding

Post 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
Roberto.
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: Expansion hub and PWM Expansion hub coding

Post 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.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Expansion hub and PWM Expansion hub coding

Post 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);
Roberto.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Expansion hub and PWM Expansion hub coding

Post 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
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: Expansion hub and PWM Expansion hub coding

Post 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
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Expansion hub and PWM Expansion hub coding

Post 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
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: Expansion hub and PWM Expansion hub coding

Post 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
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Expansion hub and PWM Expansion hub coding

Post 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
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Expansion hub and PWM Expansion hub coding

Post 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;
Roberto.
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: Expansion hub and PWM Expansion hub coding

Post 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??
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Expansion hub and PWM Expansion hub coding

Post by rimai »

What ID did you use on the relay expansion module?
Roberto.
divingdon
Posts: 57
Joined: Tue Mar 22, 2011 8:35 pm

Re: Expansion hub and PWM Expansion hub coding

Post 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;
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Expansion hub coding

Post 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?
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: Expansion hub and PWM Expansion hub coding

Post by rimai »

2nd method is prefered
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Expansion hub and PWM Expansion hub coding

Post 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
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: Expansion hub and PWM Expansion hub coding

Post by rimai »

Try this:

Code: Select all

ReefAngel.Relay.Set (Port1,(hour()%2==0));
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Expansion hub and PWM Expansion hub coding

Post 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
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: Expansion hub and PWM Expansion hub coding

Post by rimai »

Looks like Box1_Port1 is on override on mode.
Can you turn into auto mode and try again?
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Expansion hub and PWM Expansion hub coding

Post 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
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.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Expansion hub and PWM Expansion hub coding

Post 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
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.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Expansion hub and PWM Expansion hub coding

Post 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
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: Expansion hub and PWM Expansion hub coding

Post 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);
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Expansion hub and PWM Expansion hub coding

Post 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
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: Expansion hub and PWM Expansion hub coding

Post by rimai »

Correct, it will keep the charts updated :)
Roberto.
Post Reply