QHYCCD

QHY163 Low Level (1) USB Protocol

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
QHY163 Low Level (1) USB Protocol
« on: March 10, 2017, 10:45:45 PM »
Level (1) Protocol Instruction

QHYCCD Low level 1 usb protocol has two basic vend request. 

VendRequest 0xd1
VendRequest 0xd2

0xd1 direction is OUT.  Host computer will send 16bytes data in this vendrequest to the camera
0xd2 direction is IN. Host computer will read 64bytes data of camera current status information in this vendrequest from camera

There is no use for index and value of this two vend request, set them to 0x0000  0x0000



we may add other vendrequest command other than this two in future in order to achieve more complex command




Version History

20170312.  Fixed the camera series number, sensor color type,pwm value in vendrequest 0XD2 . Add CCC=0xAF command to set the temperature control

20170313.  Solved the USB2.0 support for video streaming mode. In USB2.0 it require slow down the speed 10times than the USB3.0 to meet the bandwidth requirement.

20170319  Add the CFW control  (0xAA command and add the 8 CFW buffer in 0xD2 command)

20170320  Add the Guide port control (0xAB command) . The QHY163 Low Level Protocol is almost done.
« Last Edit: March 20, 2017, 04:08:39 AM by QiuHY »
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #1 on: March 10, 2017, 10:46:14 PM »
3. VendRequest 0XD1 Instruction

0xD1 will transfer 16byte data from computer to camera. In these 16byte data, the first byte (byte0) is the Camera Control Command (CCC).  The following data is called Camera Control Parameter (CCP)


Data Structure is
Byte0                        Camera Control Command(CCC)
Byte1......Byte15        Camera Control Parameter(CCP1...15)
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #2 on: March 10, 2017, 10:54:58 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)     in current version it only support 1x1
CCP4...5  Camera Binning in Y direction   (CCP4=MSB, CCP5=LSB)     in current version it only support 1x1


*1. After entering the streaming mode, QHY163 will output the 4720*3534 8bit image @ 22.5FPS. If the speed is too high you can increase the USB traffic value to reduce the average bandwidth

*2. After enter the single frame mode. QHY163 will output the 4720*3534 16bit image and automaticly enabled the DDR buffer. There will be no data can be read till you send the CCC=0XA6 command to start one frame capture

*3. You can use VendReq 0xD2 command to read to know how many data is in DDR memeory. The unit is 2KByte

Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #3 on: March 10, 2017, 10:56:51 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.  QHY163 does not allow the readout speed to set here. The readout speed will be handle in camera automatically.
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #4 on: March 10, 2017, 11:02:43 PM »
CCC=0XA2   
select the camera resolution or ROI

CCP1  select resolution mode.                              no used in QHY163  set it to zero or anything
CCP2..3  ROI X size  (CCP2=MSB  CCP3=LSB)     no used in QHY163  set it to zero or anything
CCP4..5  ROI X start position                               no used in QHY163  set it to zero or anything
CCP6..7  ROI Y size   ( CCP6=MSB   CCP7=LSB)    You can set this value 1-3600  Default is 3534
CCP8..9  ROI Y position                                       The vertical ROI start position. The range is 0 to (4096-Ysize)




*1. QHY163 support the vertical ROI. It will output the image of 4720* ROI Y size when you se the ROI Y size. For example, if you set ROI Y size =2000. The output will be 4720*2000

*2. Camera will automatically limit the ROI Y start position when you exceed the max range.

*3. Since there is a fixed 12 lines reference area(overscan or OB area) on top of the image. So the ROI Y can be start from 13.  For 13lines, the last one line is the line which has response to the light.  In this condition(4720*13) the frame rate is about 1300FPS

*4. The vertical ROI is supported in both single frame mode and video streaming mode.


« Last Edit: March 11, 2017, 11:40:37 PM by QiuHY »
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #5 on: March 10, 2017, 11:20:31 PM »
CCC=0XA3
set exposure time

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

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #6 on: March 10, 2017, 11:28:09 PM »
CCC=0XA4
set camera gain

CCP1..2      Analog Gain R
CCP3..4      Digital Gain R
CCP5..6      Analog Gain G
CCP7..8      Digitial Gain G
CCP9..10    Analog Gain B
CCP11.12   Digital Gain B

*1.QHY163 has one global analog gain. So you can only set Analog Gain R range 0-58

*2.QHY163 has digital Gain R,G,B. The range is 1-255. The default value is 64. The formula is

        digital gain =   (digital gain set value) / 64           

For example when digital gain set value =64. The digital gain=1x. when digital gain set value =128, the digital gain is 2x

Normally the digital gain is used to do white balance. For DSO capture we recommand the digital gain = 1x  (use default value 64)
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #7 on: March 10, 2017, 11:31:29 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.

*1.For USB3.0 we the USB traffic value range is 0-60 (if a value exceed this range , the camera will limit it to the range 0-60)

*2.In single capture mode , we recommand the USB traffic is fixed to set zero to minimum the  amplifer light. Since the data will store in DDR memory then readout  so it should be no problem to set this value to zero.
« Last Edit: March 10, 2017, 11:33:39 PM by QiuHY »
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #8 on: March 10, 2017, 11:36:47 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)  QHY163 has no this unction
          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    no use in QHY163
          0XFF: stop streaming in video streaming mode or force stop exposure but not return any data in single frame mode.


*1. Not all camera will not send back the data when use CCP1=0XFF.  QHY163 has no this function.
Modify message
« Last Edit: March 10, 2017, 11:41:06 PM by QiuHY »
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #9 on: March 10, 2017, 11:37:11 PM »
CCC=0XA7
set image bit depth

CCP1=0    8BIT
CCP1=1  16BIT


*1: if the sensor is 10bit/12bit/14bit. When set to 16bit, it is MSB aligned.
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #10 on: March 10, 2017, 11:37:27 PM »
CCC=0XA8
set camera offset

CCP1..2  OFFSET1 R   range 0-511
CCP3..4  OFFSET1 G   no use in QHY163
CCP5..6  OFFSET1 B    no use in QHY163

CCP7..8      OFFSET2 R  no use in QHY163
CCP9..10    OFFSET2 G   no use in QHY163
CCP11..12  OFFSET2 B   no use in QHY163

Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #11 on: March 10, 2017, 11:38:52 PM »
CCC=0XA9
on camera DDR buffer or SDRAM buffer control

CCP1  0X00=BYPASS DDR
          0XFF=ENABLE DDR
Modify message
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #12 on: March 11, 2017, 11:15:36 PM »
CCC=0XAA
Send CFW Control Command via 4PIN QHYCFW socket

The 4PIN QHYCFW socket includes an industry standard RS232 communication port (RXD,TXD, +-10V level) and a +12V powersupply for the QHYCFW. You can connect the QHYCFW1 and QHYCFW2 with the 4PIN TO 6PIN cable.

The QHYCFW control is via RS232 communication protocol. Please refer the http://www.qhyccd.com/ManualCFW2S4.1.html  for QHYCFW2 control.

For QHYCFW1 control. The command is still the ASCII '0','1','2'.......'A','B','C','D','E','F' for the 16 positions. But the return value is ASCII '-' to indicate the color wheel arrives the target position.

CCP1                RS232 command length
CPP2..CCP15     RS232 command


For example, Go to the Position 3  ( The command should be '2' because all position is from zero)

CCP1=1
CCP2=32    (32 is the ASCII '2') 


The eight bytes CFW buffer will be clear to all zero.   After the color wheel run to target, the first byte will become 32(ASCII '2').

For example, send "VRS" command to the QHYCFW2 to get the version

CCP1=3
CCP2='V'
CCP3='R'
CCP4='S'


The version will be return via the eight byte CFW buffer in 0XD2

Code: [Select]
void CCC_AA(unsigned char length,char *buf){

unsigned char data[16];
data[0]=0xaa;
data[1]=length;
for(int i=0;i<length;i++){
  data[2+i]=buf[i];
}

QHYCCDVendRequestWrite(g_hCam,0xd1,0x00,0x00,16,data);
}



After the command sent to the QHYCFW. QHYCFW will response and send back some information back the the camera. In the 0XD2 command there is 8bytes buffer to store it. You can use 0xD2 command to get to know these information.

Please note each time after you send the command to QHYCFW, The eight bytes buffer will be clear to all zero at first ,then after the command been executed , it will be fill to the data of results.
« Last Edit: March 19, 2017, 03:13:24 AM by QiuHY »
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #13 on: March 11, 2017, 11:15:53 PM »
CCC=0xab
Qiu Hongyun

QiuHY

  • *****
  • 5000
    • View Profile
    • Email
Re: QHY163 Low Level (1) USB Protocol
« Reply #14 on: March 11, 2017, 11:16:08 PM »
CCC=0xac
Qiu Hongyun