Close

January 4, 2014

A project log for AquaPic - Aquarium Controller

Reef tank controller used to monitor various parameters such as temp and pH, and also control equipment such as pump and lights.

skyler-brandtSkyler Brandt 01/04/2015 at 10:030 Comments

After toying around with a touch GUI for the chipkit, I was not enthused with the results. It was going to be way too much work to get a half-assed end product, so the new plan is an ARM running Linux. I'm planning on using Linux because Android is too unstable for this application. As for a hardware platform, I'm planning on using the Radxa Rock. I was just going to use everyone's favorite, the Raspberry Pi, but by time I added the cost for it, wifi, a case and a power supply, I was almost 75% of the way to the cost a Radxa Rock, which is almost 4x as powerful. The ODroid was a similar story. It was actually just slightly more than the Radxa after all the accessories where added in, but shipping is $20. The Radxa can be shipped from a US supplier for $6. I think that is a fail on Hardkernel's part, the makers of the ODroid, because they say they're never going to use any outside distributors. If they did have someone in the US or shipping wasn't a third the cost of the actual board I would have gone with the ODroid.
As for a platform, I'm going to be using Mono, a cross-platform port of the .NET framework. I really enjoy writing C# code, its my favorite language, so when I found that I could use it to write programs for Linux, I was all that way on-board. Using the Mono framework is going really well. C# has a lot of useful features built into the language and standard libraries, so I'm able to get a lot done quickly. The really nice thing about Mono is that I can develop, test, and debug on Windows, and the application will still run on Linux. I know that I could have also used the more popular Java language but there's a few reasons why I didn't. First, I'm not all that familiar with Java, and yes code is just syntax and it wouldn't take me more than a few days to get a pretty good grasp on it. I just didn't feel like figuring it quite yet. I'll have to learn Java someday, its a required class for my degree. Second, Java does not allow "unsafe" behavior. I'm not doing a whole lot with pointers but I'm doing my fair share with the serial communication protocol I'm writing, more on that later. There's always work a rounds but its so much easier to simply copy memory with pointers.

Mono's preferred GUI library is Gtk#, which is a wrapper of the Gtk+ library, and I find it more useful and easier than WinForms. It does take a little bit to get used to it's quirkiness but I'm getting though it. Gtk+ is only supposed to be used for actual PC screens but with a little work I'll have some nice touch screen widgets put together. I'm planning on doing some more in-depth posts on my experiences on Gtk#, and share my experiences with others because the documentation is severely lacking.

Another aspect I'm changing with the controller is the communication protocol between all the devices to UART. I was originally going to use I2C but it wasn't fulfilling all my requirements. First its only supposed to be used for short distances, like on the same PCB, however there's some IC solutions out there that can be used to boost/buffer/extend the range, but that's just extra parts and more money. Second, most devices either don't have an useable I2C, or its a pain to setup. To be able to use UART though, I needed a protocol to allow a master to communicate to multiple slaves. I tossed around using Modbus but decided on writing my own. I'm mostly done with it. There's a few tweaks I want to make but it works. I've test this using the chipkit and mocked two slaves and that worked but I haven't tried two physical slaves. I encountered an aggravating hurtle when I was trying to test this on the chipkit. Arduino's compiler fails if the source file extension is .c so even if the code is C, the file extension has to be .cpp. That took me a little bit to figure out.

Code examples at link.

Discussions