The objective with the sensor is to calculate the Euler angles with the gyroscope and accelerometer. The angle can be easily found by integrating the gyroscope values, however, this causes gyroscope drift over time and will lead to incorrect angle readings. To mitigate this, we also use the accelerometer readings to correct the angle drift. Typically, the three Euler angles can be calculated with the fused data; the gyroscope gives angle position data in all three axes, the accelerometer gives angle position data in pitch and roll, and the magnetometer gives angle position data in yaw. Since we only have an accelerometer and gyroscope, we can only account for the angle drift in the pitch and roll angles.
Relevant Variables
#define SOP '<'#define EOP '>'bool started = false;bool ended = false;char inData[80];byte index;char delimiters[] = ",";char* valPosition;float angle[] = {0.00, 0.00};The Bluetooth communication between the two devices is at 115200 baud rate. The Serial.read function used to read the code can only read 1 byte at a time from the serial monitor. Since the readings we are sending are several digits long, we have to store the values in a character array using a while loop. Once the character array is determined for one loop, the array is tokenized and the values are split based on a delimiter. The split values can then be assigned to variables and converted to a float variable using the "atof" function. The code can be found in the Design Output section.
This table shows the risky angles associated with a total hip replacement. The values were given to us by our clinical advisor Dr. Schmidt and are based on literary research and personal experience.