Live data from Hacker News

Exploring the software that flies SpaceX rockets and starships

stackoverflow.blog

111–118 of 118 posts

Re: Exploring the software that flies SpaceX rockets and starships

#111

Earlier quoted context omitted.

Right. I can see how that could be useful in some situations but presumably it wouldn't work very well for a very dynamic situation like a rocket in flight (changing height, orientation, fuel, thrust every millisecond) And you still need a control loop to look for sensor changes? Its just a way of caching most of the computation?

It can work well for dynamic event-driven problems, with no need for a central busy loop[1]. Any sensor changes are responsible for triggering an update in any nodes that depend on it, who are responsible for triggering nodes that depend on those, and so on. One way to do it: abstract class Node, which has a list of child nodes that it loops through and alerts whenever there's been a state change in the parent node.…

One reason why this is dangerous is that you can see extremely large changes in the CPU load. For a bunch of cycles, there's apparently nothing to do, then there's a whole bunch of stuff to do, then there's almost nothing etc.

This makes it hard to reason about the overall capacity of the system (in terms of numbers of sensors and actuators). You will always end up uncertain whether you've ever really evaluated the "full load" condition, even if you formally test it in ways that say you have.

Re: Exploring the software that flies SpaceX rockets and starships

#112

On the topic of rocket flight computers, here's a link to an FC I built last year for my model rocket. It does thrust vectoring and some rudimentary navigation. The control loops on this thing run at 200hz though. It's got a state machine for knowing what to do at each stage of flight as well. https://github.com/polishdude20/CygnusX1

If you analyze the physics, you find that the way the inertia works out is that smaller things need shorter control cycles. The relevant timescales for large objects ends up being longer.

Re: Exploring the software that flies SpaceX rockets and starships

#114

Earlier quoted context omitted.

Unlikely, they talk about 50hz and 10hz tasks. Real time OS often allow you to create threads that run at a given rate and must comolete. Like the 50hz task would have 20ms to complete.

Very likely: while(true) { ...[50hz tick tasks] if(tick%5==0) { ...[10hz tick tasks] } wait_for_next_tick(); tick++; }

`wait_for_next_tick();` in any microcontroller-based embedded system will put the CPU to sleep, often lowering your overall power consumption from the mA range it uses while actively running, to the uA range.

Some systems, like those based on coin cells, will completely shut down the chip, leaving only a single timer or input active, and when triggered will turn back on and initialise the entire CPU again to handle the input/timer. Some microcontrollers give you a small allocation of you can preserve under these conditions. That's how you get year+ runtimes on tiny batteries.

Edit: if you want to nerd out on this, I would start with Jack Ganssle's excellent guide: http://www.ganssle.com/reports/ultra-low-power-design.html

Re: Exploring the software that flies SpaceX rockets and starships

#115
post #112

On the topic of rocket flight computers, here's a link to an FC I built last year for my model rocket. It does thrust vectoring and some rudimentary navigation. The control loops on this thing run at 200hz though. It's got a state machine for knowing what to do at each stage of flight as well. https://github.com/polishdude20/CygnusX1

If you analyze the physics, you find that the way the inertia works out is that smaller things need shorter control cycles. The relevant timescales for large objects ends up being longer.

Yeah that makes sense! A lot more can go wrong on smaller things in a short amount of time

Re: Exploring the software that flies SpaceX rockets and starships

#116
post #23
post #2

The article is a bit light on technical details, but the following is noteworthy: > Flight software for rockets at SpaceX is structured around the concept of a control cycle. “You read all of your inputs: sensors that we read in through an ADC, packets from the network, data from an IMU, updates from a star tracker or guidance sensor, commands from the ground,” explains Gerding. “You do some processing of those to de…

In all the embedded code I’ve seen there is invariably a “while(true)” somewhere. Is this not the same?

On Arduinos, it's actually "for (;;)", which surprised me.

https://github.com/arduino/ArduinoCore-avr/blob/master/cores...

Re: Exploring the software that flies SpaceX rockets and starships

#117
post #2

The article is a bit light on technical details, but the following is noteworthy: > Flight software for rockets at SpaceX is structured around the concept of a control cycle. “You read all of your inputs: sensors that we read in through an ADC, packets from the network, data from an IMU, updates from a star tracker or guidance sensor, commands from the ground,” explains Gerding. “You do some processing of those to de…

The flight software is actually a real-time (aka deterministic) embedded system software. And the control loop is the typical control loop found in embedded systems: 1 - read data from sensors through ADC (Analog-To-Digital Converters), I2C, SPI, CAN (Controller Area Network) and so on; 2 - compute the output to actuators, such as motors, hydraulic cylinders, valves, motors, lights and so on, using some control law and the current state; 3 - repeat the cycle. The algorithm that drives the output may be based on algorithms from control theory, namely state space model, PID control or Kalman filter. The computers that they may be using might be single-board computers based on ARM-core, MIPS-core, PowerPC or even X86 variant for embedded systems and/or lots of microcontrollers. Before the advent of computers, the control theory algorithms were implemented using "analog computers", which are specially designed analog circuits for computing differential equations.

Control theory algorithms can be developed using tools such as Matlab, Matlab-Simulink, Modelica or Scilab-Scicos (Open-Source) from Inria. Besides C or C++, another language used in embedded systems like that is Ada, which is much safer and reliable than both C and C++.

Re: Exploring the software that flies SpaceX rockets and starships

#118

are the 50hz chips manufactured at 50hz ? or are they downclocked to 50hz. why cant you use higher clocked speeds ? like even 500 mhz, etc ? is there something special about 10 and 50hz ?

Chips have internal timers which can be configured programmatically so they emit hardware interrupt in specified time intervals. When the interrupt is emitted, CPU jumps to the method which executes the certain program. After that it goes idle, waiting for the next cycle.

The greatest Joy in my life today is that i have been cured of Herpes by a Doctor called Dr. Macaulay , I was infected with HERPES Disease in 2019, i went to many hospitals for cure but there was no solution, so I was thinking how can I get a solution,so that my body can be okay. Until one faithful day as i was browsing on the internet I saw a testimony on how Dr. Macaulay has helped people in curing Herpes and other diseases, quickly copied his WhatsApp number so i contacted him for solution for my Herpes disease, So Dr. Macaulay told me that his going to prepare his herbal medicine for my health which he sent to me, luckily after 2week my Herpes was cured. Dr Macaulay is well recognize as one of the best herbalist doctor in Africa, you don't have to be sad anymore or cry anymore on this disease when the cure is available. .For enquiries:Via:Dr.Macaulayherbalhome@yahoo.comWhatsApp: (+2349067522465)https://wa.me/message/HJO6BWJEP4CFJ1
Post reply on HN