Visualizing Box0 Analog Input data using Matplot

In [2]:
%matplotlib inline

Electrical Connection

TODO: Electrical Connection

In [1]:
import box0
import numpy as np
import matplotlib.pyplot as plt

####### PART1

# Some config that are better seperate
SAMPLE_RES = 12
SAMPLE_SPEED = 10000
SAMPLE_COUNT = 500

# Prepare for Capture
dev = box0.usb.open_supported()
ain = dev.ain()
ain.snapshot_prepare()

# Capture data from device
ain.bitsize_speed_set(SAMPLE_RES, SAMPLE_SPEED)
s = np.empty(SAMPLE_COUNT, dtype=np.float64)
ain.snapshot_start(s)

# We are done with Box0
ain.close()
dev.close()

####### PART2

# X axis data
t = np.arange(0.0, float(SAMPLE_COUNT) / SAMPLE_SPEED, 1.0 / SAMPLE_SPEED)

plt.xlabel('time (s)')
plt.ylabel('voltage (V)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
plt.plot(t, s, 'r.-')

# Show the data
plt.show()