Our newborn scale is an instrument for measuring the weight and height of newborns and very young infants. It can measure up to 30 kg weight and 2 m height as maximum parameters.
Based on the interesting platform of Hexabitz, we have developed this simple, high-precision scale suitable for use in baby clinics, hospitals, etc.
This mini-project consists of a load cell (strain gauge) sensor module (H26R0) connected to a load cell (AB120-30K) to measure weight up to 30 kg, a time-of-flight IR sensor module (H08R6) that can accurately measure distances up to 2 m, and a STLINK-V3MODS computing programmer module (H40Rx) to establish real-time communication between the sensors and the monitor.
Tools used in this projectWe'll list the tools and modules used in this project:
1) Hexabitz 1D LiDAR IR SensorModule (H08R6x):
H08R6x is an infrared (IR) time-of-flight (ToF) ranging sensor module [1].
2) Hexabitz Load Cell SensorModule (H26R0x):
H26R0x is a load cell (strain gauge) sensor interface module [2].
3) M2/M2.5 Mounting Hole Module (T00R1x):
T00R1x is a triangle mounting hole module that supports M2 and M2.5 screw sizes [3].
4) User Tools Kit:
This kit includes the tools that are essential for programming, debugging, and powering Hexabitz modules.
- FTDI USB to UART Serial cable:
The 4-pin USB 2.0 to UART serial cable is an indispensable tool for Hexabitz development! It incorporates FTDI’s USB to UART interface [4].
- Hexabitz BitzClamp:
Hexabitz BitzClamp is a modified Kelvin current clamp soldered to two 2.56 mm-pitch male jumper wires [5].
- STLINK-V3MODS Programmer (H40Rx):
H40Rx is a programmer module which contains STLINK-V3MODS stand-alone debugging and programming mini probe for STM32 microcontrollers (Hexabitz modules and other MCUs) [6].
- E-Z-Hook Programming Kit:
Instead of soldering SMD connectors there, you could use a nice off-the-shelf E-Z-Hook kit that we assembled for you [7].
5) SEWHACNM Single Point Load Cell (AB120-30kgf):
A Korean anodized aluminum load cell with IP65 protection and 30kgf load capacity [8].
We'll mention step-by-step instructions from designing to implementing of the project:
1. Planning the array and assembling the hardware:
First, we prepare the project parts and plan our array design by aligning the five modules side by side. Then we solder the modules together using Hexabitz Fixture.
Let's sketch our block diagram for the project:
- The input unit: represents the sensors provided by the Hexabitz platform (H08R6x, H26R0x) that send the height and weight variables and receive commands from the monitor interface of the (H40Rx) programmer to start or stop the acquisition of their values and select the units of the sensors.
- The processing unit: represents the STLINK-V3MODS (H40Rx) programming module, which allows processing and monitoring of the project through a real-time interface.
- The output unit: represents the STM32CubeMonitor interface that starts/stops the entire project and allows us to monitor the desired values on a graphical and numerical display, as well as retrieve the values in any desired unit.
2. Writing codes with STM32CubeIDE software:
Let's first create the topology for the two modules (H08R6x, H26R0x) and set their configurations, then add the same topology for both modules. See this link for help in creating a topology file.
#define __N 2 // Number of array modules
// Array modules
#define _mod1 1<<3
#define _mod2 2<<3
// Topology
static uint16_t array[__N ][7] ={
{_H08R6, 0, 0, 0, _mod2 | P4, 0, 0}, // Module 1
{_H26R0, 0, 0, 0, _mod1 | P4, 0, 0}, // Module 2
};
// Configurations for duplex serial ports
#if ( _module == 1 )
#define H08R6 1
#define _P1pol_normal 1
#define _P2pol_normal 1
#define _P3pol_normal 1
#define _P4pol_normal 1
#define _P5pol_normal 1
#define _P6pol_normal 1
#endif
#if ( _module == 2 )
#define H26R0 1
#define _P1pol_normal 1
#define _P2pol_normal 1
#define _P3pol_normal 1
#define _P4pol_reversed 1
#define _P5pol_normal 1
#define _P6pol_normal 1
#endif
Now, let's enable the topology by uncommenting its #include directive in project.h.
#include "topology.h"
- H08R6x Firmware main.c code:
In this module, the distances representing the height of the newborn are measured continuously and activated by a "start" button from outside the file via a monitor interface.
First, we define these variables:
float childHeight;
volatile uint8_t start;
childHeight represents the distance variable to be measured, and start represents the variable that will activate the module through the monitor's interface.
Second, inside the userTask function, we write our code:
void UserTask(void *argument){
AddBOSvar(FMT_FLOAT, (uint32_t) &childHeight);
AddBOSvar(FMT_UINT8, (uint32_t) &start);
SetRangeUnit(UNIT_MEASUREMENT_MM);
// put your code here, to run repeatedly.
while(1){
if(start == 1)
{
childHeight=Sample_ToF();
WriteRemote(2, (uint32_t) &childHeight, 1, FMT_FLOAT, 100);
IND_ON();
Delay_ms(20);
IND_OFF();
}
else if(start == 2)
{
SetRangeUnit(UNIT_MEASUREMENT_MM);
}
else if(start == 3)
{
SetRangeUnit(UNIT_MEASUREMENT_CM);
}
else if(start == 4)
{
SetRangeUnit(UNIT_MEASUREMENT_INCH);
}
}
}
We use the following BOS APIs from the Hexabitz BOS factsheet to link BOS variables and enable the LED indicator for each measurement process:
To perform continuous sample measurements in mm, we used the following API from the H08R6 factsheet:
To specify the unit for the range output (mm, cm, inch), we define it in mm at the beginning and then insert it in a loop that is changed as soon as we select the desired unit from the dropdown interface of the monitor.
- H26R0x Firmware main.c code:
In this module, the weights representing the newborn's weight are measured continuously and activated by a "start" button from outside the file via a monitor interface.
First, we redefine the variable childHeight as a volatile variable so that we can read its value from this firmware and monitor it simultaneously as we take weights:
volatile float childHeight;
Then we define these variables and function:
void monitor(void);
float childWeight;
uint8_t flag;
uint8_t start;
childWeight represents the weight variable to be measured, and start represents the variable that will activate the module through the monitor's interface.
Second, inside the userTask function, we write our code:
void UserTask(void *argument){
AddBOSvar(FMT_FLOAT, (uint32_t) &childHeight);
AddBOSvar(FMT_UINT8, (uint32_t) &start);
// put your code here, to run repeatedly.
while(1){
if(start == 1 || start == 2 || start == 3 || start == 4)
{
WriteRemote(1, (uint32_t) &start, 2, FMT_UINT8, 100);
}
monitor();
Delay_ms(100);
}
}
AddBOSvar and WriteRemote BOS APIs should be recalled here so that the modules can link the specified variables to each other and to the monitor interface.
monitor( ); function is a special function that will first calibrate the used load cell parameters [8], set HX711 load cell amplifier measurement rate, calibrate the zero-weight value from channel 1 or 2, and get filtered and calibrated channel 1 or 2 weight values:
void monitor(void)
{
if(flag == 1)
{
Calibration(30,1.9242,0.0094);
SetHX711Rate(80);
flag=0;
}
else if(flag == 2)
{
ZeroCal(1);
flag=0;
}
else if(flag == 3)
{
childWeight=SampleGram(1);
}
else if(flag == 4)
{
childWeight=SampleKGram(1);
}
else if(flag == 5)
{
childWeight=SampleOunce(1);
}
else if(flag == 6)
{
childWeight=SamplePound(1);
}
}
Once we have written our codes, we download them for each module using the programmer and then connect the SWD (Serial Wire Debug) interface wires (RCD) to the load cell module (H26R0), which is responsible for collecting all the values and transmitting them to the monitor interface. We should also connect the load cell wires as shown in figure (14).
3. Operating a Monitor Online Interface using STM32CubeMonitor:3
Included in each Hexabitz module firmware is a file for the STM32CubeMonitor software, which gives us the ability to monitor our sensors online by connecting the programmer to this platform via an SWD interface. We used this feature and connected our programmer to start collecting values.
Figure (15) shows the built-in blocks used to achieve this monitoring interface.
We just need to double-click on myProbe_Out to select our connected programmer (Figure 16) and click on the update and done buttons. Finally, if you click DEPLOY and then DASHBOARD, you can use the interface in Figure (17).
We tested the water bottle shown in Figure (18) with a height of 16 cm and a weight of 385 g and compared the results with a household scale, obtaining even better results after commas.
The following video shows the final results of our project, enjoy watching!
Future IdeasIf we add some additional sensors such as temperature, humidity, etc. With a suitable printed case, we can realize an incubator with improved functions.
References[1]: 1D LiDAR IR Sensor (H08R6x) – Hexabitz
[2]: Load Cell Sensor (H26R0x) – Hexabitz
[3]: Mounting Hole (T00R1x) – Hexabitz
[4]: 4-Pin USB-Serial Prototype Cable – Hexabitz
[5]: Hexabitz BitzClamp – Hexabitz
[6]: STLINK-V3MODS Programmer (H40Rx) – Hexabitz
[7]: E-Z-Hook Programming Kit – Hexabitz
[8]: SEWHA CNM
Comments
Please log in or sign up to comment.