The Sunday blog: HMI, cybernetics and the steam engine

Part 4: Theory and practice

In the last 3 episodes of this blog we have followed the technical development of tools, machines and computers. And we have discovered that an intelligent HMI is used where an attractive and ergonomic user interface is to be created in a limited space and with manageable costs and development effort.

Reading educates… The idea of quoting a dishwasher as a practical example in the last episode and using it as a practical HMI concept from today on came to me while browsing through a forum on the Internet. There is still so much to discover!

One way to do things

In order to develop a really slim and efficient HMI afterwards, we should open the Nextion editor right now, “knit” a nice user interface with a few mouse clicks and then slowly think about how the dishwasher’s control processor provides us with the necessary information and how we display it, right? Wrong!!!

… and the more efficient way

Software development starts in the head, supported by pencil and paper. First we list the desired specifications and then define processes. Completely abstract. Only at the very end, when we have perhaps corrected several times and added one or the other thing we hadn’t thought of at the beginning, and have symbolically gone through the process again and again in our heads, then we have the chance to write really efficient code that will most likely work right away.

Looking at the basic conditions, first

Our virtual dishwasher makes it relatively easy for us: We assume that we only have to take care of the HMI, the MCU that controls the machine is already there. We have a brief spiritual discussion with the department responsible for this MCU. We find out that the MCU that is used is already quite busy with the machine’s sequencing and the polling of the sensors, and therefore there is hardly any computing time and memory available for communication with the HMI. It is therefore out of the question that the MCU continuously generates long ASCII strings such as “pre-wash – heat up” and sends them via the serial interface to the HMI all the time!

After a short thought and estimation of the intelligence of our Nextion HMI we accept the challenge!

Analysis of the information

Let’s start by listing and evaluating the information that our MCU has anyway:
1.) The number of the running program (0 for none, 1, 2, 3, 4) these are 5 values whose representation requires 3 bits.
2.) The number of the running subprogram (0 for none, 1 for prewash, 2 for the main wash, 3 for rinse, 4 for drying), also requires 3 bits.
3.) Program running (1) or paused (0) = 1 bit.
4.) The door is open (1) or closed (0) = 1 bit.
5.) The remaining time in minutes until the end of the program. We assume that none of the programs will take longer than 4 hours and 15 minutes, so we can get by with 8 bits for a maximum of 255 minutes.
6.) The water inlet is open (1) or closed (0) = 1 bit.
7.) The circulation pump is running (1) or not (0) = 1 bit.
8.) The sewage pump is running (1) or not (0) = 1 bit.
9.) The heating is running (1) or not (0) = 1 bit.
10.) There is enough rinse aid in the storage tank (1) or not (0) = 1 bit.
11.) There is enough regenerating salt in the storage tank (1) or not (0) = 1 bit.
12.) The sensor for the water level in the machine supplies values from 0 to 3 = 2 bits.
13.) The actual water temperature is supplied by a temperature sensor and is coded in integers from 15°C (0) to 75°C (60), for which we need 6 bits.

Packing and sending

If you add the whole thing up, you will find that the current status of the machine can be described with 30 bits. So with a few simple bit field operations, we can put all the necessary information on the CPU side into a single 32bit integer variable and then, whenever the machine state changes, we can use the simple instruction sequence
NexSerial.print(“sys0=”); NexSerial.print((int32_t) status, DEC); NexSerial.print(“\xFF\xFF\xFF”);
transferred to our HMI. This means that we have practically no additional load on the CPU and require almost no memory. It couldn’t be simpler! The CPU team will thank us for it!

In the next episode, we will see how we handle the occasional resetting of the system variable sys0 in our Nextion HMI with well-considered programming technology alone, and how we then use standard elements of the Nextion programming language to break down this compact 30-bit number into the individual information and finally display it in a readable and comprehensible manner.