cnc memory

Ran out of CNC Memory?

Living in a world where the average phone has memory measured in gigabytes it’s easy to forget that a lot of very capable CNC machines have far less memory available for gcode–especially older machines.  A real old Fanuc might have only 16K of RAM–that’s “K” as in 1000’s while “Gigabytes” are billions!  Even the newer controls have less memory than you’d think.

Upgrading your cnc memory is possible, but it can be expensive, difficult to do properly, and you risk losing all your parameters or otherwise taking the machine out of action.  One thread on Practical Machinist mentions it cost them $3600 to upgrade a Fanuc control from 4MB to 8MB.  Ouch!

There are a number of solutions to this problem including drip feeding, which is the “Big Hammer” for the problem.  With drip feeding, you DNC program parcels out the gcode a little at a time as your machine executes so as not to overwhelm it.

There are still limitations and challenges with drip feeding.  For example, depending on how things are set up, the RS-232 link may limit the throughput.  If you’re running lots of little tiny moves, the machine may become starved for data.  Such moves are particularly common for 3D surfacing routines.

Whenever possible, it’s nice to be able to get the whole program onto the machine if you can.  So how do we go about making gcode programs as small as possible?  It turns out there are a number of commands in our G-Wizard GCode Editor that are very good at making your gcode smaller.

Get a Free 30-Day Trial of G-Wizard GCode Editor and Simulator

Let’s run through a simple recipe for taking a program down in size.  I’m going to use one of our sample g-code files, which was an engraving and interpolated hole program for the back connection panel for the CNC control I built for my mill.  It’s code that was generated via OneCNC.  I’ll tell you how much each step saves in terms of both bytes and on a percentage basis.  All of these examples were done using G-Wizard Editor version 1.012.

Initial File Size

You can find the file size down on the status bar of GW Editor or on the “Info” tab.

HomeSwitchRearPanelEngrave: 21893 bytes

 

Step 1:  Eliminate the Comments

Comments are for people, so unless there are messages in there and programmed stops that the operator needs to see, comments are easy to give up.  Unfortunately, there typically won’t be a huge savings because there aren’t that many comments especially in CAM generated code, but every little bit helps.

To eliminate them, use Tools | Revisions | Comments | Delete Comments:

Save cnc memory remove comments

HomeSwitchRearPanelEngrave: 21670 bytes (Only saved 223 bytes, about 1%)

 

Step 2:  Get Rid of Block “N” Numbers

In most programs, every single line has a block number, so this yields better results than deleting comments.  To accomplish the task, we used GWE’s Renumber Revision and told it to only number every 10000 blocks:

SaveRAMRenumber

Just tell it to “Limit block numbers to lines that have any of”, then uncheck all the boxes except “Every … blocks” and stick a big number in there.  GWE will delete block numbers except for every 10,000th block.  If you find the block numbers helpful, perhaps you can get by numbering every 5th or 10th line as a compromise.

HomeSwitchRearPanelEngrave: 17212 bytes (Saved 4458 bytes, about 21%).  That’s a quite a bit more cnc memory savings.

 

Step 3:  Get Rid of White Space

If you’re following along with your own copy of GW Editor, you’ll notice that while the block numbers and comments were deleted, blank lines where not.  It turns out gcode doesn’t care much about spaces either (at least most dialects don’t), so we can squeeze out all the white space for more savings.  We’ll use the Add/Delete Spaces Revision to perform this task:

Save cnc memory, delete Spaces

HomeSwitchRearPanelEngrave: 15560 bytes (Saved 1652 bytes, nearly 10%).  Decent cnc memory savings, but not huge.

Step 4 (Optional):  Convert IJK style arcs to R style

I’ve labeled this step optional because you need to be sure you can check the results.  Not all IJK arcs can be translated to “R” format and GWE can’t necessarily identify all of those cases automatically.  So, you want to make sure you go over the backplot carefully to make sure everything is as you expect.  However, if you’re willing to go to the trouble, the savings can be significant.  Here are the settings I used for the Arc Adjust Revision:

SaveRAMArcs

HomeSwitchRearPanelEngrave: 13204 bytes (Saved 2356 bytes, another 15%).  Every little bit of cnc memory savings helps!

Conclusion:  40% Savings

Overall, we managed to save 8,689 bytes, a reduction of about 40% on the original 21,893 byte program.  That’s not bad for 5 or 10 minutes worth of work.  It might be just what it takes to get your program to load in one piece into the controller.

 

 

Like what you read on CNCCookbook?

Join 100,000+ CNC'ers!  Get our latest blog posts delivered straight to your email inbox once a week for free. Plus, we’ll give you access to some great CNC reference materials including:

  • Our Big List of over 200 CNC Tips and Techniques
  • Our Free GCode Programming Basics Course
  • And more!

Just enter your name and email address below:

Full Name
Email *
100% Privacy: We will never Spam you!