Sunday, February 28, 2010

Major Milestone: Half-Way There!!

I am very pleased to report that today marks a rough half-way point! To date, I have completed:
  • Part Research
  • Design Specification
  • Design & construction of Gunshot Detection System
  • Design & construction of Buzzer / Power Conditioning Circuit
  • Design & construction of Prototype Case
As of Yesterday (Feb. 27), I also was successful at developing a NIOS CPU core and loading it into my FPGA. With this core I have been able to detect a user's touch and draw a dot at the point, as well as load my User Interface.

To top all of this, I have successfully designed and tested a state machine for detecting a gunshot in hardware. So far, the state machine only records the number of shots fired, not the actual times. With this state machine, I was able to accurately count gunshots with only 0.17 seconds in between (I think I could count faster, but this was the quickest I was able to fire the .22 pistol). Either way, with split times of 0.17, I have met and surpassed my target of 5 gun shots per second.

I am now in full gear developing the software to run on the NIOS core and will keep you updated!!

P.S.
A little celebration is in order, cheers :)

Tuesday, February 23, 2010

Part 2-c: Building a Prototype Case

Today's topic is something that doesn't get discussed much in my degree, probably because we're not packaging engineers. Whatever the case, I strongly feel that presentation greatly affects how interested people are or become in a project. For this reason, I spent the past week building small, clean, looking circuits and several painstaking hours drilling, carving, and gluing to construct a case for my project. The final product is a case that will, most importantly, protect all the components of my project and secondly, position the screen and buttons in a user-friendly manner. Hopefully, in the end, I also have created something eye-catching and intriguing.


I started with a prototyping case from OKW, a plastics company based in Germany. OKW had the widest selection of cases and very easy to work with representatives. I've forwarded a few friends in need of a case, and if you are in need of a good prototyping case, I strongly recommend them!




While I now had a good starting point, there was much work to do. A few key issues that needed addressing were:
  • There are no mounting points for the development board I am using.
  • There are no holes for I/O (buttons, power plug, touchscreen, etc)
  • The only offered cover for the gaping hole is metal (I want people to be able to see inside)
  • It doesn't "pop!" e.g. It needs to be a little more... bad-ass-ness :)
General Modifications:
Lets start with mounting points and I/O ports. Now, I can't very well throw everything in and let it rattle around, this is Senior Project after all. I solved this simply by marking points where the board raisers touched the plastic and drilled holes. Next I made some measurements and drilled holes for the start button, piezo buzzer, piezo sensor, power, power switch, and LED mode switch.

Where to put the Touchscreen?:
The reason for picking this case was the large, slanted, hole in front. This offers a perfect spot for a touchscreen. Unfortunately, the only cover offered through OKW was made of metal, and I want people to see what is inside. The solution is plexiglass, and the answer comes from Basin Glass and Aluminum. I took my case and touchscreen in on a Friday morning and described what I was looking for. Immediately, the gal at the front desk was taking notes and confirming what was said. She said "No problem, we can have it ready Monday". To my surprise, they called me in just a few hours and explained that the gentlemen assigned to my project had finished early and I could pick it up anytime. Now that is service!

Adding "Pop":
With my case cut up and modified there was just one problem left, it was BEIGE! I quickly remedied this with 3 cans of spray paint (not that I needed three whole cans, more that I wanted 3 different colors). I started by painting the inside a flat white, this way onlookers will be able to clearly distinguish detail in the hardware. I then tapped off the the top and bottom so that the outer color would not get on the white. Once I had sufficiently covered each half in gobs of blue tape, I was able to paint the top in a dark blue with metal flake, and the bottom with a textured gray/silver color. with a fancy drying technique (seen to the right), my case was put together by the end of the weekend.


Recap:
OKW has awesome cases, Basin Glass has great customer service, and my case looks bad-ass!
Extra Pictures:
I took many pictures while building my case, but did not want to post them all, as it would slow down page load. Here are a couple links to more pictures:
Building the case & hardware
Painting

Monday, February 22, 2010

Part 2-b: Developing Power Conditioning / Buzzer Circuit

Hell0 Everyone, what a crazy week it was! I apologize for the lack of updates, but I was swamped last week. I had to wake up with my wife at about 6:00 AM every morning, and didn't get to bed till about 12:00 AM. That's what happens when class work clashes and in one week there are: 2 tests (one got moved to today :) ) , 2 labs, multiple homework's, a Design Specification presentation, and trying to make some progress on SP. With that said, let me catch you up with my design of the power conditioning circuit and start buzzer control. I know all of you have read my Design Spec and are just dying to find out what my implementation of these circuits look like ;) .

To summarize my Design Spec, the FPGA development board needs about 7.5 volts at roughly 600 mA in order to function. The tricky part comes from the piezo buzzer that I have selected, which needs 12 volts and must be controlled by only a 3.3 volt signal. In steps two very helpful devices: (1) a power regulator that will convert 12 volts to 8 volts (LM7808), and (2) a MOSFET (IRLZ34N), the same used in the gunshot detection circuit. Below are the block diagrams of these 2 devices being used (the power regulator is within the "Power Conditioning" block):


You may have noticed that the regulator outputs 8 volts, and the block diagram shows 7.5 volts. In reality, the regulator is not perfect and only outputs about 7.8 volts (with the power LED connected and now load being connected). As it turns out, there is enough conditioning on the the FPGA board that it can comfortably handle 7.8 volts.

Here are the schematics I developed for these 2 circuits:
TOP: Buzzer Circuit
BOTTOM: Power Conditioning Circuit



Below are the pictures of the final products:
TOP: Final Piezo Board
BOTTOM: Final Power / Buzzer Board


Sunday, February 14, 2010

Design Specification / General Update

Design Specification

As promised, I am uploading my Design Specification. In this new document you will find:
  • Updates to design
  • More in depth detail for implementation
  • Expanded sections on testing, constants, time line, and a price breakdown
Also, as I am a little ahead in implementing my hardware (custom circuits) and have included appendices with schematics of various uses, as well as oscilloscope images from testing the gunshot detection interface.

I have my presentation this Wednesday (2/17/10) and will upload my slides soon.

WARNING: **foreshadowing**
This weekend I have made some significant progress with my packaging and will be uploading details (including pictures) by next weekend, probably.

Wednesday, February 10, 2010

Part 2-a: Developing A Gunshot Detection Interface

Now that you've had time to look over the general concepts of Project: Smoke & Hope, it's time to roll-up our sleeves and dig into the finer details. A good place to start (in my mind) is with detecting a gunshot, because without this, there is no project.

When I first started thinking about detecting a gunshot, the initial thing into my mind was a microphone of some sort. I didn't take long for me to rule this type of sensor out, because I anticipated too many complications. For instance:
  • It is easy for a human to make a noise loud enough to overpower a common microphone (cause clipping in audio).
  • Microphones are expensive. A nice microphone costs a lot and is a sensitive piece of equipment, usually because they are used to detect and replicate a wide range of frequencies.
  • I don't need to detect frequency. Since I am only looking for "very loud" sounds, I don't really care what frequency they occur at.
  • Signal Processing is intensive. Two issues here: (1) I don't have the equipment to accurately profile the acoustical characteristics of a gunshot, (2) there is a large amount of overhead for the hardware in order to constantly measure the amplitude of a sound wave.
My desired input would be a single line (or bit) input to my board, that I would treat as an interrupt signal (meaning that an active logic level would signify a gunshot). With this in mind, I went searching for a sensor that I could build into my own circuit. After about a week of research, I found what I needed.

Piezoelectric Transducers:
A piezoelectric Transducer (piezo for short) is a crystal with a very special property. When pressure is applied (distorting the physical shape), the crystal will produce a variance in electrical potential (voltage). In simplified terms, when you hit the crystal, it causes the voltage to increase. A particularly interesting feature of the piezo, is that this process works backwards. Meaning, if a voltage potential is applied to the crystal it will vibrate at some frequency. This is very useful, as it is the technology that drives my buzzer.

Here is a link the piezoelectric transducer I used.


Application:
In order to take advantage of this sensor, I spent some time developing an amplifying circuit. Below is a picture of a basic Current to Voltage Amplifier / Converter that I implemented using an LM358P.

After amplifying the signal, it was rather noisy and oscillated between 0V to 3.3V, depending on the dB level detected. From here, I needed to condition the signal to be much smoother (in order to have time to detect the shot).

In order to do this, I connected the output of the OpAmp to the gate of a MOSFET (Metal Oxide Semi-Conductor, Field Effect Transistor). The source and drain of the MOSFET are connected to 0V and 3.3V, respectively. With a pull-up resistor on the output (creating a faster changing, active low, signal) and a capacitor tied to ground (smooths out the signal) I was able to create a signal that went low and stayed their until the sound was gone. For a better idea of how this works, see the following schematic below:


The following 4 pictures show the signals we've been discussing in more detail. The yellow line is the signal coming out of the OpAmp and the blue line is the signal after the MOSFET (notice how the signal has been converted to active low logic).

LEFT: Shows a good example of the oscillating signal out of the OpAmp.
RIGHT: Shows the output from the MOSFET with no conditioning (i.e. before I added the capacitor).


LEFT: Shows the time it takes for the capacitor to charge back up after the sound has stopped.
RIGHT:Shows what two, successive, shots would look like.


*NOTE: These waveforms are the product of lab testing. As I am not able to discharge a firearm in lab, these waveforms were generated by sharply striking the piezo (in attempt to replicate a concussive gunshot sound wave).

There you go, we are caught up with this particular interface! I am still waiting to have time to go to the shooting range with a scope and test this out better. I must sign off for now, as my Design Specification is due Friday (Don't worry, I should have it posted by Sunday for your reading pleasure).

Friday, February 5, 2010

Side Note: Bad Circuit?

So I was typing up the next installment of my SP blog a couple nights ago and ran into a little problem. The blog post was going to be all about my gunshot detection interface (back-story, theory, my implimentation, schematics... the works), but as I was reviewing my circuit and creating the schematic, I realized that my OpAmp circuit was a little odd. After doing some snooping I found that an extra resistor had been either added or misplaced to the circuit. This can cause some very bad times depending on the circumstances. I spent a couple hours in lab only to find my circuit was oscillating (this was not at all intended). I've come the conclusion that I've probably destroyed this particular OpAmp (not a big deal, they cost only about $0.40).

Anyways, I know I said we have quite a bit of ground to cover, but for the mean time I need to fix and verify this circuit before I can tell you how it works.

Thanks for being patient,
I'll be in touch.

Monday, February 1, 2010

Part 1: The Project

As I mentioned, we have a lot of ground to cover in these first days since I've had over 3 weeks to think about and work on my project. So, Here we go...

Competition Shooting Timer
(a.k.a Project: Smoke & Hope)

For my SP, I have decided to create a timer that will track the number of gun shots fired and the time of each one, relative to the starting buzzer. The user will be able to interact with the device via a 4.3'' LCD (full, 24-bit, color).

For this project/prototype, I will be developing on Altera's DE1 board and displaying my user
interface (UI) on a touch screen daughter board.










Altera DE1








4.3'' Touch Screen

Pictures from www.terasic.com

For detailed information (specifications, limitations, other components), please refer to my
Functional Specification
----OR----
Functional Specification Presentation