#!/usr/bin/env python # coding: utf-8 # # ScaledParameter # Sometimes the values that we set/get on the computer are not the physical value that reach/originate from the sample. The ScaledParameter can be used to convert quantities with a simple linear relationship without offset. # In[1]: from qcodes import ManualParameter, ScaledParameter # In[2]: dac0 = ManualParameter('dac0', unit = 'V') dac1 = ManualParameter('dac1', unit = 'V') amplitude = ManualParameter('amplitude', initial_value=3.14, unit = 'V') # ## Resistive voltage divider # The simplest case is a resistive divider, where the set voltage is divided by a fixed amount. # In[6]: vd = ScaledParameter(dac0, division = 10) # In[7]: vd(10) # In[8]: print('Vd =',vd(), vd.unit,', real setted value =', dac0(), dac0.unit) # ## Voltage multiplier # If the voltage is amplified, we can specify a `gain` value instead of `division`. # In[6]: vb = ScaledParameter(dac1, gain = 30, name = 'Vb') # In[7]: vb(5) # In[8]: print('Vb =',vd(), vb.unit,', Original_value =', dac1(), dac1.unit) # ## Transimpedance amplifier # The ScaledParameter can be used also for quantities that are read, like a current read by a transimpedance amplifier, digitized by a multimeter. # We can also specify a different unit from the wrapped parameter. The semantic of gain/division is inverted compared to the previous cases, since it is a value that we read. # In[9]: Id = ScaledParameter(amplitude, division = 1e6, name = 'Id', unit = 'A') # In[10]: print('Id =',Id(), Id.unit,', Read_value =', amplitude(), amplitude.unit) # The gain can be manually changed at any time # In[11]: Id.division = 1e8 print('Id =',Id(), Id.unit,', Read_value =', amplitude(), amplitude.unit) # The gain/division can be itself a Qcodes paramter, for example if is a gain set by a remote instrument # In[12]: remote_gain = ManualParameter('remote_gain', initial_value=1e6, unit = 'V/A') # In[13]: Id.division = remote_gain print('Id =',Id(), Id.unit,', Read_value =', amplitude(), amplitude.unit) # In[14]: remote_gain(1e8) print('Id =',Id(), Id.unit,', Read_value =', amplitude(), amplitude.unit)