3. Purpose
• To inspire the students of a local Martial Arts school
with a robust, inexpensive punch sensor.
– Thank you Aleksey for the idea! Check out his DIY project
blog here: https://abieneman.wordpress.com/2010/04/
9. A/D Converter: MCP3002
• 10-Bit resolution
• Dual Channel
• On-chip sample and hold
• SPI serial interface
• Low Power
• 200 ksps max sampling rate (VDD=5V)
Justification:
- An increased sampling rate is needed to capture impact events;
Arduino’s built-in ADC does not meet the requirements.
- Aleksey uses a 16-Bit ADC, but given the limited LED display digits, the
extra precision is not necessary. Plus the 16-Bit ADC is more expensive.
Fig. 2 A/D Converter.
10. Arduino Uno: ATmega328P MCU
Arduino Uno’s Job:
1. Read accelerometer data from the ADC via SPI interface (D10-D13).
2. Watch for impact events: absolute accelerations greater than 10g.
3. Send the max acceleration from each impact event to the LED display.
i. Digit control (D2-D5); to LED
ii. Segment control (D6-D7); to Shift register
To LED
To Shift
Register
SPI with
ADC
Fig. 3 Arduino Uno.
11. Shift Register: SN74HC594
• 8-Bit Serial-In, Parallel-Out Shift Register with Storage.
• Shift Register’s Job:
1. Receive the 8-Bit segment data from the MCU.
2. Transmit the 8-Bit segment data, one bit at a time, to the segment pins on
the LED display.
To
LED
From
Uno
Fig. 4 Shift Register.
12. LED Display
• 7 segment LED display
• The number displayed is the absolute max
acceleration from a given impact event.
• The MCU dictates the number to display:
– sets DIG.X pins to HIGH
– sets segment pins A-G to LOW via shift register
Current Limiting the LED Display
• A 16-Bit interrupt timer limits the duration that the LED display stays ON.
• How it works:
- The MCU has a 16MHz clock (16 million ticks per second) with a 16-Bit timer
that counts up to 216 ticks (65536 ticks).
- An overflow interrupt occurs when the timer exceeds 216 ticks; when this
happens (every 4ms) the LED display turns ON to display a number.
- A compare interrupt occurs when the timer matches 10,000 ticks; when this
happens (0.6ms after an overflow interrupt) the LED display turns OFF.
Fig. 5 LED Display.
13. Modifications
The use of the 10-Bit ADC (MCP3002) instead of Aleksey’s 16-Bit ADC demanded
two critical changes to the Arduino Script (C++):
Arduino Script Modification #1:
The 16-Bit ADC has better resolution than the 10-Bit ADC:
• 16-Bit:
acceleration (g) = ((ADReading- 215) / 216)*5 volts/ 0.008 (volts/g)
(1/ 216 )*5 volts / 0.008 (volts/g) = 0.0095 g resolution
• 10-Bit:
acceleration (g) = ((ADReading- 29) / 210)*5 volts/ 0.008 (volts/g)
(1/ 210 )*5 volts / 0.008 (volts/g) = 0.61 g resolution
Hence, the acceleration calculation must be modified for the 10-Bit ADC:
where acc =(ADReading-29) and 0.61 g is the resolution.
14. Arduino Script Modification #2:
MCP3002 is a configurable, dual channel ADC. Therefore, 8-Bit data must be sent
to the ADC’s Din pin to dictate how data is read and transmitted. For example:
0 1 1 0 1 0 0 0
This byte configures the ADC to read analog data from channel 0 and to transmit
digital data to the MCU one bit at a time with the most significant bit first. Note
that this byte corresponds to the decimal number 104; hence the following code
is used to transmit and store a 10-Bit accelerometer reading:
Don’t Care
Modifications
15. How it works: The MCU gets 30kHz-sampled data from the ADC and stores each value
as reading. Then the following variables are updated:
I. atRestJit: set true if reading is inside ±10g.
II. atRest: set true if reading has been within ±10g for 0.5 seconds
III. maxReading , minReading: the max, min readings from a given impact event.
• Impact events are recognized when the sensor is disturbed from steady state, the
state when atRest and atRestJit are both true.
• When a new impact event occurs, the old maxReading, minReading values are reset
so that new maxReading, minReading values can be stored.
• The MCU sends max(|maxReading|,|minReading|) to the LED display upon an
overflow interrupt.
Functionality
The following variables (i) identify impact events and (ii) store the absolute max
accelerations from impact events for display: