SPI fails when digital pins 2-9 are used

Hello, I am working on a light controller for my rec room and I have run into a frustrating problem. I am trying to use UDP to send commands to my Arduino through a W5100 breakout board. Everything appeared to be working until I started attaching things to my Duemilanove. I have the W5100 attached to pins D10-D13, 3 TIP 120 NPN transistors attached (through 1k resistors) to pins D5, D6, and D9 (I later moved to D3), an Omron SSR to pin D4, and my zero cross detector to pin D2. The problems started when I tried to output on the Digital pins, I would send a command to turn the transistors on (for RGB lighting) and then the Arduino would start “receiving” UDP packets some with negative lengths, some with lengths in the 10’s of thousands mostly from nonexistent IP addresses, sometimes filled with garbage data, sometimes empty, then ultimately execution stops requiring a reset. It seems like every time it fails the D13 LED on the board is lit faintly, like maybe it is trying to communicate with the W5100? I modified the UDPsendReceive example to isolate/reproduce the problem. I have tried different W5100 Breakout boards.

/*
  UDPSendReceive.pde:
 This sketch receives UDP message strings, prints them to the serial port
 and sends an "acknowledge" string back to the sender

 A Processing sketch is included at the end of file that can be used to send
 and received messages for testing with a computer.

 created 21 Aug 2010
 by Michael Margolis

 This code is in the public domain.
 */


#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 155);

unsigned int localPort = 2000;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac, ip);
  Udp.begin(localPort);
  pinMode(8, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i = 0; i < 4; i++)
    {
      Serial.print(remote[i], DEC);
      if (i < 3)
      {
        Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);
    if (packetBuffer[0] == 'R')
    {
      digitalWrite(8,HIGH);
    }

    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), 2001);
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}

The serial output is as follows:

Received packet of size 8
From 192.168.1.6, port 59047
Contents:
LIGHT_0%
Received packet of size 14
From 192.168.1.6, port 59047
Contents:
LIGHT_FADE_OFF
Received packet of size 13
From 192.168.1.6, port 59047
Contents:
LIGHT_FADE_ONF
Received packet of size 10
From 192.168.1.6, port 59047
Contents:
LIGHT_100%_ONF
Received packet of size 10
From 192.168.1.6, port 59047
Contents:
LIGHT_100%_ONF
Received packet of size 24
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -32768
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -1
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -1
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -1
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -1
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -1
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF
Received packet of size -14
From 192.168.1.6, port 58880
Contents:
RGB_CYCLE_10NF

It seems to act as desired until the digitalWrite (it occurs with analogWrite as well) then it goes off. I have tried every pin D2-D9, same result. I read about issue 605 but everything seems to point to that being a linux only issue, I am on Windows 10 using Arduino 1.6.5. Any thoughts on how to make this behave? I tried running off a bench supply in case it was a power issue, no dice.

Thanks
-Brad

Shadow42:
Hello, I am working on a light controller for my rec room and I have run into a frustrating problem. I am trying to use UDP to send commands to my Arduino through a W5100 breakout board. Everything appeared to be working until I started attaching things to my Duemilanove. I have the W5100 attached to pins D10-D13, 3 TIP 120 NPN transistors attached (through 1k resistors) to pins D5, D6, and D9 (I later moved to D3), an Omron SSR to pin D4, and my zero cross detector to pin D2. The problems started when I tried to output on the Digital pins, I would send a command to turn the transistors on (for RGB lighting) and then the Arduino would start "receiving" UDP packets some with negative lengths, some with lengths in the 10's of thousands mostly from nonexistent IP addresses, sometimes filled with garbage data, sometimes empty, then ultimately execution stops requiring a reset. It seems like every time it fails the D13 LED on the board is lit faintly, like maybe it is trying to communicate with the W5100? I modified the UDPsendReceive example to isolate/reproduce the problem. I have tried different W5100 Breakout boards.

What are you using for a powersupply? The Arduino with W5100 is pushing it's maximum capacity.

Post a schematic of your circuit. I expect the W5100 is browning out when you start driving your lights.

Chuck.

That's What I thought initially so I had been powering the W5100 with my ATX bench supply. I cannot reproduce the issue today, I have no idea why, the only change I made was tying the Arduino and W5100 Reset lies together (I was forgetting to reset the W5100 when the arduino locked up) and I doubt that would cause it. However now I am having issues with the zero cross detection, seems like my smps is pumping horrible noise back into the 120V line, maybe this isn't completely unrelated? Idk at least the accent light is operational, now if only I had an oscilloscope... Thanks