Scroll to top
Back
Firmware Industrial Medical & Analytical Software

Software and Firmware Development for Water Quality Analyzer

    Scroll

    The Context

    According to the United Nations World Water Development Report 2019, over 80% of all wastewater in the world returns to the environment without being treated. Water quality is fast becoming one of the main challenges of the 21st century, threatening human health, limiting food production, reducing ecosystem functions, and hindering economic growth. A big name in the water quality monitoring niche wanted to design and develop a state-of-the-art water quality analyzer, to be used in sewage treatment plants. Tismo was brought on board to develop the firmware for the instrument and an Android application to serve as the User Interface (UI).

    The Problem

    The water quality analyzer was intended to be used in the sewage treatment process, to measure pH, Oxidation-Reduction Potential (ORP), turbidity, conductivity, free and total chlorine content, pressure, temperature, flow etc. The instrument would have to alert operators to alarm conditions and control actuators to mitigate them. Additionally, the measurements and alarms would have to be logged on an SD card and be made available for future reference. The water quality analyzer would have to be mounted on sewage pipes in an industrial environment, with cramped working spaces. This called for an extremely user-friendly UI.

    The Solution

    Tismo developed the firmware for the water quality analyzer and an Android application to serve as its UI.

    Firmware

    The firmware of the water quality analyzer was developed using Embedded C. It followed a layered architecture, with each layer abstracting out the functionality at a certain level and exposing a well-defined interface to other layers. The firmware supported the interfacing of 8 input channels, using 4-20mA protocol, through the I2C interface. It  was responsible for the acquisition of analog inputs such as pH, Oxidation-Reduction Potential (ORP), turbidity, conductivity, free and total chlorine content, pressure and flow. The analog input channels could be configured to the different sensors and the ADC count would be converted to the selected sensor value. The firmware also handled inputs from sensors that detected the leakage of chlorine, sulfur dioxide and ammonia. It acquired data from a temperature sensor, monitored the battery using an ADC channel, shut down the instrument under low-voltage conditions and supported a power-saving mode. The firmware also supported the interfacing of 4 output channels using 4-20mA protocol, and was designed to implement PID algorithms to control the output channels.

    The firmware of the water quality analyzer also supported 8 alarms, each with high and low modes of operation. Each of the input channels could be configured to a particular alarm. 2-point calibration was enabled for the pH and ORP sensors, and 1-point calibration for all other sensors. The firmware was designed to log all parameters from the analog input channels and the status of the alarms, on an SD card, at time intervals set by the user.

    Product Architecture for a Water Quality Analyzer

    Software

    Tismo developed an Android application using Java and XML, that acted as the User Interface of the water quality analyzer. The application was designed to run in kiosk mode. The Model–View–Controller (MVC) software design architecture was followed. The Realm Database was used for data storage, as it was faster and easier to use when compared to other local database options like SQLite. The design of the Android application contained a manager module, that allowed the application to function in either the bootloader mode or the application control mode.

    The Android app supported 2 types of users. The ‘Admin’ could create new users, configure input and output channels and monitor and control the status of devices through the app. The ‘Standard User’ could only view the settings, parameters and status of peripherals connected to the input and output channels, through the app. The real time data from the input channels were displayed on customized gauges, using the SpeedView library. Each gauge was customized to show the range and units of the selected input channel. The real time data as well as historical data from user selected input channels, could be displayed as graphs on the dashboard screen. The MPAndroidChart library was used to realize the graph functionality.

    Tismo also implemented a screensaver for the Android application, that displayed real-time data from the input channels as dynamic data. The Android app was robust by design and handled events such as communication errors, unexpected disconnections, non-responsive peripherals, and unexpected parameter values without crashing. It communicated with the water quality analyzer via USB, using JSON format. The app supported firmware upgrade over USB and also supported the export of data to an SD card as CSV files.

    The Tismo team understood that the water quality analyzer was intended to be used in sewage treatment plants. The Android app was designed for use in industrial settings, with cramped working spaces, elevated noise levels and high-glare lighting. On-screen buttons, labels and error messages were designed to be easily readable and simple to understand. A flat menu system was employed, without complicated or multi-layer hierarchy. Dark and light modes were designed for the application.

    Summary

    Tismo developed the firmware for a state-of-the-art water quality analyzer and an Android application to serve as its User Interface. The Firmware development was carried out in Embedded C. It supported the interfacing of 8 input channels and 4 output channels with the controller board, using 4-20mA protocol. The Android application was developed using Java and XML, in line with the MVC architecture. The Realm Database was used for data storage. The app was robust by design, supported firmware upgrade over USB and the export of data to an SD card. Tismo implemented a screen saver with dynamic data and handled the critical UI/UX design aspects, enabling the app to be seamlessly used in an industrial setting.