- self.put(self.ss_dac, self.es_value, self.out_ann,
- [6, ['Setting %s value to %d (x%d gain)' % (s, v, g),
- '%s=%d (x%d gain)' % (s, v, g)]])
+ vref = self.options['vref_%s' % self.dac_select[3].lower()]
+ v = '%.2fV' % (vref * (v / 256) * self.gain)
+ if self.ldac == 0:
+ # If LDAC is low, the voltage is set immediately.
+ self.put(self.ss_dac, self.es_value, self.out_ann,
+ [7, ['Setting %s voltage to %s' % (s, v),
+ '%s=%s' % (s, v)]])
+ else:
+ # If LDAC is high, the voltage is not set immediately, but rather
+ # stored in a register. When LDAC goes low all four DAC voltages
+ # (DAC A/B/C/D) will be set at the same time.
+ self.put(self.ss_dac, self.es_value, self.out_ann,
+ [6, ['Setting %s register value to %s' % \
+ (s, v), '%s=%s' % (s, v)]])
+ # Save the last value the respective DAC was set to.
+ self.dacval[self.dac_select[-1]] = str(self.dac_value)
+ self.gains[self.dac_select[-1]] = self.gain