Index: hvcontrol/src/HVCalib.cc
===================================================================
--- hvcontrol/src/HVCalib.cc	(revision 40)
+++ hvcontrol/src/HVCalib.cc	(revision 46)
@@ -99,10 +99,10 @@
   }
 
-  //  for(int i=0; i<hvConfig->NumHVBoards; i++){
-    for(int i=0; i<1; i++){
-      //  for(int j=0;j<NCHAIN;j++){
-      for(int j=0;j<1;j++){
-	//      for(int k=0;k<NCHANNEL;k++){
-      for(int k=0;k<1;k++){
+  for(int i=0; i<hvConfig->NumHVBoards; i++){
+    //  for(int i=0; i<1; i++){
+    for(int j=0;j<NCHAIN;j++){
+      //  for(int j=0;j<1;j++){
+      for(int k=0;k<NCHANNEL;k++){
+	//for(int k=0;k<1;k++){
 	ihvOld = 0;
 	first = true;
Index: hvcontrol/src/HVConfig.cc
===================================================================
--- hvcontrol/src/HVConfig.cc	(revision 40)
+++ hvcontrol/src/HVConfig.cc	(revision 46)
@@ -21,4 +21,6 @@
   fUSBDevice = new char*[MAX_NUM_HVBOARDS];
   fCCClient  = new char[FILENAME_MAX_SIZE];
+
+  fPixMapTable = new char[FILENAME_MAX_SIZE];
     
   for (int i=0; i<MAX_NUM_HVBOARDS; i++) {
@@ -56,4 +58,5 @@
 
   delete [] fLogPath;
+  delete [] fPixMapTable;
 
   for (int i=0; i<MAX_NUM_HVBOARDS; i++)
@@ -78,5 +81,7 @@
   }
  
-  ReadCard("LogPath",fLogPath,'s',f);
+  ReadCard("LogPath",    fLogPath,'s',f);
+
+  ReadCard("PixMapTable",fPixMapTable,'s',f);
 
   for (int i=0;i<MAX_NUM_HVBOARDS;i++) {
@@ -118,4 +123,5 @@
   fprintf(fptr," HV control configuration (%s):\n\n", FileName);
   fprintf(fptr," Log path:          %s\n\n", fLogPath);
+  fprintf(fptr," Pixel map table:   %s\n\n", fPixMapTable);
   fprintf(fptr," %.2d USB devices:\n\n", NumHVBoards);
   
@@ -170,4 +176,5 @@
 
   fprintf(f,"LogPath            %s\n\n",   fLogPath);
+  fprintf(f,"PixMapTable        %s\n\n",   fPixMapTable);
 
   fprintf(f,"TimeOut            %.2f s   # Timeout to return from read (%.2f,...%.2f) s\n\n",fTimeOut,MIN_TIMEOUT,MAX_TIMEOUT);
Index: hvcontrol/src/HVConfig.h
===================================================================
--- hvcontrol/src/HVConfig.h	(revision 40)
+++ hvcontrol/src/HVConfig.h	(revision 46)
@@ -33,4 +33,6 @@
   char** fUSBDevice;
 
+  char*  fPixMapTable;
+ 
   float  fTimeOut;
   float  fStatusRefreshRate;
Index: hvcontrol/src/ProcessIO.cc
===================================================================
--- hvcontrol/src/ProcessIO.cc	(revision 40)
+++ hvcontrol/src/ProcessIO.cc	(revision 46)
@@ -26,5 +26,6 @@
   hv      = new HV(config->fUSBDevice,config->USBDeviceNumber,stdout);
  
-  pm = new PixelMap("../fact_repos.svn/config/PixelMap.txt");
+  pm = new PixelMap(config->fPixMapTable);
+  printf("PixMapTable = %s. \n",config->fPixMapTable);
 
   // Initialize status structure (HVStatus.cc/h)
@@ -284,7 +285,7 @@
 
     int errors = 0;
-    unsigned int hvoltage = 0;
+    unsigned int hvoltage = 0, hvAll = 0;
     float hvoltageV = 0.0;
-    int channel = 0;
+    int channel = 0, hvdiff = 0;
     bool allchannels = FALSE;
 
@@ -352,53 +353,71 @@
 	      status->HVV[i][j][channel]=hvoltageV;
 	      hvoltage = calib->HVToDAC(hvoltageV,i,j,channel);
-	      printf("HV = %f, dac hv = %d .\n",hvoltageV,hvoltage);
 	    }
-	    if ((hv->GetHVBoard(i))->SetHV(stdout,j,channel,hvoltage,rbuf,status->Verbose)==1){
-	      status->HV[i][j][channel]=hvoltage;
-	      UpdateStatus(i,rbuf);
-	      
-	      sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(i)->GetBoardNumber(),j,channel));
-	      DoPrompt(str);
-	      if (status->Verbose) {
-		sPrintStatus(status,str,i);
-		DoPrompt(str);
+	    hvdiff = hvoltage - status->HV[i][j][channel];
+	    for (int k=0;k<=abs((int)(hvdiff/config->fHVMaxDiff));k++){
+	      if (k<abs((int)(hvdiff/config->fHVMaxDiff))){
+		hvoltage=(unsigned int)(status->HV[i][j][channel] + config->fHVMaxDiff*hvdiff/abs(hvdiff));
 	      }
-	      sPrintStatus(status,str,i); // Print status only to socket 
-	    }
-	    else {
-	      sprintf(str,"board %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());
-	      DoPrompt(str);
-	      errors++;
-	    }
-	  }
-
-	  else {
-	    sprintf(str,"updating board %d chain %d\n",hv->GetHVBoard(i)->GetBoardNumber(),j);
-	    DoPrompt(str);
-	    
-	    for (int k=0;k<MAX_NUM_CHANNELS;k++) {
- // Convert from HV to DAC values
-	      if (!(config->IsDAC)){
-		status->HVV[i][j][channel]=hvoltageV;
-		hvoltage = calib->HVToDAC(hvoltageV,i,j,k);
+	      if (k==(abs((int)(hvdiff/config->fHVMaxDiff)))){
+		hvoltage=(unsigned int)(status->HV[i][j][channel] + (hvdiff%(int)config->fHVMaxDiff));
 	      }
-	      if ((hv->GetHVBoard(i))->SetHV(stdout,j,k,hvoltage,rbuf,status->Verbose)==1) {
-		status->HV[i][j][k]=hvoltage;
+	     
+	      if ((hv->GetHVBoard(i))->SetHV(stdout,j,channel,hvoltage,rbuf,status->Verbose)==1){
+		status->HV[i][j][channel]=hvoltage;
 		UpdateStatus(i,rbuf);
 		
+		sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(i)->GetBoardNumber(),j,channel));
+		//		DoPrompt(str);
 		if (status->Verbose) {
-		  sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(i)->GetBoardNumber(),j,channel));
-		  //sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X\n",hv->GetHVBoard(i)->GetBoardNumber(),j,k,hvoltage,hvoltage);
-		  DoPrompt(str);
 		  sPrintStatus(status,str,i);
 		  DoPrompt(str);
 		}
 		sPrintStatus(status,str,i); // Print status only to socket 
-		
 	      }
 	      else {
-		sprintf(str,"board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());
+		sprintf(str,"board %d error: could not set hv - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());
 		DoPrompt(str);
 		errors++;
+	      }
+	    }
+	  }
+	  else {
+	    sprintf(str,"updating board %d chain %d\n",hv->GetHVBoard(i)->GetBoardNumber(),j);
+	    DoPrompt(str);
+	  
+	    for (int k=0;k<MAX_NUM_CHANNELS;k++) {
+ // Convert from HV to DAC values
+	      if (!(config->IsDAC)){
+		status->HVV[i][j][k]=hvoltageV;
+		hvoltage = calib->HVToDAC(hvoltageV,i,j,k);
+	      }
+	      hvAll = hvoltage;
+	      hvdiff = hvAll - status->HV[i][j][k];
+	      for (int l=0;l<=abs((int)(hvdiff/config->fHVMaxDiff));l++){
+		if (l<abs((int)(hvdiff/config->fHVMaxDiff))){
+		  hvoltage=(unsigned int)(status->HV[i][j][k] + config->fHVMaxDiff*hvdiff/abs(hvdiff));
+		}
+		if (l==(abs((int)(hvdiff/config->fHVMaxDiff)))){
+		  hvoltage=(unsigned int)(status->HV[i][j][k] + (hvdiff%(int)config->fHVMaxDiff));
+		}
+		if ((hv->GetHVBoard(i))->SetHV(stdout,j,k,hvoltage,rbuf,status->Verbose)==1) {
+		  status->HV[i][j][k]=hvoltage;
+		  UpdateStatus(i,rbuf);
+		  
+		  if (status->Verbose) {
+		    sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X | %f V\n",hv->GetHVBoard(i)->GetBoardNumber(),j,channel,hvoltage,hvoltage,calib->DACToHV(hvoltage,hv->GetHVBoard(i)->GetBoardNumber(),j,channel));
+		    //sprintf(str,"board %d: high voltage of chain %d channel %d set to %d | 0X%.4X\n",hv->GetHVBoard(i)->GetBoardNumber(),j,k,hvoltage,hvoltage);
+		    //   DoPrompt(str);
+		    sPrintStatus(status,str,i);
+		    DoPrompt(str);
+		  }
+		  sPrintStatus(status,str,i); // Print status only to socket 
+		}
+		
+		else {
+		  sprintf(str,"board %d error: could not set HV - check timeout and try again\n",hv->GetHVBoard(i)->GetBoardNumber());
+		  DoPrompt(str);
+		  errors++;
+		}
 	      }
 	    }
