NM500 NeuroShield and MPU6050 IMU Test Example
Dependencies: mbed NeuroShield
Diff: main.cpp
- Revision:
- 2:28290f9caf51
- Parent:
- 1:fb672eb52bd6
--- a/main.cpp Thu Jan 25 02:54:57 2018 +0000 +++ b/main.cpp Tue Feb 11 00:57:21 2020 +0000 @@ -1,9 +1,9 @@ /****************************************************************************** * NM500 NeuroShield Board and mpu6050 imu Test example - * revision 1.1.3, 01/13, 2018 + * revision 1.1.5, 2020/02/11 * Copyright (c) 2017 nepes inc. * - * Please use the NeuroShield library v1.1.3 or later + * Please use the NeuroShield library v1.1.4 or later ******************************************************************************/ #include "mbed.h" @@ -185,13 +185,12 @@ int main() { - int i, input_key[2]; + int input_key[2]; arduino_con = LOW; sdcard_ss = HIGH; wait(0.5); - printf("Start NM500 initialzation...\n"); if (hnn.begin() != 0) { fpga_version = hnn.fpgaVersion(); if ((fpga_version & 0xFF00) == 0x0000) { @@ -203,12 +202,14 @@ else { printf("\n\n#### Unknown Board (Board v%d.0 / FPGA v%d.0) ####\n", ((fpga_version >> 4) & 0x000F), (fpga_version & 0x000F)); } - printf("\nNM500 is initialized!\n"); - printf("There are %d neurons\n", hnn.total_neurons); + printf("\nStart NM500 initialzation...\n"); + printf(" NM500 is initialized!\n"); + printf(" There are %d neurons\n", hnn.total_neurons); } else { - printf(" NM500 is NOT properly connected!!\n"); - printf(" Check the connection and Reboot again!\n"); + printf("\n\nStart NM500 initialzation...\n"); + printf(" NM500 is not connected properly!!\n"); + printf(" Please check the connection and reboot!\n"); while (1); } @@ -220,23 +221,21 @@ mpu.setFullScaleAccelRange(MPU6050_ACCEL_FS_8); // verify connection - for (i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { if (mpu.testConnection()) { - printf(" MPU-6050 connection success\n"); + printf(" MPU-6050 is connected successfully\n"); break; } else if (i == 9) { printf(" MPU-6050 connection failed\n"); - printf(" Check the connection and Reboot again!\n"); + printf(" Please check the connection and reboot!\n"); while (1); } wait(0.1); } // wait for ready - printf(" About to calibrate. Make sure your board is stable and upright\n"); - // start message - printf(" Start calibration, don't touch it until you see a finish message\n"); + printf(" Trying to calibrate. Make sure the board is stable and upright\n"); // reset offsets mpu.setXAccelOffset(0); mpu.setYAccelOffset(0); @@ -246,13 +245,12 @@ mpu.setZGyroOffset(0); mpu6050Calibration(); // end message - printf(" MPU-6050 calibration end!!\n\n"); + printf(" MPU-6050 calibration is complete!!\n\n"); - printf("Move the module vertically or horizontally...\n"); - printf("type 1 + Enter if up <-> down motion\n"); - printf("type 2 + Enter if left <-> right motion\n"); - printf("type 3 + Enter if front <-> back motion\n"); - printf("type 0 + Enter for any other motion\n"); + printf("Move the board horizontally or vertically...\n"); + printf("Type '1' and enter, to learn up <-> down motion\n"); + printf("Type '2' and enter, to learn left <-> right motion\n"); + printf("Type '0' and enter, to learn by category 0\n"); // main loop while (1) { @@ -261,7 +259,7 @@ input_key[1] = pc.getc(); if (input_key[1] == 0x0D) { // enter key learn_cat = input_key[0] - '0'; - if (learn_cat < 4) { + if (learn_cat < 3) { printf("Learning motion category %d\n", learn_cat); for (int i = 0; i < 5; i++) { extractFeatureVector();