Wednesday, August 14, 2019

Open-source Sustainability (The tale of 2 package managers)

Last weekend I had the priviledge to attend the 10th PyconAU and listen to some amazing speakers. I went with my I will write markdown on the fly and make a blog-post at the end of the day mindset. Even though I did write a lot of markdown on the fly, I haven't gathered the courage to push these unedited notes into a public post. Excellent examples of live-blogging from conferences here.
What did happen was that the niggling doubts I had around how open-source works in the real world outside of just the code crystallized. This was as a result of 2 very good talks , one about how the PyPi project works and another around Open-source sustainability beyond money.

For the last year I have been writing and reviewing a lot of React Frontend, Python backend (Flask/Django) and Notebooks code. Both frameworks are super easy to buy batteries for where the included ones are running out of juice. Simply via pip install and npm install you can climb onto the shoulders of giants who are library maintainers and the life-blood of lean start-ups everywhere. However the maintainer burnout is a thing and start-ups when building their stack should be highly cognizant of this. Package repository burnout is also a thing. In my time in the software industry I have seen Maven repositories disappear. More recently NPM go through an identity crisis and the left-pad incident.

The PyPi talk gave me great background on a tool I use every single-hour without too much thought. It takes some dedicated volunteers to keep the dream alive. Who according to Dustin Ingram are :

  • Unemployed and bored and poor (but super talented) 
  • Paid for by their employer (thanks employers who support FOSS) 
  • Not getting enough sleep (or in my case time with the family)


Vicky's talk covers another aspect. Developers and maintainers need more than money to keep going, they need back-up. The community need insurance against the bus-factor and burn-out. I have been guilty of this myself, putting a few dollars behind features I would like to see in BountySource instead of diving in. This has become more so as I have progressed in my career and become increasingly time-poor. Talking about this would anyone at VSCode like to claim the few dollars we put here ?

I love the longevity and discipline of project warehouse and will find some time to contribute to it. I also look forward to a similar alternative to npm, rather than a caching proxy with community behind it.

Wednesday, June 26, 2019

Sunbeam Coffee Maker Teardown

The bad Kenyan grid has struck again. There is very little built in surge protection in the system, so all appliances plugged to the wall end up with in-house surge protectors. This time the victim was my beloved coffee machine which had served us well for more than a year.

So I decided to take it home and spend some quality time with Pascal tearing it down. He is always curious about stuff and what is inside, so the Coffee machine is a complex beast capable of keeping him and myself occupied for hours on end. First we took of the top and looked at the heater and the electromechanical assembly controlling the hot-water head and frother was exposed. Also was exposed the heating tank with dual heating elements and a thermistor (I am assuming a thermistor rather than a thermocouple).

When we took the back plate off we found the main controller board. There is to obvious transformer in the set-up so I assume to whole power supply is cap-drop. There is a giant heat-sink attached to a 3-pin device which I assume is a triac or SCR for controlling the heating elements.

The bottom-left corner has a water pump with its own switching mechanism driven by relatively thin signal-wires from the main board.

There are some more interesting details on the main processor board including thick high current traces driven by the silicon switch with exposed copper and extra solder on top to increase thickness and provide a lower current path.

The main CPU is TQFP packaged micro-controller which is covered by the conformal coating the entire PCB is covered in. A macro image on twitter helped establish the lineage of the processor. It is a chinese 8051 variant with the datasheet here. Any help in translating it will be highly appreciated. But most of the schematic is legible.

Next up will be powering on the processor with a suitable 3.3v supply and examining the analog and digital buses. As well as powering on the whole thing to see why it turns of immediately on start. If the machine is unfixable I am planning to scavenge the thermistors, heating elements etc. to build a reflow mechanism.

All the water circulation mechanism is really interesting as well and can possibly be shoe-horned into a water cooler for a 3D printing system.

Saturday, June 22, 2019

Nairobi 2nd OSHW meetup

After a many month hiatus we finally put together the 2nd Nairobi Open-source hardware meetup. This time we were at the Tav Irish Pub near Nairobi Garage on Waiyaki way. The pub was chosen due to proximility to Nairobi garage and possible use of that venue. As it turned out none of us were memebers paying the $60 per-month fee so we ended up co-opting the pub in Chicago 3H fashion.
PCB Lineup
PCB Lineup
I had collected PCB's over the last few month from Aisler, OSHPark and PCBWay all shipped to Kenya from Germany, US and China respectively. So we lined up to try various soldering techniques on 0603 Jellybeans and some 20pin TSSOP IC's.
Soldering demo
Soldering Demo
The techniques we we tried were the tack, finish and reflow one using the iron and an experimental one with paste and dry-iron I had picked up recently. I didn't have a temperature profile controller for the dry-iron method. So we were just going to wing it by the eye.
Part Placement
Part Placement
We pasted up the boards using screwdrivers and tweezers. Started the reflow till the parts settled. Then simply turned off the iron. I am sourcing a K-Type thermocouple and SSR from KTechnics to get a better handle on this for next time. However the dry-iron does reach sufficient temperature for leaded solder reflow.
Dry iron reflow
Dry iron reflow
By the end of the session we had assembled x2 CS5464 Breakouts. Next step from here will be suitable MicroPython and Arduino drivers to ensure these things actually work. We had a lot of fun over the meetup and I hope to continue having these sessions. Next time one of the participants has promised to bring his Weighbridge Automation and IoT set-up.
Scavenging Coffee Machine
Scavenging a Coffee Machine
Following the meetup I have been hunting for accessories to make the dry-iron reflow less of a fire hazard and more controllable. (Un)fortunately the coffee machine at work has been fried by the spikes prevalent in the grid in Kenya (especially during the rainy season), so I have a spare K-type thermocouple I can work into the build. I have also co-opted a tissue holder we had on our dining table to stabilize the inverted iron during reflow.
A stand of opportunity
Stand of opportunity
Onwards to the next Meetup.

KiCon 2019 - Chicago in a weekend

Getting away from a fast paced start-up to attend conferences is a hard ask. However I managed to get away for a few days to attend the inaugural KiCad conference in Chicago a few weeks ago.
The pace has been such that only after about a month I am getting a chance to write it all up. The first night I managed to attend the Hardware Happy Hour at the Ballast Point. I got to see some amazing stuff including pneumatics for an autoplaying piano using layers of PCB.
The huge selection of beers and the chicago dogs were definitely unexpected bonuses.
Tour of MHub assembly area with pick and place machine and large Molex sign. Also got to see Chris Gammell's desk and pick up some Amazon and Mouser shopping to bring back to Nairobi.
I could definitely use the pick-n-place machine in my house and I hope Chris makes use of it whenever he can.
I also got to speak to some companies I have worked with remotely but not met the principles and representatives in person, including CrowdSupply, Aisler, SnapEDA, Hologram and of course DigiKey. It was great to speak to the KiCAD dev team as well, perhaps I can contribute on the MSVC windows native build. I also managed to score credits freebies from all the sources.
Here are pure notes to self on various topics that I picked up on 2-days of super varied and dense conferencing. Some are commands I would like to run some, are techniques I learnt and some are pure stories I picked up.

Schematics are a drug, use code instead

  • pip install skidl

Auto-routers are evil but useful

  • Triangles (Topological/ Using TIN mesh)
  • Maze solving
  • Shape based ( Rectangles)
  • Channel Based
  • FreeRouting
  • Adaptive heuristics using deep learning
  • Linear increase in PCB complexity

High-frequency simulation (in GhZ range) for PCB's

  • OpenEMS ( MEEP)
  • Wilkinson filter
  • Important in Radar Design

Prototyping in a few hours

  • Isolation milling
  • Midwest Circuit Technologies
  • Bantam tools. Binary save.
  • 1/32" end mill 0.8mm tool
  • 10 mill trace

Rendering photorealistic PCB's

  • Render layers to image texture
  • Use Blender cycles based render with bump maps for silk-screen and traces

Contributing to KiCAD

  • Development in LaunchPad + Github
  • Starter bugs are available

More HF PCB's

  • 30MHz to 3Ghz, with narrow bins
  • 5.6GSPS digitizer
  • Tuned lines. Right angles create problems.
  • Use footprint, Arc or Trace around edge cuts.
I woke up pretty early on Saturday morning and walked around and almost hopped on a fire-engine tour. Always wanted to do that. Then I checked the radar, another thing missing in Nairobi, and a huge snowstorm was inbound. Snowstorms at this time in Chicago are atypical, but hey everyone stays in for the coference. By the time the conference finished and I headed home from the after-party everything was covered in snow.
The last day (Sunday) was spent taking an Uber Pool , a novelty for me, to a Vietnamese grocery and spending around 2 hours getting additional exotic food-supplies to bring back to Nairobi
I saw a Harvey milk tail fin and took to the skies back to hop across the Atlantic and Mediterrnean to Nairobi. Flying 40 hrs to conference for 48 hours and shop for 6 is a real pain. Will have to bring the KiCAD movement back home to Nairobi and pour more effort into the local hardware scene.
So long Chicago, see you next conference.

Sunday, March 3, 2019

Kogan Energy Monitor Teardown - Sonoff-Pow in a wall plug

After doing a tear-down on the TPLink Wall Plug energy monitor I found mentions in Australia of the much cheaper Kogan Alternative. So I decided to get a couple of them see what makes them tick as well.
General Assembly of the whole unit

TL;DR - The Kogan one is cheaper because it uses a bare metal (non-linux capable) CPU and a PWM output type energy monitor (without intricacies of a SPI protocol and calibration). It is essentially a repackaged Sonoff Pow.

The details of the build are packages in sections as I discovered them.

LV and Buck converter


The LV section consists of two separate cricuits:
  1. Relay to switch the load
  2. Buck converter to rectify and convert 240v to 5v to power electronics
The diagram below presents both of these sections. The Buck converter is basically the toplogy found in many aliexpress products. Perhaps with the difference of being unisolated (notice no slots). The relay is rated at 15A which is nice compared the TPLink product which uses x2 - 5A relays in parallel to achieve 10A.

Low Voltage (240v) Circuitry

Energy Monitor and LDO

This a 3.3v operated section which uses the super low-cost PWM output energy monitor IC made popular by the Sonoff the measure instantaneous voltage, current and hence power. The pulses are channeled to the main processor for forwarding to whatever backend Kogan has put together.

Metering and LDO

Main Processor

The design seems to have taken a standard ESP module and planted it on a basic PCB to fit in the power-plug form factor, sideways. The carries board has lots of markings and test-points making the task of reverse engineering and putting new firmware on this board almost too easy.
Processor module adapter
Marked bottom test pads of processor carrier PCB
Over all this looks like a nice certified unit which you can run your own firmware on thanks with the help of the right triangular security bit.

Wednesday, January 23, 2019

Around Kenya in 4 days and a year ( part 1)

2018 was a year on making impromptu decisions and hopping on random flights heading for adventure. In the beginning of the year I left Aerometrex to explore new opportunities at Lori.

It turned out I finished the year in similar markovian motion travelling around Kenya with a couple of high school friends. Thank you so much Eric for driving and showing us the beautiful country.

I received a call late on the 29th December proposing the trip. I booked a ticket of Safarilink and went to bed.  Flying out of Wilson Airport is magnitudes easier than flying out of Jomo Kenyatta International. I almost missed the flight, but the empty Christmas streets in Nairobi and low access overheads in Wilson meant I flew into Kisumu with zero dramas. I hopped in a Probox from Kisumu to catch up with the other 2 in Kericho. The Probox are known for being death machines, but is a super cheap and fast way to get around. There is another article somewhere revolving around the impact of the Probox on transport in Kenya.
Tiny Kisumu Airport
Safarilink Flight (Turboprop)

We then travelled via some roads still being built from the tea-gardens of Kericho to the lush sugarcame farms of Awendo. In sections the road meandered into farms and cars had to go in a single file and often backup into fields when a truck came by from the other side.
Road through Kisii
It was a great night of going out to watch football match in Ulanda town and staying at Owuor's Simba. The road from Awendo to Ulanda is awesome. The sugar cane is a mass scale project and produces a lot of bagasse which can be recycled into paper tissue and other products with the right infrastructure.

Mercury laden waters used to extract gold nodules

Sheds housing diesel engines and rock crushers for mining

Next day we took a side trip to Macalder gold mines. It was in interesting experience what people will do to earn a living in far flung places in the country. Migori county is known for its high concentration of mercury in water. The operations here clearly explain why. Rocks are dug up from underground gold mine and manually broken up into smaller chunks and ground into dust using diesel operated octagonal drum crushers. The whole place is noisy. The dust is then filtered to remove solubles and then mixed with mercury to form gold amalgam nodule, women (some of whom were pregnant) then stir the mixture by hand to find gold bits. Mercury is then recovered by retorting in small ovens and reused. At least some work is being done to raise awareness of the harm from Mercury, hopefully sanity will prevail over economic incentives.

We then continued our trip south towards Kenya Tanzania border and I will continue the story in another post.

Sunday, January 13, 2019

Making PCB protos in Kenya

In Adelaide I made a lot of prototypes PCB's and filled up filing cabinets and shelves with them. Some had value to others and I sold them on Tindie and CrowdSupply. For the last year I have been hanging out in Kenya working at Lori. The output in terms of open-source hardware has taken a back seat compared to proprietary company code (we did release one open-source piece of ETL code).

This is near the end of my 3-month stint in Kenya and I decided to run an experiment in the feasibility of designing and assembling prototype batches of PCB's for an energy monitor ASIC I have been meaning to try out - the CS5490. This is a super low bar for a test run. The IC has very few dependent components and large pin pitch making it ideal of teaching manual SMD soldering.

PCB Design

Once the goal was set I broke out KiCAD and spent a night and a Sunday churning out a basic breakout board. The PCB Design and BOM are published here.





Order PCB

The harder part begins once the PCB design is done. Actually making this a physical reality in Kenya. I placed the usual order via PCBWay. A few days before Christmas before I went off to a round a country drive with some friends ( awesome content for another post). The shipping would be from Shenzhen via DHL. The logistics promises arrival by the 28th December.
Order Parts

The BOM for the design is not super complex either. Mouser covers the Kenya region. However there is no option for free DHL for orders over $60 which I get in Australia. I will be in Kenya only till the 20th January and the streets have no numbers or postcodes, which makes ordering via snail mail for any international shipping simply not fit the address template most places have. Perhaps global addressing via plus codes will become reality in future eCommerce systems. Mouser shipped the parts out of Texas immediately, I ended up paying more on shipping than for parts. The customs magic was yet to come.

Clear customs

Any packages with value below $1000 sail through customs in Australia. The Kenyan government will lose out on significant revenues if they followed this practice. On the flipside young engineers with limited resources are being stifled in self-driven learning and experimentation by this practice. I got a detailed/itemized bill from customs via DHL which ended up being the same cost as PCB + shipping for PCB's and around 20% of the cost of the parts. See file here for details and breakdown.



Source tools and materials

Thankfully this bit was much easier with a couple of local soldering iron , jumper wire and tweezers suppliers filling the gap. The ball was dropped by Fargo in delivering the stuff I ordered online again due to the addressing snafu, they attempted 5 deliveries to the wrong place before I had to redirect to the office address where a lot of parcels are received. I can recommend Nerokas and Ktechnics for getting parts in without hassle. Again better last mile logistics would have made things faster. I ended up attending the assembly meetup without the proper tools.

Find assembly space

To avoid annoying my landlord with solder fumes and messy paste workbench I started looking for a place to get together with a few interested parties and assemble the boards (at least one). I ended up starting an open-source hardware meetup and getting some Mang'u engineers together to hand solder the parts. 


Test and publish drivers


Finally this Sunday I have put together some basic micropython code to read registers from the CS5490 over serial and display them in a micropython notebook. Nothing production ready but proof that the PCB design and assembly worked as expected and we can achieve custom products here, with a lot of bureaucracy and false starts.

I am happy to meet more people designing and building open-source hardware in Nairobi and hear about their experience.