Functions


In [135]:
%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np

In [136]:
def parse_adc(filename):
    f = open(filename, 'r')
    data = f.readlines()
    values = []
    for d in data:
        d = int(d[:6], 16)
        if d > 0x7FFFFF:
            d -= 0x1000000
        values.append(d)
    x = np.arange(0, len(values), 1)
    y = np.array(values)
    return x, y

In [137]:
def parse_acc(filename):
    f = open(filename, 'r')
    data = f.readlines()
    values = []
    for d in data:
        d = int(d[:8], 16)
        if d > 0x7FFFFFFF:
            d -= 0x100000000
        values.append(d)
    x = np.arange(0, len(values), 1)
    y = np.array(values)
    return x, y

In [138]:
def debug_plot(x, y, filename):
    title = 'CF Debug Plot: ' + filename
    fig = plt.figure(title, (16, 8), 72)
    ax = fig.add_subplot(111)
    ax.grid(True)
    ax.set_title(title)
    ax.set_xlabel("Samples")
    ax.set_ylabel("Amplitude")
    ax.axis([x[0], x[-1:], min(y) * 1.1, max(y) * 1.1])
    line = ax.plot(x, y, 'b-')
    plt.show()

Plots

ADC with noise


In [139]:
filename = 'adc_noise.txt'
x, y = parse_adc(filename)
debug_plot(x, y, filename)


ADC with sine wave


In [140]:
filename = 'adc_sine.txt'
x, y = parse_adc(filename)
debug_plot(x, y, filename)


Accumulator with noise


In [141]:
filename = 'acc_noise.txt'
x, y = parse_acc(filename)
debug_plot(x, y, filename)


Accumulator with sine wave


In [142]:
filename = 'acc_sine.txt'
x, y = parse_acc(filename)
debug_plot(x, y, filename)


ADC I_A with sine wave


In [143]:
filename = 'adc_ia_sine.txt'
x, y = parse_adc(filename)
debug_plot(x, y, filename)