Esempio n. 1
0
int qhy9_setColorWheel(int Pos)
{
	unsigned char REG[2];

	REG[0] = 0x5A;                   //  Identity code
	REG[1] = (unsigned char) Pos;    //0,1,2,3,4
   	return (qhy_cameraIO(qhy_core_getendp()->write, qhy_core_getreq()->wheel, REG,  sizeof(REG), 0, 0));
}
Esempio n. 2
0
int  qhy7_setregisters(qhy_exposure *expar) 
{
	int retval = 1;	
	int time, Vbin, Hbin, ShortExp, antiamp, PatchNumber;
	int top_skip = 0, bot_skip = 0;
	int top_skip_pix = 0, top_skip_null = 10;
	unsigned char time_H,time_M,time_L;

	expar->wtime = expar->time;
	bin = expar->bin;
	if(expar->time < SHORTEXP) 
	{  
		ShortExp = 1;
		time = expar->time;
	}
	else                   
	{
		ShortExp = 0; 
		time = expar->time - SHORTEXP;
	}
	//account for general 1% error on exp time for all QHY camera tested so far
	time = (int) (time - (time / 100));
	
	antiamp = 0;
	switch ( expar->amp ) 
	{
		case 0: 
			antiamp = 1;
			break;
		case 1: 
			antiamp = 0;
			break;
		case 2: if (time > 550) 
			antiamp = 1;
			break;
		default:
			printf( "Error: Registers NOT set (amp)!\n");
			return 2;
	}
	// It looks like libusb1.0 is very picky about "transfer_size" value.
	// Please have a look at the complete comment near the bulk_read
	// Please notice width@bin3 && bin4
	
	//printf("ix: %d, iy %d\n", img_w, img_h);
	switch ( bin ) 
	{
		case 1: 
			i_width = 2112; height = 2072; width = i_width; Vbin = bin; Hbin = bin; //P_Size = 2849 * 1024;
			break;
		case 2: 
			i_width = 1056; height = 1036; width = i_width; Vbin = bin; Hbin = bin; 
			break;
		case 3: 
			i_width = 2112; height =  691; Vbin = bin; Hbin = 1; width = i_width / 3;
			break;
		case 4: 
			i_width = 1056; height =  518; Vbin = bin; Hbin = 2; width = i_width / 2; 
			break;
		default:
			printf( "Error: Registers NOT set (bin)!\n");
			return 2;
	}
	// Check for ROI (if valid)
	if (expar->width > 0 && expar->width < (i_width / (bin/Hbin)))
	{
		width = expar->width; 
	}
	else
	{
		expar->width = width;
	}
	if (expar->height > 0 && expar->height < height)
	{
		top_skip_null = 25;
		top_skip = (height - expar->height);
		if (bin == 1)
		{
			top_skip = (int)(top_skip / 2);
		}
		bot_skip = height - top_skip - expar->height;
		height = expar->height;
	}
	else
	{
		expar->height = height;
	}
	//printf("x: %d, y %d, tops %d, bots %d fx %d\n", i_width, height, top_skip, bot_skip, width);

	totalsize = i_width * 2 * height;
	expar->totsize = totalsize;
	
	// Looks like the actual transfer size is a multiple of 1024 or 512 (Camera dependent. QHY7=1024, QHY9=512)
	// Either is the nearest (round) or is the floor value (Again camera dependent QHY6=512 round)
	transfer_size = 1024 * (int)(totalsize / 1024);
	expar->tsize = transfer_size;
	
	PatchNumber = qhy_getPatch(totalsize, 1024, 0);

	time_L=fmod(time,256);
	time_M=(time-time_L)/256;
	time_H=(time-time_L-time_M*256)/65536;


	REG[0]=(int)((expar->gain * 63) / 100);  	//Camera gain   range 0-63  
	
	REG[1]=expar->offset;			//Offset : range 0-255 default is 120
	
	REG[2]=time_H;  				//unit is ms       24bit
	REG[3]=time_M;
	REG[4]=time_L;
	
	REG[5]=Hbin;					// Horizonal BINNING    0 = 1= No bin
	REG[6]=Vbin;					// Vertical Binning     0 = 1= No bin
	
	REG[7]=qhy_MSB(i_width);			// The readout X  Unit is pixel 16Bit
	REG[8]=qhy_LSB(i_width);
	
	REG[9]= qhy_MSB(height);			// The readout Y  unit is line 16Bit
	REG[10]=qhy_LSB(height);
	
	REG[11]=qhy_MSB(top_skip);		// use for subframe    Skip lines on top 16Bit
	REG[12]=qhy_LSB(top_skip);
	
	REG[13]=qhy_MSB(bot_skip);		// use for subframe    Skip lines on Buttom 16Bit
	REG[14]=qhy_LSB(bot_skip);		// VerticalSize + SKIP_TOP +  SKIP_BOTTOM  should be the actual CCD Y size 
	
	REG[15]=0;					// LiveVideo no use for QHY7-8-9   16Bit set to 0
	REG[16]=0;

	REG[17]=qhy_MSB(PatchNumber);		// PatchNumber 16Bit
	REG[18]=qhy_LSB(PatchNumber);
	
	REG[19]=0;					// AnitInterlace no use for QHY8-9-11  16Bit set to 0
	REG[20]=0;
	
	REG[22]=0;					// MultiFieldBIN no use for QHY9  set to 0
	
	REG[29]=0x0000;				// ClockADJ no use for QHY9-11  16Bit set to 0
	REG[30]=0;
	
	REG[32]=antiamp;				// 1: anti-amp light mode 
	
	REG[33]=expar->speed;			// 0: low speed     1: high speed
	
	REG[35]=0; 					// TgateMode if set to 1 , the camera will exposure forever, till the ForceStop command coming
	REG[36]=ShortExp;				// ShortExposure no use for QHY9 set to 0
	REG[37]=0;					// VSUB no use for QHY8-9-11   set to 0
	REG[38]=0;					// Unknown reg.CLAMP
	
	REG[42]=0;					// TransferBIT no use for QHY8-9-11 set to 0
	
	REG[46]=top_skip_null;			// TopSkipNull unit is line.
	
	REG[47]=qhy_MSB(top_skip_pix);	// TopSkipPix no use for QHY9-11 16Bit set to 0 
	REG[48]=qhy_LSB(top_skip_pix);
	
	REG[51]=0;					// QHY9 0: programme control mechanical shutter automaticly   1: programme will not control shutter. 
	REG[52]=0;					// DownloadCloseTEC no use for QHY9   set to 0
	
	REG[53]=0;					// Unknown: (reg.WindowHeater&~0xf0)*16+(reg.MotorHeating&~0xf0)
	
	
	REG[58]=100;					// SDRAM_MAXSIZE no use for QHY8-9-11   set to 0
	REG[63]=0;					// Unknown reg.Trig
		  
	if (memcmp(REG, REGBCK, sizeof(REG)) || expar->edit)
	{
		// If different from the last sent values
		if ((retval = qhy_cameraIO(qhy_core_getendp()->write, qhy_core_getreq()->sendregs, REG, sizeof(REG), 0, 0)) == 1)
		{
			expar->edit = 0;
		}
		// Store last sent values
		memcpy(REGBCK , REG, sizeof(REG) );
	}
	return retval;
}