Serial Output freezes. TX light stays on.

Hi,
Arduino noob here. I've been researching this for a few days with no luck, so I apologize if my answer is already here and I just can't find it.

Short background. I'm building a system that stops an operator from using a compressed air assembly press in the wrong order. Just a few positional dip switches to make sure they don't forget what they did last. And a Power Tail II to cut off the power to the machine if they get out of order.

Arduino Uno Rev. 3

The serial output on my Uno freezes after anywhere from 30 seconds to 3 hours of usage. The TX light stays lit and the serial output stops feeding to the Serial Monitor in the IDE. The UNO continues to read the sensors and operates the program accordingly. I assumed it's power related so I tried running an extension cord for the Uno and Computer but it didn't improve the results at all. It seems very related to the machine firing (Even though it's an air powered piston). I want to rule out coding errors before I beat my head against the wall chasing down ground issues on the machine.
The serial output is just 3 numbers that are interpreted by Processing.org

#define Button  8
#define Switch 10
#define Connect1 5
#define Connect2 8
#define VertConnect 12
int Marker = 1;
boolean pushState = false;
boolean lastPush = false;
boolean lastSwitch = LOW;

void setup()
{
 	pinsInit();
        Serial.begin(9600);
   
}  
 
void loop() 
{
        int POS1 = digitalRead(Connect1);
        int POS2 = digitalRead(Connect2);
        int VERT = digitalRead(VertConnect);
        if(POS1 == 1){
          Serial.print(F("1"));
          if(lastSwitch != HIGH)  {
            lastSwitch = HIGH;
          }
        }
        else if(POS2 == 1) {
          Serial.print(F("2"));
          if(lastSwitch != HIGH)  {
            lastSwitch = HIGH;
          }
        }
        else {
          Serial.print(F("0"));
          if(lastSwitch != LOW)  {
            digitalWrite(Switch, LOW);
            lastSwitch = LOW;
          }
        }
        if(VERT == 1) {
          pushState = true;
          Serial.print(F(" 1"));
        }
        else pushState = false;
        
        if(lastPush != pushState && pushState == true) {
          if(Marker == 1) Marker = 2;
          else Marker = 1;
        }
        lastPush = pushState;
        
        if(Marker == 1) {
           if(POS1 == 1) {
             Serial.println(F(" 1."));
             digitalWrite(Switch, HIGH);
           }else {
             Serial.println(F(" 2."));
             digitalWrite(Switch, LOW);
           }
        } else if(Marker == 2){
            if(POS2 == 1) {
             Serial.println(F(" 3."));
              digitalWrite(Switch, HIGH);
            } else {
             Serial.println(F(" 4."));
              digitalWrite(Switch, LOW);
            }
        } else {
          Marker = 1;
          digitalWrite(Switch, LOW);
        }
        delay(500);
}
void pinsInit()
{
        pinMode(Connect1, INPUT);
        pinMode(Connect2, INPUT);
        pinMode(VertConnect, INPUT);
        pinMode(Switch, OUTPUT);
}

Thanks for a wonderful product, and your help!

Follow up question. If my sensors have direct contact with the machine being fired, do I need to ground the Arduino circuit back to the machine(110v)?

I didn't follow all the conditional logic in your sketch but I didn't see anything that would cause stability problems.

ziggyz:
The TX light stays lit ...

I see symptoms like this when my UNO writes to the serial port and the corresponding virtual serial port in the PC is not open. That makes me wonder whether the application that is supposed to be reading from the virtual serial port has failed, or the USB drivers have somehow failed. You aren't using Gobetwino, but I've had similar problems with that where it was working OK for a few hours and then for no apparent reason stopped receiving serial input and the Arduino acted as if the serial port was closed. You could try running your sketch with Realterm reading and logging the input and see if that made any difference. I've never seen any serial port problems like that with Realterm. Not sure what the solution is if the symptoms can't be reproduced with Realterm, but at least it confirms you're looking at a client side issue.

ziggyz:
It seems very related to the machine firing (Even though it's an air powered piston).

A schematic and description of the hardware you are using is in order.

So I don't have a schematic for the press machine because we bought it from a company called Janesville Tool.

I followed this setup for the power tail II. Power Switch Tail: Control any AC Electrical Device Remotely via Spacebrew — Spacebrew

After further isolating and testing. When the PowerTail II is plugged in the machine and connected to my Arduino firing the machine makes the serial output freeze. I have the PowerTail II grounded to the arduino per the instructions, is it possible that a surge from power outlet is passed through to the Arduino? As always, thanks for the help.

Make sure the cable to the power switch is shielded if its long, and doesn't run alongside mains wiring.
The power switch tail is opto-isolated it seems so the likely explanation is EMI pick up in cabling. This
could also be happening on sensor cables.

There could be an issue with ground loops - are the sensors you are using connected electrically to a
chassis ground (if so, that's an issue).

Thanks! Not to out noob myself but I don't think we have any shielded cable handy. Would something like this (RadioShack.com Official Site - America's Technology Store) work? Thanks for all of the help guys.