# A Prototype Mechatronic Device for Upper Limb Rehabilitation and Analysis of Its Functionality
## 3 Concept and Design Solution for the Rehabilitation Device
### Characteristics of the Electronic System  
The core of the electronic system integrated into the upper limb rehabilitation prototype is a Raspberry Pi 4B (8 GB RAM) microcomputer (Cambridge, UK), operating in a Linux environment. The microcontroller provides a comprehensive suite of interfaces, including numerous digital I/O ports, a quadrature encoder input, and multiple communication protocols: Ethernet, Wi-Fi, 2\(\times\) USB 3.0, 2\(\times\) USB 2.0, microSD, Bluetooth, 2\(\times\) micro HDMI, a 40-pin GPIO connector, and interfaces for DSI, CSI, SPI, I2C, and UART communication. Key hardware specifications include  
* System-on-Chip: Broadcom 2711;
* Processor: Quad-core ARM Cortex-A72, 1.5 GHz;
* Memory: 8 GB LPDDR4 SDRAM;
* Graphics: Broadcom VideoCore VI. The Raspberry Pi is enclosed in a protective casing with accessible ports (Figure 11a). Figure 11: Main components of the device control system: (**a**) microcomputer with enclosure, (**b**) 10.1\({}^{\prime}\) colour touchscreen, (**c**) sensor and its electronic system for object colour identification, (**d**) servo drive controller. Figure 10: Sample overlays for the mechatronic rehabilitation device. For visual communication with the user and rehabilitation staff, a resistive touchscreen was used--a 10.1-inch IPS LCD (1024 \(\times\) 600 px) with HDMI and GPIO connections (Waveshare 11870, Figure 11b). This display facilitates the delivery of commands and selection of tasks. LED indicators are used to provide visual confirmation of an object's placement within the storage compartments. Micro-switches with straight levers (Type WK315, Figure 12) detect the physical presence of an object in a compartment. These switches operate in a monostable manner, automatically returning to their default position once the lever is released. To detect an object's colour, the Adafruit CircuitPython APDS9960 sensor module was implemented (Figure 11c). The presence sensor (labelled \"3\") initiates the activation of the colour sensors (\"1\" and \"2\") once an object is detected in the designated compartment. The sensor module is capable of distinguishing red, green, and blue colours based on 16-bit output signals (ranging from 0 to 65,535), where 0 indicates no detection and 65,535 represents maximum intensity. The APDS9960 module integrates an infrared LED and a control chip with four directional photodiodes, enabling the multi-directional detection of reflected infrared light. It also features built-in UV and IR filters. Initial calibration and validation were conducted using colour-coded test objects, with software used to verify the sensor's responsiveness and accuracy. The complete control system comprises the following: infrared beam-break sensors for object detection; I2C multiplexer (TCA9548A, Adafruit, Lakewood, CO, USA) for managing up to eight digital buses; Mini Maestro USB Servo Controller (Las Vegas, NV, USA) (2-channel, Pololu 1356, Figure 11d); Hitec Servo HS645 MG modules (San Diego, CA, USA) for actuation. Servo motors are controlled via a PC-based interface using a USB, serial communication, and basic scripting commands. A representative control script interface is shown in Figure 13.  
A functional block diagram illustrating the connections between electronic and electromechanical modules is presented in Figure 14. Additionally, buttons (labelled 1-4) were integrated to allow users to indicate the task's completion manually. Depending on the user's capabilities, the appropriate button is pressed to confirm the task's execution. During operation, the touchscreen interface enables calibration, task selection, and interactive control (Figure 15). In calibration mode, users or therapists can specify which limb (left, right, or both) is active, along with the corresponding object containers. The system verifies that compartments are empty and confirms the initial positions of the mechanical arms.