def __init__(self,master = None): Frame.__init__(self,master) self.master = master self.init_window()#main window and menu bar self.main_widgets()#objects that inhabit the main page bus = smbus.SMBus(1) kwargs = {'address': 0x68, 'mode':0x10, 'sample_rate':0x08, 'gain':0x00} self.mcp3428 = mcp3428.MCP3428(bus, kwargs) self.voltageConversion = 300 * 1800 / 1709 self.currentConversion = 3.3/10
#Import the module import Adafruit_MCP4725 #import the ADC module class import mcp3428 import smbus import numpy as np import matplotlib.pyplot as plt from numpy import linalg #create bus object bus = smbus.SMBus(1) #create a dictionary of addresses and information needed for the ADC instance kwargs = {'address': 0x68, 'mode': 0x10, 'sample_rate': 0x08, 'gain':0x00} #crate a ADC instance directing towards the bus with the addresses located in kwargs mcp3428 = mcp3428.MCP3428(bus, kwargs) # Create a DAC instance for the voltage input (DAC97) and the current max input # (DAC96) dac96 = Adafruit_MCP4725.MCP4725(address=0x60, busnum=1) dac97 = Adafruit_MCP4725.MCP4725(address=0x61, busnum=1) #Initialization of variables #How the readings change when they get read into and out of the ADC conversionVoltage= 300 * 1800/1709 conversionCurrent= 3.3/10 #DAC takes in a bit from 0 to 4095 since it is 12 bits #Initial Set to Bit is 0 bitVoltage = 0 dac97.set_voltage(bitVoltage) #set the voltage to zero through the dac instance bitCurrent = 0