Skip to content

Instantly share code, notes, and snippets.

@thisMagpie
Last active February 2, 2016 16:17
Show Gist options
  • Save thisMagpie/d1ede52973884a0b7364 to your computer and use it in GitHub Desktop.
Save thisMagpie/d1ede52973884a0b7364 to your computer and use it in GitHub Desktop.
from webiopi.devices.analog import MCP3208
import pylab
import numpy as np
import datetime
ADC0 = MCP3208(chip = 0)
time = datetime.datetime.now().microsecond
print("Time: {0}").format(time)
print("Analog Channel Count {0}").format(ADC0.analogCount())
print("Analog Bit Resolution {0}").format(ADC0.analogResolution())
print("Analog Maximum {0}").format(ADC0.analogMaximum())
print("Analog Reference Voltage {0}").format(ADC0.analogReference())
x = [0.0]*100
y = [0.0]*100
for i in range(len(x)):
y[i] = ADC0.analogRead(3)
x[i] = datetime.datetime.now().microsecond - time
pylab.plot(x, y)
pylab.xlabel('Time in micro seconds')
pylab.ylabel('Bit Resolution')
pylab.title('Bit Resolution vs Time in micro seconds.')
pylab.grid(True)
pylab.savefig("sample_3_5.pdf")
pylab.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment