QHYCCD

QHYCCD Software Developer Zone => QHYCCD LOW LEVEL PROTOCOL => Topic started by: QiuHY on February 26, 2017, 09:58:16 PM

Title: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 09:58:16 PM
QHY165C is our cooled CMOS camera with 16mega pixel APS-C imager. It support both video stream mode and single capture mode. It has a DDR image buffer to make the transfer more stable and allow very low CPU,ARM / USB2.0 work perfectly.


1.QHY165C LOW LEVEL PPROTOCOL  (LEVEL 1)

LEVEL 0 refers to our original FIREWARE interface
LEVEL 1 is more unified interface is based on LEVEL 0.

2. LEVEL 1 INTERFACE DESCRIPTION

This interface include command 0xD1 and 0xD2 whitch are basic Vender Request commands.
0xD1: Direction is out (computer send command to camera)
          Length is 16 bytes
0xD2:Direction is IN (computer requrest camera to submit it's some status)
         Length is 64 bytes.

Their Index and Value in vender request are not used. So you can set to 0X0000.
Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:05:10 PM
CCC=0XA0
Camera initialize. After send this command the camera will enter into a definitized working status.

CCP1       Continuous streaming mode or Single frame mode    0=streaming    1=single
CCP2...3  Camera Binning in X direction (CCP2=MSB, CCP3=LSB)
CCP4...5  Camera Binning in Y direction   (CCP4=MSB, CCP5=LSB)


*1. Current version only support BIN11. Hardware BIN33 is under development . When use BIN11. CCP[2..3] can be set to 0x0001 and CCP[4..5] can be set to 0x0001.

*2. QHY165C support both live video streaming mode and single capture mode. When initialized to live video streaming mode , the camera will send the the continuous frames  4968*3378@16bit in maximum 10FPS. The default exposure time is 20ms. The video will start transfer immediately  once it is been sent . 

*3. If set to the single frame mode. After send this command, the camera will not start one frame. Till the 0XA6 start capture command is send.

Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:14:27 PM
CCC=0XA1   

set the camera readout speed. Different camera may have different readout speed setting to optimize the noise. Or to match the computer transfer speed.


CCP1  read out speed value.

when set to 0. Sensor working frequency is 50MHz. The maxium frame rate is 10FPS@FULL resolution
when set to 1. Sensor working frequency is 33.3MHz.
when set to 2. Sensor working frequency is 25MHz.

The camera will change the sensor frequency immediately. All the other parameter does no need to reset. The camera will re-calculate the current exposure time to guarantee the exposure time is almost the same with the exposure before set this.

When use the DDR+Live video mode. This should not been set to 0. Can be set to 1.
For any other mode, like DDR+Single frame, Non-DDR+Live video mode, this can be set to 0,1,2. 

Set to 0 can reduce the thermal noise and also the amplifier glow.
Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:23:20 PM
CCC=0XA2   
select the camera resolution or ROI

CCP1  select resolution mode . No use in QHY165C. Please set to 0x00 to it.
CCP2..3  ROI X size  (CCP2=MSB  CCP3=LSB)  can be set to zero for QHY165C
CCP4..5  ROI X start position                            can be set to zero for QHY165C
CCP6..7  ROI Y size   ( CCP6=MSB   CCP7=LSB)
CCP8..9  ROI Y position

*1. QHY165C can not do the X roi. It can only do Y ROI. You can set ROIX size and start position to zero.
*2. For QHY165C it can do Y ROI. You can define the ROI size and Y start position then camera will send the ROI image as the resolution of 4968*ROI Y size For example:

CCP[6..7]=2000
CCP[8..9]=0

Camera will send the image 4968*2000

The Y position range is 0 to 3378-ROI Y. So in this example, the Y position is 0 to 1378. If you set a value above 1378, Camera will ignore it and use the maximum value 1378

 
After set to a smaller ROI. The maximum frame can be increase. This is helpful to focus and also good for video recording. For example, it can be used for 1080p or 2160p video recording.

The camera will re-calculate the exposure to let the exposure time almost the same with the one before ROI changed.

The ROI function works both in single frame mode and live video mode.
Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:32:43 PM
CCC=0XA3
set exposure time

CCP1..4   32BIT exposure time,unit is micro second   CCP1=MSB  CCP4=LSB


The QHY165C exposure range is 0-4294967296 us. (0-4294sec)
Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:38:49 PM
CCC=0XA4
set camera gain

CCP1..2      Analog Gain R    range 0-4095
CCP3..4      Digital Gain R     range 1-255
CCP5..6      Analog Gain G    range 0-4095
CCP7..8      Digitial Gain G   no use
CCP9..10    Analog Gain B    range 0-4095
CCP11.12   Digital Gain B     no use

*1.QHY165C has RGB analog gain. Range (0 to 4095). But very high gain (for example, above 3900. May cause vertical noise).

*2.QHY165C has only one digital Gain. You can use digital Gain R to set it.  Digital Gain range is 1-255. When set to 1 the digital gain ratio is x1. 

*3.It is best not use digital Gain for DSO capture. Digital gain is helpless for improve the SNR. It only make the image looks brighter but it will lose the dynamic and cause the histogram may not continuous
Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:44:40 PM
CCC=0XA5
set USB bandwidth limit value

CCP1  value


Many of the cmos camera working in the cmos continuous video streaming. The CMOS sensor can not pause the output to wait the host. So that if there is no big buffer in the camera side, when host cpu is busy and can not read the data on time. The buffer in camera will be full and then the later coming data can not enter the buffer and it will be lost. In this condition you can increase this value to reduce the usb bandwidth.

This value will be add some null pixel read in each line. So the line period will increase and the average USB data bandwidth will be limited.

Warn: In some camera, it may reduce the performance, for example, it will increase the ampilfer glow that generated during readout period.



The QHY165C will re-calculate the exposure time after this command set. So the exposure time will be kept the same as before set. You do not need to set the exposure time again.
Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:50:38 PM
CCC=0XA6
Start or stop the capture

CCP1 0X00: start video streaming in video streaming mode or start one frame capture in single capture mode
          0x11: force stop the exposure and read the sensor (data will still transfer back to computer) .This function is not avalible in QHY165C. The when you set this command. the data will not come back. The V20170311 support this function. When send this function the QHY165C will return the image with the exposure time from start to current time.
          0x22: enter sleep mode(in sleep mode sensor will not work to save power, but the register value will be keep)
          0x44: wake up the sensor
          0x66: reset CMOS/CCD
          0XFF: stop streaming in video streaming mode or force stop exposure but not return any data in single frame mode.


*1. You can use CCP1=0X00 to start one single frame. After the exposure, the data will enter the DDR and you can read the status (0xD2 read) to get to know how many data has already been in DDR. We recommend you wait all the data come back (read the status till you find the data size in DDR is not changed anymore). Then read back the data according the data size.  Please read the details of the data readout working flowing instruments in later document.

*2. For 0X11 command. QHY165C support it. Please note when you send this command , the camera will return more than more frame into DDR memory. The first frame will be the one we need. And please note you must set the exposure time again in the next capture.
Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:55:43 PM
CCC=0XA7
set image bit depth

CCP1=0    8BIT
CCP1=1  16BIT


*1: You can set the bit depth of each pixel with this command. QHY165C has 8bit or 12bit output . For 12bit, it is packaged to 16bit. (MSB is aligned) .

*2. You can set this command at anytime after initial. But please send this command after initialize.  Because the initialize will set the camera to a fixed mode (for QHY165C it is fixed to 16bit).

*3. Please note for 16bit the data length that you need to read back is doubled. For example, one frame is 4968*3378. The data size will be 4968*2*3378.



Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 10:57:30 PM
CCC=0XA8
set camera offset

CCP1..2  OFFSET1 R  range 0-2047
CCP3..4  OFFSET1 G  no used in QHY165C
CCP5..6  OFFSET1 B  not used in QHY165C

CCP7..8      OFFSET2 R  not used in QHY165C
CCP9..10    OFFSET2 G  not used in QHY165C
CCP11..12  OFFSET2 B  not used in QHY165C

*1.QHY165C has only one offset. So you can set it with CCP[1..2]
Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 11:02:02 PM
CCC=0XA9
on camera DDR buffer or SDRAM buffer control

CCP1  0X00=BYPASS DDR
          0XFF=ENABLE DDR


*1. In Single frames we recommand you set this bit always to 0xFF to enabled DDR. DDR is very important to buffer the image during long exposure.  Also the camera will be stay in the DDR enabled statu after initialized to single frame mode so you can not to set this command anymore .


*2. In continous mode, when use ddr enabled mode, you must set the cmos frequency to 1 or 2 (33.3MHz or 25MHz). The data rate of cmos frequency 0 is too high for DDR memory so it will no image come out.

*3. In Single frame mode , the DDR is always enabled and it can accept the cmos frequency of 0,1,2

*4. Camera will clear the DDR each time when you call command 0XA6 to start a new capture in single capture mode





Title: Re: QHY165C Low Level (1) USB Procotol
Post by: QiuHY on February 26, 2017, 11:03:09 PM
To be continued .