Sam's Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
notes:taking-a-picture [2026/11/30 06:16] – Add taking a picture samnotes:taking-a-picture [2026/11/30 07:35] (current) – [Improvements for Version 2] sam
Line 3: Line 3:
 I recently took a class in PCB design. For my final project, I decided to take a picture with the ESPROS EPC901, which is a 1024x1 pixel CCD image sensor which you can buy in single quantities from DigiKey. I recently took a class in PCB design. For my final project, I decided to take a picture with the ESPROS EPC901, which is a 1024x1 pixel CCD image sensor which you can buy in single quantities from DigiKey.
  
-{{camera-images:epc901.jpg}}((The EPC901 has a tiny and extremely lightweight BGA package.))+{{notes:taking-a-picture:epc901.jpg}} 
 + 
 +<WRAP lo> 
 +The EPC901 has a tiny and extremely lightweight BGA package. 
 +</WRAP>
  
 The image sensor is unusual since it has a single column of pixels (as opposed to the image sensor in, say, your cell-phone which has a 2-D matrix of pixels). The aspect ratio of the sensor made me think of [[https://en.wikipedia.org/wiki/Strip_photography|strip photography]] which is a technique where the camera captures a moving object by taking a "video" of a thin vertical slice through a swath of the scene, later reconstructing an image by placing the frames next to each-other. The image sensor is unusual since it has a single column of pixels (as opposed to the image sensor in, say, your cell-phone which has a 2-D matrix of pixels). The aspect ratio of the sensor made me think of [[https://en.wikipedia.org/wiki/Strip_photography|strip photography]] which is a technique where the camera captures a moving object by taking a "video" of a thin vertical slice through a swath of the scene, later reconstructing an image by placing the frames next to each-other.
Line 9: Line 13:
 In fact, you don't need a special camera to create a strip photograph. I produced the following image by taking a video with my cell-phone camera and using a Python script to overlap the video frames such that each frame has been shifted by the speed of the train divided by the frame rate. In fact, you don't need a special camera to create a strip photograph. I produced the following image by taking a video with my cell-phone camera and using a Python script to overlap the video frames such that each frame has been shifted by the speed of the train divided by the frame rate.
  
-{{camera-images:metra.jpg}}+{{notes:taking-a-picture:metra.jpg}}
  
 There's also a similar technique used in some panoramic cameras where the camera or optic rotates, so that each subsequent "slice" captures a different angle of the scene. I decided to try and capture a picture using this second technique, with the idea that it would be easy to produce a strip photograph by not rotating the optic during the course of the capture. There's also a similar technique used in some panoramic cameras where the camera or optic rotates, so that each subsequent "slice" captures a different angle of the scene. I decided to try and capture a picture using this second technique, with the idea that it would be easy to produce a strip photograph by not rotating the optic during the course of the capture.
Line 15: Line 19:
 To keep things as simple as possible, I decided to use a pinhole to project the image onto the image sensor. A motor will be used to rotate the image sensor and the pinhole through the scene while the image sensor continuously captures pictures. Once the capture is complete, the individual columns can be concatenated to form the final image. To keep things as simple as possible, I decided to use a pinhole to project the image onto the image sensor. A motor will be used to rotate the image sensor and the pinhole through the scene while the image sensor continuously captures pictures. Once the capture is complete, the individual columns can be concatenated to form the final image.
  
-{{camera-images:theory-of-operation.png}}((The sensor and optic rotate through the scene, capturing a series of images which are horizontally concatenated to form the final image.))+{{notes:taking-a-picture:theory-of-operation.png}} 
 + 
 +<WRAP lo> 
 +The sensor and optic rotate through the scene, capturing a series of images which are horizontally concatenated to form the final image. 
 +</WRAP>
  
 ===== Hardware Design ===== ===== Hardware Design =====
Line 25: Line 33:
 The EPC901 can be configured both by pull-up/down resistors and by I2C. I followed the data sheet's recommended settings, but enabled the sensor's differential output since the analog signal must be routed through an unshielded FFC cable to the main sensor board. The microcontroller's ADC can also be configured as a differential input, so there's no additional circuitry required to connect the image sensor and microcontroller. The EPC901 can be configured both by pull-up/down resistors and by I2C. I followed the data sheet's recommended settings, but enabled the sensor's differential output since the analog signal must be routed through an unshielded FFC cable to the main sensor board. The microcontroller's ADC can also be configured as a differential input, so there's no additional circuitry required to connect the image sensor and microcontroller.
  
-{{camera-images:block-diagram.png}}((The main hardware components of the camera.))+{{notes:taking-a-picture:block-diagram.png}} 
 + 
 +<WRAP lo> 
 +The main hardware components of the camera. 
 +</WRAP>
  
 Most of the inputs to the EPC901 are easy to drive via the SAMD21. There are lots of pins, but only ''%%READ%%'' and ''%%SHUTTER%%'' are actually required to start and read-out an image. The ''%%SHUTTER%%'' pin is held high for the desired duration of the exposure, and then the ''%%READ%%'' pin is used as a kind of clock to shift out the 1024 samples one-by-one. Most of the inputs to the EPC901 are easy to drive via the SAMD21. There are lots of pins, but only ''%%READ%%'' and ''%%SHUTTER%%'' are actually required to start and read-out an image. The ''%%SHUTTER%%'' pin is held high for the desired duration of the exposure, and then the ''%%READ%%'' pin is used as a kind of clock to shift out the 1024 samples one-by-one.
Line 33: Line 45:
 The time to read an image is limited by the microcontroller's ADC, which can sample at a maximum of around 500k samples per second. This turned out to be a significant issue – the slower images are captured, the slower the motor has to move in order to capture a wide swath of the scene. The time to read an image is limited by the microcontroller's ADC, which can sample at a maximum of around 500k samples per second. This turned out to be a significant issue – the slower images are captured, the slower the motor has to move in order to capture a wide swath of the scene.
  
-{{camera-images:sensor-board.jpg}}((The image sensor is attached to a daughter board by FFC cable so that it can rotate during image acquisition. (A pinhole and additional light-blocking tinfoil covers the sensor during normal operation.%%)%%))+{{notes:taking-a-picture:sensor-board.jpg}} 
 + 
 +<WRAP lo> 
 +The image sensor is attached to a daughter board by FFC cable so that it can rotate during image acquisition. (A pinhole and additional light-blocking tinfoil covers the sensor during normal operation.) 
 +</WRAP>
  
 The microcontroller is also limited by its onboard RAM. A monochrome 1024x1024 image with 8 bits per pixel is 1 MiB – already too much to statically allocate in the SAMD21's memory. Further, the camera is designed to capture panoramic images, so I expected to have to store images which are 2, 3, or 4 MiB. To satisfy this requirement, the microcontroller is connected to an 8 MiB pseudo DRAM via SPI. The SAMD21's DMA subsystem is used to pipe ADC samples directly into this external memory. The microcontroller is also limited by its onboard RAM. A monochrome 1024x1024 image with 8 bits per pixel is 1 MiB – already too much to statically allocate in the SAMD21's memory. Further, the camera is designed to capture panoramic images, so I expected to have to store images which are 2, 3, or 4 MiB. To satisfy this requirement, the microcontroller is connected to an 8 MiB pseudo DRAM via SPI. The SAMD21's DMA subsystem is used to pipe ADC samples directly into this external memory.
Line 47: Line 63:
 The 5-way button pad is used to adjust the camera's exposure duration and to trigger a capture. The 5-way button pad is used to adjust the camera's exposure duration and to trigger a capture.
  
-{{camera-images:main-board.jpg}}((The main board of the camera with LCD at center and the 5-axis button pad on the upper right.))+{{notes:taking-a-picture:main-board.jpg}} 
 + 
 +<WRAP lo> 
 +The main board of the camera with LCD at center and the 5-axis button pad on the upper right. 
 +</WRAP>
  
 ===== Software Design ===== ===== Software Design =====
Line 104: Line 124:
 The below is the most successful image I acquired with the line camera: The below is the most successful image I acquired with the line camera:
  
-{{camera-images:capture-edited.png?500}}((An image through a four-pane window, looking onto the roof of another building with a large tree next to a smaller, more distant tree in the background.))+{{notes:taking-a-picture:capture-edited.png?500}} 
 + 
 +<WRAP lo> 
 +An image through a four-pane window, looking onto the roof of another building with a large tree next to a smaller, more distant tree in the background. 
 +</WRAP>
  
 The image has several flaws, the most noticeable of which are probably the random black pixels. I believe these are due to SRAM write errors caused by poor adherence to the chip's timing requirements, or some issue with the DMA transfer. Even though the image is pixelated and has low contrast, we can also see that the optical system (a pin-hole poked through a sheet of aluminum foil) has trouble reproducing small details. A smaller hole, further from the image sensor would probably increase the detail. The image has several flaws, the most noticeable of which are probably the random black pixels. I believe these are due to SRAM write errors caused by poor adherence to the chip's timing requirements, or some issue with the DMA transfer. Even though the image is pixelated and has low contrast, we can also see that the optical system (a pin-hole poked through a sheet of aluminum foil) has trouble reproducing small details. A smaller hole, further from the image sensor would probably increase the detail.
Line 110: Line 134:
 The main issue with the image (in my opinion), however, is that it's not a panorama. In fact, the above image is just a thin vertical slice of the camera's output, which I've stretched to fill a square window. ((That's why the black pixels in the image look stretched horizontally.)) I was never able to capture a proper panorama with this camera because of a mechanical issue with the motor. The main issue with the image (in my opinion), however, is that it's not a panorama. In fact, the above image is just a thin vertical slice of the camera's output, which I've stretched to fill a square window. ((That's why the black pixels in the image look stretched horizontally.)) I was never able to capture a proper panorama with this camera because of a mechanical issue with the motor.
  
-==== The Motor Issue ====+==== A Motor Issue ==== 
 + 
 +{{notes:taking-a-picture:motor-controller.jpg?300}} 
 + 
 +<WRAP lo> 
 +On the left, the camera after a larger motor had been added. Compare right, the motor controller under a microscope, and with my thumb. 
 +</WRAP>
  
-{{camera-images:motor-controller.jpg?300}}((On the left, the camera after a larger motor had been added. Compare right, the motor controller under a microscope, and with my thumb.)) In order to capture a frame, the image sensor needs to sweep across the scene. To do this, the camera uses a motor which spins the sensor on its axis. The duration of this spin needs to be //slow// enough that the image sensor has time to capture sufficient frames to form a complete image. If the motor is too fast, the angular resolution will be small because not enough frames were captured for every degree of motion. If the motor is too slow, we won't capture a wide angle, but we'll have high angular resolution.+In order to capture a frame, the image sensor needs to sweep across the scene. To do this, the camera uses a motor which spins the sensor on its axis. The duration of this spin needs to be //slow// enough that the image sensor has time to capture sufficient frames to form a complete image. If the motor is too fast, the angular resolution will be small because not enough frames were captured for every degree of motion. If the motor is too slow, we won't capture a wide angle, but we'll have high angular resolution.
  
 I used a tiny geared DC motor to spin the sensor. This tiny motor wasn't geared down as much as was probably necessary, and so the image sensor made a speedy sweep across the scene during each acquisition. Sampling as fast as possible, it was not possible to capture more than a fraction of the scene. I used a tiny geared DC motor to spin the sensor. This tiny motor wasn't geared down as much as was probably necessary, and so the image sensor made a speedy sweep across the scene during each acquisition. Sampling as fast as possible, it was not possible to capture more than a fraction of the scene.
Line 125: Line 155:
  
   * The motor issue could be solved by sampling faster. The SAMD21 is a little under-powered for the task of sampling from the EPC901. A better design might include a stand-alone ADC with faster sample rate, and a microcontroller which can handle the increased data rate. Of course, there is a limit to how much faster we can sample, because we still need to allow time to expose the image sensor on each frame.   * The motor issue could be solved by sampling faster. The SAMD21 is a little under-powered for the task of sampling from the EPC901. A better design might include a stand-alone ADC with faster sample rate, and a microcontroller which can handle the increased data rate. Of course, there is a limit to how much faster we can sample, because we still need to allow time to expose the image sensor on each frame.
-  * The motor issue could also be solved by choosing a more appropriate motor, or by doing away the motor altogether. One attractive solution is to use a purely mechanical system – probably involving a spring and a damper – to rotate the sensor, and potentially an encoder to compensate for any nonlinearities in the motion. The motor and its controller are the most power hungry components of the system, and big contributors to noise, and so removing them would certainly benefit other electronics which aren't directly related to sensor motion control.+  * The motor issue could also be solved by choosing a more appropriate motor, or by doing away the motor altogether. One solution is to use a purely mechanical system, probably involving a spring and a damper, to rotate the sensor, and potentially an encoder to compensate for any nonlinearities in the motion. The motor and its controller are the most power hungry components of the system, and big contributors to noise, so removing them would simplify things.
  
-Secondly, the user interface could be somewhat improved. Mainly, I'm referring to the old Nokia 6100 display which I recycled to use on this project. There are very cheap displays to be found with better color rendering, and without the need to generate 7 volts for the backlight.+Secondly, the user interface could be improved. I'm mainly referring to the old Nokia 6100 display which I recycled to use on this project. There are very cheap displays to be found with better color rendering, and without the need to generate 7 volts for the backlight.
  
notes/taking-a-picture.1796019413.txt.gz · Last modified: by sam