Noise Interference with dual power supply

Hi there, I have my arduino connected to my computer so that I can observe the serial monitor window. I have a touch sensor that I want to stop all other movement of the single stepper motor in the system. The stepper motor requires an additional 9VDC adapter that I wire through the arduino. The touch sensor works perfectly fine and indicates 1 when I am touching and 0 when not touching if it's only pulling from my computers power. When I plug in the secondary adapter to allow stepper motor movement, the touch sensor stops working and the serial monitor goes haywire. I'm assuming this is noise or interference but I'm not sure how to completely isolate the different components.

const int fwdPin = 11;
const int rvsPin = 10;
const int shearPin = 8;  //good was 10
const int homePin = 9;   //good was 11
const int halfPin = 12;
const int crashPin = 7;
const int dirPin = 2;
const int stepPin = 3;

int fwdState = 0;
int rvsState = 0;
int halfState = 0;
int shearState = 0;
int homeState = 0;
int prevShearState = 0;
int prevHalfState = 0;
int prevHomeState = 0;
int prevFwdState = 0;
int prevRvsState = 0;
int crashState = 0;

bool crashAlert = false;

void setup() {
  // put your setup code here, to run once:
  pinMode(fwdPin, INPUT);
  pinMode(rvsPin, INPUT);
  pinMode(shearPin, INPUT);
  pinMode(homePin, INPUT);
  pinMode(halfPin, INPUT);
  pinMode(crashPin, INPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(stepPin, LOW);
  fwdState = digitalRead(fwdPin);
  rvsState = digitalRead(rvsPin);
  shearState = digitalRead(shearPin);
  homeState = digitalRead(homePin);
  halfState = digitalRead(halfPin);
  crashState = digitalRead(crashPin);
  // The two below if statements do not need crash protection
  if (shearState != prevShearState) {
    delay(50);
    shearState = digitalRead(shearPin);
    if (shearState == HIGH) {
      digitalWrite(dirPin, LOW);
      for (int x = 0; x < 8150; x++) {
        digitalWrite(stepPin, HIGH);
        delayMicroseconds(750);
        digitalWrite(stepPin, LOW);
        delayMicroseconds(750);
      }
    }
  }
  if (fwdState == HIGH) {
    digitalWrite(dirPin, HIGH);
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);
  }
  // The follwoign if statements DO need crash protection
  if (crashState == HIGH) {
    crashAlert = true;
    digitalWrite(stepPin, LOW);
  } else {
    crashAlert = false;
  }
  if (!crashAlert) {
    if (rvsState == HIGH) {
      digitalWrite(dirPin, LOW);
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(1000);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(1000);
    }
    if (homeState != prevHomeState) {
      delay(50);
      homeState = digitalRead(homePin);
      if (homeState == HIGH) {
        digitalWrite(dirPin, HIGH);
        for (int x = 0; x < 8150; x++) {
          digitalWrite(stepPin, HIGH);
          delayMicroseconds(750);
          digitalWrite(stepPin, LOW);
          delayMicroseconds(750);
        }
      }
    }
  }

  prevHomeState = homeState;
  prevShearState = shearState;
  prevFwdState = fwdState;
  prevRvsState = rvsState;
  Serial.println(crashState);
}

That sounds like a hardware or EMI (Electromagnetic Interference) problem. Post an annotated schematic showing how you have wired it including all connections, power, grounds and power sources. If I were to take a SWAG it sounds like a grounding problem.

Here's the schematic, let me know if you need more info, I'm not the brightest at this!!

Well, with switches wired from 5V to GND, and the inputs for the switches directly wired to GND, I have my doubts about the correctness of either the schematic, or your wiring, because pushing any button should make the lights go out on the Arduino, OR the button go 'sizzle'.
As for the motor, wiring to enable and direction but not pulse leaves me think not much motion will occur.
There you have it - feedback!

Yeah, I'm a bit puzzled myself there. Can you @raven3barnes try again with those buttons / switches?

Ahhhh thank you for bearing with me!!. The buttons are actually four pin momentary push buttons, see the new schematic, and the image of the stepper driver had different pin locations so I have the pulse correctly connected now!

The step motor got it's own supply, 24 V. The driver is also powered from 24 V, what needs 9 V?

Nice picture but it is not a schematic nor is it annotated. Most of the needed information is not there.

And the switches are still incorrect.

Common Grond? I see no common ground between your Arduino board and stepper driver board. Additionally your image reflects a 24 VDC stepper supply and you mention 9.0 VDC? Don't you want a common ground between your Arduino board and stepper driver?

Ron

I was under the impression that the buttons needed a small power supply to function and since the 24VDC is going directly to the driver I didn't know if the arduino needed a different power supply so that's why I have that but can remove it and try without.

Can you elaborate on how they're "incorrect" that doesn't help me much, thank you!

Thank you for the feedback, as I indicated, I am new to this and still trying to figure out things. If you could let me know what is so wrong about it that would be great thank you. I'm not sure what else needs to be annotated.

If they're working for you, I suggest you draw what is wired. There are several ways of wiring pushbuttons, but none of them connect GND to 5V when button is pressed, per your first drawing. Nor do they wire the +5 directly to the digital input, as per your second drawing.
The best approach, with Arduino inputs, is to wire button end 1 to GND, end 2 to the input, and then configure the input in setup using
pinMode(pin, INPUT_PULLUP);
which uses the built-in pullups in the mcu. (obviously, pin should be replaced by your pin number, for each button wired thusly).
Your software should then expect a low, or 0, when the button is pressed, and a high, or 1, when the button is not pressed.
(edited for clarity)

Nothing in your picture is labeled. Also it is sort of a wiring diagram, not a schematic. Without having the modules to look at I have to take a lot of time finding them so I know what pins are what. Wires going nowhere just adds confusion. What is the first and second adapter?

How you described is exactly how I have them wired, not sure if my diagram is wrong? I have not had any issues with these buttons, it is the touch sensor that is having a problem. These buttons show 0, LOW when not pressed and 1, HIGH when pressed. See attached image, I connected my buttons the same way as recommended in this tutorial:
image

Hmmm the only wires I have going "nowhere" are the pins I didn't connect anything to for the push buttons, as arduino recommends you have one to ground, one to 5V, and one to digital input, see attached image, which is what I have for the diagram. I understand it's not a perfect schematic but that is hard to do when you're just learning this sort of thing! I will try and reannotate things but not sure what annotations are required. The 9V is just the regular arduino power supply cord that plugs into AC wall outlet and is an AC2DC converter. The 24V supply is the same, plugged into a wall and converted to 24VDC within. There is a DC power adapter to screw terminal in order to break out the +/- of this supply See picture:
image

image

Reconcile that, with this:
image

I give up. Best luck!

That's not a good "Fritz" diagram for beginners, if the "4 legged" button is turned 90 degrees, it puts a constant Vcc on the resistor and leaves the input pin floating.
The pulldown resistor should always be connected to the input pin wire.

For a start I would recommend getting rid of the delay statements and use millis instead. Each time a delay is delaying the computer does nothing else.