Forum Software Ferduino code Wavemaker mode change when selected

Wavemaker mode change when selected  [SOLVED]


Post Number:#1 Post Sat May 21, 2016 10:37 am
Len Nederlof Random avatar
Hello Fernando,

In my old controller I used THIS program to automatically change the wavemaker modes, this works great.
In my new controller I also want to change the wavemaker modes, but I only want to do that when choosing wavemaker mode 5. If I choose one of the other 4 modes, I want that mode only to work.

I made the following changes:

in ferduino tab on the beginning
// for alternating mode wavemakers
#define alternating_wave


At the end of ferduino tab
unsigned long interval_wave_millis = 0;
int interval_wave = 120; // in minutes
boolean alternated_mode = false ;


in wavemaker tab
 else if (modo_selecionado == 5)


if (modo_selecionado == 5)

#ifdef alternating_wave
if  (modo_selecionado == 5)
{
alternated_mode = true ;
}
else
{
alternated_mode = false ;
}
#endif


and on Loop tab
  Wavemaker();
  //******************
  #ifdef alternating_wave
 
#endif
    if (alternated_mode == true )
     
{
  if((millis() - interval_wave_millis) > (interval_wave*60000))
  {
    modo_selecionado += 1;

    if(modo_selecionado > 4)
    {
      modo_selecionado = 1;
    }
    interval_wave_millis = millis();
  }
}
  //******************

If I choose 1,2,3 or 4, the mode stays the same so that is ok.
If I choose mode 5, the mode of the wave makers starts to change every 2 hours so that is also ok.
But when I choose one of the other modes after mode 5 it keeps changing every 2 hours instead of only the selected mode.

Can you give me advice or help me with this
Kind regards Len

Post Number:#2 Post Sat May 21, 2016 12:10 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

Try this:

#ifdef alternating_wave
if  (modo_selecionado == 5)
{
alternated_mode = true ;
}
else
{
alternated_mode = false ;
}
#endif


  #ifdef alternating_wave
  if (alternated_mode == true )
{
  if((millis() - interval_wave_millis) > (interval_wave*60000))
  {
    modo_selecionado += 1;

    if(modo_selecionado > 4)
    {
      modo_selecionado = 1;
    }
    interval_wave_millis = millis();
  }
}
#endif


Best regards
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#3 Post Sat May 21, 2016 3:53 pm
Len Nederlof Random avatar
Hi Fernando,

Thank you for the help.
I tried your code, when selecting mode 5 it starts to change the wavemaker modes when selecting an other mode after that it still keeps changing the the different modes.
I think that the problem is in "alternated_mode = true" that stays "true"or wont turn to "false" after selecting a other mode.
Kind regards

Post Number:#4 Post Sat May 21, 2016 4:11 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Have you removed this part on code?

  else if (modo_selecionado == 5)
  {
    Pump1PWM = Pump1PWM_temp;
    Pump2PWM = Pump2PWM_temp;
  }
  if (wavemaker_on_off == true)
  {
    Pump1PWM = Pump2PWM = 0;
  }


Add some debug messages on loop to see how it is working:

Serial.print("modo_selecionado: ");
Serial.println(modo_selecionado);
Serial.print("alternated_mode: ");
Serial.println(alternated_mode); // 1 = true and 0 = false
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#5 Post Tue May 24, 2016 11:05 am
Len Nederlof Random avatar
Hello Fernando,

I tried the code en debug code.
When i select mode 5 the serial monitor shows

modo_selecionado =5
alternated_mode =1

Then the mode switch to 1, the serial monitor shows

modo_selecionado=1
alternated_mode=0
I tried to get the code to work so that the alternated_mode stays 1 until I select it but i can't get i wright. :(
I tried the folowing
#ifdef alternating_wave
if  (modo_selecionado == 5)
{
alternated_mode = true ;
}
else 
if ((modo_selecionado == 5)&&(alternated_mode == true))
{
alternated_mode = false ;
}
#endif

but than atlternated_mode won't switch of anymore.
Only if i change it to
if ((modo_selecionado == 4)&&(alternated_mode == true))

it switch of after selecting mode 4. :-\

Post Number:#6 Post Tue May 24, 2016 12:10 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

When i select mode 5 the serial monitor shows

modo_selecionado =5
alternated_mode =1

Then the mode switch to 1, the serial monitor shows

modo_selecionado=1
alternated_mode=0


Hi!

This behaviour is right. The code should work.

Give me all your code in a zip file.

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#7 Post Sun May 29, 2016 6:17 am
Len Nederlof Random avatar
Hi Fernando,

I know that this behaviour is right, and the program works. :)

I wanted to start and stop the automatic mode myself, so I made the following changes.

 
#ifdef alternating_wave
if  (modo_selecionado == 4)
{
alternated_mode = true ;
}
else if (modo_selecionado == 5)
{
alternated_mode = false ;
}
#endif

I can now select mode 4 to start automatic wavemaker change and if I want it to stop the automatic mode I can select mode 5.
Thanks for the Help.

Post Number:#8 Post Sun May 29, 2016 12:08 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

This is not good idea because you will lose two modes to manage one.

The option below is better because to stop the interchange is needed only select a mode between 1 and 4.

#ifdef alternating_wave
if  (modo_selecionado == 5)
{
alternated_mode = true ;
}
else
{
alternated_mode = false ;
}
#endif


Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#9 Post Sat Jun 04, 2016 6:20 am
Len Nederlof Random avatar
Hi,

I understand thats not the best solution becaus I lose 2 modes.
I tried and tried. I even started with a new sketch and tried again.

If I use your example the wavemaker starts and altenated mode is "true"
than automatic mode switch automaticly to mode 1 alternated mode switch off.

I think this is correct because to stop the interchange you need to select a mode between 1 and 4 and this is done by the program
Here is a screenshot of the serial monitor.I only selected mode 5 and run the serial monitor

Image


Kind regards
Len

Post Number:#10 Post Sat Jun 04, 2016 10:32 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

Show me the full code please.

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#11 Post Sat Jun 04, 2016 3:45 pm
Len Nederlof Random avatar
HI,

How can i attach the zip file to the post?

Post Number:#12 Post Sat Jun 04, 2016 3:56 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Use the Google drive, One drive or Dropbox and paste the link here.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#13 Post Tue Jun 07, 2016 3:54 pm
Len Nederlof Random avatar
Hi,

here is the file
Its is the basic code with the modification for the wavemakers which i tried

Post Number:#14 Post Tue Jun 07, 2016 6:09 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

Let's start from scratch.

In the Ferduino tab find:

#define USE_TFT


Add after:

#define ALTERNATING_WAVE


Find:

byte Pump2PWM = 0;


Add after:

unsigned long interval_wave_millis = 0;
int interval_wave = 1; // in minutes
boolean alternated_mode = false ;


On loop find:

Wavemaker();


Add after:

#ifdef ALTERNATING_WAVE
  if (alternated_mode == true )
  {
    if ((millis() - interval_wave_millis) > (interval_wave * 60000))
    {
      modo_selecionado += 1;

      if (modo_selecionado > 4)
      {
        modo_selecionado = 1;
      }
      interval_wave_millis = millis();
    }
  }
#endif


In the ProcessMyTouch tab on case 10 find:

modo_selecionado = 1;
modo_selecionado = 2;
modo_selecionado = 3;
modo_selecionado = 4;


Add after each line:

alternated_mode = false;


Find:

modo_selecionado = 5;


Add after:

#ifdef ALTERNATING_WAVE
          alternated_mode = true;
#else
          alternated_mode = false;
#endif


In the Wavemaker tab find:

  else if (modo_selecionado == 5)
  {
    Pump1PWM = Pump1PWM_temp;
    Pump2PWM = Pump2PWM_temp;
  }


Replace with:

#ifndef ALTERNATING_WAVE
  else if (modo_selecionado == 5)
  {
    Pump1PWM = Pump1PWM_temp;
    Pump2PWM = Pump2PWM_temp;
  }
#endif


Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#15 Post Wed Jun 08, 2016 4:06 pm
Len Nederlof Random avatar
Hi Fernando,
Thank you very much for the help,your the best. ^:)^

Kind regards
Len




Return to Ferduino code





Who is online

Users viewing this topic: No registered users and 1 guest

cron