SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By warcher1
#159176
I see the plots now. Those do look more realistic as far as the piezo output goes.

Here is a closeup of the breadboard for my testing setup:
004_2.JPG
Here is a pic showing the connections to the mux board:
005_2.JPG
You do not have the required permissions to view the files attached to this post.
By Mee_n_Mac
#159178
warcher1 wrote:The first hit is about what I would have expected. There's some initial crosstalk but it dies down pretty quickly and then its just a matter of the capacitor discharging over time (about 9 seconds.)

But the second hit is not at all what I expected. I had to run the test a few times just to make sure I was somehow hitting the wrong piezo! The second hit starts at 10885ms. The larger value is read on port 0.
Yeah, that's confusing. In addition to the "crosstalk" being larger than the primary channel ( :? ), obviously 1 channel's RC is very different from the others. At this point I'd use a battery or some other DC voltage < 5v and verify each channel is really what you think it is. Perhaps unplug the piezo that's not being hit from the breadboard. There's something odd going on. I'm not sure what to say ... :shock: :think:

Plot of 5/4 tap tests
piezoMUX_results2_0504.jpg
You do not have the required permissions to view the files attached to this post.
By warcher1
#159180
I'll check the channels in a few minutes... I have a 5v supply right here.

In the meantime I also tried an 820k resistor and got a pulse of about 40ms.

First channel hit:
Code: Select all
Current Time: 1180
Port 0: 0
Port 1: 0
Current Time: 1224
Port 0: 0
Port 1: 0
Current Time: 1268
Port 0: 850
Port 1: 162
Current Time: 1315
Port 0: 20
Port 1: 0
Current Time: 1360
Port 0: 0
Port 1: 0
Second channel hit:
Code: Select all
Current Time: 4636
Port 0: 0
Port 1: 0
Current Time: 4680
Port 0: 538
Port 1: 368
Current Time: 4728
Port 0: 0
Port 1: 5
Current Time: 4771
Port 0: 0
Port 1: 0
Obviously the same issue with the channels going on there but I'll check that out shortly.
By Mee_n_Mac
#159181
Just to be sure, your first test had this for the detector values:
EnvelopeDetectorCKT_asTested.jpg
What channel (if any of the 2) was selected by the MUX ? The port1 decal appears as I might expect given the sample interval. The port0 is waaaaaaaaaaaaaay too long. It has a time constant of somewhere btw 2.5 - 3.0 seconds, vs the 10 msec it should be. I can only GUESS that perhaps the 1M resistor (Rd) is just not connected somehow.

As for the unexpectedly high response on port0 when port1 was hit ... were the piezo's lying on the table top as shown in the pics ? Could the top have transmitted the tap to the other piezo ? To check, disconnect the piezo on the un-hit channel and see what the response is then.

I'll have a look at the latest results in a bit.
You do not have the required permissions to view the files attached to this post.
By Mee_n_Mac
#159182
warcher1 wrote:In the meantime I also tried an 820k resistor and got a pulse of about 40ms.
This was Rd in the schematic above ? Rp was still 1M and Cd 0.01uF ?
I note the loooooooong decay is gone. Also the 40 msec makes sense. A time constant of 10 msec will have a PW of something like 25 to 30 msec. Given the sample interval, 40 msec is consistent.
By warcher1
#159183
This was Rd in the schematic above
Yes, the 820k resistor was in the Rd position. I'll have to double check the 1m resistor. Wouldn't suprise me too much to find it loose.
By Mee_n_Mac
#159185
warcher1 wrote:Yes, the 820k resistor was in the Rd position. I'll have to double check the 1m resistor. Wouldn't suprise me too much to find it loose.
That would explain, perhaps, the looooooong decay time. Plug it back in, wiggle it good, and redo your tap test. See if you get a looooooong decay time. I would hope not. The remove it and run the tap test w/o any Rd. See if you get a looooooong decay time. I might hope so. If both tests turn out as hoped for, it was a loose resistor.

As for the uber strong "crosstalk" ... got me ATM. It can't be crosstalk in the fashion we've been discussing. :shifty:
By warcher1
#159201
Yeah, this is a tough one.

Wiggled the resistor and got the same results... a higher reading on port 0.

Applied 5v on the positive side of the piezo (with the piezo still in)... The charge showed up in the correct channel. Readings were in the 900 range.

In case the table top was transferring vibrations I moved the first piezo to a rubber mouse mat (trying to avoid disconnecting it because they are tough to get into the breadboard.) Got the same results with a higher reading on port 0 when tapping the piezo on port 1. So I went ahead and disconnected the piezo. This time the reads were statistically favored on the correct port... but the reads are not consistent. I had to run this test several times just to verify.

Here are 6 reads:
Code: Select all
Tap #1
---------------
Current Time: 1006
Port 0: 0
Port 1: 0
Current Time: 1049
Port 0: 0
Port 1: 833
Current Time: 1095
Port 0: 9
Port 1: 4
Current Time: 1139
Port 0: 0
Port 1: 0

Tap #2
-----------------
Current Time: 2275
Port 0: 0
Port 1: 0
Current Time: 2318
Port 0: 432
Port 1: 265
Current Time: 2366
Port 0: 0
Port 1: 0

Tap #3
---------------
Current Time: 3677
Port 0: 0
Port 1: 0
Current Time: 3721
Port 0: 15
Port 1: 10
Current Time: 3766
Port 0: 0
Port 1: 0

Tap #4
---------------
Current Time: 4989
Port 0: 0
Port 1: 0
Current Time: 5032
Port 0: 69
Port 1: 46
Current Time: 5079
Port 0: 0
Port 1: 0

Tap #5
----------------
Current Time: 6258
Port 0: 0
Port 1: 0
Current Time: 6301
Port 0: 0
Port 1: 986
Current Time: 6347
Port 0: 12
Port 1: 9
Current Time: 6392
Port 0: 0
Port 1: 0

Tap #6
----------------
Current Time: 7571
Port 0: 0
Port 1: 0
Current Time: 7615
Port 0: 0
Port 1: 1023
Current Time: 7662
Port 0: 14
Port 1: 9
Current Time: 7706
Port 0: 0
Port 1: 0

I don't understand why taps 3 and 4 are so low. I tried to keep the force about the same for each tap.

One last test... I disconnected the first detector from the mux altogether and shorted port 0 to GND. Then ran the test with 3 taps to the piezo and detector on port 1.
Code: Select all
Tap #1
--------------
Current Time: 1268
Port 0: 0
Port 1: 0
Current Time: 1311
Port 0: 0
Port 1: 91
Current Time: 1356
Port 0: 0
Port 1: 0

Tap #2
--------------
Current Time: 2317
Port 0: 0
Port 1: 0
Current Time: 2361
Port 0: 0
Port 1: 492
Current Time: 2407
Port 0: 0
Port 1: 8
Current Time: 2450
Port 0: 0
Port 1: 0

Tap #3
------------------
Current Time: 3411
Port 0: 0
Port 1: 0
Current Time: 3456
Port 0: 0
Port 1: 348
Current Time: 3501
Port 0: 0
Port 1: 0
Again not sure about the low read. I can only assume that the decay is so fast that I'm just catching the hit either a bit early or late.
By Mee_n_Mac
#159203
warcher1 wrote:Again not sure about the low read. I can only assume that the decay is so fast that I'm just catching the hit either a bit early or late.
Good idea disconnecting the detector from the MUX ! I think that shows the effect is crosstalk through the MUX. I notice the loooooong decay time is not present in the above data, so I'll chalk that up to having a really big resistance on the input side of the MUX ... big as in nearly infinite due to the disconnected resistor. Lastly I think the the mismatch in magnitudes between the channels may be due to the sample interval. As you noted, sometimes you get a big voltage, sometimes not. What I think is happening is the voltage is sometimes there and gone before the ADC gets to sample it and the same effect is making it look like the secondary (un-hit) channel has a bigger voltage than the primary (hit) channel that should be driving it. But it's only an appearance. If the sample interval was shorter we'd see the hit channel was always bigger than the crosstalk channel. It's just that their timing is a little different. I might come up with some quick sampling code to satisfy my curiosity but to get back to the big picture ... I think it's a proven theory that the piezo needs to "see" a large resistance to output a large enough voltage and any resistance that's "large enough" results in too much crosstalk. The end conclusion being that I don't see a way to make a simple passive envelope detector work. You need to have an op-amp or comparator. The piezo needs to see a high resistance to work, the MUX needs to see a low resistance to mitigate the crosstalk.
By warcher1
#159204
Yeah, you know... the loop I'm running in the sketch reads port 0 first and then por 1. So that would predispose the second reading to be smaller based on the decay from the capacitor. Makes sense. I'll run a test where I reverse those.
By Mee_n_Mac
#159205
Here's the Spice circuit I've been using very recently to generate the comparator results shown in prior posts. You should look at the detector portion. It's my belief that an LM339 (quad) can be used in place of the LT part in the simulation w/o any change in performance. The diodes (D1, D2) are there to prevent large negative spikes from the piezo from harming the comparator. The specs says the input voltage shouldn't go more than -0.3V below ground. The 1N914 really can't clamp it to that low a level (more like -0.6V) but that's the part used in the application note so I feel OK in sticking with it. You can substitute a lower drop Schottky diode if you wish. R1 and R2 are there to add a little protection (by limiting current) to the input should it be dragged low enough to induce "high" currents. I'm not sure if they are needed or not, I'll think some more on that. Now usually there would be another resistor pair, spanning btw Vcc and ground as a voltage divider, to set the reference voltage. But since you'd have 24 such circuits all using the same reference voltage, I think it wise to use some other means to set that voltage and save the 48 resistors. You could use a precision voltage reference somewhere in the neighborhood of 2.5 to 3.5 V but I don't see your usage as really needing precision here. I figure you could just use the 3.3V regulated output from the Arduino. The Rd and Cd are just like their namesakes in the envelope detector above. They form a simple RC circuit that is discharged when a hit is detected. What happens is the comparator has a open collector type output. It's a transistor that shorts to ground and so pulls the cap voltage to zero. When the hit goes away, the open collector acts like an open switch. The cap (Cd) now slowly charges up towards Vcc (5V in this case) via Rd. The bigger the cap and/or resistor, the longer it takes to get to Vcc. The product of RdxCd is called the time constant. The voltage rises according to an exponential curve (see wiki below) and you can figure out when it will be at any voltage as a function of that time constant. The result is the hit is stretched in time (just as it was with the envelope detector) and you can choose the time it's detectable by choosing the time constant and the voltage threshold that distinguishes "hit" from "no hit". So how long must a "hit" last for to be reliably detected by your normal code ?
(click on to open)
piezo_MUX_case5_comparatorCKT.jpg
http://en.wikipedia.org/wiki/RC_circuit ... iderations
You do not have the required permissions to view the files attached to this post.
By warcher1
#159209
I'm using 1n4004's now. Those should provide better negative voltage clamping right?

That circuit doesn't look to much more complicated than the envelope detector. I see you have detector 1 and detector 2 joined together on a single piezo. I assume that's an artifact of your testing of the model right?
By Mee_n_Mac
#159212
warcher1 wrote:I'm using 1n4004's now. Those should provide better negative voltage clamping right?
I'd say about the same. Both are "normal" silicon diodes and so when conducting drop somewhere between 0.6 and 0.7 V. I'd have to check the specs to see if there's any appreciable speed difference but I suspect that's really a non-issue for your usage.
warcher1 wrote:That circuit doesn't look to much more complicated than the envelope detector. I see you have detector 1 and detector 2 joined together on a single piezo. I assume that's an artifact of your testing of the model right?
Look at the tags with fine eye and you'll see that detector #1 is connected to piezo #1, which produces the voltage you saw above. Detector #2 is connected to the tag piezo #2 which is an inactive piezo; it's modeled just by the output resistance. I have my doubts as to whether that's wholly accurate but it's enough to keep detector #2 off. I'll try and drop by Radio Shack (gack) tomorrow and pick up a LM339 and a cheapo piezo buzzer to play with. I'm thinking that circuit is pretty close to what I need so some playtime is warranted to figure out any bugs.

And yes it's pretty simple, especially if you can use the 3.3V present to set the reference voltage for the comparators. And at $0.50 per IC not all that more $$s to do. You need 24 channels, that's 6 ICs and so an extra $3. The real PITA is having to re-wire stuff.

You're correct in saying (earlier) that having the output be a high when un-hit isn't a big advantage in your case. Your detectors are all on a board right next to the MUX and Arduino. It's unlikely that there will be a connection problem there. I'm pondering on how to make it detect an open from the piezo to the detector, basically make the open circuit trigger a hit condition. It might be just an extra resistor (1+M) tied from the piezo to Vcc. If that works out, would that be worth it to you ?**

**EDIT : If you wish, take your DMM and put it on the ohms function. Disconnect the + lead of a piezo (if you don't have another sitting around) and measure the DC resistance from + to - of the piezo. Reverse the probe leads and measure it from - to + as well (I doubt it'll be any different). Also if your DMM has a diode or "beep" setting for the ohms function, repeat those 2 measurements with that setting. The diode setting uses a higher current to measure the resistance (enough to bias a diode to be "on"). This will give me a good DC model for the piezo and let me know if adding something like a 5M pull-up will result in the open circuit detection scheme mentioned.

FYI - Here's a good basic page on comparator circuits.
http://home.cogeco.ca/~rpaisley4/Comparators.html
By warcher1
#159220
As a matter of fact I have several of these piezos laying around since I bought 30 of them for this project. I set my DMM to a range of 20 and got nothing on a loose piezo either + to - nor - to +.

My DMM does have some settings labeled 'A' with the DC symbol next to it. Is that what I need for the diode setting? I tried 2000u and 20m as the ranges and the piezo once again showed nothing.

Actually, I think being able to detect an open circuit would be valuable. My targets have cat5 wire tails that all plug into a circuit board. It would be nice to know when one of those lines goes bad.
By Mee_n_Mac
#159223
warcher1 wrote:My DMM does have some settings labeled 'A' with the DC symbol next to it. Is that what I need for the diode setting? I tried 2000u and 20m as the ranges and the piezo once again showed nothing.

Actually, I think being able to detect an open circuit would be valuable. My targets have cat5 wire tails that all plug into a circuit board. It would be nice to know when one of those lines goes bad.
The 'A' sound like it an amperage setting. Here's a simple DMM with it's settings marked up. Your will be different but should have somewhat similar markings. You can verify you've go the ohms setting by measuring one of you known resistors. I don't know if your DMM is auto-ranging or is manual (as shown below). If the resistance is too large for the setting chosen it may read 199.9 or flash or flash 199.9. You measure ohms with the probe leads plugged into the DMM in the same jacks as used to measure voltage. There's usually another jack to be used when measuring amperage.
(click on to open)
DMM.jpg
A simple pull-up resistor may get you the open wire detection. The value of that resistor should be at least 5x to maybe 10x what I hope you can measure for the piezo (which I expect to be perhaps 1M ohm).
You do not have the required permissions to view the files attached to this post.