Macro complexity / custom programming within reef-pi?

Alfhari

New Member
View Badges
Joined
Apr 12, 2021
Messages
3
Reaction score
1
Location
Braunschweig, Germany
Rating - 0%
0   0   0
Hi,

I just recently came across reef-pi and I am thinking about building an all-in-one controller for my tank with it.
One part of that project would be an alkalinity monitor/controller that requires a slightly more advanced macro/programming.
The basic workflow would look like this:

Doser empties, flushes, and fills test vessel with tank water.
Magnetic stirrer starts.
pH probe records pH.
Doser adds acid in small quantities, with breaks for stirring in between, until target pH is reached, dosing slower / taking longer stirring breaks the closer the pH gets to the target value.
The total volume of acid dosed is saved as a variable.
Doser empties, flushes, and fills test vessel with tank water.
Magnetic stirrer stops.
KH is calculated with the obtained values and displayed in a graph.
Doser adds KH reagent to the tank according to the previous measurement.
Dosed volume is displayed as second data point within the KH graph.
Rinse and repeat at a certain interval.

The hardware part is fairly trivial and obviously not a problem for reef-pi.
From what I have seen of the UI thus far, I am unsure about the calculations and such required for this project.
Is impossible to have such complex macros within reef-pi?
If not, is there a simple way to add custom code to the overall program that follows the workflow above?


Best,
Janis
 

attiland

2500 Club Member
View Badges
Joined
Jul 22, 2020
Messages
2,594
Reaction score
4,800
Location
United Kingdom
Rating - 0%
0   0   0
Hi,

I just recently came across reef-pi and I am thinking about building an all-in-one controller for my tank with it.
One part of that project would be an alkalinity monitor/controller that requires a slightly more advanced macro/programming.
The basic workflow would look like this:

Doser empties, flushes, and fills test vessel with tank water.
Magnetic stirrer starts.
pH probe records pH.
Doser adds acid in small quantities, with breaks for stirring in between, until target pH is reached, dosing slower / taking longer stirring breaks the closer the pH gets to the target value.
The total volume of acid dosed is saved as a variable.
Doser empties, flushes, and fills test vessel with tank water.
Magnetic stirrer stops.
KH is calculated with the obtained values and displayed in a graph.
Doser adds KH reagent to the tank according to the previous measurement.
Dosed volume is displayed as second data point within the KH graph.
Rinse and repeat at a certain interval.

The hardware part is fairly trivial and obviously not a problem for reef-pi.
From what I have seen of the UI thus far, I am unsure about the calculations and such required for this project.
Is impossible to have such complex macros within reef-pi?
If not, is there a simple way to add custom code to the overall program that follows the workflow above?


Best,
Janis
I think you need to start a python script for this but not sure how can be done. I would be interested in this myself
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,825
Reaction score
17,041
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Alk monitoring is not built in reef-pi. we are still working on the stepper driver, which i think is a hard requirement for the alk monitoring.
 
OP
OP
A

Alfhari

New Member
View Badges
Joined
Apr 12, 2021
Messages
3
Reaction score
1
Location
Braunschweig, Germany
Rating - 0%
0   0   0
Hi Ranjib,

thank you for stepping in!

Having thought about my initial concept a bit more, I do not think a stepper driver is required here. Actually, one should probably not use timed breaks for stirring at all. That would add more margin for error to the process from the starting and stopping of the doser, different size of droplets, and so on. It might be a very small error, but still.
Instead, imho the best solution might be to use a 0.03 - 1.0 ml/min doser and have that running continuously over the entire duration of the test. Acid would be dripped in via a capillary and the amount dosed per unit of time would be regulated by the difference to target pH. The actual concentration of the acid standard should allow for all the tweaking one would ever need.

Which then brings me back to the initial question of programmability.

Best,
Janis
 
Last edited:

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,825
Reaction score
17,041
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Make sense. I like this idea, though i dont know practically how feasible this is without testing. Let us know what you learned.

Regarding the programmability. Theoretically this should be possible with the existing bits and API. Everything you do via UI can be done by API. macros can do the individual steps (i.e run doser to fill water using an ato ). Calculations in between the steps has to be done by the script that you are using to perform the end to end logic. The required metrics (number of seconds doser run) can be obtained through the usage api (e.g./api /atos/1/usage). You can emit the computed kh value via mqtt, prometheus or any other means.

The macro will likely be pretty involved. If this is a common usage, we can consider writing this as first class module within reef-pi. I also wonder if a dedicated, purpose built, micro-controller based (e.g. esp32 ) is better for this type of workload.

None the less, very exciting to hear you are experimenting with this.
 

attiland

2500 Club Member
View Badges
Joined
Jul 22, 2020
Messages
2,594
Reaction score
4,800
Location
United Kingdom
Rating - 0%
0   0   0
Make sense. I like this idea, though i dont know practically how feasible this is without testing. Let us know what you learned.

Regarding the programmability. Theoretically this should be possible with the existing bits and API. Everything you do via UI can be done by API. macros can do the individual steps (i.e run doser to fill water using an ato ). Calculations in between the steps has to be done by the script that you are using to perform the end to end logic. The required metrics (number of seconds doser run) can be obtained through the usage api (e.g./api /atos/1/usage). You can emit the computed kh value via mqtt, prometheus or any other means.

The macro will likely be pretty involved. If this is a common usage, we can consider writing this as first class module within reef-pi. I also wonder if a dedicated, purpose built, micro-controller based (e.g. esp32 ) is better for this type of workload.

None the less, very exciting to hear you are experimenting with this.
Is there a chance to have the ability to fire up a script straight from Reef-pi scheduler? That would open a whole new word of possibilities and compatibility to other bespoke or currently unsupported hardware and software.
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,825
Reaction score
17,041
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Is there a chance to have the ability to fire up a script straight from Reef-pi scheduler? That would open a whole new word of possibilities and compatibility to other bespoke or currently unsupported hardware and software.
Not right now.. but i dont see why we cant have something like this. it will be risky (as in users can hamper the performance), but i think its ok.. its just a side effect of the power that it brings with
 

attiland

2500 Club Member
View Badges
Joined
Jul 22, 2020
Messages
2,594
Reaction score
4,800
Location
United Kingdom
Rating - 0%
0   0   0
Not right now.. but i dont see why we cant have something like this. it will be risky (as in users can hamper the performance), but i think its ok.. its just a side effect of the power that it brings with
I think those who really would use it know the risk. It assumes a certain level of knowledge. Currently I have turn on virtual hardware and monitor it from outside of UI if I want to do something like this than I have the problem to feed the result back. I probably use 3 times more resources than would be required if the feature would exists.
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,825
Reaction score
17,041
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I think those who really would use it know the risk. It assumes a certain level of knowledge. Currently I have turn on virtual hardware and monitor it from outside of UI if I want to do something like this than I have the problem to feed the result back. I probably use 3 times more resources than would be required if the feature would exists.
True, which is why im considering adding something like this.
 

attiland

2500 Club Member
View Badges
Joined
Jul 22, 2020
Messages
2,594
Reaction score
4,800
Location
United Kingdom
Rating - 0%
0   0   0
True, which is why im considering adding something like this.
And just to add even more functionality to the same if you read the screen or a system wild variable it could even be used to pass figures back to the Reef-pi with the same.
 

DWKDiver

Community Member
View Badges
Joined
May 18, 2021
Messages
44
Reaction score
42
Location
Georgia
Rating - 0%
0   0   0
Sounds good. Would rather have timers running macros correctly first. That would make things like this work better.
 

epicfatigue

Active Member
View Badges
Joined
Oct 21, 2020
Messages
183
Reaction score
86
Location
Melbourne
Rating - 0%
0   0   0
Well I worked out a way of doing this for anyone that needs it.

Make a service monitoring a Pins value, when the pin is high it reads the pin and starts another service. Only thing that sucks is you will loose a pin as a result. But you can add a board to extend GPIOs better then nothing at this point.
 

Mastering the art of locking and unlocking water pathways: What type of valves do you have on your aquarium plumbing?

  • Ball valves.

    Votes: 58 49.6%
  • Gate valves.

    Votes: 64 54.7%
  • Check valves.

    Votes: 28 23.9%
  • None.

    Votes: 28 23.9%
  • Other.

    Votes: 9 7.7%
Back
Top