Automated Testing of 3.5mm AT Jacks

At ATMakers, we use lots of AT Jacks.  Every switch-adapted toy, every interface device, almost everything we make requires a 3.5mm jack or plug.

Because of this, we ask STEM programs and Robotics teams to make us jacks and plugs as their first soldering project, and we’re always making them here.  Therefore we have lots of jacks, and we need to do lots of testing! This project makes that simple!

Contents

Manual Testing

You can manually test every Jack and plug – it just takes a while.

First, you’ll need a way to access the Tip, Ring, and Sleeve of component you’re testing.  If it’s a plug, that’s easy, but if it’s a Jack, you’ll need a Male-to-Male 3.5mm TRS Adapter.

 With the adapter in the jack, use a multimeter or continuity tester to check a number of different connection points.   The goal is to make sure that the jack is wired to mimic a mono jack (which is what AT devices and switches expect).

The connections to test are:

  1. The Ring and Sleeve should be connected
  2. The Tip and Ring should not be connected
  3. The Tip and Sleeve should not be connected
  4. The Tip should be connected to only one of the leads
  5. The Sleeve should be connected only to the other lead
  6. The two leads should not be connected

(It’s been pointed out that some of these might be redundant.  Ok, but test them all anyway 🙂

Automated Testing

To make this simpler, and to let kids test their jacks on their own, we developed a testing tool based on an Adafruit Trinket M0 microcontroller board.  These boards cost less than $10 and are amazing pieces of technology.  In this case, they’re the perfect fit for this job.

To make a tester, you’ll need:

Introducing the Trinket M0

The Trinket M0 is an Arduino-compatible device from Adafruit Industries.  It has a powerful SAMD M0 processor, and runs either Arduino code or a variant of Python called CircuitPython.  It has 5 GPIO pins, a DotStar multi-color LED, and a MicroUSB interface.

It is a perfect tool for this project.  We will use all 5 GPIO pins and will use CircuitPython so that there’s very little setup – just copy over the code and it will work!

Wiring

This project’s wiring is fairly straightforward: we will connect one wire to each of the 5 GPIO pins on the board.  These are numbered 0, 1, 2, 3, and 4.  The software turns on a pins output and then reads the pin on the other end of the connection to see if there is a connection.

The wires you need to connect are as follows:

  • Pin #0 -> Yellow Alligator Clip (named “Toy1” in the code)
  • Pin #1 -> Green Alligator Clip (named “Toy2” in the code)
  • Pin #2 -> TIP on the Plug
  • Pin #3 -> RING on the Plug
  • Pin #4 -> SLEEVE on the Plug

Testing Code (CircuitPython)

The Trinket M0 comes with a Python interpreter named CircuitPython (based on MicroPython) installed directly on the chip.  It also comes with code that will automatically create a USB Mass Storage device that looks just a Thumb Drive on when you plug in your Trinket to the USB port of your computer.

There’s no need to install an Arduino IDE, install a compiler, or anything like that.  When the “drive” pops up after you plug in the Trinket, just replace the file named “main.py” with the code below!

If you want more info about how this works, check out the Trinket M0 Guide (specifcally the CircuitPython Section).

[python toolbar=”false”]
#ATMakers Jack Tester
#See guide at http://atmakers.org/2018/02/automated-at-jack-testing/

from board import *
#some boards need just "dotstar" on the next line depending on the version
import adafruit_dotstar
import time
import neopixel
from digitalio import DigitalInOut, Direction, Pull
import board
import time

led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

# One pixel connected internally!
dot = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)

d0 = DigitalInOut(D0)
d1 = DigitalInOut(D1)
d2 = DigitalInOut(D2)
d3 = DigitalInOut(D3)
d4 = DigitalInOut(D4)
jackTip = d2
jackRing = d3
jackSleeve = d4
#toy1 is green, toy2 is yellow
toy1 = d0
toy2 = d1

def resetPins():
"Resets all the pins to PULLUP so they don’t drive others"
allPins = [jackTip, jackRing, jackSleeve, toy1, toy2]
for curPin in allPins:
curPin.direction = Direction.INPUT
curPin.pull = Pull.UP

def testConnection(pin1, pin2, testname):
"sets pin1 to low and checks whether that drives pin2 low"
result = False
resetPins()
pin2.direction=Direction.INPUT
# pin2.pull = Pull.UP
# At this point, pin1 is set to HIGH, so pin2 should be if it’s connected
pin1.direction=Direction.OUTPUT
pin1.value=True
onTest = pin2.value
if (onTest == False):
result = False
else:
#now we set it low and check that
pin1.value=False
offTest = pin2.value
result = (offTest == False)
print("Testing Connection [", testname, "]: ", result)
resetPins()
return result
#Colors in RGB Order
GREEN = (0,255,0)
RED = (255,0,0)
YELLOW = (255, 255, 0)
BLACK = (0,0,0)
def showColor(color1, color2):
lastColor = color1
while True:
print("Setting Color", lastColor)
dot[0] = lastColor
dot.show()
if (lastColor == color1):
lastColor = color2
else:
lastColor = color1
time.sleep(0.5)

#We check every connection we care about. Then we apply our rules.
#Some of these are redundant, but we check anyway
toy1_toy2 = testConnection(toy1, toy2, "Toy1 -> Toy2")
tip_toy1 = testConnection(jackTip, toy1, "Tip -> Toy1")
tip_toy2 = testConnection(jackTip, toy2, "Tip -> Toy2")
sleeve_toy1 = testConnection(jackSleeve, toy1, "Sleeve -> Toy1")
sleeve_toy2 = testConnection(jackSleeve, toy2, "Sleeve -> Toy2")
ring_toy1 = testConnection(jackRing, toy1, "Ring -> Toy1")
ring_toy2 = testConnection(jackRing, toy2, "Ring -> Toy2")
ring_sleeve = testConnection(jackRing, jackSleeve, "Ring -> Sleeve")
ring_tip = testConnection(jackRing, jackTip, "Ring -> Tip")
sleeve_tip = testConnection(jackSleeve, jackTip, "Sleeve -> Tip")

testResult = True
tipPin = toy1

#Evaluate basic tests
#toy1 and toy2 should never be shorted
if (toy1_toy2):
print("Error – Toy1 and Toy2 are Shorted")
testResult = False
#Tip should not touch Ring or Sleeve
if (ring_tip):
print("Error – Tip and Ring are Shorted")
testResult = False
if (sleeve_tip):
print("Error – Tip and Sleeve are Shorted")
testResult = False
#Sleeve and Ring should be connected
if (ring_sleeve == False):
print("Error – Ring and Sleeve are Not Connected")
testResult = False

#At this point, we need to test Toy1 and Toy2 separately since we don’t know one’s connected to the Tip
if (tip_toy1):
tipPin = toy1
print("Info – Tip is connected to Toy1 (Green)")
if (ring_toy1):
print("Error – Ring Shorted to Toy1 (which is Tip)")
testResult = False
if (sleeve_toy1):
print("Eror – Sleeve Shorted to Toy1 (which is Tip)")
testResult = False
if (ring_toy2 == False):
print("Error – Ring not connected to Toy2 (which is not Tip)")
testResult = False
if (sleeve_toy2 == False):
print("Error – Sleeve not connected to Toy2 (which is not Tip)")
testResult = False
elif (tip_toy2):
tipPin = toy2
print("Info – Tip is connected to Toy2 (Yellow)")
if (ring_toy2):
print("Error – Ring Shorted to Toy2 (which is Tip)")
testResult = False
if (sleeve_toy2):
print("Eror – Sleeve Shorted to Toy2 (which is Tip)")
testResult = False
if (ring_toy1 == False):
print("Error – Ring not connected to Toy1 (which is not Tip)")
testResult = False
if (sleeve_toy1 == False):
print("Error – Sleeve not connected to Toy1 (which is not Tip)")
testResult = False
else:
print("Error – Neither Toy1 nor Toy2 is connected to tip")
testResult = False

if (testResult == False):
showColor(RED, BLACK)
elif (tipPin == toy1):
showColor(GREEN, BLACK)
else:
showColor(GREEN, YELLOW)

[/python]

Testing the Jacks (Finally!)

With the Trinket programmed and the wires connected, we can finally test our jacks!  Here’s the procedure (it’s much simpler!)

  1. Power the Trinket (from a PC or a phone charger)
  2. Plug in the tester to the jack using the 3.5mm plug
  3. Clip the two alligator clips to the leads from the jack
  4. Press the Reset button on the Trinket
  5. The Trinket will run all of the tests and give you a result.
  6. The colors of the Trinket mean the following:
    • Flashing Red/Black: Fault – at least one of the tests failed.  This jack must be manually tested and/or pitched
    • Flashing Green/Black: Good – all tests passed and the GREEN alligator clip is connected to the TIP of the plug
    • Flashing Green/Yellow: Good – all tests passed and the YELLOW alligator clip is connected to the TIP of the plug
  7. Mark the wire connected to the TIP (see #6) somehow (we tie the wire in a loose knot.  This is helpful later if you’re wiring many jacks and want them all to connect with the same polarity.

Here’s a video showing how to use this tester in practice:

Extra Credit: Serial Output

But Wait!  There’s More!

CircuitPython lets our program write text out to a serial console!  So… if you plug your Trinket into a computer (instead of a battery pack) and connect to the Serial Output, the program will tell you exactly which connection is wrong with your jack!

Here’s a link to the CircuitPython page on connecting to the Serial Port.  (It’s not that hard, but it’s beyond this guide.)

To be really honest, we rarely use this feature.  90% of our jacks test fine, and the ones that don’t are set aside for a more experienced engineer to either pitch or fix manually.  But it’s there for extra credit 🙂

Think this is awesome? Join Us!

We’d love to hear your thoughts on this!  Is it helpful?  Useless?  Want a different tester for a different device?  Let us know!

Join us on the ATMakers Facebook Group (where you’ll find lively conversation daily)

Or shoot us a message below – we’ll get back to you ASAP!