====== Pcam 5C Reference Manual ====== The [[https://digilent.com/shop/boards-and-components/system-board-expansion-modules/pcams/|Pcam 5C]] is an imaging module meant for use with FPGA development boards. The module is designed around the Omnivision OV5640 5 megapixel (MP) color image sensor. This sensor includes various internal processing functions that can improve image quality, including automatic white balance, automatic black level calibration, and controls for adjusting saturation, hue, gamma and sharpness. Data is transferred over a dual-lane MIPI CSI-2 interface, which provides enough data bandwidth to support common video streaming formats such as 1080p (at 30 frames per second) and 720p (at 60 frames per second). The module is connected to the FPGA development board via a 15-pin flat-flexible cable (FFC) that is pin compatible with the connector found on the popular Raspberry Pi development board. The Pcam 5C comes with a 10 cm flat-flexible cable and a factory-installed fixed focus lens with M12 lens mount, so it is ready to use out of the box. {{Digilent Image Gallery | image = {{:reference:add-ons:pcam-5c:pcam-5c-0.png?direct |}} | image = {{:reference:add-ons:pcam-5c:pcam-5c-1.png?direct |}} | image = {{:reference:add-ons:pcam-5c:pcam-5c-2.png?direct |}} | image = {{:reference:add-ons:pcam-5c:pcam-5c-3.png?direct |}} | image = {{:reference:add-ons:pcam-5c:pcam-5c-4.jpg?direct |}} }} == Download This Reference Manual == * //Not yet available for download// ---- ===== Features ===== * 5MP color system-on-chip image sensor * 15-pin FFC connector for image data * Dual lane MIPI CSI-2 image sensor interface * Supports QSXGA@15Hz, 1080p@30Hz, 720p@60Hz, VGA@90Hz and QVGA@120Hz* * Output formats include RAW10, RGB565, CCIR656, YUV422/420, YCbCr422, and JPEG compression* * Standard M12 lens mount for lens interchangeability * Ships with 10 cm cable and factory installed fixed-focus lens * Small PCB size for flexible designs (4.0 cm x 2.5 cm) * 1x7 straight 100-mil header for access to auxiliary camera signals * Works with Pcam compatible Digilent development boards *//Not all resolutions and output formats tested.// ---- ===== Software Support ===== Image sensor break-outs, such as the Pcam 5C, can only be controlled by an SoC with a MIPI CSI-2 controller in hardware and using these break-outs requires complicated software that properly configures the controller and the sensor. When trying to implement a method of using such a break-out with an FPGA host, there are two realistic options: - Pay a license fee to acquire MIPI CSI-2 IP that is designed to work in FPGAs. Typically this will provide a very robust solution and good software support, including embedded Linux drivers. The licensing fees are steep for these, and can be cost prohibitive to many. The source code is also often encrypted, so it can not be studied for educational purposes. - Develop the hardware and software from scratch. This requires a large time investment from someone with advanced skills. It also requires access to information that is not accessible to most, including closed specifications and datasheets. To solve this problem, Digilent has created a set of open source Vivado IP cores that work with the Pcam 5C on FPGA and Zynq host boards. In order to achieve this in a practical manner, some short-cuts have been taken that limit this IP from functioning as robustly as some of the licensed solutions that are available. Also, the software paired with the IP does not currently take full advantage of all of the OV5640's features, which affects the produced image's quality. As these IPs are open source, Digilent encourages users to contribute to the development and improvement of these cores. **Note:** //With select boards, Digilent provides vouchers for licenses as an alternative to these open source IP cores.// A full list of demos that support the Pcam 5C on various Digilent FPGA boards can be found in the [[add-ons:pcam-5c:start#example_projects|Example Projects]] section of the Pcam 5C Resource Center. Although the connector on the Pcam 5C is pin compatible with the Raspberry Pi, Digilent has not validated that the two devices work properly together and does not provide software to do so. ---- ===== Specifications ===== ^ Voltage and Power Parameters ^ Min ^ Typical ^ Max ^ Units ^ | Power Supply Input Voltage | 3.0 | 3.3 | 3.6 | V | | Power Supply Current Consumption | - | - | 200 | mA | | SCCB Signal voltage | - | 3.3 | - | V | | PWUP signal voltage | - | 3.3 | - | V | ^ Timing Parameters ^ Min ^ Typ ^ Max ^ Units ^ | MIPI_CLK Frequency | - | 672 | - | MHz | | XVCLK Frequency (IC2) | - | 12.000 | - | MHz | | PWUP Low Pulse (For Reset) | 100 | - | - | ms | | PWUP high to SCCB access | 50 | - | - | ms | | SCCB Clock (SCL) Frequency | - | - | 400 | KHz | ^ Image Sensor Parameters ^ Value ||^ Units ^ | Optical size | 1/4 ||| Inches | | Active Array Dimensions | 2592 x 1944 ||| Pixels | | Lens Chief Array Angle | 24 ||| Degrees | | Shutter Type | Rolling ||| - | | Sensitivity | 600 ||| mV/lux-sec | | Pixel Size | 1.4 x 1.4 ||| μm | ---- ===== Pinout Table Diagram ===== ^ Header J1 |||||||| ^ Pin ^ Signal ^ Direction ^ Description ^ Pin ^ Signal ^ Direction ^ Description ^ | 1 | GND | | Power Supply Ground | 9 | MIPI_CLK_P | Out | MIPI CSI-2 Clock Positive | | 2 | LANE0_N | Out | MIPI CSI-2 Lane 0 Negative | 10 | GND | | Power Supply Ground | | 3 | LANE0_P | Out | MIPI CSI-2 Lane 0 Positive | 11 | PWUP | In | Power supply and sensor enable | | 4 | GND | | Power Supply Ground | 12 | N/C | | Not Connected | | 5 | LANE1_N | Out | MIPI CSI-2 Lane 1 Negative | 13 | SCL | I/O | Serial Camera Control Bus (SCCB) Clock | | 6 | LANE1_P | Out | MIPI CSI-2 Lane 1 Positive | 14 | SDA | I/O | Serial Camera Control Bus (SCCB) Data | | 7 | GND | | Power Supply Ground | 15 | VCC3V3 | | Power Supply (3.3V) Input | | 8 | MIPI_CLK_N | Out | MIPI CSI-2 Clock Negative | | | | | ----- ===== Physical Dimensions ===== The PCB is 40 mm long and 25 mm wide. The 15-pin FFC connector is right angle and bottom mounted, with 1 mm pitch. ---- ===== Functional Description ===== ===== Serial Communication ===== ==== MIPI CSI-2 Interface ==== The Pcam 5C includes a dual-lane MIPI CSI-2 interface that is used to transmit image data from the OV5640 image sensor on the Pcam 5C to the attached host. It consists of three differential pairs, two for data and one for a clock signal, which are all routed to the 15-pin FFC connector. The clock and data signals are driven by the image sensor and should be treated as inputs by the attached host. The physical layer of the MIPI CSI-2 interface is called D-PHY. It is supported by the I/O blocks on Xilinx Ultrascale devices natively, but requires some passive circuitry external to the FPGA in order to be connected to Xilinx 7-series devices. For detailed information on the circuitry required to use D-PHY with a 7-series device, see the [[https://docs.xilinx.com/v/u/en-US/xapp894-d-phy-solutions|XAPP894 Application Note]] available from Xilinx. Further information on the details of MIPI CSI-2 and D-PHY are beyond the scope of this document. Digilent provides open source MIPI CSI-2 and D-PHY Vivado IP cores that can be studied to learn more. These IP cores are included in the [[https://github.com/Digilent/vivado-library|Digilent Vivado Library]]. ==== Serial Camera Control Bus (SCCB) ==== The SCCB on the Pcam 5C is a two-pin bus used to access the control registers for the OV5640 image sensor. The bus behaves the same way as an I2C bus, and can be treated exactly the same. This means it can be controlled using existing I2C IP cores or RTL. For a more complete description of how an I2C bus works, see the [[learn:fundamentals:communication-protocols:i2c:start|I2C Fundamentals Guide]]. It is expected that the host provide 1.5 KOhm pull-up resistors on both SCL and SDA. The attached host drives the clock (SCL) and behaves as the master on the bus. The OV5640 acts as a slave at the I2C addresses 0x78/0x79, or in 7-bit format 0b111100. The register map accessed with the SCCB consists of 8-bit registers organized in a 16-bit address space. The details of how register read and write transactions occur are detailed in proprietary documentation that is available from OmniVision. Most users should not need to fully understand how the SCCB transactions occur, and can instead rely on the libraries included with the Pcam 5C demo that use the Zynq I2C hardware to properly read and write the OV5640 registers. ----- ===== Register Details ===== The registers that are accessed using the SCCB are used to control the OV5640 image sensor. This includes things such as initializing the sensor, setting the output format, and enabling image processing features. The OV5640 image sensor register map is fully documented in the OV5640 datasheet, but Digilent does not have permission to redistribute that document. To obtain complete information on the registers, please contact OmniVision and request access to the OV5640 datasheet. The source code for the Pcam 5C demo project described in the [[#Software_Support|Software Support Section]] contains most of the practical information about what registers need to be written at what time in order to use the Pcam 5C. It can be referred to as well if the more detailed information in the datasheet is not required. ---- ===== FFC Attachment ===== The Pcam 5C is connected to a host board via a 15-pin FFC. It ships with 10 cm cable that is pre-attached to the FFC connector on the module. If the cable is detached from the Pcam 5C for any reason, it will need to be reinstalled. This can be done as follows: - Locate the 15-pin FFC connector on the bottom side of the Pcam 5C. - Pull the black plastic tab on the edge of the connector out, away from the opening of the connector. This opens the connector. - Insert the FFC with the contacts facing up, toward the Pcam 5C PCB. The blue side (without contacts exposed) should be facing down. - Ensure the FFC is fully inserted. - Gently press both sides of the black plastic tab back towards the rest of the connector to latch the FFC in. - Test the FFC is securely fastened by ensuring that both sides of the black plastic tab are touching the white part of the connector. Then gently tug on the FFC to ensure it is not loose. - The FFC is now connected properly. For information on how to attach the other side of the FFC to a host board, see the Pcam section of the board's reference manual. ---- ===== Lens Adjustment ===== The lens solution provided on the Pcam 5C includes an M12 Lens mount and a factory-installed manual focus lens with lens cap. The lens focus is adjusted by twisting it either clockwise or counter-clockwise. It is possible to adjust the focus of the lens to a point that will cause most objects to be in focus, as long as they are not very close to the lens. This can be accomplished in practice by running the Pcam 5C demo project, and then adjusting the focus of the lens until an object several feet away looks very clear and sharp. The lens should not need to be adjusted further, unless an object close to the Pcam 5C needs to be focused on. For complete optical characteristics of the lens included with the Pcam 5C, please refer to its {{ :reference:add-ons:pcam-5c:sj2718-650_ov5640_v9.pdf |datasheet}}. The mechanical dimensions of the M12 lens mount are available in its {{ :reference:add-ons:pcam-5c:pcam_5c_lens_mount.pdf |datasheet}} as well. It is also possible to replace the included lens with a different M12 lens. Many suitable M12 lenses with a range of unique characteristics are available for sale from third-party vendors. Care should be taken when choosing a third party lens to ensure it is appropriate to use with the OV5640 image sensor and the Pcam 5C lens mount. Some longer lenses may make contact with the image sensor if over tightened, which could cause damage. Digilent recommends that the included lens never be fully removed unless a different lens is being swapped in. This will help prevent damage to the image sensor, which is very delicate. If swapping in a different lens, the procedure should be done in a clean environment and the time in which the image sensor is exposed should be minimized. ---- ===== Power-up and Reset ===== The PWUP signal on the 15-pin FFC connector is used by the host to turn the Pcam 5C on and off. It directly controls the power supplies found on the Pcam 5C, disconnecting power to the OV5640 when it is not driven high. The PWUP signal must be driven high in order to use the Pcam 5C. The power-up sequence for the Pcam 5C includes a number of steps. These steps are implemented in the source code for the Pcam 5C demo described in the [[#Software_Support|Software Support section]], however they are also provided here for reference purposes: - Execute a power-cycle by applying a low pulse of 100ms on CAM_PWUP, then driving it high. - Wait for 50ms. - Read sensor ID from registers 0x300A and 0x300B and check against 0x56 and 0x40, respectively. - Choose system input clock from pad by writing 0x11 to register address 0x3103. - Execute software reset by writing 0x82 to register address 0x3008. - Wait for 10ms. - De-assert reset and enable power down until configuration is done by writing 0x42 to register address 0x3008. - Choose system input clock from PLL by writing 0x03 to register address 0x3103. - Set PLL registers for desired MIPI data rate and sensor timing (frame rate). - Set imaging configuration registers. - Enable MIPI interface by writing either 0x45 for two-lane mode or 0x25 for one-lane mode to register address 0x300E. - Let MIPI clock free-run, and force LP11 when no packet transmission by writing 0x14 to register address 0x4800. - Set output format to RAW10 by writing 0x00 to register address 0x4300 and 0x03 to register address 0x501F. - Wake up sensor by writing 0x02 to register address 0x3800. The procedure above can be repeated at any time during execution to perform a reset on the sensor. ---- ===== Auxiliary Signals ===== The unloaded header labeled J3 on the Pcam 5C can be used to access some additional signals of the OV5640. This is so that those with access to the OV5640 datasheet can use some of the additional functionality they provide. These signals will not be useful to those without access to the OV5640 datasheet, as they are otherwise undocumented. Most will not need to have any use for the functionality provided on these signals, and their use is not required for normal function of the Pcam 5C. The signals are briefly described in the table below. ^ Header J3 |||||| ^ Pin ^ Signal ^ Description ^ Pin ^ Signal ^ Description ^ | 1 | GPIO0 | Camera GPIO 0 | 5 | GND | Power Supply Ground | | 2 | GPIO1 | Camera GPIO 1 | 6 | VCMSINK | Auto-focus voice coil motor sink | | 3 | FREX | Frame exposure mode shutter signal | 7 | VCMGND | Auto-focus voice coil motor ground | | 4 | STROBE | Flash LED strobe signal | | | | ---- ===== Liquid Lens Support ===== The Pcam 5C PCB was designed to allow for the incorporation of circuitry that can drive an auto-focus M12 liquid lens assembly, such as those created by [[http://www.varioptic.com/products/auto-focus-lens-modules/|Varioptic]]. The circuitry needed to drive a liquid lens assembly is not loaded in the current version of the Pcam 5C (see page 2 of the {{reference:add-ons:pcam-5c:pcam_5c_sch.pdf|Pcam 5C Schematic}}). ---- ===== Additional Information ===== The schematics of the %%Pcam 5C%% are available {{reference:add-ons:pcam-5c:pcam_5c_sch.pdf|here}}. Additional information about the OV5640 image sensor SoC can be found in the sensor datasheet, which can be obtained by contacting OmniVision. A brief overview of the OV5640 is publicly available in the {{reference:add-ons:pcam-5c:ov5640_product_brief.pdf|OV5640 Product Brief}}. Example code demonstrating how to use the %%Pcam 5C%% can be found on its [[add-ons:pcam-5c:start|Resource Center]]. If you have any questions or comments about the %%Pcam 5C%%, feel free to post them under the appropriate section ("Add-on Boards") of the [[https://forum.digilent.com/|Digilent Forum]]. {{tag>pcam pcam-5c add-ons reference-manual doc}}