Dimiter Kendri
Published © GPL3+

Gym Trainer

Use Hexiwear as your personal gym trainer.

IntermediateFull instructions provided15 hours629
Gym Trainer

Things used in this project

Hardware components

Hexiwear
NXP Hexiwear
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

GymBuddy.step

Schematics

Hexi.jpg

Code

IMU data for matlab analysis

C/C++
Open a terminal and save the data. Then import it on Matlab or Octave.
#include "mbed.h"
#include "FXOS8700.h"
#include "FXAS21002.h"
#include "kalman.h"

DigitalOut led1(LED_GREEN);

// Initialize Serial port
Serial pc(USBTX, USBRX);

// Pin connections & address for Hexiwear
FXOS8700    accel(PTC11, PTC10);
FXOS8700    mag(PTC11, PTC10);
FXAS21002   gyro(PTC11,PTC10);

int main() {
    
    // Configure Accelerometer FXOS8700, Magnetometer FXOS8700
    accel.accel_config();
    mag.mag_config();
    gyro.gyro_config();
    
    float accel_data[3]; float accel_rms=0.0;
    float mag_data[3];   float mag_rms=0.0;
    float gyro_data[3];  float gyro_rms=0.0;

    wait(1);

    pc.printf("Begin Data Acquisition from FXOS8700CQ sensor....\r\n\r\n");
    pc.printf("Accelerometer \t Magnetometer \t Gyroscope");

    wait(1);
    
    while (1) {
      led1 = !led1;
      // Example data printing
      
      accel.acquire_accel_data_g(accel_data);
      accel_rms = sqrt(((accel_data[0]*accel_data[0])+(accel_data[1]*accel_data[1])+(accel_data[2]*accel_data[2]))/3);
      mag.acquire_mag_data_uT(mag_data);
      mag_rms = sqrt(((mag_data[0]*mag_data[0])+(mag_data[1]*mag_data[1])+(mag_data[2]*mag_data[2]))/3);
      gyro.acquire_gyro_data_dps(gyro_data);
      gyro_rms = sqrt(((gyro_data[0]*gyro_data[0])+(gyro_data[1]*gyro_data[1])+(gyro_data[2]*gyro_data[2]))/3);


     pc.printf("%4.2f %4.2f %4.2f %4.2f \t%4.2f %4.2f %4.2f %4.2f  \t%4.2f %4.2f %4.2f %4.2f \n",accel_data[0],accel_data[1],accel_data[2],accel_rms,
                                                                                               mag_data[0],mag_data[1],mag_data[2],mag_rms,
                                                                                               gyro_data[0],gyro_data[1],gyro_data[2], gyro_rms);
                                                                                               
                                                                                               
                                                                                               
                                                                                        

      wait(0.01);
      
        Thread::wait(50);
    }
}

Credits

Dimiter Kendri

Dimiter Kendri

23 projects • 159 followers
Robotics and AI

Comments