kh monitor + variable dosing

Requests for new functions or software apps
User avatar
Posts: 5381
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Dec 26, 2018 8:39 am
I wasn't getting the values expected. I suspect because of string to integer conversions, I'm not sure at all. I just know I wasn't getting odd numbers even when explicitly writing the same value to three files. I saw we have a read32 function, that didn't help me much as I wasn't sure if my write was even working properly. I have to look for my mini sd conversion thing so I can actually look at the files that were created and see what they hold.
User avatar
Posts: 5381
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Dec 26, 2018 3:18 pm
Ok, so today I have devised how I will affect the variable dosing.

Since I'm dosing by volume currently, what I've decided I will do is if the ALK is over or under the threshold that I'll make a micro adjustment to the dosing time.

So let's say the target alk is 155ppm (byte set in Memory Mem_B_AlkTarget) which converts to 868 by the PHE meter. If the ALK reading is 20 above this (so 888 or 159ppm) then I will reduce the dosing by X amount. Other people using other controllers are simply putting in a if ALK > N don't dose anything which I would worry would cause more of a swing.
Conversely, if the ALK is 20 below the threshold (.20dkH) then I will increase the dosing by X amount.

X in these cases will only be a few ml. Basically for my tank, i need 10ml to increase .2dKH (the +/- threshold I mentioned earlier). So let's say we start with the example above and my alk measures 890. I'm currently dosing 18ml a day which comes to .75ml per hour. My function will add 1/24th of a dose to each hour until the alk drops back in the range. If I set the adjustment value (Mem_B_AlkAdjVol) to 4ml, it would add .16ml to the dosage for those hours, but it won't be able to ever dose more than +/-4ml extra per day.

Next, need to add monitoring for the adjustments and maybe some more checks

Code: Select all
    // If any of these are on
    if (ReefAngel.Relay.Status(VO_Calibrate) || ReefAngel.DisplayedMenu==FEEDING_MODE || ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
       // Do nothing
    } else {
      // Only apply to pumps 0 and 1 when Adjustment value is between 1-9ml and PHExp value is not in Error (500)
      if (InternalMemory.read(Mem_B_AlkAdjVol)>0 && InternalMemory.read(Mem_B_AlkAdjVol)<10 && i<2 && ReefAngel.Params.PHExp>600) {
        if (ReefAngel.Params.PHExp < (InternalMemory.read(Mem_B_AlkTarget) / .1786) - 20) { // Convert AlkTarget PPM to DKH and subtract our threshold
          // Increase dosage time if we're under our threshold
          doseTime[i]+=(InternalMemory.read(Mem_B_AlkAdjVol)/rate)/(1440/dpRepeat);
        }
        if (ReefAngel.Params.PHExp > (InternalMemory.read(Mem_B_AlkTarget) / .1786)  + 20) { // Convert AlkTarget PPM to DKH and add our threshold.
          // Decrease dosage time if we're over our threshold
          doseTime[i]-=(InternalMemory.read(Mem_B_AlkAdjVol)/rate)/(1440/dpRepeat);
        }
      }
      ReefAngel.DosingPumpRepeat(pump[i], i*5, dpRepeat, doseTime[i]);
    }
User avatar
Posts: 5381
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Thu Dec 27, 2018 12:20 am
I think the nice thing about the approach is that it should smooth the natural curve of alk consumption on an adaptive basis. I would just have to tune the amount of adjustment I allow to compensate for the natural plus/minus that occurs. Also seeing how long an adjustment is in effect for can help me determine how often I will need to test. I've currently increased it from every 4 hours back to the 2 hour default in order to get more data and not miss any trends.

I just need to figure out how I will track the adjustments made. *scratch* that... I think I just figured that out :) So I currently report my dosing log in the actual amount based on seconds the pump has run. I record that in a CustomVar so I can see throughout the day how much has been dosed. I can then use another CustomVariable to store what should have been dosed without adjustment. That would allow me to overlay the two in a graph nicely and see the affect. I can also set an alarm to trigger at the end of the day if we've hit the limit of the threshold that's been set. So basically if I'm increasing every dosage, then it's time to increase the baseline setting on the dosers.

And thus an alert is born:
Code: Select all
      if (i=0 && abs(ReefAngel.CustomVar[1]-ReefAngel.CustomVar[7])>=InternalMemory.read(Mem_B_AlkAdjVol)) {
        alkAlert.Send("Alk+usage+alert.");
      }
User avatar
Posts: 5381
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sun Jan 06, 2019 11:29 am
So I've had some instability with the readings, but after installing the lab grade ph probe they sell for it, it's working much better. In the meantime I have a shipment on the way for a new reaction chamber which has an upgraded level sensor, float switch, and motor for the magnetic stirrer which are all supposed to really help with consistency and accuracy. As of now I still get some outliers around 30% of the time. The challenge now will be how to compensate...

Roberto, may need to revisit logging to a file and reading the results :)

01/04 08 52 09 W.145 %0 KH 7.47 / 133 ppm
01/04 12 39 14 W.150 %0 KH 7.44 / 132 ppm
01/04 16 16 38 W.147 %2 KH 7.07 / 126 ppm
01/04 16 41 29 W.146 %0 KH 7.45 / 133 ppm
01/04 17 25 12 W.145 %0 KH 7.06 / 126 ppm
01/04 18 30 47 W.151 %0 KH 7.44 / 132 ppm
01/04 19 16 06 W.151 %0 KH 7.16 / 127 ppm
01/04 19 32 28 W.152 %0 KH 7.48 / 133 ppm
01/04 19 44 25 W.148 %0 KH 7.85 / 140 ppm
01/04 20 08 06 W.149 %0 KH 7.89 / 140 ppm
01/04 22 03 11 W.148 %0 KH 7.49 / 133 ppm
01/04 23 31 48 W.147 %1 KH 7.48 / 133 ppm
01/05 00 02 37 W.149 %0 KH 7.62 / 136 ppm
01/05 00 46 52 W.150 %0 KH 7.59 / 135 ppm
01/05 01 08 02 W.150 %0 KH 7.58 / 135 ppm
01/05 02 40 06 W.150 %0 KH 7.59 / 135 ppm
01/05 04 39 15 W.153 %0 KH 7.19 / 128 ppm
01/05 06 47 15 W.150 %1 KH 7.48 / 133 ppm
01/05 08 46 40 W.152 %0 KH 7.32 / 130 ppm
01/05 12 39 56 W.151 %0 KH 7.57 / 135 ppm
01/05 14 39 49 W.150 %1 KH 7.59 / 135 ppm
01/05 16 46 45 W.147 %0 KH 7.58 / 135 ppm
01/05 18 46 47 W.151 %1 KH 7.60 / 135 ppm
01/05 20 46 41 W.151 %1 KH 7.60 / 135 ppm
01/05 22 39 51 W.155 %0 KH 7.58 / 135 ppm
01/06 00 46 41 W.156 %1 KH 7.59 / 135 ppm
01/06 02 46 15 W.150 %0 KH 7.16 / 127 ppm
01/06 04 39 30 W.147 %0 KH 7.61 / 135 ppm
01/06 06 39 38 W.146 %0 KH 7.59 / 135 ppm
01/06 08 46 50 W.147 %0 KH 7.90 / 141 ppm

Posts: 12386
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Mon Jan 07, 2019 12:40 am
What is that you are trying to log?
Roberto.
Previous

Return to Requests

Who is online

Users browsing this forum: No registered users and 2 guests