Art of 3D printer in the middle of printing a Hackaday Jolly Wrencher logo

G-code Goes Binary With Proposed New Format

G-code is effective, easily edited, and nearly ubiquitous when it comes to anything CNC. The format has many strengths, but space efficiency isn’t one of them. In fact, when it comes to 3D printing in particular file sizes can get awfully large. Partly to address this, Prusa have proposed a new .bgcode binary G-code format. You can read the specification of the new (and optional) format here.

The newest version of PrusaSlicer has support for .bgcode, and a utility to convert ASCII G-code to binary (and back) is in the File menu. Want to code an interface of your own? The libbgcode repository provides everything needed to flip .gcode to .bgcode (with a huge file size savings in the process) and vice versa in a way that preserves all aspects of the data. Need to hand-edit a binary G-code file? Convert it to ASCII G-code, make your changes, then flip it right back.

Prusa are not the only ones to notice that the space inefficiency of the G-code file format is not ideal in all situations. Heatshrink and MeatPack are two other solutions in this space with their own strong points. Handily, the command-line tool in libgcode can optionally apply Heatshrink compression or MeatPack encoding in the conversion process.

In a way, G-code is the assembly language of 3D printers. G-code files are normally created when slicing software processes a 3D model, but there are some interesting tricks to be done when G-code is created directly.

CNC Plus Microscope Plus Game Controller Equals Awesome

What do you get if you strap a microscope onto a CNC and throw in a gaming controller? The answer, according to Reddit user [AskewedBox] is something kind of awesome: you get a microscope that can be controlled with the game controller for easier tracking of tiny creepy-crawlies.

[ASkewedBox] set up this interesting combination of devices, attaching their Adonostar AD246S microscope to the stage of a no-brand 1610 CNC bought off Amazon, then connected the CNC to a computer running Universal G-Code Sender. This great open source program takes the input from an Xbox game controller and uses it to jog the CNC.

With a bit of tweaking, the game controller can now move the microscope, so it can be used to track microbes and other small creatures as they wander around on the slide mounted below the microscope eating each other. The movement of this is surprisingly smooth: the small CNC and a well-mounted microscope means that there seems to be very little wobble or backlash as the microscope moves.

[Askewedbox] hasn’t finished yet, though: in the latest update, he adds a polarizing lens to the setup and mentions that he wants to add focus control to the system, which is controlled by a remote that comes with the microscope.

There are plenty of other things that could be added beyond that, though, such as auto pan and stitch for larger photos, auto focus stacking and perhaps even auto tracking using OpenCV to track the hideous tiny creatures that live in the microscopic realm. What would you do to make this even cooler?

Wood game piece being carved by a CNC mill with a hacked rotary axis

This $12 CNC Rotary Axis Will Make Your Head Spin

[legolor] brings us a great, cheap rotary axis to add to your small 3 axis CNC mills. How are you going to generate G-Code for this 4th axis? That’s the great part, and the hack, that [legolor] really just swapped the Y axis for the rotation. To finish the workflow and keep things cheap accessible to all there’s a great trick to “unwrap” your 3D model so your CAM software of choice thinks it’s still using a linear Y axis and keeps your existing workflow largely intact. While this requires an extra step in Blender to do the unwrapping, we love the way this hack changes as little of the rest of your process as possible. The Blender script might be useful for many other purposes too.

Wood game pieces carved from wood by a CNC mill with a hacked rotary axis

The results speak for themselves too! We thought the 3D printed parts were suspect in a CNC setup, but for the small scale of game pieces and milling wood, the setup is stable enough to produce a surprisingly accurate and detailed finish. If you want to try the same approach with something larger or a tougher material, [legolor] has a suggestion of a tailstock setup that’s still under $100 USD. Continue reading “This $12 CNC Rotary Axis Will Make Your Head Spin”

Speak To The Machine

If you own a 3D printer, CNC router, or basically anything else that makes coordinated movements with a bunch of stepper motors, chances are good that it speaks G-code. Do you?

If you were a CNC machinist back in the 1980’s, chances are very good that you’d be fluent in the language, and maybe even a couple different machines’ specialized dialects. But higher level abstractions pretty quickly took over the CAM landscape, and knowing how to navigate GUIs and do CAD became more relevant than knowing how to move the machine around by typing.

a Reprap Darwin
Reprap Darwin: it was horrible, but it was awesome.

Strangely enough, I learned G-code in 2010, as the RepRap Darwin that my hackerspace needed some human wranglers. If you want to print out a 3D design today, you have a wealth of convenient slicers that’ll turn abstract geometry into G-code, but back in the day, all we had was a mess of Python scripts. Given the state of things, it was worth learning a little G-code, because even if you just wanted to print something out, it was far from plug-and-play.

For instance, it was far easier to just edit the M104 value than to change the temperature and re-slice the whole thing, which could take an appreciable amount of time back then. Honestly, we were all working on the printers as much as we were printing. Knowing how to whip up some quick bed-levelling test scripts and/or demo objects in G-code was just plain handy. And of course the people writing or tweaking the slicers had to know how to talk directly to the machine.

Even today, I think it’s useful to be able to speak to the machine in its native language. Case in point: the el-quicko pen-plotter I whipped together two weekends ago was actually to play around with Logo, the turtle language, with my son. It didn’t take me more than an hour or so to whip up a trivial Logo-alike (in Python) for the CNC: pen-up, pen-down, forward, turn, repeat, and subroutine definitions. Translating this all to machine moves was actually super simple, and we had a great time live-drawing with the machine.

So if you want to code for your machine, you’ll need to speak its language. A slicer is great for the one thing it does – turning an STL into G-code, but if you want to do anything a little more bespoke, you should learn G-code. And if you’ve got a 3D printer kicking around, certainly if it runs Marlin or similar firmware, you’ve got the ideal platform for exploration.

Does anyone else still play with G-code?

Motorized Camera Mount Was Once A 3D Printer

If you plan on building your own motorized camera mount, a 3D printer can definitely be of help. But in this case, [dslrdiy] didn’t use it for printing out parts — finding himself with little use for an old printer built from scrap back in the day, he decided to repurpose it and turn it into a remote controlled DSLR camera mount that’s capable of panning, tilting, and sliding.

The main goal was to not only salvage the stepper motors and controller board, in this case an Arduino Mega 2560 with RAMPS board, but also to keep the original firmware itself in use. For this to work, [dslrdiy] redesigned the mechanical parts that would allow him to perform the different camera movements using regular G-Code instructions operating the X, Y, and Z axes to pan, tilt, and slide respectively.

The G-Code instructions themselves are sent via UART by an accompanying control box housing an ESP32. This allows the camera mount to operated by either via joystick and buttons, or via serial Bluetooth connection, for example from a phone. The ESP32 system also allows to set predefined positions to move to, along with speed and other motor tweaks. You can see it all demonstrated in the video after the break.

While there’s simpler solutions for camera mounts out there, this is certainly an interesting approach. It also shows just how far desktop 3D printers have come if we already find the older generations repurposed like this. For more of [dslrdiy]’s work with 3D printers and cameras, check out his customizable lens caps.

Continue reading “Motorized Camera Mount Was Once A 3D Printer”

Collaborative Effort Gets Laser Galvos Talking G-Code

Everyone should know by now that we love to follow up on projects when they make progress. It’s great to be able to celebrate accomplishments and see how a project has changed over time. But it’s especially great to highlight a project that not only progresses, but also gives back a little to the community.

That’s what we’re seeing with [Les Wright]’s continuing work with a second-hand laser engraver. It was only a few weeks ago that we featured his initial experiments with the eBay find, a powerful CO2 laser originally used for industrial marking applications. It originally looked like [Les] was going to have to settle for a nice teardown and harvesting a few parts, but the eleven-year-old tube and the marking head’s galvanometers actually turned out to be working just fine.

The current work, which is also featured in the video below, mainly concerns those galvos, specifically getting them working with G-code to turn the unit into a bit of an ad hoc laser engraver. Luckily, he stumbled upon the OPAL Open Galvo project on GitHub, which can turn G-code into the XY2-100 protocol used by his laser. While [Les] has nothing but praise for the software side of OPAL, he saw a hardware hole he could fill, and contributed his design for a PCB that hosts the Teensy the code runs on as well as the buffer and line driver needed to run the galvos and laser. The video shows the whole thing in use with simple designs on wood and acrylic, as well as interesting results on glass.

Of course, these were only tests — we’re sure [Les] would address the obvious safety concerns in a more complete engraver. But for now, we’ll just applaud the collaboration shown here and wait for more updates.

Continue reading “Collaborative Effort Gets Laser Galvos Talking G-Code”

Wooden You Like To Hear A CNC-Cut Phonograph Record?

Say what you will about [Thomas Edison], but it’s hard to deny the genius of his self-proclaimed personal favorite invention: the phonograph. Capturing sound as physical patterns on a malleable medium was truly revolutionary, and the basic technology that served as the primary medium of recorded sound for more than a century and built several major industries is still alive and kicking today.

With so much technological history behind it, what’s the aspiring inventor to do when the urge to spin your own phonograph records strikes? Easy — cut them from wood with a CNC router. At least that’s how [alnwlsn] rolled after the “one-percent inspiration” hit him while cutting a PCB with his router. Reasoning that the tracks on the copper were probably about as fine as the groove on a record, he came up with some math to describe a fine-pitch spiral groove and overlay data from a sound file, and turn the whole thing into G-code.

For a suitable medium, he turned to the MDF spoil board used to ship PCB stencils, which after about three hours of milling resulted in a rather hairy-looking 78-RPM record. Surprisingly, the record worked fairly well on a wind-up Victrola. The spring-powered motor was a little weak for the heavy wooden record and needed a manual assist, but you can more or less clearly hear the 40-second recording. Even more surprising was how much better the recording sounded when the steel needle was replaced with a chunk of toothpick. You can check out the whole thing in the video below, and you’ll find the G-code generation scripts over on GitHub.

Is all this talk about reproducing music using wiggly lines confusing you? Woah, there, whippersnapper — check out [Jenny]’s primer for the MP3 generation for the background you need.

Continue reading “Wooden You Like To Hear A CNC-Cut Phonograph Record?”