Skip to content

Step response

I decided to try out different way to detect ball rolling to a pinball bumper. This needs to be a solution, that is reliable, sturdy and long lasting.

The methods I tried include step response, shorting the signal through the ball (with and without a magnet), and a switch that ball rolls over.

Components

Version 1

I decided to try out a step response ring around a bumper. I found vinyl cuttable copper sheets, and I drew four circles in Inkscape.

Draw circle with size 26 mm. Duplicate with cmd+d. Resize to 36mm. Duplicate. Resize to 37mm. Duplicate. Resize to 47mm.

Cut the shape with vinyl cutter.

Taped them on a piece of HDF.

Took the code from Adrian Torres’s website for step response. Changed the pins to match my board, but otherwise mostly ran the code as is.

The Code
//tx_rx03  Robert Hart Mar 2019.
//https://roberthart56.github.io/SCFAB/SC_lab/Sensors/tx_rx_sensors/index.html

//Originally modified by Adrián Torres Omaña in Fab Academy 2021 
//Further edits made by Joni Rajala in Fab Academy 2024
//Step Response TX, RX

//  Program to use transmit-receive across space between two conductors.
//  One conductor attached to digital pin, another to analog pin.
//
//  This program has a function "tx_rx() which returns the value in a long integer.
//
//  Optionally, two resistors (1 MOhm or greater) can be placed between 5V and GND, with
//  the signal connected between them so that the steady-state voltage is 2.5 Volts.
//
//  Signal varies with electric field coupling between conductors, and can
//  be used to measure many things related to position, overlap, and intervening material
//  between the two conductors.
//

long last_result;
long min_value = LONG_MAX;
long max_value = LONG_MIN;
long result;   //variable for the result of the tx_rx measurement.

// the pins are defined for XIAO RP2040, using the pin numbers that Arduino IDE recognizes.
int analog_pin = 28; // pin used for reading the conductance
int tx_pin = 2; // automatically toggling pin

void setup() {
pinMode(tx_pin,OUTPUT);      //Pin 2 provides the voltage step
Serial.begin(115200);
}


long tx_rx(){         //Function to execute rx_tx algorithm and return a value
                      //that depends on coupling of two electrodes.
                      //Value returned is a long integer.
  int read_high;
  int read_low;
  int diff;
  long int sum;
  int N_samples = 1000;    //Number of samples to take.  Larger number slows it down, but reduces scatter.

  sum = 0;

  for (int i = 0; i < N_samples; i++){
  digitalWrite(tx_pin,HIGH);              //Step the voltage high on conductor 1.
  read_high = analogRead(analog_pin);        //Measure response of conductor 2.
  delayMicroseconds(100);            //Delay to reach steady state.
  digitalWrite(tx_pin,LOW);               //Step the voltage to zero on conductor 1.
  read_low = analogRead(analog_pin);         //Measure response of conductor 2.
  diff = read_high - read_low;       //desired answer is the difference between high and low.
sum += diff;                       //Sums up N_samples of these measurements.
}
  return sum;
}                         //End of tx_rx function.


void loop() {

result = tx_rx();
result = map(result, 8000, 11000, 0, 1024);  //I recommend mapping the values of the two copper plates, it will depend on their size
//if (result != last_result) {
  //Serial.print(min_value);
  Serial.print(" ");
  //Serial.print(max_value);
  Serial.print(" ");
  Serial.println(result);
//}
last_result = result;
min_value = -2790;//MIN(min_value, result);
max_value = -2770;//MAX(max_value, result);

delay(100);
}

I had some trouble wiring the step response at first. I connected the switch tx-pin to the ground after passing through the copper plate. This shorted it.

In the end, I wired it as pictured above, but that took some thinking. Mostly I had to accept, that the extremely simplified diagram provided by Adrian and Neil did in fact show all the wires, and just had additional labeling for electrodes.

I got the step response working with my hand.

Even the bigger 1 inch steel ball created a measurable effect. But it was harder to detect the smaller half inch steel ball. The effect was almost undetectable even by eye and got lost in the noise.

I played around with the code a bit, trying to change the sample count and sampling interval, but neither helped me to detect the smaller ball. Increasing the sample count made the program run slowly, and even if it would have detected the ball, it would not have been able to hit it before it bounced back. Decreasing the sample count made the whole process unreliable, as the code just calculates the probabilistic fluctuations in the pin, and decreasing the sampling reduces the accuracy fast.

Plan B

I also tested the step response with a bigger plate, but the test results were similar.

The bigger ball created a measurable reaction, but the smaller ball did not.

At this point, I gave up on the step response, and decided to try out other designs.

Banned Devices

As breadboards are banned in Fab Academy, I needed to wire the step response “properly”. But as my feedback for PCB week mentioned that simple PCBs with just one component are not interesting enough, (and because I had already abandoned step response as part of the final project), I decided to not make this into a proper PCB.

Instead, why not just solder resistors to the wire directly.

Then those wires could be attached to the Quentorres directly.

This setup works similarly to previous ones.