Extracting all images from an Evernote Export (.enex) file

While it’s quite easy to get a large number of images into an Evernote note, it’s hard work to get them all out again: you have to right-click them one by one, then “Save as…” each one.

However, Evernote does let you export the entire note ‒ and even several notes at once ‒ into one .enex file. .enex files are XML, with each image base64 encoded and neatly enclosed in a <resource> tag. So here is a perl script that will take a list of .enex files as command line arguments, and write all the images from each of them to the current folder.


What I learnt today…

… is that on the AVR, the “Data Memory Usage” information given by AVRGCC  only refers to memory allocated at compile time, and does not take the stack into account.1 2 The stack is not to be underestimated: it holds not only the return addresses from function calls, but also all local variables3 of the function(s) called.

So you might feel safe and sound reading something like “Data Memory Usage : 66 bytes 51,6% Full”, thinking there’s plenty of space left for future features; and then the stack still swoops down and corrupts your precious data because of a couple of nested function calls.

Took me a while to figure out what happened here. Then again, I have never worked on a machine with just 128 Bytes of RAM before.

The good news is that this can be reproduced reliably in the AtmelStudio simulator: Find the memory locations of the data being corrupted, set data breakpoints, and when the simulator stops at the end of something like this

000000F5 PUSH R11 Push register on stack 
000000F6 PUSH R12 Push register on stack 
000000F7 PUSH R13 Push register on stack 
000000F8 PUSH R14 Push register on stack 
000000F9 PUSH R15 Push register on stack 
000000FA PUSH R16 Push register on stack 
000000FB PUSH R17 Push register on stack 
000000FC PUSH R18 Push register on stack 
000000FD PUSH R19 Push register on stack 
000000FE PUSH R20 Push register on stack 
000000FF PUSH R21 Push register on stack 
00000100 PUSH R22 Push register on stack 
00000101 PUSH R23 Push register on stack 
00000102 PUSH R24 Push register on stack 
00000103 PUSH R25 Push register on stack 
00000104 PUSH R26 Push register on stack 
00000105 PUSH R27 Push register on stack 
00000106 PUSH R28 Push register on stack 
00000107 PUSH R29 Push register on stack 
00000108 PUSH R30 Push register on stack 
00000109 PUSH R31 Push register on stack

you know Bob’s your proverbial male relative.

Inside the Kosmos CP1

Originally, I planned to save all the CP1 stuff for a later post, but there’s this one picture I really want to share. After removing the cardboard back cover, this is what I saw:

Inside the CP1: a screwdriver
After removing the cardboard back cover, this is what I saw. The screwdriver must have been in there for some 15 years at least.

Bringing an old computer back to life

Returning to the retrocomputing hobby after 12 years, most of my collection has been in storage way longer than I anticipated in 2006.1 That means I’ll have to treat every machine I take out of storage essentially as an unknown. That’s why I looked around on the internet for some best-practice checklist on how to proceed with “new” old computer, but couldn’t find anything.2

So here’s my attempt. I’ll extend and modify it as I take more and more machines out of storage. I welcome your feedback.

The basic idea behind all this is that an “unknown” machine may be damaged, and that powering it up in one piece without fixing the existing damage first may make matters worse. For example:

  • The machine’s power supply may have degraded to the point where, while still seemingly working, the output voltages are way out of spec and will do damage to the components over time; worse, it may even explode.
  • Corrosion from water damage or leaked batteries may cause further damage when the device is turned on.


  • Take lots of photos. You’ll never know when knowing the original state of something might come in handy.
  • When you need to disassemble anything, make notes about position and orientation of disassembled parts; carefully note which screw goes where.
  • Don’t hurry, work step by step and be careful not to damage anything. Spare parts are hard to get.
  • Always be grounded when touching disassembled electronic parts (of course, you schould not touch anything which is connected to the power source…). Use an antistatic mat when laying down those parts. Again, spare parts are hard to get.
  • Mains voltage is dangerous. Do not open a system that is connected to the mains unless you know exactly what you are doing. Note that power supply capacitors can remain charged long after you have disconnected the system from the mains.
  • CRT monitors work with acceleration voltages of tens of kilovolts. Never open them, unless you know how to safely work with them.

Get Background Information

  • Gather what you know from the previous owner.
  • Do an internet search for the particular model in front of you. Look for
    • service manuals,
    • schematics,
    • repair/refurbishment reports, and
    • test / diagnostic software.

Inspect the Machine Carefully before You Turn it On

  • Do a basic cleaning and a visual inspection of the outside.
  • Check the operating voltage. If there are multiple voltages, see if there is a voltage selection switch, and if so, if it is in the correct position.
  • Open the case (unless, of course, this would do permanent damage to the machine; remember, this is about limiting damage).
  • Get out the worst of the dirt.
  • Remove or disconnect all expansions, add-ons, internal drives, etc.
  • Visually inspect all boards. Pay particular attention to
    • batteries (which may have leaked)
    • electrolytic capacitors (which may have leaked or bulged / crumpled)
    • solder joints on parts subject to mechanical stress, like connectors (which may have broken, creating a “cold” solder joint)
    • previous repairs or repair attempts
    • ICs that seem out of place, e.g. having a datecode that doesn’t match the rest of the system
  • Remove leaked batteries and leaked / crumpled capacitors. Clean up. Note permanent damage. Replace capacitors.
  • Resolder cold solder joints.
  • Be suspicious of any previous repair. Check that the right component is in the right place in the right orientation.
  • Note mechanical damage.
  • Measure board resistance between all rails to detect shorts.
  • Press all socketed IC down gently, but firmly.

Check the Power Supply

  • Disconnect the power supply from the rest of the machine, if possible.
  • Check all power supply voltages under load and no-load conditions. If you have an oscilloscope, look for excessive ripple, too.
  • Note that some switch mode power supplies do not like being without load. They may not turn on without a minimum load, or worse, may sustain damage.
  • Only when the power supply checks out, connect it back to the main board.

Test the Machine

  • Power up the machine.
  • Look out for diagnostic messages from the ROM / BIOS / Kernal / etc.
  • Run diagnostic software (if available), or any other kind of software that puts the machine through its paces (if not).
  • Plug in expansions and add-ons one by one (when the machine is turned off, of course). Test separately.
  • Fix issues as they arise.3

Prepare the Machine for the Future

  • Remove or replace components that are likely to fail, like batteries (even if they haven’t leaked / failed *yet*). Some people replace all electrolytic capacitors, some even replace voltage regulators. I’m still on the fence about that – it’s about balancing risks.4
  • Ensure all components that need to be heatsinked are properly heatsinked. Add thermally conductive paste (sparingly!) where necessary.
  • Clean thoroughly. This may include
    • cleaning flux residue from solder joints with isopropanol
    • disassembling, cleaning, and reassembling the keyboard
  • Retrobright, if you want to.

UPDATED September 6, 2018

Liniertes und gepunktetes Papier zum Selberausdrucken

Gestern schrieb ich schon auf Englisch darüber, heute nochmal auf Deutsch, damit das Thema auch von denen gefunden wird, die auf Deutsch danach suchen.

Ich schreibe gerne mit der Hand, am liebsten mit Füller auf liniertem Papier. Und weil mir Kleinigkeiten manchmal wichtig sind: am allerliebsten auf liniertem Papier mit 8mm Zeilenabstand, statt der in deutschen Schulheften üblichen 9mm.

Nun werden linierte Blöcke in Büromaterialschränken immer selterner; Laserdrucker dagegen stehen überall. Deshalb habe ich mir Druckvorlagen für liniertes, gepunktetes (statt: kariertes), und vorne liniertes, hinten gepunktetes doppelseitiges A4-Papier erstellt, außerdem gepunktetes einseitiges A3 Papier für größere Zeichnungen.

Diese Vorlagen können gerne weitergegeben werden, solange die Quelle (also: dieses Blog) angegeben wird.

Apropos Handschrift und Selberausdrucken: Den ausgezeichneten Passion Planner Kalender gibt es ebenfalls als PDF, wenn man sich für den Newsletter anmeldet, oder die Information darüber in sozialen  Medien teilt.

ERGÄNZUNG 8. Juni: Sehr schöne Papiervorlagen zum Selbstausdrucken gibt es auch bei Gridzzly und Incompetech.

Print Your Own Ruled or Dotted Paper

I love writing by hand, preferably with a fountain pen, even though my handwriting is terrible. Unfortunately, decent notepads and notebooks seem to disappear from many office supply cupboards, so I decided to make my own notepaper templates to print wherever and whenever I need some.

Take your pick of ruled, dotted, or front-ruled-back-dotted hybrid double-sided A4 paper, or dotted single-sided A3 paper for those large drawings.

Share and Enjoy, 1 but don’t forget to attribute when you share!

And while we’re on the subjects of handwriting, printing-your-own, and sharing: I also like the Passion Planner,2 and the nice people at Passion Planner will let you have a free PDF copy if you spread the word on social media, or subscribe to their newsletter.

ADDENDUM June 8th: Want more paper? There’s also Gridzzly and Incompetech – I like both very much.

Repairing an AVR DDS Signal Generator


As far as I can tell, the first use of an AVR to do direct digital synthesis of an analog signal was by Jesper Hansen in 2001.  Mindaugas Marozas picked up the idea to create a stand-alone function generator in 2006. In 2008, Mindaugas published an improved version, which has become the basis of many homebrew projects, as well as a number of Chinese clones. Georg Latzel, DL6GL, gives a very nice and detailed rundown of the theory of operation (in German).

What’s wrong?

In December 2017, I purchased one of these clones on eBay. Unlike the projects linked above, this one does not require an external three-voltage power supply (+5V for digital logic, -12V/+12V for the op-amp rails). Instead, it uses a single DC barrel connector for (what I thought) +12V, deriving +5V with a 78L05, and -12V with an ICL7660.

ICL7660 pinout
ICL7660 pinout (from the Intersil / Renesas datasheet)

Avid readers of the ICL7660 datasheet will already have spotted the problem: The ICL7660 is specified only up to +10V. 1 With a 12V supply, it worked fine for about half an hour, then gave up. Now, the 5V part of the circuit (AVR, display, buttons, high speed digital output) still works fine, but the analog output appears completely dead. On pin 5 of the ICL7660 (VOUT), I measured +0.2ish Volt instead of the expected – V+. At least, the ICL7660 is socketed.2

DDS board
The DDS board in question, with the display removed. Note that the ICL7660 is the only socketed chip. Also, note that it does say +12V above pin 8 of the ICL7660. If you bought the same board, and made the same mistake, this article is for you.

The Fix

Having replaced the ICL7760, I now get -9V at VOUT, for V+ = +9V, and the analog output works again.

And that’s all?

Fortunately, yes. I also bought a spare opamp, but I’m glad I didn’t need it. I still dread SMD desoldering.

Here are some nice pictures from the working signal generator:

The charge pump at work

ICL7660 charge pump capacitor voltages
ICL7660 charge pump capacitor voltages. For the first half of the cycle, CAP+ (yellow) is connected to V+, and CAP– (cyan) is connected to ground, charging the capacitor to V+. In the second half of the cycle, CAP+ is connected to ground instead, leaving CAP– at –(V+) to charge the charge reservoir capacitor at VOUT.

Some waveforms

AVR DDS: 1 kHz sine
AVR DDS: 1 kHz sine

AVR DDS: 1 kHz EGC waveform
AVR DDS: 1 kHz EGC waveform. This nicely shows of the ability to generate arbitrary waveforms through DDS, even though it is of very limited use.

AVR DDS: "noise"
AVR DDS: “noise”. Note that “noise” means a different, random 8-bit value output every 80us or so.

AVR DDS: 1 MHz high speed TTL
AVR DDS: 1 MHz high speed TTL. Note the 8 MHz and 16 MHz components visible in the high state.

AVR DDS: 8 MHz high speed TTL
AVR DDS: 8 MHz high speed TTL