Piezo knock sensor

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

Sorry if I didn't explain this right. The problem isn't with being able to set the port to OUTPUT to discharge the cap. That's a solid and interesting technique.

The problem is with the way the TI CD74HC4067 chip on the Mayhew Labs MUX shield accepts the signal from the piezo (and the cap and diode circuit.) The mux chip experiences cross-talk across all of the ports. Unfortunately it won't matter if I can bleed the cap off quickly if the initial signal on one of the ports causes a read on all of the other ports.

I also understand that this technique can be done with digital ports (or a digital mux) as well. But the cost is the control of the trigger threshold. I either have to hardwire the threshold into the passive components used or I have to have a trim pot for each channel (target.) That complicates things for me a bit too much. If I build a board with 24 trim pots then I have to train my crew to be able to adjust them when they set the rig up. My current design has a single trim pot on one of the analog ports that just sets a threshold value in the code.

I suppose I could set all of the mux analog ports to output until I want to read them. But that defeats the purpose of being able to store the signal in the cap while the microcontroller is off doing other things.

The work being done in the sparkfun thread is mostly based around an envelope detector model (http://en.wikipedia.org/wiki/Envelope_detector) which really is only one resistor different than the circuit in this thread. However our success has been kind of limited with it.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Piezo knock sensor

Post by adafruit_support_mike »

You're right that the envelope detector is similar to the circuit I posted.. mine is a microcontroller-specific variant of the envelope detector, actually. The microcontroller takes the place of the resistor, and the INPUT/OUTPUT state provides a variable resistance.

Crosstalk usally happens for one of two reasons: inductive coupling between signal wires, or parasitic capacitance between signal traces. I wouldn't expect a chip designed for digital logic to experience serious capacitance issues, so my first suspect would be your wiring between the sensors and the control system.

If you have the wires bundled together, try separating them, or using coax with the shield conductor tied to GND.

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

That was one of my first thoughts as well. But its showing the same behavior on a breadboarded version with no parallel wires.

As mentioned, the behavior has been verified by a second party and modeled in LTSpice. Also Mark Mayhew, the maker of the mux board, has looked in on the thread and feels the issue has merit. Mind you, we don't think this is a defect in the Mux board itself. We think the signal produced by the piezo is the culprit.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Piezo knock sensor

Post by adafruit_support_mike »

Hmm.. in that case the second line of defense is to slow down the signal.

You can do that by putting a resistor in series with the diode, on either side of it. That does impose some design tradeoffs on you though. The pulse from the piezo sensor won't last any longer, so limiting the amount of current that reaches the cap will cost you some signal amplitude. You'll also need to be careful with the ratio of your "slow the signal down" resistor and your "bleed the cap down so it's ready to accept another signal" resistor. Those will form a voltage divider, which also lowers the peak signal voltage.

Try starting with a resistor about 20% the size of the one you have bleeding the cap, and see if that stops the crosstalk. If so, keep swapping in smaller ones until the crosstalk starts to appear again. If not, swap in larger ones. Again though, you'll have to watch the ratio between the two resistors.

Another option is to invert the signal from the piezo sensor by sending it through the base of an NPN transistor. The current that flows through the base of a BJT doesn't flow through the load resistance. That's usually considered a form of inefficiency, but in this case it can work to your advantage. The pulse that comes from the piezo sensor will get shunted to GND without ever entering the shield, but will allow a burst of current to flow from collector to emitter. That will show up as a HIGH-to-LOW pulse at the collector voltage, but that inverted pulse will be constrained by the local power supply and the value of the collector resistor. You can change the amplitude of the inverted response by changing the collector resistance, and you can limit the transistor's slew rate (if that's still necessary) by putting a small capacitor between the base and collector.

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

Update and a question... I'll post them in separate entries so the question doesn't get lost in th epost.

I have about a month until the Detroit Maker Faire and am running out of time so have made some concessions. I haven't been able to make the piezo circuit (as described in this thread) work with the MUX board. I'm sure it can be done with other components (i.e. op amp, or a comparator) but I don't have the time now to explore those options. So I've dropped the MUX board from the project and am replacing it with an Arduino MEGA which has enough analog ports for the job.

I've built a circuit board that has the typical 1M resistor across the piezo leads, plus a diode and capacitor. After some wrestling with my poor soldering skills (I found 2 connections accidentally solder-bridged) the board now works as expected. All channels return signals for the targets.

However, I have a question which I'll ask in the next post...

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

Now that I have a full target array assembled I am noticing something. The piezo sensors are not returning the same amount of signal. Some targets work perfectly as intentded and others you have to hit pretty hard to get a signal.

I'm beginning to wonder if I've damaged some of the piezo sensors during handling. I wonder if the ceramic side of the disk can get cracked and if that would make it return less signal? I'm using a product called Zots to mount the piezo to a clear acrylic sheet. This is a product that is used a lot in scrap book crafts and is essentially a roll of 1/4 inch dots of glue on a paper backing. You stick the dot of glue on what you want to attach and then peel the paper backing off of it. It's very neat and seems to work great for this application.

However, when I've been sticking these things on the piezos I've noticed a popping noise and I'm not sure if its coming from the glue or the piezo itself. I wonder if that was the ceramic side of the piezo cracking as the copper flexes.

Am I crazy or is this a thing? I'll be testing some sensors on a very old oscilloscope to see if I can get some idea about whether the ones I've installed match the output of some new ones. I'll report the results but hoped somebody could pass on some wisdom about what might be causing the variation in output.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Piezo knock sensor

Post by adafruit_support_bill »

In my experience, piezo sensors can take considerable abuse. But I'm sure there is some variability between models and manufacturers.

I would suspect that some of your sensors just have better physical coupling with the acrylic sheet. If there are any bubbles or incomplete adhesion of the adhesive to both surfaces, the sensor response will be lower.

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

The scope shows that the raw piezos are all generating about the same signal strength. So that's good news. This is my first project with them so it's good to know they're hard to kill.

I'm testing a few other possible issues with my circuit board.

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

I have what I think are two issues going on with my setup now. Here is how the circuit is wired up:
piezo_sensor_bb.png
piezo_sensor_bb.png (122.58 KiB) Viewed 1798 times
Note: Resistor = 1M, Diode= 1N914, Cap=.47uf

First, I think I undersized the capacitor in the piezo buffer circuit. I was using a 47pF ceramic in the hopes it would decay naturally. But now that I can see what it's doing on the scope I can see it decays way too fast and is not filtering a lot of the noise from the sensor. So I have now replaced it with a .47uf tantalum cap. (No reason to change to tantalum... that's just what my electronics store had in a range that I would guess would be more suitable.)

Now I'm seeing unexpected results on the Arduino ADC. The piezo is running the input from 50 up to 65-79 with no input (i.e. no hits on the piezo sensor.) It runs up over about 6-8 seconds to the high 70's. A hit on the target gets me about another 10 on the ADC value with successive hits adding another 10 taking me from 79 to 90, 100, 110 etc. Then a slow decay.

Second issue: If I execute this from the Arduino:

Code: Select all

    if (targetHit > SENSORTHRESHOLD) {
      pinMode( activeTarget, OUTPUT );
      digitalWrite( activeTarget, LOW );
      pinMode( activeTarget, INPUT );
      Serial.println("Flushing");
    }
I don't see the ADC voltage value drop at all. It slowly drops over about 30 seconds to the 90 range and then stays there. I thought this code was supposed to drain the cap and reset the circuit so I could detect another hit. I've even tried a delay of 100ms after the digitalWrite command just in case there wasn't enough time for the cap to discharge. It didn't have any effect. (Note this is on an Arduino Mega... not an Uno as the diagram above might give you the impression. Not sure if that makes a difference.)

Seems like this cap is a bit oversized for the job. I'd rather see a larger voltage come in on a hit. But I'm reticent to try other cap values before I get the above code to dissipate the cap charge.

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

It seems as though the cap is getting some charge from the Arduino ADC port itself. I did a test with no piezo attached and just the arduino connected and I got roughly the same results.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Piezo knock sensor

Post by adafruit_support_mike »

What happens on the scope when you remove the piezo sensor, short the capacitor's leads with a wire, then remove the wire? If the cap charges up again, you either have current leakage or dielectric soaking.

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

I'm at a bit of a disadvantage checking that on the scope, although I can try. This scope is decades old and is missing the graticule. I'm not sure it will really be useful for getting accurate measurements. In this case it's difficult to tell if there's a gradual charge of the cap since I can't see the baseline. It has been useful to me just to visualize the shape of the wave and length of the signal though.

I have been thinking about printing a grid on some some cellophane and tacking it up to the screen. I'll give that a try as well.

I suppose the reading on the arduino analog port (in the serial monitor) would be just as useful though wouldn't it? I'll give this all a try this afternoon.

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

I'm running out of ideas:

First off, shorting the cap does exactly what you thought it would. I was unable to verify using my scope... but watching the adc value in the serial monitor I could see it drop to 0 when the cap was shorted and then rise gradually. This made me suspicious of my board. So I got out the MM and looked for shorts, but I didn't find any.

I isolated the circuit on a breadboard and it works as expected there.

Here are photos of my board in case anyone sees something obviously wrong. I apologize for all the newby mistakes here... like wrong color wires ... etc. I have to run right now but will post more detail later.
IMG_4582.JPG
IMG_4582.JPG (297.5 KiB) Viewed 1729 times
IMG_4580.JPG
IMG_4580.JPG (113.4 KiB) Viewed 1729 times

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Piezo knock sensor

Post by adafruit_support_mike »

If you're getting a slow rise in the cap, you aren't looking for a short circuit (a low-impedance connection between two points). You're looking for a large-but-not-infinite resistance between the cap and some other part of the board. Probably something on the order of 4-5 megohms.

I ran into a similar problem a few months back with one of my own circuits.. I was getting signals that just didn't make sense: http://info.yawp.com/blog/2012/41/switc ... index.html

The problem turned out to be copper contamination in my flux. A chunk of wire had fallen into the tin at some point, and enough metal had diffused into the flux to make it slightly conductive. Try giving your board a really good cleaning, at least around the capacitor that's giving you problems.

User avatar
walker
 
Posts: 77
Joined: Sat Aug 04, 2012 8:40 am

Re: Piezo knock sensor

Post by walker »

I made a little progress tonight... I've discovered that the cap only charges when I have my bench power supply on.

So here's a little more detail to make sense of the photos posted earlier. There are two separate circuits on this board: one to control LED lights on individual targets, and one to get input from the piezo sensors.

The piezo envelope detector circuit is located to the top right of each of the target connectors (white blocks at the left of the board.) You'll see a cluster of a 1M resistor, 1N914 diode and a ceramic capacitor. Although this connects to the common ground plane it doesn't take a power feed from anywhere. (Not intentionally, anyway.) The positive end of the cap runs to the ADC via a 4 wire ribbon cable.

The LEDs are driven by an Adafruit PWM controller mounted at the right of the board. This board is connected on VCC to the Arduino +5v pin and ground (and of course the I2C pins.) It also has an independent 5v power supply (2A) connected to the power terminals to drive the V+ pins.

I take the V+ power from one of the ports and run it to a 5v rail on the top of the board (black and white wires.) This is used to drive the darlington array chips. The LEDs I'm using require 12 volts. So the PWM board drives one of the transistors on the darlington array which switches 12v to the LEDs. The LEDs are connected to the bottom two pins of each of the white blocks.

The 12 volt power supply is a Pyramid regulated bench supply (not variable.) It can supply 5 Amps. You can see it connecting to the 12 volt rail at the bottom of the board (red and black wires.)

So the bench supply is where I'm getting my leakage. If I leave that supply off the LEDs don't light, of course. But I don't have the phantom cap charge either.

I can't see how this could be a problem with resistance in my solder joints. I don't read any with the MM. And the only thing between the + side of the cap and the ADC port is about 6" of ribbon wire. Shouldn't I be able to measure a resistance that would be high enough to cause this?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”