Results 1 to 10 of 22
Thread: G-Code alternative.
Threaded View
-
04-07-2015, 06:09 AM #1
- Join Date
- Mar 2015
- Posts
- 59
G-Code alternative.
G-Code is a very good human readable way of representing commands to a 3D printer. Though it is big, many times larger than it needs to be to do its job. I have taken a very close look at this while I write what is going to be the release version of my 3D printer firmware.
Microcontrollers have limited RAM, this is well known. As such G-Code is a huge pain, as it has to be loaded while being used.
My solution is to create a binary control language. As I comment my code to show what works so far, here is a simple outline of my control language, extracted from the comments in its parser source code:
Code:'Command processor. 'This uses a simple set of byte commands. {The Commands are one byte folowed by one or two bytes of data. The current commands are: 00nnnn = Move X, forward. 01nnnn = Move Y forward. 02nnnn = Move Z forward. 04nnnn = Move X reverse. 05nnnn = Move Y reverse. 06nnnn = Move Z reverse. 08nn = Set Current X Speed. 09nn = Set Current Y Speed. 0Ann = Set Current Z Speed. 0Bnn = Set Current Extrusion Speed. 0Fnn = Set Current Extruder Temperature. 10 = Zero X. 11 = Zero Y. 12 = Zero Z 14 = Set current X position as Zero. 15 = Set current Y position as Zero. 16 = Set current Z position as Zero. 18nnnn = Set current X position as nnnn. 19nnnn = Set current Y position as nnnn. 1Annnn = Set current Z position to nnnn. 1Cnnnn = Set Maximum X position to nnnn. 1Dnnnn = Set Maximum Y position to nnnn. 1Ennnn = Set Maximum Z position to nnnn. 20nn = Select Extruder. 21nn = Set Current Feed Rate. 22nn = Set Heat for current Extruder. 30 = Set Simulation Mode (does all the X/Y/Z movements, with the extruder turned off). 31 = UnSet Simulation Mode (back to regular print mode). 80nnnn = Set repeat counter. 81nnnn = Decrease repeat counter by one and go back up to 65535 bytes if repeat counter not zero. 84nn = Set small repeat counter. 85nn = Decrease Small Repeat Counter and go back up to 255 bytes if small repeat counter is not zero. F0 = All Stop. FF = Print Done (Turn off extruder(s), zero X and Y, move Z to maximum).. }
Here is a commented hex dump of a 57 Byte cube measuring 256 units cubed in this new command language, that works with my 3D printer:
Code:CUBE: HEX DUMP Commented. 21:00:22:72: ;Setup extruder, wait for heatup. 10:11:12: ;Zero XYZ. 00:00:10: ;Set X start pos . 01:00:10: ;Set y Start Position. 80:00:40: ;Setup number of repeating layers (64 in this). ;Next draw a solid square: 21:7A: ;Start extruder. 84:40: ;Setup small repeat 64 times. 00:01:00: ;Draw 256 steps X. 01:00:04: ;4 steps Plus Y. 04:01:00: ;256 Steps negitive X. 01:00:04: ;4 steps plus Y. 85:0C: ;Small Repeat last 12 bytes 64 times. ;Now add a layer. 02:00:08: ;Raise Z by 8 steps. 84:40: ;Setup small repeat 64 times. 00:01:00: ;Draw 256 steps X. 05:00:04: ;4 steps -Y. 04:01:00: ;256 Steps -X. 05:00:04: ;4 steps -Y. 85:0C: ;Small Repeat last 12 bytes 64 times. 81:00:23 ;Repeat last 35 bytes, 64 times. FF ;Print complete.
Now the calibration cube that some 3D printer companies provide (with the 5 steps diagonally by five teared steps), that is only 861 bytes in size using this binary command language. That is 54 times smaller than the G-Code version.
The idea is to create a program to convert G-Code into this new command language, to get started. Then eventually create slicers that directly produce this command language instead of G-Code. Either way it will not take long to get this into use.
This coding format is open to anyone to use, no warranty of any kind.
Qidi X Plus 3 Paper thin first...
Yesterday, 01:15 AM in General 3D Printing Discussion