Custom vortech modes

Expansion modules and attachments
Post Reply
Appleseed
Posts: 86
Joined: Sat Jun 30, 2012 9:21 am

Custom vortech modes

Post by Appleseed »

Hello,

I currently have my mp40s running in differant modes at various times to of the day;

for example:

Code: Select all

 else if (hour()>=0 && hour()<1)
            ReefAngel.RF.SetMode(Lagoon,50,15);           
         else if (hour()>=1 && hour()<2)
            ReefAngel.RF.SetMode(Lagoon,40,20);            
         else if (hour()>=2 && hour()<3)
            ReefAngel.RF.SetMode(Lagoon,30,25);            
         else if (hour()>=3 && hour()<4)
            ReefAngel.RF.SetMode(Lagoon,40,20);                     
         else if (hour()>=4 && hour()<5)
I would like to use the custom mode at specific times for each of the channels.

So for example sake between 4 & 5 am I might like the following;
SetMode(Custom,30,0)
SetMode(Custom,60,1)
SetMode(Custom,40,3)

and between 5 & 6 am:

SetMode(Custom,60,0)
SetMode(Custom,30,1)
SetMode(Custom,80,3)

and so on...

The question I have is how to do it? I tried the following;

Code: Select all

else if (hour()>=4 && hour()<5)
SetMode(Custom,30,0) 
SetMode(Custom,60,1)
SetMode(Custom,40,3)
else if (hour()>=5 && hour()<6)
SetMode(Custom,60,0) 
SetMode(Custom,30,1)
SetMode(Custom,80,3)
But (I guess for obvious reasons) it does not work.

My guess is I need to define a variable alone the lines of the following;

Cust_1 = SetMode(Custom,30,0) ;SetMode(Custom,60,1);SetMode(Custom,40,3)

Cust_2 = SetMode(Custom,60,0) ;SetMode(Custom,30,1);SetMode(Custom,80,3)

and then I can run this at a specific time by doint something like the following,

else if (hour()>=4 && hour()<5)
Cust_1
else if (hour()>=5 && hour()<6)
Cust_2

Unless I can just have all three on one line ie
else if (hour()>=4 && hour()<5)
SetMode(Custom,60,0), SetMode(Custom,30,1), SetMode(Custom,80,3)
else if (hour()>=5 && hour()<6)
SetMode(Custom,30,0), SetMode(Custom,60,1), SetMode(Custom,40,3)

Which I have not tried tbh.

Any help is appreciated.

cheers

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

Re: Custom vortech modes

Post by rimai »

Humm... That's a tricky one :)
Let me think about it and check how the custom code underlying code works. I already forgot :(
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom vortech modes

Post by rimai »

But, I know that channel 3 doesn't exist.
Channel 0 = sync
Channel 1= anti-sync
Channel 2 = back-of-tank
Just as curiosity, what happens when you use this:

Code: Select all

ReefAngel.RF.SetMode(Custom,30,0) 
ReefAngel.RF.SetMode(Custom,60,1)
ReefAngel.RF.SetMode(Custom,40,2)
Roberto.
Appleseed
Posts: 86
Joined: Sat Jun 30, 2012 9:21 am

Re: Custom vortech modes

Post by Appleseed »

Sorry my bad i know its 0-2 any how i tried to verify the code and got the following error;
Ninth_attempt.cpp: In function 'void loop()':
Ninth_attempt:234: error: 'else' without a previous 'if'

Code: Select all

          else if (hour()>=19 && hour()<20)
            ReefAngel.RF.SetMode(Constant,40,10);                        
          else if (hour()>=20 && hour()<21)
//          ReefAngel.RF.SetMode(Constant,30,10);   
  
            ReefAngel.RF.SetMode(Custom,30,0);
	    ReefAngel.RF.SetMode(Custom,90,1);
	    ReefAngel.RF.SetMode(Custom,150,2);          
      
          
          else if (hour()>=21 && hour()<22)               ///<Line 234
//            ReefAngel.RF.SetMode(Custom,30,0);
//	    ReefAngel.RF.SetMode(Custom,90,1);
//	    ReefAngel.RF.SetMode(Custom,150,2);          
          
            ReefAngel.RF.SetMode(Constant,40,10);
          else if (hour()>=22 && hour()<23)
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom vortech modes

Post by rimai »

A if statement that has more than one line needs to be enclosed in {}

Code: Select all

{
  ReefAngel.RF.SetMode(Custom,30,0);
  ReefAngel.RF.SetMode(Custom,90,1);
  ReefAngel.RF.SetMode(Custom,150,2);          
}
Roberto.
Appleseed
Posts: 86
Joined: Sat Jun 30, 2012 9:21 am

Re: Custom vortech modes

Post by Appleseed »

Thanks Roberto I can verify the code so it will hopefully work.

Next question I have is I would like to change the speed every 15 minutes, so for example sake at 5am i would like it to start as follows:
ReefAngel.RF.SetMode(Custom,30,0)
then 15 minutes later change to
ReefAngel.RF.SetMode(Custom,40,0)
then
ReefAngel.RF.SetMode(Custom,50,0)
etc

Can you suggest how I can do this following the lines of may else if (hour() ... ?
Also am I in danger of making the program too "large"? . I have the plus controller.
cheers
Andy
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom vortech modes

Post by rimai »

You can use slope and have it gradually increase. Wouldn't it be better?

Code: Select all

ReefAngel.RF.SetMode(Custom,PWMSlope(5,0,17,0,30,100,70,0),0);
Roberto.
Appleseed
Posts: 86
Joined: Sat Jun 30, 2012 9:21 am

Re: Custom vortech modes

Post by Appleseed »

that sounds like a plan. can you explqin what the variables are. im guessing start at 5 am finish at 5 pm. start % 30 end% 100 but not sure about the rest.

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

Re: Custom vortech modes

Post by rimai »

Roberto.
Appleseed
Posts: 86
Joined: Sat Jun 30, 2012 9:21 am

Re: Custom vortech modes

Post by Appleseed »

thanks, i will give that a go.
Image
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: Custom vortech modes

Post by TanksNStuff »

Hmm, I didn're realize you could use PWMSlope as a variable for other functions. That's interesting and if I ever get some free time I might experiment with this.

I'm guessing you could also do the same thing with Parabola too?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom vortech modes

Post by rimai »

yeap :)
Roberto.
Post Reply