PHYTEC-USB-CAM Series communication protocol

Similar documents
ArduCAM USB Camera C/C++ SDK

ArduCAM USB Camera SDK

How to Implement an Image Sensor Interface Using EZ-USB FX3 in a USB Video Class (UVC) Framework

.NET Wrapper SDK Descriptor

Projected Capacitive Touch Solution General Specification

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

AN How to Implement an Image Sensor Interface Using EZ-USB FX3 in a USB Video Class (UVC) Framework

CODA Online Data Formats

AcquisitionApplets. User Documentation. Acq_SingleCLHSx2AreaRAW for microenable 5 marathon AF2

AcquisitionApplets. User Documentation. Acq_DualBaseAreaRGB for microenable 5 marathon/lightbridge VCL

ArduCAM USB Camera SDK

AcquisitionApplets. User Documentation. Acq_SingleFullAreaBayer for microenable 5 marathon/lightbridge VCL

Futaba MDM166A display

Test Applet. User Documentation. FrameGrabberTest for microenable 5 marathon AF2

Operating Manual. Inferface. CANopen. English

ADC ACQUISITION MODE...

Using the FADC250 Module (V1C - 5/5/14)

OEM API Specification

TELI CSB4000CL Reference Information

SBIG ASTRONOMICAL INSTRUMENTS

Artemis SDK. Copyright Artemis CCD Limited October 2011 Version

Reference Waveform File Format

PDF Document structure, that need for managing of PDF file. It uses in all functions from EMF2PDF SDK.

Test Applet. User Documentation. FrameGrabberTest for microenable 5 AQ8-CXP6B

ArduCAM USB Camera Shield

AUTO FOCUS MODULE CUSTOM CAMERAS FOR MASS PRODUCTION APPLICATIONS USER GUIDE

NanEye GS. Idule Module Evaluation Unit

Next Generation Intelligent LCDs

Modbus Register Map: Galaxy 5000 & Galaxy 5500

ArduCAM-M-2MP Camera Shield

PRODUCT RELIABILITY HOST COMMUNICATIONS PACKET STRUCTURE SPECIFICATION. % of Initial Brightness (New Module) NOTE. <type><data_length><data><crc> type

Performance Oscilloscope Reference Waveform File Format

int fnvgetconfig(handle h, UINT32 id, const void *cfg, size_t sz);... 4

The I2C BUS Interface

Read section 8 of this document for detailed instructions on how to use this interface spec with LibUSB For OSX

EZ-USB Suite User Guide

Pci3Ip, Pci5Ip, Pc104pIp, Pc104p4Ip, cpci2ip, cpci4ip and PcieCar IndustryPack Carrier Device Drivers

BMP file format - Wikipedia

Technical Resource. Genie Nano Camera Configuration

TPMC Digital Inputs/Outputs (Bit I/O) Version 2.0. User Manual. Issue February 2014

USB2 Debug Device A Functional Device Specification

C4 - Application Note. AutoStart. Rev 1.0. AT - Automation Technology GmbH

IVI-6.2: VISA Interoperability Requirements for USBTMC Specification

NOCTURN XL: Getting Started. For Win 7 Evaluation GUI Version February 21, 2013 Frisco, Texas

LORD MANUAL. Wireless Sensor Networks LXRS Data Communications Protocol

[CAMERA PROGRAMMER'S MANUAL] EMERGENT VISION TECHNOLOGIES INC March 3, 2013

ELLSI. EtherCAN Low Level Socket Interface. Software Manual. to Product C.2050.xx and C.2051.xx

Protocol of SOJI Fuel level sensor FJ-RS232/FJ-RS485 Version 1.0.2

Genesys Logic, Inc. GL862. USB 2.0 PC Camera Controller. Product Overview

Time Sensitive Control Streams in IEEE P1722A v1.3

SERIES 1004 X 1004 PROGRESSIVE SCAN CAMERA TECHNICAL REFERENCE MANUAL

Fujitsu Microelectronics Europe Application Note MCU-AN E-V10 F²MC-FR FAMILY 32-BIT MICROCONTROLLER MB91460 RELOAD TIMER APPLICATION NOTE

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

Communication Protocol Reference Guide

RAID Option ROM. Product Implementation Guide. Version 1.8 Date: 08/19/2009. Copyright 2009, Promise Technology, Inc. All Rights Reserved

IP-48DAC channel 16-bit Digital/Analog Converter With memory Industry Pack Module PROGRAMMING MANUAL Version 1.

TIM-UP 19k-S3-Spartan 6

CE PSoC 4: Time-Stamped ADC Data Transfer Using DMA

PCI-4IPM Revision C. Second Generation Intelligent IP Carrier for PCI Systems Up to Four IndustryPack Modules Dual Ported SRAM, Bus Master DMA

Picture Translation A Challenge

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

AN EZ-USB FX3 I 2 C Boot Option. Application Note Abstract. Introduction. FX3 Boot Options

spwr_base & spwr_chan

imetos LoRa Data payload structure

The Imaging Source USB 3.0 Series Cameras DMK 23UV024 / DFK 23UV024

Developing a simple UVC device based on i.mx RT1050

Modbus Map: Conext System Control Panel (SCP) Device

MIDI CPU Firmware V User Manual

Nabto Serial Link Protocol

CSCI 2212: Intermediate Programming / C Chapter 15

IP-AD Channel 500 khz Simultaneous IndustryPack Module REFERENCE MANUAL Version 1.4 June 2003

Designing Your Own Soft Modules

Protocol of data exchange with modem via USB interface Version

SC2004MBS 20x4 Characters MODBUS RTU Slave LCD

2G Actuator Communications Protocol Document Rotary & Linear Actuators

Modbus Register Map: Galaxy 300

1. Implemented CM11 protocol

GigE Vision camera featuring the Sony IMX267 CMOS sensor, Pregius global shutter

Product Specification Sapphire

C628 Enhanced JPEG Module. User Manual

CrossWorks Device Library

SPI Lasers UK Limited. Serial Command Reference for the PRISM Laser Platform

The New C Standard (Excerpted material)

TPMC815 ARCNET PMC. User Manual. The Embedded I/O Company. Version 2.0. Issue 1.2 November 2002 D

NextGenRaster API Reference

SVM-03/03U Utility Software. [SVMCtl] Software Manual. Rev. 8.1

CLD SC58x CDC Library v.1.00 Users Guide Users Guide Revision For Use With Analog Devices ADSP-SC58x Series Processors. Closed Loop Design, LLC

RS232-ADC16/24 Manual

TPMC Channel Isolated Serial Interface RS422/RS485. Version 1.0. User Manual. Issue July 2009

Private Eye Display Controller Programmer s Manual

CLD BF70x CDC Library v.1.3 Users Guide Users Guide Revision 1.3. For Use With Analog Devices ADSP-BF70x Series Processors. Closed Loop Design, LLC

EP A1 (19) (11) EP A1 (12) EUROPEAN PATENT APPLICATION. (43) Date of publication: Bulletin 2012/34

Ellisys USB Analysis Software

DxP Protocol Version 1.2

CHAPI/VAX-Qbus. The CHARON-VAX Application Programming Interface (CHAPI) for Qbus peripheral emulation in Windows

On Control SUSA v1.1 MODBUS Functions

TPMC /8 Digital Inputs (24V) 16/8 Digital Outputs (24V, 0.5A) Version 3.0. User Manual. Issue June 2014

CS360 Midterm 1 - February 21, James S. Plank. Put all answers on the answer sheet. In all of these questions, please assume the following:

CANopen. Network configuration. Operating instructions Software. Integration of Bürkert devices in CANopen networks

CPCI-IPC. Intelligent DSP Based Dual IndustryPack Carrier for CompactPCI systems REFERENCE MANUAL Version 2.

Transcription:

Application Note No. LAN-057e Version: 1.0 Author: H. Fendrich Date: 30.09.2011 Historie: Version Changes Date Author 1.0 Creation of the document 30.09.2011 H. Fendrich PHYTEC-USB-CAM Series communication protocol Table of Contents 1 Introduction... 2 2 Properties... 3 2.1 UVC Requests... 3 2.2 Definitions... 3 2.2.1 VC_PROCESSING_UNIT... 3 2.2.2 VC_INPUT_TERMINAL... 4 2.2.3 CT_PRIVACY_CONTROL... 5 3 Register Requests... 6 4 Video Format Selection... 7 4.1 Introduction... 7 4.2 Initializing the Video Format Setting (probe/commit)... 7 4.3 Video Format - USB-CAM-x51H / x52h series... 8 4.4 Frame Rates USB-CAM x03h / x04h... 9 4.5 Frame Rates - USB-CAM x51h / x52h... 10 5 Video Data Transfer... 12 6 References... 12 List of Figures Figure 1: USB-CAM... 2 LAN-057e_1 1/12

1 Introduction The communication protocol of the PHYTEC USB-CAM series (USB-CAM- 051H / 052H / 151H / 152H and USB-CAM-003H / 004H / 103H / 104H) is based on the "USB video device class" (UVC - http://en.wikipedia.org/wiki/usb_video_device_class). Unfortunately, UVC does not fully meet the requirements of industrial cameras. It, for instance, does not provide monochrome video formats. Therefore, PHYTEC has enhanced the USB video class by the features described in this document. Please note that the Phytec Messtechnik GmbH cannot and does not take any responsibility or liability for any information contained in this document. The source code presented in this document is exclusively used for didactic purposes. PHYTEC does not assume any kind of warranty expressed or implied, resulting from the use of the content of this document or the source code. The PHYTEC reserves the right to make changes in specifications, function or design at any time and without prior notice. Figure 1: USB-CAM 2/12 LAN-057e_1

2 Properties 2.1 UVC Requests To get details about the camera parameters, a UVC driver sends requests to the camera (as for instance: - PU_BRIGHTNESS_CONTROL, PU_GAIN_CONTROL and - PU_WHITE_BALANCE_TEMPERATURE_CONTROL). The USB-CAM cameras respond normally to such requests. There is only one exception: below you will find UVC add-ons that are only valid for the USB-CAM series. Please do not use the request GET_LEN in the context of these add-ons. 2.2 Definitions The UVC Processing Unit Descriptors are used to describe the features of the video device. Pls. see chapter 3.7.2.5 of the UVC specification [1] for details. To overcome some UVC limits, we enhanced the following three Interface Descriptor Subtypes: 2.2.1 VC_PROCESSING_UNIT For The PHYTEC USB-CAM cameras the UVC interface descriptor subtype VC_PROCESSING_UNIT describes some color formats that are unknown in the UVC standard (pls. see also section Video data format selection below). Please note that the controls of this terminal are readonly. To get the color formats provided by the camera, read the terminal's value and perform an operation with the following bit values: enum COLOR_FORMAT_MONO8 = 1<<0, COLOR_FORMAT_BAYER1 = 1<<3, // RG COLOR_FORMAT_BAYER2 = 1<<4, // GR COLOR_FORMAT_BAYER3 = 1<<5, // BG COLOR_FORMAT_BAYER4 = 1<<6, // GB LAN-057e_1 3/12

enum PU_TIS_CAPABILITY = 0x20, PU_TIS_COLOR_FORMAT = 0x21, enum PU_CAPABILITY_COLOR_FORMAT = 1<<1, Example: // Checking if the device delivers COLOR_FORMAT_BAYER1 data : unsigned int av_formats =...; //... = your function to read the terminal bool issupported = (av_formats & COLOR_FORMAT_BAYER1)!= 0; 2.2.2 VC_INPUT_TERMINAL For The PHYTEC USB-CAM cameras the UVC interface descriptor subtype VC_INPUT_TERMINAL describes some features that are typical for industrial cameras but unknown in the UVC standard: enum CT_TIS_CAPABILITY = 0x20, // capability bits, see CT_CAPABILITY_* CT_TIS_PIXEL_CLOCK = 0x24, CT_TIS_PARTIAL_SCAN_WIDTH = 0x25, CT_TIS_PARTIAL_SCAN_HEIGHT = 0x26, CT_TIS_BLANKING_INFO = 0x27, CT_TIS_PARTIAL_SCAN_X = 0x28, CT_TIS_PARTIAL_SCAN_Y = 0x29, CT_TIS_BINNING = 0x2a, CT_TIS_SOFTWARE_TRIGGER = 0x2b, CT_TIS_FIRMWARE_REVISION = 0x2d, CT_TIS_DIGITAL_OUTPUT = 0x2e, CT_TIS_UART = 0x41, // special values 4/12 LAN-057e_1

enum CT_CAPABILITY_PIXEL_CLOCK = 1<<4, CT_CAPABILITY_PARTIAL_SCAN_WIDTH = 1<<5, CT_CAPABILITY_PARTIAL_SCAN_HEIGHT = 1<<6, CT_CAPABILITY_BLANKING_INFO = 1<<7, CT_CAPABILITY_BINNING = 1<<8, CT_CAPABILITY_SOFTWARE_TRIGGER = 1<<9, CT_CAPABILITY_FIRMWARE_REVISION = 1<<11, CT_CAPABILITY_DIGITAL_OUTPUT = 1<<12, CT_CAPABILITY_UART = 1<<14, 2.2.3 CT_PRIVACY_CONTROL Another typical feature of industrial cameras is the trigger input (please see http://www.industrial-camera.com/trigger.htm for details). For the PHYTEC USB-CAM cameras the UVC interface descriptor subtype CT_PRIVACY_CONTROL is used to provide this feature: setting CT_PRIVACY_CONTROL to 0x1 enables the trigger, setting it to 0x3 enables the trigger and inverts the trigger pulse polarity. LAN-057e_1 5/12

3 Register Requests Some of the parameters of PHYTEC USB-CAM cameras have to be set via registers. Please use a USB vendor request [2] with the following fields to access the camera's registers: bool bvendorreq = true; BYTE RequestTarget = 0 BYTE brequestcode = 0 WORD wvalue = 0 WORD windex = register_id register_id can be one of the following registers: MPIARegister_CamType = 0x1a MPIARegister_FrameRate = 0x3a Read MPIARegister_CamType to retrieve the type of the sensor. If bit 0x2 is 0 it is a monochrome camera, otherwise it is color camera: bool is_color_cam = (readregister( MPIARegister_CamType ) & 0x2)!= 0; Register MPIARegister_FrameRate is used to set the frame rate of USB- CAM-x03H / x04h cameras. Please see details below. 6/12 LAN-057e_1

4 Video Format Selection 4.1 Introduction Because of historical reasons, the UVC Windows drivers are based on video formats providing 16 bit color values for every pixel. In contrast to this, the PHYTEC USB-CAM cameras use - depending on the specific camera - 8 bit monochrome or 8 bit raw color data (also called "Bayer" format; please see http://knol.google.com/k/henning-b%c3%a4ssmann/color-cameras-whatis-the-origin-of-the/1s6x647mrtwu6/3# for details). Therefore, please interpret a 16 bit UVC color value as two 8 bit monochrome or raw color values. As a consequence, the images only have half the columns of their nominal resolution. For instance, a USB-CAM-x03H / x04h with a nominal resolution of 744 x 480 pixel has to be treated as a camera with 372 x 480 pixel. For industrial cameras "video format" also comprises the camera's frame rate. Additionally, the USB-CAM camera series provide a ROI (region of interest) feature. Furthermore, the USB-CAM-x51H / x52h series offers two binning modes. 4.2 Initializing the Video Format Setting (probe/commit) According to chapter 4.3 of the UVC specification [1], a probe request has to be sent to the camera. For the USB-CAM-x51H / x52h series, please perform this request using the following structure (VideoStreamingControl is described in table 4-47 of the UVC specification): VideoStreamingControl probe = 0x1, 0x1, 0x1, 333333 LAN-057e_1 7/12

In case of the USB-CAM-x03H / x04h camera series this structure has to be initialized with: VideoStreamingControl probe = 0x1, 0x1, bframeindex, 333333 Please set the field bframeindex according to the video frame index that represents the required resolution. To determine the correct video frame index, please refer to the cameras Video Streaming Uncompressed Frame Type Descriptor. This descriptor has initially been read by the UVC driver. To find more details concering bframeindex, please refer to chapter 4.3.1.1 of the UVC specification [1]. 4.3 Video Format - USB-CAM-x51H / x52h series While the video format setting of the USB-CAM-x03H / x04h camera series is mainly done by the initializing procedure described in the previous section, the USB-CAM-x51H / x52h series require more parameters to be set. First of all, you need to know the minimum and maximum resolution of the image. The camera provides you with these parameters via CT_TIS_PARTIAL_SCAN_WIDTH and CT_TIS_PARTIAL_SCAN_HEIGHT. To set the image size, please set the parameters CT_TIS_PARTIAL_SCAN_WIDTH, CT_TIS_PARTIAL_SCAN_HEIGHT, CT_TIS_PARTIAL_SCAN_X, and CT_TIS_PARTIAL_SCAN_Y. Please also note that the increment of the width is 8 pixels, while that of the height is 4 pixels. 8/12 LAN-057e_1

Another important video format parameter is the frame rate. Please see section Frame rates - USB-CAM-x03H / x04h below for details. To increase the sensors sensivity, the USB-CAM-x51H / x52h camera series provides two binning modes. Please set CT_TIS_BINNING to 2 for a 2x2 binning and 4 for a 4x4 binning. If you do not intend to use any binning mode, CT_TIS_BINNING has to be 1. Important: please set the above mentioned parameters based on the following sequence: Reset CT_TIS_BINNING to 1 (no binning) Reset CT_TIS_PARTIAL_SCAN_X and CT_TIS_PARTIAL_SCAN_Y to 0 Set your frame rate (see below) Set your image resolution (region of interest) using CT_TIS_PARTIAL_SCAN_WIDTH and CT_TIS_PARTIAL_SCAN_HEIGHT Set your image position (region of interest) using CT_TIS_PARTIAL_SCAN_X and CT_TIS_PARTIAL_SCAN_Y Set your binning mode using CT_TIS_BINNING 4.4 Frame Rates USB-CAM x03h / x04h Please set the register MPIARegister_FrameRate with the following values to determine the frame rate of the USB-CAM-x03H / x04h cameras: 320x240 Register 640x480 Register 160 fps 7 87 fps 7 120 fps 6 60 fps 6 80 fps 0 or 5 30 fps 0 or 5 60 fps 1 15 fps 2 30 fps 2 7.5 fps 3 5 fps 4 744x480 Register 76 fps 7 60 fps 6 30 fps 0 or 5 15 fps 2 7.5 fps 3 5 fps 4 LAN-057e_1 9/12

4.5 Frame Rates - USB-CAM x51h / x52h Please use the function setframerate( SIZE newdim, int64 AvgTimePerFrame) to set the camera's pixel clock. By using the parameters newdim and AvgTimePerFrame, you determine the image size and the frame rate (in units of 100 nano seconds): typedef struct tagsize int cx; int cy; SIZE; unsigned int calc_pixel_per_frame( unsigned int w, unsigned int h ) unsigned int pixel_width = w * 1; unsigned int x_blanking = BlankingInfo_getValue() & 0xFFFF; unsigned int y_blanking = (BlankingInfo_getValue() >> 16) & 0xFFFF; return (pixel_width + x_blanking) * (h + y_blanking); inline int64 AvgTPFtoFP1kS( int64 v ) return 10000000000 / v; inline int64 FP1kStoAvgTimePerFrame( int64 v ) return 10000000000 / v; int64 calc_fp1ks_for_pixelclock( const SIZE& dim, INT32 val ) int64 max_pixelclock = val; int64 pixel = calc_pixel_per_frame( dim.cx, ABS( dim.cy ) ); return (max_pixelclock * int64( 1000 )) / pixel; // frames per second * 1000 10/12 LAN-057e_1

void setframerate( SIZE newdim, int64 AvgTimePerFrame ) int64 framerate_fp1ks = AvgTPFtoFP1kS( hdr.avgtimeperframe ); int64 max_fp1ks = calc_fp1ks_for_pixelclock( newdim, PixelClock_max_getValue() ); int64 min_fp1ks = calc_fp1ks_for_pixelclock( newdim, PixelClock_min_getValue() ); int64 frmratetoset_fp1ks = CLIP( framerate_fp1ks, min_fp1ks, max_fp1ks ); int64 pixel = calc_pixel_per_frame( newdim.cx, ABS( newdim.cy ) ); int64 new_pixel_clock = (pixel * fp1ks) / int64( 1000 ); PixelClock_setValue( new_pixel_clock ); Please note: Function BlankingInfo_getValue() retrieves the value of the CT_TIS_BLANKING_INFO control (please see section VC_INPUT_TERMINAL above) PixelClock_min_getValue() is used to obtain the minimum value of the CT_TIS_PIXEL_CLOCK control PixelClock_max_getValue() gets the maximum value of the CT_TIS_PIXEL_CLOCK control PixelClock_setValue(... ) sets the value of the CT_TIS_PIXEL_CLOCK control. LAN-057e_1 11/12

5 Video Data Transfer The transfer of the video data of the USB-CAM camera series is based on the UVC standard. Every image is transferred using exactly one block with this payload header (please note it is always two bytes long): struct tpayloadheaderbase enum tuvcpayloadheaderflags uvc_fid = 0x1, uvc_eof = 0x2, BYTE len; // header BYTE bfh; // header BYTE[] data; Usually, the image device provides the size of the block. Please note that the USB-CAM cameras do not provide valid data upon such a request. Therefore, please calculate its size using the following function: unsigned int calcmaxtransfersize(const uvc::videostreamingcontrol& ctrl, unsigned int bisizeimage ) unsigned int input_frame_size = bisizeimage; unsigned int max_transfer_size = ctrl.dwmaxpayloadtransfersize; if( max_transfer_size > (input_frame_size + 2) ) max_transfer_size = input_frame_size + 2; return max_transfer_size; 6 References [1] USB Implementers Forum: Universal Serial Bus Device Class Definition for Video Devices - Revision 1.1. June 1, 2005 [2] Universal Serial Bus Specification - Revision 2.0. April 27, 2000 12/12 LAN-057e_1