Apollo Guidance Computer Gets The Rust Treatment

Seems like all the cool kids are rewriting legacy C programs in Rust these days, so we suppose it was only a matter of time before somebody decided to combine the memory-safe language with some of the most historically significant software ever written by way of a new Apollo Guidance Computer (AGC) emulator. Written by [Felipe], the Apache/MIT licensed emulator can run either ROM files made from the computer’s original rope core memory, or your own code written in AGC4 assembly language.

It’s worth noting that the emulator, called ragc, needs a bit of help before it can deliver that authentic Moon landing experience. Specifically, the code only emulates the AGC itself and stops short of recreating the iconic display and keyboard (DSKY) module. To interact with the programs running on the virtual AGC you’ll need to also install yaDSKY2, an open source project that graphically recreates the panel Apollo astronauts actually used to enter commands and get data from the computer.

Of course, the next step would be to hack in support for talking to one of the physical recreations of the DSKY that have graced these pages over the years. Given the limitations of the AGC, we’d stop short of calling such an arrangement useful, but it would certainly make for a great conversation starter at the hackerspace.

Thanks for the tip, [CJ].

Blink An LED On A PIC32 With Rust, Easily

Got a PIC32 microcontroller and a healthy curiousity about the Rust programming language and its low-level capabilities, but unsure how to squash the two of them together with a minimum of hassle? If that’s the case, then today is your lucky day!

[Harry Gill] has you covered with his primer on programming a PIC32 with Rust, which will have you blinking an LED in no time. [Harry] admits that when he got started, his microcontroller programming skills were a bit rusty, so don’t let yourself think setting this up is beyond your abilities. If you have a working knowledge of the basics of microcontroller programming, you’ll be fine. [Harry] had to jump through a few hoops to get the right tools working, but thoughtfully documented the necessary steps, and provides a bare minimum hardware list.

Unsure what Rust is or what it offers? Check out the basics here, and see if it’s something that interests you. If you want to look even deeper, check out the kind of work that goes into writing a bare metal kernel in Rust.

Potassium ferrioxalate crystal

Growing Spectacular Gem-Like Crystals From Rust And Simple Ingredients

When we talk about crystals around here, we’re generally talking about the quartz variety used to make oscillators more stable, or perhaps ruby crystals used to make a laser. We hardly ever talk about homegrown crystals, though, and that’s a shame once you see how easy it is to make beautiful crystals from scratch.

We’ve got to say that we’re impressed by the size and aesthetics of the potassium ferrioxalate crystals [Chase Lean] makes with this recipe, and Zelda fans will no doubt appreciate their resemblance to green rupees. The process starts with rust, or ferric oxide, which can either be purchased or made. [Chase] chose to make his rust by soaking steel wool in a solution of saltwater and peroxide and heating the resulting sludge. A small amount of ferric oxide is added to a solution of oxalic acid, a commonly used cleaning and bleaching agent. Once the rust is dissolved, potassium carbonate is slowly added to the solution, turning it a bright green.

The rest of the process happens more or less naturally, as crystals begin to form in the saturated solution. And boy, did they grow — long, prismatic lime-green crystals, with a beautiful clarity and crisp edges and facets. The crystals don’t last long under light, though — they quickly lose their clarity and become a more opaque green.

[Chase]’s crystal-growing efforts have shown up here before, when he turned humble table salt into beautiful cubic crystals. We find the whole crystal-growing process fascinating, and we’re looking forward to more of this in the future.

The ray tracer racer

Whipping Together A Little Ray Tracer Racer

When you hear raytracing, you might think of complex dark algorithms that to stare too long at their source code invites the beginning of madness. And you’re technically not far off from the truth, but [h3r2tic] put a small open-source ray tracing game demo up on GitHub. The actual rust code powering the game is relatively short (just four files), with the longest file being the physics file. But, of course, there is a small mountain of code under this sample in the form of libraries.

Kajiya, physx-rs, and dolly are the three libraries that make this little demo possible. Kajiya, in particular, is what makes raytracing possible as it uses the newer RTX features (so only more recent Nvidia and AMD cards are supported) and Vulkan bindings. But, of course, it isn’t wholly ray-traced as we are still several years out from proper real-time raytracing. Nevertheless, the blend between raytracing and traditional rasterization looks incredible. The most important thing about this simple tiny sample isn’t the game itself but what it stands for. It shows how easy it is to create a sample like this. Even just five years, creating a demo like this required massive effort and expertise.

Visually, it is stunning to look at. While the reflections are most apparent, the takeaway from this is the ease that real-time global illumination brings. A quick look through the code shows that there are very few lights in the scene, despite looking well lit with soft shadows. Traditional video games spend a significant amount of development time lighting a scene, placing additional lights, and tweaking them to make up for all the shortcuts that lighting has to take in a rasterized environment. As more and more games are built with raytracing in mind rather than tacked on at the end, we can ditch the small crumbling mountain of hacks that we are forced to use in games today and just rely on the rays to accurately light a scene.

If using a library for your raytracing seems too easy, perhaps you’d like to take on the challenge of raytracing in excel. Video after the break.

Continue reading “Whipping Together A Little Ray Tracer Racer”

Making Your Own Touchpad With PWM And Rust

The modern touchpads are incredible feats of engineering, with everything from complex signal processing for noise and tremendous economies of scale driving prices low. So [Kevin] decided to see if he could make his own touchpad. Partially out of curiosity of what makes one touchpad better than another, but also because he was curious if he could. Using an STM32 and a custom PCB, he was off to the races in an incredibly cost-effective way.

After writing some quick firmware in Rust, he was reporting the values read by the PWM channels. Using python, he could get a good idea of the raw values that were being written over USB and visualized. So rather than implement filtering in hardware or firmware, he elected to do the filtering and processing on the host computer side in Python. We suspect this gave him much shorter iteration cycles.

If you like the idea of making your own touchpad but perhaps are dreaming a little bigger, why not make a tablecloth-sized touchpad?

Need A New Programming Language? Try Zig

Maybe you’ve heard of it, maybe you haven’t. Zig is a new programming language that seems to be growing in popularity. Let’s do a quick dive into what it is, why it’s unique, and what sort of things you would use it for. (Ed Note: Other than “for great justice“, naturally.)

What Is It?

You’ve likely heard of Rust as it has made significant inroads in critical low-level infrastructures such as operating systems and embedded microcontrollers. As a gross oversimplification, it offers memory safety and many traditional runtime checks pushed to compile time. It has been the darling of many posts here at Hackaday as it offers some unique advantages. With Rust on the rise, it makes sense that there might be some space for some new players. Languages like Julia, Go, Swift, and even Racket are all relative newcomers vying for the highly coveted mindshare of software engineers everywhere.

So let’s talk Zig. In a broad sense, Zig is really trying to provide some of the safety of Rust with the simplicity and ease of C. It touts a few core features such as:

  • No hidden control flow
  • No hidden memory allocations
  • No preprocessor, no macros
  • First-class support for optional standard library
  • Interoperable by design
  • Adjustable Runtime Safety
  • Compile-time code-execution

Continue reading “Need A New Programming Language? Try Zig”

Embedded Rust Hack Chat

Join us on Wednesday, May 12 at noon Pacific for the Embedded Rust Hack Chat with James Munns!

Programming languages, like fashion, are very much a matter of personal taste. Professional developers often don’t have much say in which language they’ll use for a given project, either for legacy or team reasons, but if they did have a choice, they’d probably choose the language that works best with the way they think. Some languages just “fit” different brains better than others, and when everything is in sync between language and developer, code just seems to flow effortlessly through the keyboard and onto the screen.

One language that consistently scores at the top of developers’ “most loved” lists is Rust. For a language that started as a personal project and has only existed for a little more than a decade, that’s really saying something. The emphasis Rust puts on safety and performance probably has a lot to do with that. And thanks to its safe concurrency, its memory safety, and its interoperability with C and other languages, Rust has made considerable in-roads with the embedded development community.

To learn more about Rust in embedded systems, James Munns will stop by the Hack Chat. James is an embedded systems engineer, with a history of working on software for a wide range of systems, including safety-critical avionics, and rapidly prototyped IoT systems. He’s a founding member of the Rust Embedded Working Group, as well as a founder of Ferrous Systems, a consultancy focused on systems development in Rust, with a specialty in embedded systems development. James also used to write for Hackaday, so he must be a pretty cool guy. So swing by the Hack Chat and find out where Rust might be able to help you out with your next embedded project.

join-hack-chatOur Hack Chats are live community events in the Hackaday.io Hack Chat group messaging. This week we’ll be sitting down on Wednesday, May 12 at 12:00 PM Pacific time. If time zones have you tied up, we have a handy time zone converter.

Click that speech bubble to the right, and you’ll be taken directly to the Hack Chat group on Hackaday.io. You don’t have to wait until Wednesday; join whenever you want and you can see what the community is talking about.
Continue reading “Embedded Rust Hack Chat”