PWM help - plug-in switchboard interface

Im trying to create a fake ‘switchboard’ interface - basically a grid of 1/4" guitar lead jacks. I want to be able to send ‘signal’ between in and Out jacks to determine which jacks are plugged into which. There doesnt have to be a real signal, it just needs to be a softare signal read over serial and passed onto to other sofware, but i need to be able to identify the jacks somehow. I have an Arduino Mega

At the moment, I was thinking of using digital PWM pins with different widths as the outputs, and Analog In as the inputs. Theoretically i should be able to read the different PWM signals and use this to determine which PWM pin is connnected to which Analog In pin right?..

i started started following this advice stackecxchange but i cant seem to get two PWM voltages working at the same time?

Any advice on how to appropach this problem?

edit - here is a sim of what I might do.simulation The slideswitch is simulating the plug being changed

see when the switch is flipped, the voltage (in the serial graph viewer drops to nothing)

PWM is digital, not analog. You can not simply connect a PWM output to an analog input, even with a low pass filter the voltage will vary. Better use a digital pin and pulseIn() for detection of the duty cycle of the connected PWM pin.

I am not completely sure what you are trying to achieve with your PWM. Couldn't you set the outs as digital outs, the ins as digital ins and

  • set one of the outputs high
  • read all of the inputs
  • set the output low
  • repeat for the other two outputs

Much easier to forget the PWM.

Use INPUT_PULLUP on the "in" jacks, each of which connects to an Arduino pin or even better, use a PCF8575 port expander board which has "INPUT_PULLUP" built in as it were, with open-collector outputs.

For an Arduino, you need a 1k resistor in series with each "out" jack because you know someone is going to plug a patch between one of them and another "out". With the PCF8575 it does not matter because all pins are the same.

All you do is to set all "out"s HIGH and make sure no "in" is LOW because that would be an anomaly. Then set each "out" LOW at a time and read all "in"s to see which one was connected to that "out". Again, if more than one is LOW that is an anomaly but by the time you have tried setting each of the "out"s LOW and read all of the "in"s, you have determined what is patched. :grinning:

Ahh gotcha! This makes a lot more sense :slight_smile:

I was thinking a bit too literally from a signal flow perspective haha...

Works great!!

Thanks so much