How convert gcode to control rc servo from "G1 Z.." "to M300 S.."

Hi, looking for a way to create/convert a gcode for a mini cnc controll using an RC servo on Z axis from "G1 Z.. command to M300 s.. command"?
Gcode generated with Eagle gives G1 Z.. and is not reconnized by the compiled sketch.
In alternative is it possible to modify the sketch so can reconnize G1 Z.. instead of M300 S.. command, and how.
Thanks

Where will the conversion take place? Do you want to run the G code through a PC application, do the conversion and save the converted G code to be subsequently sent to the CNC machine by a G code sender? Or intercept the G code as it is being sent, parse for G1 X, replace the G1 X command with M300 X in the stream? Preprocessing the G code with a PC app is probably easier.

I would agree that converting the G code externally would be a lot easier.

The program you are looking for is called CAM (Computer Aided Manufacturing) software. In that software your G code is run through a post processor that is designed for the output code you desire. Mostly the post modules are pre written for a specific control and you just pick that control type from a list and off it goes and spits out the properly formatted code for your control.

In your case it's possible that no post processor module exists. Most packages have a generic module that you can configure. You just fill in the blanks. So, if your source has a G1 for feed controlled travel and you need a D4 for that function you just put that in the post processor. It is tedious but you only have to do it once.

It all works the same as the compiler that you use for the arduino, where you write the code in C++ and the compiler converts that with a post processor to the machine code for your specific controller.

In your example a G1Z command would tell the control to drill down to a specific point in the Z axis at a particular feed rate. The actual command might be something like G1Z-.5F3.5 This will drill down .5 inches from the Z zero plane at 3.5 inches per minute feed rate. Your command M300S Would turn on the spindle (usually just written as M3) in a clockwise direction. The S function is the speed or RPM desired. The full command would be something like M3S1500 for Spindle on clockwise at a speed of 1500 RPM.

So really you are talking about two different functions that wouldn't really convert between each other.

Hope this helps.

Could be one or the other solution, agree with you, the one with an app on PC is easier.
Adding more experience about, would push me to learn how replace the G1 X command with M300 X in the stream. really do not know were to start, probably have not enough knowledge to modify the sketch. will you please suggest what and how do to make this RC servo moving
thanks a lot for your patience.