#!/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)
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') # read the date from the RTC in ISO 8601 format and print it to the screen print 'Date: ' + rtc.read_date() print '' print 'ADC: ' print 'Channel 1: ' + str(adc.read_adc_voltage(1, 0)) print 'Channel 2: ' + str(adc.read_adc_voltage(2, 0)) print 'Channel 3: ' + str(adc.read_adc_voltage(3, 0)) print 'Channel 4: ' + str(adc.read_adc_voltage(4, 0)) print 'Channel 5: ' + str(adc.read_adc_voltage(5, 0)) print 'Channel 6: ' + str(adc.read_adc_voltage(6, 0)) print 'Channel 7: ' + str(adc.read_adc_voltage(7, 0)) print 'Channel 8: ' + str(adc.read_adc_voltage(8, 0)) print '' print 'IO: ' print 'Pin 1: ' + str(io.read_pin(1)) print 'Pin 2: ' + str(io.read_pin(2)) print 'Pin 3: ' + str(io.read_pin(3)) print 'Pin 4: ' + str(io.read_pin(4)) print 'Pin 5: ' + str(io.read_pin(5)) print 'Pin 6: ' + str(io.read_pin(6))
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') # read the date from the RTC in ISO 8601 format and print it to the screen print('Date: ' + rtc.read_date()) print('') print('ADC: ') print('Channel 1: ' + str(adc.read_adc_voltage(1))) print('Channel 2: ' + str(adc.read_adc_voltage(2))) print('Channel 3: ' + str(adc.read_adc_voltage(3))) print('Channel 4: ' + str(adc.read_adc_voltage(4))) print('Channel 5: ' + str(adc.read_adc_voltage(5))) print('Channel 6: ' + str(adc.read_adc_voltage(6))) print('Channel 7: ' + str(adc.read_adc_voltage(7))) print('Channel 8: ' + str(adc.read_adc_voltage(8))) print('') print('IO: ') print('Pin 1: ' + str(io.read_pin(1))) print('Pin 2: ' + str(io.read_pin(2))) print('Pin 3: ' + str(io.read_pin(3))) print('Pin 4: ' + str(io.read_pin(4))) print('Pin 5: ' + str(io.read_pin(5))) print('Pin 6: ' + str(io.read_pin(6)))
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"] if file and allow_file(file.filename): filename = "job.gcode" file.save(os.path.join(app.config["UPLOAD_FOLDER"], filename)) pps = 4
#!/usr/bin/python3 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 Version 1.2 11/06/2017 updated to include changes to Expander Pi library 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 in single ended mode and display on the screen print(adc.read_adc_voltage(1, 0)) time.sleep(0.5)
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') # read the date from the RTC in ISO 8601 format and print it to the screen print ('Date: ' + rtc.read_date()) print ('') print ('ADC: ') print ('Channel 1: ' + str(adc.read_adc_voltage(1))) print ('Channel 2: ' + str(adc.read_adc_voltage(2))) print ('Channel 3: ' + str(adc.read_adc_voltage(3))) print ('Channel 4: ' + str(adc.read_adc_voltage(4))) print ('Channel 5: ' + str(adc.read_adc_voltage(5))) print ('Channel 6: ' + str(adc.read_adc_voltage(6))) print ('Channel 7: ' + str(adc.read_adc_voltage(7))) print ('Channel 8: ' + str(adc.read_adc_voltage(8))) print ('') print ('IO: ') print ('Pin 1: ' + str(io.read_pin(1))) print ('Pin 2: ' + str(io.read_pin(2))) print ('Pin 3: ' + str(io.read_pin(3))) print ('Pin 4: ' + str(io.read_pin(4))) print ('Pin 5: ' + str(io.read_pin(5))) print ('Pin 6: ' + str(io.read_pin(6)))
#!/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)
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') # read the date from the RTC in ISO 8601 format and print it to the screen print ('Date: ' + rtc.read_date()) print ('') print ('ADC: ') print ('Channel 1: ' + str(adc.read_adc_voltage(1, 0))) print ('Channel 2: ' + str(adc.read_adc_voltage(2, 0))) print ('Channel 3: ' + str(adc.read_adc_voltage(3, 0))) print ('Channel 4: ' + str(adc.read_adc_voltage(4, 0))) print ('Channel 5: ' + str(adc.read_adc_voltage(5, 0))) print ('Channel 6: ' + str(adc.read_adc_voltage(6, 0))) print ('Channel 7: ' + str(adc.read_adc_voltage(7, 0))) print ('Channel 8: ' + str(adc.read_adc_voltage(8, 0))) print ('') print ('IO: ') print ('Pin 1: ' + str(io.read_pin(1))) print ('Pin 2: ' + str(io.read_pin(2))) print ('Pin 3: ' + str(io.read_pin(3))) print ('Pin 4: ' + str(io.read_pin(4))) print ('Pin 5: ' + str(io.read_pin(5))) print ('Pin 6: ' + str(io.read_pin(6)))
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)) print ("Channel 6: ", adc.read_adc_voltage(6, 0)) print ("Channel 7: ", adc.read_adc_voltage(7, 0)) print ("Channel 8: ", adc.read_adc_voltage(8, 0)) time.sleep(0.1)