NETMF Applications: Sytech Designs a Heating Project

One of the key values of .NET is in handling complex projects.  This next project is a good example of this.  The project is a control system for domestic and industrial underfloor heating.  The system allows each room to be defined as a separately controlled zone.  Each zone has one or more remote temperature sensors and an electronic water valve actuators, to control the hot water feed to the zone, from the boiler water supply. Each zone is individually programmable to have a number of time periods, with a desired room temperature. All zones are controlled from one central user graphics user interface device.

The system comprises of remote wireless temperature sensors, one or more control units, which control the zone water valves, boiler and pumps as well as connect wirelessly to the temperature sensors and user graphics interface. A tablet based device is used as the graphics interface to the control system.

The remote temperature sensors are wirelessly connected to the main controller and battery operated, with a battery life in excess of two years, using a 3V CR2 battery (CR2 batteries are about the size of an AA battery).  The sensors are accurate to about 0.2C.

The main controller has two wireless communication channels, one to listen to the remote temperature sensors and one to connect to the external GUI tablet. It controls a number of water valve actuators, using solid state relays and has ‘zero volt’ relays to control the boiler, manifold pump and an optional ‘zero volt’ relay for controlling domestic hot water systems. The actual control program is running in this controller. The tablet interface is just a graphics interface to display status information and send the program parameters to the controller. Once the program parameters have been sent to the controller, it will run without the tablet.

The system is extensible, each control can physically handle up to 8 water valves (zones).  In an underfloor heating system the hot water is distributed to a group of zones thru a multi-channel water manifold. There can be a number of these water manifolds distributed around the building, allowing shorter groups of water pipe runs to the zones. To accommodate this there can be a number of controllers, the first controller is a ‘master’ and connects to the Tablet GUI device, it also connects (wirelessly) to the other ‘slave’ controllers, providing a pass thru link form the tablet to the other controllers.

The embedded controller application is quite complex as it has to implement two wireless control channels, one a Bluetooth LE ( BT4.0) ‘observer’, to listen to remote sensor broadcasts, decode the temperature data, and a bidirectional serial link over classic Bluetooth to send and receive data to the GUI on the tablet. This channel must also be able to establish simultaneous connections to up to 3 other Bluetooth devices (usually other controllers).  It must also run a real time based scheduling application, which will allow up to 8 programmed time periods, for each room, with the capability of running different programs for each day of the week. This equates to 8 time periods x 7 days, x 8 channels, which comes to 448 time periods, with each time period having its own temperature setting. It must also control 11 physical outputs (8 zones, plus boiler, pumps and hot water) and generate status information events transmitted to the tablet, such as boiler on/off, zone on/off etc.

The controller is implemented with an ARM based Cortex M4 processor, running NETMF 4.2. The C# application is a service based architecture with services for Bluetooth Sensor ‘Observer’ central host, Bluetooth Serial  Comms Service, with 4 simultaneous connections, a RTC based Scheduling Service,  a heating profile zone service ( with 8 zones) and a Output control service, controlling boiler, pumps and hot water.

Why NetMF

Initially Sytech started the controller code using a simple light weight RTOS (ARM CMSIS RTOS), however the RTOS only really provided basic task functions and semaphores. This was ok when they had just implemented two simple communications channels, but as they tried to add the other services, the code became more and more complex, and debugging a number of concurrently running tasks became more and more difficult.

A switch was made to NETMF. Now Sytech could develop the ‘middle ware’ business components, such as the scheduler, zone profile service etc. in C# and run and test these major components on a PC, constraining .NET functions to NETMF available functions. As 80% of the application was not directly hardware dependent, this allowed development of most of the business level services and components on a PC and complete unit testing of each component.  

The hardware dependent layer was implemented on the actual hardware, in managed code. Each hardware device (such as the Bluetooth LE Central device), has an API interface defined.  This API is used by a business class to ccess the hardware API. For instance the API interface to the Bluetooth LE implemented a control interface to set the device in ‘Observer’ mode and listen for BT Adverts. When an advert was received, an OnAdvertRX event was fired. A control protocol service class, registered with the event and processed the advert. If the data was related to one of our sensors (the advert could have been from any BT LE device, like a passing fitness band!) then a more specific application level event was fired, like temperature data received and passed on to a higher level business object. This way the business classes were abstracted away from a dependency on the physical hardware.

This allowed Sytech to implement and test each business service in a PC environment and then move the component over to the NETMF project, knowing internal functionality was tested and working, leaving us to concentrate on testing the interaction of the higher level service functions. 

What worked well

Initially the concern was that the application was quite complex, and that embedded processor internal RAM and Flash (190K RAM and 1 Meg Flash) would not be big enough to run the NETMF port and the application. Due to the large flash sector size in the processor, the space allocated for the MF port was 150K larger than the actual code size. This left Sytech with 512K flash space allocated to managed applications. They were worried that this would not be enough. However, as they implemented the various service components and integrated them into the application, they found that actually even their fairly complicated application was compiling down to less than 100K, so the limited flash space proved not to be a problem. (Note: In the NETMF team’s experiments with generating native code, we have found IL to be about 10 times more compact than native code.)

“As for application development, NETMF allowed the development of the application in an OO structured manner, using established software patterns. Debugging and testing in the Visual Studio environment was much simpler than using a conventional embedded RTOS, such as the ARM CMSIS RTOS, trying to debug with the Arm MDK tools.”

“As a result, the first ‘test’ system was installed in owner of the customer company’s house, in the beginning of winter, (a considerable risk, as failure would have quite a personal effect on the customer!).  However the system ran faultlessly during the initial test period, with only minor bugs showing up in the real world testing, none of which were critical (i.e they lost their heating!).  We have had several iterative test releases since then, each adding more complex functionality and in general testing has only shown minor bugs, with most problems being caught during development testing.”

Most of the business service components used on the Windows 8.1 tablet to do with communications protocols and data formatting etc were taken straight from the NETMF project code and used with minor modifications. This allowed the bulk of the coding effort for the test ablet code to be the GUI side, of course implementing a MVC pattern!

Sytech Designs Ltd Bio

"Sytech Designs Ltd was established in 1994, to design embedded hardware and software solutions. We offer design of custom embedded hardware, with in house pcb layout design and SMT assembly facilities for building proto-types and small production runs.

We offer a complete range of software development services, from native ARM code development, .NET Micro Framework custom ports, managed code development to Mobile device solutions. We specialise in remote sensors, industrial communication and internet connected embedded devices (enquiries@sytechdesigns.com)"