Exemplo n.º 1
0
class MKSMassFlowController(SysCompArduino):
    def __init__(self, name, pinInPercent, pinOutPercent, pinOutClose=None):
        SysCompArduino.__init__(
            self, name, (SysVarAnalogArduinoUnipolar('Flow', [0, 100],
                                                     pinInPercent,
                                                     pinOutPercent,
                                                     name,
                                                     'Flow percentage',
                                                     '%',
                                                     self.PreEditPercent,
                                                     highFreqPWM=True), ),
            'monitor/change gas flow')

        self.pinOutClose = pinOutClose
        if self.pinOutClose != None:
            self.varClose = SysVarDigitalArduino('close', pinOutClose, name)

    def FirstTimeOnline(self):
        if self.pinOutClose != None:
            self.GetController().PinModeOut(self.varClose.pin)
        return super(MKSMassFlowController, self).FirstTimeOnline()

    def PreEditPercent(self, value):
        if self.pinOutClose != None:
            if value == 0:
                self.varClose.Set('off')
            else:
                self.varClose.Set('on')
Exemplo n.º 2
0
 def __init__(self,
              name,
              pinEnable,
              pinPolaritySet,
              pinPolarityPositive,
              pinInV,
              pinInI,
              pinOutV,
              pinOutI=None,
              highFreqPWM=False,
              safetyMaxAbsVoltage=None,
              ctlV_I2cDac=None,
              ctlI_I2cDac=None):
     self.varPolaritySet = SysVarDigitalArduino('polaritySet',
                                                pinPolaritySet, name)
     self.varPolarityPositive = SysVarDigitalArduino('polarityPositive',
                                                     pinPolarityPositive,
                                                     name,
                                                     editable=False)
     rangeV = [-30, 30]
     rangeI = [0, 300]
     Spellman.__init__(self,
                       name,
                       rangeV,
                       rangeI,
                       pinEnable,
                       pinInV,
                       pinInI,
                       pinOutV,
                       pinOutI,
                       highFreqPWM=highFreqPWM,
                       pinsVoltsMax=5,
                       safetyMaxAbsVoltage=safetyMaxAbsVoltage,
                       ctlV_I2cDac=ctlV_I2cDac,
                       ctlI_I2cDac=ctlI_I2cDac)
Exemplo n.º 3
0
 def __init__(self,
              name,
              rangeV,
              rangeI,
              pinEnable,
              activeHigh,
              pinInV,
              pinInI,
              pinOutV,
              highFreqPWM=False):
     self.activeHigh = activeHigh
     self.varEnable = SysVarDigitalArduino('enable', pinEnable, name)
     SysCompArduino.__init__(
         self, name, (SysVarAnalogArduinoUnipolar('V',
                                                  rangeV,
                                                  pinInV,
                                                  pinOutV,
                                                  name,
                                                  'Voltage',
                                                  'kV',
                                                  self.PreEditV,
                                                  highFreqPWM=highFreqPWM,
                                                  pinInVoltsMax=1),
                      SysVarAnalogArduinoUnipolar('I',
                                                  rangeI,
                                                  pinInI,
                                                  None,
                                                  name,
                                                  'Current',
                                                  'uA',
                                                  highFreqPWM=highFreqPWM,
                                                  pinInVoltsMax=1)),
         'monitor/change High Voltage variables')
Exemplo n.º 4
0
    def __init__(self,
                 name,
                 pinInPercent,
                 pinOutPercent,
                 pinOutClose=None,
                 I2cDac=None):
        if I2cDac:
            controlVar = SysVarAnalogArduinoUnipolar('Flow', [0, 100],
                                                     pinInPercent,
                                                     None,
                                                     name,
                                                     'Flow percentage',
                                                     '%',
                                                     self.PreEditPercent,
                                                     I2cDac=I2cDac)
        else:
            controlVar = SysVarAnalogArduinoUnipolar('Flow', [0, 100],
                                                     pinInPercent,
                                                     pinOutPercent,
                                                     name,
                                                     'Flow percentage',
                                                     '%',
                                                     self.PreEditPercent,
                                                     highFreqPWM=True)

        SysCompArduino.__init__(self, name, (controlVar, ),
                                'monitor/change gas flow')

        self.pinOutClose = pinOutClose
        if self.pinOutClose != None:
            self.varClose = SysVarDigitalArduino('close', pinOutClose, name)
Exemplo n.º 5
0
class SpellmanCZE30PN2000(Spellman):
    def __init__(self,
                 name,
                 pinEnable,
                 pinPolaritySet,
                 pinPolarityPositive,
                 pinInV,
                 pinInI,
                 pinOutV,
                 pinOutI=None,
                 highFreqPWM=False,
                 safetyMaxAbsVoltage=None,
                 ctlV_I2cDac=None,
                 ctlI_I2cDac=None):
        self.varPolaritySet = SysVarDigitalArduino('polaritySet',
                                                   pinPolaritySet, name)
        self.varPolarityPositive = SysVarDigitalArduino('polarityPositive',
                                                        pinPolarityPositive,
                                                        name,
                                                        editable=False)
        rangeV = [-30, 30]
        rangeI = [0, 300]
        Spellman.__init__(self,
                          name,
                          rangeV,
                          rangeI,
                          pinEnable,
                          pinInV,
                          pinInI,
                          pinOutV,
                          pinOutI,
                          highFreqPWM=highFreqPWM,
                          pinsVoltsMax=5,
                          safetyMaxAbsVoltage=safetyMaxAbsVoltage,
                          ctlV_I2cDac=ctlV_I2cDac,
                          ctlI_I2cDac=ctlI_I2cDac)

    def SetPolarityPositive(self, positive=True):
        self.varPolaritySet.Set('on' if positive else 'off')

    def GetPolarityPositive(self):
        return self.varPolarityPositive.Get() == 'on'

    def PreEditV(self, value):
        ''' function overload '''
        self.varPolaritySet.Set('on' if value > 0 else 'off')

    def FirstTimeOnline(self):
        self.GetController().PinModeOut(self.varPolaritySet.pin)
        self.GetController().PinModeIn(self.varPolarityPositive.pin)
        super(SpellmanCZE30PN2000, self).FirstTimeOnline()
Exemplo n.º 6
0
class HvmSubMiniHighVoltage(SysCompArduino):
    def __init__(self,
                 name,
                 rangeV,
                 rangeI,
                 pinEnable,
                 activeHigh,
                 pinInV,
                 pinInI,
                 pinOutV,
                 highFreqPWM=False):
        self.activeHigh = activeHigh
        self.varEnable = SysVarDigitalArduino('enable', pinEnable, name)
        SysCompArduino.__init__(
            self, name, (SysVarAnalogArduinoUnipolar('V',
                                                     rangeV,
                                                     pinInV,
                                                     pinOutV,
                                                     name,
                                                     'Voltage',
                                                     'kV',
                                                     self.PreEditV,
                                                     highFreqPWM=highFreqPWM,
                                                     pinInVoltsMax=1),
                         SysVarAnalogArduinoUnipolar('I',
                                                     rangeI,
                                                     pinInI,
                                                     None,
                                                     name,
                                                     'Current',
                                                     'uA',
                                                     highFreqPWM=highFreqPWM,
                                                     pinInVoltsMax=1)),
            'monitor/change High Voltage variables')

    def FirstTimeOnline(self):
        self.GetController().PinModeOut(self.varEnable.pin)
        super(HvmSubMiniHighVoltage, self).FirstTimeOnline()

    def PreEditV(self, value):
        if value != 0:
            self.varEnable.Set('on' if self.activeHigh else 'off')
        else:
            self.varEnable.Set('off' if self.activeHigh else 'on')
Exemplo n.º 7
0
 def __init__(self, name, rangeT, pinInT, pinOutRelay, sensorVoltsMin,
              sensorVoltsMax, pidVar, windowSizeMs, kp, ki, kd):
     self.varEnable = SysVarDigitalArduino('enable',
                                           None,
                                           name,
                                           PreSetFunc=self.PreEditEnable)
     self.pidRelayVar = SysVarPidRelayArduino('T',
                                              rangeT,
                                              pidVar,
                                              windowSizeMs,
                                              kp,
                                              ki,
                                              kd,
                                              pinInT,
                                              pinOutRelay,
                                              name,
                                              'Temperature',
                                              'C',
                                              pinInVoltsMin=sensorVoltsMin,
                                              pinInVoltsMax=sensorVoltsMax)
     SysCompArduino.__init__(
         self, name, (self.pidRelayVar, self.varEnable),
         'control a heating element through a relay to keep the temperature set'
     )
Exemplo n.º 8
0
 def __init__(self, name, pin):
     SysCompArduino.__init__(self, name, (SysVarDigitalArduino(
         'trigger', pin, name, PreSetFunc=self.Pause), ),
                             'trigger the e-corder')
Exemplo n.º 9
0
# The first has a unipolar positive range (0 to 5 V).
# The second has a unipolar negative range (-5 to 0 V).
# The third has a bipolar range (-5 to 5 V) while a digital pin sets the polarity.
if __name__ == '__main__':
    '''
    *** System constants
    '''
    # pin assignments
    pinAnal_unipolarPositive = 0
    pinAnal_unipolarNegative = 1
    pinAnal_bipolar = 2
    pinDigi_polarity = 2
    '''
    *** System components
    '''
    polarityVariable = SysVarDigitalArduino('polarity', pinDigi_polarity)

    def SetPolarityPositiveFunc():
        pass

    def GetPolarityPositiveFunc():
        return polarityVariable.Get() == 'on'

    analPins = AnalogPins('analog pins', (
        SysVarAnalogArduinoUnipolar(
            'unipolar +', [0, 5], pinAnal_unipolarPositive, None, units='V'),
        SysVarAnalogArduinoUnipolar(
            'unipolar -', [-5, 0], pinAnal_unipolarNegative, None, units='V'),
        SysVarAnalogArduinoBipolarWithExternalPolarity('bipolar', [-5, 5],
                                                       pinAnal_bipolar,
                                                       None,
Exemplo n.º 10
0
    def __init__(self,
                 name,
                 rangeV,
                 rangeI,
                 pinEnable,
                 pinInV,
                 pinInI,
                 pinOutV,
                 pinOutI=None,
                 highFreqPWM=False,
                 pinsVoltsMax=5,
                 safetyMaxAbsVoltage=None,
                 ctlV_I2cDac=None,
                 ctlI_I2cDac=None):
        varEnable = SysVarDigitalArduino('enable', pinEnable, name)

        # Reduce maximal pin output according to security voltage
        if safetyMaxAbsVoltage != None:
            divider = safetyMaxAbsVoltage / max(abs(rangeV[0]), abs(rangeV[1]))
        else:
            divider = 1
        rangeV[0] *= divider
        rangeV[1] *= divider
        pinsVoltsMaxAdjusted = pinsVoltsMax * divider

        # set voltage variable according to the voltage range. Use methods defined in the instantiated sub-class
        if rangeV[0] * rangeV[1] >= 0:
            if ctlV_I2cDac:
                voltageVar = SysVarAnalogArduinoUnipolar(
                    'V',
                    rangeV,
                    pinInV,
                    None,
                    name,
                    'Voltage',
                    'kV',
                    self.PreEditV,
                    highFreqPWM=highFreqPWM,
                    pinOutVoltsMax=pinsVoltsMaxAdjusted,
                    pinInVoltsMax=pinsVoltsMaxAdjusted,
                    I2cDac=ctlV_I2cDac)
            else:
                voltageVar = SysVarAnalogArduinoUnipolar(
                    'V',
                    rangeV,
                    pinInV,
                    pinOutV,
                    name,
                    'Voltage',
                    'kV',
                    self.PreEditV,
                    highFreqPWM=highFreqPWM,
                    pinOutVoltsMax=pinsVoltsMaxAdjusted,
                    pinInVoltsMax=pinsVoltsMaxAdjusted)
        else:
            if ctlV_I2cDac:
                voltageVar = SysVarAnalogArduinoBipolarWithExternalPolarity(
                    'V',
                    rangeV,
                    pinInV,
                    None,
                    self.SetPolarityPositive,
                    self.GetPolarityPositive,
                    name,
                    'Voltage',
                    'kV',
                    self.PreEditV,
                    highFreqPWM=highFreqPWM,
                    pinOutVoltsMax=pinsVoltsMaxAdjusted,
                    pinInVoltsMax=pinsVoltsMaxAdjusted,
                    I2cDac=ctlV_I2cDac)
            else:
                voltageVar = SysVarAnalogArduinoBipolarWithExternalPolarity(
                    'V',
                    rangeV,
                    pinInV,
                    pinOutV,
                    self.SetPolarityPositive,
                    self.GetPolarityPositive,
                    name,
                    'Voltage',
                    'kV',
                    self.PreEditV,
                    highFreqPWM=highFreqPWM,
                    pinOutVoltsMax=pinsVoltsMaxAdjusted,
                    pinInVoltsMax=pinsVoltsMaxAdjusted)

        if ctlI_I2cDac:
            currentVar = SysVarAnalogArduinoUnipolar(
                'I',
                rangeI,
                pinInI,
                None,
                name,
                'Current',
                'uA',
                highFreqPWM=highFreqPWM,
                pinOutVoltsMax=pinsVoltsMax,
                pinInVoltsMax=pinsVoltsMax,
                I2cDac=ctlI_I2cDac)
        else:
            currentVar = SysVarAnalogArduinoUnipolar(
                'I',
                rangeI,
                pinInI,
                pinOutI,
                name,
                'Current',
                'uA',
                highFreqPWM=highFreqPWM,
                pinOutVoltsMax=pinsVoltsMax,
                pinInVoltsMax=pinsVoltsMax)

        SysCompArduino.__init__(self, name,
                                (voltageVar, currentVar, varEnable),
                                'monitor/change High Voltage variables')