DigitalWrite Stops Stepper from Operating

So I have an Arduino Uno with an adafruit motor shield controlling a stepper motor. Wired into the Arduino IO is a micro switch and a relay (for controlling a DC Motor). The Arduino is on a power supply, and the two motors are on a separate power supply to isolate noise.

The issue I an having is the stepper motor will operate properly (turning it on and off) up until the first time you call a digitalWrite() command (Used for operating the DC motor). After I use the digitalWrite() then the stepper motor will never operate again until the system is reset. I need to operate the stepper after I do a digitalWrite()

If I take the code below and comment out the two digitalWrite() in the ‘cutter operation’ section, then the stepper motor works beautiful but I lose any functionality of my relay. (which is an issue)

Can anybody shine some light on this?

// include libraries
#include <Wire.h>
#include <Adafruit_MotorShield.h>
//-------------------------------------------------

//From StepperTest Example
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); // Create the motor shield object with the default I2C address
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);
//-------------------------------------------------

// This code is for the input momentary switch that tells where cam is
const int buttonPin = 12;             // Input from momentary switch is pin 2
int buttonState = 0;                  // variable for reading the pushbutton status
const int relayPin = 11;              // relay is attched to pin 11
//-------------------------------------------------

void setup()  {
  pinMode(relayPin, OUTPUT);        // initialize the LED pin as an output:
  pinMode(buttonPin, INPUT_PULLUP); // initialize the pushbutton pin as an input:
  digitalWrite(relayPin, HIGH);

  AFMS.begin();                   // create with the default frequency 1.6KHz
  myMotor->setSpeed(20);  // 20 rpm
}
//-------------------------------------------------

void loop() {
  int stepsToTake;
  stepsToTake = 100;
  feederOperate(stepsToTake);   // Move Stepper 
  cutterOperate();              // Operate Relay
  delay(1000);
}
//-------------------------------------------------

//This is the cutter operation
void cutterOperate()  {
  digitalWrite(relayPin, LOW);                        //Turn relay on
  delay(1000);
  buttonState = digitalRead(buttonPin);               //Check status of switch
  while (buttonState == LOW)  {                       //Wait until switch is no longer depressed
    delay(10);
    buttonState = digitalRead(buttonPin);
  }
  delay(200);
  digitalWrite(relayPin, HIGH);                       //Turn relay off
}
//-------------------------------------------------

//This is the feeder operation
void feederOperate(int stepsToTake)  {
  delay(20);
  myMotor->step(stepsToTake, BACKWARD, DOUBLE);     //Move Stepper
  delay(1000);
}

How is this relay powered? Not from the Arduino pin right? You have a transistor or an optocoupler or something in between right?

I am using a 'packaged' relay board from sainsmart, (2-Channel 5V Relay Module | SainSmart – SainSmart.com), which according to specs draws 15-20ma per relay. I am only using one relay and I believe that 20 mA draw is well within specs of an Arduino pin, thus the relay board is connected straight to the arduino.

Does the relay operation lock up the board when NOT using the stepper?

Can you post a wiring diagram showing how you have all of this hooked up?

The relay works fine without the stepper motor engaged and the stepper works fine without the relay engaged.

Here is my schematic:

What's your power supply?

The stepper, motor shield, and DC motor operate off of one power supply. 12V 1 Amp. The DC motor at full stall draws .7A and the stepper motor have a max current of 350mA. They are never driven at the same time. (there is a delay in between operation) I have measured the current draw and it never exceeds 0.5 Amps

The arduino board itself is driven off a separate 12V 1A transformer.

You should have a free wheeling diode across the motor leads (like a 1N4004), cathode (end with stripe) toward +, to suppress inductive kickback which might cause the MCU to fault. And a 10nF (0.01uF) ceramic capacitor in parallel with diode to suppress brush noise wouldn't hurt.

FredScuttle:
You should have a free wheeling diode across the motor leads (like a 1N4004), cathode (end with stripe) toward +, to suppress inductive kickback which might cause the MCU to fault. And a 10nF (0.01uF) ceramic capacitor in parallel with diode to suppress brush noise wouldn't hurt.

You sir, have made my day.

For now, I have isolated power supplies between the DC motor and the MCU to eliminate any possibility of noise, and the project works as expected. I now know I have a noise issue and will continue down that path of eliminating it as you described. Thanks!