What are punch cards?

Punch cards are almost forgotten today, the last machines to use them were retired back in the 80s. There are some exceptions though, some industrial machines have survived to this day and still use them in small scale.

The biggest drawback with punched cards are that they don't store very much information. Back in the day they were often 72 bytes, and you needed a lot of them for a Fortran or Algol program. They do how ever present some interesting advantages, they hard to hack, and they can be made from material that's nearly indestructible like stainless steel, or materials that are very easy to destroy like dissolving paper.

How are these cards coded?

Its pretty simple, the card has 16 bytes of information and 4 bytes of Reed-Solomon error correction coding. Every 5th byte is an RS byte. This way upp to 4 lost bytes or 2 damaged bytes can be repaired. RS coding is used in a lot of applications, most 2d barcodes and a lot of space probes use them with the radio link to earth.

Before deciding on Reed-SlomonI did some tests with having one parity bit on the end of every byte, and to have a checksum byte in the end of the card, but it had some problems where the card was read with errors that wasn't detected.

The Python program creates a OpenSCAD file that can be rendered into an STL with OpenSCAD, and then exported for printing. This makes it possible to do batches of cards, if a bigger number is required. 

How can i read the card?

Easy, a web camera strapped to a desk lamp looking down onto a dark desk from 20 cm height. I use a Logitech C920 that works well.

Reading the card with the Python code is pretty straight forward, the program puts a matrix on the image that the user guides to cover the card. After this the program reads the color in each point on the matrix, if there is a hole the dark desk is seen, and this is detected as "1". No hole = gray color, = "0".

So what are so special about this?

Punch cards made from plastic or stainless steel has very good longevity and data retention. One can only speculate, but most SSD and USB memory sticks might only be viable for 30-40 years, and archaeologists some times find metal from the roman empire two thousand years ago. A steel card could probably survive a house fire also. A steel print of the STL can easily be ordered from places like PCBway.

Perhaps they can be used to store an important password, an encryption key or a bitcoin adress? 

Future Improvements

  • The reader could be improved by building a web camera with a card placement adapter, so its always setup correctly. With some experimentation a compact reader could probably be built, perhaps used for a lock?
  • Card size could probably be increased to 64 bytes without making reading them too difficult.
  • Better optics in the web camera might enable smaller holes, in the 2mm range.