09/19/2023

IIoT - Push oversampled arrays to InfluxDB

Disclaimer

The goal is to use ctrlX CORE or a ctrlX OS installation in order to store and monitor High Frequency signals for condition monitoring. Let's go. 

Oversample Array

Requirements:

  • ctrlX CORE - x3 or x7 or a ctrlX OS installation
  • PLC app
  • Node-Red just 
  • PLC app + ctrlX WORKS
  • Jupyter app (coming soon)

STEP0: install Node-RED, InfluxDB, PLC app, and Jupyter (to come)

The first goal is to install the needed apps and configure them. For Node-RED and InfluxDB apps we can follw this link: Setup influxDB and node-red. 
Once we have anything installed we need to keep the influxDB token and write a simple plc Progam.

STEP1: setup the PLC project

We need to simulate the acquisition of an HighFrequency signal. We can think it like a simple function like y=Kt+White Noise, where t is an index of an array that contains the value of the function. We need to think that we need the following process:

  1. Create the vector and sample the generated value.
  2. Read the data with some high level language and format it accordingly for InfluxDB using a trigger
  3. Once the load is stored then reset the signal and repeat. 

This simple functionality can be achieved using a simple PLC program. 

PLC code

STEP2: get the data, format it correctly and ship it in influxDB - Node-RED version

To correctly load an array we need to create a string that contains the measurement name, the field and the value and the time. The string is then repeated with "\n" as ending character. It is also important to Set the right precision/ authorization and database details.

Node-RED function

Once the packet is ready we need to send a POST request that contains all the details. 

Node-RED post

The code can be shaped so that any time the PLC apps has a new array recorded Node-RED can then read and ship it. Can be also convenient to visualize directly in node-red the shape and maybe apply some downsampling if needed. The full code is attached.

Node-RED code

 

Node-Red graph

Anyway, the data will be visible in influxDB and IOT Dashboard as well!

InfluxDB output

STEP2: get the data, format it correctly and ship it in influxDB - python version

The code in python is similar. Can be used externally or inside ctrlX CORE with a custom app or with Jupyter APP. Use Jupyter notebook to test this code! 

Python Code

Ciao 🙂

3
Oversample plc.zip
3.73MB
oversample_python.zip
250.58KB

Latest published/updated articles

Types
How-to
Categories
IOT
Markets
Assembly Lines
Attachments
Project