from ABE_ExpanderPi import DAC import time import os # ================================================ # ABElectronics Expander Pi | Tester # Version 1.0 Created 08/11/2014 # Version 1.1 Updated 11/06/2017 updated to include changes to Expander Pi library # # run with: python tester.py # ================================================ # This script tests the various functionality of the Expander Pi rtc = RTC() # create a new instance of the RTC class adc = ADC() # create an instance of the ADC class io = IO() # create an instance of the IO class dac = DAC(1) # create an instance of the DAC class with a gain of 0 # set the date using ISO 8601 format - YYYY-MM-DDTHH:MM:SS rtc.set_date("2017-01-01T00:00:00") dac.set_dac_voltage(1, 1.5) # set the voltage on channel 1 to 1.5V dac.set_dac_voltage(2, 1.0) # set the voltage on channel 2 to 1.0V # set the reference voltage. this should be set to the exact voltage # measured on the Expander Pi Vref pin. adc.set_adc_refvoltage(4.096) while True: # clear the console os.system('clear')
#!/usr/bin/python from ABE_ExpanderPi import ADC import time """ ================================================ ABElectronics Expander Pi | ADC Read Demo Version 1.0 Created 21/08/2014 Version 1.1 16/11/2014 updated code and functions to PEP8 format run with: python demo-adcread.py ================================================ this demo reads the voltage from channel 1 on the ADC inputs """ adc = ADC() # create an instance of the ADC # set the reference voltage. this should be set to the exact voltage # measured on the Expander Pi Vref pin. adc.set_adc_refvoltage(4.096) while True: # read the voltage from channel 1 in single ended mode and display on the screen print adc.read_adc_voltage(1,0) time.sleep(0.5)
GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.cleanup() GPIO.setup(relay, GPIO.OUT) GPIO.setup(red_led, GPIO.OUT) GPIO.setup(green_led, GPIO.OUT) GPIO.setup(switch, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.output(relay, 0) GPIO.output(red_led, 0) GPIO.output(green_led, 0) upload_folder = "./uploads" allowed_ext = set(["txt", "gcode"]) adc = ADC() app = Flask(__name__) app.config["UPLOAD_FOLDER"] = upload_folder curr_error = adc.read_adc_voltage(2) - 2.4 def allow_file(filename): return "." in filename and filename.rsplit(".", 1)[1] in allowed_ext @app.route("/", methods=["GET", "POST"]) def index(): if request.method == "POST": global pps file = request.files["file"]
import time import os # ================================================ # ABElectronics Expander Pi | Tester # Version 1.0 Created 29/03/2015 # # run with: python3 tester.py # ================================================ # This script tests the various functionality of the Expander Pi i2c_helper = ABEHelpers() bus = i2c_helper.get_smbus() rtc = RTC(bus) # create a new instance of the RTC class adc = ADC() # create an instance of the ADC class io = IO(bus) # create an instance of the IO class dac = DAC() # create an instance of the DAC class # set the date using ISO 8601 format - YYYY-MM-DDTHH:MM:SS rtc.set_date("2014-01-01T00:00:00") dac.set_dac_voltage(1, 1.5) # set the voltage on channel 1 to 1.5V dac.set_dac_voltage(2, 1.0) # set the voltage on channel 2 to 1.0V # set the reference voltage. this should be set to the exact voltage # measured on the Expander Pi Vref pin. adc.set_adc_refvoltage(4.096) while True: # clear the console os.system('clear')
#!/usr/bin/python3 from ABE_ExpanderPi import ADC import time """ ================================================ ABElectronics Expander Pi | ADC Read Demo Version 1.0 Created 29/03/2015 run with: python3 demo-adcread.py ================================================ this demo reads the voltage from channel 1 on the ADC inputs """ adc = ADC() # create an instance of the ADC # set the reference voltage. this should be set to the exact voltage # measured on the Expander Pi Vref pin. adc.set_adc_refvoltage(4.096) while True: # read the voltage from channel 1 and display on the screen print (adc.read_adc_voltage(1)) time.sleep(0.5)
import os """ ================================================ ABElectronics Expander Pi | ADC Read Demo Version 1.0 Created 29/03/2015 run with: python3 demo-adcread.py ================================================ this demo reads the voltage from all channels on the ADC inputs """ def cls(): os.system('cls' if os.name=='nt' else 'clear') adc = ADC() # create an instance of the ADC # set the reference voltage. this should be set to the exact voltage # measured on the Expander Pi Vref pin. adc.set_adc_refvoltage(4.096) clear = lambda: os.system('cls') while True: cls() # read the voltage from the 8 channels in single ended mode and display on the screen print ("Channel 1: ", adc.read_adc_voltage(1, 0)) print ("Channel 2: ", adc.read_adc_voltage(2, 0)) print ("Channel 3: ", adc.read_adc_voltage(3, 0)) print ("Channel 4: ", adc.read_adc_voltage(4, 0)) print ("Channel 5: ", adc.read_adc_voltage(5, 0))