Call/WhatsApp/Text: +44 20 3289 5183

Question: Building a Step Counter(C++ and ARM assembly)

22 May 2024,5:59 AM

You will have to use C++ and assembly to complete this project and you will use the knowledge of the micro:bit CoDAL APIs.

Task 1: Accelerometer measurement

For this first task, you are expected to use the built-in micro:bit accelerometer, accessible by the CoDAL runtime accelerometer class and collect measurements. You must develop code that handles new accelerometer measurements and prints a message of “UP”, when the direction of movement changes from down to up (i.e., acceleration on the y axis changes from negative to positive) and “DOWN” when the direction of acceleration changes from UP to DOWN (i.e., acceleration on the y axis changes from positive to negative). Your solution should process raw accelerometer data and you should not use the built-in gesture API of the accelerometer class.

Task 2: Counting steps

For the second task, you are expected to implement an algorithm for counting steps. The accelerometer returns as measurement the acceleration on each axis in mG (1G = 1000 mG). Your algorithm should count a step as a consecutive up to down or down to up movement in the Y-axis. To reduce the sensitivity of the detection mechanism, you should record the movement only when the acceleration is more than 200 mG. For example, a movement that goes from UP to DOWN will count as one step. If the next measurement registers an UP movement, then this will count as a second step. For each step you should increment a global step counter variable, so that your micro:bit can keep track of the number of steps.

 

Task 3: Raw Data Logging

For this third task you are expected to develop functionality to improve the interaction with your step counter. Firstly, you are expected to use the CoDAL API to display the number of steps that the user has taken since the last boot of the system on the LED display. A user should be able to access this information by pressing button A on the micro:bit board. Secondly, we expect you to implement a logging functionality, which stores raw accelerometer data (Y-axis acceleration measurements when an UP or DOWN movement is detected). Specifically, in each movement you code should store in memory the current and the previous measured acceleration on the Y-axis. You code should store data only for the last 30 UP or DOWN movements. To realize this logging functionality, you can use you own data structure and an array or a doubly linked list to store data for the 30 most recent movements. If you already store data for the last 30 measurements, then your code should discard the oldest measurement, before adding a new one. Additionally, your code should log this data into the micro:bit MYDATA.html file when pressing button B. The logging API of the CoDAL platform can help you in this functionality

 

Task 4: Improve step counting and displaying information

As you might have noticed so far, our simple step counter is far from perfect, and it is prone over records steps. For this last task, you must implement a better step detection algorithm. During a step, the accelerometer will record multiple accelerometer readings (the CPU is fast enough to fetch and process multiple accelerometer readings/sec) and a step will record acceleration changes in all three dimensions. As a result, your code should be able to associate many micro-movements and maintain some memory to avoid double counting steps. One possible algorithm can be the following:

• Firstly, your code should analyse acceleration data on all three dimensions and detect direction changes (change of acceleration from positive to negative, or vice-versa). In addition, a step is expected to generate acceleration greater than 400 mG. When these two conditions are true, the measurement should be classed as a micro-movement.

• Secondly, in order to record a step, you should receive four accelerometer measurements that meet the micro-movement criteria.

• Once you detect a step, you should allow a cooldown period, until a next step is recorded. The cooldown period should vary depending on the type of steps. If no micro-movements are detected in the next 10 measurements, then you should reset the step counter. This would reflect a slow mild walk. If though, you continue recording micro-movements, then your code should ignore the next 20 micro movement, as these micro-movement are part of the same step. This would reflect an intensive fast passed walk.

• Once the cooldown has elapsed, you should reset the step counter state and start measuring movement for the next step

Expert answer

This Question Hasn’t Been Answered Yet! Do You Want an Accurate, Detailed, and Original Model Answer for This Question?

 

Ask an expert

 

Stuck Looking For A Model Original Answer To This Or Any Other
Question?


Related Questions

What Clients Say About Us

WhatsApp us