25. July 2023 · Categories: Politics

The EU is currently considering a new battery directive1, and as it stands, it will effectively ban AirPods, and probably even smartwatches.

The problem is article 11, which basically forces everything using batteries weighting less than 5 kg to use user replaceable batteries, with only one exception when “specifically designed to operate primarily in an environment that is regularly subject to splashing water, water streams or water immersion, and that are intended to be washable or rinseable”. That makes it applicable for earbuds, smart watches, phones, and tablets. All of these will become seriously worse products because of this misguided law.

To understand why, a user replaceable battery needs to be more robust. It will have a plastic housing instead of directly fitting the battery pack, the housing will have significantly less flexibility to fit a battery tightly, and you need to properly secure the pack. User replaceable also means that you no longer can use glue to seal your device water tight. Instead you will use some kind of rubber seal, as they were used in tough compact cameras, like the Olympus TG-6. From experience, you need to be careful. The surfaces for the seal must be clean for the seal to be any good, especially there must never be any sand on them. Then you need to fasten the seals and batteries. You can either use a cap as in cameras, which use up a lot of space, or you use screws, which are a potential ingress point for water, and you also run the risk that users will fasten them wrongly. You really want a torque sensor to tighten them properly. In short, a user replaceable battery increases weight, and volume, and makes environmental sealing heavier. And for batteries that last at least as long as the product, they add avoidable waste.

Looking at the Fairphone and the iPhone 14, you see the impact a replaceable battery can have: 225g instead of 172g, IP54 rated instead of IP68. Apart from a few idealist, people just prefer the much better phone, and with Apple offering battery replacement for €119, this is a tradeoff many are willing to make.

For smartwatches, this is a disaster. I want my watch on during a swim, so it needs really good protection, and I want it to be smallish2. Design goals that currently cannot be achieved with replaceable batteries. But a watch is primarily used outside the water, even if swimming is critical use case, so the exception in the law does not take.

And for AirPods, they are worn inside our ears, so from an ergonomic perspective they need to be as light as possible. One AirPod Pro is just 5.3g, so even adding 1g to support a replaceable battery is bad. Apple uses a 25mAh battery, which I estimate to weight around 500mg, comparing them with a 210mAh, 3.2g CR2032. And the environment calls for good sealing, as you do not want your sweat to destroy them.

These are real design tradeoffs, and the law needs to recognize this. This means that it should be possible to have a battery replacement service as an alternative, when other design goals would be compromised. Difficult to put this into legal requirements, but let us try.

Amendment to Article 11:

  1. Devices are conditionally exempt from the user changeable requirement when one or more important design goals recognized in this article would be negatively impacted

  2. Exempt devices need to conform to all of the points below

    1. be designed that their batteries allow at least 1500 charge cycles, or that they last for at least 3 years for at least 95% of users before needing replacement.

    2. provide a battery replacement service that costs at most 50€ in 2023 euros more than a typical battery of roughly the same capacity, volume and endurance.

    3. once the battery replacement service is stopped, the necessary documentation must be provided free of charge for third parties to provide this service instead. Any necessary patents and other rights need to be licensed on a FRAND basis. This obligation includes tools, processes and replacement parts.

    4. use at least 20% of their volume or weight for batteries, or weight less than 100g.

  3. Important design goals are for

    1. Asset trackers:
      1. Robustness against manipulation

      2. Environmental sealing

      3. Weight

    2. Devices that are designed to be worn on the body, taken with you all day, or to be used handheld for at least 15 minutes continuously:

      1. Weight

      2. Size

      3. Environmental sealing

      4. Robustness against rough handling

    3. Devices intended to be portable, and be used at multiple locations. These can be exempt if the smallest dimension of their rectangular bounding box is less than 20mm.

      1. Weight

      2. Size

    4. Devices intended to be used regularly in a harsh environment. These devices do not need to meet the volume/weight threshold from 2.4.

      1. Environmental sealing

      2. Robustness against rough handling

  4. This conditional exemption is valid until two years after a comparable device with a user replaceable battery is available on the market that provides for those design goals at least as well, and with a volume and weight penalty of at most 5% of the entire device, with comparable life time hardware costs.


  1. The law text, as adapted in first reading by the parliament, is found here 

  2. The Apple Watch 8 45mm is 39g, with a 310mAh battery. That battery would be an estimated 5g to 6g. 
04. July 2023 · Categories: .NET

SharedSizeGroup is a great mechanism to align multiple columns or rows between Grids in WPF, but it can have unexpected performance implications. I recently came across this when I used it inside the ItemTemplate of a ListBox. A few items in there, and everything works as expected, but after putting in a few dozen, it became really sluggish, and the app was permanently burning CPU cycles.

I redid the design without the need for the size group, removed the Grid.IsSharedSizeScope from the list box, and performance was restored. This was with .net framework 4.8.1.

While researching the problem, I also learned:

  • ScrollViewer.CanContentScroll can be used to switch the scrolling between ensuring that the top element is aligned (true), and continuous scrolling (false)

  • SharedSizeGroup can also be used with multiple columns/rows in the same grid, if you want them equal.

09. May 2023 · Categories: Photos

The last few years we have seen the camera companies concentrating their efforts on transitioning their lineups to mirrorless, especially Nikon and Canon. This means that we have not seen any updates in the premium compact space since 2019, and it remains in a sorry state.

The phones now have a pretty good quality for their main lens, for example, the iPhone 14 Pro has a 24mm f/6.3 equivalent lens, but their other focal lengths are at least two stops slower. This gives a quite high bar to jump over, which would explain the lack of activity. They are however not optimal for taking photos, and I still believe that a well designed premium compact would sell well.

The currently best option, the Sony RX100 VII, is unfortunately a user hostile mess, and I am afraid the camera executives think We don’t want compacts anymore, when the reality is When will we finally get an enjoyable quality compact?

Such a compact would need to be small enough that you can carry it in a jacket pocket. This gives roughly the dimensions of the X100 from Fujifilm, with maybe another inch available for the lens if needed. That would be 13cm x 7.5cm x 3.2cm for the body, and up to 4.6cm extra for the lens to stick out. It needs flash and an electronic viewfinder, a small grip to hold the camera, and controls similar to larger cameras.

Excellent phone integration is a must. This means background transfers of images, fast transfer speeds (above 500Mps), user defined transfer formats (not only the small 2 mega pixels, and including full raw formats), and use of the phone as a remote with lag free video transmission. The compact should come with builtin flash memory (provide 64GB and 256GB variants) for better robustness, and it would be nice if it could share the battery type with its mirrorless siblings.

The sensor should be the DX crop (1.5x). We cannot provide a super zoom lens without too much compromises, so I would aim for two lens variants: 12-40 f/4-2.8 wide angle, and 16-80 f/2.8-4 universal. These are the most useful ranges when walking around, where you accept some limits in flexibility to get down to a truly compact package.

It also needs to be high performance. Autofocus, and capture speed should be of a level comparable to the Z6 II, so that it can serve also as a second camera. This would not come cheap, and I think a price of $1799 / $1999 for the the universal and wide ranges would be appropriate. Given the niche it fills, and the fact that current performance is so high that you would still be happy with it in ten years, it would sell well even at this price.

09. May 2023 · Categories: Photos

With Nikon expected to unveil the Z8 tomorrow, I wonder whether we will see an automatic HDR feature.

With a full electronic shutter you no longer have any vibrations that could impact on image quality, and with a shutter speed up to 1/32000 and a below 4ms full sensor readout, we can now take two exposures in one go, without movement that would make combining the images too hard. The bandwidth and memory size is there to store a handful full sensor readouts in memory, so we can first read out just the raw data, with absolute minimal delay between shots, and then process all captures in the group at leisure. That headline 20fps would still be 8 pairs per second, fast enough to apply this automatically when the camera detects potentially blown out highlights. Ideally I would love to use an automatic 5 shot approach to highlights, capturing fast-slow-fast-slow-fast sandwiched to get highlight data that can be even better combined with the main shot. That might be pushing it a bit much with 3.5ms sensor readout, but it is an aspirational goal when we get the readout speed down to 1ms.

26. February 2023 · Categories: Embedded

The nRF52840 from Nordic Semi has an issue with SPIM3, in that using it with a shared memory buffer could lead to data corruption (Erratum 198). The description describes a simultaneous access from CPU and DMA on the same RAM block as the cause, but after some testing I believe the explanation to be insufficient. The problem seems to only occur with the first byte transmitted, and then it is not corrupted, it is not loaded at all and the SPIM uses the last byte from the last transaction instead. My theory is that the DMA needs to feed two bytes at the start, and that it does not wait for the first transaction to finish before starting the DMA clock. So the first load has no tolerance to retrieve its data before the read for the second byte is issued, which also aborts the first read. On the other hand SPIM0-2 seem to wait: only after the first byte has been read will the module start with transmission, and the DMA start issuing reads for the following bytes. For all following bytes I assume that the read has, on all SPIM, at least half the byte time to get filled.

The best support for this thesis is that when we arrange for SPIM0 to SPIM2 to start at the same time, we see that with contention the times differ, while without they line up nicely.

It looks like it is only the CPU that can lead to corruption, at least a test with the 3 other SPIM could not cause an issue. This is surprising given that all other AHB Masters have higher priority than SPIM3, and so could cause a critical delay. Peripherals however work at 1/4th the speed of the CPU and RAM, and so I guess it needs more than four masters to saturate the bus.

16. September 2022 · Categories: Apple

The iPhone mini is no more, and it is not very surprising. As already said, it was still too big, it should have been 59mm by 120mm to be great phone to use one handed. The sad part is that the new camera system and the reduced size of the front cutout would have provided the ingredients that would have made even a photographer switch:

  • With the main camera of the 14 Pro, augmented with the flash and Lidar only, we would have a very compact, yet capable camera with 24mm f/6.3 and 48mm f/12.6 options1. If size required, I would even forgo the wide angle macro lens, even though the main camera only offers 1:3 magnification at 48mm.

  • We would still have a 5″ screen, enough for information on the go. And with CarPlay a larger size is no longer desired for navigation.

  • The improvements in battery life seen in the 14 Pro, including the always on screen, mean that even at the smaller size we can now provide 12 hour active battery life.

I really hope that like with the iPad mini, this phone will be offered on a 3 yearly update schedule. Long enough run to amortize the development costs, and now that annual performance gains are “just” in the 10% to 20% range, it will remain current long enough.


  1. The Sony RX100 m7 has a lens equivalent to full frame 24mm-200mm f/7.6 – f/12.1. It is f/11 at 48mm, and offers 1:2.1 near macro at 56mm. The m5 had a 24mm-70mm f/4.9 to f/7.6. The other lenses on the 14 Pro are less impressive: f/13.6 for the 14mm, f/24 for the 77mm. 
28. August 2022 · Categories: Photos

The Sony RX100 is one of the best compact cameras you can buy, a technical marvel that provides pretty good quality in a compact package, has good auto focus, a reasonably fast lens (one stop slower that a crop sensor camera with a kit lens for the 24-200 m7) that is surprisingly sharp, and can even get into macro range with a 1:2 magnification ratio. Hardware wise there is little to complain about, we are very close to what is physically possible in such a small package.

Unfortunately, it also has an interface that puts people off Sony cameras for life. Part of it is just a wrong priority on size at any cost:

  • The tripod mount is not located beneath the optical axis, but off center and so close to the battery door that putting a plate will necessarily block it. Moving it below the axis would free the door, and make holding the camera with a plate attached more comfortable.

  • There is so little space for controls, that they are all cramped, and make modifying settings less smooth than it can be. The Nikon 1 V3 was only marginally smaller, but it allowed for just enough additional controls to have two dials to modify settings in addition to focus and zoom rings on the lens.

  • The body is slippery because it has no integrated grip. Everyone puts an extra grip on it, it would be so much better to integrate that, and use the extra space for a larger battery.

Making the body 1cm wider and 4mm higher, and adding an integrated grip would keep the camera pocketable, but allow enough space to rework the controls to be much easier and more fun to use. Also the touch screen has a pretty wide black margin on its left, so you could move that margin to the right, and add a few control buttons there to improve direct control, easily reachable from your right hand.

The control missing most on the camera is support for back button focus. It prevents us from setting the camera to AF-C, and simply keep using that mode if we want precision control for manual focus. The typical approach to taking manual focus image is to use auto focus to get an initial lock, zoom in to get critical focus, zoom out again to ensure the composition is correct, and then take the image. The RX100 has two drive modes for manual focus, DMF with auto focus which is mostly useless because you half press for auto focus, and then keep it half pressed, while adjusting focus, without a way to get back to check composition. Or use MF, which is fully manual focus. There is an option to set a control to toggle between AF/MF, which allows quick switching. But it comes with no indication in the viewfinder, and is still more work than needed with back button focus. Even though you can customize the control rings, focus is not one of the options.

Finally we have the disaster that is connectivity:

  • WiFi speeds are too slow, and should be at least 800 Mbps

  • Does not support importing raw images over WiFi, and we have no choice of the processed format that we want to import. It is fixed at 2MP images (actually 1616*1080, even smaller, and not even 3:2), or VGA thumbnails. No choice to define your own processing of the 5472 × 3648 pixels. I often find that a higher pixel count (e.g., 3000×2000) with more aggressive compressions yields an overall nicer image, and it would be nice to have more options. Also the app really needs to learn not to show superfluous pop ups every time I do something: Why interrupt me with a popup of my selected transfer quality, when this could be just a small indicator in the images list?

  • Connection is not possible to initiate from a paired device. You must activate the Send to Smartphone function on the camera to start the WiFi network. Why can we not use Bluetooth to tell the camera that it should start its WiFi? A good Bluetooth chip that advertises maybe once every second (plenty fast to initiate contact) is able to run half a year on a CR2032. Even better would be if we could get Apple to support open protocols to achieve AirDrop performance, with the network all happening in the background.

  • USB is still Micro-USB with 480 Mbps, this really needs to become USB C with at least 5 Gbps, preferably 10 Gbps, adding also power delivery that can charge and operate the camera at the same time.

  • In support of this read speed, the next model should switch to CFExpress Type A cards. They are roughly the same size as SD Cards, are more durable, and have faster speeds. Or maybe even move on to internal flash. 128 GB would be enough for normal usage, you could add a 512 GB model for heavy users, and at Apple prices of $400 for 1TB it would still be cheaper than cards costing around $1500 per TB for capacities up to 256GB.

20. May 2022 · Categories: .NET

Windows .NET WPF orders their controls in a visual tree, and this tree has the restraint that every element can only have one parent. This can trip you when define a control as a resource, and then reuse it from the item template of a container. You will see the control exactly once in the list. So never do this in your XAML:

Instead either use templates, with DataTemplate or ControlTemplate, or define a VisualBrush for reuse. The better performance for icons and similar uses is with a visual brush, as it is one item that can be reused and is optimized for painting. For example:

The alternative with ControlTemplate initiates more, but is more compact to describe:

I ran into these problems when I naively tried to use the Visual Studio Image Library for some basic icons for my app. All of their icons are defined as a Rectangle, so these techniques are useful if you want to use them inside of lists.

09. May 2022 · Categories: Embedded

The gcc linker sensibly checks that all files use the same calling convention to prevent problems, but it provides an awful error message that left me confused. When I updated a Cortex‑M project to use floating point math (-float-abi=hard), the linker gave the following error

mylib.o uses VFP register arguments, build/program.elf does not

It sounds like I have to update some setting to tell the linker which calling convention to use for the output, but what it actually means is slightly different: When the first object file is added, its calling convention becomes the calling convention of the output, and when any following files do not match, it is an error, and you see that message.

The most likely cause is that your build system did not rebuild everything, and a full rebuild will fix it. If not, you will need to check your libraries, and then the build options for your object files to see why they were built with a different calling convention. Make sure you put an object file with the correct convention at the start.

31. March 2022 · Categories: .NET

I recently wanted a fast way on the command line to find all available COM ports, and after some searching I constructed the following:

This code searches for all active port devices, which nowadays should only be COM Ports, then sorts them numerically by port number, and finally displays them together with a description and the manufacturer (of the driver). The only tricky part is that the COM port number is not available directly, but must be extracted from the Name property.

My thanks to this overview by Mathew J Bray, which also includes different approaches.