reef-pi :: An opensource reef tank controller based on Raspberry Pi.

GaryE

Well-Known Member
View Badges
Joined
Mar 12, 2020
Messages
992
Reaction score
1,321
Location
Coatesville, Indiana
Rating - 0%
0   0   0
I agree, not everyone has the time, energy or patience to deal with the level of nonsense guys like us are dealing with.

I would love to jump in and help out, but as the code base has very little in the way of comments, I'm not exactly sure what's going on with a lot of it. I don't like mucking about in things I don't understand. (completely untrue)

And the sickness continues.. another RPI 4 on the way, thanks to Adafruit...
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
I was having a similar issue with my flow meter, it was showing incorrectly. It was 100 times higher than it should have been.

So, simple math fixed it.. (by the way, I was stationed at Pease AFB in the late 1980's)
1647564959040.png
+1 I had the same issue for my return pump, I just did the math and applied it...all good now. :)
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
And the sickness continues.. another RPI 4 on the way, thanks to Adafruit...
I was able to order 2 zero 2w this week from pihut, still more than I wanted to pay but they are supposedly on their way...still pretty crazy I do not think this will get much better supply wise this year...:(
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
Hive mind,
I have cut 5.2 release of reef-pi yesterday.

This release brings an experimental stepper based doser support using drv8825 ICs. I have tested it with a 42 step doser from Amazon ( goso) . The wiring details are explaIned here:
I’m calling this an experimental driver as I expect the ui might change a bit, I may move it under connector/driver later on .
ph controller now has enabled/disabled toggle button from collapsed ui similar to ato or temperature controllers.
Users with MQTT integration can now specify a prefix value that will be used as parent topic for publishing all messages.


other than this, the main focus was on fixing outstanding bugs. Community member Markus Kuhn contributed bulk of the ui validation related fixes and i18n improvements across temperature, ph, lighting, driver components.
Ato reset button not working bug was fixed.

Capability changes under settings ui was not reflected correctly with backend state. Fixed.

Timer when used with revert back feature, would raise duration parsing error . Fixed

Journal entries were not sorted. I fixed this. But have some bad news here, this is a breaking change. Due to the poor was I designed it in the beginning the time information was not modeled correctly. It will be considerably hard to decipher correct time, that we need to sort the entries using the existing type. To make this manageable in time, I have updated the type. This will save the sorting issue for all new entries, but existing entries will render as invalid (Reset toast jan 01, 01 ). I request users to recreate the journal. I’m sorry for this, I’ll be mindful of this. In fact this is what made me call out stepper driver as experimental. I think going forward it will be wise to augment the newly developed component that we are still hammering through user feedbacks and has not gone through couple of minor release cycle at least , will be called out experimental . This also means we can be double strict about not altering non experimental api in minor releases,


Release builds are available in usual location : https://github.com/reef-pi/reef-pi/releases/tag/5.2

Nice job, thanks for all your efforts. I think this is a great start for steppers and like the method you've used, I also don't mind the settings where they are, seems to make sense, select stepper and you get all the settings.

As others have reports there is a bug when adding one, I noticed if I changed pump type to "DC motor" it was complaining for "duration" and "speed". If something is put in these fields, then switched back to "Stepper" you can save it ok.

For down the road it would be nice to have a selection or setting of "Don't Use" for direction and micro stepping pins. :)

For for thought...

Steppers for dosing seems like it is screaming for i2c stepper driver boards. Many dosers and NO RPI pins required. I used 5v L293 i2c boards with BYJ cheap steppers for project and it was a piece of cake. It would require a driver for each specific i2c stepper board though assuming i2c commands where different between boards. You would just get the peristaltic head and attach the stepper.
That might seems like a good idea but IMO I2C or SPI should only be used when absolutely necessary. It was never designed to leave a circuit board and is very susceptible to noise and interference. Using GPIO's are by far the most reliable method for DIY.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
OK I did further trials for ato resets. I had to delete the first ato for resest to work. However, it now works for all the ato resets. One down.

Tried the same with the temp keyboard pop up, still no go... value error.
the ato issue could be due to cached front end code (fix was in front end code). Use shift+refresh after the update, just to be sure. I'll check the temperature ui. Can you file a github bug, it will be awesome to have the details, it helps me quickly recreate the issue (and fix henceforth).
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I wanted to try out the stepper implementation but it wouldn't let me save the configuration.

Created outlets on GPIO 7 and 8 for STEP and DIR. It threw errors if i wanted to save without A, B, C assigned, but that was a simple fix, i created dummy outlets on GPIOs 23,24,25 and just didn't connect anything. Then, with every field filled out, it throws validation error null

Is there a problem with my pin selection? Or something else? Schedule was the default selection, hour minute, second as 0, the rest starred

1647515930326.png


Also, having 1/64 stepping as an option, at least for calculation purposes might be nice, but not hugely important, haven't tried out how fast the pi can even keep up
I can reproduce this. Looking into it. I dont know why this is happening, will report back soon (suspect some UI bug must have gone through)


Here are the details :
Delay, is in nano second. It is the pause in between steps. For micro stepping, it will be divided by the appropriate micro step level. By default it is 20800000.
All pins are required right now, as the underlying driver currently requires all those pins. You are right, most of it could be done out of band, but those are specific cases. The initial version for experimenting needs to support all of it. As we understand the user experience, we can make it simpler, and just require one pin or so.. those will be special case of this driver.
I had tested with 42 stepper motor.



https://github.com/reef-pi/reef-pi/blob/main/controller/modules/doser/stepper.go#L25
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I was having a similar issue with my flow meter, it was showing incorrectly. It was 100 times higher than it should have been.

So, simple math fixed it.. (by the way, I was stationed at Pease AFB in the late 1980's)
1647564959040.png
+100. This is very handy and useful for any generic transformation function, including decimal reduction ..
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I can reproduce this. Looking into it. I dont know why this is happening, will report back soon (suspect some UI bug must have gone through)


Here are the details :
Delay, is in nano second. It is the pause in between steps. For micro stepping, it will be divided by the appropriate micro step level. By default it is 20800000.
All pins are required right now, as the underlying driver currently requires all those pins. You are right, most of it could be done out of band, but those are specific cases. The initial version for experimenting needs to support all of it. As we understand the user experience, we can make it simpler, and just require one pin or so.. those will be special case of this driver.
I had tested with 42 stepper motor.



https://github.com/reef-pi/reef-pi/blob/main/controller/modules/doser/stepper.go#L25
Ok, i understand now what is happening. The dc motor settings are not set, and the errors are about that. It should not error in first place (thats one bug), and by any reason if UI error appears, it should show the details of the error (thats another bug). While I work on fixing this, you can by pass the error by selecting the dc motor and filling out (duration and speed) and then reselect the stepper driver it should let you save.
thank you for testing it out,
 

elysics

Valuable Member
View Badges
Joined
Jan 15, 2020
Messages
1,695
Reaction score
1,607
Rating - 0%
0   0   0
Yeah, got it to save the settings by saving a DC doser first and then editing it to change to stepper. Btw, is he volume field in DC motor mode functional and we can now calibrate volume for those somehow, or is that just an artifact of the new UI? Come to think of it, that won't mess with existing doser configs or will it if those configs are untouched from before the update to 5.2?

Anyway, I got it to consistently move my stepper, although not how i expected it. With Microsteppings 1/16 and 1/32, setting delay to 1 million or 5 million (which if that is supposed to be nanoseconds, should be 1ms and 5ms for a full step respectively right?) the motor would block. Setting it to values between 1000 and 50000 would work, but consistently gives the wrong degree of rotation (too much). Probably because that is so fast that there are weird effects going on with the limit of the pi's effective switching speed. But 5/16ms = 3.2 kHz pulses shouldnt be too fast for the pi right? Definitely not too fast for my driver/stepper pair, had them running faster with arduino, even without speed ramping. But i don't know if this is due to unreliable jumper wires, limitations of the pi, or some other issue, and I don't have an oscilloscope to check.

Can someone with an oscilloscope and preferably a pi zero confirm where the speed limit (delay value) is at which the step signal gets corrupted? And what is the pulsewidth of the step signals?


Why is the selection in nanoseconds btw, are you expecting high megahertz or low gigahertz switching speeds in some application?
 
Last edited:

Martin Lowry

Community Member
View Badges
Joined
Sep 19, 2017
Messages
60
Reaction score
65
Location
Dover, NH
Rating - 0%
0   0   0
I was having a similar issue with my flow meter, it was showing incorrectly. It was 100 times higher than it should have been.

So, simple math fixed it.. (by the way, I was stationed at Pease AFB in the late 1980's)
1647564959040.png
@GaryE Ha! small world. I've been in Dover since 95. Long story, but originally from London.
 

DWKDiver

Community Member
View Badges
Joined
May 18, 2021
Messages
44
Reaction score
41
Location
Georgia
Rating - 0%
0   0   0
Nice job, thanks for all your efforts. I think this is a great start for steppers and like the method you've used, I also don't mind the settings where they are, seems to make sense, select stepper and you get all the settings.

As others have reports there is a bug when adding one, I noticed if I changed pump type to "DC motor" it was complaining for "duration" and "speed". If something is put in these fields, then switched back to "Stepper" you can save it ok.

For down the road it would be nice to have a selection or setting of "Don't Use" for direction and micro stepping pins. :)


That might seems like a good idea but IMO I2C or SPI should only be used when absolutely necessary. It was never designed to leave a circuit board and is very susceptible to noise and interference. Using GPIO's are by far the most reliable method for DIY.
Boards like Grove board with its own logic chip? Just tell the board what to do and it does it till you tell it to stop. It's basically an arduino running a driver. Which may have to be done as its been awhile since I looked at the Grove board and they are now less plentiful than a $15 rpi zero w!
 

DWKDiver

Community Member
View Badges
Joined
May 18, 2021
Messages
44
Reaction score
41
Location
Georgia
Rating - 0%
0   0   0
Maybe there are good ones with i2c capabilties, the trinamic ones sadly only have uart which isn't much help when looking at multiple steppers at the same time, but i really wouldn't recommend using L293 as stepper "drivers". At least not if you are going to be in the same room. That's worse than a4988 and those are already loud.

I don't know what the best way forward is, maybe it is an arduino based pin extender/ arduino based doser controlled by the pi, some other kind of expansion, or maybe we just have to cram in as much to the pins we have as we can, with the current way of doing things all we really need is 1 pin per pump to run a doser, 2 if we want to run a pump in both directions, the rest can be hardwired

edit: come to think of it, there are some with SPI, but that wouldn't really save on pins either due to the need for chip select
My DC doser is pretty dang loud. Especially if I pwm it.
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
Boards like Grove board with its own logic chip? Just tell the board what to do and it does it till you tell it to stop. It's basically an arduino running a driver. Which may have to be done as its been awhile since I looked at the Grove board and they are now less plentiful than a $15 rpi zero w!
I don't know much about Grove, there's too many to keep track of. You shouldn't need it though as the drv8825 stepper driver will connect directly to GPIO's on the Pi.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Yeah, got it to save the settings by saving a DC doser first and then editing it to change to stepper. Btw, is he volume field in DC motor mode functional and we can now calibrate volume for those somehow, or is that just an artifact of the new UI? Come to think of it, that won't mess with existing doser configs or will it if those configs are untouched from before the update to 5.2?

Anyway, I got it to consistently move my stepper, although not how i expected it. With Microsteppings 1/16 and 1/32, setting delay to 1 million or 5 million (which if that is supposed to be nanoseconds, should be 1ms and 5ms for a full step respectively right?) the motor would block. Setting it to values between 1000 and 50000 would work, but consistently gives the wrong degree of rotation (too much). Probably because that is so fast that there are weird effects going on with the limit of the pi's effective switching speed. But 5/16ms = 3.2 kHz pulses shouldnt be too fast for the pi right? Definitely not too fast for my driver/stepper pair, had them running faster with arduino, even without speed ramping. But i don't know if this is due to unreliable jumper wires, limitations of the pi, or some other issue, and I don't have an oscilloscope to check.

Can someone with an oscilloscope and preferably a pi zero confirm where the speed limit (delay value) is at which the step signal gets corrupted? And what is the pulsewidth of the step signals?


Why is the selection in nanoseconds btw, are you expecting high megahertz or low gigahertz switching speeds in some application?
Golang uses nanoseconds as the duration unit . I don’t know what the limits will be or if it’s sensible to have it in nano seconds. i can always switch it to milli or micro second later, if thats more suitable
 

GaryE

Well-Known Member
View Badges
Joined
Mar 12, 2020
Messages
992
Reaction score
1,321
Location
Coatesville, Indiana
Rating - 0%
0   0   0
Almost complete. Just need to add a webserver to allow setting temp and hysteresis.

It's all working, emitting metrics and whatnot. Even has an endpoint to reboot the ESP32 from the web browser.

If you want to try it out or help make it better... https://github.com/indymx/TpLInk-Arduino

The webserver for setting the set temp is working.. Just needs a bit of polish and it'll be ready to put into production!

1647716244455.png


1647719951065.png
1647719924786.png
 
Last edited:

Dave's Reef

Active Member
View Badges
Joined
Nov 4, 2018
Messages
102
Reaction score
148
Rating - 0%
0   0   0
Eh I prefer vi but nano will work ;)

I would add those to command at the end of the unit section and not at the bottom. Here is what the file looks like now:

Code:
[Unit]
Description=raspberry pi based reef tank controller

[Service]
ExecStart=/usr/bin/reef-pi daemon -config /etc/reef-pi/config.yaml
WorkingDirectory=/var/lib/reef-pi
Restart=always
RestartSec=90
StartLimitInterval=400
StartLimitBurst=10

[Install]
WantedBy=multi-user.target

How I think you want it to look like:
Code:
[Unit]
Description=raspberry pi based reef tank controller
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/bin/reef-pi daemon -config /etc/reef-pi/config.yaml
WorkingDirectory=/var/lib/reef-pi
Restart=always
RestartSec=90
StartLimitInterval=400
StartLimitBurst=10


[Install]
WantedBy=multi-user.target

You don't have to reboot just do this command and you will be good...

Code:
sudo systemctl daemon-reload
I finally got around to trying this and I am still having to reload reef-pi to get the wifi plugs to work. Any thought on this?
 

Attachments

  • 20220320_102126.jpg
    20220320_102126.jpg
    215.3 KB · Views: 60

Vnomus

Community Member
View Badges
Joined
Aug 22, 2020
Messages
89
Reaction score
102
Location
Jeffersonton
Rating - 0%
0   0   0
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I finally got around to trying this and I am still having to reload reef-pi to get the wifi plugs to work. Any thought on this?
You have a driver that’s not loaded. Which driver the connector wp1 is using ? That driver is not loaded
 

TOP 10 Trending Threads

WHAT AMOUNT OF LIVE ROCK AND SAND SHOULD BE PRIORITIZED FOR OPTIMAL BIODIVERSITY/FILTRATION?

  • 100% live rock + bagged sand

    Votes: 37 27.4%
  • 100% dry rock + 100% live sand

    Votes: 46 34.1%
  • 50/50 live/dry rock, 50/50 live/bagged sand

    Votes: 30 22.2%
  • 75% live rock, 25% live sand

    Votes: 12 8.9%
  • 25% live rock, 75% live sand

    Votes: 10 7.4%
Back
Top