In this part I will describe the hardware side of the Punch Acceleration Sensor and the next part will be about the software.
You can download Eagle schematics and printouts here
Here’s the basic hardware schematic (click for pdf version):
These schematics use SparkFun Eagle Library for the Arduino board so the pins shown are for the Arduino board and not ATmega328. You can see how those pins correspond to ATmega328 pins by downloading schematics from Arduino Duemilanove specs page.
ADXL193 sensor comes only in a surface mounted package but fortunately SparkFun sells it already soldered on a breakout board with decoupling capacitor. The sensor has 4 pins: Gnd, Vcc, Vout and ST. The ST signal is the self-test feature and when set to logic HIGH will apply electrostatic field on the movable frame within the chip and causes Vout to change to indicate acceleration.
The ADXL193 is connected to the main unit using pair of 4 pin right angle connectors (Tyco Electronics 640457-4), connector receptacle housing (Tyco Electronics 1375820-4), connector contacts (Tyco Electronics 1375819-1), and a flat under-carpet phone cable (don’t have the model number, bought at Home Depot)
AD7680 16 bit A/D Converter also comes only in SMD package, so i had to purchase a breakout board and solder it myself (Capital Advanced Technologies 33108). The AD7680 has standard Vdd, Gnd pins, Vin for input voltage and following SPI interface pins: CS(neg), SDATA, SCLK. ATmega328 supports SPI interface on SCK (PB5), MISO (PB4), MOSI (PB3), SS (PB2) pins, which correspond to 13,12,11, and 10 pins of the Arduino board. Therefore, CS of AD7680 is connected to pin 10 of Arduino board, SDATA to 12, and CS to 10.
SN74HC594 8 bit Shift Register. As I mentioned in the first part of this post, ATMega328P did not have enough digital pins to drive all of the 7 segment LED and even through i could probably use some of the analog pins i wanted to experiment with shift register so i went that route. The reason shift register help save up pins is that it only needs 2 pins to program it and it outputs 8 lines of data. You can stack them in series and output as many lines as you would like. There are also input versions of this chip, so you can use it to read multiple lines of data as well. Now it takes 2 pin for the most simplistic design (which i took): one pin for clock and another for data. The disadvantage of this method is that while you are shifting data out the output values of the register are unstable – 1st bit of data travels through all 8 outputs until it arrives at it’s place. SN74HC594 has a solution to that in the way of storage registers and RCLK pin. The way it works is that SN74HC594 actually has 16 1bit registers: 8 data and 8 storage. When you shift data out it is stored in data registers while output is read from storage registers. So if you keep RCLK pin unchanged when you are shifting out the data and when it’s all done toggle RCLK from low to high SN74HC594 will output old data until that upward edge and at that point move data from data to storage registers and start outputting new data. There are even more advanced types of these chips called I/O Expanders (example Microchip MCP23018-E/SP). In these chips, each pin can be independently configured as either input or output and you can set triggers to be fired when input data changes. For the purpose of this project a simple register with SCLK and RCLK tied together was sufficient.
7 segment 4 digit LEDis a generic 7 segment led from SparkFun. In order to control the LED you set one of the digit selection pins to HIGH and pins corresponding to the segments of that digit that you want to be turned on to LOW. This coding scheme allows only one digit to be “on” at the time so micro-controller has to rapidly switch between digits to maintain illusion that all of them are lit. As with all LEDs controlling current is important as too little current will make it too dim and too much (more than 20mA) will burn it out. The recommended practice is to put 330 Om resistor in series with LED, however an alternative solution is to limit amount of time LED current is on. This project implements the latter solution, so no resistors are necessary.
Miscellaneous Components. A 250 mA thermistor (Tyco Electronics RXEF025) is placed in series with power supply for circuit protection. A 100 uF (micro farad) capacitor is placed in supply/ground rails, 10 uF and 0.1 uF capacitors are placed in parallel on the Vdd and Gnd of AD7680 A/D converter as recommended by AD7680 spec sheet.
Putting it all together
Putting initial circuit prototype was very easy and fast thanks to the solder-less breadboard and jumper wires:
The problem with prototype was that the jumper wires didn’t hold all that great and were constantly flying out of the board. So the next step was to build something soldered down. I have considered available solutions and there was much to choose from: single or dual copper clad, not copper clad, pre-drilled, pre-etched, high quality from pcb house, etc… I thought I would try my luck with single side pre-drilled but not etched board i found on DigiKey. The idea is to lay out components in the most compact way and cut groves between the pads on the copper side. I have also attempted to use the existing copper for some of the connections as well:
the rest of the connections were made using 30 AWG wires. I have attempted to run those wires through the top of the board at first but found it too time consuming. In retrospect a faster way would be to just make sure every pin of a iC component has a connected empty pad next to it and wire everything with bottom side wires and not to worry about making connections using copper – it took to much time to lay those paths out and in the end i could not route that many of them anyway – soldering wire is faster. The groves between the pads were cut using Dremel and an engraving attachment.
I hope you have found this useful. If you have any questions please feel free to comment or shoot me an email.
Update – Errata:
Thank you Mark Z. for finding these:
- Schematic diagram has incorrect labels on AD7680. It should be as follows: 5 – CLK, 7 – DATA, 8 – CS. Pin 6 should be pin 7. Wiring diagram and code are correct.
- Schematic diagram is missing power and ground connections to shift register: GND pin 8 and VCC to pin 16. Wiring diagram is correct