More pretty graphs, and initial correction calculation
This commit is contained in:
parent
6936655d45
commit
ca6a4353cf
5 changed files with 273 additions and 86 deletions
File diff suppressed because one or more lines are too long
|
|
@ -77,20 +77,20 @@ uint32_t sys_time_seconds = 0;
|
|||
*/
|
||||
static uint16_t timer_period_lookup[NBITS] = {
|
||||
/* LSB here */
|
||||
A - C + (B<< 0),
|
||||
A - C + (B<< 1),
|
||||
A - C + (B<< 2),
|
||||
A - C + (B<< 3),
|
||||
A - C + (B<< 4),
|
||||
A - C + (B<< 5),
|
||||
A - C + (B<< 6),
|
||||
A - C + (B<< 7),
|
||||
A - C + (B<< 8),
|
||||
A - C + (B<< 9),
|
||||
A - C + (B<<10),
|
||||
A - C + (B<<11),
|
||||
A - C + (B<<12),
|
||||
A - C + (B<<13),
|
||||
A + (B<< 0) - C,
|
||||
A + (B<< 1) - C,
|
||||
A + (B<< 2) - C,
|
||||
A + (B<< 3) - C,
|
||||
A + (B<< 4) - C,
|
||||
A + (B<< 5) - C,
|
||||
A + (B<< 6) - C,
|
||||
A + (B<< 7) - C,
|
||||
A + (B<< 8) - C,
|
||||
A + (B<< 9) - C,
|
||||
A + (B<<10) - C,
|
||||
A + (B<<11) - C,
|
||||
A + (B<<12) - C,
|
||||
A + (B<<13) - C,
|
||||
/* MSB here */
|
||||
};
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ int main(void) {
|
|||
/* Configure TIM1 for display strobe generation */
|
||||
TIM1->CR1 = TIM_CR1_ARPE;
|
||||
|
||||
TIM1->PSC = 1; /* Prescale by 2, resulting in a 16MHz timer frequency and 62.5ns timer step size. */
|
||||
TIM1->PSC = 1; /* Prescale by 2, resulting in a 15MHz timer frequency and 66.7ns timer step size. */
|
||||
/* CH2 - clear/!MR, CH3 - strobe/STCP */
|
||||
TIM1->CCMR2 = (6<<TIM_CCMR2_OC3M_Pos) | TIM_CCMR2_OC3PE | (6<<TIM_CCMR2_OC4M_Pos);
|
||||
TIM1->CCER |= TIM_CCER_CC3E | TIM_CCER_CC3NE | TIM_CCER_CC3P | TIM_CCER_CC3NP | TIM_CCER_CC4E;
|
||||
|
|
|
|||
|
|
@ -11,25 +11,17 @@ if __name__ == '__main__':
|
|||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('channels', type=str, help='olsndot channels to test, format: 0-3,5,7,8-10')
|
||||
parser.add_argument('run_name', nargs='?', default=None)
|
||||
parser.add_argument('run_name', nargs='?', default='auto')
|
||||
parser.add_argument('olsndot_port', nargs='?', default='/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0')
|
||||
parser.add_argument('buspirate_port', nargs='?', default='/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AD01W1RF-if00-port0')
|
||||
parser.add_argument('-c', '--channels', nargs='?', default='auto', help='olsndot channels to test, format: 0-3,5,7,8-10')
|
||||
parser.add_argument('-d', '--database', default='results.sqlite3', help='sqlite3 database file to store results in')
|
||||
parser.add_argument('-m', '--mac', type=int, default=0xDEBE10BB, help='olsndot MAC address')
|
||||
parser.add_argument('-w', '--wait', type=float, default=0.1, help='time to wait between samples in seconds')
|
||||
parser.add_argument('-o', '--oversample', type=int, default=16, help='oversampling ratio')
|
||||
parser.add_argument('-b', '--bits', type=int, default=None, help='number of bits to sample')
|
||||
args = parser.parse_args()
|
||||
|
||||
def parse_channels(channels):
|
||||
for spec in channels.split(','):
|
||||
if str.isnumeric(spec):
|
||||
yield int(spec)
|
||||
else:
|
||||
low, high = spec.split('-')
|
||||
yield from range(int(low), int(high)+1)
|
||||
channels = list(parse_channels(args.channels))
|
||||
|
||||
db = sqlite3.connect(args.database)
|
||||
db.execute("""
|
||||
CREATE TABLE IF NOT EXISTS runs (
|
||||
|
|
@ -55,18 +47,43 @@ if __name__ == '__main__':
|
|||
|
||||
uut = Olsndot(args.mac)
|
||||
d = Driver(args.olsndot_port, devices=[uut])
|
||||
uut.send_framebuf([0]*uut.nchannels)
|
||||
print('Connected to uut:', uut)
|
||||
|
||||
run_name = args.run_name
|
||||
if args.run_name is None:
|
||||
names = [ n[4:] for n, in db.execute('SELECT name FROM runs WHERE name LIKE "test%"').fetchall() ]
|
||||
run_name = 'test{}'.format(1+max(int(n) if str.isnumeric(n) else 0 for n in names))
|
||||
if not str.isnumeric(args.run_name[-1]):
|
||||
names = [ n[len(run_name):] for n, in db.execute(
|
||||
'SELECT name FROM runs WHERE name LIKE ?||"%"', (run_name,)).fetchall() ]
|
||||
names.append('0') # in case we get no results
|
||||
run_name += str(1+max(int(n) if str.isnumeric(n) else 0 for n in names))
|
||||
with db:
|
||||
cur = db.cursor()
|
||||
cur.execute('INSERT INTO runs(name, uut_mac, timestamp) VALUES (?, ?, ?)',
|
||||
(run_name, args.mac, time.time()))
|
||||
run_id = cur.lastrowid
|
||||
|
||||
nbits = args.bits if args.bits is not None else uut.nbits
|
||||
|
||||
def parse_channels(channels):
|
||||
for spec in channels.split(','):
|
||||
if str.isnumeric(spec):
|
||||
yield int(spec)
|
||||
else:
|
||||
low, high = spec.split('-')
|
||||
yield from range(int(low), int(high)+1)
|
||||
if args.channels == 'auto':
|
||||
for i in range(uut.nchannels):
|
||||
fb = [0]*uut.nchannels
|
||||
fb[i] = 0xffff;
|
||||
uut.send_framebuf(fb)
|
||||
time.sleep(0.2)
|
||||
if bp.adc_value > 0.5:
|
||||
break;
|
||||
else:
|
||||
raise ValueError('Cannot find active channel')
|
||||
channels = [i]
|
||||
else:
|
||||
channels = list(parse_channels(args.channels))
|
||||
|
||||
print('Starting run {} "{}" at {:%y-%m-%d %H:%M:%S:%f}'.format(run_id, run_name, datetime.now()))
|
||||
print('mac={:08x} channels={}'.format(args.mac, ','.join('{:02d}'.format(ch) for ch in channels)))
|
||||
print('[measurement id] " " [hex setpoint value] "(" [float duty cycle] ")" " " [reading (V)]')
|
||||
|
|
@ -84,7 +101,7 @@ if __name__ == '__main__':
|
|||
print('Zero cal: {:5.4f}V stdev={:5.4f}V'.format(mean, stdev))
|
||||
|
||||
for ch in channels:
|
||||
for i in range(uut.nbits):
|
||||
for i in range(nbits):
|
||||
fb = [0]*uut.nchannels
|
||||
val = 1<<i
|
||||
duty_cycle = val/(2**uut.nbits)
|
||||
|
|
@ -105,7 +122,7 @@ if __name__ == '__main__':
|
|||
run_id, channel, duty_cycle, voltage, voltage_stdev, timestamp
|
||||
) VALUES (?, ?, ?, ?, ?, ?)''',
|
||||
(run_id, ch, duty_cycle, mean, stdev, time.time()))
|
||||
print('{:08d} ch={} {:04x}({:6.5f}): {:5.4f} stdev {:5.4}'.format(
|
||||
print('{:08d} ch={} {:04x}({:6.5f}): {:5.4f} stdev {:5.4f}'.format(
|
||||
cur.lastrowid, ch, val, duty_cycle, mean, stdev))
|
||||
|
||||
uut.send_framebuf([0]*uut.nchannels)
|
||||
|
|
|
|||
|
|
@ -112,8 +112,8 @@ class Olsndot:
|
|||
|
||||
def __str__(self):
|
||||
st = self.fetch_status()
|
||||
return '<Olsndot@{} {}.{} {}ch*{} up {}s vcc {:4.3}V temp {}C>'.format(
|
||||
self.addr, self.fw_ver, self.hw_ver, self.nchannels, self.channel_format,
|
||||
return '<Olsndot {}.{}@{} {}ch*{} up {}s vcc {:4.3}V temp {}C>'.format(
|
||||
self.fw_ver, self.hw_ver, self.addr, self.nchannels, self.channel_format,
|
||||
st.uptime_s, st.vcc_mv/1000, st.temp_celsius)
|
||||
|
||||
@property
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue