Sunday, November 16, 2014

Plot It - a useful graphing programme for serial data

Plot It allows data to be exported in various image formats

An immensely powerful technique when developing smart sensor systems is the ability to capture data in real time from a microcontroller and save it either as a CSV file or plot it graphically.

Several open source programs are available, but the ones I have tried never seem to do exactly what I need, so it was great news when a software colleague of mine produced Plot It, and has agreed to make it widely available for hobbyists and enthusiasts.

Plot It takes in data from a serial port, by polling the microcontroller at regular intervals with a serial character as a request for data packets.

The data packets were designed to hold up to 32 bit data, and Plot It currently accepts 24 bit data - as it was intended to be used as a diagnostic tool for debugging a 24 bit ADC system. 

The data packet consists of 4 data bytes - of which the most significant byte is set to zero.

Following the data bytes, a single byte represents the data channel number. This allows for up to 256 separate sensor channels.  The early version of Plot It caters for just 2 channels at the moment.

Finally, there is a packet terminator consisting of the bytes 0x0D, 0x0A.

The code to send these packets from an Arduino or Nucleo is fairly simple.  The microcontroller waits to see a character arrive in it's serial receive buffer, and then executes a routine that sends out the data packet.

A sketch for Arduino has been put on Github Gist  - here.

Plot It currently works at 9600 baud, but can be tailored up to baudrates of 921600 baud.  The 24 bit ADC system we were testing was sending packets at 20kHz (50uS) - and so we needed a super fast baud rate to get the data across quickly.

Temperature Monitoring - A Typical Application

Plot It can be used for local monitoring of sensors.  One example is my  Arduino based central heating controller, which reads a series of temperature values from analogue thermistor channels.

Thermistors are a fairly cheap method of measuring temperatures, and an alternative to the digital devices such as the one wire Dallas 18B20 series.

Although the Arduino ADC is just 10 bits, multiple readings can be averaged to produce a smoother data. In addition, a simple 100nF capacitor across each thermistor input is a good way of reducing analogue noise.

As a consequence, the thermistor can produce fairly high resolution data - down to about 1000th of a degree.  Whilst the absolute accuracy of this measurement may only be to 1/10th of a degree, the high resolution allows minute changes in temperature trend - such as those caused by draughts etc to be analysed.

Plot It may be used to provide an insight into how quickly a room responds to having the eating turned on, or how quickly a tank of hot water cools down after heating.  Seeing how these systems respond to inputs over time allows better analysis, and better control systems to be designed. 

The "Blue Room" heats up smoothly, whist the "Red Room" is prone to draughts and air movements

Note how each graph has its own scale, blue on the left hand side and red on the right

Temperature fell by 0.7C - until a door was closed, removing the draught

The right hand mouse button allows several features to be selected - such as auto-scaling, image export, and setting the scaling to default.  The left mouse button allows drag selection of data to pan and zoom into any area of interest.

Plot It can export your data to a CSV file for further analysis in spreadsheets etc.

It is anticipated that further features will be developed in time.

No comments: