I am using a X and Y gantry robot to do some movements while holding a welding torch, which is causing a lot of EMF issues. The program will sometimes just freeze and need rebooted, but now it has just broken. This is the second time it has happened.
My setup is an arduino mega 2560 with a RAMPS 1.4. The motors are wired to a TB6600 micro stepper driver, which wire directly to the three X step, dir, and en pins on the RAMPS. I believe I had it all wired correctly as it was working totally fine for a while until the EMF just got too big for the arduino to handle I guess. Now, I am trying to find out what in the arduino/RAMPS is broken.
The main bug that I am seeing is that when the program starts, it will home to origin, but instead, the motors will just hum loudly and not move, or move back and fourth slightly like it just hit the endstop. When I open the serial monitor and try to home, move, or get the current position (M114), it will read out some crazy wrong number (something like -166677.72, this isn't the exact number but it looks a lot like that).
I checked the analog pins that correlate to the three pins connected to the stepper driver by just hooking up a potentiometer and seeing if they were reading out correctly, all three for the X and Y were reading out fine. I then checked the digital pins that the end stops were using with a pushbutton and pulldown resistor, and they read fine. I also checked the endstops by manually tripping them, then calling on them with M119 and they would read open or closed correctly.
I have no clue what is wrong with the Arduino, and I do not think it is the RAMPS fault as I was able to just switch out the arduino for a new one, and it worked fine again (albeit this one also ended up doing the same thing but for both axes now). If there is any idea please let me know.