Open Source Spacecraft Avionics With NASA’s Core Flight System

One thing about developing satellites, spacecraft, rovers and kin is that they have a big overlap in terms of functionality. From communication, to handling sensors, propulsion, managing data storage, task scheduling and so on, the teams over at NASA have found over the years that with each project there was a lot of repetition.

Block diagram of a simplified avionics system. (Credit: NASA)
Block diagram of a simplified avionics system. (Credit: NASA)

Either they were either copy-pasting code from old projects, or multiple teams were essentially writing the same code.

To resolve this inefficiency NASA developed the Core Flight System (cFS), a common software framework for spacecraft, based on code and lessons from various space missions. The framework, which the space agency has released under the Apache license, consists of an operating system abstraction layer (OSAL), the underlying OS (VxWorks, FreeRTOS, RTEMS, POSIX, etc.), and the applications that run on top of the OSAL alongside the Core Flight Executive (cFE) component. Here cFS apps can be loaded and unloaded dynamically, along with cFS libraries, as cFS supports both static and dynamic linking.

There are a few sample applications to get started with, and documentation is available, should you wish to use cFS for your own projects. Admittedly, it’s a more complex framework than you’d need for a backyard rover. But who knows? As access to space gets cheaper and cheaper, you might actually get the chance to put together a DIY CubeSat someday — might as well start practicing now.

Scope GUI Made Easier

Last time, I assembled a Python object representing a Rigol oscilloscope. Manipulating the object communicates with the scope over the network. But my original goal was to build a little GUI window to sit next to the scope’s web interface. Had I stuck with C++ or even C, I would probably have just defaulted to Qt or maybe FLTK. I’ve used WxWidgets, too, and other than how many “extra” things you want, these are all easy enough to use. However, I had written the code in Python, so I had to make a choice.

Granted, many of these toolkits have Python bindings — PyQt, PySide, and wxPython come to mind. However, the defacto GUI framework for Python is Tkinter, a wrapper around Tk that is relatively simple to use. So, I elected to go with that. I did consider PySimpleGUI, which is, as the name implies, simple. It is attractive because it wraps tkinter, Qt, WxPython, or Remi (another toolkit), so you don’t have to pick one immediately. However, I decided to stay conservative and stuck with Tkinter. PySimpleGUI does have a very sophisticated GUI designer, though.

About Tkinter

The Tkinter toolkit lets you create widgets (like buttons, for example) and give them a parent, such as a window or a frame. There is a top-level window that you’ll probably start with. Once you create a widget, you make it appear in the parent widget using one of three layout methods:

  1. Absolute or relative coordinates in the container
  2. “Pack” to the top, bottom, left, or right of the container
  3. Row and column coordinates, treating the container like a grid

The main window is available from the Tk() method:

import tkinter as tk
root=tk.Tk()
root.title('Example Program')
button=tk.Button(root, text="Goodbye!", command=root.destroy)
button.pack(side='left')
root.mainloop()

That’s about the simplest example. Make a button and close the program when you push it. The mainloop call handles the event loop common in GUI programs.

Continue reading “Scope GUI Made Easier”

Data Science The Stanford Way

Data science is a relatively new term for a relatively old discipline. Essentially, it is data analysis, particularly for large data sets. It involves techniques as wide-ranging as statistics, computer science, and information theory. What to know more? Stanford has a “Data Science Handbook” that you can read online.

Topics range from how to design a study and create an analytic plan to how to do data visualization, summarization, and analysis. The document covers quite a bit but is very concise.

Continue reading “Data Science The Stanford Way”

Roll Your Own Python Debugger

Debugging might be the one thing that separates “modern” programming from “classic” programming. If you are on an old enough computer — or maybe one that has limited tools like some microcontrollers — debugging is largely an intellectual exercise. Try a program, observe its behavior, and then try again. You can liberally sprinkle print statements around if you have an output device or turn on LEDs or digital outputs if you don’t. But with a debugger, you can get a bird’s-eye view of your program’s data and execution flow.

For some languages, writing a debugger can be hard — you usually use at least some system facility to get started. But as [mostlynerdness] shows, Python’s interpreter wants to help you create your own debugger, and you can follow along to see how it’s done. This is accessible because Python has a built-in debugging core that you can use and extend. Well, regular Python, that is. MicroPython has some low-level support, and while we’ve seen attempts to add more, we haven’t tried it.

Of course, you may never need to build your own debugger — most of the IDEs have already done this for you, and some of the code is, in fact, lifted from an open code base and simplified. However, understanding how the debugging plumbing works may give you a leg up if you need to create custom logic to trap an error that would be difficult to find with a generic debugger. Plus, it is just darn interesting.

Like many Python things, there are some version sensitivities. The post is in four parts, with the last two dealing with newer API changes.

We can’t promise that Python can debug your hardware, though. We always thought the C preprocessor was subject to abuse, but it turns out that Python has the same problem.

Learn Forth On The Commodore VIC-20

Although BASIC was most commonly used on home computers like the Commodore VIC-20, it was possible to write programs in other languages, such as Forth. Conveniently, all it took to set up a Forth development system was inserting the cartridge into the VIC-20 and powering it on, with the VIC-FORTH cartridge by [Tom Zimmer] being a popular choice for the Commodore VIC-20. In a recent video, the [My Developer Thoughts] YouTube channel covers Forth development using this cartridge.

In addition to the video tutorial, the original VIC-FORTH Instruction Manual is also available, together with the 1541 disk image. In an upcoming video, the Commodore 64 version of the cartridge will also be covered, which is called 64Forth, and which is also readily available to tinker with. For those interested in learning more about [Tom Zimmer] and his Forth-related work, a 2010 interview could be interesting. This covers the other platforms which he developed an implementation for.

As for why Forth might be interesting to developers and users, this comes mostly down to the much lower overhead of Forth compared to BASIC, while avoiding the pitfalls of ASM and resource-intensive nature of developing in C, as the entire Forth development system (compiler, editor, etc.) comfortably fits in the limited memory of the average 8-bit home computer.

(Thanks to [Stephen Walters] for the tip)

Continue reading “Learn Forth On The Commodore VIC-20”

Most AI Content Is Trash, Just Like Everything Else

[Max Woolf] has been working in the AI space since 2015, and among other work has created numerous useful open-source tools. He also recently wrote a thoughtful blog post that attempts to put into words his feelings on the state of things in the wake of experiencing a bit of an AI backlash-related burnout. Essentially, people effortlessly creating vast amounts of bad AI content has caused a bigger problem than we may realize.

How so? Well, Sturgeon’s law (summarized as “ninety percent of everything is crud”) applies to AI as much as it does to anything else. Theodore Sturgeon was a science fiction author and critic (and writer of multiple Star Trek episodes) who observed in the 1950s that while Science Fiction — the hot new popular thing at the time — was often derided by critics as being little more than low quality pap, so was everything else. It was true that most Science Fiction was garbage. But most work in other fields was of similarly low quality, and thus Science Fiction was really no different. It’s all trash, except for the parts one likes. Just like anything else.

What makes this observation particularly applicable to the current AI landscape is that, according to [Max], the incredible ease of use makes AI’s “ninety percent crud” very large indeed, and the attached backlash is similarly big. The remaining ten percent of AI that is absolutely fantastic and full of possibilities? It’s practically invisible due to how quickly the industry is moving, the speed with which the big players are vying to control it, and how unfashionable it has become to admit one is using AI tools at all.

[Max] knows the scene better than most. One of his projects is simpleaichat, a tool aimed not just at enabling people to integrate AI into projects easier, but piercing the hype around AI to more easily reveal just how these tools actually work. Sadly, a general AI backlash has made developing these tools feel rather less rewarding than it once did.

Die of an Altera EPM7032 EEPROM-based Complex Programmable Logic Device (CPLD). (Credit: ZeptoBars, Wikipedia)

Using EPROMS And EEPROMs As Programmable Logic With Lisp

That EPROMs, EEPROMs and kin can be used as programmable logic should probably not come as a major surprise, but [Jimmy] has created a Lisp-based project that makes using these chips as a logic array very straightforward. All it takes is importing the package into one’s Lisp project and defining the logic, before the truth function generates the binary file that can be written to the target chip.

Suggested is the one-time-programmable AT27C512R EPROM (64k x8), but any 8-bit parallel interface (E)EPROM should work, with non-OTP chips being nice unless the chip has to go into a production device. A possible future improvement is the addition of 16-bit (E)EPROM support.

The use of EEPROMs is common with PLA-replacements, as with, for example, the Commodore 64, where the official PLA IC tends to go bad over time. Due to the complexity of the logic in these PLA ICs, here CPLDs are used, which internally are still EEPROM-based, but feature many more programmable elements to allow for more complex logic. If all you need is a bit of glue logic and you are looking for something in between a stack of 74-logic ICs and a CPLD, an EEPROM may be just be the solution, regardless of whether you prefer to create the binary image with Lisp or C.

Continue reading “Using EPROMS And EEPROMs As Programmable Logic With Lisp”