# 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') # 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))
#!/usr/bin/python3 from ABE_ExpanderPi import DAC import time """ ================================================ ABElectronics Expander Pi | DAC Write Demo Version 1.0 Created 21/08/2014 Version 1.1 Updated 11/06/2017 updated to include changes to Expander Pi library run with: python3 demo-dacwrite.py ================================================ this demo will generate a 1.5V p-p square wave at 1Hz on channel 1 """ dac = DAC(1) # create a dac instance with the gain set to 1 while True: dac.set_dac_voltage(1, 1.5) # set the voltage on channel 1 to 1.5V time.sleep(1) # wait 1 seconds dac.set_dac_voltage(1, 0) # set the voltage on channel 1 to 0V time.sleep(1) # wait 1 seconds