Preventing cross-talk on switches

Hi there all, I have a number of panels I am making that use multiple small toggle switches and a couple of encoders to work as a game controller.

The issue I am having is that the switches are affecting each other, where as they share a common ground, if one switch is in a certain position, when another switch is toggled it then commands the in game switch to move, even though the actual physical switch has not been moved

I was thinking of maybe using diodes in the lines to the switches, would that work and if so what would be a suitable type of diode to use?

Cheers

Les

WE will need:

A schematic

A photo of your hardware set up

LINKS to components you are using.



Here are pictures, schematics to follow

SAS panel PCB schematic.pdf (68.3 KB)

Essentially there are four 2 way toggle switches at the top, one 2 way toggle switch at the bottom, one push switch and one rotary encoder. Three SMD LED's are connected via pin D7 of the Nano

I use through hole pins soldered on both sides to make vias, and there is also a jumper lead to connect the ground to a separate area.

I have gone over the entire board checking for shorts or partial shorts, I can't find anything wrong in terms of poor connections either

#define DCSBIOS_DEFAULT_SERIAL

#include <Wire.h>

#include <DcsBios.h>

DcsBios::Switch2Pos saspToTrim("SASP_TO_TRIM", 8);

DcsBios::LED takeOffTrim(0x1026, 0x0400, 7);

DcsBios::RotaryEncoder saspYawTrim("SASP_YAW_TRIM", "-3200", "+3200", 11, 10);

const byte saspPitchSasLPins[3] = {17, 18};
DcsBios::SwitchMultiPos saspPitchSasL("SASP_PITCH_SAS_L", saspPitchSasLPins, 3);

const byte saspPitchSasRPins[3] = {16, 19};
DcsBios::SwitchMultiPos saspPitchSasR("SASP_PITCH_SAS_R", saspPitchSasRPins, 3);

const byte saspYawSasLPins[3] = {14, 9};
DcsBios::SwitchMultiPos saspYawSasL("SASP_YAW_SAS_L", saspYawSasLPins, 3);

const byte saspYawSasRPins[3] = {13, 15};
DcsBios::SwitchMultiPos saspYawSasR("SASP_YAW_SAS_R", saspYawSasRPins, 3);

//DcsBios::Switch3Pos saspMonitorTest("SASP_MONITOR_TEST", 5, 6);

void setup() {
 

  DcsBios::setup();
  
}

void loop() {
  DcsBios::loop();


}

Hi, @Lesthegringo

A schematic would help, so we can see how you have wired your switches up.
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Thanks... Tom.. :smiley: :+1: :coffee: :australia:

When?

We can't start to help until you post one. Pictures as pretty as they are do not cut it here. Yes it looks well constructed but it could have a built in problem. We just don't know until you post it.

Your PDF link saying schematic is not a schematic is it.

SAS panel PCB schematicdxf.pdf (18.1 KB)

Power is by the USB connection, the Max487 chip is not installed, grounds are common

Hi,
A jpg is easier for some platforms to read.

The inputs that are connected to the toggle and push buttons, do they have PULL_UP resistors?
Does the encoder need PULL_UP resistors?

We also need to see your code.

Thanks... Tom.. :smiley: :+1: :coffee: :australia:

Hi there

No, there are no pull up resistors, although so far on all the other panels that I have made they have not been necessary (apparently - they all work fine)

here is teh code

#define DCSBIOS_DEFAULT_SERIAL


#include <Wire.h>


#include <DcsBios.h>

DcsBios::Switch2Pos saspToTrim("SASP_TO_TRIM", 8);

DcsBios::LED takeOffTrim(0x1026, 0x0400, 7);

DcsBios::RotaryEncoder saspYawTrim("SASP_YAW_TRIM", "-3200", "+3200", 11, 10);

const byte saspPitchSasLPins[3] = {17, 18};
DcsBios::SwitchMultiPos saspPitchSasL("SASP_PITCH_SAS_L", saspPitchSasLPins, 3);

const byte saspPitchSasRPins[3] = {16, 19};
DcsBios::SwitchMultiPos saspPitchSasR("SASP_PITCH_SAS_R", saspPitchSasRPins, 3);

const byte saspYawSasLPins[3] = {14, 9};
DcsBios::SwitchMultiPos saspYawSasL("SASP_YAW_SAS_L", saspYawSasLPins, 3);

const byte saspYawSasRPins[3] = {13, 15};
DcsBios::SwitchMultiPos saspYawSasR("SASP_YAW_SAS_R", saspYawSasRPins, 3);

//DcsBios::Switch3Pos saspMonitorTest("SASP_MONITOR_TEST", 5, 6);

void setup() {
 

  DcsBios::setup();
  
}

void loop() {
  DcsBios::loop();


}

What happens when you leave an input open?
You need pullups to make sure the input goes high.
This is possibly an answer to your "Preventing cross-talk on switches".
Without pullups, an open input remain or go low when it is intended to be NOT low.

What code is that?
Please post a link to what it is all about.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

1 Like

3 leds in parallel, driven from a single arduino pin and without current limiting resistors does not appear to be a good idea.
Are built in pin pull up resistors activated in that code ?

Hi, thanks for the answer

DSC Bios is basically a way to use external devices to both input and output data from the DCS Word Sim game, so that you can use switches, Potentiometers, encoders, BCD switches for various inputs, and OLEDs, LCD modules, LEDs, TFTs, stepper motors, servos etc for outputs to represent gauges, readouts, indicator lights, instrument faces etc.

It is pretty good, and the attached is what I have made to work with it. As you can see there are plenty more panels already constructed and working, which is why I am puzzled that this particularly simple one is giving me problems. None of the others did, although maybe that was more luck than judgement

I'm more than happy to try resistors in the circuit, the PCB's are home made so I can modify them as needed or make a new one

As for the LED's they are SMD 0805 type, again I have used them in lots of occasions for years on the other panels without any apparent ill effects. I am not saying it's correct, but it does seem to work

Les

Hi,
Where is the code that reads all the inputs?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

So that is the DCS Bios itself; and I understand that this is where it will become more difficult for you to be able to have an apples and apples comparison. BCS bios is an addon to the game, so you would have to have both the game and DCS Bios installed to be able to do a comparison I think.

What I was looking for here is to try and understand what in circuit design terms is the mitigation that would be considered to prevent one simple switch circuit from affecting the others. The code itself is there just to demonstrate that I was selecting the correct pins for the switches and that the basic logic of my circuitry is sound. Cleary something is amiss because it is not behaving like other (apparently) similar circuits I've made before.

It may be that there is something behind this in the game coding, but as a general concept I want to make sure my physical circuitry is not the cause. If you guys have any best practice or suggestions I will give them a go, and potentially retrofit my existing panels if it proves to be beneficial

Les

Hi,
Okay, well we have told you what the input of a Nano is like if left open circuit.

So I would start there and add pullup resistors, 10K is the usual value.

Its up to you.

Do you have a DMM to make sure your tracks are continuous?

Tom.. :smiley: :+1: :coffee: :australia:

No problem, will do. I will test with what I have lying around, if I don't have many 10K resistors, is there a resistance range to stay within?

Les

Hi,
In your case with the switches close to the controller, 10K to 33K would be good.

Too high and noise will be a problem.

Tom.. :smiley: :+1: :coffee: :australia:

Yes it is the cause, as Tom said.

Yes it is because the code does not enable the internal pull up resistors on the Nano. If it did you would have no problem.

Also the design of using two pins for the same toggle switch is a bit useless, you are using twice the number of Nano input lines than you need. Is this a recommended circuit? If so the people doing the recommendation know less about interfacing than they thought they did.

On that last point, it is so that when the Sim is started, all controls are energised to match the physical input of the switch. Without it you can have a device that remains in the wrong position until the switch is moved

Cheers

Les

No that is simply wrong.