Goniometer Sensor - Unit Conversion
Difficulty Level:
Tags pre-process☁goniometer☁gon☁conversion

The OpenSignals outputted file formats contain raw data, so each sample has a digital unit.

In scientific terms it is recommended the use of specific units, like electric tension (V) or electric current (A). Each sensor that PLUX commercialise has a datasheet where a transfer function is mentioned for unit conversion be done.

The next lines are intended to explain how this conversion can be programmatically implemented.

In spite of the unit conversion procedure has some common steps applicable to all sensors, the current Jupyter Notebook is dedicated to the unit conversion procedure of signals acquired with Goniometer (GON) sensor.


1 - Importation of the needed packages

In [1]:
# biosignalsnotebooks Python package with useful functions that support and complement the available Notebooks
import biosignalsnotebooks as bsnb

# Function used for creating a numpy array, where a mathematical operation can be applied to each entry in an easy and automatic way. On the other side, linspace, here will be used for generation of a time-axis.
from numpy import array, linspace

2 - Download of the sensor datasheet (from https://biosignalsplux.com/index.php/learn/documentation ). In this case we are working with GON, being our file located at http://biosignalsplux.com/datasheets/GON_Sensor_Datasheet.pdf

In [2]:
# Embedding of .pdf file
from IPython.display import IFrame
IFrame(src="//biosignalsplux.com/images/pre-process/unit_conversion_gon/GON_Sensor_Datasheet.pdf#page=2", width="100%", height="350")
Out[2]:

3 - Extraction of the transfer function from the beginning of the second page

\begin{equation} ANG{(^°)}= \frac{\big(\frac{VCC}{2^n-1}\big)\times ADC - \frac{VCC}{2}}{\frac{VCC}{2}\times{606}\times{10^{-5}}} \end{equation}
$ANG{(^°)}$ - Angle value in degrees (°) $ADC$ - Digital value sampled from the channel (initialism of "Analog to Digital Converter") $n$ - Number of bits of the channel (dependent on the chosen resolution specified on OpenSignals previously to the acquisition stage [8, 12 or 16 bits])
$VCC$ - Working voltage (3 V)

4 - Loading of data stored in biosignalsnotebooks own signal library

In [3]:
# Data loading
data, header = bsnb.load_signal("gonio_arm_flex", get_header=True)

In the following cell, some relevant information is stored inside variables. This relevant information includes the mac-address of the device, channel number and signal acquisition parameters such as resolution and sampling rate.

For a detailed explanation of how to access this info, the "Signal Loading - Working with File Header" Notebook should be consulted.

In [4]:
mac = "00:07:80:79:6F:DB" # Mac-address
gon_ch1 = "CH1" # Channel
gon_ch2 = "CH2" # Channel
sr = 1000 # Sampling rate
resolution = 16 # Resolution (number of available bits)

Access to acquired signal samples and storage inside a new variable.

In [5]:
signal_ch1 = data[gon_ch1]
signal_ch2 = data[gon_ch2]

5 - Final unit conversion (to degrees ) by applying the transfer function sample by sample

Definition of $VCC$ constant

In [6]:
vcc = 3 # V
In [7]:
ang_degrees_ch1 = ((vcc / (2**resolution - 1)) * signal_ch1 - (vcc / 2)) / ((vcc / 2) * 606e-5)
ang_degrees_ch2 = ((vcc / (2**resolution - 1)) * signal_ch2 - (vcc / 2)) / ((vcc / 2) * 606e-5)

6 - Time axis generation

In [8]:
time = bsnb.generate_time(ang_degrees_ch1, sr)

Comparison between RAW and signal in degrees scale.

In [9]:
bsnb.plot([time, time, time, time], [signal_ch1, ang_degrees_ch1, signal_ch2, ang_degrees_ch2], y_axis_label=["Raw Data", "Angle (º)", "Raw Data", "Angle (º)"], title=["Goniometer CH1 (Raw)", "Goniometer CH1 (º)", "Goniometer CH2 (Raw)", "Goniometer CH2 (º)"], grid_lines=2, grid_columns=2, grid_plot=True)

Similar Notebooks , dedicated to the unit conversion of other sensors, are available in the following "conversion" section of Notebooks Grouped by Tag page

A list of PLUX"s available sensors (and the respective datasheets) can be accessed at Sensors page .

We hope that you have enjoyed this guide. biosignalsnotebooks is an environment in continuous expansion, so don"t stop your journey and learn more with the remaining Notebooks !

In [10]:
from biosignalsnotebooks.__notebook_support__ import css_style_apply
css_style_apply()
.................... CSS Style Applied to Jupyter Notebook .........................
Out[10]: