Close

Interfacing with raspberry pi 5

A project log for Project Gigapixel - Linear CCD camera

Building a better linear CCD scanner camera - Not just a scanner in a box -

yannick-gigawipfYannick (Gigawipf) 07/01/2025 at 13:300 Comments

As the final project should only run on a standalone computer the data needs to be acquired by a raspberry pi.

Using an RP2350 to generate commands and timing data was successful to read an image but the fullspeed usb interface is way too slow for the expected data rates of over 12MB/s.

The raspberry pi 5 has PIO state machines in the RP1 IO controller that can be used via PCIe using the new PIOLIB.

Getting the timing of the sync pulse right was a big challenge as the DMA transfer can take several milliseconds and it is not repeatable meaning after starting a line a random time passes until data is actually received and it is not possible to reconstruct colors from that.

Also the DMA transfer is currently too slow for full 16b resolution so only half the data is sampled at 8b resolution for now. This gets hopefully fixed with a later PIOLIB version.


After months of trial and error repeatable syncs have been achieved by filling and stalling the FIFO after each state machine reset, generating the sync pulse after syncing with the external clock in this SM when the DMA transfer starts reading this dummy data and then pulling the actual image data.

The first image may not look great but every line has the right color and you can see that it is a (blurry) image of a red flashlight on a table:

First image
Red flashlight on table

Instruments on desk
Instruments on desk
Realigned channels
Realigned colour channels

With this image i think i am close to the right pixel pitch. Seems to be about 1.25µm at full resolution or an actual pixel distance within a line of 5µm which sounds reasonable. This image was taken in 1/8 resolution and has a certain analog feel to it.

With manually realigned colour channels it does look quite sharp already.

The most important step actually works. With actual image processing, pixel offset correction and a stiffer case it might even take good pictures.

Discussions