Milo Sobral commited on
Commit
e7c3f79
·
1 Parent(s): c20b8b2

Modified code to for leadoff

Browse files
Files changed (1) hide show
  1. portiloop/capture.py +33 -4
portiloop/capture.py CHANGED
@@ -82,6 +82,32 @@ FRONTEND_CONFIG = [
82
  0x20, # Enable SRB1
83
  ]
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  EDF_PATH = Path.home() / 'workspace' / 'edf_recording'
86
 
87
 
@@ -116,16 +142,15 @@ def mod_config(config, datarate, channel_modes):
116
  config[1] = new_cf1
117
 
118
  # bias:
119
-
120
  assert len(channel_modes) == 7
121
  config[13] = 0x00 # clear BIAS_SENSP
122
  config[14] = 0x00 # clear BIAS_SENSN
123
  for chan_i, chan_mode in enumerate(channel_modes):
124
- n = 5 + chan_i
125
  mod = config[n] & 0x78 # clear PDn and MUX[2:0]
126
  if chan_mode == 'simple':
127
  # If channel is activated, we send the channel's output to the BIAS mechanism
128
- bit_i = 1 << chan_i
129
  config[13] = config[13] | bit_i
130
  config[14] = config[14] | bit_i
131
  elif chan_mode == 'disabled':
@@ -1183,7 +1208,11 @@ class Capture:
1183
  try:
1184
  frontend.write_regs(0x00, FRONTEND_CONFIG)
1185
  frontend.start()
1186
- new_config = frontend.read_regs(0x00, len(FRONTEND_CONFIG))
 
 
 
 
1187
  leadoff_p = new_config[18]
1188
  leadoff_n = new_config[19]
1189
 
 
82
  0x20, # Enable SRB1
83
  ]
84
 
85
+
86
+ LEADOFF_CONFIG = [
87
+ 0x3E, # ID (RO)
88
+ 0x95, # CONFIG1 [95] [1, DAISY_EN(bar), CLK_EN, 1, 0, DR[2:0]] : Datarate = 500 SPS
89
+ 0xC0, # CONFIG2 [C0] [1, 1, 0, INT_CAL, 0, CAL_AMP0, CAL_FREQ[1:0]]
90
+ 0xFC, # CONFIG3 [E0] [PD_REFBUF(bar), 1, 1, BIAS_MEAS, BIASREF_INT, PD_BIAS(bar), BIAS_LOFF_SENS, BIAS_STAT] : Power-down reference buffer, no bias
91
+ 0x00, # No lead-off
92
+ 0x60, # CH1SET [60] [PD1, GAIN1[2:0], SRB2, MUX1[2:0]] set to measure BIAS signal
93
+ 0x60, # CH2SET
94
+ 0x60, # CH3SET
95
+ 0x60, # CH4SET
96
+ 0x60, # CH5SET
97
+ 0x60, # CH6SET
98
+ 0x60, # CH7SET
99
+ 0x60, # CH8SET
100
+ 0x00, # BIAS_SENSP 00
101
+ 0x00, # BIAS_SENSN 00
102
+ 0xFF, # LOFF_SENSP Lead-off on all positive pins?
103
+ 0xFF, # LOFF_SENSN Lead-off on all negative pins?
104
+ 0x00, # Normal lead-off
105
+ 0x00, # Lead-off positive status (RO)
106
+ 0x00, # Lead-off negative status (RO)
107
+ 0x00, # All GPIOs as output ?
108
+ 0x20, # Enable SRB1
109
+ ]
110
+
111
  EDF_PATH = Path.home() / 'workspace' / 'edf_recording'
112
 
113
 
 
142
  config[1] = new_cf1
143
 
144
  # bias:
 
145
  assert len(channel_modes) == 7
146
  config[13] = 0x00 # clear BIAS_SENSP
147
  config[14] = 0x00 # clear BIAS_SENSN
148
  for chan_i, chan_mode in enumerate(channel_modes):
149
+ n = 6 + chan_i
150
  mod = config[n] & 0x78 # clear PDn and MUX[2:0]
151
  if chan_mode == 'simple':
152
  # If channel is activated, we send the channel's output to the BIAS mechanism
153
+ bit_i = 1 << chan_i + 1
154
  config[13] = config[13] | bit_i
155
  config[14] = config[14] | bit_i
156
  elif chan_mode == 'disabled':
 
1208
  try:
1209
  frontend.write_regs(0x00, FRONTEND_CONFIG)
1210
  frontend.start()
1211
+ start_time = time.time()
1212
+ current_time = time.time()
1213
+ while current_time - start_time < 2:
1214
+ current_time = time.time()
1215
+ new_config = frontend.read_regs(0x00, len(LEADOFF_CONFIG))
1216
  leadoff_p = new_config[18]
1217
  leadoff_n = new_config[19]
1218