import time
import math
"""
================================================
ABElectronics Expander Pi | DAC sine wave generator 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-dacsinewave.py
================================================

this demo uses the set_dac_raw method to generate a sine wave from a
predefined set of values
"""

dac = DAC(1)

DACLookup_FullSine_12Bit = \
    [2048, 2073, 2098, 2123, 2148, 2174, 2199, 2224,
     2249, 2274, 2299, 2324, 2349, 2373, 2398, 2423,
     2448, 2472, 2497, 2521, 2546, 2570, 2594, 2618,
     2643, 2667, 2690, 2714, 2738, 2762, 2785, 2808,
     2832, 2855, 2878, 2901, 2924, 2946, 2969, 2991,
     3013, 3036, 3057, 3079, 3101, 3122, 3144, 3165,
     3186, 3207, 3227, 3248, 3268, 3288, 3308, 3328,
     3347, 3367, 3386, 3405, 3423, 3442, 3460, 3478,
     3496, 3514, 3531, 3548, 3565, 3582, 3599, 3615,
     3631, 3647, 3663, 3678, 3693, 3708, 3722, 3737,
     3751, 3765, 3778, 3792, 3805, 3817, 3830, 3842,
     3854, 3866, 3877, 3888, 3899, 3910, 3920, 3930,
     3940, 3950, 3959, 3968, 3976, 3985, 3993, 4000,
示例#2
0
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')

    # read the date from the RTC in ISO 8601 format and print it to the screen
示例#3
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
示例#4
0
# ================================================
# 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')

    # read the date from the RTC in ISO 8601 format and print it to the screen
#!/usr/bin/python3

from ABE_ExpanderPi import DAC
import time
"""
================================================
ABElectronics Expander Pi | DAC Write Demo
Version 1.0 Created 29/03/2015

run with: python3 demo-dacwrite.py
================================================

this demo will generate a 1.5V p-p square wave at 1Hz on channel 1
"""

dac = DAC()

while True:
    dac.set_dac_voltage(1, 1.5)  # set the voltage on channel 1 to 1.5V
    time.sleep(0.5)  # wait 0.5 seconds
    dac.set_dac_voltage(1, 0)  # set the voltage on channel 1 to 0V
    time.sleep(0.5)  # wait 0.5 seconds
import time
import math

"""
================================================
ABElectronics Expander Pi | DAC sine wave generator demo
Version 1.0 Created 21/08/2014

run with: python demo-dacsinewave.py
================================================

this demo uses the set_dac_raw method to generate a sine wave from a
predefined set of values
"""

dac = DAC()

DACLookup_FullSine_12Bit = \
    [2048, 2073, 2098, 2123, 2148, 2174, 2199, 2224,
     2249, 2274, 2299, 2324, 2349, 2373, 2398, 2423,
     2448, 2472, 2497, 2521, 2546, 2570, 2594, 2618,
     2643, 2667, 2690, 2714, 2738, 2762, 2785, 2808,
     2832, 2855, 2878, 2901, 2924, 2946, 2969, 2991,
     3013, 3036, 3057, 3079, 3101, 3122, 3144, 3165,
     3186, 3207, 3227, 3248, 3268, 3288, 3308, 3328,
     3347, 3367, 3386, 3405, 3423, 3442, 3460, 3478,
     3496, 3514, 3531, 3548, 3565, 3582, 3599, 3615,
     3631, 3647, 3663, 3678, 3693, 3708, 3722, 3737,
     3751, 3765, 3778, 3792, 3805, 3817, 3830, 3842,
     3854, 3866, 3877, 3888, 3899, 3910, 3920, 3930,
     3940, 3950, 3959, 3968, 3976, 3985, 3993, 4000,