Evan's Blog

Margo flight computer part I - The hardware

After LURA’s last launch in June, the conversation moved to the next year. New projects, new goals, new members, and of course, new leadership. I received some terrible news - I was being promoted back to Avionics team lead.

Now, I’ve had this position before and I did not enjoy it. I am a programmer at heart. Sure, I love working with hardware, but I’d prefer if my involvement began with a board being handed to me and ended with me handing a programmed board back. I know about microcontroller programming and I can read a datasheet like a book, but electronics and PCB design is not exactly my specialty. However, I was now begrudgingly being put back in that position like a parliamentary speaker being dragged to the front of the house. Previously I managed this by delegating lots of work to other people and eventually handing the position off when I got busy with other projects. But not this time, I decided to take the summer to really try and fill gaps in my knowledge.

The goal was to create a very simple flight computer from scratch. The main requirement was to keep this dead simple and easy to build while still creating a functional altimeter to fly on level-1 high power rockets at the end of summer. All it needed was a processor, a barometer, maybe an accelerometer, some storage, and any other peripherals I fancy.

I mentioned this personal project idea to some of the other leadship team at LURA, and someone told me that for LURA academy (our training programme for new members) they were going to ask me to design a simple PCB that the new members could assemble and program. I could not have asked for a better coincidence - my personal project was now coming out of LURA’s pocket!

One last thing, it needs a name. Our previous mainline flight computer was called the Hamilton Flight Computer, named for avionics pioneer Margaret Hamilton. Last year I watched the sci-fi show For All Mankind (it’s pretty good, I really enjoyed the first 2 seasons but it started to lose me afer that), they have a character named Margo Madison who is based on Margaret Hamilton. This flight computer is based on the Hamilton Flight Computer. Hence, the Margo flight computer!

The first step was to throw together a parts list, while cost wasn’t a primary concern, the components needed to be relatively cheap as we might be building 5-6 of these for the academy.

The requirements

Part list

Processor - STM32F0

I am already very familiar with the STM32 series, so it made sense to stick where I was familiar. We previously used an STM32L4R5VIT6 (that product code is permanently engrained into my brain) but I scaled it back to a much smaller ARM Cortex M0 based STM32F0. I actually consider this a bit of a mistake, but we’ll get to that later.

Barometer - MS5607

This was an easy choice, we previously used an MS5611 which is the gold standard for consumer available barometers, it was the first sensor I ever programmed! Dropping in it’s little brother in the MS5607 was a no-brainer, even though it’s relatively expensive.

Accelerometer - LIS2HH12

I went back and forth on whether to even include an accelerometer forever, and I eventually landed on putting in an LIS2HH12, which is not a good choice. It can only read up to 8g and will be easily satured by some launches. I couldn’t find a suitable low cost alternative so I just decided to leave it on rather than go through the work of removing it.

USB-C

As a consumer, I hate Micro USB. I have almost entirely ridded my life of this horrible connector with the only holdouts being an old speaker, oh, and of course every electronics development board apparently.

I decided that we at LURA are banning Micro USB unless otherwise absolutley necessary.

Thus, this board will have USB-C.

Storage

We previously used a 1gb NAND flash package that was VERY slow and VERY annoying to program. After searching for alternatives I settled on the popular W25Q128JVE. This only has a teeny tiny capacity but it should be enough, and allows us to interface with a much simpler SPI interface.

Everything else

Naturally, you need some other bits like voltage regulators, a programming header, a JST battery connector, etc. I also added some optional bits like an LED and a buzzer. You also need a bunch of resistors and capacitors, I chose comparatively massive 0805/2012 since this was my first time doing SMD soldering. Although in hindsight the resistors and capacitors were easy and I could have gone with a much smaller size.

Schematics

The next step was to design the schematics, I found this to be quite fun, and scratched a similar itch to Programming. It even borrows some concepts like global and local variables that made sense to me straight away.

The global level schematic for Margo The local level schematic for Margo’s MCU logic

Routing

Oh my god routing is the worst. As soon as you think you’ve got a decent layout you realise there’s another component that conflicts with everything else you’ve done. It takes some serious thinking ahead and planning to get a decent layout, and this is a very simple 2 layer PCB! In the end, I don’t think this layout is good but it could be worse.

Ok it’s not actually that bad. It’s easy to get into a rat’s nest mess with it, but once it comes together it can be very satisfying.

A picture of the routing of this PCB

A 3d render of the Margo flight computer

The board was manufactured by Eurocircuits, who actually sponsor LURA! The boards we get from Eurocircuits are really great, and this one only came to about €60 for a set of 2.

Assembly

Now, an embarassing confession, I have never done SMD soldering before. There’s always been someone sat next to me who can do it in half the time and double the quality. This would be a first time and a great learning experience, and while I tried to pick components to minimise assembly pain, there’s some hard components on here.

I found this series really helpful for learning the best methods for each component type.

It was quite difficult, I messed up the first MCU attempt badly, but it came together ok in the end. The key was to just cover everything in flux, flux, and more flux.

The assembled Margo PCB

Look, I’m not trying to win any prizes for my soldering, but I’m pretty proud I managed to put this thing together so quickly.

Also, seeing this thing fully assembled was one of my most satisfying pieces of work I’ve ever done. This is nowhere near the hardest project I’ve ever done, but the physicality of feeling your work pay off is unrivaled.

Mistakes

I definitely expected to make a bunch of mistakes with this project, but to be honest I didn’t make anywhere near as many as I thought. Once you have a decent schematic and the DRC and ERC checks passed ok it came together pretty quick. Even assembly was easier than I expected, and there was very little debugging to do after. However I obviously did make some mistakes.

The good thing about this project is that I pretty quickly get to design a second version with all these mistakes fixed. I can pretend like it never happened.

Voltage regulator not regulating

In the above assembled picture you can see that the voltage regulator in the bottom right has two pins bridged, this wasn’t an assembly mistake but is actually just to cover up a schematic mistake I made earlier. The TLV76733DGNR Fixed Voltage Regulator’s pin 2 (labelled SNS) is actually quite important it turns out, and I shouldn’t have left it floating…

If I payed a bit more attention to page 4 of the datasheet

Output sense pin. Connect the SNS pin to the OUT pin, or to remotely sense the output voltage at the load, connect the SNS pin to the load. Do not float this pin. For fixed voltage version devices only

Oops, well anyway I could just cover this up with a bit of solder and it’s all fine.

STM32 what now?

So I chose that STM32F0 pretty quickly, I just wanted an ARM Cortex M0 processor core and didn’t want to think about it too long, but an STM32L0 series chip would have been similar in functionality and have lower power usage which would be more suitable for a project like this. This isn’t the biggest mistake, with a typical power consumption of 25ma this will last plenty long on a small LiPo.

In future, it’s good to know the STM32 series has a standardised naming convention that is really handy to memorise until they don’t follow it sometimes.

Upside down LED component

I was really proud of this little LED circuit I came up with, I selected a nice looking red-green LED that has two power lines, powering one will make the LED go red, and powering both would make it turn green. I wired the red line straight to the power rail and the green LED line into a GPIO pin. The idea being at a glance you can see the state of the board, either unpowered, powered with no firmware booted, or powered with firmware booted.

I still like this idea, but I somehow managed to chose a downward facing LED that points through the back of the board. Not sure how I managed that.

Part II - Software

Coming soon