element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Design For A Cause 2021
  • Challenges & Projects
  • Design Challenges
  • Design For A Cause 2021
  • More
  • Cancel
Design For A Cause 2021
Blog Trakcore #8 Refining User Experience AKA Bugs Fix
  • Blog
  • Forum
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
Author: vlasov01
Date Created: 4 Jun 2021 2:43 AM
Views: 213
Likes: 1
Comments: 0
  • imu
  • demo
  • bug
  • arduino nano 33 iot
  • design_for_a_cause_2021
Related
Recommended

Trakcore #8 Refining User Experience AKA Bugs Fix

vlasov01
vlasov01
4 Jun 2021

Design for A Cause 2021Trakcore #1 AI Assisted Posture Modification - Project Introduction

#1 - Project Introduction

#2 - Acquiring Data and Designing a Model

#3 - Deploying and Testing Edge Impulse ML Model on Arduino Nano 33 IoT

#4 - Enabling IMU and BLE with Edge Impulse ML on Arduino Nano 33 IoT

#5 - Using Cordova Bluetooth (BLE) Plugin to Connect Arduino Nano 33 IoT with Android Phone

#6 - Arduino Nano 33 IoT Wearable Design

#7 - Adding Pedometer to Reduce False Positives

#8 - Refining User Experience AKA Bugs Fix

 

Bug

I've added pedometer capability to my project in the previous blog post. And to add this feature I've switched IMU library to one provided by Sparkfun, which is exposing the pedometer function of IMU. Even these libraries were built for the same chip, they have a bit different APIs. So I've done migration to Sparkfun API.

 

#ifdef __LSM6DS3IMU_H__
    buffer[ix + 1] = myIMU.readFloatAccelX();
    buffer[ix] = myIMU.readFloatAccelY();
    buffer[ix + 2] = myIMU.readFloatAccelZ();
#endif

#ifdef  _ARUDINO_LSM6DS3_H_  // if define Arduino_LSM6DS3.h
    IMU.readAcceleration(buffer[ix + 1], buffer[ix], buffer[ix + 2]);
    //IMU.readAcceleration(buffer[ix], buffer[ix + 1], buffer[ix + 2]); not adjusted to orientation
#endif
buffer[ix + 0] *= CONVERT_G_TO_MS2;
buffer[ix + 1] *= CONVERT_G_TO_MS2;
buffer[ix + 2] *= -CONVERT_G_TO_MS2;

 

But than I discovered that behavior of my posture tracker become quite different. It basically didn't like any of my postures and classified them as a bad posture. As the code was quite trivial, I've start thinking why the results so different. May be API enumerates axis differently? Or may be it is converting values?

I've compared values and realized that Sparkfun provides converted values. So I move conversion code in a section specific to Arduino library.

 

Fix #1

#ifdef __LSM6DS3IMU_H__
    buffer[ix + 1] = myIMU.readFloatAccelX();
    buffer[ix] = myIMU.readFloatAccelY();
    buffer[ix + 2] = myIMU.readFloatAccelZ();
#endif

#ifdef  _ARUDINO_LSM6DS3_H_  // if define Arduino_LSM6DS3.h
    IMU.readAcceleration(buffer[ix + 1], buffer[ix], buffer[ix + 2]);
    //IMU.readAcceleration(buffer[ix], buffer[ix + 1], buffer[ix + 2]); not adjusted to orientation
    buffer[ix + 0] *= CONVERT_G_TO_MS2;
    buffer[ix + 1] *= CONVERT_G_TO_MS2;
    buffer[ix + 2] *= -CONVERT_G_TO_MS2;
#endif

 

But it didn't help. So I've start thinking about rebuilding the model. I was not really like this idea as the model built from a phone sensor was working fine with the Arduino library and should still work well with another library for the same chip. As result I've switched to other activities like reading Cryptonomicon by Neal Stephenson, which is more than 900 pages long.

 

Fix #2

After a week of procrastination and after finishing the book I decided to look at my code again. And I was able to fix it relatively fast. I've realized that I've missed one transformation. on line 4. Just by adding a minuart working as expected. And i realized that this bug was a side effect of my fix #1.

#ifdef __LSM6DS3IMU_H__
    buffer[ix + 1] = myIMU.readFloatAccelX();
    buffer[ix] = myIMU.readFloatAccelY();
    buffer[ix + 2] = -myIMU.readFloatAccelZ();
#endif

#ifdef  _ARUDINO_LSM6DS3_H_  // if define Arduino_LSM6DS3.h
    IMU.readAcceleration(buffer[ix + 1], buffer[ix], buffer[ix + 2]);
    //IMU.readAcceleration(buffer[ix], buffer[ix + 1], buffer[ix + 2]); not adjusted to orientation
    buffer[ix + 0] *= CONVERT_G_TO_MS2;
    buffer[ix + 1] *= CONVERT_G_TO_MS2;
    buffer[ix + 2] *= -CONVERT_G_TO_MS2;
#endif

 

Demo

Now I can use it again. So I was able to capture a short demo of my wearable device. On the video initially I have a bad posture. It  can be observed by looking at light from a yellow LED on MCU, some vibration and a red message on the phone. Than I change my posture (at 7th second) and the LED gets switched off  (at 9th second) and the red alert disappears on the phone at the same time.

You don't have permission to edit metadata of this video.
Edit media
x
Upload Preview

 

Thank you for reading my project blog post!

Anonymous
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube