Browse Source

Changed Filling pattern for consitency check
Increased safety margin on sleep time for readout
Now dumping a few lines of data for inconstitent files

Timo Dritschler 9 years ago
parent
commit
af8f6478ec
2 changed files with 10 additions and 6 deletions
  1. 6 5
      heb/board.py
  2. 4 1
      heb/io.py

+ 6 - 5
heb/board.py

@@ -350,9 +350,9 @@ def stop_dma(dma='dma0r'):
 
 def data_reset():
     log.info('Data reset')
-    write_pci('000003f1', hex_mask='1')
+    write_pci('000003f5', hex_mask='7')
     time.sleep(0.05)
-    write_pci('000003f0', hex_mask='1')
+    write_pci('000003f0', hex_mask='7')
     time.sleep(0.05)
 
 
@@ -379,6 +379,7 @@ def start_pilot_bunch_emulator():
 def start_acquisition():
     log.info('Start acquisition')
     write_pci('1', '4', hex_mask='1')
+    time.sleep(0.05)
     write_pci('00bf0', hex_mask='CF0')
 
 
@@ -409,13 +410,13 @@ def run_status(script_path):
 
 def acquire_data(filename, duration=1.0, simulate=False):
     #start_dma()  #Dont start dma when it is already active! (Causes data corruption in the driver)
-    #data_reset() #No Longer needed
 
     if simulate:
         start_pilot_bunch_emulator()
 
     start_acquisition()
-    time.sleep(duration)
+    #time.sleep(duraition) #calculate the time instead
+    wait_for_revolutions()
     stop_acquisition()
     enable_transfer()
     write_data(filename)
@@ -426,4 +427,4 @@ def wait_for_revolutions():
     n = read_pci(1, '0x9020', decimal=True)[0]  # Get the ammount of orbits to observe
     spin_time_ns = 368 * n
     wait_time_s = spin_time_ns / 1000.0 / 1000.0 / 1000.0   # Milli, Micro, Nano
-    time.sleep(wait_time_s * 1.2)  # 20% Safety margin
+    time.sleep(wait_time_s * 1.4)  # 40% Safety margin

+ 4 - 1
heb/io.py

@@ -11,8 +11,11 @@ def is_data_consistent(dataset):
     expected = np.tile(np.arange(0, BUNCHES_PER_TURN), bunch_numbers.shape[0] / BUNCHES_PER_TURN)
     wrong_indices = np.argwhere(bunch_numbers != expected)
     if wrong_indices.shape[0] > 0:
+        first_error =  bunch_numbers.shape[0] - wrong_indices.shape[0]
+        logging.info('Data inconsistent at offset %i'%first_error)
+        np.savetxt('wrongdump', dataset.array[first_error - 3: first_error + 3]) 
         filling = bunch_numbers[wrong_indices[0][0]:]
-        expected_filling = np.tile([0xdead], filling.shape[0])
+        expected_filling = np.tile([222, 223], filling.shape[0] / 2)
         wrong_filling_indices = np.argwhere(filling != expected_filling)
         if wrong_filling_indices.shape[0] > 2:  # Some times filling does not start immediately... Why? I have NO IDEA!
             return False