User:Jstapko/DoorAccess

Write problem/project Goal
To devise a machine which can recognize a particular pattern of sounds over time, and if that particular pattern is present, operate a mechanism which will allow passage through a door. links page

My First Task

 * I am going to review the literature left by prior teams to determine what our team needs in an effort to understand the current status of the project.
 * I am going to document an idea for sound pattern recognition in an effort to help my team mates understand it so that they may implement it in software.

Summary of actual work over first weekend
I spent most of the weekend wrapping up project LockPick. For project Door Access, I experimented with an idea for logic external to the arduino that could check the knocking pattern when sent control signals by the arduino, and built a working model of it in a logic gate simulator I discovered on the internet. I reviewed Wikiversity pages on the project by other teams and found several useful pieces of information, including two options for source code. Based on descriptions by the previous team of mechanical difficulties, I recovered two servo motors from my personal collection to try to use for opening the door. I also thought about and documented some motor control ideas, such as an H bridge driver and edge triggering to turn it on and off or change direction.

Week1 Narrative

 * I had planned on taking perhaps one or two days to do wrap up work for my previous project, the ComboLockPick
 * Contrary to my expectation, I spent almost the entire weekend finalizing the lockpick project
 * I still found time to investigate making digital logic circuits with CircuitLab and Logic Lab
 * I developed a working model of the pattern recognition logic in Logic Lab, as well as learned how to use digital logic elements in CircuitLab (models to come)
 * I also documented on paper, and plan to build in circuitlab, ideas for motor drive in both forward and reverse directions, to open and close the door handle. Generally, they are based on an H bridge, with one circuit using photodiodes driving transistors, while the other uses two separate relays driven from separate arduino lines
 * I considered means of edge triggering, such as a single capacitor operating two different optoisolators, or edge triggered flip flops, as a means of controlling both motor directions with a single arduino pin.
 * I built an attempt at an optoisolator in circuitlab
 * By searching through prior team's work, I found two sources of arduino code already tuned to perform the knock processing:
 * 1)Grathio Labs' door opener


 * 2)Grathio Labs' gumball machine

My Second Task
I am going to incorporate a closed loop motor position control into the current motor drive circuit.

Summary of actual work over second weekend
I had planned to have some sort of closed loop motor position control system in place by the close of the weekend. When I set myself to executing this task, I found myself pulled down paths that were related only tangentially, and spending far more time and effort focusing on those than I should have. I also followed at least 2 dead end leads, the use of a servo motor's on board sensor as a limit switch, and the construction of a limit switch concept demonstration device. Eventually, I realized that the limit switch was not an efficient path to success, and resolved to refocus my efforts on optical encoders and computer control.

Week2 Narrative
First, I identified some options for position control systems. These were, generally speaking,


 * 1) mechanical switching arrangements


 * 2) analog electronics with an option for digital input


 * 3) digital/computer control using an optical encoder as a sensing element

Time was a significant factor in deciding which lead to follow first. I had 4 days, and thought it best to produce a functional device to meet the needs of the project first, which could then be improved as much as desired as time permitted. Believing mechanical switching to be simple and quick to implement I pursued that option first. I could always go back and either convert it to a digital system later or introduce digital or analog elements into it incrementally.


 * I reverse engineered a servo motor, thinking that its sensor could act as a built in limit switch.
 * While doing so, I thought a tool that could check continuity between many wires simultaneously would be very useful, so I reverse engineered a tube tester  that had such a circuit(see pages 11 and 23 of the manual for a circuit description and the schematic)
 * I tried to design a new multi wire continuity tester based on the tube tester’s short indicator circuit, but thus far have been unsuccessful
 * I designed a machine that would demonstrate the use of limit switches as closed loop position controllers, and might possibly be included in some form in the door opener
 * I spent most of Saturday trying to select a one of many motors, and a few other parts for the limit switch demonstrator
 * Eventually, I decided that there were so many problems with the mechanical limit switch demonstrator that I should re focus my efforts on the computerized control/optical encoder option

Where can I go from here:


 * I came up with an idea to use the arduino to control an ac clock motor. The clock motor would have plenty of torque, but would be very slow.  It might be possible to boost its output speed, either mechanically (gears/slider crank) or electrically (high voltage amplifier, variable frequency drive).


 * I finally have some potentially good leads on arduino optical encoder tutorials. I can watch all of those videos, and read as much of the text of the websites as possible.


 * Several people have told me, and I have found online that arduino is basically a program called “C.” My uncle recommended a book by Kernigan and Richey called “C”.  I could find a copy of that and begin reading it.


 * I have found several very promising books on the website of Montgomery County public libraries, many readable online. I could read those (Have started this already).


 * I still have the WorkForce 600 business machine I was assigned to dismantle and recover systems from at the beginning of the semester. I could proceed with reverse engineering that.


 * I have a mechanical type computer mouse. I could attempt to get pulses out of its rotary encoder.


 * I found some code examples that show how to use analog in pins. I could attempt to get the arduino to  operate the motor based on analog inputs.


 * I have several relatives and friends who know far more about this than I do. I could (and have to some extent already) ask them questions.

I reverse engineered a servo motor

I designed a machine to demonstrate limit switches

and took apart a multifunction printer in search of an optical encoder



My Third task
Work with Aabdelaz6573 to mount the opener mechanism on the door and attach it to the knob. If I complete this task with time remaining, I will attempt to replicate Kheckco1075's work on knock pattern recognition with the arduino.

Summary of actual work over third weekend
I had planned on spending weekend 3 in HCC’s engineering lab grinding sharp edges and unnecessary metal off of the door handle retracting mechanism. However, I was unable to access the engineering lab, so I had to make an alternate plan. During class on Thursday, professor Foerster showed our team some code that a different team doing the same project had developed, and demonstrated some of the problems with poor acoustical coupling of the piezo buzzer to the door (actually, table) surface, and intermittent knock signal levels that that caused. I thought that if I could amplify the signal, I could make a larger voltage difference between that with a knock present and that with no knock present (basically, boosting the [signal to noise ratio]). This would give the programmer a bit more flexibility with software thresholds, and the person knocking more flexibility with how hard they could pound the door. To test this theory, I designed, built, and refined a linear amplifier for the sensor, started investigating the possibility of epoxy potting the sensor to improve acoustical coupling, and learned to modify arduino code to test my knock sensing amplifier. While learning the arduino code and testing the amplifier, I tried to use the arduino to make a software based frequency sweeping signal generator (had limited success doing so), and learned how to integrate subroutines from different programs into a single program. While modifying the arduino knock sensing code, I added pieces to it from Messi’s motor drive sketch so that now the knock sensing program, when it detects a valid knock, has the motor shield power a motor.

What I Did

 * I had planned on grinding sharp edges off of the door handle opening mechanism, but could not access the engineering lab.
 * I decided to try to solve the problem with sound sensor being unreliable.
 * I salvaged a piezoelectric transducer from a microwave oven control circuit board and tested it.
 * I designed, built and refined a linear amplifier to increase the signal voltage coming from the sound sensor.
 * To test the amplifier, I tried to write a program that would turn the arduino into a sweep frequency oscillator (I had limited success).
 * I salvaged several other sound sensors from telephones, and tried t5em in various circuits as signal sources.
 * I encased the piezoelectric crystal in epoxy in an effort to improve its sound transfer characteristics, or acoustical coupling to the surface.
 * I spent a lot of time looking at and trying to understand arduino tutorials to find out how to display the arduino's reading of the analog input pin on the computer monitor.
 * To test the effectiveness of the sensors and amplifier, I modified some arduino code. While doing so, I modified the code to run an electric motor through the motor shield when it was given a valid knock pattern.
 * In the end, I had the entire system working flawlessly when I tapped the sensor directly, but could not get the sensor to pick up vibrations from a surface reliably.
 * Once the system was working while tapping the sensor, I tried to improve it by changing sensors.
 * The other sensors didn't work noticeably better, and when I reconnected the original one, it didn't work anymore.
 * While trying to get the original sensor working, I accidentally shorted a pin of the arduino to the motor shield's power supply terminal, (at least, I think that's what happened) killing my computer instantly (it went black, and wouldn't restart).
 * I am still waiting for word on the damage/salvagability of my computer.
 * UPDATE - computer survived with all data intact, but leaving wires loose and randomly touching circuit board pins is still something very important to avoid

Possible next seps:

 * get my computer fixed
 * test motor shield/arduino for damage
 * re write arduino programs and try to find related websites online to document it before I forget what they were/how to do it
 * try ideas for alternate sensors, such as a seismic sensor or a record player pickup
 * try to build a new, direct copy of the amplifier to ensure repeatability
 * try to improve the gain of the amplifier*grind sharp edges off of door handle mechanism, as originally planned

Story in Images
I salvaged a piezoelectric crystal from a microwave oven circuit board

I tested it for output with an oscilloscope

I designed a (not so) linear amplifier

tested it

and refined it

until finally, success!

whole system, set up and working

Major Lessons:
1) ALWAYS put the live voltage source on the SOCKET end of the connector, NOT the plug end

2) 12 volts can be as bad for computers as 12,000 is for people; be very mindful of loose connections, live wires, and high voltage near computer terminals

3) Don't work on live circuits, ever!


 * I believe that if I had followed EITHER (1) OR (3) above, my computer would be fine now

My Fourth task
I am going to try to get a sensor to reliably trigger the arduino when the surface to which the sensor is attached is knocked on

Summary of actual work over fourth weekend
I built a new, higher gain amplifier for the sensor, contacted some friends about additional sensors, and experimented with a few sensors and software adjustments in an effort to optimize system reliability. While doing so, I identified a potential problem with sensor reliability caused by standing waves in the structure to which the sensor is mounted.

Overview

 * I searched for, and found a book, Getting Started in Electronics that I remembered as having many transistor circuits, hoping to find a pre designed high gain amplifier circuit.
 * based on the content of the book, I decided the Bipolar Junction Transistorapproach was not an efficient use of time, and instead decided to pursue one based on the LM741 operational amplifier
 * I used the 741 op amp gain calculator and a table of standard resistor values to design a 2 stage direct coupled sensor amplifier based on the '741
 * Once I got the amp working, I experimented with several sensors and the readings from them generated by the arduino. While doing so, I found that the point on the surface on which you knock had a substantial effect.
 * I suspected, based on experience at work and on an exhibit at the Franklin Institute Science Museum that the output variations with impact position were due in part to standing waves in the structure, as dramatically shown by this video illustrating principles of cymatics
 * I contacted some friends hoping they might have some alternative sensors that I could use or at least borrow for testing.
 * One of those friends had a carbon button microphone from a Swiss army tank, which is showing potential not only to be very sensitive, but also convenient to mount on the door
 * I built a device to mount the printer mechanism on the door, and ran some initial tests
 * those tests showed that the belt did not have enough tension to pull the door handle all the way open before slipping
 * I tried to fix the belt tension, but decided instead to focus efforts on a gear motor which not only seems to have more torque, but is much more compact/light weight.
 * I designed two brackets for mounting the gear motor to the bracket that was originally intended

Next Steps
If I had had more time I would have:


 * designed an amplifier requiring only a single polarity voltage source, perhaps a 2 stage direct coupled BJT or single stage MOSFET amplifier to replace the op amp based one that requires both positive and negative power supplies.
 * Ideally, the amplifier would use as few and as cheap components as possible, run on the same power source as the motor shield, and have enough gain to reliably trigger the arduino with a cheap sensor such as a piezoelectric loudspeaker, often obtainable at little or no financial cost.
 * I would have mounted sensors on the door and adjusted various parameters such as mount location, elasticity, and software/amplifier sensitivity to reliably trigger the program
 * I would have repeated the sensor placement/adjustment process with every sensor I had available
 * I would have tried to find a [record player pickup] or seismic sensor to try in addition to those already available
 * Based on a suggestion of one friend consulted about sensors, I would have explored the possibility of modifying the program so that it could adjust its own sensitivity based on the intensity of a particular sequence of knocks, compensating for differences between people's knock styles
 * I would have built the mounting brackets I designed for the gear motor and tested it
 * I would have tried to find a pulley to fit the inkjet printer motor and tried using that motor to implement the string wrapped on a pulley idea of the previous team.

Story in Images








Detailed Information
My task was to get the arduino to reliably respond to the output of a sensor when the door, not the sensor, was knocked. The situation as it stood was that we could trigger the arduino by knocking the sensor, but not by knocking the surface the sensor was on. I thought that I could solve this problem by either increasing the gain of the sensor amplifier, or by finding a more sensitive sensor. I decided to first try increasing the amplifier gain, then pursue a more sensitive sensor. For amplifiers, I had at least four options:


 * Continue to refine the existing bipolar junction transistor (BJT, for operating principles,see link above) based amplifier
 * Abandon the BJT based approach and try to find parts to build a new amplifier based on a junction field effect transistor (JFET), or metal oxide semiconductor field effect transistor (MOSFET).
 * Abandon discrete transistors altogether and try to build an amplifier based on integrated circuit operational amplifiers
 * build an amplifier based on commonly available vacuum tubes such as the 12AX7 or the 6AU6 and one of hundreds of already designed microphone preamplifier circuits already designed for them

I recalled having a book ("Getting Started in Electronics," Forrest M. Mims, III, link above)years ago that showed many simple circuits using a common transistor, the 2N2222. I thought that if I could find that book, I might find a pre designed schematic for a high gain transistor amplifier, saving me the time required to design/test/refine a new one. With extensive searching, I found the book, and, as I remembered, there were many circuits using the 2N2222, but none were high gain amplifiers. There were, however, high gain amplifier circuits in it based either on JFET’s or on LM741 op amps. This was consistent with the opinion of my uncle that a BJT would not have sufficient gain or input impedance to amplify a piezoelectric crystal well, and his recommendation to use a JFET instead. At this point I had two promising options, an FET based approach and an op amp based approach. I chose not to pursue the vacuum tube approach unless all else failed, because vacuum tubes require extensive hardware work (socket mounting, transformer mounting, etc.) and support electronics (3 power supplies, careful adjustment), require using out of production parts, and involve dangerous voltages, limiting repeatability to those with experience working with high voltage and access to antique parts. I did not recall having any FET’s on shelf, but did seem to remember having a box of op amps. I did, however, have half a dozen circuit boards with discrete components, some of which might be FET’s. I could either spend time reverse engineering circuit boards, looking up datasheets for anything that might be an FET, or I could try to find the box of op amps and use a predesigned circuit. A few minutes’ searching revealed a drawer of op amps, mostly DIP versions of the '741, an RE709 and some TO 5-8 (metal can) packaged ‘741s. Not knowing how to use op amps, I looked online for some basic introductions. I found some critical information at hamradioindia’s site. Note particularly the chart of open loop gain vs. frequency, and the schematic/procedure at the bottom, “offset null adjustment procedure for uA741.” I incorporated the offset null adjustment circuit into the prototype (though ultimately abandoned it because of problems with poor quality potentiometers), and took into consideration the open loop gain at the expected operating frequency, 500-1000 Hz. I decided I could probably get enough gain with two units in cascade, while having plenty of degenerative feedback to ensure stability. I started with an assumed sensor output of 0.01 volts, and wanted to boost that to 5 volts, the maximum analog input of the arduino. This is an overall gain of 500. Since I would be running two op amps cascaded, the total gain would be the product of the gains of each stage, and I wanted the stages to have identical gain so that each could have the most degenerative feedback, and thus the most stability, possible while still achieving the desired gain. The desired gain, then, is the square root of 500 for each stage. 500 = 5* 100, so the square root of 500 = sq rt 5 * sqr rt. 100, or 10 (sqr rt. 5), just over 22. I started plugging numbers into a calculator to find convenient resistor values for the desired gain, per the gain calculation procedure described here, but then found the 741 op amp gain calculator, where I just started entering numbers. I wanted to follow the advice given on the gain calculator of using standard value resistors, so I used this table as a guide. I ultimately selected 1.1k for the input resistor, 27 k for the feedback resistor, and 100k as a dc return path to ground, all resistors 5% tolerance (based slightly on available parts). Initial tests revealed intermittent or no output. Troubleshooting revealed this to be a combination of defective offset null adjustment potentiometers and defective or incorrectly wired op amps. To compensate for the potentiometer problem, I initially tried alternate pots, but ultimately replaced the pot with a pair of 5.1k fixed resistors. These should be modified in future versions of this amp because the output coupling capacitor is electrolytic, and should have enough forward bias that negative peaks of the output signal do not drive the positive side of the capacitor negative with respect to the negative lead of the capacitor. Alternatively, an external capacitor biasing scheme could be implemented, or the coupling capacitor could be replaced with a non polarized type. The coupling capacitor is to keep dc voltage, particularly negative, off of the arduino analog pin; it is essentially for dc blocking. Once I had a reliable circuit, I compared many op amp chips, finding several to either not operate or not operate as well as others. Once I had found several well functioning chips, I proceeded to build the final amplifier stage and adjust it. As expected, the resulting 2 stage amplifier was very sensitive, so much so that several sensors are capable of driving the arduino digital conversion of the analog input to over 100, when only the surface on which the sensor is sitting is knocked, and not even knocked right next to the sensor. Also, the conservative selection of feedback resistors leaves plenty of room to increase the amplifier’s gain if so desired at a later date. With the amplifier operating reliably and with high sensitivity, remaining time can be spent on exploring different input sensors and securing the sensor to the door.

Possible types of sensors:

I have salvaged a carbon granule microphone from a Western Electric trimline telephone, a speaker and a microphone from an answering machine handset, and have thought of using a record player pickup cartridge, possibly mounting it on the door with the body attached to a structure elastically connected to the door such as with rubber band padding, then adjusting it so that the needle just touches the door. The cartridge body/mounting is much more massive than the needle point, and thus has much more inertia. This means that when the door moves, the needle would move a long way before the cartridge body had time to move with it, and the elastic mounting would allow the cartridge body to stay relatively stationary. This idea is borrowed from the gramophone reproducer, which uses a thin mica diaphragm as the low inertia element mounted in a massive metal frame. Both move sideways in time with the needle deflections, but the mica diaphragm moves much more so. Along the lines of the record player cartridge, I thought of possibly gluing a stylus to the surface of a piezoelectric crystal loudspeaker in an effort to mimic the function of the gramophone reproducer, except that the mica diaphragm is replaced by the piezo crystal. Finally, it might be possible to find a seismic sensor, specially designed for detecting earth movements, but which would probably also work very well for detecting door vibrations.

Effect of knock position on sensor reading:

During tests of the new amplifier, I noticed that the placement of the sensor with respect to the point of knocking had a significant effect on the output. A knock in one place might make a digital output of several hundred, while a knock of comparable intensity just a few inches away may produce an output of just dozens or a few hundred. This could be because of imprecise action of the sensors, but I suspect it is actually a result of standing waves set up in the surface. If the surface has a particular propagation speed and resonant frequency, knocking at particular points will set up mechanical nodes and antinodes, as in a slinky or the electrical equivalent in an antenna. Experience at work has shown this to have a a pronounced effect; Often, to get a package to slide down an inclined piece of sheet metal, workers hit the sheet metal to vibrate it free. By adjusting the rate of knocking and position of impact, I have found that some combinations of points of impact/knock rate are much more effective at dislodging the package than others. Additionally, a device at the Franklin Institute Science Museum in Philadelphia, PA shows this effect clearly. An aluminum plate is suspended at its center, and an instrument with a piece of string or similar material held tightly on it, like a violin bow, is provided. The participant rubs the edge of the aluminum plate with the violin bow while spreading fine sand on the surface of the plate. The disc makes a loud, high pitched sound, and the sand distributes itself in patterns that show the maxima and minima of the mechanical oscillations of the plate (much like in this video. If this action is in fact responsible for the variations in sensor readings, it suggests that the sensor’s output would be very dependent on where the sensor is mounted, and where on the door a person knocks.  To compensate for this, perhaps an unobtrusive looking flyer, perhaps a comic, apparent announcement, or even a speck of dirt, could be used to indicate to a knowing person the proper place to knock, while appearing to the casual passerby to be completely insignificant.  This would establish within small limits the origin point of the sound wave; foam padding and other acoustic property modifications could then probably be used to get the sensor working reliably.

Complete Team Page
Return to Team Page

10/10/70 ... great ... --1sfoerster (talk) 01:11, 13 November 2012 (UTC)