Hello. I working on a hand-made CNC mill that runs on a TinyG and ChiliPeppr. For safety reasons, I want to add a set of lights that change depending on the state of the mill: blue is on when it's idle, red when milling, and green when finished. I want to use an Arduino Uno to control the lights. This has some tricky implications because Arduino uses C++ and TinyG uses GCode. I was wondering about the best way to go about getting the Arduino to recognize when the mill is doing what.
I don't know if the Uno can read the TinyG (because its serial port is being used) so I thought to take a more external approach. I want to have the Uno taking inpouts from the TinyG where it feeds power to the motors, where the Uno is simplyreading whether or not each pin is getting power. The X, Y, and Z motors all get power directly from the TinyG. I could program my Uno with inputs detecting whether or not the motors are moving. (the motors have two powers, and both powers are on when it's stopped, so they are moving when it is only receiving one power).
I would have it power the blue light when the motors are all idle. When one or more motors are moving, the red light powers. It also trips a variable that makes the green light, instead of the blue one, turn on next time the motors are idle. I would probably also make it so that when all motors are idle while the red light is on, it initiates a 10 second countdown (without delay). If a motor moves within that ten seconds, the green light does not turn on.
I would have the Uno just read the motor for the bit, but that is not directly wired to the TinyG. However, the TinyG should still be giving electrical signals to where the spindle should be hooked up. I can probably use those as extra inputs for the Uno so I can make sense of what's going on. Maybe I only need the spindle connection?
This is a simplified outline of what I am trying to accomplish. I would just like feedback on the feasibility of this or if there is a better way. I am confident that I will not have trouble coding this, assuming the TinyG and steppers work as I think they do. Maybe there is a better way to go about this? Feel free to leave your thoughts about it.