Quote Originally Posted by kingcreaky View Post
Even "invented" gcode... before I realised I wasnt the first one! :-D
I re-invented G code because it wasn't invented for computers.

Picture this scenario, you are belting along a line, reach the end and the next item is an arc, joining at a tangent so you want to hold your speed. All you get is offsets to the centre and an end point. This is not friendly. The stepper motor is champing at the bit for it's next step and you start to do floating point trig on ASCII text. You manage to carry past that and, before you know it, that swine of an operator decides to press PAUSE halfway through your acceleration

Obviously you are going to predigest the tool trajectory before you even attempt this. At one end of the wire you have a 10GHz 64 bit monster with Gigabytes of fast access RAM which can hold the whole movement array without breaking a sweat. At the other end you have a 100Mhz tiddler, 32 bits if you are lucky, and an SD card for storage. No prizes for guessing which end is best suited to do the conversion.

My R code is binary XYZW co-ordinates defining the end points of a series of interconnecting straight lines. The co-ordinates are integers in stepper resolution. The only other clues you get for the line are a maximum velocity and a preferred terminal velocity. Velocities are pointers to a list of timer delays. To accelerate you move up the list one slot at a time. To decellerate you move down similarly.

I don't even start producing R code until the tool position is known and all is ready to go. It starts from where you are now with no appreciable delay. It flips the mill into cut mode, PAUSE's it then starts streaming R codes. That way I have to press the GREEN button on the pendant to start it and my thumb is convenoently close to the RED button should I have forgotten something.

Driving steppers on an interrupt with R code input is a doddle once you accept that the terminal velocity for the line is only a suggestion. If you can't make it on this line, try next time. To brake you convert every step to a decelleration until you are safe. To restart you use the same routine that you use at the beginning of every line. Simples.