Balanced Design And How To Know When To Quit Optimizing

I got a relatively inexpensive 6040 CNC machine, and have been spending most weekends making the thing work, and then cutting stuff, learning the toolchain, and making subsequent improvements. Probably 90% of my machine time has been on making improvements. It’s not that the machine was bad — I got the version with ballscrews and a decently solid frame — but it’s that it somehow didn’t work together as a whole. It’s just an incredibly unbalanced design.

Let’s start with the spindle motor. It’s a 2.2 kW water-cooled beast that is capable of putting tons of work into a piece and spinning at very high speed. Yet to keep up with the high speed spindle, the motors that move it around would have to be capable of high speeds as well — it’s a feeds and speeds thing if you’re not a CNC geek. And they can’t. Instead, the stepper motors that came with the kit are designed for maximum force at low speeds. Which can make sense for some machines, but for one with a slightly flexible X-axis like this one, that’s wasted as well. The frame just can’t handle the low-end grunt that the motors are capable of, so it can’t take advantage of the spindle’s power either. The design is all over the place.

Over the last two months’ of weekends, I’ve been going through this iterative procedure of asking “what is my limiting factor right now?”, working on fixing that thing up, running it some, and then asking the question again. And it’s a good general procedure, and I believe that it’s getting me to the machine I want at the minimum cost of time, money, and effort.

At first, it was the driver hardware/software with its emulated USB parallel port, so I swapped out the controller for an Arduino running GRBL, soldered directly to the DB-25 that comes out of the back. At least it can put out pulses fast enough to order the motors around, but they would still stall out at high speeds. Swapping the stepper motors out for a high-speed pair only cost me €40, which makes you wonder why they didn’t just put the right motors on in the first place. The machine now travels fast enough to make use of the high-speed spindle, and I’m flying through plywood and plastics without leaving burn marks. It’s a huge win for not much money.

The final frontier is taking big bites out of aluminum. The spindle can do it, but I fear I’m up against the frame’s rigidity on the X-axis. For whatever reason, they went with unsupported rods on the X, which are significantly more flexible than an axis that’s backed up by more metal. And this is where the limiting factor may actually be my time and patience, rather than money. I just can’t bear to disassemble and reassemble the thing again. So for now, it’s going to be small nibbles, taking advantage of the machine’s speed, if not yet the spindle’s full horsepower.

But it’s odd, because this machine is a bundle of good parts. It’s just that they haven’t been chosen to work together optimally; the frame doesn’t work with the stepper motors, which don’t work with the spindle. If they went through my procedure of saying “what’s the limiting factor?” they could have saved themselves €100 by just shipping it with a wimpier spindle, which would have been a balanced, if anemic, machine. Or they could have built it with the right motors for more speed. Or supported rails for more grunt. Or both!

I’ll never know why they quit optimizing their design when they did. Maybe they never got past the slow USB/parallel port speed? But I’m near the end of my path, and I can tell because the limiting ingredient isn’t a simple upgrade, or even mere money anymore, but my own willpower.

How can you tell when you’re at the top of a mountain in a dense fog? A step you take in any direction would lead you downhill. How can you tell when you’re satisfied with a project’s state? When you don’t have the need, or desire, to undertake the next most obvious improvement.

Frances Allen Optimised Your Code Without You Even Knowing

In 2020, our digital world and the software we use to create it are a towering structure, built upon countless layers of abstraction and building blocks — just think about all the translations and interactions that occur from loading a webpage. Whilst abstraction is undoubtedly a great thing, it only works if we’re building on solid ground; if the lower levels are stable and fast. What does that mean in practice? It means low-level, compiled languages, which can be heavily optimised and leveraged to make the most of computer hardware. One of the giants in this area was Frances Allen, who recently passed away in early August. Described by IBM as “a pioneer in compiler organization and optimization algorithms,” she made numerous significant contributions to the field. Continue reading “Frances Allen Optimised Your Code Without You Even Knowing”

Gaming In Different Languages

One of the perks of using older hardware is its comparative simplicity and extensive documentation. After years or decades of users programming on a platform, the amount of knowledge available for it can become extensive. This is certainly the case with the 6502 microprocessor, used in old Apple computers and some video game systems from the ’80s. The extensive amount of resources available make it a prime candidate in exploring various programming languages, and their advantages and disadvantage.

This project looks into those differences using a robot game, which has been programmed four different ways in three languages. [Joey] created the game in Python first and then began to port it to the 65C02, a CMOS variant of the 6502. The first iteration is its assembly language, and then a second iteration with optimized assembly code. From there, he ports it to C and then finally to Forth. Each version of the game is available to play in a browser using an emulator to run the 6502 hardware.

Since the games run in the browser, other tools are available to examine the way the game runs in each language. Registers can be viewed in real time, as well as the values stored in the memory. It’s an interesting look at an old piece of hardware and of its inner workings. For an even deeper dive into the 6502, it’s possible to build a working computer on breadboards using one.

Compiler Explorer, Explored

It wasn’t long ago that we introduced you to a web site, the Godbolt compiler explorer, that allows the visitor to compile code using a slew of compilers and compare their output. We suspect some number of readers said, “Wow! I can use that!”, while perhaps everyone else said, “Huh?” Well if you were in the second group, you ought to watch [What’s a Creel’s] video below where he walks through using the website. He looks at four different algorithms using four different compilers and it is a good example of how you might use the tool to make decisions about how you write software.

Continue reading “Compiler Explorer, Explored”

Dirty Tricks For 6502 Programming

We know the 6502 isn’t exactly the CPU of choice for today’s high-performance software, but with the little CPU having appeared in so many classic computers — the Apple, the KIM-1, The Commodores, to name a few — we have a real soft spot for it. [Janne] has a post detailing the eight best entries in the Commodore 64 coding competition. The goal was to draw an X on the screen using the smallest program possible. [Janne] got 56 bytes, but two entrants clocked in at 34 bytes.

In addition to the results, [Janne] also exposes the tricks people used to get these tiny programs done. Just looking at the solution in C and then 6502 assembly is instructive. Naturally, one trick is to use the existing ROM code to do tasks such as clearing the screen. But that’s just the starting point.

Continue reading “Dirty Tricks For 6502 Programming”

Pop-Up Outlet Helps Make The Most Of A Tiny Shop

You’ve got to admire the steps some people take to squeeze a shop into a small space. Finding ways to pack in ever more tools and to work on bigger and bigger projects become ends to themselves for some, and the neat little tricks they find to do so can be really instructive.

Take this workbench pop-up outlet strip for example. The shop that [Woodshop Junkies] occupies appears to be a single-car garage, on the smallish size in the first place, that is almost entirely filled with a multipurpose workbench. It provides tons of storage underneath and a massive work surface on top, but working with small power tools means stretching extension cords across the already limited floor space and creating a tripping hazard. So he claimed a little space on the benchtop for a clever trap door concealing a small tray holding an outlet strip.

The tray rides on short drawer glides and, thanks to a small pneumatic spring, pops up when the door is unlatched. There was a little trouble with some slop in the glides causing the tray to jam, but that was taken care of with a simple roller bearing. The video below shows its construction and how it stays entirely out of the way until needed.

As cool as this build is, it’s just icing on the small shop cake when compared to the workbench. [Woodshop Junkies] has a complete playlist covering the build which is worth watching. And you might want to refer to our tiny shop roundup for more tips on getting a lot done in a little space.

Continue reading “Pop-Up Outlet Helps Make The Most Of A Tiny Shop”

New Game, Old Ways: Cramming An NES Game Into 40 KB

Why would anyone bother to create new content for a console system that’s staring down its 40th birthday? Perhaps just for the challenge of fitting a game into 40 kilobytes of storage.

That at least seems to be the motivation behind [Morphcat Games] pending release of Micro Mages, a new game for the Nintendo Entertainment System console that takes its inspiration from Super Mario Bros. The interesting bit here is how they managed to stuff so much content into so little space. The video below goes into great detail on that, and it’s a fascinating lesson in optimization. The game logic itself is coded in assembler, which of course is far more efficient than higher level languages. Even so, that took 32 kB of ROM, leaving a mere 8 kB for background elements and foreground sprites.

Through a combination of limited sprite size, tiling of smaller sprites to make larger characters, and reusing tiles by flipping them horizontally or vertically, an impressively complete palette of animated characters was developed. Background elements were similarly deconstructed and reused, resulting in a palette of tiles used to generate all the maps for the game that takes up just 60 bytes. Turning those into playable levels involves more mirroring and some horizontal shifting of tiles, and it looks like quite an engaging playfield.

Yes, there’s a Kickstarter for the game, but we’re mainly intrigued by what it takes to cram a playable game into so little space. Don’t get us wrong – we love the Retro Pie builds too, but seeing the tricks that early game developers relied upon to make things work really gets the creative juices flowing.

Continue reading “New Game, Old Ways: Cramming An NES Game Into 40 KB”