π¦ It is clear that the Corona pandemic (COVID-19) has radically impacted - and continues to impact - the industry and its future in all its sectors around the world.
The urgency of reducing the COVID-19 pandemic and the health precautions taken when moving, travelling, meeting and using everyday objects required a rethinking of the use of these objects to reduce contagion.
Therefore, we will build a liquid soap machine that can be placed in the kitchen or bathroom for daily useThis machine works automatically so that it squeezes out the soap without direct contact with the machine to ensure that the infection is not transmitted between people.
With Hexabitz platform, we can easily build this project in a few minutes by soldering a few modules and writing a few lines of code. π»
Steps:π‘First : Planning and tools required.First, planning and tools needed.To be able to pump the soap liquid, we will use a DC water pump motor (operates at 6-12 volts), DC-powered pumps use direct current from motors, batteries or solar energy to move liquids in various ways. This diaphragm pump is the perfect choice for any project where liquid needs to be moved from one place to another. The pump requires a hose that you can cut to fit your needs. The hose provides a good seal and will not leak.
We can use the H18R1x module to control the motor (start, stop, forward and reverse direction, or speed control).H18R1x is a dual H-bridge motor driver module based on L298 and STM32G0 MCU.The H-bridge motor driver module enables motors to be driven in two directions (forward and reverse). With such a module, the motor can be made to rotate, and the polarity of the motorβs power supply can be reversed to change the direction of rotation. If necessary, the motor can also be braked.
To enable us to start the motor remotely without touching the machine, we use the H08R6 module. When we hold our hand over the sensor, the motor is started and soap liquid flows out.
H08R6x is an infrared (IR) time-of-flight (ToF) ranging sensor module based on an ST VL53L0X sensor and an STM32F0 MCU. This sensor is insensitive to surface reflection or changing light conditions and can function as a 1D-LiDAR or gesture recognition interface. It can measure distances up to 2 m accurately.
For programming STM32 microcontrollers (Hexabitz modules and other MCUs), we can use H40Rx, a programming module that includes STLINK-V3MODS for stand-alone debugging and programming.
First, the two modules are soldered together to look like this:
Second, we will install the matrix and connect the pump to the power supply, and make it into 3D shape so that we can use the project in the kitchen or bathroom for daily use.
After we have plugged the two modules together and put them into 3D shape, we will start programming the project.Normally, the first step in programming a project on the Hexabitz platform is to create a topology file.We will number the modules to create a file with a fixed topology and upload the code to the processors so that they can communicate with each other and know their neighbors.We will give the H18R1 module the number 1 and the H08R6 module the number 2After numbering, we enter the fixed topology to create a code and use the STM32CubeIDE software.First, we disable the Include a predefined topology entry in the "project.h" file.
#include "topology.h"
Secondly, we write the fixed file "topology.h"
#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, _mod2 | P2, 0, 0, 0, 0}, //module 1
{_H18R1, 0, _mod1 | P2, 0, 0, 0, 0}, // Modul 2
};
Third,we will configure the serial duplex ports in the sam file "topology.h"
// 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 H18R1 1
#define _P1pol_normal 1
#define _P2pol_reversed 1
#define _P3pol_normal 1
#define _P4pol_normal 1
#define _P5pol_normal 1
#define _P6pol_normal 1
#endif
For more information on how to create a fixed topology, you can always visit:
Make a Pre-built Array Topology File β Hexabitz
Now we can write our main program file (main.c
).
As seen above in the project flowchart, we will first determine whether the hand is present or not, and then decide whether to run the pump.
1-First:To take a sample reading (mm) from TOF sensor, we can use this API in (H08R6) module.
uint32_t distance;
distance = Sample_ToF ( );
But to get the reading sample in (H18R1) module from TOF (H08R6) module, we should use Remote Memory Access.
BOS(Bitz Opreating System) provides a powerful function for read and write access to the remote memory through special messages and APIs. This allows a module to access and modify almost any RAM or flash memory location in another module in the array. This enables powerful synchronization and granular control.
So we will use the AddBOSvar()
API to read a BOS variable of a remote module from the emulated EEPROM:
volatile uint32_t distance2 ;
AddBOSvar( FMT_UINT32, (uint32_t) &distance3);
After adding the distance as a BOS variable, we write the variable to a remote memory location using API WriteRemote():
AddBOSvar(FMT_UINT32, (uint32_t) &distance);
distance = Sample_ToF();
WriteRemote(2, (uint32_t) &distance, 1, FMT_UINT32, 0);
If you want to know how we use this function, you can visit the following website:
We will turn on the LED indicator module (HO8R6) as a user interface.
IND_blink(5);
IND_OFF();
2-Second:Now we will write a program for four (H18R1) modules, step by step:1-Declaring the variables :
volatile uint32_t distance;
bool Enable = 0, Disable = 0 ;
2-Writing the variables (distance) to a remote memory location:
void UserTask(void *argument){
AddBOSvar(FMT_UINT32, (uint32_t) &distance);
}
3-Turning the pump on and off according to the sensor range:
while(1){
Enable = (distance >= 50 && distance<= 150);
if(Enable && Disable){
Turn_ON(forward, MotorA);
Delay_ms(200);
Turn_OFF(MotorA);
Disable = 0;
Delay_ms(500);
}
else if(distance > 150)
{
Disable = 1;
}
}
βIf the sensor value is within the range (the hand is in front of the sensor), we give the enable variable the logical value (1), and if this condition is met, we switch the pump on with APITurn_ON(forward, MotorA)
for a certain time and then off with API Turn_OFF(MotorA);
However, if the value of the sensor value is above the range (no hand), we assign the value (1) to the variable disable until the condition is met again when the sensor detects the value.
For more information on how to write API and Massge, you can always visit:
Module Factsheets β Hexabitz
πFourth: TestingAfter we have written the program and uploaded it to the modules, we can test the project to see if it works properly.Now you can watch the following video and see the final version of the work, enjoy watching :)
References:[1]: Hexabitz β Better prototypes. Faster.
[2]: Wiki β Hexabitz
[3]: Dual H-Bridg Motor Driver (H18R1x)
[4]:1D LiDAR IR Sensor (H08R6x)
[5]: STLINK-V3MODS Programmer (H40Rx) β Hexabitz
[6]: Writing Code with STM32CubeIDE
[7]: Remote Memory Access
[8]: EEPROM Emulation
Comments
Please log in or sign up to comment.