def mxgabout(): global mxgbench message = [] status = MXG.model(mxgbench) # model message += ['Model: %s (%s)' % (status[1], status[0])] status = MXG.frequency(mxgbench) # frequency message += ['Frequency: %s (%s)' % (status[1], status[0])] status = MXG.power(mxgbench) # power message += ['Power: %s (%s)' % (status[1], status[0])] status = MXG.output(mxgbench) # output message += ['RF output: %s (%s)' % (output_code(status[1]), status[0])] return jsonify(message=message)
def sgabout(): global sgbench message = [] status = SG.model(sgbench) # model message += ['Model: %s (%s)' % (status[1], status[0])] status = SG.frequency(sgbench) # frequency message += ['Frequency: %s (%s)' % (status[1], status[0])] status = SG.power(sgbench) # power message += ['Power: %s (%s)' % (status[1], status[0])] status = SG.rfoutput(sgbench) # rf output message += ['RF output: %s (%s)' % (output_code(status[1]), status[0])] return jsonify(message=message)
def awgsettingschannel(): global awgsess, seqhandl print("seq handle in set-channel is %s"%seqhandl) message = [] channel = request.args.get('channel') stat = AWG.arb_sequence_handle(awgsess, RepCap=channel, action=["Set", seqhandl]) message += ['Sequence embeded: %s <%s>' %(stat[1], status_code(stat[0]))] outputch = request.args.get('outputch') stat = AWG.output_enabled(awgsess, RepCap=channel, action=["Set", int(outputch)]) message += ['output channel %s: %s <%s>' %(channel, output_code(stat[1]), status_code(stat[0]))] oupfiltr = request.args.get('oupfiltr') stat = AWG.output_filter_enabled(awgsess, RepCap=channel, action=["Set", int(oupfiltr)]) message += ['output filter channel %s: %s <%s>' %(channel, output_code(stat[1]), status_code(stat[0]))] # temporary: AWG.output_filter_bandwidth(awgsess, RepCap=channel, action=["Set", 0]) AWG.output_config(awgsess, RepCap=channel, action=["Set", 0]) AWG.arb_gain(awgsess, RepCap=channel, action=["Set", 0.25]) AWG.output_impedance(awgsess, RepCap=channel, action=["Set", 50]) AWG.operation_mode(awgsess, RepCap=channel, action=["Set", 0]) AWG.trigger_source_adv(awgsess, RepCap=channel, action=["Set", 0]) AWG.burst_count(awgsess, RepCap=channel, action=["Set", 1000001]) return jsonify(message=message)
def awgsettingsifwave(): global awgsess AWG.Clear_ArbMemory(awgsess) # PENDING MOVE to TABs samplingrate = AWG.arb_sample_rate(awgsess)[1] dt = 1e9 / samplingrate # in ns message, WaveForms = [], [] WAVE = [] # PRESET Output: ''' To get the BEST from AWG (M9331A). It can be considered a bug to such extent that without this, the output amplitude would be somewhat inconsistent and very much suppressed. ''' for ch in range(2): channel = str(ch + 1) AWG.output_config(awgsess, RepCap=channel, action=["Set", 0]) # Single-ended AWG.output_filter_bandwidth(awgsess, RepCap=channel, action=["Set", 0]) AWG.arb_gain(awgsess, RepCap=channel, action=["Set", 0.5]) AWG.output_impedance(awgsess, RepCap=channel, action=["Set", 50]) # Output Settings: outputch = [request.args.get('outputch1'), request.args.get('outputch2')] oupfiltr = [request.args.get('oupfiltr1'), request.args.get('oupfiltr2')] oupconfig = [ request.args.get('oupconfig1'), request.args.get('oupconfig2') ] for ch in range(2): channel = str(ch + 1) stat = AWG.output_enabled(awgsess, RepCap=channel, action=["Set", int(outputch[ch])]) message += [ 'output channel %s: %s <%s>' % (channel, output_code(stat[1]), status_code(stat[0])) ] stat = AWG.output_filter_enabled( awgsess, RepCap=channel, action=["Set", bool(int(oupfiltr[ch]))]) message += [ 'output filter channel %s: %s <%s>' % (channel, output_code(stat[1]), status_code(stat[0])) ] stat = AWG.output_config(awgsess, RepCap=channel, action=["Set", int(oupconfig[ch])]) message += [ 'output configuration %s: %s <%s>' % (channel, output_code(stat[1]), status_code(stat[0])) ] AWG.output_filter_bandwidth(awgsess, RepCap=channel, action=["Set", 0]) AWG.arb_gain(awgsess, RepCap=channel, action=["Set", 0.5]) AWG.output_impedance(awgsess, RepCap=channel, action=["Set", 50]) # Waveform Construction: ifperiod = float(request.args.get('ifperiod')) Nperiod = round(ifperiod / dt) // 8 * 8 + 8 # to ensure multiples of 8 iffunction = request.args.get('iffunction1'), request.args.get( 'iffunction2') ifdesign = request.args.get('ifdesign1'), request.args.get('ifdesign2') iffreq = float(request.args.get('iffreq1')), float( request.args.get('iffreq2')) ifvoltag = float(request.args.get('ifvoltag1')), float( request.args.get('ifvoltag2')) ifoffset = float(request.args.get('ifoffset1')), float( request.args.get('ifoffset2')) ifphase = float(request.args.get('ifphase1')), float( request.args.get('ifphase2')) ifontime = float(request.args.get('ifontime1')), float( request.args.get('ifontime2')) ifscale = float(request.args.get('ifscale1')), float( request.args.get('ifscale2')) sqeifoffset = float(request.args.get('sqeifoffset1')), float( request.args.get('sqeifoffset2')) ifdelay = float(request.args.get('ifdelay1')), float( request.args.get('ifdelay2')) for ch in range(2): channel = str(ch + 1) # Create Waveforms: if iffunction[ch] == 'arb': wavefom = waveform(ifdesign[ch]).data elif iffunction[ch] == 'sqe': wavefom = squarewave(ifperiod, ifontime[ch], ifdelay[ch], ifscale[ch], sqeifoffset[ch]) else: wavefom = [ ifvoltag[ch] * eval(iffunction[ch] + '(x*%s*%s/1000*2*pi + %s/180*pi)' % (dt, iffreq[ch], ifphase[ch])) + ifoffset[ch] for x in range(Nperiod) ] stat, wave = AWG.CreateArbWaveform(awgsess, wavefom) message += [ 'Waveform channel %s: %s <%s>' % (channel, wave, status_code(stat)) ] WAVE.append(wave) WaveForms.append(wavefom * 3) # Collecting waveforms to plot on mach # Building Sequences: for ch in range(2): channel = str(ch + 1) status, seqhandl = AWG.CreateArbSequence( awgsess, [WAVE[ch]], [1]) # loop# canbe >1 if longer sequence is needed in the future! message += [ 'Sequence channel %s: %s <%s>' % (channel, seqhandl, status_code(status)) ] # Channel Assignment: stat = AWG.arb_sequence_handle(awgsess, RepCap=channel, action=["Set", seqhandl]) message += [ 'Sequence channel %s embeded: %s <%s>' % (channel, stat[1], status_code(stat[0])) ] # Trigger Settings: for ch in range(2): channel = str(ch + 1) AWG.operation_mode(awgsess, RepCap=channel, action=["Set", 0]) AWG.trigger_source_adv(awgsess, RepCap=channel, action=["Set", 0]) # AWG.burst_count(awgsess, RepCap=channel, action=["Set", 1000001]) return jsonify(message=message, WaveForms=WaveForms, t=[i * dt for i in range(len(wavefom) * 3)])