jarjonam 5 éve
szülő
commit
8efa9a09c8
2 módosított fájl, 20 hozzáadás és 20 törlés
  1. 11 11
      microcontroller/Demo.C
  2. 9 9
      pi/ADUCv2p1.py

+ 11 - 11
microcontroller/Demo.C

@@ -55,7 +55,7 @@ unsigned short remote_trigg; // Set to 0 so that the microcontroller uses the tr
 // set it to 1 so that it continuously triggers
 unsigned short auto_set_pga; // Whether the microcontroller should automatically select the 
 // best offset and gain when in learn mode
-unsigned short coarse_fine_ratio; // Ratio of sensitivities of the fine to coarse voltage 
+float coarse_fine_ratio; // Ratio of sensitivities of the fine to coarse voltage 
 // outputs of the board
 unsigned short mode; // read_only; 0 when in learn; 1 when in lock
 unsigned short out_of_lock; // 1 when the board is out of lock
@@ -201,28 +201,28 @@ void lock_StabPulse_i2c(void) {
   N = 10;
   Vin = 0;
   Vin_gnd = 0;
-  start = 100;
-  stop = 200;
-  start_gnd = 0;
-  stop_gnd = 100;
+  start = 25;
+  stop = 80;
+  start_gnd = 110;
+  stop_gnd = 135;
   wf_len = 200;
   Vset = 0;
-  Vlearn = 2000;
+  Vlearn = 3200;
   step = 50;
-  step_max = 100;
-  Gain = 1;
+  step_max = 300;
+  Gain = 10;
 
   transf = 0;
   trigg_cnt = 0;
   wf_cnt = 0;
   v_cnt = 0;
   cnt_N = 0;
-  enab_gnd = 0;
+  enab_gnd = 1;
   remote_trigg = 0;
-  auto_set_pga = 0;
+  auto_set_pga = 1;
   mode = 0; //read only
   out_of_lock = 0;
-  coarse_fine_ratio = 20; //As per circuit design; can be tuned by Pi
+  coarse_fine_ratio = 20.0; //As per circuit design; can be tuned by Pi
   valid_data = 0;
 
   // SPI configuration

+ 9 - 9
pi/ADUCv2p1.py

@@ -362,14 +362,11 @@ class ADUCv2p1:
     def set_Gain(self,Gain):
         tmp = (Gain)
         buff = pack("<f",Gain)
-        #print buff
         dat = unpack("4B",buff)
-        #print dat
         return self.bus_pi.write_i2c_block_data(self._addr,134,[dat[0],dat[1],dat[2],dat[3]])
 
     def get_Gain(self):
         block = self.bus_pi.read_i2c_block_data(self._addr,134,4)
-        #print block
         buff = pack("4B",*block)
         dat = unpack("<f",buff)   
         dat=np.float32(dat)
@@ -395,14 +392,17 @@ class ADUCv2p1:
         return dat[0]
 
     # Set the relative sensitivities of the coarse and fine output
-    def set_coarse_fine_ratio(self,status):
-        return self.bus_pi.write_byte_data(self._addr,140,status)
+    def set_coarse_fine_ratio(self,ratio):
+        tmp = (Gain)
+        buff = pack("<f",ratio)
+        dat = unpack("4B",buff)
+        return self.bus_pi.write_i2c_block_data(self._addr,140,[dat[0],dat[1],dat[2],dat[3]])
 
     def get_coarse_fine_ratio(self):
-        block = self.bus_pi.read_i2c_block_data(self._addr,140,2)
-        buff = pack("2B",*block)
-        dat = unpack("<H",buff)   
-        dat=np.uint16(dat)
+        block = self.bus_pi.read_i2c_block_data(self._addr,140,4)
+        buff = pack("4B",*block)
+        dat = unpack("<f",buff)   
+        dat=np.float32(dat)
         return dat[0]
 
     # Read whether we are out of lock