top of page

Code

The DATA_ACQUISITION function serves to record the number of oscillations over time (frequency). It does this by incrementing a counter every time the the force value recorded by the LIS3DH goes from less than 0.8g to greater than 0.8g. The program increments 10 periods of oscillation before calculating the frequency. Since the system timer (sys_ticks) is set to zero until the counter is above zero, the count is reduced by 1 before dividing by the time (in milliseconds divided by 1000 for to get seconds) it takes to complete the 10 periods. The program is set to do this 3 times. The program stops after the 3rd time because, after testing, this was found to be the most accurate and consistent frequency value. 

Code Flowchart.JPG
PWM inits.JPG
code for data.JPG
Collect_Display.JPG
Forever Loop.JPG
motor control.JPG

© 2023 by Name of Site. Proudly created with Wix.com

bottom of page