Mayhew Labs MUX Shield issue

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:

Here is a pic showing the connections to the mux board:

warcher1:
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

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:

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:

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.

Just to be sure, your first test had this for the detector values:

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.

warcher1:
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.

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.

warcher1:
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:

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:

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.

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.

warcher1:
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.

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.

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)

http://en.wikipedia.org/wiki/RC_circuit … iderations

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?

warcher1:
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:
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

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.

warcher1:
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)

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).

That looks pretty similar to my DMM but I do not have the diode mode.

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).

So, does that mean the resistor might need to by 5m or 10m. Or are you saying the 1m resistor would be about 5x the piezo.

Also, just FYI… I went back and updated my posts on the Adafruit forum. That’s where I originally posted for suggestions about conditioning the piezo and Mike at Adafruit support suggested the diode/capacitor circuit. (Only later did I find out about the issue with the crosstalk on the MUX chip.)

Mike has made a suggestion on that board to place another resistor in series with the diode to charge the capacitor more slowly.

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.

What do you think about that strategy. It’s certainly easy to test.

warcher1:
So, does that mean the resistor might need to by 5m or 10m. Or are you saying the 1m resistor would be about 5x the piezo.

Look at the schematic below. I believe the piezo has some high resistance (Rp2) which I've been modelling as 1M ohm (=1000K). I hope it can be measured with an ohm meter. Then I would add R3 into the detector as shown below. That has a few effects. First, if there's no piezo attached for some reason, it will pull-up the - input terminal of the comparator to Vcc (5v). That's higher than the reference voltage at the + input and so the output of the comparator goes low. That's the "hit" condition and so your code, reading the state of all the detectors prior to activating the gallery, can say "Hey, there's a wire missing !". Now when you plug the piezo in, I'm hoping that the DC resistance or the piezo will form a voltage divider with the newly added R3. This divider will place a voltage on the -input and I want that voltage to be much less than the reference voltage so that the comparator output will be a high (no hit). That will be the case when R3 >> Rp2. So if Rp2 measures 1M, then R3 might be 5M or even 10M.

FYI : http://en.wikipedia.org/wiki/Voltage_divider

Normally you’d have to include the “resistance” of the diode and -input as well. But in this case those resistances are so much larger than even 10M that, as a practical matter, you can assume they aren’t there to do the divider calcs. That’s not always the case.

warcher1:
What do you think about that strategy. It’s certainly easy to test.

My prediction is that what he said will be true. The cap will charge up more slowly and to a lesser value. But then it discharges through the ADC only and so will also have the long discharge time you saw when the resistor was (apparently) not connected. That might be a good or bad thing for you. But I predict the crosstalk problem will still remain. Give it shot, it's easy enough to test and I always favor test results over theory.

EDIT to add :

If I’ve understood the idea, the detector would look like this ?

I’ve added R3 in series with the diode. What’s perhaps not immediately apparent is that R3 is also in series with the output resistance of the piezo. Resistor in series act like 1 resistor whose value is the sum. So if Rpiezo is 1M then adding 10k or even 100k (as shown) makes only a little difference. Adding 1M would double the charge up time constant. Of course another way to do that would be to double the capacitance, from 47pF to ~100pF (also as shown above). You’ve already played with that and so have an idea of what the test result would be.

Yes, that’s the placement I understand as being “in series”. He said it wouldn’t matter if it was before or after the diode… which makes sense to me. (But if placed before won’t it potentially affect the diode bias? Probably only if the resistor is too big.) I think the placement is a little different from the 1m resistor though isn’t it? The 1m is across ground and positive which makes it a voltage divider. Whereas this new resistor is inline so it just reduces the current across the capacitor and i/o port.