Open-Source Professional-Grade Aquacontroller

JackOMalley

Community Member
View Badges
Joined
Sep 2, 2018
Messages
33
Reaction score
74
Rating - 0%
0   0   0
All,
Due to the state of global affairs, I've taken advantage of my downtime to start a project I've been wanting to work on for a long time: A replacement for my Neptune Apex!
Using the P1AM-100 module from AutomationDirect.com ($49) I created a platform with a collaborative task scheduler, Asynchronous MQTT messaging system for IOT integration, Micro-SD datalogger, NTP time synchronization of the internal clock, and a few other nifty tools.
I wasn't terribly excited about a lot of the existing open-source aquacontrollers for a few reasons: Hobby-grade hardware, potential for the controller to "hang" on certain operations and block critical functionality, and you were limited to the 3.3V-5V digital and analog IO on the Raspberry Pi/Arduino. The P1AM is a HUGE improvement in terms of durability, longevity, and expandability of hardware (e.g. 120/240V relays, Sinking vs. Sourcing inputs and outputs, high-power IO) especially when you consider the price point is just barely above the arduino (~$25 for an Arduino vs. $49 for the P1AM).
Note that this does require a certain level of technical understanding, but I will definitely be working on "lowering the bar" in future updates with better documentation and eventually compatibility with graphical programming languages (Ladder Logic).
Link: https://github.com/JohnnyG89/SeaDragon
Deuces,
-TheReefySeaDragon
 
All,

I've made some more progress on my Aquacontroller "SeaDragon". Some of the noteworthy changes are:

-Completely new file structure that sequesters each tasks' variables, libraries, initialization, and cyclic programs

-MQTTS using adafruit.io. Takes ~8s to authenticate so more than likely you'll just want to use a local bridge that authenticates directly to the cloud. In the future I plan on making an ESP8266 shield from AD's proto kit which has the ECCX hardware accelerator chip.

-Gratuitous use of compiler flags for debug vs. deployment configurations

-Pretty awesome header

I've worked in the PLC programming industry for 10 years now so I hope you all are able to garner some wisdom from how I've broken my code down into discrete units that are all independent of one another.

something something something it's open source so copy at your own risk, I'm not responsible something something something

https://github.com/JohnnyG89/SeaDragon

-JohnnyG89 (TheReefySeaDragon)
 
Here's a picture of the P1AM (center) in its "forever home". Below is the Apex Jr. it will be replacing, and right inside the cabinet is the IOT server that's going to manage local and cloud data.

Just FYI, this is NOT UL COMPLIANT. At least not yet.

20200414_080810.jpg
 
I wanted to give you an update as to where I am::
-Thingsboard server is running, receiving data, displaying it on the dashboard
-All wiring for the discrete inputs, discrete outputs, and relay outputs is done
-I made a simple TOF program to control one of the relays from the switch on the front of the P1AM. Nothing fancy.
-The Analog Input and RTD temp. probe IO modules will be in tomorrow. They'll need some wiring.
What I haven't done yet::
-Program some basic alarms, show SMS/Email notifications (needs to be configured in ThingsBoard)
-Wire/Calibrate the pH probe.
-Set up trend graphs

Note that all of the rats nest is Neptune Apex. Cable and wire management is so much easier with this hardware.

https://youtu.be/Eb6_EMCZ_Tc
 
Oh, and of course the source code repository:

https://github.com/JohnnyG89/SeaDragon/
Most recent changes:
-Took out RTCZero library because it randomly seems to stop compiling
-Did some fancy pointer/reference magic to reduce the number of arguments from 2 to 1
-Did a terrible job debugging and placed random "return;" statements while testing something else.
-Did some fancy formatting of the task declarations. A little "fancy-pants" I know.
-Right now, ThingsBoard works (based on "PubSubClient.h"). Use it as an "either/or" with the other mqtt task, unless you can make it work.
-Added a picture of the assembly.
-Added PLC-like logic "TOF" from plclib to turn open RO1-NC1 in slot 3. Kind of a "Hello World" type deal with the Par38 LED on a gooseneck over the freshwater tank.
 
Cool build! Interested to see where you take this. Will be following.

Right now, I'm just trying to get a pushbutton + indicator light unit set up for basic monitoring and control.

In terms of UI/HMI - it's really not my forte'. Everyone seems to know EXACTLY how they want their HMI to play into the system, but I just can't integrate complex auxiliary functionality until I have the basic core of the unit functional.

Imagine this scenario: "Oops, my lunar simulator script hung on execution during the middle of my autofeeder cycle and dumped all the food into the tank."
 
I put a little effort into the BOM today. Note that this isn't the exact BOM I'm using but the architecture stays the same.

I do want to ruminate for a moment on the conundrum I am facing. It would be amazing to make money from this hobby - however, there are much more profitable outlets for my intrigue. To me, this hobby is about authenticity - being able to feel an authentic connection to nature. If I started to try to derive profit from this, I'm afraid I may drift away from my core motivations and passion for this hobby. I'm calling this "Joe Exotic Syndrome".

...Aaannnnddddd that's enough navel-gazing about where I'm planning on taking this seadragon project. If someone offered a "blank check" for starting a business without any strings attached, I'd take the Arduino business model - you could buy a real, authentic Arduino, or you could follow their schematics and make one yourself. 100% off-the-shelf components, 100% source code transparency.

This is enough to get you:
8x 120V outlet control
4x Temp probe monitoring
4x pH/ORP inputs
2x variable speed DC motor control
8x switch monitoring
8x valve/actuator discrete outputs
waterproof enclosure
"signal tower" indicator for the machine state (Running, Faulted, Warning, Idle, Stopped, etc.)

This is the AutomationDirect BOM I put together:

Item CodeQtyDescriptionPriceTotal
PSL-24-090
1​
RHINO switching power supply, 24 VDC (adjustable) output, 3.8A, 91.2W, 120/240 VAC or 125-250 VDC nominal input, 1-phase, enclosed, plastic housing, IP20, 35mm DIN rail mount, screw terminals, NEC Class 2.
$60.00​
$60.00​
P1AM-100
1​
ProductivityOpen Arduino-compatible CPU, microSD card slot, (1) microB-USB port(s), external 24 VDC required.
$49.00​
$49.00​
P1-08TRS
1​
Productivity1000 relay output module, 8-point, 6-24 VDC/6-120 VAC, (6) Form A, (2) Form C, 8 isolated common(s), 1 point(s) per common, 3A/point. Requires P2-RTB or P2-RTB-1 removable terminal block or ZIPLink pre-wired cables.
$46.50​
$46.50​
P1-01DC
1​
Productivity1000 DC power supply, 12-24 VDC nominal input. External power supply optional. For applications not exceeding (8) P1000 modules.
$45.00​
$45.00​
P1AM-ETH
1​
ProductivityOpen Ethernet shield, 1 port, (1) Ethernet 10/100Base-T (RJ45) port(s). For use with ProductivityOpen P1AM-100 CPU.
$39.00​
$39.00​
P1-08ND3
1​
Productivity1000 discrete input module, 8-point, 12-24 VDC, sinking/sourcing, 2 common(s), 4 point(s) per common. Requires P1-10RTB or P1-10RTB-1 removable terminal block or ZIPLink pre-wired cables.
$36.50​
$36.50​
P1-08TD2
1​
Productivity1000 discrete output module, 8-point, 12-24 VDC, sourcing, 1 common(s), 8 point(s) per common, 1A/point. Requires P1-10RTB or P1-10RTB-1 removable terminal block or ZIPLink pre-wired cables.
$36.00​
$36.00​
DN-T12-A
1​
DINnector single-level terminal block, accepts wire size 24-12 AWG, gray, 20A, 600V rated (UL), 35mm DIN rail mount. Package of 100. For use with jumpers DN-24J2Y, DN-2J2Y and DN-3J2Y.
$43.00​
$43.00​
P1-04RTD
1​
Productivity1000 temperature input module, RTD, 4-channel, 16-bit resolution, input RTD type(s): Pt100, Pt1000, JPt100, Cu10, Cu25 and Ni120. (1) P1-10RTB screw terminal block included.
$121.00​
$121.00​
P1-4ADL2DAL-2
1​
Productivity1000 analog combo module, Input: 4-channel, voltage, 0-10 VDC, Output: 2-channel, voltage, 0-10 VDC. Requires P1-10RTB or P1-10RTB-1 removable terminal block or ZIPLink pre-wired cables.
$111.00​
$111.00​
RTD0100-10-010-H
1​
ProSense temperature sensor, Pt100 RTD, M12 probe, 160mm insertion length, 10mm probe diameter, stainless steel sheath, 4-pin M12 quick-disconnect.
$30.50​
$30.50​
SE-SW5U
1​
STRIDE industrial unmanaged Ethernet switch, 5 ports, (5) Ethernet 10/100Base-T (RJ45) port(s), -10 to +60 deg C, plastic housing, IP40, 35mm DIN rail mount.
$95.00​
$95.00​
DN-R35S1-2
1​
DIN rail, slotted, 35mm, 7.5mm height, 1m length, plated steel. Package of 2.
$10.00​
$10.00​
TFFN18BK
1​
TFFN hook-up wire, 18 AWG, 16-stranded, bare copper, black insulation, 600V, 500ft spool. Alternate part ID: 106100501440.
$33.50​
$33.50​
MW2016HLL
1​
AttaBox MachoBox series enclosure, NEMA 1/3R/4X/6P/12, 20 x 16 x 8in (HxWxD), wall mount, fiberglass reinforced polyester, gray, single-door, (2) twist-lock latches, SAR acrylic window.
$393.00​
$393.00​
BPM2016CS
1​
AttaBox subpanel, carbon steel, white, polyester powder coat finish. For use with 20x16 (HxW) FRx201610xx Freedom series and Mx808xx & WH-M2016Hxx MachoBox series enclosures.
$31.50​
$31.50​
MES-302A-RYG
1​
Patlite LED signal tower, (3) tiers, 25mm diameter, red/amber/green, permanent light function, 24 VDC, NPN polarity, clear lens, 40mm body length, silver, 360 degree viewing angle, direct mount, IP42.
$132.00​
$132.00​
CD12L-0B-020-C0
1​
Cable, M12 right-angle female to pigtail, 4-pole, PVC jacket, gray, 6.5ft/2m cable length, IP67.
$8.50​
$8.50​
DN-24J2Y
1​
DINnector terminal block jumper, push-in type, 24-pole, orange, 25A, 600V rated (UL). Package of 5. For use with multiple terminal blocks.
$18.50​
$18.50​
DN-EB35MN
1​
DINnector screw-down end bracket, 9mm wide. Package of 20. For use with 35mm DIN rail.
$21.00​
$21.00​
DN-G10-10
1​
DINnector grounding terminal block, accepts wire size 24-10 AWG, green and yellow, 35mm DIN rail mount. Package of 10. Use to mechanically and electrically connect wires to 35mm DIN rail through the clamping foot.
$28.00​
$28.00​
025400-00
1​
Stego LED enclosure light, 100-240 VAC operating voltage, on/off switch, 13.8in length, 400 Lm, magnet mount, 2-pole plug with snap lock, 5W, IP20.
$87.00​
$87.00​
FA-REC3
1​
Three-receptacle outlet, 15A combined, 125 VAC, DIN rail mount, for laptop computers and test equipment.
$24.50​
$24.50​
TOTAL
$1,500.00​
 
In terms of UI/HMI - it's really not my forte'. Everyone seems to know EXACTLY how they want their HMI to play into the system, but I just can't integrate complex auxiliary functionality until I have the basic core of the unit functional.

Imagine this scenario: "Oops, my lunar simulator script hung on execution during the middle of my autofeeder cycle and dumped all the food into the tank."

You have hit on my exact concern. Lacking specific evidence to the contrary, I would say all current controllers are software reliability black holes. They rely on APIs that almost no one understands the internals of. Your Arduino based system is better in that respect. You can actually look through the libraries and figure out what they do.

That is why I am trying to transition to a more distributed type of system where each function will have a little stupid microcontroller with its own timers. The system will boot and execute a simple default function and any sophistication, such as your lunar cycle, will be in an alternate that can only be started by external command.

The idea is to make each core function 100% testable and then use interfaces that are hard to hang. I am old fashioned, I like the idea of polling a command buffer that is sized to accept one command. Since the device being controlled polls its input buffer you are guaranteed that either one or zero commands execute each loop.

As far as hardware goes, anything you get from a reputable distributor like Arrow, Newark, Digi-Key or Mouser will be fine for this application. If you can source automotive grade parts they will probably give the most reliability for the money. Anything you get from ebay, amazon, or alianything probably has a 50% chance of being counterfeit.
 
There seems to be this pervading belief that packing all of the functionality into a single processor is prudent. SeaDragon is going to be only the core control components - cyclic polling of sensors and actuators, stacklight indicators, pushbutton operation, ip67 or ip69 protection of the ip20 cabinet components, and simple MQTT pub/sub API (at which point, whatever you want to do with the data is up to you.)

I copied the examples from the Chronos.h library to make an event/alarm scheduler (i.e. trigger autofeeder daily 4x at 60m intervals) but I'm not 100% sure that's how I want to handle that. I'd almost rather just have the autofeeder triggered by the pub/sub API and the request validated by the PLC (e.g. 2 feedings within 30m disables autofeeder functionality and raises an alarm which much be acknowledged before the autofeeder will run again.)

I designed this system to work with multiple tanks as well so I can modularize the code even further.

Eventually I hope someone makes a ladder-logic/sequential function chart IDE for the user programs, while the system will take care of scheduling the tasks and feed back a status information API.
 
The idea is to make each core function 100% testable and then use interfaces that are hard to hang. I am old fashioned, I like the idea of polling a command buffer that is sized to accept one command. Since the device being controlled polls its input buffer you are guaranteed that either one or zero commands execute each loop.

I like that idea about 100% testable/modular software. I chose components such that each component is responsible for a discrete operation (i.e. RO1 is just the mechanical relay control). I guess it could be further broken down into a schema like T1_RO1 (Tank 1 Relay Output 1), but I'd rather modularize that with software blocks and just have a single IO bus controller.

The P1AM has the option to connect modules with ZipLink over a longer distance, in case you wanted to have a single controller with two tanks but don't want to wire each signal between the tanks (Remote IO). Fortunately my tanks are adjacent to one another, so the controls box will be for both.

Controllino and Programmino also look pretty cool, my only concern is that they're limited in the amount of IO points per module. P1AM can do 15 modules total in slices.
 

IF YOU HAD TO TAKE A REEFING EXAM, WOULD YOU PASS?

  • Yes!

    Votes: 32 45.7%
  • Not yet, but I have one that I want to buy in mind!

    Votes: 9 12.9%
  • No.

    Votes: 26 37.1%
  • Other (please explain).

    Votes: 3 4.3%

New Posts

Back
Top