Most embedded systems will need to interface with “reality” in some way, whether that is reading in information measured by transducers or controlling some “actor” device to achieve some action. In the case of the Harting MICA, it has eight GPIO lines which can be used for this purpose.
Working with GPIO
The Harting MICA includes eight lines of GPIO on the I/O connector, including four high-side drivers, two low-side drivers and two configurable drivers. These lines can be used as input to receive a digital on/off input from a transducer, or as an output driving the same voltages as supplied via the I/O connector. This means if powering the MICA via the I/O port at 12V, the GPIO signals will be at 12V, likewise if powering at 24V, the GPIO signals will be at 24V.
As included in the kit, the provided I/O cable is only terminated on the power pair to a female barrel socket to connect to the included power supply. The remaining wires are left unterminated and modification will be necessary in order to access the GPIO pins. The information regarding this can be found in the Harting HAIIC MICA Hardware Development guide which details the cable colour versus pin-out versus pin function. The information is not presented in the most convenient way, requiring cross-reference between diagrams to work out pin colour vs pin function. I have provided feedback on this in the hopes they would improve the documentation to make it slightly easier to interpret.
The GPIO ports are driven by a TLE chip capable of a maximum of 50mA per channel, up to 250mA for the whole chip to avoid overheating. As a result, drive current is somewhat limited, but still sufficient to drive LEDs and some models of relays (with appropriate reverse EMF protection) directly.
Regardless, in order to access the GPIO, I built a small break-out board that opened up all of the wires to header-pins. These are multipled to allow for several connections (in case it is needed for debugging or paralleling several loads or sensors).
One method of accessing the GPIO is to use the GPIO container supplied by Harting. This container provides a web interface that allows for manual toggling and demonstration of the GPIO, connection to MQTT for “remote” control using JSON formatted requests (e.g. from a NodeRED instance) and a websockets-based JSON RPC service which can be accessed directly. For input pins, MQTT messages are published at 200ms intervals. The broker address and pin-names can be defined in the interface and set to “auto” mode for remote control.
This seems simple enough, although at first, I had some difficulty getting this to work as I wasn’t interpreting the documentation correctly regarding the expected MQTT message format. While it is in the documentation, it was under the WEB-RPC heading which did not mention MQTT, thus I had missed it and instead contacted support for clarification. Thankfully, they quickly gave me the pointer to the information I needed and an example, while I provided feedback in the hopes the documentation could be made clearer.
Project: Simple “Bang-Bang” Controller
To best demonstrate the use of GPIO capabilities, I decided to implement a simple “bang-bang” controller at the edge, using NodeRED. Put simply, a bang-bang controller is one that is either on or off – nothing in-between. This can be implemented simply by using threshold-based comparisons.
The aim, in this case, was to maintain the temperature as measured by the Bosch CISS at 25°C. When the temperature is below 25°C, turn on the heating. When the temperature is 25°C or above, turn off the heating. To supply the source of heat, a MR16 50W halogen dichroic downlight was used, supplied by the second channel of the HMP4040.04, current limited to 2A for an effective power of about 6W. The current to the light was passed through a 12V relay that is reverse-EMF protected by a diode and consumes 46mA, connected to the high-side output Pin 2.
This was easily achieved with a thresholding function which is merely a comparison in Javascript. Another function (trigger) was added to blink the LED on Pin 1 just to illustrate that data from the Bosch CISS was being received and processed. This system works entirely on the end-point device with no intervention from a back-end of any sort.
In all, it seemed to work quite well, pulsing the relay on and off at 1s intervals due to the CISS Gateway fixed data output rate. I added some hysteresis later, one degree either side, which results in the familiar sawtooth curve. This is what it looks like as monitored and plotted with the same NodeRED instance.
I did find that adding additional functions did eventually slow-down NodeRED to the point that it was not able to process all the incoming data in real-time, resulting in stuttering in the blink rate of the triggered LED and delayed responses – so it’s important to optimise your flows and keep your processing within the constraints of the system, as this is more akin to a multitasking computer rather than a real-time operating system with guaranteed response times.
Project: Cooking with the MICA
Then, I thought, why not bake the whole MICA instead of just the CISS sensor? The Harting MICA is specified with an operational temperature range of -25°C to 75°C, so it would be interesting to assess how it might handle the upper extremes.
In order to do this, the set-up was changed to have the lamp on top of the MICA and the CISS underneath. As the CISS does not contact the MICA body directly, we expect the temperature readings to be an underestimate, but the GPIO flow was set with changed temperature thresholds so the testing can be run for extended periods with the unit (hopefully) disconnecting the lamp once the set threshold had been passed. It would also create work for the unit to monitor its own “baking” progress to determine when thermal equilibrium had been reached – in order to help it along its way, the lamp was overvolted to 14.5V for an output of about 67W.
It seems the temperature levelled out at about 40°C on the CISS on the underside of the unit separated by an air gap. This implies the MICA got very hot, and stayed there for the better part of over two hours.
According to the IR thermometer, the case surface temperature was 73.9°C, very close to the upper limit.
However, as we all know, IR thermometers can be deceptive, especially when the emissivity of the surface does not match the assumed value. For a better result, I turned the unit off, removed the cap from a USB port and shoved a thermocouple into the void space within the unit. This process took about a minute and a half, yet, the MICA was still measuring 71.3°C internally. Throughout this high-temperature testing, it did not falter at all, thus confirming its abilities as an industrial-grade computer.
Video: Demonstrating the GPIO
For those who might want to see the GPIO in action, I’ve created a short video:
Conclusion
The Harting MICA offers a total of eight GPIO lines, four of which are configured as high-side driving, two of which are configured as low-side driving and the final two being configurable. The drivers provide the same voltage as provided through the I/O port – if powered through 12V, then output is 12V. The GPIO is capable of 50mA per pin, up to a total of 250mA in total to avoid overheating.
The GPIO can be accessed on the I/O port through modification of the supplied grey cable to expose the necessary connections. The necessary documentation is provided in the Harting HAIIC MICA Hardware Development guide, although its format could be improved to better relate the pin number, wire colour and pin function without needing to cross-reference two diagrams manually.
In order to access the GPIO pins, the GPIO container can be used which provides a Websockets-based RPC interface, MQTT or a web interface for manual demonstration and configuration. Input pins configured for MQTT publish updates at 200ms intervals, with each pin having an MQTT topic name which can be redefined. The documentation was initially confusing due to misleading headings, as it was unclear to me what format MQTT messages should be in as the manual seems to mix Websockets RPC with MQTT information, however, Harting support were quick to point me in the right direction.
With this, it was simple to implement a simple bang-bang controller in NodeRED, both with and without hysteresis to keep the Bosch CISS sensor at 25°C. Such a design allows for processing at the edge, requiring no intervention from a back-end. However, it is discovered that more complex flows may suffer issues with processing such as delays or jitter due to limited computational resources and the multitasking nature of the operating system. Later, another test realised the use of the controller to “cook” the Harting MICA, bringing the unit up to about 73.9°C while remaining perfectly functional, thus verifying its industrial temperature rating.
---
This post is a part of the Harting MICA CISS Complete IIoT Starter Kit RoadTest