当前位置: 首页>>代码示例>>Python>>正文


Python ADCPi.set_pga方法代码示例

本文整理汇总了Python中ABE_ADCPi.ADCPi.set_pga方法的典型用法代码示例。如果您正苦于以下问题:Python ADCPi.set_pga方法的具体用法?Python ADCPi.set_pga怎么用?Python ADCPi.set_pga使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ABE_ADCPi.ADCPi的用法示例。


在下文中一共展示了ADCPi.set_pga方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PIDController

# 需要导入模块: from ABE_ADCPi import ADCPi [as 别名]
# 或者: from ABE_ADCPi.ADCPi import set_pga [as 别名]
class PIDController(multiprocessing.Process):

    def __init__(self, inputqueue, outputqueue):
        multiprocessing.Process.__init__(self)
        self.safetytrigger = False

        # Use correct communication queues
        self.inputqueue = inputqueue
        self.outputqueue = outputqueue

        # Configure ADC correctly
        self.i2c_helper = ABEHelpers()
        self.bus = self.i2c_helper.get_smbus()
        self.adc = ADCPi(self.bus, 0x68, 0x69, 16)
        self.adc.set_pga(8)

        # Setup variables dictionary with initial values
        self.variabledict = {
            'sleeptime': 5,
            'kp': 0,
            'ki': 0,
            'kd': 0,
            'setpoint': {
                '2016-08-12 09:00:00': 20,
                '2016-08-13 09:00:00': 20
            },
            'control_channel': 1,
            'control_k1': 885,
            'control_k2': 2790,
            'control_k3': 0,
            'safety_channel': 2,
            'safety_k1': 885,
            'safety_k2': 2790,
            'safety_k3': 0,
            'safety_value': 0,
            'safety_mode': "off",
            'umax': 100,
            'umin': 0,
            'moutput': "auto",
            'ssrduty': 1,
            'ssrpin': 27,
            'ssrmode': "pwm",
            'pwm_frequency': 1,
            'relayduty': {'Relay1': 0, 'Relay2': 0, 'Relay3': 0, 'Relay4': 0, 'Relay5': 0},
            'relaypin': {'Relay1': "off", 'Relay2': "off", 'Relay3': "off", 'Relay4': "off", 'Relay5': "off"},
            'terminate': 0,
            'autotune_temp': 102,
            'autotune_hysteresis': 1,
            'autotune_kp': 0,
            'autotune_ki': 0,
            'autotune_kd': 0,
            'autotune_on': 'False',
            'autotune_sleeptime': 0.1,
            'autotune_maxiterations': 20,
            'autotune_iterations': 0,
            'autotune_convergence': 0.01,
            'autotune_gainsign': 1,
            'autotune_dict': {
                'time': [],
                'temp': [],
                'output': [],
                'timeperiod': [],
                'peaktype': 'max',
                'startrange': 0,
                'timeperiodstart': 0,
                'relayofftime': 0
            },
            'autotune_peaks': {
                'max': {},
                'min': {}
            }
        }

        # Initialize required variables
        self.setpoint = 0
        self.setpointchanges = 2
        self.output = 0
        self.maxoutput = 0
        self.outputdict = {}
        self.outputdict['Status'] = 'PID Controller Started'

    # Function for interpolating setpoint
    def setpoint_interpolate(self):
        timelist = []
        valuelist = []
        for time, value in sorted(self.variabledict['setpoint'].items()):
            timelist.append(time)
            valuelist.append(value)
        setpointchanges = len(timelist) - 1
        timenow = datetime.datetime.now()

        if timenow < datetime.datetime.strptime(timelist[0], '%Y-%m-%d %H:%M:%S'):
            self.setpoint = "off"
        elif timenow == datetime.datetime.strptime(timelist[0], '%Y-%m-%d %H:%M:%S'):
            self.setpoint = valuelist[0]
        elif timenow >= datetime.datetime.strptime(timelist[setpointchanges], '%Y-%m-%d %H:%M:%S'):
            self.setpoint = "off"
        else:
            self.setpoint = "off"
            for x in range(setpointchanges, -1, -1):
#.........这里部分代码省略.........
开发者ID:GentlemanBrewing,项目名称:BrewManager,代码行数:103,代码来源:Controller.py


注:本文中的ABE_ADCPi.ADCPi.set_pga方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。