The microcontroller unit acts as an universal device for several experiments and tasks. It is not possible to predict all the functions and features needed in future, so both, the hardware and also the software is modular. The software consists from HAL, the Hardware Abstraction Layer, which isolates all the internal and external peripherals from application, next is the UART Communication Module and the Application Module. Maybe, there will be more in future.
The Application Module contains calls for initialisation all the system and then it is branched into 16 application functions. The function is selected by the DIP switch combination, which is read once after system RESET. Every from the application functions have its own purpose, isolated from others.
Up to now, we have implemented these application functions:
00 - Hand Control Mode
In this mode, there is unlimited loop, when the air pressure is measured in the time interval given by TIME_MARK constant (usually 20 - 100 ms). Data are put on the UART interface in 4digit HEX format. Sending the message is indicated by the yellow LED flash.
When the ADC converter is saturated during measurement, the red LED will
glow until another, not saturated value is get. This acts as a overload
indicator.
Also the FET switches can be toggled, one button is used for the FET switch selection and second for selected FET switch toggling.
01 - Pressure Record Mode
After RESET and initialisation, the green (init ok) and yellow (waiting) LED glows. The program is waiting for the key press to start. When one of the buttons is pressed, the recording loop will begin.
In the loop, the air pressure is measured in the sampling frequency given by the TIME_MARK constant (usually 20 - 100 ms). When the actual sample is different than previous, result is sent onto UART, together with the time mark number. Message format is simple - two decimal long integers on the line, separated by comma character. Sending of the message is indicated by the yellow LED flash.
When the ADC converter is saturated during measurement, the red LED will glow until another, not saturated value is get. This acts as a overload indicator.
During the loop, both buttons can be used for FET output toggle - you can switch on and off the air compressor or draining valve.