diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-29 23:57:04 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-29 23:57:04 -0500 |
commit | d234eeb2c614c77cb5faee7476ce03c31d2c72cb (patch) | |
tree | 62268ce965070d42a73aa4957652e06b84f7a75f /examples | |
parent | 34608b4334c22b2ecac1beb5d4f55537b17df31e (diff) | |
download | pyExpControl-d234eeb2c614c77cb5faee7476ce03c31d2c72cb.tar.gz pyExpControl-d234eeb2c614c77cb5faee7476ce03c31d2c72cb.zip |
added scope to track magnetic current
Diffstat (limited to 'examples')
-rw-r--r-- | examples/lock_eit.py | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/examples/lock_eit.py b/examples/lock_eit.py index 6ca0452..0dba19d 100644 --- a/examples/lock_eit.py +++ b/examples/lock_eit.py @@ -89,13 +89,11 @@ def adjustRFandLog(apparatus): timenow = time.time() ai = apparatus.instruments - scope = ai['scope'] - rfgen = ai['rfgen'] - pid = ai['pid'] + pid = ai['pid'] + scope_fdbk = ai['scope.feedback'] log = apparatus.gui_log.traces - err = apparatus.getErr() - eit = apparatus.getEIT() + err, eit = apparatus.getErrAndEit() fdbck = pid.feedback(err) freq0 = apparatus.getRFreq() @@ -117,6 +115,7 @@ dfB = freqDeltaMp2 - freqZero freqDeltaMm2 = freqZero - dfB; async def main(): + app_nickname=apparatus.config['DeviceNickname'] task_wp_update_loop = asyncio.create_task(update_webpage_loop(update_interval=1)) @@ -126,11 +125,13 @@ async def main(): logger.info("Accessing hardware") rm = pyvisa.ResourceManager() instr_scope=rm.open_resource('TCPIP::192.168.0.61::INSTR') - scope = SDS1104X(instr_scope, device_nickname='scope.feedback', tsdb_ingester=tsdb_ingester) + scope_fdbk = SDS1104X(instr_scope, device_nickname='.'.join([app_nickname, 'scope.feedback']), tsdb_ingester=tsdb_ingester) + instr_scope=rm.open_resource('TCPIP::192.168.0.62::INSTR') + scope_mon = SDS1104X(instr_scope, device_nickname='.'.join([app_nickname, 'scope.monitor']), tsdb_ingester=tsdb_ingester) instr_rfgen=rm.open_resource('TCPIP::192.168.0.114::INSTR') - rfgen = AgilentE8257D(instr_rfgen, tsdb_ingester=tsdb_ingester) + rfgen = AgilentE8257D(instr_rfgen, device_nickname='.'.join([app_nickname, 'rfgen']), tsdb_ingester=tsdb_ingester) instr_lockin=rm.open_resource('TCPIP::192.168.0.51::INSTR') - lockin = SRS_SR865A(instr_lockin, tsdb_ingester=tsdb_ingester) + lockin = SRS_SR865A(instr_lockin, device_nickname='.'.join([app_nickname, 'lockin']), tsdb_ingester=tsdb_ingester) # print('------ Header start -------------') # print(str.join('\n', scope.getHeader())) # print(str.join('\n', rfgen.getHeader())) @@ -138,14 +139,21 @@ async def main(): # ch1 = scope.getTrace(1) # traces = scope.getAllTraces() # pid = PID(100,400,0, sign=-1); # good for dm=-2 resonance - pid = PID(50,200,0, sign=-1) + pid = PID(50,200,0, sign=-1, device_nickname='.'.join([app_nickname, 'pid']), tsdb_ingester=tsdb_ingester) apparatus.instruments={} ai = apparatus.instruments ai['rfgen'] = rfgen ai['lockin'] = lockin ai['pid'] = pid - ai['scope'] = scope + ai['scope.feedback'] = scope_fdbk + # scope_fdbk.setTimePerDiv(0.0005) + # scope_fdbk.setChanVoltsPerDiv(1, 0.02) + # scope_fdbk.setChanVoltsPerDiv(3, 0.02) + ai['scope.monitor'] = scope_mon + # scope_mon.setTimePerDiv(0.0005) + # scope_mon.setChanVoltsPerDiv(2, 0.002) + # scope_mon.setVoltageOffset(2, -0.0726) apparatus.state = None apparatus.runStatus = False @@ -212,6 +220,8 @@ async def main(): logger.info(f'dE = {dE}') logger.info(f'slope = {slope}') + # apparatus.getBCurrent(); # this automatically logs value to TSDB + return slope lockin_slope= await calibratingLockin() @@ -285,15 +295,34 @@ class Apparatus(BasicInstrument): self.setLockinSlope(0) @BasicInstrument.tsdb_append + def getBCurrent(self): + scope = self.instruments['scope.monitor'] + ch=scope.getTrace(2, decimate=False) + bCurrent = np.mean(ch.y.values); # mV -> mA + return bCurrent + + def getErrAndEit(self): + scope = self.instruments['scope.feedback'] + # we need to freeze scope since this two values are taken on the same scope + trg_mode = scope.getTriggerMode() + scope.setTriggerMode('STOP') + err = self.getErr() + eit = self.getEIT() + scope.setTriggerMode(trg_mode) + return(err,eit) + + + + @BasicInstrument.tsdb_append def getErr(self): - scope = self.instruments['scope'] + scope = self.instruments['scope.feedback'] ch1=scope.getTrace(1, decimate=False) err = np.mean(ch1.y.values) return err @BasicInstrument.tsdb_append def getEIT(self): - scope = self.instruments['scope'] + scope = self.instruments['scope.feedback'] ch3=scope.getTrace(3, decimate=False) eit = np.mean(ch3.y.values) return eit |