## 2 Methods
### Angle Measuring Using the Wireless Electronic Component  
The accuracy of the wireless electronic system is fundamentally influenced by the noise characteristics of its inertial sensors. To validate the claimed angular measurement error of \(\pm 1^{\circ}\), a calibrated digital protractor was used as a reference instrument. The knee joint was manually positioned at known angles, such as \(30^{\circ}\), \(45^{\circ}\), \(60^{\circ}\), and \(90^{\circ}\), and the correspondingreadings from the wireless system were recorded in parallel. The comparison between the digital protractor and the inertial module outputs revealed a maximum deviation of less than \(1^{\circ}\), confirming the system's angular accuracy under controlled conditions. This result supports the suitability of the wireless module for precise joint angle tracking in clinical gait monitoring applications. The calibration of the sensors is important to minimize offsets. Therefore, the sensors must be calibrated and configured on-site through the base station. A sampling period of 33 milliseconds was used, which is enough to capture the desired knee movement. The sensor node generates a packet with three samples at each superframe, which is configured for 100 milliseconds. The base station uses an RS232 serial port to communicate with the PC. The data is further processed by the PC using Matlab v24.1. The accelerometer and magnetometer readings are converted into angles (e.g., pitch, roll, and yaw) using a pre-compiled algorithm. Due to the inclination of the magnetic pole relative to the earth's surface, the magnetometer readings are previously compensated in order to extract only the horizontal components (\(X_{h}\),\(Y_{h}\)), so an angle can be produced in the azimuth plane. Furthermore, since any acceleration apart from gravity induces errors in angle measurements, a compensation algorithm is applied to the inertial sensors in order to minimize errors due to accelerations during the motion of the body. When accelerometer calibration takes place, the gravity values are obtained for each axis. These values are used to normalize readings, producing outputs in the range of \(-1\) to \(1\) (as in 'g' forces) when no external force besides gravity is present. When a measurement is collected, the acceleration vector is normalized, and its module must be equal to \(1\) (within a certain minimum threshold in the order of 10-3) when gravity is the only force being applied. When the acceleration module is not equal to unity, the measurement contains acceleration besides gravity. Since the magnetic sensor does not depend on the acceleration of the body, it is used to compensate the acceleration measurement when this happens. The values from the previous and current magnetic readings are used to compute the angle and axis of rotation that occurred during two consecutive readings. The axis and angle are then used to rotate the previous gravity vector to the new orientation that is being described in current measurements. This method allows for the separation of the gravity force from other accelerations present in the acceleration measurement by simply subtracting the gravity component from the original acceleration reading. Pitch, roll, and yaw angles are computed using the gravity part of the acceleration vector. The axis and angle of rotation are obtained using Equations (3) and (4):  
\[angle=\arccos\left(\left\|\stackrel{{\rightarrow}}{{M}}_{n-1} \right\|\centerdot\left\|\stackrel{{\rightarrow}}{{M}}_{n} \right\|\right) \tag{3}\]  
\[axis=\left\|\stackrel{{\rightarrow}}{{M}}_{n-1}\right\|\times \left\|\stackrel{{\rightarrow}}{{M}}_{n}\right\| \tag{4}\]  
Equation (3) uses the dot product of the normalized vectors to obtain the smallest angle between the previous and current magnetic vectors. In Equation (4), the cross product between the previous and current normalized magnetic vectors produces the rotation vector, by which the previous gravity vector (the acceleration vector without any force besides gravity) is rotated.