DCPump Custom Mode

Related to the development libraries, released by Curt Binder

Posts: 118
Joined: Mon Sep 17, 2012 12:41 pm
Location: Lincoln Park, Chicago, IL, USA 60614
PostPosted: Thu Jan 17, 2019 8:55 am
When using DCPump Custom mode, do the Sync and AntiSync for DaylightChannel and ActinicChannel work as expected? For example:

Code: Select all
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
   
    ReefAngel.DCPump.SetMode(Custom, SineMode(TideMode(InternalMemory.PWMSlopeStartD_read(), 2, 10), TideMode(InternalMemory.PWMSlopeEndD_read(), 4, 20), InternalMemory.PWMSlopeDurationD_read() * 60, true), 0);


Is there a way to control both channels using the DCPump class in Custom mode?

Or do I have to do this by setting the PWM directly? For example:

Code: Select all
        byte daylight = SineMode(TideMode(InternalMemory.PWMSlopeStartD_read(), 2, 10), TideMode(InternalMemory.PWMSlopeEndD_read(), 4, 20), InternalMemory.PWMSlopeDurationD_read() * 60, true);
        byte actinic = SineMode(TideMode(InternalMemory.PWMSlopeStartA_read(), 2, 10), TideMode(InternalMemory.PWMSlopeEndA_read(), 4, 20), InternalMemory.PWMSlopeDurationA_read() * 60, false);
       
        ReefAngel.PWM.SetDaylight(daylight);
        ReefAngel.PWM.SetActinic(actinic);

Posts: 12507
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Jan 17, 2019 10:28 am
I think so. You might as well just use straight PWM
Roberto.

Posts: 118
Joined: Mon Sep 17, 2012 12:41 pm
Location: Lincoln Park, Chicago, IL, USA 60614
PostPosted: Thu Jan 17, 2019 3:04 pm
Does Custom mode even work for the DCPump class? It doesn't appear to be implemented. In fact, the SyncSpeed and AntiSyncSpeed variables are not initialized and there is no default case in the switch statement, so it seems the behavior is pretty undefined:

Code: Select all
#ifdef DCPUMPCONTROL
   if (DCPump.UseMemory)
   {
      DCPump.Mode=InternalMemory.DCPumpMode_read();
      DCPump.Speed=InternalMemory.DCPumpSpeed_read();
      DCPump.Duration=InternalMemory.DCPumpDuration_read();
      DCPump.Threshold=InternalMemory.DCPumpThreshold_read();
   }
   byte SyncSpeed;
   byte AntiSyncSpeed;
   switch (DCPump.Mode)
   {
   case Constant:
   {
      SyncSpeed=DCPump.Speed;
      AntiSyncSpeed=DCPump.Speed;
      break;
   }
   case Lagoon:
   {
      SyncSpeed=ReefCrestMode(DCPump.Speed,10,true);
      AntiSyncSpeed=ReefCrestMode(DCPump.Speed,10,false);
      break;
   }
   case ReefCrest:
   {
      SyncSpeed=ReefCrestMode(DCPump.Speed,20,true);
      AntiSyncSpeed=ReefCrestMode(DCPump.Speed,20,false);
      break;
   }
   case ShortPulse:
   {
      SyncSpeed=ShortPulseMode(0,DCPump.Speed,DCPump.Duration*10,true);
      AntiSyncSpeed=ShortPulseMode(0,DCPump.Speed,DCPump.Duration*10,false);
      break;
   }
   case LongPulse:
   {
      SyncSpeed=LongPulseMode(0,DCPump.Speed,DCPump.Duration,true);
      AntiSyncSpeed=LongPulseMode(0,DCPump.Speed,DCPump.Duration,false);
      break;
   }
   case Gyre:
   {
      SyncSpeed=GyreMode(DCPump.Threshold,DCPump.Speed,DCPump.Duration,true);
      AntiSyncSpeed=GyreMode(DCPump.Threshold,DCPump.Speed,DCPump.Duration,false);
      break;
   }
   case NutrientTransport:
   {
      SyncSpeed=NutrientTransportMode(0,DCPump.Speed,DCPump.Duration*10,true);
      AntiSyncSpeed=NutrientTransportMode(0,DCPump.Speed,DCPump.Duration*10,false);
      break;
   }
   case TidalSwell:
   {
      SyncSpeed=TidalSwellMode(DCPump.Speed,true);
      AntiSyncSpeed=TidalSwellMode(DCPump.Speed,false);
      break;
   }
   case Sine:
   {
      SyncSpeed=SineMode(DCPump.Threshold,DCPump.Speed,DCPump.Duration,true);
      AntiSyncSpeed=SineMode(DCPump.Threshold,DCPump.Speed,DCPump.Duration,false);
      break;
   }
   case Else:
   {
      SyncSpeed=ElseMode(DCPump.Speed,DCPump.Duration,true);
      AntiSyncSpeed=ElseMode(DCPump.Speed,DCPump.Duration,false);
      break;
   }
   case Storm:
   {
      SyncSpeed=StormMode(DCPump.Speed,DCPump.Duration,true);
      AntiSyncSpeed=StormMode(DCPump.Speed,DCPump.Duration,false);
      break;
    }
    }
   if (DisplayedMenu==FEEDING_MODE)
   {
      if (DCPump.FeedingSpeed < 100)
      {
         SyncSpeed=DCPump.FeedingSpeed;
         AntiSyncSpeed=DCPump.FeedingSpeed;
      }
   }
   if (DisplayedMenu==WATERCHANGE_MODE)
   {
      if (DCPump.WaterChangeSpeed < 100)
      {
         SyncSpeed=DCPump.WaterChangeSpeed;
         AntiSyncSpeed=DCPump.WaterChangeSpeed;
      }
   }
   SetDCPumpChannels(SyncSpeed,AntiSyncSpeed);
#endif  // DCPUMPCONTROL

Posts: 12507
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Jan 17, 2019 3:09 pm
Actually custom mode means you have full control to change the speed in each channel, which makes it sync/anti-sync useless.
That mode was created for RF module, which doesn't have an underlying class to use. Then the same modes were duplicated for DCPump. So, if you want control of each channel, use the PWM class instead.
Roberto.

Posts: 118
Joined: Mon Sep 17, 2012 12:41 pm
Location: Lincoln Park, Chicago, IL, USA 60614
PostPosted: Thu Jan 17, 2019 3:55 pm
I think I see what you're saying. You're basically saying that one would look at the current mode, and if Custom, then implement whatever they want. Correct?

Yeah, the PWM class is probably the best option right now, but I might submit a pull request for an update to better support Custom mode, similar to the way the RF module handles it. Still wouldn't prevent someone from just using PWM, but Custom mode would then support the FeedingSpeed and WaterChangeSpeed features of DCPump, for example. And keeping it more in parity with the RF modes seems to make sense.

Posts: 12507
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Jan 17, 2019 3:59 pm
Ahh. Yeah, feeding and water change speed is a good point. I forgot about that.
Roberto.

Posts: 118
Joined: Mon Sep 17, 2012 12:41 pm
Location: Lincoln Park, Chicago, IL, USA 60614
PostPosted: Thu Jan 17, 2019 4:03 pm
Also, it appears the UApp doesn't play nice with selecting Custom mode from the DC Pump screen and not actually calling SetMode() to Custom. It times out instead and continues showing the previously selected mode, even though it actually does select Custom mode.

Posts: 118
Joined: Mon Sep 17, 2012 12:41 pm
Location: Lincoln Park, Chicago, IL, USA 60614
PostPosted: Fri Jan 18, 2019 1:53 pm
Opened a pull request to address this and the open issue with Radion intensity, which I ran into as well:

https://github.com/reefangel/Libraries/pull/250

Posts: 12507
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Fri Jan 18, 2019 6:53 pm
Thanks for the contribution!!! :)
Roberto.

Return to Development Libraries

Who is online

Users browsing this forum: No registered users and 2 guests

cron