Tidal Effect Simulation

Share you PDE file with our community
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Tidal Effect Simulation

Post by lnevo »

Hmmm...maybe I did want the range cut in half...probably...not sure now...oh well, play with it later :)

Edit: reverted the change in the code above...after re-looking at the math...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

I think I can use the map() function to shift the range... this way I can stop banging my head and questioning myself... :)
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Tidal Effect Simulation

Post by DrewPalmer04 »

lnevo wrote:I think I can use the map() function to shift the range... this way I can stop banging my head and questioning myself... :)
HATE when that happens ;)
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

Modified the above code with the map function which looks to be working good in my test executable. Should be good. We'll see how test goes.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Tidal Effect Simulation

Post by lnevo »

Doing the constrain badly...need to reload later tonight. Thank god for graphs! ;)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

Yep... was actually doing the constrain twice and amplitude starts out -1 to 1. So... didn't need it.

Code modified in http://forum.reefangel.com/viewtopic.php?p=22049#p22049
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Tidal Effect Simulation

Post by lnevo »

I think the map function is not working as written. Hard to tell since based on current MoonPhase we should be close to minimum which I am, but I've seen no change... In any event, I plan on doing some debug tonight to confirm the values Im getting.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

Yeah, map did not like a number between 0 and 1. I multiplied by 100 and then used that in the map function :)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

So, I wanted to post some charts of that show the usage of the simulation.

Here is the graph of the default curve coming out of CalcTide() function. You can see that the high/low marks before Mar 25 are just slightly less than today's. This will continue to grow till we hit full moon.
Image

Here you can see the change of incoming/outgoing tide. I use the following code to address either channel 0 or channel 1 of my vortech pumps. I do the slower pump first so that RFS shows the higher value :)

Code: Select all

  ReefAngel.RF.SetMode(Custom,rcSpeedAS,tide.isOutgoing());
  ReefAngel.RF.SetMode(Custom,rcSpeed,tide.isIncoming());
Image

Here's the speed that my tide class is set to. You can see my transition to night mode around the 9pm and 10am marks.

Code: Select all

  tide.SetSpeed(PWMSlope-1(sl.GetRiseHour(),sl.GetRiseMinute(),
    sl.GetSetHour(),sl.GetSetMinute(),vtNightSpeed,vtSpeed,120,vtNightSpeed));
Image

And finally, the moment we've been building up to. This is the end result of the speed my vortech's are being set to. This is with the ReefCrest function applied to it. You could use whichever mode you wanted and feed the result similarly. The anti-sync output is applied to the second pump. That is the second graph.

Code: Select all

  int rcSpeed=ReefCrestMode(tide.CalcTide(),vtDuration,true);
Image
Currently the anti-sync pump is running at 70% of the main pump. The pumps switch roles during the switch from high toward low tide and vice-versa.

Code: Select all

  int rcSpeedAS=ReefCrestMode(tide.CalcTide(),vtDuration,false)*pumpOffset;
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Tidal Effect Simulation

Post by rimai »

Looks pretty cool :)
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

Just as a reference, my base speed is 45 and my night speed is 25.. So you don't see so much change in the graphs above. I do have 2 mp-40 on a 65g tank... so I try to avoid going above 65 (my Smart_NTM setting) :)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

oh, and I don't have good long term graphs because I keep playing with them... but at some point :)
dapg8gt
Posts: 104
Joined: Tue Apr 16, 2013 7:33 pm
Location: 650 Bay Area..

Re: Tidal Effect Simulation

Post by dapg8gt »

Has this code been working well for you? I'm going to be tinkering and setting up my RA in the next few weeks and so far I'm really liking this option. I still need to get the RF module but I will have 4 MP10's and 2 Wp40's on my tank and was wondering if this would be sufficient for that many pumps?

Still really new to RA but I need some randomized flow and the WP's are gonna prob be running max 50-70% so I would just have to alter the speeds and implement this code? Or would I have to have different options installed as I'm running the WP's off PWM and the MP's on the RF? Maybe I should just run the MP's on this and do a seperate code for the WP's?

Sorry if I sidetracked the thread a little but I def would like to try this out and have something that is really not a recurring/looping current.. Thanks in advance for the time put into the code. ;)
My other hobby has 450rwhp and eats tires instead of mysis!
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Tidal Effect Simulation

Post by lnevo »

dapg8gt wrote:Has this code been working well for you? I'm going to be tinkering and setting up my RA in the next few weeks and so far I'm really liking this option. I still need to get the RF module but I will have 4 MP10's and 2 Wp40's on my tank and was wondering if this would be sufficient for that many pumps?

Still really new to RA but I need some randomized flow and the WP's are gonna prob be running max 50-70% so I would just have to alter the speeds and implement this code? Or would I have to have different options installed as I'm running the WP's off PWM and the MP's on the RF? Maybe I should just run the MP's on this and do a seperate code for the WP's?

Sorry if I sidetracked the thread a little but I def would like to try this out and have something that is really not a recurring/looping current.. Thanks in advance for the time put into the code. ;)
This code is more about how you use it. There is a tide mode function now in the library or you could use the class posted. The difference being that the class tracks ebb and flow of the tide effect. Using the value by itself, you would get a constant speed that varied from a max speed to a min speed with two "high tides" and two "low tides" a day. The gap between the max and min is adjusted based on MoonPhase. I use this value returned and feed it to the RA ReefCrestMode and get that effect on top of it. I'm using the custom rf function so I can control each mp40 separately so I basically flip the primary pump when the tide changes. So far I've been happy. I'm going to go back Ectotech mode for a little while just to see if there's any difference.
dapg8gt
Posts: 104
Joined: Tue Apr 16, 2013 7:33 pm
Location: 650 Bay Area..

Re: Tidal Effect Simulation

Post by dapg8gt »

Thanks for responding. I am gonna have 2 wp40's along with the four MP10's . I think if I use the ecotechs with a tidal swell mode I can have the random chaotic flow delivered by my wp's.. just brainstorming and trying to gauge all my options as I will have a good chance that the MP's will not overpower the larger tank and can have them follow this code 24/7 while the wp adds the main flow and add night mode to them.. I may just run them all on alternating reef crest, lagoon and long pulse at various speeds antisynched between the two brands. Still unsure. Thanks for the info
My other hobby has 450rwhp and eats tires instead of mysis!
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

Latest version and 1.1.0 compatible
Attachments
Tide.zip
(1.52 KiB) Downloaded 662 times
Sleepingtiger
Posts: 32
Joined: Fri Aug 30, 2013 3:50 pm

Re: Tidal Effect Simulation

Post by Sleepingtiger »

is their an easy way to incorporate this code into my file? looking at this coding is like trying to count the number of branches on a birds nest.

I only have to WP40's with the max output at 80%.

I know this is asking alot, but can someone put the tidal effect simulation into my ino file?
Attachments
sketch_oct04a.ino
(4.51 KiB) Downloaded 602 times
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

The question I always ask when someone wants this is what do you want it to do?

The class is pretty easy to use and overall pretty easy to add, but you need to do something with the data it gives you... Right now the output looks like a wave going from the min speed to the max speed 2 times a day (2 high tides and 2 low todes per 24 hours). The speed needs to get passed back to something like the other wave functions, otherwise it's just a constant speed.
Sleepingtiger
Posts: 32
Joined: Fri Aug 30, 2013 3:50 pm

Re: Tidal Effect Simulation

Post by Sleepingtiger »

lnevo wrote:The question I always ask when someone wants this is what do you want it to do?

The class is pretty easy to use and overall pretty easy to add, but you need to do something with the data it gives you... Right now the output looks like a wave going from the min speed to the max speed 2 times a day (2 high tides and 2 low todes per 24 hours). The speed needs to get passed back to something like the other wave functions, otherwise it's just a constant speed.

is that pig latin? LOL

ok, what data are you refering too? are you talking about the graphs... ummm, i don't need it

can it go back to reefcrest mode or lagoon or nutrient export mode?
Image
89delta
Posts: 163
Joined: Mon Oct 15, 2012 7:21 pm
Location: Leesburg, GA

Re: Tidal Effect Simulation

Post by 89delta »

lnevo

I've tried to add this to my nighttime mode but am getting some errors....here is the error msg:

My_RA_Version2_1.cpp: In function 'void loop()':
My_RA_Version2_1:253: error: expected primary-expression before '.' token
My_RA_Version2_1:253: error: '2' cannot be used as a function

And this is the code in the loop:

// Jebao Code
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
pinMode(lowATOPin,OUTPUT);
analogWrite(lowATOPin,ReefCrestMode(50,20,true)*2.55);
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.LowATOChannel = Sync ; // Jebo connected to AtoPINLow



// Add random mode if we set to Mode to Custom in portal
static int rmode;
static boolean changeMode=true;


// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { Lagoon, ReefCrest, TidalSwell, Sine, Gyre, NutrientTransport, Else };

if (now()%SECS_PER_DAY==0 || changeMode==true) { // Change at midnight or if controller rebooted
rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
changeMode=false;
}

// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();

if (now()-feeding<900) {
// First 15 minutes after feeding mode stops. Smart_NTM
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()-feeding<2250) { // 15 minutes plus 1 hour
// Continue NTM for the next 60 minutes (75 minutes total)
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<27000 || now()%SECS_PER_DAY>=67500) { // 8:30am / 10:30pm
// Night mode (go to 30%)
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Mode=(Custom,ReefCrest(Tide.CalcSpeed()),-1Tide.isIncoming());
//ReefAngel.DCPump.Speed=30;

} else if (InternalMemory.DCPumpMode_read()==11) {
// Custom Mode and nothing else going on
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
if (modes[rmode]==Else) {
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Mode=Constant;
ReefAngel.DCPump.Speed=ElseMode(InternalMemory.DCPumpSpeed_read(),25,true ); // ElseMode on sync mode, Portal Speed Setting +/- 25%
} else {
ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
}
} else {
ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

I don't think the same code can be used with DCPump. I think you could just set the Speed to the result and Mode to Constant.

Then I'd flip the channels based on Tide.isIncoming();

Code: Select all

if (Tide.isIncoming()) {
  ReefAngel.DCPump.ActinicChannel=None;
  ReefAngel.DCPump.StandardChannel=Sync;
} else {
  ReefAngel.DCPump.ActinicChannel=Sync;
  ReefAngel.DCPump.StandardChannel=None;
}
Another thing you could do is set the AntiSyncOffset. Below 100 will reduce the Anti-Sync channel, above 100 will raise the Anti-Sync channel.

Code: Select all

ReefAngel.DCPump.Speed=Tide.CalcSpeed();
if (Tide.isIncoming()) {
  ReefAngel.DCPump.ActinicOffset=150;
} else {
  ReefAngel.DCPump.ActinicOffset=50;
}
Your main compiling issue though is you have -1Tide.isIncoming() which should be -1*Tide.isIncoming()
89delta
Posts: 163
Joined: Mon Oct 15, 2012 7:21 pm
Location: Leesburg, GA

Re: Tidal Effect Simulation

Post by 89delta »

Thanks lnevo,
Will try this out tonight after work.

Sent from my Samsung Galaxy Note 3
saf1
Posts: 111
Joined: Thu Jun 28, 2012 1:46 pm

Re: Tidal Effect Simulation

Post by saf1 »

lnevo wrote:I don't think the same code can be used with DCPump. I think you could just set the Speed to the result and Mode to Constant.

Then I'd flip the channels based on Tide.isIncoming();

Code: Select all

if (Tide.isIncoming()) {
  ReefAngel.DCPump.ActinicChannel=None;
  ReefAngel.DCPump.StandardChannel=Sync;
} else {
  ReefAngel.DCPump.ActinicChannel=Sync;
  ReefAngel.DCPump.StandardChannel=None;
}
This is actually what I'm looking for I believe although I'm not 100% sure(still reading the various threads). I used the arduino wizard to finally get the two RW 4's I have running and the code is below. However, when I try and add in the tide code I am running into some compile issues. One issue I think I saw is that my code is referencing DaylightChannel and ActinicChannel. The code above is using ActinicChannel and StandardChannel. I swapped to match what I have running still no luck. Also when it says =None I would probably want to change that to be Sync and AntiSync so they are both running. Let the night mode slow them down?


All I should have to do is load in the Tide.h header to access the functions or is there something else that I'm not understanding yet? The compile error is below so I'm sure it is something I'm not doing correctly.

sketch_wavemodule.cpp: In function 'void loop()':
sketch_wavemodule:98: error: expected primary-expression before '.' token
sketch_wavemodule:121: error: expected `}' at end of input

Here is the code that is currently controlling the two RW-4's and I'd like to see if I can use the tide/moon patterns. Just missing something.

ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode( ReefCrest,55,10 );
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Tidal Effect Simulation

Post by lnevo »

Your error is coming from somewhere else. It's a syntax error. Whats the tide code your trying to add? Post your before and after code in full.
saf1
Posts: 111
Joined: Thu Jun 28, 2012 1:46 pm

Re: Tidal Effect Simulation

Post by saf1 »

lnevo wrote:Your error is coming from somewhere else. It's a syntax error. Whats the tide code your trying to add? Post your before and after code in full.
Yeah, it is a compile or type-o on my part for sure. I removed it and added a if statement to slow them down after lights out. That appeared to work ok. At this point and time it is more of a learning / reading threads to understand how the libraries work that I want to use. I see the tidal simulation and also found the weather pattern based on location. Both of which sound super cool but not sure how to implement :)

Also am trying to understand what the various power head modes do. I have reef crest implemented now and saw a graph somewhere, not sure where now, but it looked cool. Not sure how the sync anti-sync work though. My original post was to make them alternate so they don't always go the same direction - thus tide/high/low. Does the library automatically sync-anti-sync or change directions based on a set time?

Anyway - they are working now and slow down at night. That was the first hurdle. Now it is just playing and learning. Like why Daylight is 41% vs. Actinic at 69% (they change all the time) but I have power set to 55%? Even if it is plus 10, I am over and seen it higher.

Thanks - searching and reading :) Good stuff and love the additions.

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 <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>
#include <Tide.h>  // testing for tide control

////// Place global variable code below here
Tide tide;  // testing for tide control

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


void setup()
{
 // This must be the first line
 ReefAngel.Init(); //Initialize controller
 ReefAngel.Use2014Screen(); // Let's use 2014 Screen 
 ReefAngel.AddPHExpansion(); // pH Expansion Module
 // Ports toggled in Feeding Mode
 ReefAngel.FeedingModePorts = Port1Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
 // Ports toggled in Water Change Mode
 ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
 // Ports toggled when Lights On / Off menu entry selected
 ReefAngel.LightsOnPorts = 0;
 // Ports turned off when Overheat temperature exceeded
 ReefAngel.OverheatShutoffPorts = Port2Bit;
 // Use T1 probe as temperature and overheat functions
 ReefAngel.TempProbe = T1_PROBE;
 ReefAngel.OverheatProbe = T1_PROBE;
 // Set the Overheat temperature setting
 InternalMemory.OverheatTemp_write( 869 );

 // Feeeding and Water Change mode speed
 ReefAngel.DCPump.FeedingSpeed=0;
 ReefAngel.DCPump.WaterChangeSpeed=0;

 // Ports that are always on
 ReefAngel.Relay.On( Port1 );  // skimmer
 // ReefAngel.Relay.On( Port4 );  // LED Fans
 ReefAngel.Relay.On( Port5 );  // RW 4 left side facing tank
 ReefAngel.Relay.On( Port6 );  // RW 4 right side facing tank

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


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

void loop()
{
 ReefAngel.StandardLights( Port2,9,0,21,0 ); // power to LED power supply
 ReefAngel.StandardLights( Port4,9,0,21,0 ); // LED fans
// ReefAngel.WavemakerRandom( Port5,5,90 ); // Not sure what these are for now
// ReefAngel.WavemakerRandom( Port6,5,90 ); // Not sure what these are for now
// ReefAngel.StandardLights( Port7,9,0,21,0 );
// ReefAngel.StandardLights( Port8,9,0,21,0 );

// Channel 0 (1000mA max) - 5 Neutral White
// Channel 1 (1000mA max) - 6 Royal Blue + 5 Blue
// Channel 2 (700mA max) - 12 Lime
// Channel 3 (700mA max) - 5 Violet UV + 4 Deep Red (660nm)
 ReefAngel.PWM.SetChannel( 0, PWMParabola(10,0,21,0,0,65,0) );
 ReefAngel.PWM.SetChannel( 1, PWMParabola(10,0,21,0,0,75,0) );
 ReefAngel.PWM.SetChannel( 2, PWMParabola(10,0,21,0,0,65,0) );
 ReefAngel.PWM.SetChannel( 3, PWMParabola(10,0,21,0,0,65,0) );

 ReefAngel.DCPump.UseMemory = false;
 // ReefAngel.DCPump.SetMode( ReefCrest,55,10 );
 
 ReefAngel.DCPump.DaylightChannel = Sync;
 ReefAngel.DCPump.ActinicChannel = AntiSync;

// ReefAngel.DCPump.ExpansionChannel[0] = None;
// ReefAngel.DCPump.ExpansionChannel[1] = None;
// ReefAngel.DCPump.ExpansionChannel[2] = None;
// ReefAngel.DCPump.ExpansionChannel[3] = None;
// ReefAngel.DCPump.ExpansionChannel[4] = None;
// ReefAngel.DCPump.ExpansionChannel[5] = None;
 
 ////// Place your custom code below here

if (hour()>=21 || hour()<10)
{
 // Sleep mode - slow things down 
 ReefAngel.DCPump.SetMode( ReefCrest,25,10 );
}
else
{
// Normal power
 ReefAngel.DCPump.SetMode( ReefCrest,55,10 );
}

 ////// Place your custom code above here

 // This should always be the last line
 ReefAngel.Portal( "saf1" );
 ReefAngel.DDNS( "saf1-dns.myreefangel.com" ); // Your DDNS is saf1-saf1-dns.myreefangel.com.myreefangel.com
 ReefAngel.ShowInterface();
}
Post Reply