def setCLMidVoltage(self, vinput): syslog.syslog(LOG_STSW_PRI, "> HVControlBoard:setCLMidVoltage") vmax = 2000 if (vinput < vmax): digInput = int(round(vinput * 0x10000 / vmax)) PBBDevices.selectSPISlave(DAC_LOAD_ID, SPI_MODE_3) PBBDevices.setDAC7731(digInput >> 8, SPI_MODE_3) PBBDevices.deSelectSPISlaves(SPI_MODE_3) PBBDevices.selectSPISlave(DAC_LOAD_ID, SPI_MODE_3) PBBDevices.setDAC7731(digInput & 0x00ff, SPI_MODE_3) PBBDevices.deSelectSPISlaves(SPI_MODE_3) PBBDevices.deSelectSPISlaves(SPI_MODE_0) PBBDevices.selectSPISlave(DAC_OPUT_ID, SPI_MODE_0) PBBDevices.deSelectSPISlaves(SPI_MODE_0) PBBDevices.selectSPISlave(DAC_LOAD_ID, SPI_MODE_3) config1 = int(PBBDevices.setDAC7731(digInput >> 8, SPI_MODE_3)) PBBDevices.deSelectSPISlaves(SPI_MODE_3) PBBDevices.selectSPISlave(DAC_LOAD_ID, SPI_MODE_3) config2 = int(PBBDevices.setDAC7731(digInput & 0x00ff, SPI_MODE_3)) PBBDevices.deSelectSPISlaves(SPI_MODE_3) PBBDevices.deSelectSPISlaves(SPI_MODE_0) PBBDevices.selectSPISlave(DAC_OPUT_ID, SPI_MODE_0) PBBDevices.deSelectSPISlaves(SPI_MODE_0) if (digInput == (config1 << 8 | config2)): print "Desired voltage is set" else: print "Unable to set desired Voltage" else: print "wrong input, input voltage should be less than 10 Volts" syslog.syslog(LOG_STSW_PRI, "< HVControlBoard:setCLMidVoltage")
def setCLMidVoltage(self,vinput): syslog.syslog(LOG_STSW_PRI,"> HVControlBoard:setCLMidVoltage") vmax = 2000 if (vinput<vmax): digInput = int(round(vinput*0x10000/vmax)) PBBDevices.selectSPISlave(DAC_LOAD_ID,SPI_MODE_3) PBBDevices.setDAC7731(digInput>>8,SPI_MODE_3) PBBDevices.deSelectSPISlaves(SPI_MODE_3) PBBDevices.selectSPISlave(DAC_LOAD_ID,SPI_MODE_3) PBBDevices.setDAC7731(digInput & 0x00ff,SPI_MODE_3) PBBDevices.deSelectSPISlaves(SPI_MODE_3) PBBDevices.deSelectSPISlaves(SPI_MODE_0) PBBDevices.selectSPISlave(DAC_OPUT_ID,SPI_MODE_0) PBBDevices.deSelectSPISlaves(SPI_MODE_0) PBBDevices.selectSPISlave(DAC_LOAD_ID,SPI_MODE_3) config1 = int(PBBDevices.setDAC7731(digInput>>8,SPI_MODE_3)) PBBDevices.deSelectSPISlaves(SPI_MODE_3) PBBDevices.selectSPISlave(DAC_LOAD_ID,SPI_MODE_3) config2 = int(PBBDevices.setDAC7731(digInput & 0x00ff,SPI_MODE_3)) PBBDevices.deSelectSPISlaves(SPI_MODE_3) PBBDevices.deSelectSPISlaves(SPI_MODE_0) PBBDevices.selectSPISlave(DAC_OPUT_ID,SPI_MODE_0) PBBDevices.deSelectSPISlaves(SPI_MODE_0) if (digInput == (config1<<8|config2)): print "Desired voltage is set" else: print "Unable to set desired Voltage" else: print "wrong input, input voltage should be less than 10 Volts" syslog.syslog(LOG_STSW_PRI,"< HVControlBoard:setCLMidVoltage")