Introduction: Combo Blocks
Project by CU Boulder Thinks That Think students:
Michelle Bourgeois, Charles Dietrich, and Ben Link
Imagine having a safe in which the combo is any small object of your choosing. Perhaps it's your favorite coffee mug, or a bat man figurine. This project is based on this idea, using the weight and placement of your "key" object(s) to determine the combination for a safe.
This safe uses an array of force sensors to determine the unique weight distribution of your key object(s). The Arduino is set up to lock and unlock the safe door when objects are placed on the platform, and an LED indicates whether the door is locked (red) or unlocked (green). For this prototype, we used stacks of Alphabet Blocks as our key to open the safe. This project utilizes a laser cutter, some soldering, and a cabinet in which we constructed ourselves, but you could modify any box you wish to use.
Note: There is a variation of this project which uses homemade sensors. You will see additional materials and steps for this variation. These sensors were taken from the "DIY Force Sensitive Resistor" Instructable.
1 box with a door
1 Arduino Uno
1 12x12" 1/4" thick, color acrylic sheet
1 12x12" 1/8" thick, color acrylic sheet (detail work)
2? 12x12" 1/8" thick, clear acrylic sheets
4 small pressure sensors (www.sparkfun.com/products/9673 )
4 1" long, 1/4" diameter dowels (cut from shelving pegs)
1 push button
1 tri-colored LED
4 1 kOhm ? resistors
9V battery and casing
scraps of wood and wood glue (or latch)
hot glue and glue gun
Additional Materials (for homemade sensors):
1 3x4" one-sided copper plated PCB (http://www.jpmsupply.com/servlet/the-196/Copper-Clad-Circuit-Board/Detail )
1/4" thick, conductive foam
Aleene's Original Tacky Glue (http://www.amazon.com/Aleenes-Original-Tacky-Glue-4-oz/dp/B00195OGKA )
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Build the Safe
1. Obtain or build a boxwith a door . We built our own box out of spare shelving and 2.5" screws. Two hinges where attached to the door and the left interior of the box. Each side was then sanded to be smooth and each facing was covered with piping and white caps over the screws. It measures one cubic foot.
2. Attach the locking servo with duct tape or other means.
3. Build a latch that fits the servo lock. We made ours out of small scraps of wood and used wood glue to bond it to the interior of the door.
4. Drill a hole in the top of the box to allow wiring to the servo and light sensor.
Step 2: Build the Sensor Block
Our sensor block was made using a laser cutter to cut pieces of clear acrylic.
Holes allowed the wiring from the Arduino to reach the hole in the safe for the servo.
The pieces were bonded together using an acrylic bond.
The sensor block was bonded to a 12x12" piece of clear acrylic with a square cut out to use as its base.
Step 3: Build the Acrylic Casing
The casing is meant to protect the electronics and to allow observation of the inner workings of the device. It sits on top of the box and fits snugly around the base of the sensor block constructed in the previous step.
This was cut from 1/4" thick clear acrylic and pieced together.
Eight 1.8x1.8" squares of color acrylic were placed around the sensor opening to provide stability and aesthetic appeal. They were attached with double-sided tape.
Step 4: Homemade Pressure Sensors
In the original version of this project we used homemade sensors as seen in the "DIY Force Sensitive Resistor " instructable. Due to variations in the conductivity and the elasticity, it was decided to move to a more conventional sensor. We used some computational solutions to compensate for these variations, but ultimately the amount of time it took for most sensors to recover from being compressed was too long for our purposes, taking anywhere from a couple of minutes for initial recovery to a couple of hours for full recovery.
1. Score the one-sided copper PCB plates into 1" squares. Scoring the plates from both sides with a box cutter helps prevent bending in the layered material of the PCB when breaking apart. Once scored, snap apart the pieces by hand or, for the more difficult ones, a pair of pliers.
2. Cut the conductive foam into matching 1" squares using a razor blade or scissors. We chose a high density foam because it seemed to have a more linear response to applied pressure. However the recovery time was much longer than that of the low density foam.
3. Solder the composite wire to the copper side of each 1" square PCB. We found that using the composite wire was easier to solder to the smooth copper surface than solid wire.
4. Glue the pieces together. Apply tacky glue to two opposite edges of the PCB plate and bind to the foam. Do not apply glue to the whole surface or the conductive link will be broken. Repeat with the other side of the foam and another PCB square.
Note: Unlike the "DIY Force Sensitive Resistor " instructable, we constructed our sensors so that the wire leads came out opposite sides of the sensor. This helped with the functional range of the sensor by separating the two solder bulges so they do not touch each other when the foam is compressed.
5. Attach the 1.8" square platform piece using double-sided tape. This provides a larger surface for applying weight.
After constructing our sensors we ran several tests of its conductivity under compression(see the programming section for more details). One thing we observed at this point was a need to "exercise" the sensor. The first few times the sensor was compressed, the foam provided a larger amount of physical resistance. Once the foam was broken-in, it was much easier to compress, and provided more consistent readings. Secondly, even if the sensor was broken-in, occasionally we would get readings that were completely inconsistent with the pressure being applied. The resistance would go up when it was supposed to go down, or it would read 1/2 its original resistance in one trial and 1/6 in the second trial under the same amount of compression.
To get around this we attempted to count increments of applied force. Since we were using alphabet blocks to test our sensors we tried the approach of detecting changes in the resistance of the sensors, allowing us to count the number of blocks placed on the sensor. This approach looked promising but time did not allow for full exploration of this option and we switched to a conventional pressure sensor.
Step 5: Sensor Installation
For this step, several pieces of acrylic were cut to help focus the weight from each platform on the center of each pressure sensor. Listed are the dimensions of these pieces.
4 1.8x1.8" 3/8" thick color acrylic platforms, with a 0.25x0.25" square cut at its center
4 1.8x1.8" 3/8" thick color acrylic stabilizers, with a 0.25" circle cut at its center
4 1.8x1.8" 1/8" thick color acrylic covers
8 1.0x.25" 1/4" thick color acrylic bars
1. Attach the four pressure sensors to the sensor block using double-sided tape. Avoid taping the actual sensor as it tends to pull the sensor apart after being moved several times. Make sure each sensor is centered in its section of the block.
2. Attach two acrylic support bars around each sensor using double-sided tape.
3. Attach the four acrylic stabilizers using double-sided tape and check that the sensors are centered beneath the holes.
4. Insert the wooden dowels into the square holes and hot glue into place. Make sure the dowel is perpendicular to the platform piece or it will not come down on the center of the sensor.
5. This leaves the sensor platforms with an ugly top, so we finished them off by sanding off the excess glue and attaching the thinner 1/8" thick pieces to the top with double-sided tape. This leaves the platforms with a smooth surface.
6. Finally, each platform, with dowel attached, is inserted into the circular holes of the stabilizer pieces. If the dowel is a tight fit you may have to sand it down a bit. The fit should be loose enough that the dowel drops through the hole under its own weight and tight enough to prevent wobble in the platform. We tried many different setups for distributing the weight onto such a small sensor, but had trouble using any other method getting them to work consistently.
Step 6: Electronics
Wiring the Arduino
- pressure sensors
- MultiColor LED
- MakerShield with Potentiometer and red and green LEDs
- reset button
- light sensor
The Fritzing diagram shows the wiring.
The wiring for the pressure sensors ran to each of the pressure sensor leads, facing the outside of the sensor block. Each pressure sensor was connected with a 1kOhm resistor between the sensor and +5v. Each sensor was connected to a pwm digital port.
The servo wiring ran through the hole to the inside of the sensor block and down through the hole in the top of the safe and to the servo that operated the locking mechanism. The servo was connected to an analog port.
The light sensor wiring ran alongside the servo wiring down into the safe and to the light sensor that was attached to the inside of the safe with tape. The sensor was connected with a 1kOhm resistor between the sensor and +5v. The lightsensor was connected to an analog port.
The reset button wiring ran to an acrylic plug built to seal the hole used for USB access the Arduino when testing. The reset button was connected with a 1kOhm resistor between the sensor and +5v.
The potentiometer to control the error value was part of the MakerShield and connected to an analog port.
The bright RGB Led was connected with 300Ohm resistors to 3 digital ports.
The low-power red and blue leds were part of the MakerShield and connected to digital ports.
Step 7: Programming the Lock
To program the Arduino, we used the Arduino library. We sent debugging information to the serial port. We then read this serial data with Processing, and graphed the data. The source code is available on github .
First, we created some simple debugging code to help us set up our sensors. Making sure your sensor readings change when placing objects on them is necessary, as many small mistakes in wiring or setup can prevent a small sensor from reading any values at all. We used this debug code to graph our sensor readings and then decide which pressure sensor type we should use. We discovered that the homemade sensors did significantly worse in consistently reading weight changes.
In the Arduino code, we set the combo in setup. In the loop function, we set the values as the current values of the sensors. If the door is unlocked, we set the combo to the values. We then compare the combo to the current values using a comparison function. We found that root mean square error (RMSE) worked well (wikipedia ). To do this, we took the absolute value of the difference between the combo for scale i and the value for scale i (e..g abs(combo[i]-value[i]) and divided by the combo for scale i. We squared and summed these errors and then took the square root of the sum. RMSE does a very good job at increasing large errors and decreasing the effect of small errors. Objects being placed and removed from ours sensors make large changes in our error making RMSE ideal. Small errors due to different humidities, and various other environmental effects are also minimized when using RMSE.
We compared this error to the value of the potentiometer knob that controlled the maximum error. If the error was consistently less for half a second, we unlocked the door using the servo. The small LEDs indicated that the current error was less than the max, and the bright LED indicated that the door was locked or unlocked.
The Processing graph was used to observe the current values for variables in the Arduino code. We used a simple protocol to send messages over the serial port. For example, 'COMBO <port> <value>' indicated the current combination value for port. We displayed these messages as text in the Processing window. In addition, we graphed the values of the scales over time, and the error value over time.
Step 8: Final Product
Next apply the desired combination to the sensor platforms and place the object of value inside the safe.
Now close the door and remove the pressure from the sensors. The LED turns red and the servo moves to the locked position.
Reapply the correct pressure combination. Pause for the reading to take and if the combination is correct the LED turns green and the door unlocks!