Cananka for Framework Laptop

Illustration

I find the Framework laptop an interesting concept and the only thing preventing me from buying one was the fact there’s no 15" model. As I use a laptop screen as my primary visual interface most of the time, I simply find 13" a tad bit too small. However, I couldn’t help but notice their developer program for expansion cards. And that peeked my interest. Can I fit a CAN bus interface there?

All resources for expansion cards are part of a reasonably structured GitHub repository. In there you’ll find KiCAD templates for creating your own PCB and a bunch of a mechanical drawings in addition to an enclosure suitable for 3D printing. Those using other PCB software are kinda out of luck as board description is not sufficient to replicate all the curves board has. Fortunately, due to KiCAD using a (relatively speaking) simple human-readable file format, I managed to create a DipTrace PCB template.

Since I already have a CAN bus USB controller, I figured to just make everything a bit smaller while retaining as much features I could. It was immediately clean that I couldn’t support a fully insulated interface as there was no chance to fit all components. Cananka mini was as good as it gets. While most of LEDs had to go due to the lack of space, the programmatically-controlled bus termination thankfully remained.

After much jiggling of components in order to fit them, all was done. A type-C connector was a pain in the butt to hand solder and 0.5 mm microcontroller and UART controller were close to follow. Even better, all passives retained their 0805 size. I did have to go with a full size PCB in order to fit everything onto a single PCB side but I figured 3D printed case would be ok.

Selecting a user-facing connector was a pure trouble and I went over multiple ideas to no avail. My favorite failure was using an edge connector with a Phoenix ZEC connector attached to it but I found it sticking from the side of laptop was a bit too much. At the end I went with a surprisingly well-fitting bodge. A vertical JST PH connector required just a minimal pin bending to fit highly restricted module height perfectly. Not only that but the connector is common enough that finding a premade cable (or making your own) will present no trouble.

Manufacturing board was actually a breeze as I modified PCB slightly as not to cause warnings with the Molex 105444-0001 connector. Any manufacturer capable of producing double-sided 0.8mm PCB at 6/6 should be just fine. And yes, you really need thinner than regular PCB in order to mount a type-C connector.

With PCB in hand and after a LONG time waiting for components (darn car manufacturers got all the good CAN bus stuff), I was ready to test the device. And here is the genius of Framework’s extension card design - it’s still just a type-C so I managed to test everything before ever needing a Framework device. Really easy R&D.

Illustration

However, with all electrical stuff out of way, it came time to see if my expansion card can actually fit. I contacted Framework for a loaner laptop to test it, got it in a few days, tried to push card in, and… the darn thing fitted like a glove. :)

While I would consider the whole adventure a success, I am not completely happy. First of all, a full size PCB was a mistake. I expected it to terminate 1 or 2 millimeters before module’s edge but in reality it’s flush with the frame. That means my connector is actually sticking out a bit. Probably not enough to matter for normal handling but any harder blow to the side (e.g. due to throwing a laptop into the bag) runs risk of just shearing the connector off. Also, while 3D printed case is fine for prototyping, having a better looking finish would go a long way.

Illustration

What’s next then? Well, the first step will be shortening PCB by a few millimeters as not to have connector sticking out from side. This change will be easily done as there is still enough space on a PCB. But that’s not where I’ll stop.

My thoughts go toward making the board even smaller as to fit into the existing Framework USB type-A enclosure. While this will mean I will have to go toward double-sided PCB load, it will look MUCH neater even though there will be some extra space. My thinking is to 3D print a transparent plug that would allow a status LED to shine through. That would avoid the “gaping hole” look while actually serving a purpose.

Timeline for this is a painful topic. While I managed to obtain some PIC18F25K80 chips, I am completely out of MCP2221A. And the soonest anybody seems to be able to get them is end of the year. And let’s not even talk about MCP2561 CAN bus controller. In short, I don’t expect anything new before the next year no matter how quickly I turn the PCBs around.

However, for now, I have the single Framework with a “native” CAN bus interface out there. :)


PS: While I did ask Framework for a loaner, I was told to just keep it once I queried how to send it back. I don’t believe my experience with developing and designing expansion card was affected by this as 95% of this work was completed way before a free Framework landed in my lap. I was never asked by a Framework team to write anything nor they conditioned sending me laptop to a positive coverage.

PPS: Yes, despite now having a 13" Framework in my possession, I still hope to purchase a 15" variant if it becomes available.

Longwave Fun (part 4; aka Failure)

This is a part 4 (out of 4) in my WWVB time signal series (part 3).


Illustration

While I had a tremendous amount of fun making PIC-based WWVB receiver and both hardware and software worked, it wasn’t a full success. Frankly, I would recommend anyone wanting time synchronization functionality to use a Raspberry Pi based version (also available for purchase). Reason is one and one only - operating frequency.

With Raspberry Pi working at 1 GHz+ it’s really easy to generate precise 60 kHz carrier wave and keep the timing straight. Microchip PIC16F1454 working at 48 MHz should be capable of giving a nice clean 60 KHz waveform too. In practice, it doesn’t. In order to allow the internal clock (a minor miracle, if you ask me) to work with USB, PIC will keep doing minor adjustments with every received packet. It will be awesome for USB but any external element will see this as a slight drift.

My Casio watch takes its time to synchronize to WWVB signal and, until done, it keeps comparing it to its internal quartz. And it has a damn good quartz so these micro-adjustment PIC makes really mess with it. Nine times our of ten, it would just abort synchronization since it thought signal was unreliable. In short, it was a pain in the butt.

And yes, it was possible to synchronize some clocks regardless of these imprecisions. Most clock actually do a much shorter synchronization cycle and without much verification. But the one I wanted to play with was being a smart alec. And in general, I actually found watches to be more picky than clocks - go figure.

Having an external crystal for microcontroller would help with stability. But it would need to be a full 48 kHz one. Guess what - the maximum supported frequency for external clock is 20 MHz. So, if we go with 16 MHz and 3x PLL, we’re in a slightly less leaky boat but still not out of woods (I just love mixed metaphors.)

Combine that with a general simplicity Raspberry Pi solution provides and the whole microcontroller-based solution was doomed to be inferior. But there are worse ways to spend a few weekends. :)

Longwave Fun (part 3; aka Firmware)

This is a part 3 in my WWVB time signal series (part 2, part 4).


Illustration

When connecting custom hardware to a computer, I love using a serial port interface. It’s widely supported and there are so many tools you can use to connect to it. While it’s common to use UART-USB interface chips (e.g. notorious FTDI or my current favorite MCP2221A), I chose to skip that part. As project was using PIC16F1454 that has USB capabilities, it seemed quite sensible to roll one’s own serial port interface.

The serial port code is based on Microchip’s CDC example but with all unnecessary parts removed. Since I wanted direct communication, all that baud rate stuff could go out. Yes, you can talk to the hardware at any baud rate you want - USB doesn’t care nor does my code. A bit unusually, I used polling instead of interrupts for USB. It actually doesn’t impact the USB communication speed for this use case and it leaves interrupts clean for timer code that’s much more sensitive to timings.

And this code is all about timing. The carrier signal is generated using PWM functionality. Based on the built-in frequency signal (48 MHz), it was actually possible to hit 40 kHz (JJY) and 60 kHz (WWVB, MSF, JJY) PWM frequency exactly. But this was not possible for 77.5 kHz (DCF77) so there we have about 0.1% error. Not great, not terrible.

Once we have the carrier sorted out, we need to have a separate time tracking for attenuation. This is in interrupt happening every 0.2 ms until we “collect” 100 ms. At that moment, a decision is made whether to keep the carrier signal as it is, turn it off, or just attenuate it a bit.

The actual data for all this logic is not done in microcontroller. While it would be possible to do for any of the protocols, this microcontroller simply doesn’t have enough programming space to do them all. Therefore, all necessary calculations are done in software and then transferred once a minute to the device.

And that’s about it. The software on a computer calculates bit-stream data for the next minute and sends it to the microcontroller. The microcontroller loads that data and keeps accounting for the current minute. Once minute is over, all repeats again. Yes, there are a few details more but you can discover those yourself.

Of course, the source code is available on GitHub.

Longwave Fun (part 2; aka Standalone)

This is a part 2 in my WWVB time signal series (part 1, part 3).


After I essentially reproduced TxTempus project in PCB format, I thought to myself - what if I remove Raspberry Pi portion and get it working over USB?

Illustration

Choosing the enclosure was the easiest part. I saw this project fitting perfectly in Hammond 1593DBK. Its long format gives me enough space for antenna while its shape just calls for a watch to be placed around it. Even better, if I cannot get the original, there is an extremely similar HP-3653-B from Bud Industries.

Mind you, they are not exactly the same. For example, one has screws on the top while other has them on the bottom. Bud has just a smidgen shorter length. Even the shape of the panel is slightly different. So you cannot really just get PCB designed to fit Hammond directly into the other. However, if you are aware of those things, you can abuse tolerances a bit and design both board and panels that fit either case without any noticeable difference.

At first I decided to have a 0.8mm PCB so my favorite type-C can be easily soldered. PCBWay generously offered to get them to me for free. While this wasn’t the first time I ordered from them (and yes, I paid for boards more times than I got them free) it was the first time I used them for 0.8mm board.

Illustration

They have a crazy amount of options and I keep changing my mind about how user-friendly this is. For some projects it makes sense to go over many options and fully customize everything but having all options on one page is slightly overwhelming and selecting the “wrong” option can really increase the price. If you don’t catch it immediately, it might be hard to figure out which option changed the price. Fortunately, both 1.6mm and 0.8mm are the same price. While some colors do involve extra cost, there is a fair selection of colors you can get for free. I went with green just because it ships faster.

For this project I didn’t go with any extra options and the only thing I missed was gold plating. While their HASL surface was leveled and I didn’t have any issues soldering 0.65mm SSOP components, the “golden” ENIG finish is nicer. However, $35 price increase for such finish seemed excessive and was not worth it for me.

When it comes to how the finished board looks, a basic green PCB is not a looker. While normal 1.6mm boards are a bit translucent, going to 0.8mm makes it excessively so. I cannot say I’m a fan of how it ended up looking and I would go with any other color (love the blue they have), even if it means a few days more.

Also worth it, is the removal of an internal product number PCBWay places on their boards unless you pay the extra $3. The placement itself was unobtrusive and sensibly done (way better than a few years before) but I am not sure if it was due to the care or pure coincidence. Even so, I think not having that number should be the default (and free).

My board didn’t push any limits (8/8 mils) so I didn’t really expect any issues. And I must say I saw none. The quality was good with traces looking really even. Based on just that I can bet their process is quite better than 6/6 they offered as a default. Either way, hand soldering 0.65mm SSOP was not troublesome at all. Not only traces and their solder masks were perfectly aligned but also surface didn’t have any serious leveling issues. I did notice there were some leveling artefacts (more on those later) but they seemed to be purely visual.

Interestingly, something went wrong with board sizes once I uploaded gerbers and my board suddenly became smaller as the order was placed. Their support did notice the same and we managed to sort it out but it caused a small delay. And yes, it was repeatable as board I ordered some time later (non-sponsored) had the exactly same issue. It might have been that their parser had issues with my DipTrace gerbers but I didn’t notice anything suspicious in them.

In any case, the boards arrived quickly. Some might say too quickly as I was still waiting for my microcontroller of choice - PIC16F1454. And I waited. And waited. Yep, I got hit by a chip shortage. But eventually Microchip came through (yes, I had to order directly from them) and the chips were in my hand.

PCB design itself was reasonably simple and only about a fifth of board was used by components. The heart was already mentioned 16F1454 with an USB connector on one side and an antenna output on another. And I simply love this microcontroller.

If you want to make a serial USB device, it’s hard to get it easier than this. The only extra components you need for everything to work are two capacitors; one for general decoupling and one for the built-in USB module regulator. No external crystal, voltage regulator, nor USB pull-ups. That leaves fair 9 pins for general I/O.

Considering I just needed USB communication (D+ and D- pins), PWM module to generate 60 kHz, one output to modulate antenna signal, and another to blink a LED, even this microcontroller was more powerful than needed. However, if I needed some other features (e.g. ADC), its pin-compatible brethren - 16F1455 and 16F1459 - would allow for some growth before going to a completely different device.

The most notable board feature is, of course, its rectangular PCB antenna. First of all you should understand that realistically you cannot create a good 60 kHz antenna on a PCB. For such a low frequency you need a LOT of wire and this PCB is way too small to fit so many loops. Even if I could fit all these loops, a PCB is not a friendly environment for it. Not only putting wire loops in a close proximity will make an inductor but it will also make a capacitor and a decent resistor.

Even if you cajole inductance and capacitance to get it to resonate at a right frequency, the amount of resistance all those trace loops have would force us to use a proper antenna driving circuit and not just a few resistors you see here. Even with all that, the imperfections in PCB process would make it impossible to retain all parameters from board to board as even the smallest trace change would throw it out of whack. And remember, we’re talking here about impractically big PCB to start with.

However, since I was intending to use this antenna in a close range, a lot of things don’t matter. Having such a huge mismatch actually helps with preventing signal going to far and messing with devices further away. It also doesn’t matter if antenna has solder mask removed or not. For this board I decided to go with solder mask removed but looks are literally the only reason for that decision. At 60 kHz this solder mask simply doesn’t change anything.

Illustration

While waiting for components to arrive, I also decided to trim board a bit and make it easier to solder as not everybody likes SSOP and a type-C connector. This variant was a standard 1.6mm, slightly shorter in length, and with some components moved around a bit. And yes, I got it too from PCBWay but I paid for it with my own money . Regardless, the service I experienced was the same (including support for gerber size issue). The only change was a definitely nicer blue color - well worth extra few days of waiting if you ask me.

One extra thing I noticed about the blue board is that antenna looks much nicer and more leveled when compared to the green PCB. While the green board seemed leveled enough, on photos (or if you turn it slightly under the light), antenna has what looks as a “wave” across its surface. The blue board has the antenna surface looking much more leveled and without such artefacts.

I did check boards I previously ordered from PCBWay and I don’t see similar issues. My best guess is that their HASL leveling is not really optimized for 0.8mm boards and when you combine this with a slightly transparent (and thus less forgiving) green board you get visually worse result. Mind you, I only noticed it once I took photos under bright light so it’s really not a big deal.

In any case, with the board ready, it was time to do the firmware…


Please note I have received PCBs for this project for free from PCBWay and they are also the current sponsor of my website. They didn’t request anything specific for me to say and all opinions given here are mine and mine alone.

Longwave Fun (part 1; aka HAT)

This is a part 1 in my WWVB time signal series (part 2).


I have been aware of “atomic” clocks and watches for a while now. Those devices rely on WWVB signal (at least in USA) for occasional time synchronization. Between two synchronizations they depend upon a standard quartz crystal to keep time. This allows for decent accuracy almost assuring time is always within a second of precision.

So, this year I decided to jump on that particular band wagon with a Casio Lineage watch. And I was immediately hit by a disappointment. While watch itself was exactly what I wanted, I simply couldn’t get it to receive and decode WWVB signal during the day. Night was slightly better and I could get it synced in the wee hours. And yes, night-time synching is what watch does anyhow and for any normal person that would suffice. But me? I wanted to play with it.

So I went searching for a WWVB transmitter. And it took no time to find Radio time station transmitter by HennerZeller. It worked wonderfully using nothing more than three resistors and a loop of wire. Instead of leaving the perfection alone, I decided to mess a bit with it.

First of all, I decided to put all components of HennerZeller’s design onto a PCB. Already with this change things got even simpler as the only external element was the antenna wire. So I attempted to remove even that using PCB trace. And here comes the first issue - if you want to make a proper antenna for WWVB at 60 kHz, you need quite a long trace. About 1.25 km for the quarter length. A bit too much for a PCB.

However, same principle as in the original design applies. If you’re ok with making a really bad antenna, any loop will do. And bad antenna has unexpected benefit - it will limit range of transmitter. Since we want to keep emissions under 40 μV/m as measured at 300 meters in order to keep FCC happy, having an imperfect antenna is really a good thing. Moreover, since watches were designed to work with weak signal, better antenna might cause issues at close range.

It did take me a few tries to figure out the exact geometry to make it work. I found that 13 loops in rectangular area allows for up to 10-20 cm (4-8 inches) of working distance. If more distance is required, PCB also includes a connector for external antenna. While transmitting longwave is troublesome, one could look into a loop stick or even a spiderweb antenna.

When it comes to PCB, one thing that immediately grabs attention is its wonky shape. Overall dimensions were clear to start with as I wanted to match Raspberry Pi zero footprint. And as long as one makes 65x30 mm rounded rectangle PCB, you have it. Since full size Raspberry Pi can take smaller boards, one would think that there’s no need for messing with it further. Until you try to put it into the official Raspberry Pi case.

Due to how the official Raspberry Pi case connects together, rectangular PCB hits side pillars and prevents it from closing. Further more, there is a camera connector underneath it so notch is needed to allow easy routing. Due to both these issues, the actual PCB got a few curves and a slim down on sides where it would interfere thus giving it the final shape.

The end result is a WWVB transmitter fully compatible with HennerZeller’s design and software fitting nicely into an official Raspberry Pi case.


PS: While this device complies with FCC rules for low power transmitters, that doesn’t make it legal in every other country. Do your research before using it.

PPS: If you’re interested in building your own, you can grab source files from GitHub or purchase kit here.