SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By warcher1
#159113
you'd need a way to combine all the targets outputs into 1 or 2 interrupt signals (1 per gun ?).
The MCP23017 was the mux chip that I primarily looked at, and I actually have 4 of them on hand right now. (Enough for replacements if one blows out during an event.) Each chip actually has 16 ports and 2 interrupt pins so each gun could have 2 interrupts... one for every 6 targets.

But if I'm remembering right the Uno only has 2 interrupts. Although I've read that all of the pins can be configured to have interrupts if you twiddle the registers. I do have a spare Uno on hand just in case the full processing load of 24 targets and two guns was too much for a single one. I could use one Uno for each gun.

Sigh... yes, I was trying to run the entire range with a single Uno. That would have given me some bragging rights at Maker Faire and I thought the MUX and PWM boards might make it achievable. But I realize it might be a bit of a stretch and I picked up a spare to fall back on.
By warcher1
#159120
Okay, I have an explanation for the weird test this morning. Maybe just chalk it up to caffeine deficiency.

The first port had the 100k resistor removed and the second port didn't. So, of course the first port hit 1023 easily. But since the second port had the resistor there really was a good reason not to have the crosstalk. Unfortunately because the resistor is bleeding off the cap too quickly I never get a reading from it so it just registered 0's and therefore my sketch wouldn't move on to the next target. It makes sense to me now.

So, I picked up some smaller resistors on the way home and I'm going to try them now (22 ohm and 10 ohm.)
By Mee_n_Mac
#159122
warcher1 wrote:So, I picked up some smaller resistors on the way home and I'm going to try them now (22 ohm and 10 ohm.)
Errrr, what for ?
By warcher1
#159123
Nope, no luck with either of those resistor values. I've tried as many different things as I could think of (no 1m resistor... replacing the 1m with the 100k... putting the 1m resistor at the port end. Anytime there is a resistor across the GND and I/O port lines I get solid 0 reads. No matter how hard I hit the piezos it always reads 0.

Now, as promised here is my code:
Code: Select all
// Ping Pong Arcade
// by WARCHER1 <http://thundermoon.com>
// This code runs the Arduino fire rate control on the Ping Pong Arcade shooting gallery
// and also controls the targets

#include <Servo.h>
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

//Give convenient names to the control pins for the target sensor MUX
#define CONTROL0 5    
#define CONTROL1 4
#define CONTROL2 3
#define CONTROL3 2
#define SERVOINDEXPOS 80
#define SERVOLOADPOS 35
#define SERVOSWEEPDELAY 170
#define TRIGGER1PIN 11
#define TRIGGER2PIN 12
#define SERVO1PIN 10
#define SERVO2PIN 9
#define NUMTARGETS 2
#define SENSORTHRESHOLD 400

Servo gunServo1;
Servo gunServo2;
boolean gun1Button = HIGH;
boolean gun2Button = HIGH;
unsigned long gun1Time = 0;
unsigned long CurrentTime;
boolean gun1Cycle = false;
unsigned long gun2Time = 0;
boolean gun2Cycle = false;
int target1Flash = 0;
int target2Flash = 0;
int gun1TargetHit = 0;
int gun2TargetHit = 0;
int gun1ActiveTarget = 0;
int gun2ActiveTarget = 0;
int gun1PrevTarget = 0;
int gun2PrevTarget = 0;
int gun1Score = 0;
int gun2Score = 0;
unsigned long target1FlashOnTime;
unsigned long target2FlashOnTime;

#define LEDOFF  0 // this is the 'minimum' pulse length count (out of 4096)
#define LEDON  4095 // this is the 'maximum' pulse length count (out of 4096)

// Init the driver board for the Target LEDs
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver();
  
void setup()
{
  Serial.begin(9600);
  //Set MUX control pins to output
  pinMode(CONTROL0, OUTPUT);
  pinMode(CONTROL1, OUTPUT);
  pinMode(CONTROL2, OUTPUT);
  pinMode(CONTROL3, OUTPUT);

  pinMode(TRIGGER1PIN, INPUT);
  pinMode(TRIGGER2PIN, INPUT);
  digitalWrite(TRIGGER1PIN, INPUT_PULLUP);
  digitalWrite(TRIGGER2PIN, INPUT_PULLUP);
  gunServo1.attach(SERVO1PIN);
  gunServo2.attach(SERVO2PIN);
  gunServo1.write(SERVOINDEXPOS);
  gunServo2.write(SERVOINDEXPOS);
  pwm1.begin();
  pwm1.setPWMFreq(1600);  // This is the maximum PWM frequency
  for (int thisTarget = 0; thisTarget < 8; thisTarget++) {
    pwm1.setPWM(thisTarget, 0, LEDOFF);
  }
}

void loop()
{
  gun1Button = digitalRead(TRIGGER1PIN);
  CurrentTime = millis();
  Serial.print("gun1PrevTarget: ");
  Serial.print(gun1PrevTarget);
  Serial.print(" gun1ActiveTarget: ");
  Serial.print(gun1ActiveTarget);
  Serial.print(" target1Flash: ");
  Serial.print(target1Flash);
  Serial.print(" millis: ");
  Serial.print(CurrentTime);
  Serial.print(" gun1Score: ");
  Serial.println(gun1Score);
  
  pwm1.setPWM(gun1ActiveTarget, 0, LEDON);
  
  switch (target1Flash) {
    case 1:
    case 3:
    case 5:
      pwm1.setPWM(gun1PrevTarget, 0, LEDOFF);
      delay(100);
      target1Flash++;
      break;
    case 2:
    case 4:
    case 6:
      pwm1.setPWM(gun1PrevTarget, 0, LEDOFF);
      delay(100);
      pwm1.setPWM(gun1ActiveTarget, 0, LEDON);
      target1Flash++;
      break;
    case 7:
      target1Flash = 0;
      pwm1.setPWM(gun1PrevTarget, 0, LEDOFF);
      pwm1.setPWM(gun1ActiveTarget, 0, LEDON);
      break;
    default:
      ;
  }

  gun1TargetHit = readTarget(gun1ActiveTarget);
  Serial.print("piezo: ");
  Serial.println(gun1TargetHit);
  if (gun1TargetHit > SENSORTHRESHOLD) {
    target1Flash++;
    gun1Score += 100;
    gun1PrevTarget = gun1ActiveTarget;
    gun1ActiveTarget++;
    if (gun1ActiveTarget == NUMTARGETS) gun1ActiveTarget = 0;
    Serial.println("Hit");
  }
  
  if (gun1Button == LOW)    // If the button is pressed feed a ball into the venturi by starting a fire cycle
  {                         // A fire cycle is 1 move to the Load Position, 1 wait for servo sweep time, and 1 move
                            // back to the index position (balls blocked)
    if (gun1Cycle == false)  // Check to see if we're already in a fire cycle
    {
      gun1Cycle = true;      // If we're not in a fire cycle start one.
      gun1Time = CurrentTime;
    }
  }
  
  if (gun1Cycle == true)    // If we're in a fire cycle
  {
    if (CurrentTime >= gun1Time + (SERVOSWEEPDELAY * 2))  // If the cycle time has been exceeded then exit the fire cycle
    {
      gun1Cycle = false;
    }
    else if (CurrentTime >= gun1Time + SERVOSWEEPDELAY)  // If we're past the sweep time then return to the index position
    {
      gunServo1.write(SERVOINDEXPOS);
    }
    else if (CurrentTime < gun1Time + SERVOSWEEPDELAY)  // If we're within one sweep time then set it to the load position
    {
      gunServo1.write(SERVOLOADPOS);
    }
  }
  
  gun2Button = digitalRead(TRIGGER2PIN);
  CurrentTime = millis();

  if (gun2Button == LOW)  // If the button is pressed feed a ball into the venturi
  {
    if (gun2Cycle == false)
    {
      gun2Cycle = true;
      gun2Time = CurrentTime;
    }
  }
  
  if (gun2Cycle == true)
  {
    if (CurrentTime >= gun2Time + (SERVOSWEEPDELAY * 2))
    {
      gun2Cycle = false;
    }
    else if (CurrentTime >= gun2Time + SERVOSWEEPDELAY)
    {
      gunServo2.write(SERVOINDEXPOS);
    }
    else if (CurrentTime < gun2Time + SERVOSWEEPDELAY)
    {
      gunServo2.write(SERVOLOADPOS);
    }
  }  
}

int readTarget(int targetnum)
{
  Serial.print("targetnum: ");
  Serial.println(targetnum);
  
  //The following 4 commands set the correct logic for the control pins to select the desired input
  digitalWrite(CONTROL0, (targetnum&15)>>3); 
  digitalWrite(CONTROL1, (targetnum&7)>>2);  
  digitalWrite(CONTROL2, (targetnum&3)>>1);  
  digitalWrite(CONTROL3, (targetnum&1));     
    
  //Read and store the input value at a location in the array
  // analogRead(<<mux number>>);
  return analogRead(2);
//  return analogRead(targetnum);
}
By Mee_n_Mac
#159127
warcher1 wrote:I was trying to see if sizing the resistor would get some signal. Guessing that's wrong?
My thinking is that if 100k kills the signal, anything smaller is just going to be worse (or just as bad, zero is zero). From what I've read, a piezo can't source much current. It needs to "see" a high resistance if it were to look at the circuit attached to it. What it sees in your original circuit was a 1 Mohm resistor (which qualifies as high in my book) and then a diode and cap in parallel with that resistor. Initially that cap looks like a small resistor, before the cap gets charged up. Then as the cap gets charged up, as the voltage on it rises, the current going into it gets smaller. It looks to the piezo, like a bigger resistor as the current gets smaller.

When I added a 100k, it was basically in parallel with the 1 Mohm. That combo looks like a smaller than 100k resistor (90.9k). I knew that would reduce the voltage. In fact I wanted it too as I figured the 10's to 100's of volts that the piezo can produce was too big for the Arduino to handle. Adding a "big" (compared to 47 pF) cap only added to the reduction. And apparently that combo, or even just the 100k, is too much for the piezo to drive. From what you've seen with your experiments so far, either results in a very small voltage.

One advantage of the op-amp circuit is that it presents a high resistance to the piezo, independent of the envelope detector's time constant. That means, for better or worse, the piezo makes it's maximum voltage. The trick is then to make sure that voltage doesn't damage, like an ESD shock, the op-amp. In the link you provided a Zener diode and another diode (BAT85) were to prevent the voltage from being much larger than 5.1V above ground or -0.4V below ground.
By Mee_n_Mac
#159129
warcher1 wrote:Now, as promised here is my code:
Obviously there's a lot more in there than is needed to do some investigation into the piezo. So let me make a suggestion. Code up a very slimmed down version that does just the following:
- allow you to select just 1 port to sample
- samples that port as quickly as possible
- compares the sample to a threshold (as you do now)
- if the sample is > threshold, println just the piezo reading
- continue printing the sample value until it's less than a new, "low" threshold (perhaps 100)

Capture the serial output as you have been doing and post as a text file. I'd up the baud rate from 9600 to at least 38,400. That should get you a little under 1 msec between samples. This will give a very detailed view of what the envelope detector is doing. If you want, have an option to sample and print a second channel. The reason I'm asking for this is that I'm wondering if the present scheme isn't missing a short pulse. Right now I'd rather "see" what's happening with your original 1 M and 47 pF, then 1M-(diode)-100k and 47 pF, then perhaps some other R's and C ... than to know if that pulse can be detected via your normal program. Again the big picture is to see if there isn't a way to lower the resistance "seen" looking at the circuitry from the MUX input back into the detector output. When that resistance is low enough, the crosstalk is reduced. Alas lowering that resistance means decreasing the effective piezo output. Before admitting defeat and going to added circuitry (op-amps) I'd like to be sure there isn't some happy compromise. If there's just no usable output at 100k to maybe 250k, then it's time to add more stuff. At 250k the crosstalk is about 15% of the hit channels magnitude (per the sim). Much larger resistance and the crosstalk is perhaps too large.

We can benchmark the timing and get an approximate idea of the sample interval, so printing the timing is not needed and just slows down the sampling.
By Mee_n_Mac
#159139
Here's a short test matrix to try with the Super Sampling Software. If you can't catch a signal with one of the non-original combo's below (or one you can think of) then it's time to admit defeat on the purely passive fix front. At least I'm out of ideas to try.
EnvelopeDetectorCKT.jpg
test_table.jpg
If you can get some non-zero signal repeatably on the "hit" channel (other than #1), then switch to non-hit channel (with the same detector setup on both channels) and see what the crosstalk is.
You do not have the required permissions to view the files attached to this post.
By warcher1
#159140
Code up a very slimmed down version that does just the following
I have exactly that sketch. It's what I used to analyze the length of the piezo envelope, both the raw signal and the length of the envelope for each value of capacitor that I tested.

I'll cobble up these tests and report back. I may not be able get to it until tomorrow though. I have a Maker meeting tonight to work on the details of our next showing of this project.
By warcher1
#159142
anything smaller is just going to be worse
Well, this is just a symptom of my newbishness to electronics. My thought process was that if we saw high signal with no resistor and no signal with 100k then there must be a value in between that gave us the right signal level.
By Mee_n_Mac
#159144
Here's a principle that will help you then.
http://en.wikipedia.org/wiki/Ohm%27s_law
Think of it this way, a resistor resists the flow of current, like an obstruction in a pipe resists the flow of water. The bigger the resistance, the less flow. When there's no flow the resistance is infinite. So no resistor in place means there's no flow of current and so an infinite resistance. A 1 M resistor is like a small pipe, perhaps a straw. A 100k is a fat straw. A 1k a garden hose. A 100 ohm a fire hose. A 1 ohm is a city water main. A short circuit is the biggest river in the world.
By warcher1
#159145
Yes, I can see know how my logic was backwards. The resistor in between the cap and the I/O port works like a voltage divider right? When there was no resistor the only path the current could take was through the port. And once the resistor is in place it gives a path for the current to be shunted to ground. The less resistance across that path the more current will go to ground instead of the port.
By Mee_n_Mac
#159149
warcher1 wrote:Yes, I can see know how my logic was backwards. The resistor in between the cap and the I/O port works like a voltage divider right? When there was no resistor the only path the current could take was through the port. And once the resistor is in place it gives a path for the current to be shunted to ground. The less resistance across that path the more current will go to ground instead of the port.
You got it ! For DC circuits the water in the pipe analog works pretty well. Voltage corresponds to pump pressure. Current is the flow rate of water. And water is the electrons, the electricity. More pressure generally means more flow as so a higher voltage means more current. Bigger pipes (less resistance) means more flow (current) for a given pressure (voltage).
By Mee_n_Mac
#159173
I did some looking around and couldn't find a quad package 1 shot timer. National did make a 558 but it's not available anymore. However that did get me thinking about using a quad comparator instead of a 1 shot or op-amp design. The comparator would be like a 1 shot design except that the output pulsewidth (PW) wouldn't be strictly set by some RC time constant. Instead, like the envelope detector, the RC time constant would result in a slowly changing voltage. For my usage in my AS target system, that's not an issue as I'm driving interrupt(s) with the output(s). In your case ... well it's no different from what you have now (except it won't have the crosstalk problem).

The design can use the very common, industry standard LM339 comparator. It's readily available in a DIP, quad comparators to 1 IC, and only $0.40 - $0.50 at DigiKey (and probably everywhere). I've not quite figured out all the proper components so I'll hold off posting the circuit but here are the 2 results plots (using LT's equivalent comparator). Two things to note that are different from before; first is I ginned up a more realistic piezo output voltage (should be obvious from the plot) and secondly the output now goes low (instead of high) when the hit occurs. That means your detection algorithm would have to change from looking for a voltage above some threshold to looking for a voltage below some threshold. No biggie IMO. I'll leave the reason why that is for latter but will point out it has one advantage (IMO) over your existing design or even the op-amp design. Because that voltage is present whenever power is applied and w/o a hit, it allows the code to run a built-in-test (BIT) to check for problems. In this case BIT can verify that all the connections are connected, which will detect the most common fault (broken wire). It's an advantage that's not to be underestimated when tearing down and setting up a system.

This plot shows the case where the hit channel is selected by the MUX to go to the Arduino ADC. You can see the other channel is unaffected by the hit (no x-talk) and that after the hit is gone, the "low" pulse is stretched out and slowly (over msecs) comes back to 5v. The length of time that hit would be detectable by a polling scheme would be determined by the RC constant and the threshold used. Making it longer isn't a problem.
piezo_MUX_case5a_comparator.jpg
This plot show the voltages when the un-hit channel is selected by the MUX. It more clearly shows the lack of the crosstalk problem. The selected channel's voltage is a constant 5v. Click on plots to open and enlarge.
piezo_MUX_case5b_comparator.jpg
You do not have the required permissions to view the files attached to this post.
By warcher1
#159175
Looks like your plots didn't post... there's just a filename.

I like the idea of the line being high by default instead of low. It would be good to be able to detect a line fault. But I'm wondering if that means the comparator would have to be housed at the target. Not a problem really... just curious.

I tested some larger resistors this morning and here is what I found. Just to be clear I used the 1m, 1n4004, .01mf setup as before and just changed the resistor between the cap and the port. The 220k resistor gave 0's across the board. So I tried a 470k resistor and began to get some signal. Most readings were under 10. I didn't have anything between that and a 1m resistor so I flipped a 1m in to see how it would do and here are the results... with 1 hit on piezo 1, a pause and then a hit on the second piezo.
Code: Select all
Current Time: 750
Port 0: 0
Port 1: 0
Current Time: 793
Port 0: 0
Port 1: 0
Current Time: 835
Port 0: 220
Port 1: 232
Current Time: 882
Port 0: 1023
Port 1: 10
Current Time: 929
Port 0: 1023
Port 1: 7
Current Time: 974
Port 0: 1023
Port 1: 7
Current Time: 1020
Port 0: 1011
Port 1: 8
Current Time: 1068
Port 0: 997
Port 1: 7
Current Time: 1113
Port 0: 984
Port 1: 6
Current Time: 1159
Port 0: 970
Port 1: 7
Current Time: 1205
Port 0: 959
Port 1: 7
Current Time: 1250
Port 0: 945
Port 1: 6
Current Time: 1296
Port 0: 932
Port 1: 5
Current Time: 1342
Port 0: 921
Port 1: 6
Current Time: 1387
Port 0: 911
Port 1: 7
Current Time: 1433
Port 0: 899
Port 1: 6
Current Time: 1479
Port 0: 886
Port 1: 5
Current Time: 1525
Port 0: 875
Port 1: 6
Current Time: 1570
Port 0: 865
Port 1: 6
Current Time: 1616
Port 0: 853
Port 1: 5
Current Time: 1662
Port 0: 841
Port 1: 4
Current Time: 1708
Port 0: 833
Port 1: 5
Current Time: 1754
Port 0: 823
Port 1: 6
Current Time: 1800
Port 0: 812
Port 1: 4
Current Time: 1845
Port 0: 800
Port 1: 4
Current Time: 1891
Port 0: 791
Port 1: 5
Current Time: 1937
Port 0: 782
Port 1: 5
Current Time: 1982
Port 0: 771
Port 1: 4
Current Time: 2028
Port 0: 760
Port 1: 4
Current Time: 2074
Port 0: 750
Port 1: 4
Current Time: 2119
Port 0: 742
Port 1: 5
Current Time: 2165
Port 0: 731
Port 1: 4
Current Time: 2211
Port 0: 721
Port 1: 3
Current Time: 2257
Port 0: 713
Port 1: 4
Current Time: 2302
Port 0: 703
Port 1: 4
Current Time: 2349
Port 0: 693
Port 1: 3
Current Time: 2395
Port 0: 682
Port 1: 3
Current Time: 2440
Port 0: 675
Port 1: 4
Current Time: 2486
Port 0: 666
Port 1: 4
Current Time: 2532
Port 0: 657
Port 1: 3
Current Time: 2577
Port 0: 646
Port 1: 3
Current Time: 2623
Port 0: 638
Port 1: 4
Current Time: 2669
Port 0: 631
Port 1: 4
Current Time: 2714
Port 0: 622
Port 1: 2
Current Time: 2760
Port 0: 613
Port 1: 3
Current Time: 2806
Port 0: 604
Port 1: 3
Current Time: 2851
Port 0: 596
Port 1: 3
Current Time: 2897
Port 0: 586
Port 1: 2
Current Time: 2944
Port 0: 578
Port 1: 2
Current Time: 2990
Port 0: 571
Port 1: 3
Current Time: 3035
Port 0: 564
Port 1: 3
Current Time: 3081
Port 0: 555
Port 1: 2
Current Time: 3127
Port 0: 545
Port 1: 2
Current Time: 3172
Port 0: 539
Port 1: 3
Current Time: 3218
Port 0: 532
Port 1: 3
Current Time: 3264
Port 0: 523
Port 1: 1
Current Time: 3309
Port 0: 515
Port 1: 2
Current Time: 3355
Port 0: 509
Port 1: 3
Current Time: 3401
Port 0: 501
Port 1: 2
Current Time: 3446
Port 0: 493
Port 1: 1
Current Time: 3492
Port 0: 484
Port 1: 2
Current Time: 3538
Port 0: 478
Port 1: 2
Current Time: 3584
Port 0: 472
Port 1: 2
Current Time: 3630
Port 0: 464
Port 1: 1
Current Time: 3676
Port 0: 456
Port 1: 1
Current Time: 3722
Port 0: 450
Port 1: 2
Current Time: 3767
Port 0: 444
Port 1: 1
Current Time: 3813
Port 0: 436
Port 1: 1
Current Time: 3859
Port 0: 429
Port 1: 1
Current Time: 3904
Port 0: 422
Port 1: 2
Current Time: 3950
Port 0: 416
Port 1: 1
Current Time: 3996
Port 0: 409
Port 1: 1
Current Time: 4041
Port 0: 402
Port 1: 1
Current Time: 4087
Port 0: 396
Port 1: 2
Current Time: 4133
Port 0: 390
Port 1: 1
Current Time: 4178
Port 0: 383
Port 1: 0
Current Time: 4225
Port 0: 376
Port 1: 1
Current Time: 4271
Port 0: 371
Port 1: 1
Current Time: 4316
Port 0: 365
Port 1: 0
Current Time: 4362
Port 0: 358
Port 1: 0
Current Time: 4408
Port 0: 352
Port 1: 1
Current Time: 4454
Port 0: 346
Port 1: 1
Current Time: 4499
Port 0: 340
Port 1: 0
Current Time: 4545
Port 0: 334
Port 1: 0
Current Time: 4591
Port 0: 328
Port 1: 1
Current Time: 4636
Port 0: 324
Port 1: 1
Current Time: 4682
Port 0: 318
Port 1: 0
Current Time: 4728
Port 0: 311
Port 1: 0
Current Time: 4773
Port 0: 306
Port 1: 0
Current Time: 4819
Port 0: 301
Port 1: 1
Current Time: 4866
Port 0: 295
Port 1: 0
Current Time: 4911
Port 0: 289
Port 1: 0
Current Time: 4957
Port 0: 284
Port 1: 0
Current Time: 5003
Port 0: 280
Port 1: 0
Current Time: 5048
Port 0: 274
Port 1: 0
Current Time: 5094
Port 0: 268
Port 1: 0
Current Time: 5140
Port 0: 264
Port 1: 0
Current Time: 5186
Port 0: 260
Port 1: 0
Current Time: 5231
Port 0: 254
Port 1: 0
Current Time: 5277
Port 0: 248
Port 1: 0
Current Time: 5323
Port 0: 244
Port 1: 0
Current Time: 5368
Port 0: 240
Port 1: 0
Current Time: 5414
Port 0: 234
Port 1: 0
Current Time: 5460
Port 0: 229
Port 1: 0
Current Time: 5506
Port 0: 225
Port 1: 0
Current Time: 5552
Port 0: 221
Port 1: 0
Current Time: 5598
Port 0: 216
Port 1: 0
Current Time: 5643
Port 0: 211
Port 1: 0
Current Time: 5689
Port 0: 207
Port 1: 0
Current Time: 5735
Port 0: 203
Port 1: 0
Current Time: 5780
Port 0: 198
Port 1: 0
Current Time: 5826
Port 0: 193
Port 1: 0
Current Time: 5872
Port 0: 190
Port 1: 0
Current Time: 5918
Port 0: 186
Port 1: 0
Current Time: 5963
Port 0: 181
Port 1: 0
Current Time: 6009
Port 0: 177
Port 1: 0
Current Time: 6055
Port 0: 174
Port 1: 0
Current Time: 6100
Port 0: 170
Port 1: 0
Current Time: 6147
Port 0: 165
Port 1: 0
Current Time: 6193
Port 0: 161
Port 1: 0
Current Time: 6238
Port 0: 158
Port 1: 0
Current Time: 6284
Port 0: 154
Port 1: 0
Current Time: 6330
Port 0: 150
Port 1: 0
Current Time: 6375
Port 0: 146
Port 1: 0
Current Time: 6421
Port 0: 143
Port 1: 0
Current Time: 6467
Port 0: 140
Port 1: 0
Current Time: 6512
Port 0: 136
Port 1: 0
Current Time: 6558
Port 0: 132
Port 1: 0
Current Time: 6604
Port 0: 129
Port 1: 0
Current Time: 6650
Port 0: 126
Port 1: 0
Current Time: 6695
Port 0: 121
Port 1: 0
Current Time: 6742
Port 0: 118
Port 1: 0
Current Time: 6788
Port 0: 116
Port 1: 0
Current Time: 6833
Port 0: 113
Port 1: 0
Current Time: 6879
Port 0: 108
Port 1: 0
Current Time: 6925
Port 0: 105
Port 1: 0
Current Time: 6970
Port 0: 103
Port 1: 0
Current Time: 7016
Port 0: 100
Port 1: 0
Current Time: 7062
Port 0: 97
Port 1: 0
Current Time: 7106
Port 0: 94
Port 1: 0
Current Time: 7151
Port 0: 91
Port 1: 0
Current Time: 7196
Port 0: 88
Port 1: 0
Current Time: 7240
Port 0: 85
Port 1: 0
Current Time: 7285
Port 0: 83
Port 1: 0
Current Time: 7330
Port 0: 79
Port 1: 0
Current Time: 7374
Port 0: 77
Port 1: 0
Current Time: 7419
Port 0: 75
Port 1: 0
Current Time: 7464
Port 0: 72
Port 1: 0
Current Time: 7508
Port 0: 69
Port 1: 0
Current Time: 7554
Port 0: 67
Port 1: 0
Current Time: 7599
Port 0: 65
Port 1: 0
Current Time: 7643
Port 0: 62
Port 1: 0
Current Time: 7688
Port 0: 60
Port 1: 0
Current Time: 7733
Port 0: 58
Port 1: 0
Current Time: 7777
Port 0: 55
Port 1: 0
Current Time: 7822
Port 0: 53
Port 1: 0
Current Time: 7867
Port 0: 51
Port 1: 0
Current Time: 7911
Port 0: 48
Port 1: 0
Current Time: 7956
Port 0: 47
Port 1: 0
Current Time: 8001
Port 0: 45
Port 1: 0
Current Time: 8046
Port 0: 42
Port 1: 0
Current Time: 8090
Port 0: 40
Port 1: 0
Current Time: 8135
Port 0: 39
Port 1: 0
Current Time: 8180
Port 0: 37
Port 1: 0
Current Time: 8224
Port 0: 35
Port 1: 0
Current Time: 8269
Port 0: 34
Port 1: 0
Current Time: 8314
Port 0: 32
Port 1: 0
Current Time: 8358
Port 0: 30
Port 1: 0
Current Time: 8403
Port 0: 29
Port 1: 0
Current Time: 8449
Port 0: 27
Port 1: 0
Current Time: 8493
Port 0: 25
Port 1: 0
Current Time: 8538
Port 0: 24
Port 1: 0
Current Time: 8583
Port 0: 23
Port 1: 0
Current Time: 8627
Port 0: 20
Port 1: 0
Current Time: 8672
Port 0: 20
Port 1: 0
Current Time: 8717
Port 0: 18
Port 1: 0
Current Time: 8761
Port 0: 16
Port 1: 0
Current Time: 8806
Port 0: 16
Port 1: 0
Current Time: 8851
Port 0: 15
Port 1: 0
Current Time: 8895
Port 0: 13
Port 1: 0
Current Time: 8940
Port 0: 12
Port 1: 0
Current Time: 8985
Port 0: 12
Port 1: 0
Current Time: 9029
Port 0: 10
Port 1: 0
Current Time: 9074
Port 0: 9
Port 1: 0
Current Time: 9118
Port 0: 9
Port 1: 0
Current Time: 9161
Port 0: 7
Port 1: 0
Current Time: 9205
Port 0: 7
Port 1: 0
Current Time: 9249
Port 0: 6
Port 1: 0
Current Time: 9292
Port 0: 5
Port 1: 0
Current Time: 9336
Port 0: 5
Port 1: 0
Current Time: 9380
Port 0: 4
Port 1: 0
Current Time: 9423
Port 0: 3
Port 1: 0
Current Time: 9467
Port 0: 4
Port 1: 0
Current Time: 9511
Port 0: 2
Port 1: 0
Current Time: 9554
Port 0: 2
Port 1: 0
Current Time: 9598
Port 0: 2
Port 1: 0
Current Time: 9641
Port 0: 1
Port 1: 0
Current Time: 9686
Port 0: 2
Port 1: 0
Current Time: 9730
Port 0: 1
Port 1: 0
Current Time: 9773
Port 0: 1
Port 1: 0
Current Time: 9817
Port 0: 1
Port 1: 0
Current Time: 9861
Port 0: 0
Port 1: 0
Current Time: 9904
Port 0: 0
Port 1: 0
Current Time: 9948
Port 0: 0
Port 1: 0
Current Time: 9992
Port 0: 0
Port 1: 0
Current Time: 10035
Port 0: 0
Port 1: 0
Current Time: 10080
Port 0: 0
Port 1: 0
Current Time: 10125
Port 0: 0
Port 1: 0
Current Time: 10169
Port 0: 0
Port 1: 0
Current Time: 10214
Port 0: 0
Port 1: 0
Current Time: 10259
Port 0: 0
Port 1: 0
Current Time: 10303
Port 0: 0
Port 1: 0
Current Time: 10348
Port 0: 0
Port 1: 0
Current Time: 10393
Port 0: 0
Port 1: 0
Current Time: 10437
Port 0: 0
Port 1: 0
Current Time: 10482
Port 0: 0
Port 1: 0
Current Time: 10527
Port 0: 0
Port 1: 0
Current Time: 10571
Port 0: 0
Port 1: 0
Current Time: 10616
Port 0: 0
Port 1: 0
Current Time: 10661
Port 0: 0
Port 1: 0
Current Time: 10705
Port 0: 0
Port 1: 0
Current Time: 10750
Port 0: 0
Port 1: 0
Current Time: 10796
Port 0: 0
Port 1: 0
Current Time: 10840
Port 0: 0
Port 1: 0
Current Time: 10885
Port 0: 1023
Port 1: 778
Current Time: 10935
Port 0: 990
Port 1: 14
Current Time: 10983
Port 0: 973
Port 1: 6
Current Time: 11029
Port 0: 960
Port 1: 6
Current Time: 11076
Port 0: 945
Port 1: 6
Current Time: 11123
Port 0: 932
Port 1: 6
Current Time: 11169
Port 0: 922
Port 1: 7
Current Time: 11216
Port 0: 909
Port 1: 6
Current Time: 11264
Port 0: 897
Port 1: 5
Current Time: 11311
Port 0: 884
Port 1: 5
Current Time: 11357
Port 0: 873
Port 1: 6
Current Time: 11404
Port 0: 861
Port 1: 6
Current Time: 11451
Port 0: 852
Port 1: 6
Current Time: 11497
Port 0: 840
Port 1: 5
Current Time: 11544
Port 0: 828
Port 1: 4
Current Time: 11591
Port 0: 818
Port 1: 5
Current Time: 11637
Port 0: 807
Port 1: 5
Current Time: 11684
Port 0: 798
Port 1: 5
Current Time: 11731
Port 0: 787
Port 1: 5
Current Time: 11779
Port 0: 775
Port 1: 4
Current Time: 11825
Port 0: 766
Port 1: 4
Current Time: 11872
Port 0: 756
Port 1: 4
Current Time: 11919
Port 0: 747
Port 1: 5
Current Time: 11965
Port 0: 736
Port 1: 4
Current Time: 12012
Port 0: 726
Port 1: 3
Current Time: 12059
Port 0: 715
Port 1: 3
Current Time: 12106
Port 0: 707
Port 1: 4
Current Time: 12152
Port 0: 698
Port 1: 4
Current Time: 12199
Port 0: 688
Port 1: 4
Current Time: 12247
Port 0: 679
Port 1: 3
Current Time: 12293
Port 0: 668
Port 1: 3
Current Time: 12340
Port 0: 660
Port 1: 3
Current Time: 12387
Port 0: 651
Port 1: 4
Current Time: 12433
Port 0: 643
Port 1: 4
Current Time: 12480
Port 0: 633
Port 1: 3
Current Time: 12527
Port 0: 622
Port 1: 2
Current Time: 12574
Port 0: 615
Port 1: 3
Current Time: 12620
Port 0: 607
Port 1: 3
Current Time: 12667
Port 0: 599
Port 1: 3
Current Time: 12715
Port 0: 590
Port 1: 3
Current Time: 12761
Port 0: 580
Port 1: 2
Current Time: 12808
Port 0: 572
Port 1: 2
Current Time: 12855
Port 0: 564
Port 1: 3
Current Time: 12901
Port 0: 558
Port 1: 3
Current Time: 12948
Port 0: 548
Port 1: 2
Current Time: 12995
Port 0: 540
Port 1: 2
Current Time: 13042
Port 0: 531
Port 1: 2
Current Time: 13088
Port 0: 524
Port 1: 3
Current Time: 13135
Port 0: 518
Port 1: 3
Current Time: 13182
Port 0: 509
Port 1: 2
Current Time: 13229
Port 0: 501
Port 1: 1
Current Time: 13276
Port 0: 493
Port 1: 1
Current Time: 13323
Port 0: 486
Port 1: 2
Current Time: 13369
Port 0: 479
Port 1: 2
Current Time: 13416
Port 0: 472
Port 1: 2
Current Time: 13463
Port 0: 465
Port 1: 1
Current Time: 13510
Port 0: 456
Port 1: 1
Current Time: 13556
Port 0: 449
Port 1: 1
Current Time: 13603
Port 0: 443
Port 1: 2
Current Time: 13650
Port 0: 436
Port 1: 2
Current Time: 13697
Port 0: 429
Port 1: 1
Current Time: 13744
Port 0: 421
Port 1: 0
Current Time: 13791
Port 0: 415
Port 1: 1
Current Time: 13838
Port 0: 408
Port 1: 2
Current Time: 13884
Port 0: 402
Port 1: 2
Current Time: 13931
Port 0: 395
Port 1: 1
Current Time: 13978
Port 0: 388
Port 1: 0
Current Time: 14024
Port 0: 381
Port 1: 1
Current Time: 14071
Port 0: 375
Port 1: 1
Current Time: 14118
Port 0: 370
Port 1: 1
Current Time: 14164
Port 0: 363
Port 1: 1
Current Time: 14212
Port 0: 357
Port 1: 0
Current Time: 14259
Port 0: 350
Port 1: 0
Current Time: 14306
Port 0: 344
Port 1: 1
Current Time: 14352
Port 0: 339
Port 1: 1
Current Time: 14399
Port 0: 333
Port 1: 1
Current Time: 14446
Port 0: 327
Port 1: 0
Current Time: 14492
Port 0: 320
Port 1: 0
Current Time: 14539
Port 0: 315
Port 1: 0
Current Time: 14586
Port 0: 310
Port 1: 1
Current Time: 14632
Port 0: 305
Port 1: 0
Current Time: 14680
Port 0: 298
Port 1: 0
Current Time: 14727
Port 0: 292
Port 1: 0
Current Time: 14774
Port 0: 287
Port 1: 0
Current Time: 14820
Port 0: 282
Port 1: 0
Current Time: 14867
Port 0: 277
Port 1: 0
Current Time: 14914
Port 0: 272
Port 1: 0
Current Time: 14960
Port 0: 266
Port 1: 0
Current Time: 15007
Port 0: 261
Port 1: 0
Current Time: 15054
Port 0: 256
Port 1: 0
Current Time: 15101
Port 0: 252
Port 1: 0
Current Time: 15148
Port 0: 246
Port 1: 0
Current Time: 15195
Port 0: 241
Port 1: 0
Current Time: 15242
Port 0: 236
Port 1: 0
Current Time: 15288
Port 0: 231
Port 1: 0
Current Time: 15335
Port 0: 227
Port 1: 0
Current Time: 15382
Port 0: 222
Port 1: 0
Current Time: 15428
Port 0: 217
Port 1: 0
Current Time: 15475
Port 0: 212
Port 1: 0
Current Time: 15522
Port 0: 208
Port 1: 0
Current Time: 15569
Port 0: 204
Port 1: 0
Current Time: 15616
Port 0: 200
Port 1: 0
Current Time: 15663
Port 0: 195
Port 1: 0
Current Time: 15710
Port 0: 189
Port 1: 0
Current Time: 15756
Port 0: 186
Port 1: 0
Current Time: 15803
Port 0: 182
Port 1: 0
Current Time: 15850
Port 0: 178
Port 1: 0
Current Time: 15896
Port 0: 174
Port 1: 0
Current Time: 15943
Port 0: 169
Port 1: 0
Current Time: 15990
Port 0: 165
Port 1: 0
Current Time: 16037
Port 0: 162
Port 1: 0
Current Time: 16083
Port 0: 159
Port 1: 0
Current Time: 16131
Port 0: 154
Port 1: 0
Current Time: 16178
Port 0: 150
Port 1: 0
Current Time: 16224
Port 0: 146
Port 1: 0
Current Time: 16271
Port 0: 143
Port 1: 0
Current Time: 16318
Port 0: 139
Port 1: 0
Current Time: 16364
Port 0: 135
Port 1: 0
Current Time: 16411
Port 0: 131
Port 1: 0
Current Time: 16458
Port 0: 128
Port 1: 0
Current Time: 16505
Port 0: 124
Port 1: 0
Current Time: 16551
Port 0: 122
Port 1: 0
Current Time: 16599
Port 0: 118
Port 1: 0
Current Time: 16646
Port 0: 114
Port 1: 0
Current Time: 16692
Port 0: 111
Port 1: 0
Current Time: 16739
Port 0: 108
Port 1: 0
Current Time: 16786
Port 0: 105
Port 1: 0
Current Time: 16833
Port 0: 102
Port 1: 0
Current Time: 16879
Port 0: 99
Port 1: 0
Current Time: 16925
Port 0: 95
Port 1: 0
Current Time: 16971
Port 0: 92
Port 1: 0
Current Time: 17016
Port 0: 90
Port 1: 0
Current Time: 17062
Port 0: 86
Port 1: 0
Current Time: 17108
Port 0: 83
Port 1: 0
Current Time: 17154
Port 0: 81
Port 1: 0
Current Time: 17200
Port 0: 79
Port 1: 0
Current Time: 17246
Port 0: 75
Port 1: 0
Current Time: 17291
Port 0: 72
Port 1: 0
Current Time: 17337
Port 0: 70
Port 1: 0
Current Time: 17383
Port 0: 68
Port 1: 0
Current Time: 17428
Port 0: 65
Port 1: 0
Current Time: 17474
Port 0: 62
Port 1: 0
Current Time: 17520
Port 0: 60
Port 1: 0
Current Time: 17566
Port 0: 58
Port 1: 0
Current Time: 17611
Port 0: 55
Port 1: 0
Current Time: 17657
Port 0: 53
Port 1: 0
Current Time: 17703
Port 0: 51
Port 1: 0
Current Time: 17748
Port 0: 49
Port 1: 0
Current Time: 17795
Port 0: 46
Port 1: 0
Current Time: 17841
Port 0: 44
Port 1: 0
Current Time: 17886
Port 0: 43
Port 1: 0
Current Time: 17932
Port 0: 41
Port 1: 0
Current Time: 17978
Port 0: 38
Port 1: 0
Current Time: 18023
Port 0: 36
Port 1: 0
Current Time: 18069
Port 0: 35
Port 1: 0
Current Time: 18115
Port 0: 33
Port 1: 0
Current Time: 18160
Port 0: 31
Port 1: 0
Current Time: 18206
Port 0: 29
Port 1: 0
Current Time: 18252
Port 0: 28
Port 1: 0
Current Time: 18298
Port 0: 26
Port 1: 0
Current Time: 18343
Port 0: 24
Port 1: 0
Current Time: 18390
Port 0: 22
Port 1: 0
Current Time: 18436
Port 0: 22
Port 1: 0
Current Time: 18481
Port 0: 20
Port 1: 0
Current Time: 18527
Port 0: 18
Port 1: 0
Current Time: 18573
Port 0: 17
Port 1: 0
Current Time: 18618
Port 0: 16
Port 1: 0
Current Time: 18664
Port 0: 15
Port 1: 0
Current Time: 18710
Port 0: 13
Port 1: 0
Current Time: 18755
Port 0: 12
Port 1: 0
Current Time: 18801
Port 0: 11
Port 1: 0
Current Time: 18847
Port 0: 10
Port 1: 0
Current Time: 18892
Port 0: 8
Port 1: 0
Current Time: 18937
Port 0: 8
Port 1: 0
Current Time: 18982
Port 0: 8
Port 1: 0
Current Time: 19026
Port 0: 6
Port 1: 0
Current Time: 19072
Port 0: 5
Port 1: 0
Current Time: 19117
Port 0: 6
Port 1: 0
Current Time: 19162
Port 0: 4
Port 1: 0
Current Time: 19206
Port 0: 4
Port 1: 0
Current Time: 19251
Port 0: 4
Port 1: 0
Current Time: 19296
Port 0: 3
Port 1: 0
Current Time: 19340
Port 0: 1
Port 1: 0
Current Time: 19385
Port 0: 2
Port 1: 0
Current Time: 19430
Port 0: 1
Port 1: 0
Current Time: 19474
Port 0: 0
Port 1: 0
Current Time: 19519
Port 0: 1
Port 1: 0
Current Time: 19564
Port 0: 1
Port 1: 0
Current Time: 19608
Port 0: 0
Port 1: 0
Current Time: 19653
Port 0: 0
Port 1: 0
Current Time: 19698
Port 0: 0
Port 1: 0
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.

I'll upload photos of my breadboard in a minute... having a problem with my camera.