Skip to main content

Subsection 12.5.6 Part 7: Plot It

Numbers scrolling by are hard to read as motion; a chart shows the shape of what is happening instead. A few changes turn accel_test.c into a data source CoolTerm can plot: comment out all the printf() statements, print the three values as one comma-separated line inside the while(1) loop instead, and shorten the delay.
printf("%d,%d,%d\n\r", accel_x, accel_y, accel_z);
delay_ms(100);      // or less
In CoolTerm, connect as usual. Then, in the View menu, select View Chart (Figure 12.5.19). Each comma-separated value becomes one trace.
Figure 12.5.19. CoolTerm’s View menu: View Plain, View Hex, and View Chart (circled). With the program printing comma-separated values, View Chart plots each value as its own trace.

Activity 12.5.7. Make the chart move.

For each experiment, predict what the three traces will do before you move the board.

(c)

Shake the board. Then set it on the table and bang the table: that is what a shock looks like.

(d)

If you finish early: re-derive CTRL_REG1_A and CTRL_REG4_A for low-power mode, and then for high-resolution mode, rebuild, and watch what happens to the step size in the chart.
Figure 12.5.20. Three axes of acceleration in CoolTerm’s chart view. The steady levels are gravity’s projection on each axis; the steps are the board being turned; the burst about two-thirds of the way across is shaking, and the flat traces after it are the board back at rest.