The weekend project

An industrial process PID controller (commercial project), with wifi, lcd, button-driven menu, thumb-drive storage, and a GSM Click board (not fully connected in the image) for fault alerts. I put it together with Gadgeteer hardware (native netmf software) as a prototype and as a prelude to custom hardware. It’s running the Verdant node architecture core, is network configurable, and logs to Azure.

10 Likes

Cool Project. Where is all the button wires going?

@ njbuch - It’s hard to see because I routed them under the “Breadboard X1” module, but the four switches go to Socket X14 on the Spider 2. I chose that port because I could enable interrupts on the four pins that I am using. Each button has a 10K pull-up, and pressing the button brings the line low.

EDIT: I should probably also mention that they are for navigating a menu system and changing settings. The buttons are up, down, back/cancel, and enter. Holding CANCEL will take you back to the top of the menu system. After a 30s timeout, the menu disappears and you get a cycling display of status values. Pressing any button takes you back into the menu system.

1 Like

What does the PID control?

Sounds like a brilliant codeshare entity
:wink:

2 Likes

@ ianlee74 - I am being purposely circumspect about that because it’s a commercial project. With permission, I’ll try to describe it more fully (or the project lead will as he is also occasionally on the forum).

@ njbuch - EDIT: See below

There’s an added bit of complexity here. The display and menu system rely heavily on the Verdant Node structure, and so I will end up publishing that anyway (and that’s always been the intent).

The Verdant Node structure relies on Dependency Inversion (aka Inversion of Control), and a system of “drivers” and “agents”

Drivers are things that interface to the hardware and abstract away some hardware differences and/or provide some system-level service. So here, the term ‘driver’ also encompasses ‘service’. Drivers can be composed to create synthetic drivers/services (e.g., the menu system is a driver that composes the button driver and lcd driver). Agents are periodic, scheduled tasks, like “read the sensors”, “make decisions”, “upload to Azure”. The use of drivers and agents is an attempt to significantly improve testability and reusability.

So, when you press a button, the periodically executing agent that displays a rotating list of status values gets preempted (loses access to the lcd) and the menu system takes over.

The point is, I can’t just publish “the buttons” or “the menu system”. It is all based on the Verdant infrastructure - which I do plan to publish, open source, at the end of this project. I won’t publish the application-specific bits, though, of course - those belong to my client.

Here’s an example of using Dependency Inversion:

 public class MenuDriver : IDriver, IMenuDriver
    {
[...]
        public void Start()
        {
            _buttons = (IButtonDriver) DiContainer.Instance.Resolve(typeof (IButtonDriver));
            _buttons.ButtonEvent += OnButtonEvent;

            _lcd = (ICharacterLcdDriver) DiContainer.Instance.Resolve(typeof (ICharacterLcdDriver));

            DiContainer.Instance.Register(typeof (IMenuDriver), () => this);
        }
[...]

The above code obtains a reference to the button driver and subscribes to button events. It then acquires the lcd driver (which it will use later) and then registers itself as a singleton instance of the IMenuDriver interface - that is, it becomes a service offering IMenuDriver.

Dependency Inversion is a core component that offers runtime binding to services; hardware abstraction; and simplified emulation and unit testing.

It’s going to take me some time to prepare this for release, but I will get it out sometime in late April. This will also include a lot of ready-to-run drivers and agents. This has been used in two commercial projects (soon to be three) and that experience has helped me refine the design.

5 Likes

@ mcalsyn - Im impressed by your reflections and sophistication in a simple 4-button menu… something to learn from! Looking forward to see more! Thanks :slight_smile: