ALICE 1.3  1.0
Develpoer documentation
alice-desktop-1.3.pyw
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: cp1252 -*-
3 
12 import __future__
13 import math
14 import time
15 try:
16  import numpy
17  numpy_found = True
18 except:
19  numpy_found = False
20 import csv
21 import wave
22 import os
23 #import requests
24 import sys
25 import struct
26 import subprocess
27 from time import gmtime, strftime
28 if sys.version_info[0] == 2:
29  print ("Python 2.x")
30  import urllib2
31  import tkFont
32  from Tkinter import *
33  from ttk import *
34  from tkFileDialog import askopenfilename
35  from tkFileDialog import asksaveasfilename
36  from tkSimpleDialog import askstring
37  from tkMessageBox import *
38 if sys.version_info[0] == 3:
39  print ("Python 3.x")
40  import urllib.request, urllib.error, urllib.parse
41  from tkinter.font import *
42  from tkinter import *
43  from tkinter.ttk import *
44  from tkinter.filedialog import askopenfilename
45  from tkinter.filedialog import asksaveasfilename
46  from tkinter.simpledialog import askstring
47  from tkinter.messagebox import *
48 #
49 import webbrowser
50 try:
51  from pysmu import *
52  pysmu_found = True
53 except:
54  pysmu_found = False
55 #
56 # check which operating system
57 import platform
58 #
59 RevDate = "(14 Aug 2020)"
60 SWRev = "1.3 "
61 Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.8/alice-desktop-1.3-setup.exe'
62 # small bit map of ADI logo for window icon
63 TBicon = """
64 R0lGODlhIAAgAHAAACH5BAEAAAIALAAAAAAgACAAgQAAAP///wAAAAAAAAJJhI+py+0PYwtBWkDp
65 hTnv2XlfEobjUZZnmn4se72vJMtcbYN4ruz44uORgiodsfI4Im++2M5VW81OmBbVULxiRVrUsgsO
66 i8fUAgA7
67 """
68 
69 root=Tk()
70 root.title("ALICE DeskTop " + SWRev + RevDate + ": ALM1000 Oscilloscope")
71 img = PhotoImage(data=TBicon)
72 root.call('wm', 'iconphoto', root._w, '-default', img)
73 print("Windowing Syayem is " + str(root.tk.call('tk', 'windowingsystem')))
74 
75 GRW = 720 # Width of the time grid 720 default
76 GRH = 390 # Height of the time grid 390 default
77 X0L = 55 # Left top X value of time grid
78 Y0T = 25 # Left top Y value of time grid
79 #
80 GRWF = 720 # Width of the spectrum grid 720 default
81 GRHF = 390 # Height of the spectrum grid 390 default
82 X0LF = 37 # Left top X value of spectrum grid
83 Y0TF = 25 # Left top Y value of spectrum grid
84 #
85 GRWBP = 720 # Width of the Bode Plot grid 720 default
86 GRHBP = 390 # Height of the Bode Plot grid 390 default
87 X0LBP = 37 # Left top X value of Bode Plot grid
88 Y0TBP = 25 # Left top Y value of Bode Plot grid
89 #
90 GRWXY = 420 # Width of the XY grid 420 default
91 GRHXY = 390 # Height of the XY grid 390 default
92 X0LXY = 37 # Left top X value of XY grid
93 Y0TXY = 25 # Left top Y value of XY grid
94 #
95 GRWIA = 400 # Width of the grid 400 default
96 GRHIA = 400 # Height of the grid 400 default
97 X0LIA = 37 # Left top X value of grid
98 Y0TIA = 25 # Left top Y value of grid
99 #
100 GRWNqP = 400 # Width of the Nyquist plot grid 400 default
101 GRHNqP = 400 # Height of the grid 400 default
102 X0LNqP = 25 # Left top X value of grid
103 Y0TNqP = 25 # Left top Y value of grid
104 #
105 GRWNiC = 400 # Width of the Nichols plot grid 400 default
106 GRHNiC = 400 # Height of the grid 400 default
107 X0LNiC = 25 # Left top X value of grid
108 Y0TNiC = 25 # Left top Y value of grid
109 #
110 GRWPhA = 400 # Width of the grid 400 default
111 GRHPhA = 400 # Height of the grid 400 default
112 X0LPhA = 37 # Left top X value of grid
113 Y0TPhA = 25 # Left top Y value of grid
114 #
115 FontSize = 8
116 MouseX = MouseY = -10
117 MouseCAV = MouseCAI = MouseCBV = MouseCBI = MouseMuxA = MouseMuxB = MouseMuxC = MouseMuxD = -10
118 
119 COLORframes = "#000080" # Color = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
120 COLORcanvas = "#000000" # 100% black
121 COLORgrid = "#808080" # 50% Gray
122 COLORzeroline = "#0000ff" # 100% blue
123 COLORtrace1 = "#00ff00" # 100% green
124 COLORtrace2 = "#ff8000" # 100% orange
125 COLORtrace3 = "#00ffff" # 100% cyan
126 COLORtrace4 = "#ffff00" # 100% yellow
127 COLORtrace5 = "#ff00ff" # 100% magenta
128 COLORtrace6 = "#C80000" # 90% red
129 COLORtrace7 = "#8080ff" # 100% purple
130 COLORtraceR1 = "#008000" # 50% green
131 COLORtraceR2 = "#905000" # 50% orange
132 COLORtraceR3 = "#008080" # 50% cyan
133 COLORtraceR4 = "#808000" # 50% yellow
134 COLORtraceR5 = "#800080" # 50% magenta
135 COLORtraceR6 = "#800000" # 80% red
136 COLORtraceR7 = "#4040a0" # 80% purple
137 COLORtext = "#ffffff" # 100% white
138 COLORtrigger = "#ff0000" # 100% red
139 COLORsignalband = "#ff0000" # 100% red
140 ButtonGreen = "#00ff00" # 100% green
141 ButtonRed = "#ff0000" # 100% red
142 
143 OnBoardRes = 50.83
144 AD584act = 2.5
145 # Set sample buffer size
146 HoldOff = 0.0
147 LShift = 0
148 BaseSampleRate = 100000
149 AWGSAMPLErate = BaseSampleRate # Sample rate of the AWG channels
150 SAMPLErate = BaseSampleRate # Scope sample rate can be decimated
151 MinSamples = 2000
152 MaxSamples = 200000
153 ETSrecord = 2000
154 DISsamples = GRW
155 # set initial trigger conditions
156 TRIGGERlevel = 2.5 # Triggerlevel in volts
157 
158 MathString = "VBuffA[t] + VBuffB[t]"
159 MathUnits = " V"
160 MathXString = "VBuffA[t]"
161 MathXUnits = " V"
162 MathYString = "VBuffB[t]"
163 MathYUnits = " V"
164 UserAString = "MaxV1-VATop"
165 UserALabel = "OverShoot"
166 UserBString = "MinV2-VBBase"
167 UserBLabel = "UnderShoot"
168 MathAxis = "V-A"
169 MathXAxis = "V-A"
170 MathYAxis = "V-B"
171 AWGAMathString = "(VBuffA + VBuffB)/2"
172 AWGBMathString = "(VBuffA + VBuffB)/2"
173 FFTUserWindowString = "numpy.kaiser(SMPfft, 14) * 3"
174 DigFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
175 DigFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
176 ChaMeasString1 = "DCV1"
177 ChaMeasString2 = "DCI1"
178 ChaMeasString3 = "SV1"
179 ChaMeasString4 = "MaxV1-MinV1"
180 ChaMeasString5 = "MaxI1-MinI1"
181 ChaMeasString6 = "math.sqrt(SV1**2 - DCV1**2)"
182 ChbMeasString1 = "DCV2"
183 ChbMeasString2 = "DCI2"
184 ChbMeasString3 = "SV2"
185 ChbMeasString4 = "MaxV2-MinV2"
186 ChbMeasString5 = "MaxI2-MinI2"
187 ChbMeasString6 = "math.sqrt(SV2**2 - DCV2**2)"
188 ChaLableSrring1 = "CHA-DCV "
189 ChaLableSrring2 = "CHA-DCI "
190 ChaLableSrring3 = "CHA-TRMS "
191 ChaLableSrring4 = "CHA-VP-P "
192 ChaLableSrring5 = "CHA-IP-P "
193 ChaLableSrring6 = "CHA-ACRMS "
194 ChbLableSrring1 = "CHB-DCV "
195 ChbLableSrring2 = "CHB-DCI "
196 ChbLableSrring3 = "CHB-TRMS "
197 ChbLableSrring4 = "CHB-VP-P "
198 ChbLableSrring5 = "CHB-IP-P "
199 ChbLableSrring6 = "CHB-ACRMS "
200 LabelPlotText = IntVar(0)
201 PlotLabelText = "Custom Plot Label"
202 
203 GridWidth = IntVar(0)
204 GridWidth.set(1)
205 TRACEwidth = IntVar(0)
206 TRACEwidth.set(1)
207 TRACEaverage = IntVar(0) # Number of average sweeps for average mode
208 TRACEaverage.set(8)
209 Vdiv = IntVar(0)
210 Vdiv.set(10) # Number of vertical divisions for spectrum / Bode
211 LPFTrigger = IntVar(0) # trigger lpf on/off
212 Trigger_LPF_length = IntVar(0)
213 Trigger_LPF_length.set(10) # Length of Trigger box car LPF in samples
214 HarmonicMarkers = IntVar(0)
215 HarmonicMarkers.set(3)
216 AWGShowAdvanced = IntVar(0)
217 AWGShowAdvanced.set(0)
218 AWG_Amp_Mode = IntVar(0)
219 AWG_Amp_Mode.set(0) # 0 = Min/Max mode, 1 = Amp/Offset
220 AWGA_Ext_Gain = DoubleVar(0)
221 AWGA_Ext_Gain.set(1.0)
222 AWGA_Ext_Offset = DoubleVar(0)
223 AWGA_Ext_Offset.set(0.0)
224 AWGB_Ext_Gain = DoubleVar(0)
225 AWGB_Ext_Gain.set(1.0)
226 AWGB_Ext_Offset = DoubleVar(0)
227 AWGB_Ext_Offset.set(0.0)
228 AWG_2X = IntVar(0) # selection variable to set AWG DAC channes for 2X samplerate modes
229 Two_X_Sample = IntVar(0) # selection variable to set ADC channes for 2X samplerate mode
230 Two_X_Sample.set(0)
231 ADC_Mux_Mode = IntVar(0) # selection variable to set ADC CHA for voltagr or current 2X samplerate mode
232 ADC_Mux_Mode.set(0)
233 Last_ADC_Mux_Mode = 0
234 Alternate_Sweep_Mode = IntVar(0) # alternate sweeps when in 2X samplerate mode
235 Alternate_Sweep_Mode.set(0)
236 #
237 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
238 ZEROstuffing.set(1)
239 FFTwindow = IntVar(0) # FFT window function variable
240 FFTwindow.set(5) # FFTwindow 0=None (rectangular B=1), 1=Cosine (B=1.24), 2=Triangular non-zero endpoints (B=1.33),
241  # 3=Hann (B=1.5), 4=Blackman (B=1.73), 5=Nuttall (B=2.02), 6=Flat top (B=3.77)
242 RelPhaseCorrection = 15 # Relative Phase error seems to be a random number each time board is powered up
243 RelPhaseCenter = IntVar(0)
244 RelPhaseCenter.set(0) # Center line value for phase plots
245 ImpedanceCenter = IntVar(0)
246 ImpedanceCenter.set(0) # Center line value for impedance plots
247 MultipleBoards = IntVar(0)
248 MultipleBoards.set(0) # Turn on access for multiple m1k boards
249 IgnoreFirmwareCheck = 0
250 EnableXYPlotter = 1
251 EnablePhaseAnalizer = 1
252 EnableSpectrumAnalizer = 1
253 EnableBodePlotter = 1
254 EnableImpedanceAnalizer = 1
255 EnableOhmMeter = 1
256 EnableDigIO = 1
257 EnableCommandInterface = 0
258 EnableMuxMode = 0
259 EnablePIODACMode = 0
260 EnableMinigenMode = 0
261 EnablePmodDA1Mode = 0
262 EnableDigPotMode = 0
263 EnableGenericSerialMode = 0
264 EnableAD5626SerialMode = 0
265 EnableDigitalFilter = 0
266 EnableMeasureScreen = 0
267 EnableETSScreen = 0
268 EnableHSsampling = 0
269 AllowFlashFirmware = 0
270 DeBugMode = 0
271 ShowTraceControls = 0
272 # ADC Mux defaults
273 v1_adc_conf = 0x20F1
274 i1_adc_conf = 0x20F7
275 v2_adc_conf = 0x20F7
276 i2_adc_conf = 0x20F1
277 #
278 MouseFocus = 1
279 HistAsPercent = 0
280 ShowBallonHelp = 0
281 contloop = 0
282 discontloop = 0
283 AwgLayout = "Horz"
284 MarkerLoc = 'UL' # can be UL, UR, LL or LR
285 CHA_TC1 = DoubleVar(0)
286 CHA_TC1.set(1)
287 CHA_TC2 = DoubleVar(0)
288 CHA_TC2.set(1)
289 CHB_TC1 = DoubleVar(0)
290 CHB_TC1.set(1)
291 CHB_TC2 = DoubleVar(0)
292 CHB_TC2.set(1)
293 CHA_A1 = DoubleVar(0)
294 CHA_A1.set(1)
295 CHA_A2 = DoubleVar(0)
296 CHA_A2.set(1)
297 CHB_A1 = DoubleVar(0)
298 CHB_A1.set(1)
299 CHB_A2 = DoubleVar(0)
300 CHB_A2.set(1)
301 Auto_ETS_Comp = IntVar(0)
302 ETS_TC1 = DoubleVar(0)
303 ETS_TC1.set(0.18333)
304 ETS_A1 = DoubleVar(0)
305 ETS_A1.set(5.0)
306 ETS_TC2 = DoubleVar(0)
307 ETS_TC2.set(0.03)
308 ETS_A2 = DoubleVar(0)
309 ETS_A2.set(5.0)
310 PhaseOffset1x = 37
311 PhaseOffset2x = 37
312 #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
313 # 'aqua' built-in native Mac OS X only; Native Mac OS X
314 if (root.tk.call('tk', 'windowingsystem')=='aqua'):
315  Style_String = 'aqua'
316 else:
317  Style_String = 'alt'
318 # Check if there is an alice_init.ini file to read in
319 try:
320  InitFile = open("alice_init.ini")
321  for line in InitFile:
322  try:
323  exec( line.rstrip() )
324  except:
325  print("Skiping " + line.rstrip())
326  InitFile.close()
327 except:
328  print( "No Init File Read")
329 #
330 X0L = FontSize * 7
331 XOLF = XOLBP = XOLXY = XOLIA = int(FontSize * 4.625)
332 XOLNqP = XOLNiC = int(FontSize * 3.125)
333 root.style = Style()
334 try:
335  root.style.theme_use(Style_String)
336 except:
337  root.style.theme_use('default')
338 if MouseFocus == 1:
339  root.tk_focusFollowsMouse()
340 #
341 DevID = "m1k"
342 #
343 if sys.version_info[0] == 2:
344  default_font = tkFont.nametofont("TkDefaultFont")
345 if sys.version_info[0] == 3:
346  default_font = tkinter.font.nametofont("TkDefaultFont")
347 default_font.configure(size=FontSize)
348 
349 CHvpdiv = (0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0)
350 
351 CHipdiv = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
352 
353 TMpdiv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
354 ResScalediv = (1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000)
355 SampRateList = (1024, 2048, 4096, 8192, 16384, 32765, 64000, 93023, 93385, 93750, 94118,
356  96385, 96774, 97166, 97561, 97959, 98361, 98765, 99174, 99585, 100000)
357 TIMEdiv = 0.5
358 RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
359 
360 
361 AWGAAmplvalue = 0.0
362 AWGAOffsetvalue = 0.0
363 AWGAFreqvalue = 0.0
364 AWGAPhasevalue = 0
365 AWGAdelayvalue = 0
366 AWGADutyCyclevalue = 50
367 AWGAWave = 'dc'
368 AWGBAmplvalue = 0.0
369 AWGBOffsetvalue = 0.0
370 AWGBFreqvalue = 0.0
371 AWGBPhasevalue = 0
372 AWGBdelayvalue = 0
373 AWGBDutyCyclevalue = 50
374 AWGBWave = 'dc'
375 AWGACycles = 1
376 AWGBCycles = 1
377 AWGABurstDelay = 0
378 AWGBBurstDelay = 0
379 Reset_Freq = 300
380 MeasGateLeft = 0.0
381 MeasGateRight = 0.0 # in mSec
382 MeasGateNum = 0
383 MeasGateStatus = IntVar(0)
384 MeasGateStatus.set(0)
385 #
386 DCV1 = DCV2 = MinV1 = MaxV1 = MinV2 = MaxV2 = MidV1 = PPV1 = MidV2 = PPV2 = SV1 = SI1 = 0
387 
388 DCVMuxA = MinVMuxA = MaxVMuxA = MidVMuxA = PPVMuxA = SVMuxA = 0
389 DCVMuxB = MinVMuxB = MaxVMuxB = MidVMuxB = PPVMuxB = SVMuxB = 0
390 DCVMuxC = MinVMuxC = MaxVMuxC = MidVMuxC = PPVMuxC = SVMuxC = 0
391 DCVMuxD = MinVMuxD = MaxVMuxD = MidVMuxD = PPVMuxD = SVMuxD = 0
392 PeakVA = PeakVB = PeakIA = PeakIB = 0.0
393 PeakVMA = PeakVMB = PeakVMC = PeakVMD = 0.0
394 PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
395 PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = 0.0
396 PeakphaseVA = PeakphaseVB = PeakphaseIA = PeakphaseIB = PeakphaseVAB = 0.0
397 CHADCy = CHBDCy = 0
398 DCI1 = DCI2 = MinI1 = MaxI1 = MinI2 = MaxI2 = MidI1 = PPI1 = MidI2 = PPI2 = SV2 = SI2 = 0
399 CHAperiod = CHAfreq = CHBperiod = CHBfreq = 0
400 # Calibration coefficients
401 CHAVGain = CHBVGain = 1.0
402 CHAVOffset = CHBVOffset = 0.0
403 # Initialisation of general variables
404 CHAOffset = CHBOffset = CHBAOffset = CHBBOffset = CHBCOffset = CHBDOffset = 2.5
405 CHAIOffset = CHBIOffset = InOffA = InGainA = InOffB = InGainB = 0.0
406 # Other global variables required in various routines
407 CANVASwidth = GRW + 2 * X0L # The canvas width
408 CANVASheight = GRH + Y0T + (FontSize * 7) # The canvas height
409 
410 ADsignal1 = [] # Ain signal array channel A and B
411 VBuffA = []
412 VBuffB = []
413 IBuffA = []
414 IBuffB = []
415 VBuffMA = []
416 VBuffMB = []
417 VBuffMC = []
418 VBuffMD = []
419 VmemoryMuxA = []
420 VmemoryMuxB = []
421 VmemoryMuxC = []
422 VmemoryMuxD = []
423 #
424 VAresult = []
425 VBresult = []
426 IAresult = []
427 IBresult = []
428 PhaseIA = []
429 PhaseIB = []
430 PhaseVA = []
431 PhaseVB = []
432 DFiltACoef = [1]
433 DFiltBCoef = [1]
434 DigFiltA = IntVar(0)
435 DigFiltA.set(0)
436 DigFiltABoxCar = IntVar(0)
437 DigFiltBBoxCar = IntVar(0)
438 DigFiltB = IntVar(0)
439 DigFiltB.set(0)
440 DigBuffA = IntVar(0)
441 DigBuffB = IntVar(0)
442 DigBuffA.set(0)
443 DigBuffB.set(0)
444 VFilterA = {}
445 VFilterB = {}
446 SampleRateStatus = IntVar(0)
447 ETSStatus = IntVar(0)
448 ETSDisp = IntVar(0)
449 ETSDir = IntVar(0)
450 #
451 AWGAwaveform = []
452 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
453 AWGBwaveform = []
454 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
455 VmemoryA = numpy.ones(1) # The memory for averaging
456 VmemoryB = numpy.ones(1)
457 ImemoryA = numpy.ones(1) # The memory for averaging
458 ImemoryB = numpy.ones(1)
459 TRACEresetTime = True # True for first new trace, false for averageing
460 TRACEresetFreq = True # True for first new trace, false for averageing
461 AWGScreenStatus = IntVar(0)
462 
463 T1Vline = [] # Voltage Trace line channel A
464 T2Vline = [] # Voltage Trace line channel B
465 T1Iline = [] # Current Trace line channel A
466 T2Iline = [] # Current Trace line channel B
467 TMAVline = [] # Voltage Trace line MUX channel A
468 TMBVline = [] # Voltage Trace line MUX channel B
469 TMCVline = [] # Voltage Trace line MUX channel C
470 TMDVline = [] # Voltage Trace line MUX channel D
471 TMBRline = [] # V reference Trace line MUX channel B
472 TMCRline = [] # V reference line MUX channel C
473 TXYline = [] # XY Trace line
474 TXYRline = [] # XY reference trace line
475 Tmathline = [] # Math trace line
476 TMXline = [] # X math Trace line
477 TMYline = [] # Y math Trace line
478 T1VRline = [] # V reference Trace line channel A
479 T2VRline = [] # V reference Trace line channel B
480 T1IRline = [] # I reference Trace line channel A
481 T2IRline = [] # I reference Trace line channel B
482 TMRline = [] # Math reference Trace line
483 Triggerline = [] # Triggerline
484 Triggersymbol = [] # Trigger symbol
485 #
486 SHOWsamples = 4000 # Number of samples on the screen
487 SCstart = 0 # Start sample of the trace
488 HozPoss = 0.0
489 Is_Triggered = 0
490 #
491 TRACES = 1 # Number of traces 1 or 2
492 TRACESread = 0 # Number of traces that have been read from ALM
493 ScreenTrefresh = IntVar(0)
494 ScreenXYrefresh = IntVar(0)
495 #
496 NSteps = IntVar(0) # number of frequency sweep steps
497 NSteps.set(128)
498 LoopNum = IntVar(0)
499 LoopNum.set(1)
500 LastWindow = -1
501 LastSMPfft = 0
502 CurrentFreqX = X0LBP + 14
503 FBins = numpy.linspace(0, 50000, num=16384)
504 FStep = numpy.linspace(0, 16384, num=NSteps.get())
505 FSweepMode = IntVar(0)
506 FSweepCont = IntVar(0)
507 FStepSync = IntVar(0)
508 FSweepSync = IntVar(0)
509 ShowCA_VdB = IntVar(0) # curves to display variables
510 ShowCA_P = IntVar(0)
511 ShowCB_VdB = IntVar(0)
512 ShowCB_P = IntVar(0)
513 ShowMarkerBP = IntVar(0)
514 ShowCA_RdB = IntVar(0)
515 ShowCA_RP = IntVar(0)
516 ShowCB_RdB = IntVar(0)
517 ShowCB_RP = IntVar(0)
518 ShowMathBP = IntVar(0)
519 ShowRMathBP = IntVar(0)
520 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
521 FSweepAdB = []
522 FSweepBdB = []
523 FSweepAPh = []
524 FSweepBPh = []
525 NSweepSeriesR = []
526 NSweepSeriesX = []
527 NSweepSeriesMag = [] # in ohms
528 NSweepSeriesAng = [] # in degrees
529 NetworkScreenStatus = IntVar(0)
530 BDSweepFile = IntVar(0)
531 FileSweepFreq = []
532 FileSweepAmpl = []
533 #
534 MarkerNum = MarkerFreqNum = 0
535 ShowTCur = IntVar(0)
536 ShowVCur = IntVar(0)
537 TCursor = VCursor = 0
538 ShowXCur = IntVar(0)
539 ShowYCur = IntVar(0)
540 XCursor = YCursor = 0
541 ShowFCur = IntVar(0)
542 ShowdBCur = IntVar(0)
543 FCursor = dBCursor = 0
544 ShowBPCur = IntVar(0)
545 ShowBdBCur = IntVar(0)
546 BPCursor = BdBCursor = 0
547 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
548 PowerStatus = 1
549 TRIGGERsample = 0 # AD sample trigger point
550 DX = 0 # interpolated trigger point
551 
552 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
553 DBdivindex = IntVar(0) # 10 dB/div as initial value
554 DBdivindex.set(4)
555 DBlevel = IntVar(0) # Reference level
556 DBlevel.set(0)
557 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
558 DBdivindexBP.set(4)
559 DBlevelBP = IntVar(0) # Reference level
560 DBlevelBP.set(0)
561 hldn = 0
562 SpectrumScreenStatus = IntVar(0)
563 SmoothCurvesSA = IntVar(0)
564 SmoothCurvesBP = IntVar(0)
565 CutDC = IntVar(0)
566 IAScreenStatus = IntVar(0)
567 NqPScreenStatus = IntVar(0)
568 NqPDisp = IntVar(0)
569 NiCScreenStatus = IntVar(0)
570 NiCDisp = IntVar(0)
571 ImpedanceMagnitude = 0.0 # in ohms
572 ImpedanceAngle = 0.0 # in degrees
573 ImpedanceRseries = 0.0 # in ohms
574 ImpedanceXseries = 0.0 # in ohms
575 Show_Rseries = IntVar(0)
576 Show_Xseries = IntVar(0)
577 Show_Magnitude = IntVar(0)
578 Show_Angle = IntVar(0)
579 Show_RseriesRef = IntVar(0)
580 Show_XseriesRef = IntVar(0)
581 Show_MagnitudeRef = IntVar(0)
582 Show_AngleRef = IntVar(0)
583 
584 TIARline = []
585 TIAXline = []
586 TIAMagline = []
587 TIAAngline = []
588 TIAMline = []
589 TIAMRline = []
590 RefIARline = []
591 RefIAXline = []
592 RefIAMagline = []
593 RefIAAngline = []
594 IASource = IntVar(0)
595 
596 DisplaySeries = IntVar(0)
597 IA_Ext_Conf = IntVar(0)
598 IASweepSaved = IntVar(0)
599 OverRangeFlagA = 0
600 OverRangeFlagB = 0
601 PeakdbA = 10
602 PeakdbB = 10
603 PeakRelPhase = 0.0
604 PeakfreqA = 100
605 PeakfreqB = 1000
606 OhmStatus = IntVar(0)
607 OhmRunStatus = IntVar(0)
608 FFTbandwidth = 0 # The FFT bandwidth
609 FFTBuffA = [] # Clear the FFTBuff array for trace A
610 FFTBuffB = [] # Clear the FFTBuff array for trace B
611 FFTresultA = [] # FFT result CHA
612 PhaseA = []
613 FFTresultB = [] # FFT result CHB
614 PhaseB = []
615 FFTresultAB = []
616 FFTwindowname = "--" # The FFT window name
617 FFTmemoryA = numpy.ones(1) # The memory for averaging
618 PhaseMemoryA = numpy.ones(1)
619 FFTmemoryB = numpy.ones(1) # The memory for averaging
620 PhaseMemoryB = numpy.ones(1)
621 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
622 SMPfftpwrTwo.set(11)
623 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
624 Two28 = 268435456
625 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
626 
627 T1Fline = [] # Frequency Trace line channel A
628 T2Fline = [] # Frequency Trace line channel B
629 T1Pline = [] # Phase angle Trace line channel A - B
630 T2Pline = [] # Phase angle Trace line channel B - A
631 T1FRline = [] # F reference Trace line channel A
632 T2FRline = [] # F reference Trace line channel B
633 T1PRline = [] # Phase reference Trace line channel A - B
634 T2PRline = [] # Phase reference Trace line channel B - A
635 TFMline = [] # Frequency Math Trace
636 TFRMline = [] # Frequency reference Math Trace
637 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
638 FreqTraceMode.set(1)
639 
640 TAFline = [] # Bode Freq Trace line channel A
641 TBFline = [] # Bode Freq Trace line channel B
642 TAPline = [] # Bode Phase angle Trace line channel A - B
643 TBPline = [] # Bode Phase angle Trace line channel B - A
644 TAFRline = [] # Bode F reference Trace line channel A
645 TBFRline = [] # Bode F reference Trace line channel B
646 TAPRline = [] # Bode Phase reference Trace line channel A - B
647 TBPRline = [] # Bode Phase reference Trace line channel B - A
648 TBPMline = [] # Bode Frequency Math Trace
649 TBPRMline = [] # Bode Frequency reference Math Trace
650 #
651 MinSamplesSA = 64
652 MaxSamplesSA = 65536
653 #
654 MathScreenStatus = IntVar(0)
655 #
656 XYScreenStatus = IntVar(0)
657 Xsignal = IntVar(0) # Signal for X axis variable
658 Xsignal.set(1)
659 Ysignal = IntVar(0) # Signal for X axis variable
660 Ysignal.set(3)
661 ShowRXY = IntVar(0) # show reference XY trace
662 # show Analog Input Mux Variables
663 Show_CBA = IntVar(0)
664 Show_CBB = IntVar(0)
665 Show_CBC = IntVar(0)
666 Show_CBD = IntVar(0)
667 D0 = IntVar(0)
668 D1 = IntVar(0)
669 D2 = IntVar(0)
670 D3 = IntVar(0)
671 D4 = IntVar(0)
672 D5 = IntVar(0)
673 D6 = IntVar(0)
674 D7 = IntVar(0)
675 PIO_0 = 28
676 PIO_1 = 29
677 PIO_2 = 47
678 PIO_3 = 3
679 PIO_4 = 4
680 PIO_5 = 5
681 PIO_6 = 6
682 PIO_7 = 7
683 #
684 SCLKPort = IntVar(0)
685 SDATAPort = IntVar(0)
686 SLATCHPort = IntVar(0)
687 
688 
689 hipulse = """
690 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
691 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
692 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
693 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
694 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
695 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
696 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
697 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
698 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
699 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
700 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
701 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
702 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
703 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
704 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
705 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
706 """
707 hipulseimg = PhotoImage(data=hipulse)
708 
709 lowpulse = """
710 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
711 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
712 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
713 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
714 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
715 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
716 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
717 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
718 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
719 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
720 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
721 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
722 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
723 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
724 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
725 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
726 """
727 lowpulseimg = PhotoImage(data=lowpulse)
728 
729 class CreateToolTip(object):
730 
731  def __init__(self, widget, text='widget info'):
732  self.waittime = 500 #miliseconds
733  self.wraplength = 100 #pixels
734  self.widget = widget
735  self.text = text
736  self.widget.bind("<Enter>", self.enter)
737  self.widget.bind("<Leave>", self.leave)
738  self.widget.bind("<ButtonPress>", self.leave)
739  self.id = None
740  self.tw = None
741 
742  def enter(self, event=None):
743  self.schedule()
744 
745  def leave(self, event=None):
746  self.unschedule()
747  self.hidetip()
748 
749  def schedule(self):
750  self.unschedule()
751  self.id = self.widget.after(self.waittime, self.showtip)
752 
753  def unschedule(self):
754  id = self.id
755  self.id = None
756  if id:
757  self.widget.after_cancel(id)
758 
759  def showtip(self, event=None):
760  x = y = 0
761  x, y, cx, cy = self.widget.bbox("insert")
762  x += self.widget.winfo_rootx() + 25
763  y += self.widget.winfo_rooty() + 20
764  # creates a toplevel window
765  self.tw = Toplevel(self.widget)
766  # Leaves only the label and removes the app window
767  self.tw.wm_overrideredirect(True)
768  self.tw.wm_geometry("+%d+%d" % (x, y))
769  label = Label(self.tw, text=self.text, justify='left',
770  background="#ffffe0", relief='solid', borderwidth=1,
771  wraplength = self.wraplength)
772  label.pack(ipadx=1)
773 
774  def hidetip(self):
775  tw = self.tw
776  self.tw= None
777  if tw:
778  tw.destroy()
779 #
780 # =========== Start widgets routines =============================
781 
783 def BSaveConfig(filename):
784  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
785  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
786  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
787  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
788  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
789  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
790  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
791  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
792  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
793  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
794  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
795  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
796  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
797  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
798  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
799  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
800  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
801  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
802  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
803  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
804  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
805  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
806  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
807  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
808  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
809  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
810  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
811  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
812  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
813  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode
814  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
815  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
816  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
817  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
818  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
819  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
820  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
821  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
822  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
823  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
824  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
825  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
826  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
827  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
828  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
829  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
830  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
831  global AWGABurstFlag, AWGACycles, AWGABurstDelay
832  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
833  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
834  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
835  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
836  global DigFiltStatus, DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
837  global phawindow, PhAca, PhAScreenStatus, PhADisp
838  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA
839  global VScale, IScale, RefphEntry
840  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
841  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
842 
843  # open Config file for Write?
844  try:
845  ConfgFile = open(filename, "w")
846  except: # didn't work? then just return
847  return
848  # Save Window placements
849  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
850  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
851  ConfgFile.write('global GRW; GRW = ' + str(GRW) + '\n')
852  ConfgFile.write('global GRH; GRH = ' + str(GRH) + '\n')
853  # Windows configuration
854  ConfgFile.write('global MathString; MathString = "' + MathString + '"\n')
855  ConfgFile.write('global MathUnits; MathUnits = "' + MathUnits + '"\n')
856  ConfgFile.write('global MathAxis; MathAxis = "' + MathAxis + '"\n')
857  ConfgFile.write('global MathXString; MathXString = "' + MathXString + '"\n')
858  ConfgFile.write('global MathXUnits; MathXUnits = "' + MathXUnits + '"\n')
859  ConfgFile.write('global MathXAxis; MathXAxis = "' + MathXAxis + '"\n')
860  ConfgFile.write('global MathYString; MathYString = "' + MathYString + '"\n')
861  ConfgFile.write('global MathYUnits; MathYUnits = "' + MathYUnits + '"\n')
862  ConfgFile.write('global MathYAxis; MathYAxis = "' + MathYAxis + '"\n')
863  if MathScreenStatus.get() > 0:
864  ConfgFile.write('NewEnterMathControls()\n')
865  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
866  else:
867  ConfgFile.write('DestroyMathScreen()\n')
868  if XYScreenStatus.get() > 0:
869  ConfgFile.write('global GRWXY; GRWXY = ' + str(GRWXY) + '\n')
870  ConfgFile.write('global GRHXY; GRHXY = ' + str(GRHXY) + '\n')
871  ConfgFile.write('MakeXYWindow()\n')
872  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
873  ConfgFile.write('CHAsbxy.delete(0,END)\n')
874  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
875  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
876  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
877  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
878  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
879  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
880  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
881  ConfgFile.write('CHBsbxy.delete(0,END)\n')
882  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
883  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
884  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
885  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
886  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
887  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
888  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
889  else:
890  ConfgFile.write('DestroyXYScreen()\n')
891  if IAScreenStatus.get() > 0:
892  ConfgFile.write('global GRWIA; GRWIA = ' + str(GRWIA) + '\n')
893  ConfgFile.write('global GRHIA; GRHIA = ' + str(GRHIA) + '\n')
894  ConfgFile.write('MakeIAWindow()\n')
895  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
896  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
897  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
898  ConfgFile.write('RsystemEntry.delete(0,END)\n')
899  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
900  ConfgFile.write('ResScale.delete(0,END)\n')
901  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
902  ConfgFile.write('GainCorEntry.delete(0,END)\n')
903  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
904  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
905  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
906  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
907  else:
908  ConfgFile.write('DestroyIAScreen()\n')
909  if SpectrumScreenStatus.get() > 0:
910  ConfgFile.write('global GRWF; GRWF = ' + str(GRWF) + '\n')
911  ConfgFile.write('global GRHF; GRHF = ' + str(GRHF) + '\n')
912  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
913  ConfgFile.write('MakeSpectrumWindow()\n')
914  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
915  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
916  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
917  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
918  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
919  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
920  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
921  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
922  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
923  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
924  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
925  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
926  else:
927  ConfgFile.write('DestroySpectrumScreen()\n')
928  #
929  if DacScreenStatus.get() > 0:
930  ConfgFile.write('MakeDacScreen()\n')
931  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
932  else:
933  ConfgFile.write('DestroyDacScreen()\n')
934  if DigScreenStatus.get() > 0:
935  ConfgFile.write('MakeDigScreen()\n')
936  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
937  else:
938  ConfgFile.write('DestroyDigScreen()\n')
939  if EnableHSsampling > 0:
940  ConfgFile.write('FminEntry.delete(0,"end")\n')
941  ConfgFile.write('FminEntry.insert(0, ' + FminEntry.get() + ')\n')
942  ConfgFile.write('HtMulEntry.delete(0,"end")\n')
943  ConfgFile.write('HtMulEntry.insert(0, ' + HtMulEntry.get() + ')\n')
944  ConfgFile.write('Auto_ETS_Comp.set(' + str(Auto_ETS_Comp.get()) + ')\n')
945  try:
946  ConfgFile.write('ets_TC1Entry.delete(0,"end")\n')
947  ConfgFile.write('ets_TC1Entry.insert(0, ' + ets_TC1Entry.get() + ')\n')
948  ConfgFile.write('ETS_TC1.set(' + ets_TC1Entry.get() + ')\n')
949  ConfgFile.write('ets_A1Entry.delete(0,"end")\n')
950  ConfgFile.write('ets_A1Entry.insert(0, ' + ets_A1Entry.get() + ')\n')
951  ConfgFile.write('ETS_A1.set(' + ets_A1Entry.get() + ')\n')
952  ConfgFile.write('ets_TC2Entry.delete(0,"end")\n')
953  ConfgFile.write('ets_TC2Entry.insert(0, ' + ets_TC2Entry.get() + ')\n')
954  ConfgFile.write('ETS_TC2.set(' + ets_TC2Entry.get() + ')\n')
955  ConfgFile.write('ets_A2Entry.delete(0,"end")\n')
956  ConfgFile.write('ets_A2Entry.insert(0, ' + ets_A2Entry.get() + ')\n')
957  ConfgFile.write('ETS_A2.set(' + ets_A2Entry.get() + ')\n')
958  except:
959  ConfgFile.write('ETS_TC1.set(' + str(ETS_TC1.get()) + ')\n')
960  ConfgFile.write('ETS_A1.set(' + str(ETS_A1.get()) + ')\n')
961  ConfgFile.write('ETS_TC2.set(' + str(ETS_TC2.get()) + ')\n')
962  ConfgFile.write('ETS_A2.set(' + str(ETS_A2.get()) + ')\n')
963  if DigFiltStatus.get() == 1:
964  ConfgFile.write('MakeDigFiltWindow()\n')
965  ConfgFile.write('DigFiltABoxCar.set(' + str(DigFiltABoxCar.get()) + ')\n')
966  ConfgFile.write('DigFiltBBoxCar.set(' + str(DigFiltBBoxCar.get()) + ')\n')
967  ConfgFile.write('BCALenEntry.delete(0,"end")\n')
968  ConfgFile.write('BCALenEntry.insert(0, ' + BCALenEntry.get() + ')\n')
969  ConfgFile.write('BCBLenEntry.delete(0,"end")\n')
970  ConfgFile.write('BCBLenEntry.insert(0, ' + BCBLenEntry.get() + ')\n')
971  ConfgFile.write('BuildBoxCarA()\n')
972  ConfgFile.write('BuildBoxCarB()\n')
973  else:
974  ConfgFile.write('DestroyDigFiltScreen()\n')
975  if MinigenScreenStatus.get() == 1:
976  ConfgFile.write('MakeMinigenWindow()\n')
977  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
978  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
979  ConfgFile.write('MinigenFout.delete(0,END)\n')
980  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
981  ConfgFile.write('MinigenFclk.delete(0,END)\n')
982  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
983  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
984  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
985  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
986  else:
987  ConfgFile.write('DestroyMinigenScreen()\n')
988  if MuxScreenStatus.get() == 1:
989  ConfgFile.write('MakeMuxModeWindow()\n')
990  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
991  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
992  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
993  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
994  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
995  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
996  ConfgFile.write('CHB_Asb.delete(0,END)\n')
997  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
998  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
999  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
1000  ConfgFile.write('CHB_Csb.delete(0,END)\n')
1001  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
1002  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
1003  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
1004  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
1005  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
1006  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
1007  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
1008  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
1009  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
1010  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
1011  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
1012  else:
1013  ConfgFile.write('DestroyMuxScreen()\n')
1014  # Save Phase Anayzer stuff after Analog Mux in case they are both open
1015  if PhAScreenStatus.get() > 0:
1016  ConfgFile.write('global GRWPhA; GRWPhA = ' + str(GRWPhA) + '\n')
1017  ConfgFile.write('global GRHPhA; GRHPhA = ' + str(GRHPhA) + '\n')
1018  ConfgFile.write('MakePhAWindow()\n')
1019  ConfgFile.write("phawindow.geometry('+" + str(phawindow.winfo_x()) + '+' + str(phawindow.winfo_y()) + "')\n")
1020  ConfgFile.write('VScale.delete(0,END)\n')
1021  ConfgFile.write('VScale.insert(0, ' + str(VScale.get()) + ')\n')
1022  ConfgFile.write('IScale.delete(0,END)\n')
1023  ConfgFile.write('IScale.insert(0, ' + str(IScale.get()) + ')\n')
1024  ConfgFile.write('RefphEntry.delete(0,END)\n')
1025  ConfgFile.write('RefphEntry.insert(0, "' + str(RefphEntry.get()) + '")\n')
1026  if vat_btn.config('text')[-1] == 'OFF':
1027  ConfgFile.write('vat_btn.config(text="OFF", style="Stop.TButton")\n')
1028  else:
1029  ConfgFile.write('vat_btn.config(text="ON", style="Run.TButton")\n')
1030  if MuxScreenStatus.get() == 0: # these buttons do not exist if Mux screen open
1031  if vbt_btn.config('text')[-1] == 'OFF':
1032  ConfgFile.write('vbt_btn.config(text="OFF", style="Stop.TButton")\n')
1033  else:
1034  ConfgFile.write('vbt_btn.config(text="ON", style="Run.TButton")\n')
1035  if vabt_btn.config('text')[-1] == 'OFF':
1036  ConfgFile.write('vabt_btn.config(text="OFF", style="Stop.TButton")\n')
1037  else:
1038  ConfgFile.write('vabt_btn.config(text="ON", style="Run.TButton")\n')
1039  else: # But these do
1040  ConfgFile.write('ShowPB_A.set(' + str(ShowPB_A.get()) + ')\n')
1041  ConfgFile.write('ShowPB_B.set(' + str(ShowPB_B.get()) + ')\n')
1042  ConfgFile.write('ShowPB_C.set(' + str(ShowPB_C.get()) + ')\n')
1043  ConfgFile.write('ShowPB_D.set(' + str(ShowPB_D.get()) + ')\n')
1044  if iat_btn.config('text')[-1] == 'OFF':
1045  ConfgFile.write('iat_btn.config(text="OFF", style="Stop.TButton")\n')
1046  else:
1047  ConfgFile.write('iat_btn.config(text="ON", style="Run.TButton")\n')
1048  if ibt_btn.config('text')[-1] == 'OFF':
1049  ConfgFile.write('ibt_btn.config(text="OFF", style="Stop.TButton")\n')
1050  else:
1051  ConfgFile.write('ibt_btn.config(text="ON", style="Run.TButton")\n')
1052  #
1053  else:
1054  ConfgFile.write('DestroyPhAScreen()\n')
1055  if BodeScreenStatus.get() == 1:
1056  ConfgFile.write('global GRWBP; GRWBP = ' + str(GRWBP) + '\n')
1057  ConfgFile.write('global GRHBP; GRHBP = ' + str(GRHBP) + '\n')
1058  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1059  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
1060  ConfgFile.write('MakeBodeWindow()\n')
1061  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
1062  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
1063  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
1064  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
1065  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
1066  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
1067  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
1068  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
1069  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
1070  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
1071  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
1072  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
1073  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
1074  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
1075  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
1076  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
1077  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
1078  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
1079  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
1080  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
1081  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
1082  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
1083  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
1084  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
1085  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
1086  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
1087  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
1088  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
1089  else:
1090  ConfgFile.write('DestroyBodeScreen()\n')
1091  if MeasureStatus.get() == 1:
1092  # Save strings
1093  ConfgFile.write('global ChaLableSrring1; ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
1094  ConfgFile.write('global ChaLableSrring2; ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
1095  ConfgFile.write('global ChaLableSrring3; ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
1096  ConfgFile.write('global ChaLableSrring4; ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
1097  ConfgFile.write('global ChaLableSrring5; ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
1098  ConfgFile.write('global ChaLableSrring6; ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
1099  ConfgFile.write('global ChbLableSrring1; ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
1100  ConfgFile.write('global ChbLableSrring2; ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
1101  ConfgFile.write('global ChbLableSrring3; ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
1102  ConfgFile.write('global ChbLableSrring4; ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
1103  ConfgFile.write('global ChbLableSrring5; ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
1104  ConfgFile.write('global ChbLableSrring6; ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
1105  ConfgFile.write('global ChaMeasString1; ChaMeasString1 = "' + ChaMeasString1 + '"\n')
1106  ConfgFile.write('global ChaMeasString2; ChaMeasString2 = "' + ChaMeasString2 + '"\n')
1107  ConfgFile.write('global ChaMeasString3; ChaMeasString3 = "' + ChaMeasString3 + '"\n')
1108  ConfgFile.write('global ChaMeasString4; ChaMeasString4 = "' + ChaMeasString4 + '"\n')
1109  ConfgFile.write('global ChaMeasString5; ChaMeasString5 = "' + ChaMeasString5 + '"\n')
1110  ConfgFile.write('global ChaMeasString6; ChaMeasString6 = "' + ChaMeasString6 + '"\n')
1111  ConfgFile.write('global ChbMeasString1; ChbMeasString1 = "' + ChbMeasString1 + '"\n')
1112  ConfgFile.write('global ChbMeasString2; ChbMeasString2 = "' + ChbMeasString2 + '"\n')
1113  ConfgFile.write('global ChbMeasString3; ChbMeasString3 = "' + ChbMeasString3 + '"\n')
1114  ConfgFile.write('global ChbMeasString4; ChbMeasString4 = "' + ChbMeasString4 + '"\n')
1115  ConfgFile.write('global ChbMeasString5; ChbMeasString5 = "' + ChbMeasString5 + '"\n')
1116  ConfgFile.write('global ChbMeasString6; ChbMeasString6 = "' + ChbMeasString6 + '"\n')
1117  ConfgFile.write('MakeMeasureScreen()\n')
1118  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
1119  else:
1120  ConfgFile.write('DestroyMeasuewScreen()\n')
1121  if ETSStatus.get() == 1: #
1122  ConfgFile.write('MakeETSWindow()\n')
1123  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
1124  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
1125  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
1126  ConfgFile.write('FMulXEntry.delete(0,END)\n')
1127  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
1128  ConfgFile.write('DivXEntry.delete(0,END)\n')
1129  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
1130  ConfgFile.write('ETSts.delete(0,END)\n')
1131  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
1132  else:
1133  ConfgFile.write('DestroyETSScreen()\n')
1134  #
1135  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
1136  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
1137  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
1138  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
1139  ConfgFile.write('HozPossentry.delete(0,"end")\n')
1140  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
1141  ConfgFile.write('TMsb.delete(0,END)\n')
1142  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
1143  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
1144  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
1145  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
1146  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
1147  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
1148  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
1149  ConfgFile.write('Ysignal.set(' + str(Ysignal.get()) + ')\n')
1150  #
1151  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
1152  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
1153  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
1154  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
1155  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
1156  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
1157  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
1158  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
1159  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
1160  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
1161  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
1162  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
1163  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
1164  #
1165  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
1166  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
1167  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
1168  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1169  ConfgFile.write('CHAsb.delete(0,END)\n')
1170  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1171  ConfgFile.write('CHAIsb.delete(0,END)\n')
1172  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1173  #
1174  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1175  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1176  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1177  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1178  ConfgFile.write('CHBsb.delete(0,END)\n')
1179  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1180  ConfgFile.write('CHBIsb.delete(0,END)\n')
1181  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1182  # AWG stuff
1183  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1184  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1185  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1186  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1187  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1188  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1189  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1190  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1191  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1192  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1193  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1194  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1195  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1196  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1197  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1198  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1199  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1200  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1201  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1202  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1203  #
1204  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1205  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1206  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1207  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1208  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1209  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1210  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1211  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1212  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1213  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1214  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1215  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1216  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1217  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1218  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1219  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1220  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1221  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1222  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1223  #
1224  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1225  #
1226  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1227  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1228  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1229  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1230  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1231  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1232  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1233  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1234  #
1235  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1236  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1237  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1238  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1239  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1240  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1241  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1242  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1243  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1244  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1245  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1246  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1247  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1248  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1249  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1250  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1251  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1252  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1253  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1254  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1255  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1256  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1257  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1258  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1259  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1260  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1261  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1262  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1263  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1264  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1265  #
1266  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1267  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1268  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1269  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1270  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1271  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1272  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1273  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1274  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1275  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1276  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1277  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1278  #
1279  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1280  #
1281  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1282  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1283  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1284  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1285  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1286  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1287  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1288  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1289  # Save strings
1290  ConfgFile.write('global UserAString; UserAString = "' + UserAString + '"\n')
1291  ConfgFile.write('global UserALabel; UserALabel = "' + UserALabel + '"\n')
1292  ConfgFile.write('global UserBString; UserBString = "' + UserBString + '"\n')
1293  ConfgFile.write('global UserBLabel; UserBLabel = "' + UserBLabel + '"\n')
1294  ConfgFile.write('global AWGAMathString; AWGAMathString = "' + AWGAMathString + '"\n')
1295  ConfgFile.write('global AWGBMathString; AWGBMathString = "' + AWGBMathString + '"\n')
1296  ConfgFile.write('global FFTUserWindowString; FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1297  ConfgFile.write('global DigFilterAString; DigFilterAString = "' + DigFilterAString + '"\n')
1298  ConfgFile.write('global DigFilterBString; DigFilterBString = "' + DigFilterBString + '"\n')
1299  # save channel AC frequency compensation settings
1300  try:
1301  CHA_TC1.set(float(cha_TC1Entry.get()))
1302  CHA_TC2.set(float(cha_TC2Entry.get()))
1303  CHB_TC1.set(float(chb_TC1Entry.get()))
1304  CHB_TC2.set(float(chb_TC2Entry.get()))
1305  CHA_A1.set(float(cha_A1Entry.get()))
1306  CHA_A2.set(float(cha_A2Entry.get()))
1307  CHB_A1.set(float(chb_A1Entry.get()))
1308  CHB_A2.set(float(chb_A2Entry.get()))
1309  except:
1310  donothing()
1311  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1312  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1313  ConfgFile.write('CHAI_RC_HP.set(' + str(CHAI_RC_HP.get()) + ')\n')
1314  ConfgFile.write('CHBI_RC_HP.set(' + str(CHBI_RC_HP.get()) + ')\n')
1315  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1316  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1317  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1318  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1319  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1320  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1321  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1322  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1323  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1324  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1325  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1326  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1327  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1328  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1329  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1330  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1331  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1332  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1333  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1334  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1335  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1336  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1337  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1338  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1339 
1340  # extra Spectrum stuff
1341  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1342  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1343  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1344  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1345  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1346  #
1347  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1348  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1349  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1350  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1351  #
1352  ConfgFile.close()
1353 
1355  global iawindow
1356 
1357  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1358  BSaveConfig(filename)
1359 
1361  global freqwindow
1362 
1363  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1364  BSaveConfig(filename)
1365 
1367  global bodewindow
1368 
1369  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1370  BSaveConfig(filename)
1371 
1373  global root
1374  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1375  BSaveConfig(filename)
1376 
1377 def BLoadConfig(filename):
1378  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1379  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1380  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
1381  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1382  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1383  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1384  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1385  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1386  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1387  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1388  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1389  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1390  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1391  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1392  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1393  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1394  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1395  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1396  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1397  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1398  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1399  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1400  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1401  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1402  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1403  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1404  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1405  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
1406  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1407  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1408  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1409  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1410  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1411  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1412  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1413  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1414  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1415  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1416  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1417  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1418  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1419  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1420  global AWGABurstFlag, AWGACycles, AWGABurstDelay
1421  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
1422  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1423  global phawindow, PhAca, PhAScreenStatus, PhADisp
1424  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA
1425  global VScale, IScale, RefphEntry
1426  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
1427  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
1428 
1429  # Read configuration values from file
1430  try:
1431  ConfgFile = open(filename)
1432  for line in ConfgFile:
1433  try:
1434  exec( line.rstrip() )
1435  except:
1436  print( "Skipping " + line.rstrip())
1437  ConfgFile.close()
1438  if DevID != "No Device":
1439  BAWGAModeLabel()
1440  BAWGBModeLabel()
1441  BAWGAPhaseDelay()
1442  BAWGBPhaseDelay()
1443  UpdateAWGWin()
1444  TimeCheckBox()
1445  XYCheckBox()
1446  FreqCheckBox()
1447  BodeCheckBox()
1448  IACheckBox()
1449  OhmCheckBox()
1450 #
1451  time.sleep(0.05)
1452  ReMakeAWGwaves()
1453  session.end() # Add this to turn off outputs after first tiem loading a config?
1454  BTime()
1455  except:
1456  print( "Config File Not Found.")
1457 
1458 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1459  global AWGAShape, AWGBShape, BisCompA, AWGAShapeLabel, AWGBShapeLabel
1460 
1461  if AWGAShape.get()==9:
1462  AWGAMakeImpulse()
1463  AWGAShapeLabel.config(text = "Impulse") # change displayed value
1464  elif AWGAShape.get()==11:
1466  AWGAShapeLabel.config(text = "Trapazoid") # change displayed value
1467  elif AWGAShape.get()==15:
1468  AWGAMakeSSQ()
1469  AWGAShapeLabel.config(text = "SSQ Pulse") # change displayed value
1470  elif AWGAShape.get()==16:
1471  AWGAMakeRamp()
1472  AWGAShapeLabel.config(text = "Ramp") # change displayed value
1473  elif AWGAShape.get()==17:
1474  AWGAMakePWMSine()
1475  AWGAShapeLabel.config(text = "PWN Sine") # change displayed value
1476  elif AWGAShape.get()==18:
1478  AWGAShapeLabel.config(text = "Hi Res Sine") # change displayed value
1479  elif AWGAShape.get()==12:
1481  AWGAShapeLabel.config(text = "Up Down Ramp") # change displayed value
1482  elif AWGAShape.get()==14:
1483  AWGAMakeFourier()
1484  AWGAShapeLabel.config(text = "Fourier Series") # change displayed value
1485  elif AWGAShape.get()==19:
1486  AWGAMakeSinc()
1487  AWGAShapeLabel.config(text = "Sinc Pulse") # change displayed value
1488  elif AWGAShape.get()==20:
1489  AWGAMakePulse()
1490  AWGAShapeLabel.config(text = "Pulse") # change displayed value
1491  elif AWGAShape.get()==21:
1492  AWGAMakeFMSine()
1493  AWGAShapeLabel.config(text = "FM Sine") # change displayed value
1494  elif AWGAShape.get()==22:
1495  AWGAMakeAMSine()
1496  AWGAShapeLabel.config(text = "AM Sine") # change displayed value
1497  elif AWGAShape.get()==7:
1498  AWGAMakeUUNoise()
1499  AWGAShapeLabel.config(text = "UU Noise") # change displayed value
1500  elif AWGAShape.get()==8:
1501  AWGAMakeUGNoise()
1502  AWGAShapeLabel.config(text = "UG Noise") # change displayed value
1503  elif AWGAShape.get()==0:
1504  AWGAShapeLabel.config(text = "DC") # change displayed value
1505  elif AWGAShape.get()==2:
1506  AWGAShapeLabel.config(text = "Triangle") # change displayed value
1507  elif AWGAShape.get()==4:
1508  AWGAShapeLabel.config(text = "Square") # change displayed value
1509  elif AWGAShape.get()==3:
1510  AWGAShapeLabel.config(text = "Saw Tooth") # change displayed value
1511  elif AWGAShape.get()==5:
1512  AWGAShapeLabel.config(text = "Starestep") # change displayed value
1513  elif AWGAShape.get()==6:
1514  AWGAShapeLabel.config(text = "CSV File") # change displayed value
1515  elif AWGAShape.get()==13:
1516  AWGAShapeLabel.config(text = "Wav File") # change displayed value
1517  else:
1518  AWGAShapeLabel.config(text = "Other Shape") # change displayed value
1519 #
1520  if BisCompA.get() == 1:
1521  SetBCompA()
1522  if AWGBShape.get()==9:
1523  AWGBMakeImpulse()
1524  AWGBShapeLabel.config(text = "Impulse") # change displayed value
1525  elif AWGBShape.get()==11:
1527  AWGBShapeLabel.config(text = "Trapazoid") # change displayed value
1528  elif AWGBShape.get()==15:
1529  AWGBMakeSSQ()
1530  AWGBShapeLabel.config(text = "SSQ Pulse") # change displayed value
1531  elif AWGBShape.get()==16:
1532  AWGBMakeRamp()
1533  AWGBShapeLabel.config(text = "Ramp") # change displayed value
1534  elif AWGBShape.get()==17:
1535  AWGBMakePWMSine()
1536  AWGBShapeLabel.config(text = "PWN Sine") # change displayed value
1537  elif AWGBShape.get()==18:
1539  AWGBShapeLabel.config(text = "Hi Res Sine") # change displayed value
1540  elif AWGBShape.get()==12:
1542  AWGBShapeLabel.config(text = "Up Doen Ramp") # change displayed value
1543  elif AWGBShape.get()==14:
1544  AWGBMakeFourier()
1545  AWGBShapeLabel.config(text = "Fourier Series") # change displayed value
1546  elif AWGBShape.get()==19:
1547  AWGBMakeSinc()
1548  AWGBShapeLabel.config(text = "Sinc Pulse") # change displayed value
1549  elif AWGBShape.get()==20:
1550  AWGBMakePulse()
1551  AWGBShapeLabel.config(text = "Pulse") # change displayed value
1552  elif AWGBShape.get()==7:
1553  AWGBMakeUUNoise()
1554  AWGBShapeLabel.config(text = "UU Noise") # change displayed value
1555  elif AWGBShape.get()==8:
1556  AWGBMakeUGNoise()
1557  AWGBShapeLabel.config(text = "UG Noise") # change displayed value
1558  elif AWGBShape.get()==0:
1559  AWGBShapeLabel.config(text = "DC") # change displayed value
1560  elif AWGBShape.get()==2:
1561  AWGBShapeLabel.config(text = "Triangle") # change displayed value
1562  elif AWGBShape.get()==4:
1563  AWGBShapeLabel.config(text = "Square") # change displayed value
1564  elif AWGBShape.get()==3:
1565  AWGBShapeLabel.config(text = "Saw Tooth") # change displayed value
1566  elif AWGBShape.get()==5:
1567  AWGBShapeLabel.config(text = "Starestep") # change displayed value
1568  elif AWGBShape.get()==6:
1569  AWGBShapeLabel.config(text = "CSV File") # change displayed value
1570  elif AWGBShape.get()==13:
1571  AWGBShapeLabel.config(text = "Wav File") # change displayed value
1572  else:
1573  AWGBShapeLabel.config(text = "Other Shape") # change displayed value
1574  UpdateAwgCont()
1575  time.sleep(0.05)
1576 
1578  global iawindow
1579 
1580  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1581  BLoadConfig(filename)
1582 
1584  global freqwindow
1585 
1586  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1587  BLoadConfig(filename)
1588 
1590  global bodewindow
1591 
1592  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1593  BLoadConfig(filename)
1594 
1596  global root
1597 
1598  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1599  BLoadConfig(filename)
1600  UpdateTimeTrace()
1601 
1602 def BgColor():
1603  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus, PhAca, PhAScreenStatus
1604  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
1605 
1606  if ColorMode.get() > 0:
1607  COLORtext = "#000000" # 100% black
1608  COLORtrace4 = "#a0a000" # 50% yellow
1609  COLORtraceR4 = "#606000" # 25% yellow
1610  COLORcanvas = "#ffffff" # 100% white
1611  else:
1612  COLORcanvas = "#000000" # 100% black
1613  COLORtrace4 = "#ffff00" # 100% yellow
1614  COLORtraceR4 = "#808000" # 50% yellow
1615  COLORtext = "#ffffff" # 100% white
1616  ca.config(background=COLORcanvas)
1618  if SpectrumScreenStatus.get() > 0:
1619  Freqca.config(background=COLORcanvas)
1621  if XYScreenStatus.get() > 0:
1622  XYca.config(background=COLORcanvas)
1623  UpdateXYScreen()
1624  if PhAScreenStatus.get() > 0:
1625  PhAca.config(background=COLORcanvas)
1626  UpdatePhAScreen()
1627  if IAScreenStatus.get() > 0:
1628  IAca.config(background=COLORcanvas)
1629  UpdateIAScreen()
1630  if BodeScreenStatus.get() > 0:
1631  Bodeca.config(background=COLORcanvas)
1633 
1635  global CANVASwidth, CANVASheight
1636  global COLORtext, MarkerNum, ColorMode
1637  # ask for file name
1638  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
1639  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
1640  if MarkerNum > 0 or ColorMode.get() > 0:
1641  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
1642  else: # temp chnage text corlor to black
1643  COLORtext = "#000000"
1645  # first save postscript file
1646  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
1647  # now convert to bit map
1648  # img = Image.open("screen_shot.eps")
1649  # img.save("screen_shot.gif", "gif")
1650  COLORtext = "#ffffff"
1652 
1654  global CANVASwidthXY, CANVASheightXY, xywindow
1655  global COLORtext, MarkerNum, ColorMode, XYca
1656  # ask for file name
1657  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
1658  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
1659  if MarkerNum > 0 or ColorMode.get() > 0:
1660  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
1661  else: # temp chnage text corlor to black
1662  COLORtext = "#000000"
1663  UpdateXYScreen()
1664  # first save postscript file
1665  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
1666  # now convert to bit map
1667  # img = Image.open("screen_shot.eps")
1668  # img.save("screen_shot.gif", "gif")
1669  COLORtext = "#ffffff"
1670  UpdateXYScreen()
1671 
1673  global CANVASwidthIA, CANVASheightIA
1674  global COLORtext, IAca, ColorMode, iawindow
1675  # ask for file name
1676  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
1677  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
1678  if ColorMode.get() > 0:
1679  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
1680  else: # temp change text color to black for Black BG
1681  COLORtext = "#000000"
1682  UpdateIAScreen()
1683  # save postscript file
1684  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
1685  #
1686  COLORtext = "#ffffff"
1687  UpdateIAScreen()
1688 
1690  global CANVASwidthBP, CANVASheightBP
1691  global COLORtext, Bodeca, bodewindow
1692  # ask for file name
1693  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
1694  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
1695  if MarkerNum > 0 or ColorMode.get() > 0:
1696  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
1697  else: # temp change text color to black
1698  COLORtext = "#000000"
1700  # save postscript file
1701  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
1702  #
1703  COLORtext = "#ffffff"
1705 
1707  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
1708 
1709  # open file to save data
1710  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
1711  DataFile = open(filename, 'w')
1712  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
1713  for index in range(len(VBuffA)):
1714  TimePnt = float((index+0.0)/SAMPLErate)
1715  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
1716  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
1717  DataFile.close()
1718 
1720  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
1721 
1722  # ask user for channel to save
1723  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I or CB-I\n\nChannel:\n", initialvalue="CA-V")
1724  if (Channel == None): # If Cancel pressed, then None
1725  return
1726  # open file to save data
1727  filename = asksaveasfilename(defaultextension = ".txt", filetypes=[("Text Columns", "*.txt")])
1728  DataFile = open(filename, 'w')
1729  for index in range(len(VBuffA)):
1730  TimePnt = float((index+0.0)/SAMPLErate)
1731  if Channel == "CA-V":
1732  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
1733  elif Channel == "CA-I":
1734  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
1735  elif Channel == "CB-V":
1736  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
1737  elif Channel == "CB-I":
1738  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
1739  DataFile.close()
1740 
1742  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
1743 
1744  # Read values from CVS file
1745  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
1746  try:
1747  CSVFile = open(filename)
1748  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
1749  CSVFile.seek(0)
1750  csv_f = csv.reader(CSVFile, dialect)
1751  VBuffA = []
1752  VBuffB = []
1753  IBuffA = []
1754  IBuffB = []
1755  SHOWsamples = 0
1756  for row in csv_f:
1757  try:
1758  VBuffA.append(float(row[1]))
1759  IBuffA.append(float(row[2]))
1760  VBuffB.append(float(row[3]))
1761  IBuffB.append(float(row[4]))
1762  SHOWsamples = SHOWsamples + 1
1763  except:
1764  print( 'skipping non-numeric row')
1765  VBuffA = numpy.array(VBuffA)
1766  IBuffA = numpy.array(IBuffA)
1767  VBuffB = numpy.array(VBuffB)
1768  IBuffB = numpy.array(IBuffB)
1769  CSVFile.close()
1770  UpdateTimeTrace()
1771  except:
1772  showwarning("WARNING","No such file found or wrong format!")
1773 
1775 def BHelp():
1776 
1777  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
1778  webbrowser.open(url,new=2)
1779 
1780 def BAbout():
1781  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
1782 #Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.8/alice-desktop-1.3-setup.exe'
1783  try:
1784  if sys.version_info[0] == 2:
1785  u = urllib2.urlopen(Version_url)
1786  if sys.version_info[0] == 3:
1787  u = urllib.request.urlopen(Version_url)
1788  meta = u.info()
1789  time_string = str(meta.getheaders("Last-Modified"))
1790  except:
1791  time_string = "Unavailable"
1792  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
1793  "Last Released Version: " + time_string[7:18] + "\n" +
1794  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
1795  "Firmware Rev " + str(FWRevOne) + "\n" +
1796  "Board Serial Number " + DevID + "\n" +
1797  "Software is provided as is without any Warranty")
1798 
1800  global T1Vline, T2Vline, T1Iline, T2Iline
1801  global TXYline, Tmathline, TMRline, TXYRline
1802  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
1803  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
1804  global MuxScreenStatus, TMCRline, TMBRline, TMAVline, TMBVline, TMCVline, TMDVline
1805  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
1806 
1807  if ShowC1_V.get() == 1:
1808  T1VRline = T1Vline # V reference Trace line channel A
1809  if ShowC2_V.get() == 1:
1810  T2VRline = T2Vline # V reference Trace line channel B
1811  if ShowC1_I.get() == 1:
1812  T1IRline = T1Iline # I reference Trace line channel A
1813  if ShowC2_I.get() == 1:
1814  T2IRline = T2Iline # I reference Trace line channel B
1815  if MathTrace.get() > 0:
1816  TMRline = Tmathline # Math reference Trace line
1817  if MuxScreenStatus.get() > 0:
1818  if Show_CBA.get() > 0:
1819  T2VRline = TMAVline # V reference Trace line Mux channel A
1820  if Show_CBB.get() > 0:
1821  TMBRline = TMBVline # V reference Trace line Mux channel B
1822  if Show_CBC.get() > 0:
1823  TMCRline = TMCVline # V reference Trace line Mux channel C
1824  if Show_CBD.get() > 0:
1825  T2IRline = TMDVline # V reference Trace line Mux channel D
1826  if len(TXYline) > 4:
1827  TXYRline = TXYline # XY reference trace line
1828 
1829 def BSaveCal():
1830  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1831  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1832  global DevID
1833  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1834  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
1835  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1836  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1837 
1838  devidstr = DevID[17:31]
1839  filename = devidstr + "_O.cal"
1840  CalFile = open(filename, "w")
1841  #
1842  CalFile.write('CHAVGainEntry.delete(0,END)\n')
1843  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1844  CalFile.write('CHBVGainEntry.delete(0,END)\n')
1845  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1846  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
1847  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1848  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
1849  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1850  #
1851  CalFile.write('CHAIGainEntry.delete(0,END)\n')
1852  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1853  CalFile.write('CHBIGainEntry.delete(0,END)\n')
1854  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1855  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
1856  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1857  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
1858  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1859  #
1860  # save channel AC frequency compensation settings
1861  try:
1862  CHA_TC1.set(float(cha_TC1Entry.get()))
1863  CHA_TC2.set(float(cha_TC2Entry.get()))
1864  CHB_TC1.set(float(chb_TC1Entry.get()))
1865  CHB_TC2.set(float(chb_TC2Entry.get()))
1866  CHA_A1.set(float(cha_A1Entry.get()))
1867  CHA_A2.set(float(cha_A2Entry.get()))
1868  CHB_A1.set(float(chb_A1Entry.get()))
1869  CHB_A2.set(float(chb_A2Entry.get()))
1870  except:
1871  donothing()
1872  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1873  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1874  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1875  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1876  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1877  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1878  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1879  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1880  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1881  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1882  CalFile.write('cha_TC1Entry.delete(0,END)\n')
1883  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1884  CalFile.write('cha_TC2Entry.delete(0,END)\n')
1885  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1886  CalFile.write('chb_TC1Entry.delete(0,END)\n')
1887  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1888  CalFile.write('chb_TC2Entry.delete(0,END)\n')
1889  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1890  CalFile.write('cha_A1Entry.delete(0,END)\n')
1891  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1892  CalFile.write('cha_A2Entry.delete(0,END)\n')
1893  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1894  CalFile.write('chb_A1Entry.delete(0,END)\n')
1895  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1896  CalFile.write('chb_A2Entry.delete(0,END)\n')
1897  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1898 
1899  CalFile.close()
1900 
1901 def BLoadCal():
1902  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1903  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1904  global DevID
1905  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1906  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
1907  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1908  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1909 
1910  devidstr = DevID[17:31]
1911  filename = devidstr + "_O.cal"
1912  try:
1913  CalFile = open(filename)
1914  for line in CalFile:
1915  exec( line.rstrip() )
1916  CalFile.close()
1917  except:
1918  print( "Cal file for this device not found")
1919 
1921  global UserAString, UserALabel, MeasUserA
1922 
1923  TempString = UserALabel
1924  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
1925  if (UserALabel == None): # If Cancel pressed, then None
1926  MeasUserA.set(0)
1927  UserALabel = TempString
1928  return
1929  TempString = UserAString
1930  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
1931  if (UserAString == None): # If Cancel pressed, then None
1932  MeasUserA.set(0)
1933  UserAString = TempString
1934  return
1935  MeasUserA.set(1)
1936 
1938  global UserBString, UserBLabel, MeasUserB
1939 
1940  TempString = UserBLabel
1941  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
1942  if (UserBLabel == None): # If Cancel pressed, then None
1943  MeasUserB.set(0)
1944  UserBLabel = TempString
1945  return
1946  TempString = UserBString
1947  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
1948  if (UserBString == None): # If Cancel pressed, then None
1949  MeasUserB.set(0)
1950  UserBString = TempString
1951  return
1952  MeasUserB.set(1)
1953 #
1954 
1956  global LabelPlotText, PlotLabelText # = "Custom Plot Label"
1957 
1958  TempString = PlotLabelText
1959  PlotLabelText = askstring("Custom Label", "Current Plot Label: " + PlotLabelText + "\n\nNew Label:\n", initialvalue=PlotLabelText)
1960  if (PlotLabelText == None): # If Cancel pressed, then None
1961  LabelPlotText.set(0)
1962  PlotLabelText = TempString
1963  return
1964  LabelPlotText.set(1)
1965 
1967  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
1968  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
1969  global MathAxis, MathXAxis, MathYAxis, MathTrace
1970  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
1971  global formlab, xformlab, yformlab
1972 
1973  if MathScreenStatus.get() == 0:
1974  MathScreenStatus.set(1)
1975  #
1976  MathWindow = Toplevel()
1977  MathWindow.title("Math Formula " + SWRev + RevDate)
1978  MathWindow.resizable(FALSE,FALSE)
1979  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
1980  frame1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10R1.TLabelframe")
1981  frame2 = LabelFrame(MathWindow, text="Math Trace", style="A10R1.TLabelframe")
1982  frame3 = LabelFrame(MathWindow, text="X Math Trace", style="A10R1.TLabelframe")
1983  frame4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10R1.TLabelframe")
1984  # frame1.grid(row=0, column=0, sticky=W)
1985  #
1986  frame1.grid(row = 0, column=0, rowspan=3, sticky=W)
1987  frame2.grid(row = 0, column=1, sticky=W)
1988  frame3.grid(row = 1, column=1, sticky=W)
1989  frame4.grid(row = 2, column=1, sticky=W)
1990  #
1991  # Built in functions
1992  #
1993  rb1 = Radiobutton(frame1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
1994  rb1.grid(row=0, column=0, sticky=W)
1995  rb2 = Radiobutton(frame1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
1996  rb2.grid(row=1, column=0, sticky=W)
1997  rb3 = Radiobutton(frame1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
1998  rb3.grid(row=2, column=0, sticky=W)
1999  rb4 = Radiobutton(frame1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
2000  rb4.grid(row=3, column=0, sticky=W)
2001  rb5 = Radiobutton(frame1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
2002  rb5.grid(row=4, column=0, sticky=W)
2003  rb6 = Radiobutton(frame1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
2004  rb6.grid(row=5, column=0, sticky=W)
2005  rb7 = Radiobutton(frame1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
2006  rb7.grid(row=6, column=0, sticky=W)
2007  rb8 = Radiobutton(frame1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
2008  rb8.grid(row=7, column=0, sticky=W)
2009  rb9 = Radiobutton(frame1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
2010  rb9.grid(row=8, column=0, sticky=W)
2011  rb10 = Radiobutton(frame1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
2012  rb10.grid(row=9, column=0, sticky=W)
2013  rb11 = Radiobutton(frame1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
2014  rb11.grid(row=10, column=0, sticky=W)
2015  rb12 = Radiobutton(frame1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
2016  rb12.grid(row=11, column=0, sticky=W)
2017  rb13 = Radiobutton(frame1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
2018  rb13.grid(row=12, column=0, sticky=W)
2019  #
2020  # Math trace formula sub frame2
2021  #
2022  sframe2a = Frame( frame2 )
2023  sframe2a.pack(side=TOP)
2024  formlab = Label(sframe2a, text=" Formula ", style= "A10B.TLabel")
2025  formlab.pack(side=LEFT)
2026  formentry = Entry(sframe2a, width=23)
2027  formentry.pack(side=LEFT)
2028  formentry.delete(0,"end")
2029  formentry.insert(0,MathString)
2030  sframe2b = Frame( frame2 )
2031  sframe2b.pack(side=TOP)
2032  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
2033  unitslab.pack(side=LEFT)
2034  unitsentry = Entry(sframe2b, width=6)
2035  unitsentry.pack(side=LEFT)
2036  unitsentry.delete(0,"end")
2037  unitsentry.insert(0,MathUnits)
2038  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
2039  checkbt.pack(side=LEFT)
2040  sframe2c = Frame( frame2 )
2041  sframe2c.pack(side=TOP)
2042  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
2043  axislab.pack(side=LEFT)
2044  axisentry = Entry(sframe2c, width=3)
2045  axisentry.pack(side=LEFT)
2046  axisentry.delete(0,"end")
2047  axisentry.insert(0,MathAxis)
2048  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
2049  applybt.pack(side=LEFT)
2050  #
2051  # X Math trace formula sub frame3
2052  #
2053  sframe3a = Frame( frame3 )
2054  sframe3a.pack(side=TOP)
2055  xformlab = Label(sframe3a, text="X Formula ", style= "A10B.TLabel")
2056  xformlab.pack(side=LEFT)
2057  xformentry = Entry(sframe3a, width=23)
2058  xformentry.pack(side=LEFT)
2059  xformentry.delete(0,"end")
2060  xformentry.insert(0, MathXString)
2061  sframe3b = Frame( frame3 )
2062  sframe3b.pack(side=TOP)
2063  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
2064  xunitslab.pack(side=LEFT)
2065  xunitsentry = Entry(sframe3b, width=6)
2066  xunitsentry.pack(side=LEFT)
2067  xunitsentry.delete(0,"end")
2068  xunitsentry.insert(0, MathXUnits)
2069  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
2070  xcheckbt.pack(side=LEFT)
2071  sframe3c = Frame( frame3 )
2072  sframe3c.pack(side=TOP)
2073  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
2074  xaxislab.pack(side=LEFT)
2075  xaxisentry = Entry(sframe3c, width=3)
2076  xaxisentry.pack(side=LEFT)
2077  xaxisentry.delete(0,"end")
2078  xaxisentry.insert(0, MathXAxis)
2079  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
2080  xapplybt.pack(side=LEFT)
2081  #
2082  # Math trace formula sub frame4
2083  #
2084  sframe4a = Frame( frame4 )
2085  sframe4a.pack(side=TOP)
2086  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
2087  yformlab.pack(side=LEFT)
2088  yformentry = Entry(sframe4a, width=23)
2089  yformentry.pack(side=LEFT)
2090  yformentry.delete(0,"end")
2091  yformentry.insert(0,MathYString)
2092  sframe4b = Frame( frame4 )
2093  sframe4b.pack(side=TOP)
2094  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
2095  yunitslab.pack(side=LEFT)
2096  yunitsentry = Entry(sframe4b, width=6)
2097  yunitsentry.pack(side=LEFT)
2098  yunitsentry.delete(0,"end")
2099  yunitsentry.insert(0,MathYUnits)
2100  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
2101  ycheckbt.pack(side=LEFT)
2102  sframe4c = Frame( frame4 )
2103  sframe4c.pack(side=TOP)
2104  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
2105  yaxislab.pack(side=LEFT)
2106  yaxisentry = Entry(sframe4c, width=3)
2107  yaxisentry.pack(side=LEFT)
2108  yaxisentry.delete(0,"end")
2109  yaxisentry.insert(0,MathYAxis)
2110  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
2111  yapplybt.pack(side=LEFT)
2112 
2113  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
2114  dismissbutton.grid(row=3, column=0, sticky=W)
2115 
2116  if RUNstatus.get() > 0:
2117  UpdateTimeTrace()
2118 
2120  global MathScreenStatus, MathWindow
2121 
2122  if MathScreenStatus.get() == 1:
2123  MathScreenStatus.set(0)
2124  MathWindow.destroy()
2125 
2127  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
2128  global VBuffA, VBuffB, IBuffA, IBuffB
2129  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2130  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2131  global FFTBuffA, FFTBuffB, FFTwindowshape
2132  global AWGAwaveform, AWGBwaveform
2133  global Show_MathX, Show_MathY
2134  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2135  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2136 
2137  t = 0
2138  TempString = formentry.get()
2139  try:
2140  MathResult = eval(TempString)
2141  formlab.configure(text="Formula ", style= "A10G.TLabel")
2142  except:
2143  formlab.configure(text="Formula ", style= "A10R.TLabel")
2144 
2146  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
2147  global VBuffA, VBuffB, IBuffA, IBuffB
2148  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2149  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2150  global FFTBuffA, FFTBuffB, FFTwindowshape
2151  global AWGAwaveform, AWGBwaveform
2152  global Show_MathX, Show_MathY
2153  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2154  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2155 
2156  t = 0
2157  TempString = xformentry.get()
2158  try:
2159  MathResult = eval(TempString)
2160  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
2161  except:
2162  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
2163 
2165  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
2166  global VBuffA, VBuffB, IBuffA, IBuffB
2167  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2168  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2169  global FFTBuffA, FFTBuffB, FFTwindowshape
2170  global AWGAwaveform, AWGBwaveform
2171  global Show_MathX, Show_MathY
2172  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2173  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2174 
2175  t = 0
2176  TempString = yformentry.get()
2177  try:
2178  MathResult = eval(TempString)
2179  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
2180  except:
2181  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
2182 
2184  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
2185 
2186  MathString = formentry.get()
2187  MathUnits = unitsentry.get()
2188  MathAxis = axisentry.get()
2189 
2191  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
2192 
2193  MathXString = xformentry.get()
2194  MathXUnits = xunitsentry.get()
2195  MathXAxis = xaxisentry.get()
2196 
2198  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
2199 
2200  MathYString = yformentry.get()
2201  MathYUnits = yunitsentry.get()
2202  MathYAxis = yaxisentry.get()
2203 
2205  global MarkerLoc
2206 
2207  TempString = MarkerLoc
2208  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
2209  if (MarkerLoc == None): # If Cancel pressed, then None
2210  MarkerLoc = TempString
2211  UpdateTimeTrace()
2212 
2214  global RUNstatus
2215 
2216 def DoNothing(event):
2217  global RUNstatus
2218 
2220  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
2221  ShowC1_V.set(1)
2222  ShowC1_I.set(1)
2223  ShowC2_V.set(1)
2224  ShowC2_I.set(1)
2225  UpdateTimeTrace()
2226 
2228  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
2229  ShowC1_V.set(0)
2230  ShowC1_I.set(0)
2231  ShowC2_V.set(0)
2232  ShowC2_I.set(0)
2233  UpdateTimeTrace()
2234 
2236  global TgEdge
2237 
2238 # TRIGCOND trigcondRisingPositive = 0
2239 # TRIGCOND trigcondFallingNegative = 1
2240 
2242  global TgInput, TRIGGERlevel, TRIGGERentry
2243  global MaxV1, MinV1, MaxV2, MinV2
2244  global MaxI1, MinI1, MaxI2, MinI2
2245  # set new trigger level to mid point of waveform
2246  MidV1 = (MaxV1+MinV1)/2
2247  MidV2 = (MaxV2+MinV2)/2
2248  MidI1 = (MaxI1+MinI1)/2
2249  MidI2 = (MaxI2+MinI2)/2
2250  if (TgInput.get() == 0):
2251  DCString = "0.0"
2252  elif (TgInput.get() == 1 ):
2253  DCString = ' {0:.2f} '.format(MidV1)
2254  elif (TgInput.get() == 2 ):
2255  DCString = ' {0:.2f} '.format(MidI1)
2256  elif (TgInput.get() == 3 ):
2257  DCString = ' {0:.2f} '.format(MidV2)
2258  elif (TgInput.get() == 4 ):
2259  DCString = ' {0:.2f} '.format(MidI2)
2260 
2261  TRIGGERlevel = eval(DCString)
2262  TRIGGERentry.delete(0,END)
2263  TRIGGERentry.insert(4, DCString)
2264 
2265  UpdateTimeTrace() # Always Update
2266 
2268  global TgInput
2269 
2270 # if (TgInput.get() == 0):
2271  # no trigger
2272 # elif (TgInput.get() == 1):
2273  # trigger source set to detector of analog in channels
2274  # auto trigger timeout value
2275 # elif (TgInput.get() == 2):
2276  # trigger source set to detector of analog in channels
2277  # 0 disables auto trigger
2278 
2279 def BTriglevel(event):
2280  global TRIGGERlevel, TRIGGERentry
2281 
2282  # evalute entry string to a numerical value
2283  try:
2284  TRIGGERlevel = float(eval(TRIGGERentry.get()))
2285  except:
2286  TRIGGERentry.delete(0,END)
2287  TRIGGERentry.insert(0, TRIGGERlevel)
2288  # set new trigger level
2289 
2290  UpdateTimeTrace() # Always Update
2291 
2292 def BHoldOff(event):
2293  global HoldOff, HoldOffentry
2294 
2295  try:
2296  HoldOff = float(eval(HoldOffentry.get()))
2297  except:
2298  HoldOffentry.delete(0,END)
2299  HoldOffentry.insert(0, HoldOff)
2300 # Set Horx possition from entry widget
2301 def BHozPoss(event):
2302  global HozPoss, HozPossentry
2303 
2304  try:
2305  HozPoss = float(eval(HozPossentry.get()))
2306  except:
2307  HozPossentry.delete(0,END)
2308  HozPossentry.insert(0, HozPoss)
2309 #
2311  global HozPossentry, TgInput, TMsb
2312 
2313  # get time scale
2314  try:
2315  TIMEdiv = float(eval(TMsb.get()))
2316  except:
2317  TIMEdiv = 0.5
2318  TMsb.delete(0,"end")
2319  TMsb.insert(0,TIMEdiv)
2320  # prevent divide by zero error
2321  if TIMEdiv < 0.0002:
2322  TIMEdiv = 0.01
2323  if TgInput.get() > 0:
2324  HozPoss = -5 * TIMEdiv
2325  HozPossentry.delete(0,END)
2326  HozPossentry.insert(0, HozPoss)
2327 #
2329  global HoldOffentry, HoldOff, TgInput, TMsb
2330 
2331 # get time scale
2332  try:
2333  TIMEdiv = float(eval(TMsb.get()))
2334  except:
2335  TIMEdiv = 0.5
2336  TMsb.delete(0,"end")
2337  TMsb.insert(0,TIMEdiv)
2338  # prevent divide by zero error
2339  if TIMEdiv < 0.0002:
2340  TIMEdiv = 0.01
2341  if TgInput.get() == 0:
2342  HoldOff = HoldOff + TIMEdiv
2343  HoldOffentry.delete(0,END)
2344  HoldOffentry.insert(0, HoldOff)
2345 
2347  global CHB_APosEntry, DCVMuxA
2348 
2349  CHB_APosEntry.delete(0,"end")
2350  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
2351 #
2353  global CHB_BPosEntry, DCVMuxB
2354 
2355  CHB_BPosEntry.delete(0,"end")
2356  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
2357 #
2359  global CHB_CPosEntry, DCVMuxC
2360 
2361  CHB_CPosEntry.delete(0,"end")
2362  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
2363 #
2365  global CHD_BPosEntry, DCVMuxD
2366 
2367  CHB_DPosEntry.delete(0,"end")
2368  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
2369 #
2371  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2372 
2373  if MarkerScale.get() != 1:
2374  MarkerScale.set(5)
2375  CHB_Alab.config(style="Rtrace2.TButton")
2376  CHB_Blab.config(style="Strace6.TButton")
2377  CHB_Clab.config(style="Strace7.TButton")
2378  CHB_Dlab.config(style="Strace4.TButton")
2379  else:
2380  MarkerScale.set(0)
2381 #
2383  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2384 
2385  if MarkerScale.get() != 1:
2386  MarkerScale.set(6)
2387  CHB_Alab.config(style="Strace2.TButton")
2388  CHB_Blab.config(style="Rtrace6.TButton")
2389  CHB_Clab.config(style="Strace7.TButton")
2390  CHB_Dlab.config(style="Strace4.TButton")
2391  else:
2392  MarkerScale.set(0)
2393 #
2395  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2396 
2397  if MarkerScale.get() != 1:
2398  MarkerScale.set(7)
2399  CHB_Alab.config(style="Strace2.TButton")
2400  CHB_Blab.config(style="Strace6.TButton")
2401  CHB_Clab.config(style="Rtrace7.TButton")
2402  CHB_Dlab.config(style="Strace4.TButton")
2403  else:
2404  MarkerScale.set(0)
2405 #
2407  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2408 
2409  if MarkerScale.get() != 1:
2410  MarkerScale.set(8)
2411  CHB_Alab.config(style="Strace2.TButton")
2412  CHB_Blab.config(style="Strace6.TButton")
2413  CHB_Clab.config(style="Strace7.TButton")
2414  CHB_Dlab.config(style="Rtrace4.TButton")
2415  else:
2416  MarkerScale.set(0)
2417 #
2419  global CHAVPosEntry, DCV1
2420 
2421  CHAVPosEntry.delete(0,"end")
2422  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
2423 #
2425  global CHBVPosEntry, DCV2
2426 
2427  CHBVPosEntry.delete(0,"end")
2428  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
2429 #
2431  global CHAIPosEntry, DCI1
2432 
2433  CHAIPosEntry.delete(0,"end")
2434  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
2435 #
2437  global CHBIPosEntry, DCI2
2438 
2439  CHBIPosEntry.delete(0,"end")
2440  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
2441 #
2443  global CHAVPosEntryxy, DCV1
2444 
2445  CHAVPosEntryxy.delete(0,"end")
2446  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
2447 #
2449  global CHBVPosEntryxy, DCV2
2450 
2451  CHBVPosEntryxy.delete(0,"end")
2452  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
2453 #
2455  global CHAIPosEntryxy, DCI1
2456 
2457  CHAIPosEntryxy.delete(0,"end")
2458  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
2459 #
2461  global CHBIPosEntryxy, DCI2
2462 
2463  CHBIPosEntryxy.delete(0,"end")
2464  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
2465 
2467  global RUNstatus, session, CHA, CHB, devx, AWG_2X
2468 
2469  RUNstatus.set(0)
2470  # BSaveConfig("alice-last-config.cfg")
2471  try:
2472  # try to write last config file, Don't crash if running in Write protected space
2473  BSaveConfig("alice-last-config.cfg")
2474  # Put channels in Hi-Z and exit
2475  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2476  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2477  devx.set_adc_mux(0) # set ADC mux conf to default
2478  AWG_2X.set(0)
2479  BAWG2X()
2480  CHA.constant(0.0)
2481  CHB.constant(0.0)
2482  devx.set_led(0b001) # Set LED.red on the way out
2483  if session.continuous:
2484  session.end()
2485  except:
2486  donothing()
2487 
2488  root.destroy()
2489  exit()
2490 
2491 def BStart():
2492  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
2493  global contloop, discontloop, TIMEdiv, First_Slow_sweep
2494 
2495  if DevID == "No Device":
2496  showwarning("WARNING","No Device Plugged In!")
2497  elif FWRevOne == 0.0:
2498  showwarning("WARNING","Out of data Firmware!")
2499  else:
2500  if PowerStatus == 0:
2501  PowerStatus = 1
2502  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2503  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2504  if (RUNstatus.get() == 0):
2505  RUNstatus.set(1)
2506  if AWGSync.get() == 0:
2507  session.flush()
2508  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2509  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2510  BAWGEnab()
2511  if not session.continuous:
2512  session.start(0)
2513  time.sleep(0.02) # wait awhile here for some reason
2514  elif session.continuous:
2515  session.end()
2516  session.flush()
2517  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2518  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2519 
2531  BAWGEnab()
2532  else:
2533  contloop = 0
2534  discontloop = 1
2535  if session.continuous:
2536  session.end() # end continuous session mode
2537 
2538  # UpdateTimeScreen() # Always Update
2539  if TIMEdiv >= 100:
2540  First_Slow_sweep = 0
2541  else:
2542  First_Slow_sweep = 1
2543 #$ Start running Ohmmeter tool
2545  global session, AWGSync
2546 
2547  AWGSync.set(1)
2548  if AWGSync.get() == 0:
2549  session.flush()
2550  if not session.continuous:
2551  session.start(0)
2552  time.sleep(0.02) # wait awhile here for some reason
2553  elif session.continuous:
2554  session.end()
2555  session.flush()
2556  else:
2557  contloop = 0
2558  discontloop = 1
2559  if session.continuous:
2560  session.end() # end continuous session mode
2561 
2562 def BStartIA():
2563  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne
2564 
2565  try:
2566  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
2567  except:
2568  AWGAFreqEntry.delete(0,"end")
2569  AWGAFreqEntry.insert(0, AWGAFreqvalue)
2570  if FWRevOne > 2.16:
2571  if AWGAFreqvalue > 20000.0:
2572  Two_X_Sample.set(1)
2573  else:
2574  Two_X_Sample.set(0)
2575  SetADC_Mux()
2576  IASourceSet()
2577  BStart()
2578 
2580  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode, AWGSync
2581 
2582  if AWGSync.get() == 0: # running in continuous mode
2583  AWGSync.set(1)
2584  if IASource.get() == 1:
2585  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
2586  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
2587  AWGAMode.set(2) # Set AWG A to Hi-Z
2588  else:
2589  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
2590  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
2591  AWGAMode.set(0) # Set AWG A to SVMI
2592  if AWGBIOMode.get() == 0: # if not in split I/O mode
2593  AWGBMode.set(2) # Set AWG B to Hi-Z
2594 
2595 def BStop():
2596  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
2597  global CHA, CHB, contloop, discontloop
2598 
2599  if (RUNstatus.get() == 1):
2600  # print("Stoping")
2601  RUNstatus.set(0)
2602  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2603  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2604  if AWGSync.get() == 0: # running in continuous mode
2605  CHA.constant(0.0)
2606  CHB.constant(0.0)
2607  # print("Stoping continuous mode")
2608  # session.cancel() # cancel continuous session mode while paused
2609  if session.continuous:
2610  #print( "Is Continuous? ", session.continuous)
2611  session.end()
2612  #time.sleep(0.02)
2613  #print( "Is Continuous? ", session.continuous)
2614  else:
2615  contloop = 0
2616  discontloop = 1
2617  session.cancel()
2618 #
2619  if TimeDisp.get() > 0:
2620  UpdateTimeScreen() # Always Update screens as necessary
2621  if XYDisp.get() > 0:
2622  UpdateXYScreen()
2623  if FreqDisp.get() > 0:
2625  if IADisp.get() > 0:
2626  UpdateIAScreen()
2627 
2628 def BPower():
2629  global RUNstatus, PowerStatus, devx, PwrBt
2630 
2631  if (RUNstatus.get() == 1):
2632  BStop()
2633  if PowerStatus == 1:
2634  PowerStatus = 0
2635  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
2636  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
2637  else:
2638  PowerStatus = 1
2639  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2640  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2641 
2642 def BTime():
2643  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne
2644 
2645  try: # get time scale in mSec/div
2646  TIMEdiv = float(eval(TMsb.get()))
2647  if TIMEdiv < 0.0002:
2648  TIMEdiv = 0.01
2649  TMsb.delete(0,"end")
2650  TMsb.insert(0,TIMEdiv)
2651  except:
2652  TIMEdiv = 0.5
2653  TMsb.delete(0,"end")
2654  TMsb.insert(0,TIMEdiv)
2655  # Switch to 2X sampleling if time scale small enough and not runing ETS
2656  if ETSDisp.get() == 0:
2657  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
2658  if FWRevOne > 2.16:
2659  if Samples_per_div < 20.0:
2660  Two_X_Sample.set(1)
2661  else:
2662  Two_X_Sample.set(0)
2663  SetADC_Mux()
2664  #
2665  if RUNstatus.get() == 2: # Restart if running
2666  RUNstatus.set(4)
2667 
2668  UpdateTimeTrace() # Always Update
2669 
2671  global CHAsb
2672 
2673  try:
2674  CH1vpdvLevel = float(eval(CHAsb.get()))
2675  except:
2676  CHAsb.delete(0,END)
2677  CHAsb.insert(0, CH1vpdvLevel)
2678  UpdateTimeTrace() # Always Update
2679 
2681  global CHAIsb
2682 
2683  try:
2684  CH1ipdvLevel = float(eval(CHAIsb.get()))
2685  except:
2686  CHAIsb.delete(0,END)
2687  CHAIsb.insert(0, CH1ipdvLevel)
2688  UpdateTimeTrace() # Always Update
2689 
2691  global CHBsb
2692 
2693  try:
2694  CH2vpdvLevel = float(eval(CHBsb.get()))
2695  except:
2696  CHBsb.delete(0,END)
2697  CHBsb.insert(0, CH2vpdvLevel)
2698  UpdateTimeTrace() # Always Update
2699 
2701  global CHBIsb
2702 
2703  try:
2704  CH2ipdvLevel = float(eval(CHBIsb.get()))
2705  except:
2706  CHBIsb.delete(0,END)
2707  CHBIsb.insert(0, CH2ipdvLevel)
2708  UpdateTimeTrace() # Always Update
2709 
2710 def BOffsetA(event):
2711  global CHAOffset, CHAVPosEntry
2712 
2713  try:
2714  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
2715  except:
2716  CHAVPosEntry.delete(0,END)
2717  CHAVPosEntry.insert(0, CHAOffset)
2718  # set new offset level
2719  UpdateTimeTrace() # Always Update
2720 
2721 def BIOffsetA(event):
2722  global CHAIOffset, CHAIPosEntry
2723 
2724  try:
2725  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
2726  except:
2727  CHAIPosEntry.delete(0,END)
2728  CHAIPosEntry.insert(0, CHAIOffset)
2729  # set new offset level
2730  UpdateTimeTrace() # Always Update
2731 
2732 def BOffsetB(event):
2733  global CHBOffset, CHBVPosEntry
2734 
2735  try:
2736  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
2737  except:
2738  CHBVPosEntry.delete(0,END)
2739  CHBVPosEntry.insert(0, CHBOffset)
2740  # set new offset level
2741  UpdateTimeTrace() # Always Update
2742 
2743 def BIOffsetB(event):
2744  global CHBIOffset, CHBIPosEntry
2745 
2746  try:
2747  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
2748  except:
2749  CHBIPosEntry.delete(0,END)
2750  CHBIPosEntry.insert(0, CHBIOffset)
2751  # set new offset level
2752  UpdateTimeTrace() # Always Update
2753 
2755  global TimeDisp, ckb1
2756  if TimeDisp.get() == 1:
2757  ckb1.config(style="Enab.TCheckbutton")
2758  else:
2759  ckb1.config(style="Disab.TCheckbutton")
2760 #
2762  global XYDisp, ckb2
2763  if XYDisp.get() == 1:
2764  ckb2.config(style="Enab.TCheckbutton")
2765  else:
2766  ckb2.config(style="Disab.TCheckbutton")
2767 #
2769  global FreqDisp, ckb3
2770  if FreqDisp.get() == 1:
2771  ckb3.config(style="Enab.TCheckbutton")
2772  else:
2773  ckb3.config(style="Disab.TCheckbutton")
2774 #
2776  global BodeDisp, ckb5, AWGSync
2777  if BodeDisp.get() == 1:
2778  AWGSync.set(1)
2779  ckb5.config(style="Enab.TCheckbutton")
2780  else:
2781  ckb5.config(style="Disab.TCheckbutton")
2782 #
2784  global IADisp, ckb4
2785  if IADisp.get() == 1:
2786  ckb4.config(style="Enab.TCheckbutton")
2787  else:
2788  ckb4.config(style="Disab.TCheckbutton")
2789 #
2791  global PhADisp, Phckb
2792  if PhADisp.get() == 1:
2793  phckb.config(style="Enab.TCheckbutton")
2794  else:
2795  phckb.config(style="Disab.TCheckbutton")
2796 #
2798  global OhmDisp, ckb6
2799  if OhmDisp.get() == 1:
2800  ckb6.config(style="Enab.TCheckbutton")
2801  else:
2802  ckb6.config(style="Disab.TCheckbutton")
2803 #
2805  global ETSDisp, enb1
2806  if ETSDisp.get() == 1:
2807  enb1.config(style="Enab.TCheckbutton")
2808  else:
2809  try:
2810  enb1.config(style="Disab.TCheckbutton")
2811  except:
2812  donothing()
2813 # ========================= Main routine ====================================
2814 
2816  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
2817  global IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
2818  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
2819  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
2820  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
2821  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
2822  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2823  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2824  global SV1, SI1, SV2, SI2, SVA_B
2825  global FregPoint, FBins, FStep
2826  # Analog Mux channel measurement variables
2827  global TRACEresetTime, TRACEmodeTime, SettingsStatus
2828  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
2829  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
2830  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
2831  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
2832  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
2833  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
2834 
2835  while (True): # Main loop
2836  # RUNstatus = 1 : Open Acquisition
2837  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
2838  if SettingsStatus.get() == 1:
2839  SettingsUpdate() # Make sure current entries in Settings controls are up to date
2840  if TimeDisp.get() > 0 or XYDisp.get() > 0:
2841  if MuxScreenStatus.get() == 0:
2842  MuxChan = -1
2843  Analog_Time_In()
2844  else:
2845  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
2846  AWGAIOMode.set(1)
2847  AWGBIOMode.set(1)
2848  ShowC1_V.set(0) # force A voltage trace off
2849  ShowC2_V.set(0) # force B voltage trace off
2850  if HWRevOne == "D" :
2851  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
2852  AWGBMode.set(2)
2853  if AWGBIOMode.get() == 0: # if not in split I/O mode
2854  ShowC2_I.set(0) # no need to show CH-B current
2855  if MuxEnb.get() == 1:
2856  PIO2 = 0x51
2857  else:
2858  PIO2 = 0x50
2859  if MuxSync.get() == 0:
2860  PIO3 = 0x51
2861  PIO3x = 0x50
2862  else:
2863  PIO3 = 0x50
2864  PIO3x = 0x51
2865  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
2866  TRACEresetTime = True # Clear the memory for averaging
2867  elif TRACEmodeTime.get() == 1:
2868  if TRACEresetTime == True:
2869  TRACEresetTime = False
2870  # Save previous trace in memory for average trace
2871  VmemoryMuxA = VBuffMA
2872  VmemoryMuxB = VBuffMB
2873  VmemoryMuxC = VBuffMC
2874  ImemoryMuxD = VBuffMD
2875  if Show_CBA.get() == 1:
2876  MuxChan = 0
2877  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2878  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2879  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
2880  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
2881  time.sleep(0.002)
2882  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2883  Analog_Time_In()
2884  if Show_CBB.get() == 1:
2885  MuxChan = 1
2886  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2887  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2888  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2889  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2890  time.sleep(0.002)
2891  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
2892  Analog_Time_In()
2893  if Show_CBC.get() == 1:
2894  MuxChan = 2
2895  if DualMuxMode.get() == 1:
2896  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2897  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2898  else:
2899  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2900  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
2901  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2902  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2903  time.sleep(0.002)
2904  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2905  Analog_Time_In()
2906  if Show_CBD.get() == 1:
2907  MuxChan = 3
2908  if DualMuxMode.get() == 1:
2909  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2910  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2911  else:
2912  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2913  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
2914  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2915  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2916  time.sleep(0.002)
2917  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2918  Analog_Time_In()
2919  if Show_CBA.get() == 0 and Show_CBB.get() == 0 and Show_CBC.get() == 0 and Show_CBD.get() == 0 and ShowC1_V.get() == 1:
2920  Analog_Time_In()
2921  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
2922  if IADisp.get() > 0 or BodeDisp.get() > 0:
2923  CutDC.set(1) # remove DC portion of waveform
2924  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
2925  if BodeDisp.get() > 0:
2926  if LoopNum.get() <= len(FStep):
2927  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
2928  if FregPoint < 100.0:
2929  SMPfft = 16384
2930  elif FregPoint < 500.0:
2931  SMPfft = 8192
2932  elif FregPoint < 2000.0:
2933  SMPfft = 4096
2934  else:
2935  SMPfft = 2048
2936  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
2937  SMPfft = SMPfft * 2
2938 
2939  Analog_Freq_In()
2940  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
2941  Ohm_Analog_In()
2942  root.update_idletasks()
2943  root.update()
2944 
2946  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
2947  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
2948  global AWGAIOMode, AWGBIOMode, Two_X_Sample
2949 
2950 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
2951  try:
2952  InOffA = float(eval(CHAVOffsetEntry.get()))
2953  except:
2954  CHAVOffsetEntry.delete(0,END)
2955  CHAVOffsetEntry.insert(0, InOffA)
2956  try:
2957  InGainA = float(eval(CHAVGainEntry.get()))
2958  except:
2959  CHAVGainEntry.delete(0,END)
2960  CHAVGainEntry.insert(0, InGainA)
2961  try:
2962  InOffB = float(eval(CHBVOffsetEntry.get()))
2963  except:
2964  CHBVOffsetEntry.delete(0,END)
2965  CHBVOffsetEntry.insert(0, InOffB)
2966  try:
2967  InGainB = float(eval(CHBVGainEntry.get()))
2968  except:
2969  CHBVGainEntry.delete(0,END)
2970  CHBVGainEntry.insert(0, InGainB)
2971  try:
2972  CurOffA = float(CHAIOffsetEntry.get())
2973  except:
2974  CurOffA = 0.0
2975  try:
2976  CurOffB = float(CHBIOffsetEntry.get())
2977  except:
2978  CurOffB = 0.0
2979  try:
2980  CurGainA = float(CHAIGainEntry.get())
2981  except:
2982  CurGainA = 1.0
2983  try:
2984  CurGainB = float(CHBIGainEntry.get())
2985  except:
2986  CurGainB = 1.0
2987  try:
2988  chatestv = float(eval(CHATestVEntry.get()))
2989  if chatestv > 5.0:
2990  chatestv = 5.0
2991  CHATestVEntry.delete(0,END)
2992  CHATestVEntry.insert(0, chatestv)
2993  except:
2994  CHATestVEntry.delete(0,END)
2995  CHATestVEntry.insert(0, chatestv)
2996  try:
2997  chatestr = float(eval(CHATestREntry.get()))
2998  except:
2999  CHATestREntry.delete(0,END)
3000  CHATestREntry.insert(0, chatestr)
3001  #
3002  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
3003  RIN = 1000000 # nominal ALM1000 input resistance is 1 Mohm
3004  Two_X_Sample.set(0) # make sure we are in 1V sample rate mode
3005  SetADC_Mux()
3006  # set A and B channels
3007  AWGAMode.set(0) # Set AWG A to SVMI
3008  AWGAShape.set(0) # DC
3009  AWGBMode.set(2) # Set AWG B to Hi-Z
3010  AWGAIOMode.set(0) # turn off Split I/O mode
3011  AWGBIOMode.set(0) # turn off Split I/O mode
3012  AWGAOffsetEntry.delete(0,"end")
3013  AWGAOffsetEntry.insert(0, chatestv)
3014  BAWGAModeLabel()
3015  BAWGBModeLabel() # update AWG labels
3016 
3017  if RMode.get() == 0:
3018  AWGBTerm.set(0)
3019  else:
3020  AWGBTerm.set(1)
3021  #
3022  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3023  if discontloop > 0:
3024  session.flush()
3025  else:
3026  discontloop = 1
3027  time.sleep(0.01)
3028  BAWGEnab()
3029  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
3030  # time.sleep(1000.0/SHOWsamples)
3031  else: # running in continuous mode
3032  if session.continuous:
3033  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
3034  #
3035  # get_samples returns a list of values for voltage [0] and current [1]
3036  for index in range(200): # calculate average
3037  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
3038  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
3039  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
3040  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
3041 
3042  DCVA0 = DCVA0 / 200.0 # calculate average
3043  DCVB0 = DCVB0 / 200.0 # calculate average
3044  DCIA0 = DCIA0 / 200.0 # calculate average
3045  DCIB0 = DCIB0 / 200.0 # calculate average
3046  DCVA0 = (DCVA0 - InOffA) * InGainA
3047  DCVB0 = (DCVB0 - InOffB) * InGainB
3048  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
3049  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
3050  if RMode.get() == 0: # external resistor
3051  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
3052  DCR = (DCM * RIN) / (RIN - DCM) # correct for channel B input resistance
3053  else: # use internal 50 ohm resistor
3054  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
3055  if DCR < 1000:
3056  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
3057  else:
3058  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
3059  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
3060  OhmA0.config(text = OhmString) # change displayed value
3061  OhmA1.config(text = IAString) # change displayed value
3062 #
3063  time.sleep(0.1)
3064  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3065 
3068  global TIMEdiv, TMsb, TRACEmodeTime, TRACEresetTime, TRACEaverage
3069  global VBuffMA, VmemoryMuxA, VBuffMB, VmemoryMuxB, VBuffMC, VmemoryMuxC, VBuffMD, VmemoryMuxD
3070  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
3071  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
3072  global InOffA, InGainA, InOffB, InGainB
3073  global CurOffA, CurOffB, CurGainA, CurGainB
3074  global PhADisp, PhAScreenStatus, MuxScreenStatus
3075  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3076 
3077  # get time scale
3078  try:
3079  TIMEdiv = eval(TMsb.get())
3080  except:
3081  TIMEdiv = 0.5
3082  TMsb.delete(0,"end")
3083  TMsb.insert(0,TIMEdiv)
3084  if TIMEdiv < 0.0002:
3085  TIMEdiv = 0.01
3086  #
3087 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3088  try:
3089  InOffA = float(eval(CHAVOffsetEntry.get()))
3090  except:
3091  CHAVOffsetEntry.delete(0,END)
3092  CHAVOffsetEntry.insert(0, InOffA)
3093  try:
3094  InGainA = float(eval(CHAVGainEntry.get()))
3095  except:
3096  CHAVGainEntry.delete(0,END)
3097  CHAVGainEntry.insert(0, InGainA)
3098  try:
3099  InOffB = float(eval(CHBVOffsetEntry.get()))
3100  except:
3101  CHBVOffsetEntry.delete(0,END)
3102  CHBVOffsetEntry.insert(0, InOffB)
3103  try:
3104  InGainB = float(eval(CHBVGainEntry.get()))
3105  except:
3106  CHBVGainEntry.delete(0,END)
3107  CHBVGainEntry.insert(0, InGainB)
3108  try:
3109  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
3110  except:
3111  CurOffA = 0.0
3112  try:
3113  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
3114  except:
3115  CurOffB = 0.0
3116  try:
3117  CurGainA = float(CHAIGainEntry.get())
3118  except:
3119  CurGainA = 1.0
3120  try:
3121  CurGainB = float(CHBIGainEntry.get())
3122  except:
3123  CurGainB = 1.0
3124 # Dedecide which Fast or Slow sweep routine to call
3125  if TIMEdiv > 500:
3126  Analog_Slow_time() # failed attempt as rolling trace
3127  else:
3129  if MuxScreenStatus.get() > 0:
3130  if Show_CBA.get() == 1:
3131  # Average mode 1, add difference / TRACEaverage to arrayif :
3132  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
3133  try:
3134  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
3135  except:
3136  # buffer size mismatch so reset memory buffers
3137  VmemoryMuxA = VBuffMA
3138  if Show_CBB.get() == 1:
3139  # Average mode 1, add difference / TRACEaverage to arrayif :
3140  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
3141  try:
3142  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
3143  except:
3144  # buffer size mismatch so reset memory buffers
3145  VmemoryMuxB = VBuffMB
3146  if Show_CBC.get() == 1:
3147  # Average mode 1, add difference / TRACEaverage to arrayif :
3148  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
3149  try:
3150  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
3151  except:
3152  # buffer size mismatch so reset memory buffers
3153  VmemoryMuxC = VBuffMC
3154  if Show_CBD.get() == 1:
3155  # Average mode 1, add difference / TRACEaverage to arrayif :
3156  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
3157  try:
3158  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
3159  except:
3160  # buffer size mismatch so reset memory buffers
3161  VmemoryMuxD = VBuffMD
3162  if PhADisp.get() > 0 and PhAScreenStatus.get() == 1:
3163  Analog_Phase_In()
3164 #
3165 # Process captured time dmain signals to extract magnitude and phase data
3167  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB
3168  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3169  global VAresult, VBresult, IAresult, IBresult, VABresult
3170  global PhaseVA, PhaseVB, PhaseIA, PhaseIB, PhaseVAB
3171  global VMAresult, VMBresult,VMCresult, VMDresult
3172  global PhaseVMA, PhaseVMB, PhaseVMC, PhaseVMD
3173  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3174  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3175  global DCVMuxA, DCVMuxB, DCVMuxC, DCVMuxD
3176  global SHOWsamples, SMPfft, hldn, MuxScreenStatus, MuxChan
3177  global FFTwindowshape, ZEROstuffing
3178 
3179  if len(VBuffA) < SMPfft: # put up warning to reduce number of FFT Samples or increase Time/Div time base
3181  #showwarning("WARNING","Redude Number of Samples \n Or Increas Time/Div time base.")
3182  #BStop() # Force Stop loop if running
3183  #return
3184  # Do an FFT on captured voltage and current buffer
3185  StartSmp = hldn
3186  StopSmp = hldn + SMPfft
3188  REX = []
3189  PhaseVA = []
3190  PhaseIA = []
3191  PhaseIB = []
3192  # Convert list to numpy array REX for faster Numpy calculations
3193  # Take the first SMPfft samples of VBuffA
3194  REX = numpy.array(VBuffA[StartSmp:StopSmp]-DCV1) # Make a numpy arry of the list
3195 
3196  # Set Analog level display value MAX value is 5 volts for ALM1000
3197  REX = REX / 5.0
3198 
3199  # Do the FFT window function
3200  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3201  # FFT with numpy
3202  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3203  PhaseVA = numpy.angle(ALL, deg=True) # calculate angle
3204  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3205 
3206  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3207  ALL = ALL[0:le] # So take only first half of the array
3208  PhaseVA = PhaseVA[0:le]
3209  Totalcorr = 7.07106 / SMPfft # RMS For VOLTAGE!
3210  VAresult = Totalcorr * ALL
3211  # check to see if analog Mux is being used?
3212  if MuxScreenStatus.get() == 0:
3213  PhaseVB = []
3214  PhaseVAB = []
3215  # Now VB array
3216  REX = numpy.array(VBuffB[StartSmp:StopSmp]-DCV2) # Make a numpy arry of the list
3217 
3218  # Set Analog level display value MAX value is 5 volts for ALM1000
3219  REX = REX / 5.0
3220 
3221  # Do the FFT window function
3222  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3223 
3224  # FFT with numpy
3225  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3226  PhaseVB = numpy.angle(ALL, deg=True) # calculate angle
3227  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3228 
3229  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3230  ALL = ALL[0:le] # So take only first half of the array
3231  PhaseVB = PhaseVB[0:le]
3232  Totalcorr = 7.07106 / SMPfft # For rMS VOLTAGE!
3233  VBresult = Totalcorr * ALL
3234 
3235  # Now VAB array
3236  REX = numpy.array(VBuffA[StartSmp:StopSmp]-VBuffB[StartSmp:StopSmp]) # Make a numpy arry of the list
3237  REX = REX - (DCV1-DCV2) # cut any remaining DC
3238  # Set Analog level display value MAX value is 5 volts for ALM1000
3239  REX = REX / 5.0
3240 
3241  # Do the FFT window function
3242  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3243 
3244  # FFT with numpy
3245  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3246  PhaseVAB = numpy.angle(ALL, deg=True) # calculate angle
3247  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3248 
3249  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3250  ALL = ALL[0:le] # So take only first half of the array
3251  PhaseVAB = PhaseVAB[0:le]
3252  Totalcorr = 7.07106 / SMPfft # For rms VOLTAGE!
3253  VABresult = Totalcorr * ALL
3254  else: # Do FFTs on Mux buffers as needed if MuxScreenStatus.get() == 0:
3255  if MuxChan == 0: #
3256  PhaseVMA = []
3257  # Now VMuxA array
3258  REX = numpy.array(VBuffMA[StartSmp:StopSmp]-DCVMuxA) # Make a numpy arry of the list
3259 
3260  # Set Analog level display value MAX value is 5 volts for ALM1000
3261  REX = REX / 5.0
3262 
3263  # Do the FFT window function
3264  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3265 
3266  # FFT with numpy
3267  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3268  PhaseVMA = numpy.angle(ALL, deg=True) # calculate angle
3269  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3270 
3271  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3272  ALL = ALL[0:le] # So take only first half of the array
3273  PhaseVMA = PhaseVMA[0:le]
3274  Totalcorr = 7.07106 / SMPfft # For rms VOLTAGE!
3275  VMAresult = Totalcorr * ALL
3276  if MuxChan == 1: # MuxChan = 1
3277  PhaseVMB = []
3278  # Now VMuxA array
3279  REX = numpy.array(VBuffMB[StartSmp:StopSmp]-DCVMuxB) # Make a numpy arry of the list
3280 
3281  # Set Analog level display value MAX value is 5 volts for ALM1000
3282  REX = REX / 5.0
3283 
3284  # Do the FFT window function
3285  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3286 
3287  # FFT with numpy
3288  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3289  PhaseVMB = numpy.angle(ALL, deg=True) # calculate angle
3290  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3291 
3292  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3293  ALL = ALL[0:le] # So take only first half of the array
3294  PhaseVMB = PhaseVMB[0:le]
3295  Totalcorr = 7.07106 / SMPfft # For rms VOLTAGE!
3296  VMBresult = Totalcorr * ALL
3297  if MuxChan == 2: # MuxChan = 2
3298  PhaseVMC = []
3299  # Now VMuxA array
3300  REX = numpy.array(VBuffMC[StartSmp:StopSmp]-DCVMuxC) # Make a numpy arry of the list
3301 
3302  # Set Analog level display value MAX value is 5 volts for ALM1000
3303  REX = REX / 5.0
3304 
3305  # Do the FFT window function
3306  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3307 
3308  # FFT with numpy
3309  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3310  PhaseVMC = numpy.angle(ALL, deg=True) # calculate angle
3311  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3312 
3313  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3314  ALL = ALL[0:le] # So take only first half of the array
3315  PhaseVMC = PhaseVMC[0:le]
3316  Totalcorr = 7.07106 / SMPfft # For rms VOLTAGE!
3317  VMCresult = Totalcorr * ALL
3318  if MuxChan == 3: # MuxChan = 3
3319  PhaseVMD = []
3320  # Now VMuxA array
3321  REX = numpy.array(VBuffMD[StartSmp:StopSmp]-DCVMuxD) # Make a numpy arry of the list
3322 
3323  # Set Analog level display value MAX value is 5 volts for ALM1000
3324  REX = REX / 5.0
3325 
3326  # Do the FFT window function
3327  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3328 
3329  # FFT with numpy
3330  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3331  PhaseVMD = numpy.angle(ALL, deg=True) # calculate angle
3332  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3333 
3334  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3335  ALL = ALL[0:le] # So take only first half of the array
3336  PhaseVMD = PhaseVMD[0:le]
3337  Totalcorr = 7.07106 / SMPfft # For rms VOLTAGE!
3338  VMDresult = Totalcorr * ALL
3339  # Now IA array
3340  REX = numpy.array(IBuffA[StartSmp:StopSmp]) # -DCI1 Make a numpy arry of the list
3341 
3342  # Set Analog level display value MAX value is 0.2 amps for ALM1000
3343  REX = REX / 0.5
3344 
3345  # Do the FFT window function
3346  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3347 
3348  # FFT with numpy
3349  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3350  PhaseIA = numpy.angle(ALL, deg=True) # calculate angle
3351  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3352 
3353  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3354  ALL = ALL[0:le] # So take only first half of the array
3355  PhaseIA = PhaseIA[0:le]
3356  Totalcorr = 0.707106 / SMPfft # RMS For current!
3357  IAresult = Totalcorr * ALL
3358 
3359  # Now IB array
3360  REX = numpy.array(IBuffB[StartSmp:StopSmp]) # -DCI2 Make a numpy arry of the list
3361 
3362  # Set Analog level display value MAX value is 0.2 amps for ALM1000
3363  REX = REX / 0.5
3364 
3365  # Do the FFT window function
3366  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3367 
3368  # FFT with numpy
3369  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3370  PhaseIB = numpy.angle(ALL, deg=True) # calculate angle
3371  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3372 
3373  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3374  ALL = ALL[0:le] # So take only first half of the array
3375  PhaseIB = PhaseIB[0:le]
3376  Totalcorr = 0.707106 / SMPfft # RMS For current!
3377  IBresult = Totalcorr * ALL
3378 #
3379  UpdatePhAAll()
3380 #
3381 
3384  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
3385  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3386  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
3387  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
3388  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
3389  global CHA, CHB, session, devx, discontloop, contloop
3390  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, ShiftPointer
3391  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
3392  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered
3393  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
3394  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
3395  global SCREENrefresh, DCrefresh
3396  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3397  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3398  global SV1, SI1, SV2, SI2, SVA_B
3399  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3400  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
3401  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
3402  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
3403  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
3404  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3405  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3406  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3407  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3408  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
3409  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
3410  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
3411  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
3412  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
3413  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
3414  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3415  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3416  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3417  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3418  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3419  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3420 
3421  # Starting acquisition
3422  DCVA0 = DCVB0 = DCIA0 = DCIB0= 0.0 # initalize measurment variable
3423  #
3424  NumSamples = 1 # int(SAMPLErate/TIMEdiv)
3425  if First_Slow_sweep == 0:
3426  BufferLen = TIMEdiv*12.0
3427  VBuffA = numpy.ones(BufferLen)
3428  VBuffB = numpy.ones(BufferLen)
3429  IBuffA = numpy.ones(BufferLen)
3430  IBuffB = numpy.ones(BufferLen)
3431  First_Slow_sweep = 1
3432  #
3433  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3434  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3435  if discontloop > 0:
3436  session.flush()
3437  else:
3438  discontloop = 1
3439  BAWGEnab()
3440  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
3441  # waite to finish then return to open termination
3442  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3443  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3444  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3445  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3446 
3447  else: # running in continuous mode
3448  if session.continuous:
3449  if MuxScreenStatus.get() > 0:
3450  devx.flush(-1, True)
3451  DummySamples = NumSamples*2
3452  if DummySamples < 10000:
3453  DummySamples = 10000
3454  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
3455  ADsignal1 = devx.read(NumSamples, -1, True) # get samples for both channel A and B
3456  #
3457  else:
3458  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
3459 
3460  # get_samples returns a list of values for voltage [0] and current [1]
3461  for index in range(NumSamples): # calculate average
3462  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
3463  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
3464  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
3465  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
3466  DCVA0 = DCVA0/(NumSamples) # calculate V average
3467  DCVB0 = DCVB0/(NumSamples) # calculate V average
3468  DCVA0 = (DCVA0 - InOffA) * InGainA
3469  DCVB0 = (DCVB0 - InOffB) * InGainB
3470  DCIA0 = DCIA0/(NumSamples) # calculate I average
3471  DCIB0 = DCIB0/(NumSamples) # calculate I average
3472  DCIA0 = DCIA0 * 1000 # convert to mA
3473  DCIB0 = DCIB0 * 1000 # convert to mA
3474  DCIA0 = (DCIA0 - CurOffA) * CurGainA
3475  DCIB0 = (DCIB0 - CurOffB) * CurGainB
3476 # Shift in next new sample
3477  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
3478  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
3479  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
3480  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
3481 # Calculate measurement values
3482  DCV1 = numpy.mean(VBuffA)
3483  DCV2 = numpy.mean(VBuffB)
3484  DCI1 = numpy.mean(IBuffA)
3485  DCI2 = numpy.mean(IBuffB)
3486 # find min and max values
3487  MinV1 = numpy.amin(VBuffA)
3488  MaxV1 = numpy.amax(VBuffA)
3489  MinV2 = numpy.amin(VBuffB)
3490  MaxV2 = numpy.amax(VBuffB)
3491  MinI1 = numpy.amin(IBuffA)
3492  MaxI1 = numpy.amax(IBuffA)
3493  MinI2 = numpy.amin(IBuffB)
3494  MaxI2 = numpy.amax(IBuffB)
3495 # RMS value = square root of average of the data record squared
3496  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA)))
3497  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA)))
3498  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB)))
3499  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB)))
3500  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA-VBuffB)))
3501 #
3502  if TimeDisp.get() > 0:
3503  UpdateTimeAll() # Update Data, trace and time screen
3504  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3505  UpdateXYAll() # Update Data, trace and XY screen
3506  if MeasureStatus.get() > 0:
3508  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
3509  if RUNstatus.get() == 3:
3510  RUNstatus.set(0)
3511  if RUNstatus.get() == 4:
3512  RUNstatus.set(1)
3513  if TimeDisp.get() > 0:
3515  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3516  UpdateXYScreen()
3517  # update screens
3518 
3521  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
3522  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3523  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
3524  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
3525  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
3526  global CHA, CHB, session, devx, discontloop, contloop, DeBugMode
3527  global TRACES, TRACESread, TRACEsize
3528  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
3529  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, Trigger_LPF_length, LPFTrigger
3530  global SAMPLErate, SHOWsamples, SMPfft, MinSamples, MaxSamples, AWGSAMPLErate
3531  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
3532  global SCREENrefresh, DCrefresh, ETSrecord
3533  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3534  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3535  global SV1, SI1, SV2, SI2, SVA_B
3536  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3537  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
3538  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
3539  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
3540  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
3541  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
3542  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3543  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3544  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3545  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
3546  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
3547  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
3548  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
3549  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
3550  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
3551  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3552  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3553  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3554  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3555  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3556  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3557 
3558  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3559  TRACEresetTime = True # Clear the memory for averaging
3560  elif TRACEmodeTime.get() == 1:
3561  if TRACEresetTime == True:
3562  TRACEresetTime = False
3563  # Save previous trace in memory for average trace
3564  VmemoryA = VBuffA
3565  VmemoryB = VBuffB
3566  ImemoryA = IBuffA
3567  ImemoryB = IBuffB
3568 
3569  try:
3570  HoldOff = float(eval(HoldOffentry.get()))
3571  if HoldOff < 0:
3572  HoldOff = 0
3573  HoldOffentry.delete(0,END)
3574  HoldOffentry.insert(0, HoldOff)
3575  except:
3576  HoldOffentry.delete(0,END)
3577  HoldOffentry.insert(0, HoldOff)
3578 #
3579  try:
3580  HozPoss = float(eval(HozPossentry.get()))
3581  except:
3582  HozPossentry.delete(0,END)
3583  HozPossentry.insert(0, HozPoss)
3584 
3585  hldn = int(HoldOff * SAMPLErate/1000 )
3586  hozpos = int(HozPoss * SAMPLErate/1000 )
3587  if hozpos < 0:
3588  hozpos = 0
3589  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
3590  onescreen = int(twoscreens/2)
3591  if hldn+hozpos > MaxSamples-twoscreens:
3592  hldn = MaxSamples-twoscreens-hozpos
3593  HoldOffentry.delete(0,END)
3594  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
3595  if ETSDisp.get() > 0:
3596  if TIMEdiv > 0.2:
3597  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
3598  else:
3599  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
3600  if (MaxETSrecord*100) > MaxSamples:
3601  MaxETSrecord = MaxSamples / 100
3602  try:
3603  DivX = float(eval(DivXEntry.get()))
3604  if DivX < 2:
3605  DivX = 2
3606  if DivX > 75:
3607  DivX = 75
3608  DivXEntry.delete(0,END)
3609  DivXEntry.insert(0, DivX)
3610  except:
3611  DivXEntry.delete(0,END)
3612  DivXEntry.insert(0, DivX)
3613  FOff = 25
3614  MulX = (DivX*SAMPLErate)/(100*FOff)
3615  while MulX > MaxETSrecord:
3616  FOff = FOff + 5
3617  MulX = (DivX*SAMPLErate)/(100*FOff)
3618  FOff = 0 - FOff
3619  if DeBugMode > 0:
3620  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
3621  MulXEntry.config(text = SRstring) # change displayed value
3622  SRstring = "Offset = " + str(FOff) + " samples"
3623  FOffEntry.config(text = SRstring) # change displayed value
3624  SHOWsamples = int(MulX * 100)
3625  else:
3626  SHOWsamples = twoscreens + hldn + hozpos
3627  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
3628  SHOWsamples = MaxSamples
3629  if SHOWsamples < MinSamples: # or a Min of 1000 samples
3630  SHOWsamples = MinSamples
3631  if PhAScreenStatus.get() > 0:
3632  if SHOWsamples < SMPfft:
3633  SHOWsamples = SMPfft + hldn + hozpos
3634  if hozpos >= 0:
3635  TRIGGERsample = hldn
3636  else:
3637  TRIGGERsample = abs(hozpos)
3638  TRIGGERsample = TRIGGERsample + hozpos #
3639 # Starting acquisition
3640  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3641  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3642  if discontloop > 0:
3643  session.flush()
3644  else:
3645  discontloop = 1
3646  time.sleep(0.01)
3647  BAWGEnab()
3648  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3649  # waite to finish then return to open termination
3650  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3651  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3652  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3653  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3654  else: # running in continuous mode
3655  if session.continuous:
3656  if MuxScreenStatus.get() > 0:
3657  devx.flush(-1, True)
3658  DummySamples = SHOWsamples*2
3659  if DummySamples < 20000:
3660  DummySamples = 20000
3661  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
3662  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
3663  #
3664  else:
3665  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
3666  # waite to finish then return to open termination
3667  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3668  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3669  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3670  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3671  #
3672  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
3673  if ADC_Mux_Mode.get() == 0: # VA and VB
3674  VBuffA = [] # Clear the V Buff array for trace A
3675  VBuffB = [] # Clear the V Buff array for trace B
3676  elif ADC_Mux_Mode.get() == 1: # IA and IB
3677  IBuffA = [] # Clear the I Buff array for trace A
3678  IBuffB = [] # Clear the I Buff array for trace B
3679  elif ADC_Mux_Mode.get() == 4: # VA and IA
3680  VBuffA = [] # Clear the V Buff array for trace A
3681  IBuffA = [] # Clear the I Buff array for trace A
3682  elif ADC_Mux_Mode.get() == 5: # VB and IB
3683  VBuffB = [] # Clear the V Buff array for trace B
3684  IBuffB = [] # Clear the I Buff array for trace B
3685  else:
3686  VBuffA = [] # Clear the V Buff array for trace A
3687  IBuffA = [] # Clear the I Buff array for trace A
3688  VBuffB = [] # Clear the V Buff array for trace B
3689  IBuffB = [] # Clear the I Buff array for trace B
3690  increment = 1
3691  # SAMPLErate = 200000 #AWGSAMPLErate
3692  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
3693  increment = 2
3694  SAMPLErate = int(AWGSAMPLErate/increment)
3695  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
3696  increment = 4
3697  SAMPLErate = int(AWGSAMPLErate/increment)
3698  index = 0
3699  if SHOWsamples != len(ADsignal1):
3700  SHOWsamples = len(ADsignal1)
3701  while index < SHOWsamples: # build arrays and decimate if needed
3702  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
3703  if ADC_Mux_Mode.get() == 0: # VA and VB
3704  VBuffA.append(ADsignal1[index][0][0])
3705  VBuffA.append(ADsignal1[index][1][1])
3706  VBuffB.append(ADsignal1[index][0][1])
3707  VBuffB.append(ADsignal1[index][1][0])
3708  if Alternate_Sweep_Mode.get() == 0:
3709  IBuffA.append(0.0) # fill as a place holder
3710  IBuffA.append(0.0) # fill as a place holder
3711  IBuffB.append(0.0) # fill as a place holder
3712  IBuffB.append(0.0) # fill as a place holder
3713  elif ADC_Mux_Mode.get() == 1: # IA and IB
3714  IBuffA.append(ADsignal1[index][0][1])
3715  IBuffA.append(ADsignal1[index][1][0])
3716  IBuffB.append(ADsignal1[index][0][0])
3717  IBuffB.append(ADsignal1[index][1][1])
3718  if Alternate_Sweep_Mode.get() == 0:
3719  VBuffA.append(0.0) # fill as a place holder
3720  VBuffA.append(0.0) # fill as a place holder
3721  VBuffB.append(0.0) # fill as a place holder
3722  VBuffB.append(0.0) # fill as a place holder
3723  elif ADC_Mux_Mode.get() == 2: # VA and IB
3724  VBuffA.append((ADsignal1[index][0][1])/1024.0)
3725  VBuffA.append((ADsignal1[index][1][0])/1024.0)
3726  #
3727  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
3728  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
3729  #
3730  if Alternate_Sweep_Mode.get() == 0:
3731  VBuffB.append(0.0) # fill as a place holder
3732  VBuffB.append(0.0) # fill as a place holder
3733  IBuffA.append(0.0) # fill as a place holder
3734  IBuffA.append(0.0) # fill as a place holder
3735  elif ADC_Mux_Mode.get() == 3: # VB and IA
3736  VBuffB.append((ADsignal1[index][0][0])/1024.0)
3737  VBuffB.append((ADsignal1[index][1][1])/1024.0)
3738  #
3739  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
3740  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
3741  #
3742  if Alternate_Sweep_Mode.get() == 0:
3743  VBuffA.append(0.0) # fill as a place holder
3744  VBuffA.append(0.0) # fill as a place holder
3745  IBuffB.append(0.0) # fill as a place holder
3746  IBuffB.append(0.0) # fill as a place holder
3747  elif ADC_Mux_Mode.get() == 4: # VA and IA
3748  VBuffA.append(ADsignal1[index][0][0])
3749  VBuffA.append(ADsignal1[index][1][1])
3750  IBuffA.append(ADsignal1[index][0][1])
3751  IBuffA.append(ADsignal1[index][1][0])
3752  if Alternate_Sweep_Mode.get() == 0:
3753  VBuffB.append(0.0) # fill as a place holder
3754  VBuffB.append(0.0) # fill as a place holder
3755  IBuffB.append(0.0) # fill as a place holder
3756  IBuffB.append(0.0) # fill as a place holder
3757  elif ADC_Mux_Mode.get() == 5: # VB and IB
3758  VBuffB.append(ADsignal1[index][0][1])
3759  VBuffB.append(ADsignal1[index][1][0])
3760  IBuffB.append(ADsignal1[index][0][0])
3761  IBuffB.append(ADsignal1[index][1][1])
3762  if Alternate_Sweep_Mode.get() == 0:
3763  VBuffA.append(0.0) # fill as a place holder
3764  VBuffA.append(0.0) # fill as a place holder
3765  IBuffA.append(0.0) # fill as a place holder
3766  IBuffA.append(0.0) # fill as a place holder
3767  else:
3768  VBuffA.append(ADsignal1[index][0][0])
3769  IBuffA.append(ADsignal1[index][0][1])
3770  VBuffB.append(ADsignal1[index][1][0])
3771  IBuffB.append(ADsignal1[index][1][1])
3772  index = index + increment
3773 #
3774  SHOWsamples = len(VBuffA)
3775  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
3776  if ADC_Mux_Mode.get() == 0: # VA and VB
3777  VBuffA = numpy.array(VBuffA)
3778  VBuffB = numpy.array(VBuffB)
3779  VBuffA = (VBuffA - InOffA) * InGainA
3780  VBuffB = (VBuffB - InOffB) * InGainB
3781  ADC_Mux_Mode.set(1) # switch mode
3782  Last_ADC_Mux_Mode = 0
3783  elif ADC_Mux_Mode.get() == 1: # IA and IB
3784  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3785  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3786  IBuffA = (IBuffA - CurOffA) * CurGainA
3787  IBuffB = (IBuffB - CurOffB) * CurGainB
3788  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
3789  elif ADC_Mux_Mode.get() == 4: # VA and IA
3790  VBuffA = numpy.array(VBuffA)
3791  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3792  IBuffA = (IBuffA - CurOffA) * CurGainA
3793  VBuffA = (VBuffA - InOffA) * InGainA
3794  ADC_Mux_Mode.set(1) # switch mode
3795  Last_ADC_Mux_Mode = 4
3796  elif ADC_Mux_Mode.get() == 5: # VB and IB
3797  VBuffB = numpy.array(VBuffB)
3798  VBuffB = (VBuffB - InOffB) * InGainB
3799  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3800  IBuffB = (IBuffB - CurOffB) * CurGainB
3801  ADC_Mux_Mode.set(1) # switch mode
3802  Last_ADC_Mux_Mode = 5
3803  SetADC_Mux()
3804  #
3805  else:
3806  VBuffA = numpy.array(VBuffA)
3807  VBuffB = numpy.array(VBuffB)
3808  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3809  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3810  VBuffA = (VBuffA - InOffA) * InGainA
3811  VBuffB = (VBuffB - InOffB) * InGainB
3812  IBuffA = (IBuffA - CurOffA) * CurGainA
3813  IBuffB = (IBuffB - CurOffB) * CurGainB
3814  TRACESread = 2
3815 # temp ETS calculations
3816  if ETSDisp.get() > 0:
3817  baseFreq = SAMPLErate/DivX
3818  #
3819  VAets = []
3820  VBets = []
3821  IAets = []
3822  IBets = []
3823  index = 0
3824  try:
3825  FMul = float(eval(FminEntry.get()))
3826  if FMul < 1:
3827  FMul = 1
3828  FMulXEntry.delete(0,END)
3829  FMulXEntry.insert(0, int(FMul))
3830  if FMul > 75:
3831  FMul = 75
3832  FMulXEntry.delete(0,END)
3833  FMulXEntry.insert(0, int(FMul))
3834  except:
3835  FMulXEntry.delete(0,END)
3836  FMulXEntry.insert(0, int(FMul))
3837  Fmin = baseFreq * FMul
3838  FminE = float(SAMPLErate + FOff)
3839  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
3840  # length of record set my Multiplcation factor
3841  tot_cycles = int((MulX*100)/Samples_Cycle)
3842  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
3843  ETSrecord = int((MulX*50)/Samples_Cycle)
3844  if tot_cycles > SHOWsamples:
3845  tot_cycles = SHOWsamples-1
3846  # now sort RT data into ETS sample buffers
3847  while index < SHOWsamples:
3848  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
3849  IndexValue = int(tot_cycles * Dpart)
3850  if IndexValue > SHOWsamples:
3851  IndexValue = SHOWsamples-1
3852  if IndexValue > tot_cycles:
3853  IndexValue = tot_cycles
3854  if ETSDir.get() == 0:
3855  VAets.append(VBuffA[IndexValue])
3856  VBets.append(VBuffB[IndexValue])
3857  IAets.append(IBuffA[IndexValue])
3858  IBets.append(IBuffB[IndexValue])
3859  else:
3860  VAets.append(VBuffA[tot_cycles-IndexValue])
3861  VBets.append(VBuffB[tot_cycles-IndexValue])
3862  IAets.append(IBuffA[tot_cycles-IndexValue])
3863  IBets.append(IBuffB[tot_cycles-IndexValue])
3864  index = index + 1
3865  SHiftFact = 5
3866  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
3867  VBuffA = VAets
3868  VBuffB = VBets
3869  IBuffA = IAets
3870  IBuffB = IBets
3871  VBuffA = numpy.array(VBuffA)
3872  VBuffB = numpy.array(VBuffB)
3873  IBuffA = numpy.array(IBuffA)
3874  IBuffB = numpy.array(IBuffB)
3875  try:
3876  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
3877  except:
3878  TimeCorrection = SHiftFact
3879  if ETSDir.get() == 0:
3880  VBuffB = numpy.roll(VBuffB, TimeCorrection)
3881  IBuffB = numpy.roll(IBuffB, TimeCorrection)
3882  else:
3883  VBuffB = numpy.roll(VBuffB, TimeCorrection)
3884  IBuffB = numpy.roll(IBuffB, TimeCorrection)
3885  SHOWsamples = twoscreens + hldn + hozpos
3886 # Check if Input channel RC high pass compensation checked
3887  if CHA_RC_HP.get() == 1 or CHAI_RC_HP.get() == 1:
3888  try:
3889  TC1A = float(cha_TC1Entry.get())
3890  if TC1A < 0:
3891  TC1A = 0
3892  cha_TC1Entry.delete(0,END)
3893  cha_TC1Entry.insert(0, TC1A)
3894  except:
3895  TC1A = CHA_TC1.get()
3896  try:
3897  TC2A = float(cha_TC2Entry.get())
3898  if TC2A < 0:
3899  TC2A = 0
3900  cha_TC2Entry.delete(0,END)
3901  cha_TC2Entry.insert(0, TC2A)
3902  except:
3903  TC2A = CHA_TC2.get()
3904  #
3905  try:
3906  Gain1A = float(cha_A1Entry.get())
3907  except:
3908  Gain1A = CHA_A1.get()
3909  try:
3910  Gain2A = float(cha_A2Entry.get())
3911  except:
3912  Gain2A = CHA_A2.get()
3913  #
3914  if len(VBuffA) > 4:
3915  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
3916  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
3917  if CHAI_RC_HP.get() == 1:
3918  IBuffA = Digital_RC_High_Pass( IBuffA, TC1A, Gain1A )
3919  #IBuffA = Digital_RC_High_Pass( IBuffA, TC2A, Gain2A )
3920  if CHB_RC_HP.get() == 1 or CHBI_RC_HP.get() == 1:
3921  try:
3922  TC1B = float(chb_TC1Entry.get())
3923  if TC1B < 0:
3924  TC1B = 0
3925  chb_TC1Entry.delete(0, END)
3926  chb_TC1Entry.insert(0, TC1B)
3927  except:
3928  TC1B = CHB_TC1.get()
3929  try:
3930  TC2B = float(chb_TC2Entry.get())
3931  if TC2B < 0:
3932  TC2B = 0
3933  chb_TC2Entry.delete(0, END)
3934  chb_TC2Entry.insert(0, TC2B)
3935  except:
3936  TC2B = CHB_TC2.get()
3937  #
3938  try:
3939  Gain1B = float(chb_A1Entry.get())
3940  except:
3941  Gain1B = CHB_A1.get()
3942  try:
3943  Gain2B = float(chb_A2Entry.get())
3944  except:
3945  Gain2B = CHB_A2.get()
3946  #
3947  if len(VBuffB) > 4:
3948  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
3949  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
3950  if CHBI_RC_HP.get() == 1:
3951  IBuffB = Digital_RC_High_Pass( IBuffB, TC1B, Gain1B )
3952  #IBuffB = Digital_RC_High_Pass( IBuffB, TC2B, Gain2B )
3953 # check if digital filter box checked
3954  if DigFiltA.get() == 1:
3955  if len(DFiltACoef) > 1:
3956  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
3957  if DigFiltB.get() == 1:
3958  if len(DFiltBCoef) > 1:
3959  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
3960 # Find trigger sample point if necessary
3961  LShift = 0
3962  if TgInput.get() == 1:
3963  FindTriggerSample(VBuffA)
3964  if TgInput.get() == 2:
3965  FindTriggerSample(IBuffA)
3966  if TgInput.get() == 3:
3967  FindTriggerSample(VBuffB)
3968  if TgInput.get() == 4:
3969  FindTriggerSample(IBuffB)
3970  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
3971  # Average mode 1, add difference / TRACEaverage to array
3972  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
3973  LShift = 0 - TRIGGERsample
3974  VBuffA = numpy.roll(VBuffA, LShift)
3975  VBuffB = numpy.roll(VBuffB, LShift)
3976  IBuffA = numpy.roll(IBuffA, LShift)
3977  IBuffB = numpy.roll(IBuffB, LShift)
3978  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
3979  try:
3980  if DualMuxMode.get() == 0 and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
3981  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
3982  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
3983  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
3984  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
3985  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
3986  except:
3987  # buffer size mismatch so reset memory buffers
3988  VmemoryA = VBuffA
3989  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
3990  VmemoryB = VBuffB
3991  ImemoryA = IBuffA
3992  ImemoryB = IBuffB
3993  if TgInput.get() == 1:
3994  ReInterploateTrigger(VBuffA)
3995  if TgInput.get() == 2:
3996  ReInterploateTrigger(IBuffA)
3997  if TgInput.get() == 3:
3998  ReInterploateTrigger(VBuffB)
3999  if TgInput.get() == 4:
4000  ReInterploateTrigger(IBuffB)
4001 # DC value = average of the data record
4002  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
4003  Endsample = hldn+onescreen # average over only one screen's worth of samples
4004  else:
4005  Endsample = SHOWsamples - 10 # average over all samples
4006  if MeasGateStatus.get() == 1:
4007  if (MeasGateRight-MeasGateLeft) > 0:
4008  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
4009  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
4010  if Endsample <= hldn:
4011  Endsample = hldn + 2
4012  DCV1 = numpy.mean(VBuffA[hldn:Endsample])
4013  DCV2 = numpy.mean(VBuffB[hldn:Endsample])
4014  # convert current values to mA
4015  DCI1 = numpy.mean(IBuffA[hldn:Endsample])
4016  DCI2 = numpy.mean(IBuffB[hldn:Endsample])
4017 # find min and max values
4018  MinV1 = numpy.amin(VBuffA[hldn:Endsample])
4019  MaxV1 = numpy.amax(VBuffA[hldn:Endsample])
4020  MinV2 = numpy.amin(VBuffB[hldn:Endsample])
4021  MaxV2 = numpy.amax(VBuffB[hldn:Endsample])
4022  MinI1 = numpy.amin(IBuffA[hldn:Endsample])
4023  MaxI1 = numpy.amax(IBuffA[hldn:Endsample])
4024  MinI2 = numpy.amin(IBuffB[hldn:Endsample])
4025  MaxI2 = numpy.amax(IBuffB[hldn:Endsample])
4026 # RMS value = square root of average of the data record squared
4027  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample])))
4028  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[hldn:Endsample])))
4029  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[hldn:Endsample])))
4030  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[hldn:Endsample])))
4031  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample]-VBuffB[hldn:Endsample])))
4032 # Transfer to mux buffers as necessary
4033  if TgInput.get() > 0 and MuxChan > -1 and TRACEmodeTime.get() != 1:
4034  # if triggering left shift all arrays such that trigger point is at index 0
4035  LShift = 0 - TRIGGERsample
4036  VBuffA = numpy.roll(VBuffA, LShift)
4037  VBuffB = numpy.roll(VBuffB, LShift)
4038  IBuffA = numpy.roll(IBuffA, LShift)
4039  IBuffB = numpy.roll(IBuffB, LShift)
4040  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4041  if MuxChan > -1:
4042  Dval0 = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
4043  Dval1 = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
4044  if Show_CBA.get() == 1 and Dval0[0] == 0 and Dval1[0] == 0:
4045  DCVMuxA = DCV2
4046  MinVMuxA = MinV2
4047  MaxVMuxA = MaxV2
4048  MidVMuxA = (MaxV2+MinV2)/2.0
4049  PPVMuxA = MaxV2-MinV2
4050  SVMuxA = SV2
4051  VBuffMA = VBuffB
4052  if Show_CBB.get() == 1 and Dval0[0] == 1 and Dval1[0] == 0:
4053  DCVMuxB = DCV2
4054  MinVMuxB = MinV2
4055  MaxVMuxB = MaxV2
4056  MidVMuxB = (MaxV2+MinV2)/2.0
4057  PPVMuxB = MaxV2-MinV2
4058  SVMuxB = SV2
4059  VBuffMB = VBuffB
4060  if Show_CBC.get() == 1 and Dval0[0] == 0 and Dval1[0] == 1:
4061  if DualMuxMode.get() == 1:
4062  DCVMuxC = DCV1
4063  MinVMuxC = MinV1
4064  MaxVMuxC = MaxV1
4065  MidVMuxC = (MaxV1+MinV1)/2.0
4066  PPVMuxC = MaxV1-MinV1
4067  SVMuxC = SV1
4068  VBuffMC = VBuffA
4069  else:
4070  DCVMuxC = DCV2
4071  MinVMuxC = MinV2
4072  MaxVMuxC = MaxV2
4073  MidVMuxC = (MaxV2+MinV2)/2.0
4074  PPVMuxC = MaxV2-MinV2
4075  SVMuxC = SV2
4076  VBuffMC = VBuffB
4077  if Show_CBD.get() == 1 and Dval0[0] == 1 and Dval1[0] == 1:
4078  if DualMuxMode.get() == 1:
4079  DCVMuxD = DCV1
4080  MinVMuxD = MinV1
4081  MaxVMuxD = MaxV1
4082  MidVMuxD = (MaxV1+MinV1)/2.0
4083  PPVMuxD = MaxV1-MinV1
4084  SVMuxD = SV1
4085  VBuffMD = VBuffA
4086  else:
4087  DCVMuxD = DCV2
4088  MinVMuxD = MinV2
4089  MaxVMuxD = MaxV2
4090  MidVMuxD = (MaxV2+MinV2)/2.0
4091  PPVMuxD = MaxV2-MinV2
4092  SVMuxD = SV2
4093  VBuffMD = VBuffB
4094 #
4095  if TimeDisp.get() > 0:
4096  UpdateTimeAll() # Update Data, trace and time screen
4097  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4098  UpdateXYAll() # Update Data, trace and XY screen
4099  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
4100  BStop() #
4101  SingleShot.set(0)
4102  if ManualTrigger.get() == 1: # Manual trigger is on
4103  BStop() #
4104  if MeasureStatus.get() > 0:
4106  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
4107  if RUNstatus.get() == 3:
4108  RUNstatus.set(0)
4109  if RUNstatus.get() == 4:
4110  RUNstatus.set(1)
4111  if TimeDisp.get() > 0:
4113  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4114  UpdateXYScreen()
4115  # update screens
4116 #
4117 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
4118 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
4119 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
4120 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
4121 
4122 
4124 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
4125  global SAMPLErate
4126 
4127  OutBuff = []
4128  n = len(InBuff)
4129  Delta = 1.0/SAMPLErate
4130  TC = TC1 * 1.0E-6
4131  Alpha = TC / (TC + Delta)
4132  OutBuff.append(InBuff[1]-InBuff[0]) # set inital sample to derivative (difference of first two samples)
4133  i = 1
4134  while i < n:
4135  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
4136  i += 1
4137  OutBuff = numpy.array(OutBuff)
4138  OutBuff = InBuff + (OutBuff * Gain)
4139  return OutBuff
4140 
4142 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
4143  global SAMPLErate
4144 
4145  OutBuff = []
4146  n = len(InBuff)
4147  Delta = 1.0/SAMPLErate
4148  TC = TC1 * 1.0E-6
4149  Alpha = Delta / (TC + Delta)
4150  i = 1
4151  OutBuff.append(Alpha*InBuff[0])
4152  while i < n:
4153  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
4154  i += 1
4155  OutBuff = numpy.array(OutBuff)
4156  OutBuff = (OutBuff * Gain)
4157  return OutBuff
4158 
4162 def shift_buffer(arr, num, fill_value=numpy.nan):
4163  result = numpy.empty_like(arr)
4164  if num > 0:
4165  result[:num] = fill_value
4166  result[num:] = arr[:-num]
4167  elif num < 0:
4168  result[num:] = fill_value
4169  result[:num] = arr[-num:]
4170  else:
4171  result[:] = arr
4172  return result
4173 
4174 
4177  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
4178  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
4179  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
4180  global NSteps, LoopNum, FSweepMode, FStep, FBins
4181  global StartFreqEntry, StopFreqEntry, HoldOffentry
4182  global session, CHA, CHB, devx, MaxSamples, discontloop
4183  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
4184  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
4185  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
4186  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
4187  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
4188  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4189  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
4190  global BDSweepFile, FileSweepFreq, FileSweepAmpl
4191  global PIO_0, PIO_1, PIO_2, PIO_3
4192  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
4193  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4194  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4195  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4196  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
4197 
4198  HalfSAMPLErate = SAMPLErate/2
4199  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
4200  try:
4201  InOffA = float(eval(CHAVOffsetEntry.get()))
4202  except:
4203  CHAVOffsetEntry.delete(0,END)
4204  CHAVOffsetEntry.insert(0, InOffA)
4205  try:
4206  InGainA = float(eval(CHAVGainEntry.get()))
4207  except:
4208  CHAVGainEntry.delete(0,END)
4209  CHAVGainEntry.insert(0, InGainA)
4210  try:
4211  InOffB = float(eval(CHBVOffsetEntry.get()))
4212  except:
4213  CHBVOffsetEntry.delete(0,END)
4214  CHBVOffsetEntry.insert(0, InOffB)
4215  try:
4216  InGainB = float(eval(CHBVGainEntry.get()))
4217  except:
4218  CHBVGainEntry.delete(0,END)
4219  CHBVGainEntry.insert(0, InGainB)
4220  try:
4221  HoldOff = float(eval(HoldOffentry.get()))
4222  if HoldOff < 0:
4223  HoldOff = 0
4224  HoldOffentry.delete(0,END)
4225  HoldOffentry.insert(0, HoldOff)
4226  except:
4227  HoldOffentry.delete(0,END)
4228  HoldOffentry.insert(0, HoldOff)
4229  #
4230  INITIALIZEstart()
4231  # Starting acquisition This is a HACK to get around non-continous AWG mode!
4232  # restart AWGs if indicated
4233  if BodeDisp.get() == 0: # make new noise waveforms each sweep
4234  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
4235  AWGAMakeUUNoise()
4236  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
4237  AWGAMakeUGNoise()
4238  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
4239  AWGBMakeUUNoise()
4240  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
4241  AWGBMakeUGNoise()
4242  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
4243  if BDSweepFile.get() == 0:
4244  if LoopNum.get() <= len(FStep):
4245  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
4246  else:
4247  FregPoint = FBins[FStep[0]]
4248  else:
4249  if LoopNum.get() <= len(FileSweepFreq): #
4250  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
4251  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
4252  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
4253  else:
4254  FregPoint = FBins[FileSweepFreq[0]]
4255  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
4256  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
4257  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
4258  if FSweepMode.get() == 1: # set new CH-A amplitude
4259  AWGAAmplEntry.delete(0,END)
4260  AWGAAmplEntry.insert(4, VMin)
4261  AWGAOffsetEntry.delete(0,END)
4262  AWGAOffsetEntry.insert(4, VMax)
4263  if FSweepMode.get() == 2: # set new CH-B amplitude
4264  AWGBAmplEntry.delete(0,END)
4265  AWGBAmplEntry.insert(4, VMin)
4266  AWGBOffsetEntry.delete(0,END)
4267  AWGBOffsetEntry.insert(4, VMax)
4268  if FSweepMode.get() == 1: # set new CH-A frequency
4269  AWGAFreqEntry.delete(0,END)
4270  AWGAFreqEntry.insert(4, FregPoint)
4272  if FSweepMode.get() == 2: # set new CH-B frequency
4273  AWGBFreqEntry.delete(0,END)
4274  AWGBFreqEntry.insert(4, FregPoint)
4276  if FSweepMode.get() == 3: # set new MiniGen frequency
4277  MinigenFout.delete(0,END)
4278  MinigenFout.insert(4, FregPoint)
4279  BSendMG()
4280  if AWGSync.get() > 0:
4281  if IAScreenStatus.get() > 0 and IASource.get() == 0:
4282  if Two_X_Sample.get() == 1:
4283  AWGBIOMode.set(1)
4284  AWGBMode.set(0)
4285  else:
4286  AWGBMode.set(2)
4287  # BAWGEnab()
4288 #
4289  hldn = int(HoldOff * 100 )
4290  if hldn > MaxSamples-SMPfft:
4291  hldn = MaxSamples-SMPfft
4292  HoldOffentry.delete(0,END)
4293  HoldOffentry.insert(0, hldn/100)
4294  if hldn < 128:
4295  hldn = 128
4296  SHOWsamples = SMPfft + hldn # get holf off extra samples
4297  if BodeDisp.get() > 0: # check if doing Bode Plot
4298  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
4299  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
4300  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
4301  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
4302  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
4303  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
4304  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
4305  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
4306  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
4307  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
4308  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
4309  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
4310  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
4311  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
4312  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
4313  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
4314  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4315  if IAScreenStatus.get() > 0 and IASource.get() == 0:
4316  if Two_X_Sample.get() == 1:
4317  AWGBIOMode.set(1)
4318  AWGBMode.set(0)
4319  else:
4320  AWGBMode.set(2)
4321  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4322  if discontloop > 0:
4323  session.flush()
4324  else:
4325  discontloop = 1
4326  BAWGEnab()
4327  try:
4328  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
4329  except:
4330  donothing()
4331  # waite to finish then return to open termination
4332  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4333  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4334  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4335  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4336  else: # running in continuous mode
4337  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
4338  #
4339  else:
4340  if session.continuous:
4341  ADsignal1 = devx.read(SHOWsamples, -1, True)
4342  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
4343  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4344  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4345  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4346  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4347  FFTBuffA = [] # Clear the FFTBuff array for trace A
4348  FFTBuffB = [] # Clear the FFTBuff array for trace B
4349  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
4350  index = hldn # skip first hldn samples
4351  if SHOWsamples != len(ADsignal1):
4352  SHOWsamples = len(ADsignal1)
4353  while index < SHOWsamples:
4354  if Two_X_Sample.get() == 1:
4355  if ADC_Mux_Mode.get() == 0: # VA and VB
4356  FFTBuffA.append(ADsignal1[index][0][0])
4357  FFTBuffA.append(ADsignal1[index][1][1])
4358  FFTBuffB.append(ADsignal1[index][0][1])
4359  FFTBuffB.append(ADsignal1[index][1][0])
4360  else:
4361  VAdata = ADsignal1[index][0][0]
4362  FFTBuffA.append(VAdata)
4363  VBdata = ADsignal1[index][1][0]
4364  FFTBuffB.append(VBdata)
4365  if VAdata > 5.0 or VAdata < 0.0:
4366  OverRangeFlagA = 1
4367 
4368  if VBdata > 5.0 or VBdata < 0.0:
4369  OverRangeFlagB = 1
4370  index = index + 1
4371 
4372  FFTBuffA = numpy.array(FFTBuffA)
4373  FFTBuffB = numpy.array(FFTBuffB)
4374  FFTBuffA = (FFTBuffA - InOffA) * InGainA
4375  FFTBuffB = (FFTBuffB - InOffB) * InGainB
4376  DCA = numpy.average(FFTBuffA)
4377  DCB = numpy.average(FFTBuffB)
4378  if CutDC.get() == 1:
4379  FFTBuffA = FFTBuffA - DCA
4380  FFTBuffB = FFTBuffB - DCB
4381 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4382  if CHA_RC_HP.get() == 1:
4383  try:
4384  TC1A = float(cha_TC1Entry.get())
4385  if TC1A < 0:
4386  TC1A = 0
4387  cha_TC1Entry.delete(0,END)
4388  cha_TC1Entry.insert(0, TC1A)
4389  except:
4390  TC1A = CHA_TC1.get()
4391  try:
4392  TC2A = float(cha_TC2Entry.get())
4393  if TC2A < 0:
4394  TC2A = 0
4395  cha_TC2Entry.delete(0,END)
4396  cha_TC2Entry.insert(0, TC2A)
4397  except:
4398  TC2A = CHA_TC2.get()
4399  #
4400  try:
4401  Gain1A = float(cha_A1Entry.get())
4402  except:
4403  Gain1A = CHA_A1.get()
4404  try:
4405  Gain2A = float(cha_A2Entry.get())
4406  except:
4407  Gain2A = CHA_A2.get()
4408  #
4409  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
4410  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
4411  if CHB_RC_HP.get() == 1:
4412  try:
4413  TC1B = float(chb_TC1Entry.get())
4414  if TC1B < 0:
4415  TC1B = 0
4416  chb_TC1Entry.delete(0, END)
4417  chb_TC1Entry.insert(0, TC1B)
4418  except:
4419  TC1B = CHB_TC1.get()
4420  try:
4421  TC2B = float(chb_TC2Entry.get())
4422  if TC2B < 0:
4423  TC2B = 0
4424  chb_TC2Entry.delete(0, END)
4425  chb_TC2Entry.insert(0, TC2B)
4426  except:
4427  TC2B = CHB_TC2.get()
4428  #
4429  try:
4430  Gain1B = float(chb_A1Entry.get())
4431  except:
4432  Gain1B = CHB_A1.get()
4433  try:
4434  Gain2B = float(chb_A2Entry.get())
4435  except:
4436  Gain2B = CHB_A2.get()
4437  #
4438  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
4439  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
4440 # check if digital filter box checked
4441  if DigFiltA.get() == 1:
4442  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
4443  if DigFiltB.get() == 1:
4444  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
4445  DoFFT()
4446  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
4447  UpdateFreqAll() # Update spectrum Data, trace and screen
4448  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
4449  UpdateIAAll()
4450  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
4451  UpdateBodeAll()
4452  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
4453  UpdateNqPAll()
4454  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
4455  UpdateNiCAll()
4456  if SingleShotSA.get() == 1: # Single shot sweep is on
4457  RUNstatus.set(0)
4458 # RUNstatus = 3: Stop
4459 # RUNstatus = 4: Stop and restart
4460  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
4461  if RUNstatus.get() == 3:
4462  RUNstatus.set(0) # Status is stopped
4463  if RUNstatus.get() == 4:
4464  RUNstatus.set(1) # Status is (re)start
4465  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
4466  UpdateFreqScreen() # Freq UpdateScreen() call
4467  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
4468  UpdateIAScreen()
4469  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
4470  LoopNum.set(LoopNum.get() + 1)
4471  if LoopNum.get() > NSteps.get():
4472  if FSweepMode.get() == 1:
4473  AWGAFreqEntry.delete(0,"end")
4474  AWGAFreqEntry.insert(0, Reset_Freq)
4475  if FSweepMode.get() == 2:
4476  AWGBFreqEntry.delete(0,"end")
4477  AWGBFreqEntry.insert(0, Reset_Freq)
4478 #
4479  LoopNum.set(1)
4480  if FSweepCont.get() == 0:
4481  RUNstatus.set(0)
4482 #
4483 
4485  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
4486  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
4487  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
4488  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4489  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4490  global VABase, VATop, VBBase, VBTop
4491 
4492  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
4493  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
4494  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
4495  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
4496  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
4497  LowerPeak = 0
4498  UpperPeak = 0
4499  b = 0
4500  while (b < 4999):
4501  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
4502  LowerPeak = b
4503  VABase = HBuffA[1][b]
4504  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
4505  UpperPeak = b
4506  VATop = HBuffA[1][b]
4507  b = b + 1
4508  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
4509  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
4510  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
4511  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
4512  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
4513  LowerPeak = 0
4514  UpperPeak = 0
4515  b = 0
4516  while (b < 4999):
4517  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
4518  LowerPeak = b
4519  VBBase = HBuffB[1][b]
4520  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
4521  UpperPeak = b
4522  VBTop = HBuffB[1][b]
4523  b = b + 1
4524 
4526  global HistAsPercent
4527 
4528  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
4529  HistAsPercent = 1
4530  else:
4531  HistAsPercent = 0
4532 
4533 def FindRisingEdge(Trace1, Trace2):
4534  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
4535  global ETSrecord, DISsamples
4536  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
4537  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
4538  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
4539 
4540  anr1 = bnr1 = 0
4541  anf1 = bnf1 = 1
4542  anr2 = bnr2 = 2
4543  hldn = int(HoldOff * SAMPLErate/1000)
4544  # print(DISsamples, len(Trace1))
4545  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
4546  Trace1 = numpy.roll(Trace1, -LShift)
4547  Trace2 = numpy.roll(Trace2, -LShift)
4548  else:
4549  Trace1 = numpy.roll(Trace1, -hldn)
4550  Trace2 = numpy.roll(Trace2, -hldn)
4551  try:
4552  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
4553  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
4554  except:
4555  MidV1 = (MinV1+MaxV1)/2
4556  MidV2 = (MinV2+MaxV2)/2
4557 # search Trace 1
4558 
4565  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
4566  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
4567  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
4568  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
4569 
4570  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
4571  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
4572 # Catch zero length array?
4573  try:
4574  Dummy_read = Arising[0]
4575  except:
4576  return
4577  if len(Arising) > 0 or len(Afalling) > 0:
4578  if Arising[0] > 0:
4579  try:
4580  anr1 = AIrising[0]
4581  except:
4582  anr1 = 0
4583  try:
4584  anr2 = AIrising[1]
4585  except:
4586  anr2 = SHOWsamples
4587  try:
4588  if AIfalling[0] < AIrising[0]:
4589  anf1 = AIfalling[1]
4590  else:
4591  anf1 = AIfalling[0]
4592  except:
4593  anf1 = 1
4594  else:
4595  try:
4596  anr1 = AIrising[1]
4597  except:
4598  anr1 = 0
4599  try:
4600  anr2 = AIrising[2]
4601  except:
4602  anr2 = SHOWsamples
4603  try:
4604  if AIfalling[1] < AIrising[1]:
4605  anf1 = AIfalling[2]
4606  else:
4607  anf1 = AIfalling[1]
4608  except:
4609  anf1 = 1
4610 # search Trace 2
4611 
4618  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
4619  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
4620  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
4621  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
4622 
4623  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
4624  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
4625 # Catch zero length array?
4626  try:
4627  Dummy_read = Brising[0]
4628  except:
4629  return
4630  if len(Brising) > 0 or len(Bfalling) > 0:
4631  if Brising[0] > 0:
4632  try:
4633  bnr1 = BIrising[0]
4634  except:
4635  bnr1 = 0
4636  try:
4637  bnr2 = BIrising[1]
4638  except:
4639  bnr2 = SHOWsamples
4640  try:
4641  if BIfalling[0] < BIrising[0]:
4642  bnf1 = BIfalling[1]
4643  else:
4644  bnf1 = BIfalling[0]
4645  except:
4646  bnf1 = 1
4647  else:
4648  try:
4649  bnr1 = BIrising[1]
4650  except:
4651  bnr1 = 0
4652  try:
4653  bnr2 = BIrising[2]
4654  except:
4655  bnr2 = SHOWsamples
4656  try:
4657  if BIfalling[1] < BIrising[1]:
4658  bnf1 = BIfalling[2]
4659  else:
4660  bnf1 = BIfalling[1]
4661  except:
4662  bnf1 = 1
4663  #
4664  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
4665  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
4666  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
4667  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
4668  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
4669  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
4670 #
4671  if bnr1 > anr1:
4672  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
4673  else:
4674  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
4675  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
4676  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
4677  try:
4678  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
4679  except:
4680  CHABphase = 0.0
4681  if CHABphase < 0.0:
4682  CHABphase = CHABphase + 360.0
4683 
4685  global DX, TRIGGERsample, TRIGGERlevel
4686 
4687  DX = 0
4688  n = TRIGGERsample
4689  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
4690  if DY != 0.0:
4691  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
4692  else:
4693  DX = 0
4694 
4695 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
4696  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
4697  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
4698  global Trigger_LPF_length, LPFTrigger
4699 
4700  # Set the TRACEsize variable
4701  TRACEsize = SHOWsamples # Set the trace length
4702  DX = 0
4703  Is_Triggered = 0
4704  if LPFTrigger.get() > 0:
4705  TFiltCoef = [] # empty coef array
4706  for n in range(Trigger_LPF_length.get()):
4707  TFiltCoef.append(float(1.0/Trigger_LPF_length.get()))
4708  TFiltCoef = numpy.array(TFiltCoef)
4709  TrgBuff = numpy.convolve(TrgBuff, TFiltCoef)
4710 
4711  if len(TrgBuff) == 0:
4712  return
4713  try:
4714  TrgMin = numpy.amin(TrgBuff)
4715  except:
4716  TrgMin = 0.0
4717  try:
4718  TrgMax = numpy.amax(TrgBuff)
4719  except:
4720  TrgMax = 0.0
4721 # Find trigger sample
4722  try:
4723  if AutoLevel.get() == 1:
4724  TRIGGERlevel = (TrgMin + TrgMax)/2
4725  TRIGGERentry.delete(0,"end")
4726  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
4727  else:
4728  TRIGGERlevel = eval(TRIGGERentry.get())
4729  except:
4730  TRIGGERentry.delete(0,END)
4731  TRIGGERentry.insert(0, TRIGGERlevel)
4732 # Start from first sample after HoldOff
4733  try:
4734  HoldOff = float(eval(HoldOffentry.get()))
4735  if HoldOff < 0:
4736  HoldOff = 0
4737  HoldOffentry.delete(0,END)
4738  HoldOffentry.insert(0, HoldOff)
4739  except:
4740  HoldOffentry.delete(0,END)
4741  HoldOffentry.insert(0, HoldOff)
4742 # slide trace left right by HozPoss
4743  try:
4744  HozPoss = float(eval(HozPossentry.get()))
4745  except:
4746  HozPossentry.delete(0,END)
4747  HozPossentry.insert(0, HozPoss)
4748 
4749  hldn = int(HoldOff * SAMPLErate/1000)
4750  hozpos = int(HozPoss * SAMPLErate/1000)
4751  if hozpos >= 0:
4752  TRIGGERsample = hldn
4753  else:
4754  TRIGGERsample = abs(hozpos)
4755 #
4756  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
4757  DX = 0
4758  n = TRIGGERsample
4759  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
4760  if TRIGGERlevel2 < TrgMin:
4761  TRIGGERlevel2 = TrgMin
4762  if TRIGGERlevel2 > TrgMax:
4763  TRIGGERlevel2 = TrgMax
4764  ChInput = TrgBuff[int(n)]
4765  Prev = ChInput
4766  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
4767  n = n + 1
4768  ChInput = TrgBuff[int(n)]
4769  while (ChInput <= TRIGGERlevel) and n < Nmax:
4770  Prev = ChInput
4771  n = n + 1
4772  ChInput = TrgBuff[int(n)]
4773  DY = ChInput - Prev
4774  if DY != 0.0:
4775  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
4776  else:
4777  DX = 0
4778  if TgEdge.get() == 1:
4779  TRIGGERlevel2 = 1.01 * TRIGGERlevel
4780  if TRIGGERlevel2 < TrgMin:
4781  TRIGGERlevel2 = TrgMin
4782  if TRIGGERlevel2 > TrgMax:
4783  TRIGGERlevel2 = TrgMax
4784  ChInput = TrgBuff[int(n)]
4785  Prev = ChInput
4786  while (ChInput <= TRIGGERlevel2) and n < Nmax:
4787  n = n + 1
4788  ChInput = TrgBuff[int(n)]
4789  while (ChInput >= TRIGGERlevel) and n < Nmax:
4790  Prev = ChInput
4791  n = n + 1
4792  ChInput = TrgBuff[int(n)]
4793  DY = Prev - ChInput
4794  try:
4795  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
4796  except:
4797  DX = 0
4798 
4799 # check to insure trigger point is in bounds
4800  if n < Nmax:
4801  TRIGGERsample = n - 1
4802  Is_Triggered = 1
4803  elif n > Nmax: # Didn't find edge in first 2/3 of data set
4804  TRIGGERsample = 1 + hldn # reset to begining
4805  Is_Triggered = 0
4806  if DX > 1:
4807  DX = 1 # never more than 100% of a sample period
4808  elif DX < 0:
4809  DX = 0 # never less than 0% of a sample period
4810  if math.isnan(DX):
4811  DX = 0
4812  TRIGGERsample = TRIGGERsample + hozpos
4813 
4815  global win2, DigScreenStatus
4816 
4817  DigScreenStatus.set(0)
4818  win2.destroy()
4819 
4820 def sel():
4821  global devx, DevID
4822  global D0, D1, D2, D3, D4, D5, D6, D7
4823  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4824  # sending 0x50 = set to 0, 0x51 = set to 1
4825  if D0.get() > 0:
4826  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
4827  else:
4828  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
4829  if D1.get() > 0:
4830  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
4831  else:
4832  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
4833  if D2.get() > 0:
4834  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
4835  else:
4836  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
4837  if D3.get() > 0:
4838  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
4839  else:
4840  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
4841  if D4.get() > 0:
4842  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
4843  else:
4844  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
4845  if D5.get() > 0:
4846  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
4847  else:
4848  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
4849  if D6.get() > 0:
4850  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
4851  else:
4852  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
4853  if D7.get() > 0:
4854  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
4855  else:
4856  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
4857 
4859  global D0, D1, D2, D3, D4, D5, D6, D7
4860  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4861  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
4862  # setup Dig output window
4863  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
4864  DigScreenStatus.set(1)
4865  win2 = Toplevel()
4866  win2.title("Dig Out")
4867  win2.resizable(FALSE,FALSE)
4868  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
4869  rb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
4870  rb1.grid(row=2, column=0, sticky=W)
4871  rb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
4872  rb0z.grid(row=2, column=1, sticky=W)
4873  rb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
4874  rb2.grid(row=2, column=2, sticky=W)
4875  rb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
4876  rb3.grid(row=3, column=0, sticky=W)
4877  rb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
4878  rb3z.grid(row=3, column=1, sticky=W)
4879  rb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
4880  rb4.grid(row=3, column=2, sticky=W)
4881  rb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
4882  rb5.grid(row=4, column=0, sticky=W)
4883  rb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
4884  rb5z.grid(row=4, column=1, sticky=W)
4885  rb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
4886  rb6.grid(row=4, column=2, sticky=W)
4887  rb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
4888  rb7.grid(row=5, column=0, sticky=W)
4889  rb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
4890  rb7z.grid(row=5, column=1, sticky=W)
4891  rb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
4892  rb8.grid(row=5, column=2, sticky=W)
4893  rb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
4894  rb9.grid(row=6, column=0, sticky=W)
4895  rb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
4896  rb9z.grid(row=6, column=1, sticky=W)
4897  rb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
4898  rb10.grid(row=6, column=2, sticky=W)
4899  rb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
4900  rb11.grid(row=7, column=0, sticky=W)
4901  rb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
4902  rb11z.grid(row=7, column=1, sticky=W)
4903  rb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
4904  rb12.grid(row=7, column=2, sticky=W)
4905  rb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
4906  rb13.grid(row=8, column=0, sticky=W)
4907  rb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
4908  rb13z.grid(row=8, column=1, sticky=W)
4909  rb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
4910  rb13.grid(row=8, column=2, sticky=W)
4911  rb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
4912  rb14.grid(row=9, column=0, sticky=W)
4913  rb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
4914  rb14z.grid(row=9, column=1, sticky=W)
4915  rb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
4916  rb15.grid(row=9, column=2, sticky=W)
4917 
4918  dismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
4919  dismissbutton.grid(row=10, column=0, sticky=W)
4920 
4922  global win1, DacScreenStatus
4923 
4924  DacScreenStatus.set(0)
4925  win1.destroy()
4926 
4927 def sel0(temp):
4928  global devx, DevID
4929  global PIO_0, PIO_4
4930  global DAC0
4931  # sending 0x50 = set to 0, 0x51 = set to 1
4932  if DAC0.get() == 1:
4933  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4934  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
4935  elif DAC0.get() == 4:
4936  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4937  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
4938  elif DAC0.get() == 2:
4939  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4940  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4941  elif DAC0.get() == 3:
4942  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
4943  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
4944  elif DAC0.get() == 5:
4945  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
4946  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4947  elif DAC0.get() == 7:
4948  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
4949  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
4950  elif DAC0.get() == 8:
4951  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
4952  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4953  elif DAC0.get() == 6:
4954  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
4955  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
4956  elif DAC0.get() == 9:
4957  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
4958  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
4959 
4960 def sel1(temp):
4961  global devx, DevID
4962  global PIO_1, PIO_5
4963  global DAC1
4964  # sending 0x50 = set to 0, 0x51 = set to 1
4965  if DAC1.get() == 1:
4966  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4967  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
4968  elif DAC1.get() == 4:
4969  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4970  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
4971  elif DAC1.get() == 2:
4972  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4973  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4974  elif DAC1.get() == 3:
4975  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4976  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
4977  elif DAC1.get() == 5:
4978  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4979  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4980  elif DAC1.get() == 7:
4981  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4982  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
4983  elif DAC1.get() == 8:
4984  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
4985  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4986  elif DAC1.get() == 6:
4987  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
4988  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
4989  elif DAC1.get() == 9:
4990  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
4991  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
4992 
4993 def sel2(temp):
4994  global devx, DevID
4995  global PIO_2, PIO_6
4996  global DAC2
4997  # sending 0x50 = set to 0, 0x51 = set to 1
4998  if DAC2.get() == 1:
4999  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5000  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
5001  elif DAC2.get() == 4:
5002  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5003  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
5004  elif DAC2.get() == 2:
5005  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5006  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5007  elif DAC2.get() == 3:
5008  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5009  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
5010  elif DAC2.get() == 5:
5011  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5012  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5013  elif DAC2.get() == 7:
5014  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5015  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
5016  elif DAC2.get() == 8:
5017  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
5018  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5019  elif DAC2.get() == 6:
5020  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
5021  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
5022  elif DAC2.get() == 9:
5023  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
5024  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
5025 
5026 def sel3(temp):
5027  global devx, DevID
5028  global PIO_3, PIO_7
5029  global DAC3
5030  # sending 0x50 = set to 0, 0x51 = set to 1
5031  if DAC3.get() == 1:
5032  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5033  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
5034  elif DAC3.get() == 4:
5035  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5036  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
5037  elif DAC3.get() == 2:
5038  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5039  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5040  elif DAC3.get() == 3:
5041  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5042  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
5043  elif DAC3.get() == 5:
5044  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5045  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5046  elif DAC3.get() == 7:
5047  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5048  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
5049  elif DAC3.get() == 8:
5050  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
5051  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5052  elif DAC3.get() == 6:
5053  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
5054  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
5055  elif DAC3.get() == 9:
5056  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
5057  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
5058 
5060  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
5061  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
5062  # setup Dig output window
5063  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
5064  DacScreenStatus.set(1)
5065  win1 = Toplevel()
5066  win1.title("DAC Out "+ SWRev + RevDate)
5067  win1.resizable(FALSE,FALSE)
5068  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
5069  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
5070  DAC0.grid(row=0, column=0, sticky=W)
5071  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
5072  DAC1.grid(row=0, column=1, sticky=W)
5073  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
5074  DAC2.grid(row=0, column=2, sticky=W)
5075  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
5076  DAC3.grid(row=0, column=3, sticky=W)
5077 
5078  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
5079  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
5080 
5082 
5083  MakeTimeTrace() # Update the traces
5084  UpdateTimeScreen() # Update the screen
5085 
5087 
5088  MakeTimeTrace() # Update traces
5089  UpdateTimeScreen() # Update the screen
5090 
5092 
5093  MakeTimeScreen() # Update the screen
5094  root.update() # Activate updated screens
5095 
5097 
5098  MakeXYTrace() # Update the traces
5099  UpdateXYScreen() # Update the screen
5100 
5102 
5103  MakeXYTrace() # Update traces
5104  UpdateXYScreen() # Update the screen
5105 
5107 
5108  MakeXYScreen() # Update the screen
5109  root.update() # Activate updated screens
5110 
5112  global VBuffA, VBuffB, IBuffA, IBuffB
5113  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus
5114  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
5115  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
5116  global FFTBuffA, FFTBuffB, FFTwindowshape
5117  global AWGAwaveform, AWGBwaveform
5118  global T1Vline, T2Vline, T1Iline, T2Iline
5119  global TMAVline, TMBVline, TMCVline, TMDVline
5120  global Tmathline, TMXline, TMYline
5121  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
5122  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
5123  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
5124  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
5125  global SHOWsamples, ZOHold, AWGBMode
5126  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
5127  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
5128  global Show_MathX, Show_MathY
5129  global TRACES, TRACESread, RUNstatus
5130  global AutoCenterA, AutoCenterB
5131  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
5132  global TMpdiv # Array with time / div values in ms
5133  global TMsb # Time per div spin box variable
5134  global TIMEdiv # current spin box value
5135  global SAMPLErate, SCstart, Two_X_Sample, DISsamples
5136  global TRIGGERsample, TRACEsize, DX
5137  global TRIGGERlevel, TRIGGERentry, AutoLevel
5138  global InOffA, InGainA, InOffB, InGainB
5139  global CurOffA, CurOffB, CurGainA, CurGainB
5140  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5141  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5142  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
5143  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
5144  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
5145  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
5146  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
5147  global HozPoss, HozPossentry
5148 
5149  # Set the TRACEsize variable
5150  if len(VBuffA) < 100:
5151  return
5152  TRACEsize = SHOWsamples # Set the trace length
5153  SCstart = 0
5154  ylo = 0.0
5155  xlo = 0.0
5156  Ymin = Y0T # Minimum position of time grid (top)
5157  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
5158  Xmin = X0L # Minimum position of time grid (left)
5159  Xmax = X0L + GRW # Maximum position of time grid (right)
5160 
5161  # prevent divide by zero error
5162  if TIMEdiv < 0.0002:
5163  TIMEdiv = 0.01
5164  # Check for Auto Centering
5165  if AutoCenterA.get() > 0:
5166  CHAOffset = DCV1
5167  CHAVPosEntry.delete(0,END)
5168  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
5169  if AutoCenterB.get() > 0:
5170  CHBOffset = DCV2
5171  CHBVPosEntry.delete(0,END)
5172  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
5173  # get the vertical ranges
5174  try:
5175  CH1pdvRange = float(eval(CHAsb.get()))
5176  except:
5177  CHAsb.delete(0,END)
5178  CHAsb.insert(0, CH1vpdvRange)
5179  try:
5180  CH2pdvRange = float(eval(CHBsb.get()))
5181  except:
5182  CHBsb.delete(0,END)
5183  CHBsb.insert(0, CH2vpdvRange)
5184  try:
5185  CH1IpdvRange = float(eval(CHAIsb.get()))
5186  except:
5187  CHAIsb.delete(0,END)
5188  CHAIsb.insert(0, CH1IpdvRange)
5189  try:
5190  CH2IpdvRange = float(eval(CHBIsb.get()))
5191  except:
5192  CHBIsb.delete(0,END)
5193  CHBIsb.insert(0, CH2IpdvRange)
5194  # get the vertical offsets
5195  try:
5196  CHAOffset = float(eval(CHAVPosEntry.get()))
5197  except:
5198  CHAVPosEntry.delete(0,END)
5199  CHAVPosEntry.insert(0, CHAOffset)
5200  try:
5201  CHAIOffset = float(eval(CHAIPosEntry.get()))
5202  except:
5203  CHAIPosEntry.delete(0,END)
5204  CHAIPosEntry.insert(0, CHAIOffset)
5205  try:
5206  CHBOffset = float(eval(CHBVPosEntry.get()))
5207  except:
5208  CHBVPosEntry.delete(0,END)
5209  CHBVPosEntry.insert(0, CHBOffset)
5210  try:
5211  CHBIOffset = float(eval(CHBIPosEntry.get()))
5212  except:
5213  CHBIPosEntry.delete(0,END)
5214  CHBIPosEntry.insert(0, CHBIOffset)
5215  # prevent divide by zero error
5216  if CH1pdvRange < 0.001:
5217  CH1pdvRange = 0.001
5218  if CH2pdvRange < 0.001:
5219  CH2pdvRange = 0.001
5220  if CH1IpdvRange < 0.1:
5221  CH1IpdvRange = 0.1
5222  if CH2IpdvRange < 0.1:
5223  CH2IpdvRange = 0.1
5224 #
5225  try:
5226  HoldOff = float(eval(HoldOffentry.get()))
5227  if HoldOff < 0:
5228  HoldOff = 0
5229  HoldOffentry.delete(0,END)
5230  HoldOffentry.insert(0, HoldOff)
5231  except:
5232  HoldOffentry.delete(0,END)
5233  HoldOffentry.insert(0, HoldOff)
5234 #
5235  try:
5236  HozPoss = float(eval(HozPossentry.get()))
5237  except:
5238  HozPossentry.delete(0,END)
5239  HozPossentry.insert(0, HozPoss)
5240 #
5241  hldn = int(HoldOff * SAMPLErate/1000 )
5242  hozpos = int(HozPoss * SAMPLErate/1000 )
5243  if hozpos < 0:
5244  hozpos = 0
5245  # drawing the traces
5246  if TRACEsize == 0: # If no trace, skip rest of this routine
5247  T1Vline = [] # Trace line channel A V
5248  T2Vline = [] # Trace line channel B V
5249  T1Iline = []
5250  T2Iline = []
5251  TMAVline = [] # V Trace line Mux channel A
5252  TMBVline = [] # V Trace line Mux channel B
5253  TMCVline = [] # V Trace line Mux channel C
5254  TMDVline = [] # V Trace line Mux channel D
5255  Tmathline = [] # math trce line
5256  return()
5257 
5258  # set and/or corrected for in range
5259  if TgInput.get() > 0:
5260  SCmin = int(-1 * TRIGGERsample)
5261  SCmax = int(TRACEsize - TRIGGERsample - 0)
5262  else:
5263  SCmin = 0 # hldn
5264  SCmax = TRACEsize - 1
5265  if SCstart < SCmin: # No reading before start of array
5266  SCstart = SCmin
5267  if SCstart > SCmax: # No reading after end of array
5268  SCstart = SCmax
5269 
5270  # Make Trace lines etc.
5271 
5272  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
5273  Yconv2 = float(GRH/10.0) / CH2pdvRange
5274  YIconv1 = float(GRH/10.0) / CH1IpdvRange
5275  YIconv2 = float(GRH/10.0) / CH2IpdvRange
5276  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
5277  Xconv2 = float(GRW/10.0) / CH2pdvRange
5278  XIconv1 = float(GRW/10.0) / CH1IpdvRange
5279  XIconv2 = float(GRW/10.0) / CH2IpdvRange
5280  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
5281  try:
5282  CHMApdvRange = float(eval(CHB_Asb.get()))
5283  except:
5284  CHB_Asb.delete(0,END)
5285  CHB_Asb.insert(0, CHMApdvRange)
5286  try:
5287  CHMBpdvRange = float(eval(CHB_Bsb.get()))
5288  except:
5289  CHB_Bsb.delete(0,END)
5290  CHB_Bsb.insert(0, CHMBpdvRange)
5291  try:
5292  CHMCpdvRange = float(eval(CHB_Csb.get()))
5293  except:
5294  CHB_Csb.delete(0,END)
5295  CHB_Csb.insert(0, CHMCpdvRange)
5296  try:
5297  CHMDpdvRange = float(eval(CHB_Dsb.get()))
5298  except:
5299  CHB_Dsb.delete(0,END)
5300  CHB_Dsb.insert(0, CHMDpdvRange)
5301  YconvMA = float(GRH/10.0) / CHMApdvRange
5302  YconvMB = float(GRH/10.0) / CHMBpdvRange
5303  YconvMC = float(GRH/10.0) / CHMCpdvRange
5304  YconvMD = float(GRH/10.0) / CHMDpdvRange
5305  try:
5306  CHBAOffset = float(eval(CHB_APosEntry.get()))
5307  except:
5308  CHB_APosEntry.delete(0,END)
5309  CHB_APosEntry.insert(0, CHBAOffset)
5310  try:
5311  CHBBOffset = float(eval(CHB_BPosEntry.get()))
5312  except:
5313  CHB_BPosEntry.delete(0,END)
5314  CHB_BPosEntry.insert(0, CHBBOffset)
5315  try:
5316  CHBCOffset = float(eval(CHB_CPosEntry.get()))
5317  except:
5318  CHB_CPosEntry.delete(0,END)
5319  CHB_CPosEntry.insert(0, CHBCOffset)
5320  try:
5321  CHBDOffset = float(eval(CHB_DPosEntry.get()))
5322  except:
5323  CHB_DPosEntry.delete(0,END)
5324  CHB_DPosEntry.insert(0, CHBDOffset)
5325  if MathAxis == "V-A":
5326  YconvM = Yconv1
5327  CHMOffset = CHAOffset
5328  elif MathAxis == "V-B":
5329  YconvM = Yconv2
5330  CHMOffset = CHBOffset
5331  elif MathAxis == "I-A":
5332  YconvM = YIconv1
5333  CHMOffset = CHAIOffset
5334  elif MathAxis == "I-B":
5335  YconvM = YIconv2
5336  CHMOffset = CHBIOffset
5337  else:
5338  YconvM = Yconv1
5339  CHMOffset = CHAOffset
5340 # include ploting X and Y math formulas vs time
5341  if MathYAxis == "V-A":
5342  YconvMxy = Yconv1
5343  CHMYOffset = CHAOffset
5344  elif MathYAxis == "V-B":
5345  YconvMxy = Yconv2
5346  CHMYOffset = CHBOffset
5347  elif MathYAxis == "I-A":
5348  YconvMxy = YIconv1
5349  CHMYOffset = CHAIOffset
5350  elif MathYAxis == "I-B":
5351  YconvMxy = YIconv2
5352  CHMYOffset = CHBIOffset
5353  else:
5354  YconvMxy = Yconv1
5355  CHMYOffset = CHAOffset
5356 #
5357  if MathXAxis == "V-A":
5358  XconvMxy = Yconv1
5359  CHMXOffset = CHAOffset
5360  elif MathXAxis == "V-B":
5361  XconvMxy = Yconv2
5362  CHMXOffset = CHBOffset
5363  elif MathXAxis == "I-A":
5364  XconvMxy = YIconv1
5365  CHMXOffset = CHAIOffset
5366  elif MathXAxis == "I-B":
5367  XconvMxy = YIconv2
5368  CHMXOffset = CHBIOffset
5369  else:
5370  XconvMxy = Yconv1
5371  CHMXOffset = CHAOffset
5372 #
5373  c1 = GRH / 2.0 + Y0T # fixed correction channel A
5374  c2 = GRH / 2.0 + Y0T # fixed correction channel B
5375 
5376  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
5377  T1Vline = [] # V Trace line channel A
5378  T2Vline = [] # V Trace line channel B
5379  T1Iline = [] # I Trace line channel A
5380  T2Iline = [] # I Trace line channel B
5381  TMAVline = [] # V Trace line Mux channel A
5382  TMBVline = [] # V Trace line Mux channel B
5383  TMCVline = [] # V Trace line Mux channel C
5384  TMDVline = [] # V Trace line Mux channel D
5385  Tmathline = [] # math trce line
5386  TMXline = [] # X math Trace line
5387  TMYline = [] # Y math Trace line
5388  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
5389  return
5390  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
5391  if t < 0:
5392  t = 0
5393  x = 0 # Horizontal screen pixel
5394 #
5395  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
5396  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
5397  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
5398  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
5399  DvY1 = DvY2 = DiY1 = DiY2 = 0
5400 #
5401  if (DISsamples <= GRW):
5402  Xstep = GRW / DISsamples
5403  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
5404  xa = int((Xstep/-2.5) - (Xstep*DX))
5405  else:
5406  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
5407  x = 0 - int(Xstep*DX)
5408  Tstep = 1
5409  x1 = 0 # x position of trace line
5410  xa1 = 0
5411  y1 = 0.0 # y position of trace line
5412  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
5413  ytemp = IBuffA[t]
5414  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
5415  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
5416  if MuxScreenStatus.get() == 1:
5417  if len(VBuffMA) > 4:
5418  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
5419  if len(VBuffMB) > 4:
5420  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
5421  if len(VBuffMC) > 4:
5422  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
5423  if len(VBuffMD) > 4:
5424  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
5425  ytemp = IBuffB[t]
5426  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
5427  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
5428  if TgInput.get() == 0:
5429  Xlimit = GRW
5430  else:
5431  Xlimit = GRW+Xstep
5432  while x <= Xlimit:
5433  if t < TRACEsize:
5434  xa1 = xa + X0L
5435  x1 = x + X0L
5436  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
5437  ytemp = IBuffA[t]
5438  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
5439 
5440  if y1 < Ymin: # clip waveform if going off grid
5441  y1 = Ymin
5442  if y1 > Ymax:
5443  y1 = Ymax
5444  if yi1 < Ymin:
5445  yi1 = Ymin
5446  if yi1 > Ymax:
5447  yi1 = Ymax
5448  if ShowC1_V.get() == 1 :
5449  if ZOHold.get() == 1:
5450  T1Vline.append(int(xa1))
5451  T1Vline.append(int(ypv1))
5452  T1Vline.append(int(xa1))
5453  T1Vline.append(int(y1))
5454  else:
5455  T1Vline.append(int(xa1))
5456  T1Vline.append(int(y1))
5457  DvY1 = ypv1 - y1
5458  ypv1 = y1
5459  if ShowC1_I.get() == 1:
5460  if ZOHold.get() == 1:
5461  T1Iline.append(int(xa1))
5462  T1Iline.append(int(ypi1))
5463  T1Iline.append(int(xa1))
5464  T1Iline.append(int(yi1))
5465  else:
5466  T1Iline.append(int(xa1))
5467  T1Iline.append(int(yi1))
5468  DiY1 = ypi1 - yi1
5469  ypi1 = yi1
5470  if ShowC2_V.get() == 1:
5471  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
5472  if y1 < Ymin: # clip waveform if going off grid
5473  y1 = Ymin
5474  if y1 > Ymax:
5475  y1 = Ymax
5476  if ZOHold.get() == 1:
5477  T2Vline.append(int(x1))
5478  T2Vline.append(int(ypv2))
5479  T2Vline.append(int(x1))
5480  T2Vline.append(int(y1))
5481  else:
5482  T2Vline.append(int(x1))
5483  T2Vline.append(int(y1))
5484  DvY2 = ypv2 - y1
5485  ypv2 = y1
5486  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
5487  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
5488  if y1 < Ymin: # clip waveform if going off grid
5489  y1 = Ymin
5490  if y1 > Ymax:
5491  y1 = Ymax
5492  if ZOHold.get() == 1:
5493  TMAVline.append(int(x1))
5494  TMAVline.append(int(ypvma))
5495  TMAVline.append(int(x1))
5496  TMAVline.append(int(y1))
5497  else:
5498  TMAVline.append(int(x1))
5499  TMAVline.append(int(y1))
5500  ypvma = y1
5501  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5502  Xfine = MouseX - X0L - x
5503  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
5504  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
5505  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
5506  if y1 < Ymin: # clip waveform if going off grid
5507  y1 = Ymin
5508  if y1 > Ymax:
5509  y1 = Ymax
5510  if ZOHold.get() == 1:
5511  TMBVline.append(int(x1))
5512  TMBVline.append(int(ypvmb))
5513  TMBVline.append(int(x1))
5514  TMBVline.append(int(y1))
5515  else:
5516  TMBVline.append(int(x1))
5517  TMBVline.append(int(y1))
5518  ypvmb = y1
5519  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5520  Xfine = MouseX - X0L - x
5521  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
5522  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
5523  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
5524  if y1 < Ymin: # clip waveform if going off grid
5525  y1 = Ymin
5526  if y1 > Ymax:
5527  y1 = Ymax
5528  if ZOHold.get() == 1:
5529  TMCVline.append(int(x1))
5530  TMCVline.append(int(ypvmc))
5531  TMCVline.append(int(x1))
5532  TMCVline.append(int(y1))
5533  else:
5534  TMCVline.append(int(x1))
5535  TMCVline.append(int(y1))
5536  ypvmc = y1
5537  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5538  Xfine = MouseX - X0L - x
5539  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
5540  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
5541  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
5542  if y1 < Ymin: # clip waveform if going off grid
5543  y1 = Ymin
5544  if y1 > Ymax:
5545  y1 = Ymax
5546  if ZOHold.get() == 1:
5547  TMDVline.append(int(x1))
5548  TMDVline.append(int(ypvmd))
5549  TMDVline.append(int(x1))
5550  TMDVline.append(int(y1))
5551  else:
5552  TMDVline.append(int(x1))
5553  TMDVline.append(int(y1))
5554  ypvmd = y1
5555  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5556  Xfine = MouseX - X0L - x
5557  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
5558  if ShowC2_I.get() == 1:
5559  ytemp = IBuffB[t]
5560  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
5561  if yi1 < Ymin:
5562  yi1 = Ymin
5563  if yi1 > Ymax:
5564  yi1 = Ymax
5565  if (ZOHold.get() == 1):
5566  T2Iline.append(int(x1))
5567  T2Iline.append(int(ypi2))
5568  T2Iline.append(int(x1))
5569  T2Iline.append(int(yi1))
5570  else:
5571  T2Iline.append(int(x1))
5572  T2Iline.append(int(yi1))
5573  DiY2 = ypi2 - yi1
5574  ypi2 = yi1
5575  if MathTrace.get() > 0:
5576  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
5577  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
5578 
5579  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
5580  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
5581 
5582  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
5583  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
5584 
5585  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
5586  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
5587  ytemp = YIconv1 * (Ypower - CHAIOffset)
5588  y1 = int(c1 - ytemp)
5589 
5590  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
5591  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
5592  ytemp = YIconv2 * (Ypower - CHBIOffset)
5593  y1 = int(c2 - ytemp)
5594 
5595  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
5596  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
5597  ytemp = YIconv1 * (Yohms - CHAIOffset)
5598  y1 = int(c1 - ytemp)
5599 
5600  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
5601  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
5602  ytemp = YIconv2 * (Yohms - CHBIOffset)
5603  y1 = int(c2 - ytemp)
5604 
5605  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
5606  Ydif = (IBuffA[t] - IBuffB[t])# in mA
5607  ytemp = YIconv1 * (Ydif - CHAIOffset)
5608  y1 = int(c2 - ytemp)
5609 
5610  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
5611  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
5612  ytemp = YIconv2 * (Ydif - CHBIOffset)
5613  y1 = int(c2 - ytemp)
5614 
5615  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
5616  try:
5617  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
5618  except:
5619  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
5620 
5621  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
5622  try:
5623  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
5624  except:
5625  Y1 = (IBuffB[t] / 0.000001)
5626  ytemp = YIconv2 * (Y1 - CHBIOffset)
5627  y1 = int(c2 - ytemp)
5628 
5629  elif MathTrace.get() == 12: # plot from equation string
5630  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
5631  try:
5632  MathResult = eval(MathString)
5633  MathResult = MathResult - CHMOffset
5634  y1 = int(c1 - YconvM * MathResult)
5635  except:
5636  RUNstatus.set(0)
5637  x = Xlimit + 1 # exit loop
5638 
5639  if y1 < Ymin: # clip waveform if going off grid
5640  y1 = Ymin
5641  if y1 > Ymax:
5642  y1 = Ymax
5643  if ZOHold.get() == 1: # connet the dots with stair step
5644  Tmathline.append(int(x1))
5645  Tmathline.append(int(ypm))
5646  Tmathline.append(int(x1))
5647  Tmathline.append(int(y1))
5648  else: # connet the dots with single line
5649  Tmathline.append(int(x1))
5650  Tmathline.append(int(y1))
5651  ypm = y1
5652  if Show_MathX.get() > 0:
5653  try:
5654  MathResult = eval(MathXString)
5655  MathResult = MathResult - CHMXOffset
5656  y1 = int(c1 - XconvMxy * MathResult)
5657  except:
5658  RUNstatus.set(0)
5659  x = Xlimit + 1 # exit loop
5660 
5661  if y1 < Ymin: # clip waveform if going off grid
5662  y1 = Ymin
5663  if y1 > Ymax:
5664  y1 = Ymax
5665  if ZOHold.get() == 1: # connet the dots with stair step
5666  TMXline.append(int(x1))
5667  TMXline.append(int(ypmx))
5668  TMXline.append(int(x1))
5669  TMXline.append(int(y1))
5670  else: # connet the dots with single line
5671  TMXline.append(int(x1))
5672  TMXline.append(int(y1))
5673  ypmx = y1
5674  if Show_MathY.get() > 0:
5675  try:
5676  MathResult = eval(MathYString)
5677  MathResult = MathResult - CHMYOffset
5678  y1 = int(c1 - YconvMxy * MathResult)
5679  except:
5680  RUNstatus.set(0)
5681  x = Xlimit + 1 # exit loop
5682 
5683  if y1 < Ymin: # clip waveform if going off grid
5684  y1 = Ymin
5685  if y1 > Ymax:
5686  y1 = Ymax
5687  if ZOHold.get() == 1: # connet the dots with stair step
5688  TMYline.append(int(x1))
5689  TMYline.append(int(ypmy))
5690  TMYline.append(int(x1))
5691  TMYline.append(int(y1))
5692  else: # connet the dots with single line
5693  TMYline.append(int(x1))
5694  TMYline.append(int(y1))
5695  ypmy = y1
5696  # remember trace verticle pixel at X mouse location
5697  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
5698  Xfine = MouseX - X0L - x
5699  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
5700  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
5701  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
5702  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
5703  t = int(t + Tstep)
5704  x = x + Xstep
5705  xa = xa + Xstep
5706 
5707  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
5708  Xstep = 1
5709  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
5710  x1 = 0.0 # x position of trace line
5711  ylo = 0.0 # ymin position of trace 1 line
5712  yhi = 0.0 # ymax position of trace 1 line
5713 
5714  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
5715  if t > len(VBuffA)-1:
5716  t = 0
5717  if t < 0:
5718  t = 0
5719  x = 0 # Horizontal screen pixel
5720  ft = t # time point with fractions
5721  while (x <= GRW):
5722  if (t < TRACEsize):
5723  if (t >= len(VBuffA)):
5724  t = len(VBuffA)-2
5725  x = GRW
5726  x1 = x + X0L
5727  ylo = VBuffA[t] - CHAOffset
5728  ilo = IBuffA[t] - CHAIOffset
5729  yhi = ylo
5730  ihi = ilo
5731  n = t
5732  while n < (t + Tstep) and n < TRACEsize:
5733  if ( ShowC1_V.get() == 1 ):
5734  v = VBuffA[t] - CHAOffset
5735  if v < ylo:
5736  ylo = v
5737  if v > yhi:
5738  yhi = v
5739  if ( ShowC1_I.get() == 1 ):
5740  i = IBuffA[t] - CHAIOffset
5741  if i < ilo:
5742  ilo = i
5743  if i > ihi:
5744  ihi = i
5745  n = n + 1
5746  if ( ShowC1_V.get() == 1 ):
5747  ylo = int(c1 - Yconv1 * ylo)
5748  yhi = int(c1 - Yconv1 * yhi)
5749  if (ylo < Ymin):
5750  ylo = Ymin
5751  if (ylo > Ymax):
5752  ylo = Ymax
5753  if (yhi < Ymin):
5754  yhi = Ymin
5755  if (yhi > Ymax):
5756  yhi = Ymax
5757  T1Vline.append(int(x1))
5758  T1Vline.append(int(ylo))
5759  T1Vline.append(int(x1))
5760  T1Vline.append(int(yhi))
5761  ypv1 = ylo
5762  if ( ShowC1_I.get() == 1 ):
5763  ilo = int(c1 - YIconv1 * ilo)
5764  ihi = int(c1 - YIconv1 * ihi)
5765  if (ilo < Ymin):
5766  ilo = Ymin
5767  if (ilo > Ymax):
5768  ilo = Ymax
5769  if (ihi < Ymin):
5770  ihi = Ymin
5771  if (ihi > Ymax):
5772  ihi = Ymax
5773  T1Iline.append(int(x1))
5774  T1Iline.append(int(ilo))
5775  T1Iline.append(int(x1))
5776  T1Iline.append(int(ihi))
5777  ypi1 = ilo
5778  ylo = VBuffB[t] - CHBOffset
5779  ilo = IBuffB[t] - CHBIOffset
5780  yhi = ylo
5781  ihi = ilo
5782  n = t
5783  if MuxScreenStatus.get() == 0:
5784  while n < (t + Tstep) and n < TRACEsize:
5785  if ( ShowC2_V.get() == 1 ):
5786  v = VBuffB[t] - CHBOffset
5787  if v < ylo:
5788  ylo = v
5789  if v > yhi:
5790  yhi = v
5791  if ( ShowC2_I.get() == 1 ):
5792  i = IBuffB[t] - CHBIOffset
5793  if i < ilo:
5794  ilo = i
5795  if i > ihi:
5796  ihi = i
5797  n = n + 1
5798  if ( ShowC2_V.get() == 1 ):
5799  ylo = int(c2 - Yconv2 * ylo)
5800  yhi = int(c2 - Yconv2 * yhi)
5801  if (ylo < Ymin):
5802  ylo = Ymin
5803  if (ylo > Ymax):
5804  ylo = Ymax
5805 
5806  if (yhi < Ymin):
5807  yhi = Ymin
5808  if (yhi > Ymax):
5809  yhi = Ymax
5810  T2Vline.append(int(x1))
5811  T2Vline.append(int(ylo))
5812  T2Vline.append(int(x1))
5813  T2Vline.append(int(yhi))
5814  ypv2 = ylo
5815  if ( ShowC2_I.get() == 1 ):
5816  ilo = int(c2 - YIconv2 * ilo)
5817  ihi = int(c2 - YIconv2 * ihi)
5818  if (ilo < Ymin):
5819  ilo = Ymin
5820  if (ilo > Ymax):
5821  ilo = Ymax
5822  if (ihi < Ymin):
5823  ihi = Ymin
5824  if (ihi > Ymax):
5825  ihi = Ymax
5826  T2Iline.append(int(x1))
5827  T2Iline.append(int(ilo))
5828  T2Iline.append(int(x1))
5829  T2Iline.append(int(ihi))
5830  ypi2 = ilo
5831  else:
5832  if Show_CBA.get() == 1 and len(VBuffMA)>4:
5833  if t < len(VBuffMA):
5834  ylo = VBuffMA[t] - CHBAOffset
5835  yhi = ylo
5836  n = t
5837  while n < (t + Tstep) and n < len(VBuffMA):
5838  v = VBuffMA[t] - CHBAOffset
5839  if v < ylo:
5840  ylo = v
5841  if v > yhi:
5842  yhi = v
5843  n = n + 1
5844  ylo = int(c2 - YconvMA * ylo)
5845  yhi = int(c2 - YconvMA * yhi)
5846  if (ylo < Ymin):
5847  ylo = Ymin
5848  if (ylo > Ymax):
5849  ylo = Ymax
5850  if (yhi < Ymin):
5851  yhi = Ymin
5852  if (yhi > Ymax):
5853  yhi = Ymax
5854  TMAVline.append(int(x1))
5855  TMAVline.append(int(ylo))
5856  TMAVline.append(int(x1))
5857  TMAVline.append(int(yhi))
5858  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5859  MouseMuxA = ylo
5860  if Show_CBB.get() == 1 and len(VBuffMB)>4:
5861  if t < len(VBuffMB):
5862  ylo = VBuffMB[t] - CHBBOffset
5863  yhi = ylo
5864  n = t
5865  while n < (t + Tstep) and n < len(VBuffMB):
5866  v = VBuffMB[t] - CHBBOffset
5867  if v < ylo:
5868  ylo = v
5869  if v > yhi:
5870  yhi = v
5871  n = n + 1
5872  ylo = int(c2 - YconvMB * ylo)
5873  yhi = int(c2 - YconvMB * yhi)
5874  if (ylo < Ymin):
5875  ylo = Ymin
5876  if (ylo > Ymax):
5877  ylo = Ymax
5878  if (yhi < Ymin):
5879  yhi = Ymin
5880  if (yhi > Ymax):
5881  yhi = Ymax
5882  TMBVline.append(int(x1))
5883  TMBVline.append(int(ylo))
5884  TMBVline.append(int(x1))
5885  TMBVline.append(int(yhi))
5886  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5887  MouseMuxB = ylo
5888  if Show_CBC.get() == 1 and len(VBuffMC)>4:
5889  if t < len(VBuffMC):
5890  ylo = VBuffMC[t] - CHBCOffset
5891  yhi = ylo
5892  n = t
5893  while n < (t + Tstep) and n < len(VBuffMC):
5894  v = VBuffMC[t] - CHBCOffset
5895  if v < ylo:
5896  ylo = v
5897  if v > yhi:
5898  yhi = v
5899  n = n + 1
5900  ylo = int(c2 - YconvMC * ylo)
5901  yhi = int(c2 - YconvMC * yhi)
5902  if (ylo < Ymin):
5903  ylo = Ymin
5904  if (ylo > Ymax):
5905  ylo = Ymax
5906  if (yhi < Ymin):
5907  yhi = Ymin
5908  if (yhi > Ymax):
5909  yhi = Ymax
5910  TMCVline.append(int(x1))
5911  TMCVline.append(int(ylo))
5912  TMCVline.append(int(x1))
5913  TMCVline.append(int(yhi))
5914  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5915  MouseMuxC = ylo
5916  if Show_CBD.get() == 1 and len(VBuffMD)>4:
5917  if t < len(VBuffMD):
5918  ylo = VBuffMD[t] - CHBDOffset
5919  yhi = ylo
5920  n = t
5921  while n < (t + Tstep) and n < len(VBuffMD):
5922  v = VBuffMD[t] - CHBDOffset
5923  if v < ylo:
5924  ylo = v
5925  if v > yhi:
5926  yhi = v
5927  n = n + 1
5928  ylo = int(c2 - YconvMD * ylo)
5929  yhi = int(c2 - YconvMD * yhi)
5930  if (ylo < Ymin):
5931  ylo = Ymin
5932  if (ylo > Ymax):
5933  ylo = Ymax
5934  if (yhi < Ymin):
5935  yhi = Ymin
5936  if (yhi > Ymax):
5937  yhi = Ymax
5938  TMDVline.append(int(x1))
5939  TMDVline.append(int(ylo))
5940  TMDVline.append(int(x1))
5941  TMDVline.append(int(yhi))
5942  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5943  MouseMuxD = ylo
5944  if ( ShowC2_I.get() == 1 ):
5945  while n < (t + Tstep) and n < TRACEsize:
5946  i = IBuffB[t] - CHBIOffset
5947  if i < ilo:
5948  ilo = i
5949  if i > ihi:
5950  ihi = i
5951  n = n + 1
5952  ilo = int(c2 - YIconv2 * ilo)
5953  ihi = int(c2 - YIconv2 * ihi)
5954  if (ilo < Ymin):
5955  ilo = Ymin
5956  if (ilo > Ymax):
5957  ilo = Ymax
5958  if (ihi < Ymin):
5959  ihi = Ymin
5960  if (ihi > Ymax):
5961  ihi = Ymax
5962  T2Iline.append(int(x1))
5963  T2Iline.append(int(ilo))
5964  T2Iline.append(int(x1))
5965  T2Iline.append(int(ihi))
5966  if MathTrace.get() > 0:
5967  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
5968  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
5969 
5970  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
5971  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
5972 
5973  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
5974  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
5975 
5976  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
5977  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
5978  ytemp = YIconv1 * (Ypower - CHAIOffset)
5979  y1 = int(c1 - ytemp)
5980 
5981  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
5982  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
5983  ytemp = YIconv2 * (Ypower - CHBIOffset)
5984  y1 = int(c2 - ytemp)
5985 
5986  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
5987  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
5988  ytemp = YIconv1 * (Yohms- CHAIOffset)
5989  y1 = int(c1 - ytemp)
5990 
5991  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
5992  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
5993  ytemp = YIconv2 * (Yohms - CHBIOffset)
5994  y1 = int(c2 - ytemp)
5995 
5996  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
5997  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
5998  ytemp = YIconv1 * (Ydif - CHAIOffset)
5999  y1 = int(c2 - ytemp)
6000 
6001  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
6002  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
6003  ytemp = YIconv2 * (Ydif - CHBIOffset)
6004  y1 = int(c2 - ytemp)
6005 
6006  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
6007  try:
6008  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
6009  except:
6010  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
6011  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
6012  try:
6013  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
6014  except:
6015  Y1 = (IBuffB[t] / 0.000001)
6016  ytemp = YIconv2 * (Y1 - CHBIOffset)
6017  y1 = int(c2 - ytemp)
6018 
6019  elif MathTrace.get() == 12: # plot from equation string
6020  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
6021  try:
6022  MathResult = eval(MathString)
6023  MathResult = MathResult - CHMOffset
6024  y1 = int(c1 - YconvM * MathResult)
6025  except:
6026  RUNstatus.set(0)
6027  x = GRW + 1
6028 
6029  if (y1 < Ymin):
6030  y1 = Ymin
6031  if (y1 > Ymax):
6032  y1 = Ymax
6033  if (ZOHold.get() == 1):
6034  Tmathline.append(int(x1))
6035  Tmathline.append(int(ypm))
6036  Tmathline.append(int(x1))
6037  Tmathline.append(int(y1))
6038  else:
6039  Tmathline.append(int(x1))
6040  Tmathline.append(int(y1))
6041  ypm = y1
6042  if Show_MathX.get() > 0:
6043  try:
6044  MathResult = eval(MathXString)
6045  MathResult = MathResult - CHMXOffset
6046  y1 = int(c1 - XconvMxy * MathResult)
6047  except:
6048  RUNstatus.set(0)
6049  x = GRW + 1
6050 
6051  if y1 < Ymin: # clip waveform if going off grid
6052  y1 = Ymin
6053  if y1 > Ymax:
6054  y1 = Ymax
6055  if ZOHold.get() == 1: # connet the dots with stair step
6056  TMXline.append(int(x1))
6057  TMXline.append(int(ypmx))
6058  TMXline.append(int(x1))
6059  TMXline.append(int(y1))
6060  else: # connet the dots with single line
6061  TMXline.append(int(x1))
6062  TMXline.append(int(y1))
6063  ypmx = y1
6064  if Show_MathY.get() > 0:
6065  try:
6066  MathResult = eval(MathYString)
6067  MathResult = MathResult - CHMYOffset
6068  y1 = int(c1 - YconvMxy * MathResult)
6069  except:
6070  RUNstatus.set(0)
6071  x = GRW + 1
6072 
6073  if y1 < Ymin: # clip waveform if going off grid
6074  y1 = Ymin
6075  if y1 > Ymax:
6076  y1 = Ymax
6077  if ZOHold.get() == 1: # connet the dots with stair step
6078  TMYline.append(int(x1))
6079  TMYline.append(int(ypmy))
6080  TMYline.append(int(x1))
6081  TMYline.append(int(y1))
6082  else: # connet the dots with single line
6083  TMYline.append(int(x1))
6084  TMYline.append(int(y1))
6085  ypmy = y1
6086  ft = ft + Tstep
6087  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
6088  MouseCAV = ypv1
6089  MouseCAI = ypi1
6090  MouseCBV = ypv2
6091  MouseCBI = ypi2
6092  t = int(ft)
6093  if (t > len(VBuffA)):
6094  t = len(VBuffA)-2
6095  x = GRW
6096  x = x + Xstep
6097 
6098  # Make trigger triangle pointer
6099  Triggerline = [] # Trigger pointer
6100  Triggersymbol = [] # Trigger symbol
6101  if TgInput.get() > 0:
6102  if TgInput.get() == 1 : # triggering on CA-V
6103  x1 = X0L
6104  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) # / InGainA
6105  y1 = int(c1 - ytemp)
6106  elif TgInput.get() == 2: # triggering on CA-I
6107  x1 = X0L+GRW
6108  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
6109  elif TgInput.get() == 3: # triggering on CB-V
6110  x1 = X0L
6111  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) # / InGainB
6112  y1 = int(c2 - ytemp)
6113  elif TgInput.get() == 4: # triggering on CB-I
6114  x1 = X0L+GRW
6115  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
6116 
6117  if (y1 < Ymin):
6118  y1 = Ymin
6119  if (y1 > Ymax):
6120  y1 = Ymax
6121  Triggerline.append(int(x1-5))
6122  Triggerline.append(int(y1+5))
6123  Triggerline.append(int(x1+5))
6124  Triggerline.append(int(y1))
6125  Triggerline.append(int(x1-5))
6126  Triggerline.append(int(y1-5))
6127  Triggerline.append(int(x1-5))
6128  Triggerline.append(int(y1+5))
6129  x1 = X0L + (GRW/2)
6130  if TgEdge.get() == 0: # draw rising edge symbol
6131  y1 = -3
6132  y2 = -13
6133  else:
6134  y1 = -13
6135  y2 = -3
6136  Triggersymbol.append(int(x1-10))
6137  Triggersymbol.append(int(Ymin+y1))
6138  Triggersymbol.append(int(x1))
6139  Triggersymbol.append(int(Ymin+y1))
6140  Triggersymbol.append(int(x1))
6141  Triggersymbol.append(int(Ymin+y2))
6142  Triggersymbol.append(int(x1+10))
6143  Triggersymbol.append(int(Ymin+y2))
6144 
6146  global VBuffA, VBuffB, IBuffA, IBuffB
6147  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
6148  global TXYline, MathXString, MathYString, MathXAxis, MathYAxis
6149  global HoldOff, HoldOffentry
6150  global X0LXY, Y0TXY, GRWXY, GRHXY
6151  global YminXY, YmaxXY, XminXY, XmaxXY
6152  global SHOWsamples, ZOHold, AWGBMode
6153  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
6154  global TRACES, TRACESread, RUNstatus
6155  global Xsignal, Ysignal
6156  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
6157  global TMpdiv # Array with time / div values in ms
6158  global TMsb # Time per div spin box variable
6159  global TIMEdiv # current spin box value
6160  global SAMPLErate
6161  global SCstart, MathString
6162  global TRIGGERsample, TRACEsize, DX
6163  global TRIGGERlevel, TRIGGERentry, AutoLevel
6164  global InOffA, InGainA, InOffB, InGainB
6165  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
6166  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
6167  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6168  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
6169  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
6170  global HozPoss, HozPossentry
6171 
6172  # Set the TRACEsize variable
6173  if len(VBuffA) < 100:
6174  return
6175  TRACEsize = SHOWsamples # Set the trace length
6176  SCstart = 0
6177  ylo = 0.0
6178  xlo = 0.0
6179  # get the vertical ranges
6180  try:
6181  CH1pdvRange = float(eval(CHAsbxy.get()))
6182  except:
6183  CHAsbxy.delete(0,END)
6184  CHAsbxy.insert(0, CH1vpdvRange)
6185  try:
6186  CH2pdvRange = float(eval(CHBsbxy.get()))
6187  except:
6188  CHBsbxy.delete(0,END)
6189  CHBsbxy.insert(0, CH2vpdvRange)
6190  try:
6191  CH1IpdvRange = float(eval(CHAIsbxy.get()))
6192  except:
6193  CHAIsbxy.delete(0,END)
6194  CHAIsbxy.insert(0, CH1IpdvRange)
6195  try:
6196  CH2IpdvRange = float(eval(CHBIsbxy.get()))
6197  except:
6198  CHBIsbxy.delete(0,END)
6199  CHBIsbxy.insert(0, CH2IpdvRange)
6200  # get the vertical offsets
6201  try:
6202  CHAOffset = float(eval(CHAVPosEntryxy.get()))
6203  except:
6204  CHAVPosEntryxy.delete(0,END)
6205  CHAVPosEntryxy.insert(0, CHAOffset)
6206  try:
6207  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
6208  except:
6209  CHAIPosEntryxy.delete(0,END)
6210  CHAIPosEntryxy.insert(0, CHAIOffset)
6211  try:
6212  CHBOffset = float(eval(CHBVPosEntryxy.get()))
6213  except:
6214  CHBVPosEntry.delete(0,END)
6215  CHBVPosEntry.insert(0, CHBOffset)
6216  try:
6217  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
6218  except:
6219  CHBIPosEntryxy.delete(0,END)
6220  CHBIPosEntryxy.insert(0, CHBIOffset)
6221  # prevent divide by zero error
6222  if CH1pdvRange < 0.001:
6223  CH1pdvRange = 0.001
6224  if CH2pdvRange < 0.001:
6225  CH2pdvRange = 0.001
6226  if CH1IpdvRange < 0.1:
6227  CH1IpdvRange = 0.1
6228  if CH2IpdvRange < 0.1:
6229  CH2IpdvRange = 0.1
6230  #
6231  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
6232  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
6233  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
6234  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
6235  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
6236  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
6237  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
6238  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
6239 
6240  if MathYAxis == "V-A":
6241  YconvMxy = Yconv1
6242  CHMYOffset = CHAOffset
6243  elif MathYAxis == "V-B":
6244  YconvMxy = Yconv2
6245  CHMYOffset = CHBOffset
6246  elif MathYAxis == "I-A":
6247  YconvMxy = YIconv1
6248  CHMYOffset = CHAIOffset
6249  elif MathYAxis == "I-B":
6250  YconvMxy = YIconv2
6251  CHMYOffset = CHBIOffset
6252  else:
6253  YconvMxy = Yconv1
6254  CHMYOffset = CHAOffset
6255  if MathXAxis == "V-A":
6256  XconvMxy = Xconv1
6257  CHMXOffset = CHAOffset
6258  elif MathXAxis == "V-B":
6259  XconvMxy = Xconv2
6260  CHMXOffset = CHBOffset
6261  elif MathYAxis == "I-A":
6262  XconvMxy = XIconv1
6263  CHMXOffset = CHAIOffset
6264  elif MathXAxis == "I-B":
6265  XconvMxy = XIconv2
6266  CHMXOffset = CHBIOffset
6267  else:
6268  XconvMxy = Xconv1
6269  CHMXOffset = CHAOffset
6270  # draw an X/Y plot
6271  TXYline = [] # XY Trace line
6272  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
6273  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
6274  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
6275  while (t < TRACEsize):
6276  if (Xsignal.get() == 3 and Ysignal.get() == 1): # mode CAV/CBV
6277  ylo = VBuffA[t] - CHAOffset
6278  xlo = VBuffB[t] - CHBOffset
6279  ylo = int(c1 - Yconv1 * ylo)
6280  xlo = int(c2 + Xconv2 * xlo)
6281  elif (Xsignal.get() == 1 and Ysignal.get() == 3): # mode CBV/CAV
6282  ylo = VBuffB[t] - CHBOffset
6283  xlo = VBuffA[t] - CHAOffset
6284  ylo = int(c1 - Yconv2 * ylo)
6285  xlo = int(c2 + Xconv1 * xlo)
6286  elif (Xsignal.get() == 5 and Ysignal.get() == 3): # mode CBV/Math
6287  if ( MathTrace.get() == 2): # plot difference of CA-V and CB-V
6288  ylo = VBuffB[t] - CHBOffset
6289  ylo = int(c1 - Yconv2 * ylo)
6290  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
6291  xlo = int(c2 + Xconv1 * xlo)
6292  elif (Xsignal.get() == 5 and Ysignal.get() == 4): # mode CBI/Math
6293  if ( MathTrace.get() == 2): # plot difference of CA-V and CB-V
6294  ylo = (IBuffB[t]) - CHBIOffset
6295  ylo = int(c1 - YIconv2 * ylo)
6296  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
6297  xlo = int(c2 + Xconv1 * xlo)
6298  elif (Xsignal.get() == 5 and Ysignal.get() == 2): # mode CAI/Math
6299  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
6300  ylo = (IBuffA[t]) - CHAIOffset
6301  ylo = int(c1 - YIconv1 * ylo)
6302  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
6303  xlo = int(c2 + Xconv2 * xlo)
6304  elif (Xsignal.get() == 3 and Ysignal.get() == 5): # mode Math/CBV
6305  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
6306  ylo = VBuffA[t] - VBuffB[t] - CHAOffset
6307  ylo = int(c1 - Yconv1 * ylo)
6308  xlo = VBuffB[t] - CHBOffset
6309  xlo = int(c2 + Xconv2 * xlo)
6310  elif (Xsignal.get() == 5 and Ysignal.get() == 1): # mode CAV/Math
6311  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
6312  ylo = VBuffA[t] - CHAOffset
6313  ylo = int(c1 - Yconv1 * ylo)
6314  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
6315  xlo = int(c2 + Xconv2 * xlo)
6316  elif (Xsignal.get() == 1 and Ysignal.get() == 5): # mode Math/CAV
6317  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
6318  ylo = VBuffB[t] - VBuffA[t] - CHBOffset
6319  ylo = int(c1 - Yconv2 * ylo)
6320  xlo = VBuffA[t] - CHAOffset
6321  xlo = int(c2 + Xconv1 * xlo)
6322  elif (Xsignal.get() == 1 and Ysignal.get() == 2): # mode CAI/CAV
6323  ylo = (IBuffA[t]) - CHAIOffset
6324  xlo = VBuffA[t] - CHAOffset
6325  ylo = int(c1 - YIconv1 * ylo)
6326  xlo = int(c2 + Xconv1 * xlo)
6327  elif (Xsignal.get() == 3 and Ysignal.get() == 2): # mode CAI/CBV
6328  ylo = (IBuffA[t]) - CHAIOffset
6329  xlo = VBuffB[t] - CHBOffset
6330  ylo = int(c1 - YIconv1 * ylo)
6331  xlo = int(c2 + Xconv2 * xlo)
6332  elif (Xsignal.get() == 2 and Ysignal.get() == 1): # mode CAV/CAI
6333  ylo = VBuffA[t] - CHAOffset
6334  xlo = (IBuffA[t]) - CHAIOffset
6335  ylo = int(c1 - Yconv1 * ylo)
6336  xlo = int(c2 + XIconv1 * xlo)
6337  elif (Xsignal.get() == 2 and Ysignal.get() == 3): # mode CBV/CAI
6338  ylo = VBuffB[t] - CHBOffset
6339  xlo = (IBuffA[t]) - CHAIOffset
6340  ylo = int(c1 - Yconv2 * ylo)
6341  xlo = int(c2 + XIconv1 * xlo)
6342  elif (Xsignal.get() == 3 and Ysignal.get() == 4): # mode CBI/CBV
6343  ylo = (IBuffB[t]) - CHBIOffset
6344  xlo = VBuffB[t] - CHBOffset
6345  ylo = int(c1 - YIconv2 * ylo)
6346  xlo = int(c2 + Xconv2 * xlo)
6347  elif (Xsignal.get() == 4 and Ysignal.get() == 3): # mode CBV/CBI
6348  ylo = VBuffB[t] - CHBOffset
6349  xlo = (IBuffB[t]) - CHBIOffset
6350  ylo = int(c1 - Yconv2 * ylo)
6351  xlo = int(c2 + XIconv2 * xlo)
6352  elif (Xsignal.get() == 4 and Ysignal.get() == 2): # mode CAI/CBI
6353  ylo = (IBuffA[t]) - CHAIOffset
6354  xlo = (IBuffB[t]) - CHBIOffset
6355  ylo = int(c1 - YIconv1 * ylo)
6356  xlo = int(c2 + XIconv2 * xlo)
6357  elif (Xsignal.get() == 2 and Ysignal.get() == 4): # mode CBI/CAI
6358  ylo = (IBuffB[t]) - CHBIOffset
6359  xlo = (IBuffA[t]) - CHAIOffset
6360  ylo = int(c1 - YIconv2 * ylo)
6361  xlo = int(c2 + XIconv1 * xlo)
6362  elif (Xsignal.get() == 1 and Ysignal.get() == 4): # mode CBI/CAV
6363  ylo = (IBuffB[t]) - CHBIOffset
6364  xlo = VBuffA[t] - CHAOffset
6365  ylo = int(c1 - YIconv2 * ylo)
6366  xlo = int(c2 + Xconv1 * xlo)
6367  elif (Xsignal.get() == 5 and Ysignal.get() == 5): # mode MathYString/MathXString
6368  try:
6369  MathResult = eval(MathYString)
6370  MathResult = MathResult - CHMYOffset
6371  ylo = int(c1 - YconvMxy * MathResult)
6372  except:
6373  RUNstatus.set(0)
6374  try:
6375  MathResult = eval(MathXString)
6376  MathResult = MathResult - CHMXOffset
6377  xlo = int(c2 + XconvMxy * MathResult)
6378  except:
6379  RUNstatus.set(0)
6380  if ylo < YminXY: # clip waveform if going off grid
6381  ylo = YminXY
6382  if ylo > YmaxXY:
6383  ylo = YmaxXY
6384  if xlo < XminXY: # clip waveform if going off grid
6385  xlo = XminXY
6386  if xlo > XmaxXY:
6387  xlo = XmaxXY
6388  TXYline.append(int(xlo))
6389  TXYline.append(int(ylo))
6390  t = int(t + 1)
6391 
6393  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
6394  global TMXline, TMYline
6395  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
6396  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
6397  global VBuffA, VBuffB, IBuffA, IBuffB
6398  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus
6399  global TMAVline, TMBVline, TMCVline, TMDVline, TMCRline, TMBRline
6400  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
6401  global X0L # Left top X value
6402  global Y0T # Left top Y value
6403  global GRW # Screenwidth
6404  global GRH # Screenheight
6405  global FontSize, EnableHSsampling, ETSDisp, MinigenScreenStatus
6406  global LabelPlotText, PlotLabelText # plot custom label text flag
6407  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
6408  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
6409  global ShowXCur, ShowYCur, TCursor, VCursor
6410  global SHOWsamples # Number of samples in data record
6411  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowRXY, Show_MathX, Show_MathY
6412  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
6413  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
6414  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
6415  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
6416  global CHAsb # V range spinbox Index for channel 1
6417  global CHBsb # V range spinbox Index for channel 2
6418  global CHAOffset # Position value for channel 1 V
6419  global CHBOffset # Position value for channel 2 V
6420  global CHAIsb # I range spinbox Index for channel 1
6421  global CHBIsb # I range spinbox Index for channel 2
6422  global CHAIOffset # Postion value for channel 1 I
6423  global CHBIOffset # position value for channel 2 I
6424  global TMpdiv # Array with time / div values in ms
6425  global TMsb # Time per div spin box variable
6426  global TIMEdiv, Mulx, DISsamples # current spin box value
6427  global SAMPLErate, contloop, discontloop, HtMulEntry
6428  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
6429  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
6430  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
6431  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
6432  global CANVASwidth, CANVASheight
6433  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
6434  global ScreenTrefresh, SmoothCurves, Is_Triggered
6435  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
6436  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
6437  global InOffA, InGainA, InOffB, InGainB
6438  global CurOffA, CurOffB, CurGainA, CurGainB
6439  # Analog Mux channel measurement variables
6440  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
6441  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
6442  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
6443  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
6444  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
6445  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
6446  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
6447  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
6448  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
6449  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
6450  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
6451  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
6452  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
6453  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6454  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6455  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
6456  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
6457  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
6458  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
6459  global D0, D1, D2, D3, D4, D5, D6, D7
6460  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
6461  global HozPoss, HozPossentry
6462  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
6463  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
6464  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
6465  #
6466  Ymin = Y0T # Minimum position of time grid (top)
6467  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
6468 
6469  # DISsamples = (10.0 * TIMEdiv) # grid width in time
6470  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
6471  # get the vertical ranges
6472  try:
6473  CH1pdvRange = float(eval(CHAsb.get()))
6474  except:
6475  CHAsb.delete(0,END)
6476  CHAsb.insert(0, CH1vpdvRange)
6477  try:
6478  CH2pdvRange = float(eval(CHBsb.get()))
6479  except:
6480  CHBsb.delete(0,END)
6481  CHBsb.insert(0, CH2vpdvRange)
6482  try:
6483  CH1IpdvRange = float(eval(CHAIsb.get()))
6484  except:
6485  CHAIsb.delete(0,END)
6486  CHAIsb.insert(0, CH1IpdvRange)
6487  try:
6488  CH2IpdvRange = float(eval(CHBIsb.get()))
6489  except:
6490  CHBIsb.delete(0,END)
6491  CHBIsb.insert(0, CH2IpdvRange)
6492  # get the vertical offsets
6493  try:
6494  CHAOffset = float(eval(CHAVPosEntry.get()))
6495  except:
6496  CHAVPosEntry.delete(0,END)
6497  CHAVPosEntry.insert(0, CHAOffset)
6498  try:
6499  CHAIOffset = float(eval(CHAIPosEntry.get()))
6500  except:
6501  CHAIPosEntry.delete(0,END)
6502  CHAIPosEntry.insert(0, CHAIOffset)
6503  try:
6504  CHBOffset = float(eval(CHBVPosEntry.get()))
6505  except:
6506  CHBVPosEntry.delete(0,END)
6507  CHBVPosEntry.insert(0, CHBOffset)
6508  try:
6509  CHBIOffset = float(eval(CHBIPosEntry.get()))
6510  except:
6511  CHBIPosEntry.delete(0,END)
6512  CHBIPosEntry.insert(0, CHBIOffset)
6513  try:
6514  HoldOff = float(eval(HoldOffentry.get()))
6515  if HoldOff < 0:
6516  HoldOff = 0
6517  except:
6518  HoldOffentry.delete(0,END)
6519  HoldOffentry.insert(0, HoldOff)
6520  if ETSDisp.get() > 0 or MinigenScreenStatus.get() > 0:
6521  try:
6522  Mulx = float(eval(HtMulEntry.get()))
6523  if Mulx < 1:
6524  Mulx = 1
6525  except:
6526  Mulx = 1
6527  if EnableHSsampling > 0:
6528  HtMulEntry.delete(0,END)
6529  HtMulEntry.insert(0, 1)
6530  else:
6531  Mulx = 1
6532  # slide trace left right by HozPoss
6533  try:
6534  HozPoss = float(eval(HozPossentry.get()))
6535  except:
6536  HozPossentry.delete(0,END)
6537  HozPossentry.insert(0, HozPoss)
6538  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6539  try:
6540  CHMApdvRange = float(eval(CHB_Asb.get()))
6541  except:
6542  CHB_Asb.delete(0,END)
6543  CHB_Asb.insert(0, CHMApdvRange)
6544  try:
6545  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6546  except:
6547  CHB_Bsb.delete(0,END)
6548  CHB_Bsb.insert(0, CHMBpdvRange)
6549  try:
6550  CHMCpdvRange = float(eval(CHB_Csb.get()))
6551  except:
6552  CHB_Csb.delete(0,END)
6553  CHB_Csb.insert(0, CHMCpdvRange)
6554  try:
6555  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6556  except:
6557  CHB_Dsb.delete(0,END)
6558  CHB_Dsb.insert(0, CHMDpdvRange)
6559  if CHMApdvRange < 0.001:
6560  CHMApdvRange = 0.001
6561  if CHMBpdvRange < 0.001:
6562  CHMBpdvRange = 0.001
6563  if CHMCpdvRange < 0.001:
6564  CHMCpdvRange = 0.001
6565  if CHMDpdvRange < 0.001:
6566  CHMDpdvRange = 0.001
6567  try:
6568  CHBAOffset = float(eval(CHB_APosEntry.get()))
6569  except:
6570  CHB_APosEntry.delete(0,END)
6571  CHB_APosEntry.insert(0, CHBAOffset)
6572  try:
6573  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6574  except:
6575  CHB_BPosEntry.delete(0,END)
6576  CHB_BPosEntry.insert(0, CHBBOffset)
6577  try:
6578  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6579  except:
6580  CHB_CPosEntry.delete(0,END)
6581  CHB_CPosEntry.insert(0, CHBCOffset)
6582  try:
6583  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6584  except:
6585  CHB_DPosEntry.delete(0,END)
6586  CHB_DPosEntry.insert(0, CHBDOffset)
6587  # prevent divide by zero error
6588  if CH1pdvRange < 0.001:
6589  CH1pdvRange = 0.001
6590  if CH2pdvRange < 0.001:
6591  CH2pdvRange = 0.001
6592  if CH1IpdvRange < 0.1:
6593  CH1IpdvRange = 0.1
6594  if CH2IpdvRange < 0.1:
6595  CH2IpdvRange = 0.1
6596  vt = HoldOff + HozPoss # invert sign and scale to mSec
6597  if ScreenTrefresh.get() == 0:
6598  # Delete all items on the screen
6599  ca.delete(ALL) # remove all items
6600  MarkerNum = 0
6601  # Draw horizontal grid lines
6602  i = 0
6603  x1 = X0L
6604  x2 = X0L + GRW
6605  mg_siz = GRW/10.0
6606  mg_inc = mg_siz/5.0
6607  MathFlag1 = (MathAxis == "V-A" and MathTrace.get() == 12) or (MathXAxis == "V-A" and Show_MathX.get() == 1) or (MathYAxis == "V-A" and Show_MathY.get() == 1)
6608  MathFlag2 = (MathAxis == "V-B" and MathTrace.get() == 12) or (MathXAxis == "V-B" and Show_MathX.get() == 1) or (MathYAxis == "V-B" and Show_MathY.get() == 1)
6609  MathFlag3 = (MathAxis == "I-A" and MathTrace.get() == 12) or (MathXAxis == "I-A" and Show_MathX.get() == 1) or (MathYAxis == "I-A" and Show_MathY.get() == 1)
6610  MathFlag4 = (MathAxis == "I-B" and MathTrace.get() == 12) or (MathXAxis == "I-B" and Show_MathX.get() == 1) or (MathYAxis == "I-B" and Show_MathY.get() == 1)
6611  # vertical scale text labels
6612  RightOffset = FontSize * 3
6613  LeftOffset = int(FontSize/2)
6614  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
6615  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
6616  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
6617  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
6618  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
6619  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
6620  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
6621  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
6622  #
6623  while (i < 11):
6624  y = Y0T + i * GRH/10.0
6625  Dline = [x1,y,x2,y]
6626  if i == 5:
6627  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
6628  k = 0
6629  while (k < 10):
6630  l = 1
6631  while (l < 5):
6632  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
6633  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6634  l = l + 1
6635  k = k + 1
6636  else:
6637  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6638 
6639  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
6640  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6641  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
6642  Vaxis_label = str(round(Vaxis_value,3 ))
6643  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
6644 
6645  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
6646  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6647  Iaxis_label = str(round(Iaxis_value, 3))
6648  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
6649 
6650  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
6651  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6652  Vaxis_label = str(round(Vaxis_value, 3))
6653  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
6654 
6655  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
6656  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6657  Iaxis_label = str(round(Iaxis_value, 3))
6658  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
6659  if MuxScreenStatus.get() == 1:
6660  if Show_CBA.get() == 1:
6661  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
6662  Vaxis_label = str(round(Vaxis_value, 3))
6663  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
6664  if Show_CBB.get() == 1:
6665  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
6666  Iaxis_label = str(round(Iaxis_value, 3))
6667  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
6668  if Show_CBC.get() == 1:
6669  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
6670  Iaxis_label = str(round(Iaxis_value, 3))
6671  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
6672  if Show_CBD.get() == 1:
6673  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
6674  Iaxis_label = str(round(Iaxis_value, 3))
6675  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
6676  i = i + 1
6677  # Draw vertical grid lines
6678  i = 0
6679  y1 = Y0T
6680  y2 = Y0T + GRH
6681  mg_siz = GRH/10.0
6682  mg_inc = mg_siz/5.0
6683  vx = TIMEdiv/Mulx
6684  vt = HoldOff/Mulx # invert sign and scale to mSec
6685  # vx = TIMEdiv
6686  while (i < 11):
6687  x = X0L + i * GRW/10.0
6688  Dline = [x,y1,x,y2]
6689  if (i == 5):
6690  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
6691  k = 0
6692  while (k < 10):
6693  l = 1
6694  while (l < 5):
6695  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
6696  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6697  l = l + 1
6698  k = k + 1
6699  #
6700  if vx >= 1000:
6701  axis_value = ((i * vx)+ vt) / 1000.0
6702  axis_label = ' {0:.1f} '.format(axis_value) + " S"
6703  if vx < 1000 and vx >= 1:
6704  axis_value = (i * vx) + vt
6705  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
6706  if vx < 1:
6707  axis_value = ((i * vx) + vt) * 1000.0
6708  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
6709  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
6710  else:
6711  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6712  if vx >= 1000:
6713  axis_value = ((i * vx)+ vt) / 1000.0
6714  axis_label = ' {0:.1f} '.format(axis_value) + " S"
6715  if vx < 1000 and vx >= 1:
6716  axis_value = (i * vx) + vt
6717  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
6718  if vx < 1:
6719  axis_value = ((i * vx) + vt) * 1000.0
6720  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
6721  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
6722 
6723  i = i + 1
6724  # Write the trigger line if available
6725  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
6726  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
6727  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
6728  if TgInput.get() == 1:
6729  TgLabel = "CA-V"
6730  if TgInput.get() == 2:
6731  TgLabel = "CA-I"
6732  if TgInput.get() == 3:
6733  TgLabel = "CB-V"
6734  if TgInput.get() == 4:
6735  TgLabel = "CB-I"
6736  if Is_Triggered == 1:
6737  TgLabel = TgLabel + " Triggered"
6738  else:
6739  TgLabel = TgLabel + " Not Triggered"
6740  if SingleShot.get() > 0:
6741  TgLabel = TgLabel + " Armed"
6742  x = X0L + (GRW/2) + 12
6743  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
6744  # Draw T - V Cursor lines if required
6745  if MarkerScale.get() == 0:
6746  Yconv1 = float(GRH/10.0) / CH1pdvRange
6747  Yoffset1 = CHAOffset
6748  COLORmarker = COLORtrace1
6749  Units = " V"
6750  if MarkerScale.get() == 1:
6751  MouseY = MouseCAV
6752  Yconv1 = float(GRH/10.0) / CH1pdvRange
6753  Yoffset1 = CHAOffset
6754  COLORmarker = COLORtrace1
6755  Units = " V"
6756  if MarkerScale.get() == 2:
6757  MouseY = MouseCBV
6758  Yconv1 = float(GRH/10.0) / CH2pdvRange
6759  Yoffset1 = CHBOffset
6760  COLORmarker = COLORtrace2
6761  Units = " V"
6762  if MarkerScale.get() == 3:
6763  MouseY = MouseCAI
6764  Yconv1 = float(GRH/10.0) / CH1IpdvRange
6765  Yoffset1 = CHAIOffset
6766  COLORmarker = COLORtrace3
6767  Units = " mA"
6768  if MarkerScale.get() == 4:
6769  MouseY = MouseCBI
6770  Yconv1 = float(GRH/10.0) / CH2IpdvRange
6771  Yoffset1 = CHBIOffset
6772  COLORmarker = COLORtrace4
6773  Units = " mA"
6774  # Analog Mux settings
6775  if MarkerScale.get() == 5:
6776  MouseY = MouseMuxA
6777  Yconv1 = float(GRH/10.0) / CHMApdvRange
6778  Yoffset1 = CHBAOffset
6779  COLORmarker = COLORtrace2
6780  Units = " V"
6781  if MarkerScale.get() == 6:
6782  MouseY = MouseMuxB
6783  Yconv1 = float(GRH/10.0) / CHMBpdvRange
6784  Yoffset1 = CHBBOffset
6785  COLORmarker = COLORtrace6
6786  Units = " V"
6787  if MarkerScale.get() == 7:
6788  MouseY = MouseMuxC
6789  Yconv1 = float(GRH/10.0) / CHMCpdvRange
6790  Yoffset1 = CHBCOffset
6791  COLORmarker = COLORtrace7
6792  Units = " V"
6793  if MarkerScale.get() == 8:
6794  MouseY = MouseMuxD
6795  Yconv1 = float(GRH/10.0) / CHMDpdvRange
6796  Yoffset1 = CHBDOffset
6797  COLORmarker = COLORtrace4
6798  Units = " V"
6799 #
6800  if ShowTCur.get() > 0:
6801  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
6802  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6803  Tpoint = ((TCursor-X0L) * Tstep) + vt
6804  Tpoint = Tpoint/Mulx
6805  if Tpoint >= 1000:
6806  axis_value = Tpoint / 1000.0
6807  V_label = ' {0:.2f} '.format(axis_value) + " S"
6808  if Tpoint < 1000 and Tpoint >= 1:
6809  axis_value = Tpoint
6810  V_label = ' {0:.2f} '.format(axis_value) + " mS"
6811  if Tpoint < 1:
6812  axis_value = Tpoint * 1000.0
6813  V_label = ' {0:.2f} '.format(axis_value) + " uS"
6814  ca.create_text(TCursor+1, VCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
6815  if ShowVCur.get() > 0:
6816  Dline = [X0L, VCursor, X0L+GRW, VCursor]
6817  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
6818  c1 = GRH / 2 + Y0T # fixed Y correction
6819  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
6820  V1String = ' {0:.3f} '.format(-yvolts)
6821  V_label = V1String + Units
6822  ca.create_text(TCursor+1, VCursor+5, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
6823  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
6824  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
6825  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
6826  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6827  Tpoint = ((MouseX-X0L) * Tstep) + vt
6828  Tpoint = Tpoint/Mulx
6829  if Tpoint >= 1000:
6830  axis_value = Tpoint / 1000.0
6831  V_label = ' {0:.2f} '.format(axis_value) + " S"
6832  if Tpoint < 1000 and Tpoint >= 1:
6833  axis_value = Tpoint
6834  V_label = ' {0:.2f} '.format(axis_value) + " mS"
6835  if Tpoint < 1:
6836  axis_value = Tpoint * 1000.0
6837  V_label = ' {0:.2f} '.format(axis_value) + " uS"
6838  ca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
6839  Dline = [X0L, MouseY, X0L+GRW, MouseY]
6840  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6841  c1 = GRH / 2 + Y0T # fixed Y correction
6842  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
6843  V1String = ' {0:.3f} '.format(-yvolts)
6844  V_label = V1String + Units
6845  ca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
6846 #
6847  if MeasGateStatus.get() == 1:
6848  LeftGate = X0L + MeasGateLeft / Tstep
6849  RightGate = X0L + MeasGateRight / Tstep
6850  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace5)
6851  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace7)
6852  #
6853  # TString = ' {0:.2f} '.format(Tpoint)
6854  DT = (MeasGateRight-MeasGateLeft)/Mulx
6855  if DT == 0.0:
6856  DT = 1.0
6857  if DT >= 1000:
6858  axis_value = DT / 1000.0
6859  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
6860  if DT < 1000 and DT >= 1:
6861  axis_value = DT
6862  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
6863  if DT < 1:
6864  axis_value = DT * 1000.0
6865  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
6866  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
6867  DFreq = ' {0:.3f} '.format(1.0/DT)
6868  V_label = " Delta T" + DeltaT
6869  #V_label = V_label + Units
6870  V_label = V_label + ", Freq " + DFreq + " KHz"
6871  # place in upper left unless specified otherwise
6872  x = X0L + 5
6873  y = Y0T + 7
6874  Justify = 'w'
6875  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
6876  x = X0L + GRW - 5
6877  y = Y0T + 7
6878  Justify = 'e'
6879  if MarkerLoc == 'LL' or MarkerLoc == 'll':
6880  x = X0L + 5
6881  y = Y0T + GRH + 7 - (MarkerNum*10)
6882  Justify = 'w'
6883  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
6884  x = X0L + GRW - 5
6885  y = Y0T + GRH + 7
6886  Justify = 'e'
6887  ca.create_text(x, y, text=V_label, fill=COLORtrace5, anchor=Justify, font=("arial", FontSize ))
6888  #
6889 #
6890  SmoothBool = SmoothCurves.get()
6891  # Write the traces if available
6892  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
6893  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
6894  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
6895  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
6896  if len(T2Vline) > 4: # Write the trace 2 if active
6897  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6898  if len(T2Iline) > 4:
6899  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6900  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
6901  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6902  if len(TMXline) > 4 : # Write X Math tace if active
6903  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6904  if len(TMYline) > 4 : # Write Y Math tace if active
6905  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6906  if MuxScreenStatus.get() == 1:
6907  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
6908  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6909  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
6910  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6911  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
6912  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6913  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
6914  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6915  if ShowRB_V.get() == 1 and len(TMBRline) > 4:
6916  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6917  if ShowRB_I.get() == 1 and len(TMCRline) > 4:
6918  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6919  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
6920  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6921  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
6922  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6923  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
6924  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6925  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
6926  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6927  if ShowMath.get() == 1 and len(TMRline) > 4:
6928  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6929 
6930  # General information on top of the grid
6931  # Sweep information
6932  if session.continuous:
6933  sttxt = "Running Continuous"
6934  else:
6935  sttxt = "Running Discontinuous"
6936  if TRACEmodeTime.get() == 1:
6937  sttxt = sttxt + " Averaging"
6938  if ManualTrigger.get() == 1:
6939  sttxt = "Manual Trigger"
6940  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
6941  sttxt = "Stopped"
6942  if ScreenTrefresh.get() == 1:
6943  sttxt = sttxt + " Persistance ON"
6944  # Delete text at bottom of screen
6945  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
6946  for n in de:
6947  ca.delete(n)
6948  # Delete text at top of screen
6949  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
6950  for n in de:
6951  ca.delete(n)
6952  if LabelPlotText.get() > 0:
6953  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
6954  else:
6955  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
6956  x = X0L+2
6957  y = 12
6958  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6959  # digital I/O indicators
6960  x2 = X0L + GRW
6961  BoxColor = "#808080" # gray
6962  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
6963  if D0.get() == 0 and D4.get() == 0:
6964  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
6965  if Dval[0] == 1:
6966  BoxColor = "#00ff00" # 100% green
6967  elif Dval[0] == 0:
6968  BoxColor = "#ff0000" # 100% red
6969  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
6970  else:
6971  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
6972  if D1.get() == 0 and D5.get() == 0:
6973  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
6974  if Dval[0] == 1:
6975  BoxColor = "#00ff00" # 100% green
6976  elif Dval[0] == 0:
6977  BoxColor = "#ff0000" # 100% red
6978  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
6979  else:
6980  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
6981  if D2.get() == 0 and D6.get() == 0:
6982  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
6983  if Dval[0] == 1:
6984  BoxColor = "#00ff00" # 100% green
6985  elif Dval[0] == 0:
6986  BoxColor = "#ff0000" # 100% red
6987  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
6988  else:
6989  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
6990  if D3.get() == 0 and D7.get() == 0:
6991  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
6992  if Dval[0] == 1:
6993  BoxColor = "#00ff00" # 100% green
6994  elif Dval[0] == 0:
6995  BoxColor = "#ff0000" # 100% red
6996  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
6997  else:
6998  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
6999  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
7000  # Time sweep information and view at information
7001  vx = TIMEdiv/Mulx
7002  if vx >= 1000:
7003  txt = ' {0:.2f} '.format(vx / 1000.0) + " S/div"
7004  if vx < 1000 and vx >= 1:
7005  txt = ' {0:.2f} '.format(vx) + " mS/div"
7006  if vx < 1:
7007  txt = ' {0:.2f} '.format(vx * 1000.0) + " uS/div"
7008 
7009  txt = txt + " "
7010  #
7011  txt = txt + "View at "
7012  if abs(vt) >= 1000:
7013  txt = txt + str(int(vt / 1000.0)) + " S "
7014  if abs(vt) < 1000 and abs(vt) >= 1:
7015  txt = txt + str(int(vt)) + " mS "
7016  if abs(vt) < 1:
7017  txt = txt + str(int(vt * 1000.0)) + " uS "
7018  # print period and frequency of displayed channels
7019  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
7020  if ETSDisp.get() > 0:
7021  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
7022  else:
7023  FindRisingEdge(VBuffA,VBuffB)
7024  if ShowC1_V.get() == 1:
7025  if MeasAHW.get() == 1:
7026  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
7027  if MeasALW.get() == 1:
7028  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
7029  if MeasADCy.get() == 1:
7030  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
7031  if MeasAPER.get() == 1:
7032  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
7033  if MeasAFREQ.get() == 1:
7034  txt = txt + " CA Freq = "
7035  ChaF = CHAfreq*Mulx
7036  if ChaF < 1000:
7037  V1String = ' {0:.1f} '.format(ChaF)
7038  txt = txt + str(V1String) + " Hz "
7039  if ChaF > 1000 and ChaF < 1000000:
7040  V1String = ' {0:.1f} '.format(ChaF/1000)
7041  txt = txt + str(V1String) + " KHz "
7042  if ChaF > 1000000:
7043  V1String = ' {0:.1f} '.format(ChaF/1000000)
7044  txt = txt + str(V1String) + " MHz "
7045  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
7046  if ShowC2_V.get() == 1:
7047  if MeasBHW.get() == 1:
7048  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
7049  if MeasBLW.get() == 1:
7050  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
7051  if MeasBDCy.get() == 1:
7052  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
7053  if MeasBPER.get() == 1:
7054  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
7055  if MeasBFREQ.get() == 1:
7056  txt = txt + " CB Freq = "
7057  ChaF = CHBfreq*Mulx
7058  if ChaF < 1000:
7059  V1String = ' {0:.1f} '.format(ChaF)
7060  txt = txt + str(V1String) + " Hz "
7061  if ChaF > 1000 and ChaF < 1000000:
7062  V1String = ' {0:.1f} '.format(ChaF/1000)
7063  txt = txt + str(V1String) + " KHz "
7064  if ChaF > 1000000:
7065  V1String = ' {0:.1f} '.format(ChaF/1000000)
7066  txt = txt + str(V1String) + " MHz "
7067  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
7068  if MuxScreenStatus.get() == 0:
7069  if MeasPhase.get() == 1:
7070  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
7071  if MeasDelay.get() == 1:
7072  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
7073 
7074  x = X0L
7075  y = Y0T+GRH+int(2.5 *FontSize) # 20
7076  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7077  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
7078  MakeHistogram()
7079  txt = " "
7080  if ShowC1_V.get() == 1:
7081  # Channel A information
7082  if CHA_RC_HP.get() == 1:
7083  txt = "CHA: HP "
7084  else:
7085  txt = "CHA: "
7086  txt = txt + str(CH1pdvRange) + " V/div"
7087  if MeasDCV1.get() == 1:
7088  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
7089  if MeasMaxV1.get() == 1:
7090  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
7091  if MeasTopV1.get() == 1:
7092  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
7093  if MeasMinV1.get() == 1:
7094  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
7095  if MeasBaseV1.get() == 1:
7096  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
7097  if MeasMidV1.get() == 1:
7098  MidV1 = (MaxV1+MinV1)/2.0
7099  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
7100  if MeasPPV1.get() == 1:
7101  PPV1 = MaxV1-MinV1
7102  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
7103  if MeasRMSV1.get() == 1:
7104  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
7105  if MeasRMSVA_B.get() == 1:
7106  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
7107  if MeasDiffAB.get() == 1:
7108  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
7109  if MeasUserA.get() == 1:
7110  try:
7111  TempValue = eval(UserAString)
7112  V1String = ' {0:.4f} '.format(TempValue)
7113  except:
7114  V1String = "####"
7115  txt = txt + UserALabel + " = " + V1String
7116  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
7117  txt = "CHA: "
7118  txt = txt + str(CH1IpdvRange) + " mA/div"
7119  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
7120  txt = txt + "CHA: "
7121  txt = txt + str(CH1IpdvRange) + " mA/div"
7122  if ShowC1_I.get() == 1:
7123  if MeasDCI1.get() == 1:
7124  V1String = ' {0:.2f} '.format(DCI1)
7125  txt = txt + " AvgI = " + V1String
7126  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
7127  try:
7128  Resvalue = (DCV1/DCI1)*1000
7129  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7130  except:
7131  txt = txt + " Res = OverRange"
7132  if MeasMaxI1.get() == 1:
7133  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
7134  if MeasMinI1.get() == 1:
7135  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
7136  if MeasMidI1.get() == 1:
7137  MidI1 = (MaxI1+MinI1)/2.0
7138  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
7139  if MeasPPI1.get() == 1:
7140  PPI1 = MaxI1-MinI1
7141  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
7142  if MeasRMSI1.get() == 1:
7143  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
7144 
7145  x = X0L
7146  y = Y0T+GRH+(4*FontSize) # 32
7147  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7148  txt= " "
7149  # Channel B information
7150  if MuxScreenStatus.get() == 1:
7151  txt = "CHB-Mux: "
7152  if Show_CBA.get() > 0:
7153  FindRisingEdge(VBuffA,VBuffMA)
7154  elif Show_CBB.get() > 0:
7155  FindRisingEdge(VBuffA,VBuffMB)
7156  elif Show_CBC.get() > 0:
7157  FindRisingEdge(VBuffA,VBuffMC)
7158  elif Show_CBD.get() > 0:
7159  FindRisingEdge(VBuffA,VBuffMD)
7160  if MeasPhase.get() == 1:
7161  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
7162  if MeasDelay.get() == 1:
7163  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
7164  if MeasUserB.get() == 1:
7165  try:
7166  TempValue = eval(UserBString)
7167  V1String = ' {0:.4f} '.format(TempValue)
7168  except:
7169  V1String = "####"
7170  txt = txt + UserBLabel + " = " + V1String
7171  if ShowC2_V.get() == 1:
7172  if CHB_RC_HP.get() == 1:
7173  txt = "CHB: HP "
7174  else:
7175  txt = "CHB: "
7176  txt = txt + str(CH2pdvRange) + " V/div"
7177  if MeasDCV2.get() == 1:
7178  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
7179  if MeasMaxV2.get() == 1:
7180  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
7181  if MeasTopV2.get() == 1:
7182  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
7183  if MeasMinV2.get() == 1:
7184  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
7185  if MeasBaseV2.get() == 1:
7186  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
7187  if MeasMidV2.get() == 1:
7188  MidV2 = (MaxV2+MinV2)/2.0
7189  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
7190  if MeasPPV2.get() == 1:
7191  PPV2 = MaxV2-MinV2
7192  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
7193  if MeasRMSV2.get() == 1:
7194  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
7195  if MeasDiffBA.get() == 1:
7196  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
7197  if MeasUserB.get() == 1:
7198  try:
7199  TempValue = eval(UserBString)
7200  V1String = ' {0:.4f} '.format(TempValue)
7201  except:
7202  V1String = "####"
7203  txt = txt + UserBLabel + " = " + V1String
7204  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
7205  txt = "CHB: "
7206  txt = txt + str(CH2IpdvRange) + " mA/div"
7207  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
7208  txt = txt + "CHB: "
7209  txt = txt + str(CH2IpdvRange) + " mA/div"
7210  if ShowC2_I.get() == 1:
7211  if MeasDCI2.get() == 1:
7212  V1String = ' {0:.2f} '.format(DCI2)
7213  txt = txt + " AvgI = " + V1String
7214  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
7215  try:
7216  Resvalue = (DCV2/DCI2)*1000
7217  R1String = ' {0:.1f} '.format(Resvalue)
7218  txt = txt + " Res = " + R1String
7219  except:
7220  txt = txt + " Res = OverRange"
7221  if MeasMaxI2.get() == 1:
7222  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
7223  if MeasMinI2.get() == 1:
7224  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
7225  if MeasMidI2.get() == 1:
7226  MidI2 = (MaxI2+MinI2)/2.0
7227  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
7228  if MeasPPI2.get() == 1:
7229  PPI2 = MaxI2-MinI2
7230  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
7231  if MeasRMSI2.get() == 1:
7232  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
7233 
7234  x = X0L
7235  y = Y0T+GRH+int(5.5*FontSize) # 44
7236  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7237 
7239  global TXYline # active trave lines
7240  global Tmathline, TMRline, TXYRline
7241  global X0LXY # Left top X value
7242  global Y0TXY # Left top Y value
7243  global GRWXY # Screenwidth
7244  global GRHXY # Screenheight
7245  global FontSize, LabelPlotText, PlotLabelText
7246  global XYca, MouseX, MouseY, MouseWidget
7247  global ShowXCur, ShowYCur, XCursor, YCursor
7248  global SHOWsamples # Number of samples in data record
7249  global ShowRXY, ShowMath, MathUnits, MathXUnits, MathYUnits
7250  global Xsignal, Ysignal, MathXAxis, MathYAxis
7251  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
7252  global CHAsbxy # spinbox Index for channel 1 V
7253  global CHBsbxy # spinbox Index for channel 2 V
7254  global CHAOffset # Offset value for channel 1 V
7255  global CHBOffset # Offset value for channel 2 V
7256  global CHAIsbxy # spinbox Index for channel 1 I
7257  global CHBIsbxy # spinbox Index for channel 2 I
7258  global CHAIOffset # Offset value for channel 1 I
7259  global CHBIOffset # Offset value for channel 2 I
7260  global TMpdiv # Array with time / div values in ms
7261  global TMsb # Time per div spin box variable
7262  global TIMEdiv # current spin box value
7263  global SAMPLErate
7264  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
7265  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7 # The colors
7266  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
7267  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5
7268  global CANVASwidthXY, CANVASheightXY, COLORXmarker, COLORYmarker
7269  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
7270  global ScreenXYrefresh, SmoothCurves
7271  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
7272  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
7273  global SV1, SI1, SV2, SI2, CHABphase
7274  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
7275  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
7276  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
7277  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
7278  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
7279  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
7280  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
7281  global AWGAShape, AWGBShape
7282  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7283  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
7284  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
7285  global DacScreenStatus, DigScreenStatus
7286  global D0, D1, D2, D3, D4, D5, D6, D7
7287  global DevID, devx, MarkerNum, MarkerScale
7288  global HozPoss, HozPossentry
7289  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
7290  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
7291  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
7292  #
7293  Ymin = Y0TXY # Minimum position of screen grid (top)
7294  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
7295  try:
7296  InOffA = float(eval(CHAVOffsetEntry.get()))
7297  except:
7298  CHAVOffsetEntry.delete(0,END)
7299  CHAVOffsetEntry.insert(0, InOffA)
7300  try:
7301  InGainA = float(eval(CHAVGainEntry.get()))
7302  except:
7303  CHAVGainEntry.delete(0,END)
7304  CHAVGainEntry.insert(0, InGainA)
7305  try:
7306  InOffB = float(eval(CHBVOffsetEntry.get()))
7307  except:
7308  CHBVOffsetEntry.delete(0,END)
7309  CHBVOffsetEntry.insert(0, InOffB)
7310  try:
7311  InGainB = float(eval(CHBVGainEntry.get()))
7312  except:
7313  CHBVGainEntry.delete(0,END)
7314  CHBVGainEntry.insert(0, InGainB)
7315 #
7316  try:
7317  CH1pdvRange = float(eval(CHAsbxy.get()))
7318  except:
7319  CHAsbxy.delete(0,END)
7320  CHAsbxy.insert(0, CH1vpdvRange)
7321  try:
7322  CH2pdvRange = float(eval(CHBsbxy.get()))
7323  except:
7324  CHBsbxy.delete(0,END)
7325  CHBsbxy.insert(0, CH2vpdvRange)
7326  try:
7327  CH1IpdvRange = float(eval(CHAIsbxy.get()))
7328  except:
7329  CHAIsbxy.delete(0,END)
7330  CHAIsbxy.insert(0, CH1IpdvRange)
7331  try:
7332  CH2IpdvRange = float(eval(CHBIsbxy.get()))
7333  except:
7334  CHBIsbxy.delete(0,END)
7335  CHBIsbxy.insert(0, CH2IpdvRange)
7336  # get the vertical offsets
7337  try:
7338  CHAOffset = float(eval(CHAVPosEntryxy.get()))
7339  except:
7340  CHAVPosEntryxy.delete(0,END)
7341  CHAVPosEntryxy.insert(0, CHAOffset)
7342  try:
7343  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
7344  except:
7345  CHAIPosEntryxy.delete(0,END)
7346  CHAIPosEntryxy.insert(0, CHAIOffset)
7347  try:
7348  CHBOffset = float(eval(CHBVPosEntryxy.get()))
7349  except:
7350  CHBVPosEntry.delete(0,END)
7351  CHBVPosEntry.insert(0, CHBOffset)
7352  try:
7353  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
7354  except:
7355  CHBIPosEntryxy.delete(0,END)
7356  CHBIPosEntryxy.insert(0, CHBIOffset)
7357  # prevent divide by zero error
7358  if CH1pdvRange < 0.001:
7359  CH1pdvRange = 0.001
7360  if CH2pdvRange < 0.001:
7361  CH2pdvRange = 0.001
7362  if CH1IpdvRange < 0.05:
7363  CH1IpdvRange = 0.05
7364  if CH2IpdvRange < 0.05:
7365  CH2IpdvRange = 0.05
7366  # If drawing histograms adjust offset based on range such that bottom grid is zero
7367  if Xsignal.get() == 6:
7368  CHAIOffset = 5 * CH1IpdvRange
7369  if Xsignal.get() == 7:
7370  CHBIOffset = 5 * CH2IpdvRange
7371  if ScreenXYrefresh.get() == 0:
7372  # Delete all items on the screen
7373  MarkerNum = 0
7374  XYca.delete(ALL) # remove all items
7375  # Draw horizontal grid lines
7376  i = 0
7377  x1 = X0LXY
7378  x2 = X0LXY + GRWXY
7379  mg_siz = GRWXY/10.0
7380  mg_inc = mg_siz/5.0
7381  while (i < 11):
7382  y = Y0TXY + i * GRHXY/10.0
7383  Dline = [x1,y,x2,y]
7384  if i == 5:
7385  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
7386  k = 0
7387  while (k < 10):
7388  l = 1
7389  while (l < 5):
7390  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
7391  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7392  l = l + 1
7393  k = k + 1
7394  else:
7395  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7396  if Ysignal.get() == 2 or Xsignal.get() == 6:
7397  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
7398  Iaxis_label = str(round(Iaxis_value, 3))
7399  XYca.create_text(x1-3, y, text=Iaxis_label, fill=COLORtrace3, anchor="e", font=("arial", FontSize ))
7400  elif Ysignal.get() == 4 or Xsignal.get() == 7:
7401  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
7402  Iaxis_label = str(round(Iaxis_value, 3))
7403  XYca.create_text(x1-3, y, text=Iaxis_label, fill=COLORtrace4, anchor="e", font=("arial", FontSize ))
7404  elif Ysignal.get() == 1:
7405  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7406  Vaxis_label = str(round(Vaxis_value, 3))
7407  XYca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
7408  elif Ysignal.get() == 3:
7409  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7410  Vaxis_label = str(round(Vaxis_value, 3))
7411  XYca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
7412  elif Ysignal.get() == 5:
7413  TempCOLOR = COLORtrace5
7414  if MathTrace.get() == 2:
7415  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7416  elif MathTrace.get() == 3:
7417  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7418  else:
7419  if MathYAxis == "V-A":
7420  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7421  TempCOLOR = COLORtrace1
7422  elif MathYAxis == "V-B":
7423  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7424  TempCOLOR = COLORtrace2
7425  elif MathYAxis == "I-A":
7426  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
7427  TempCOLOR = COLORtrace3
7428  elif MathYAxis == "I-B":
7429  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
7430  TempCOLOR = COLORtrace4
7431  else:
7432  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7433  Vaxis_label = str(round(Vaxis_value, 3))
7434  XYca.create_text(x1-3, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
7435  i = i + 1
7436  # Draw vertical grid lines
7437  i = 0
7438  y1 = Y0TXY
7439  y2 = Y0TXY + GRHXY
7440  mg_siz = GRHXY/10.0
7441  mg_inc = mg_siz/5.0
7442  #
7443  while (i < 11):
7444  x = X0LXY + i * GRWXY/10.0
7445  Dline = [x,y1,x,y2]
7446  if (i == 5):
7447  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
7448  k = 0
7449  while (k < 10):
7450  l = 1
7451  while (l < 5):
7452  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
7453  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7454  l = l + 1
7455  k = k + 1
7456  if Xsignal.get() == 1 or Xsignal.get() == 6: #
7457  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7458  Vaxis_label = str(round(Vaxis_value, 3))
7459  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
7460  elif Xsignal.get() == 3 or Xsignal.get() == 7:
7461  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7462  Vaxis_label = str(round(Vaxis_value, 3))
7463  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
7464  elif Xsignal.get() == 2:
7465  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7466  Iaxis_label = str(round(Iaxis_value, 3))
7467  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
7468  elif Xsignal.get() == 4:
7469  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7470  Iaxis_label = str(round(Iaxis_value, 3))
7471  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
7472  elif Xsignal.get() == 5:
7473  TempCOLOR = COLORtrace5
7474  if MathTrace.get() == 2:
7475  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7476  elif MathTrace.get() == 3:
7477  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7478  else:
7479  if MathXAxis == "V-A":
7480  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7481  TempCOLOR = COLORtrace1
7482  elif MathXAxis == "V-B":
7483  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7484  TempCOLOR = COLORtrace2
7485  elif MathXAxis == "I-A":
7486  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7487  TempCOLOR = COLORtrace3
7488  elif MathXAxis == "I-B":
7489  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7490  TempCOLOR = COLORtrace4
7491  else:
7492  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7493  TempCOLOR = COLORtrace5
7494  Vaxis_label = str(round(Vaxis_value, 3))
7495  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
7496  else:
7497  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7498  if Xsignal.get() == 1 or Xsignal.get() == 6:
7499  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7500  Vaxis_label = str(round(Vaxis_value, 3))
7501  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
7502  elif Xsignal.get() == 3 or Xsignal.get() == 7:
7503  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7504  Vaxis_label = str(round(Vaxis_value, 3))
7505  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
7506  elif Xsignal.get() == 2:
7507  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7508  Iaxis_label = str(round(Iaxis_value, 3))
7509  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
7510  elif Xsignal.get() == 4:
7511  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7512  Iaxis_label = str(round(Iaxis_value, 3))
7513  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
7514  elif Xsignal.get() == 5:
7515  TempCOLOR = COLORtrace5
7516  if MathTrace.get() == 2:
7517  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7518  elif MathTrace.get() == 3:
7519  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7520  else:
7521  if MathXAxis == "V-A":
7522  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7523  TempCOLOR = COLORtrace1
7524  elif MathXAxis == "V-B":
7525  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7526  TempCOLOR = COLORtrace2
7527  elif MathXAxis == "I-A":
7528  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7529  TempCOLOR = COLORtrace3
7530  elif MathXAxis == "I-B":
7531  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7532  TempCOLOR = COLORtrace4
7533  else:
7534  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7535  Vaxis_label = str(round(Vaxis_value, 3))
7536  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
7537  i = i + 1
7538 # Draw traces
7539  if len(TXYline) > 4: # Avoid writing lines with 1 coordinate
7540  if Xsignal.get() == 1:
7541  XYca.create_line(TXYline, fill=COLORtrace1, width=TRACEwidth.get())
7542  elif Xsignal.get() == 2:
7543  XYca.create_line(TXYline, fill=COLORtrace3, width=TRACEwidth.get())
7544  elif Xsignal.get() == 3:
7545  XYca.create_line(TXYline, fill=COLORtrace2, width=TRACEwidth.get())
7546  elif Xsignal.get() == 4:
7547  XYca.create_line(TXYline, fill=COLORtrace4, width=TRACEwidth.get())
7548  elif Xsignal.get() == 5 or Ysignal.get() == 5:
7549  XYca.create_line(TXYline, fill=COLORtrace5, width=TRACEwidth.get())
7550  if len(TXYRline) > 4 and ShowRXY.get() == 1:
7551  XYca.create_line(TXYRline, fill=COLORtraceR1, width=TRACEwidth.get())
7552 # Draw Histogram Traces
7553  if Xsignal.get() == 6:
7554  MakeHistogram()
7555  b = 0
7556  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7557  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
7558  y1 = Y0TXY + GRHXY
7559  # print Yconv1, y1
7560  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7561  while b < 4999: #
7562  if HistAsPercent == 1: # convert to percent of total sample count
7563  ylo = float(HBuffA[0][b]) / len(VBuffA)
7564  ylo = ylo * 100.0
7565  else:
7566  ylo = HBuffA[0][b] #
7567  ylo = int(y1 - (Yconv1 * ylo))
7568  if ylo > Ymax:
7569  ylo = Ymax
7570  if ylo < Ymin:
7571  ylo = Ymin
7572  xlo = HBuffA[1][b] - CHAOffset
7573  xlo = int(c2 + Xconv1 * xlo)
7574  Dline = [xlo,y1,xlo,ylo]
7575  XYca.create_line(Dline, fill=COLORtrace1)
7576  b = b + 1
7577  if Xsignal.get() == 7:
7578  MakeHistogram()
7579  b = 0
7580  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7581  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
7582  y1 = Y0TXY + GRHXY
7583  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7584  while b < 4999: #
7585  if HistAsPercent == 1: # convert to percent
7586  ylo = float(HBuffB[0][b]) / len(VBuffB)
7587  ylo = ylo * 100.0
7588  else:
7589  ylo = HBuffB[0][b]
7590  ylo = int(y1 - Yconv1 * ylo)
7591  if ylo > Ymax:
7592  ylo = Ymax
7593  if ylo < Ymin:
7594  ylo = Ymin
7595  xlo = HBuffB[1][b] - CHBOffset
7596  xlo = int(c2 + Xconv1 * xlo)
7597  Dline = [xlo,y1,xlo,ylo]
7598  XYca.create_line(Dline, fill=COLORtrace2)
7599  b = b + 1
7600 # Draw X - Y Cursor lines if required
7601  COLORXmarker = COLORtrace1
7602  COLORYmarker = COLORtrace2
7603  if Xsignal.get() == 1 or Xsignal.get() == 6:
7604  Xconv1 = float(GRWXY/10) / CH1pdvRange
7605  Xoffset1 = CHAOffset
7606  COLORXmarker = COLORtrace1
7607  X_label = " V"
7608  if Xsignal.get() == 2:
7609  Xconv1 = float(GRWXY/10) / CH1IpdvRange
7610  Xoffset1 = CHAIOffset
7611  COLORXmarker = COLORtrace3
7612  X_label = " mA"
7613  if Xsignal.get() == 3 or Xsignal.get() == 7:
7614  Xconv1 = float(GRWXY/10) / CH2pdvRange
7615  Xoffset1 = CHBOffset
7616  COLORXmarker = COLORtrace2
7617  X_label = " V"
7618  if Xsignal.get() == 4:
7619  Xconv1 = float(GRWXY/10) / CH2IpdvRange
7620  Xoffset1 = CHBIOffset
7621  COLORmarker = COLORtrace4
7622  X_label = " mA"
7623  if Xsignal.get() == 5:
7624  X_label = MathXUnits
7625  if MathXAxis == "V-A":
7626  Xconv1 = float(GRWXY/10) / CH1pdvRange
7627  Xoffset1 = CHAOffset
7628  COLORXmarker = COLORtrace1
7629  elif MathXAxis == "V-B":
7630  Xconv1 = float(GRWXY/10) / CH2pdvRange
7631  Xoffset1 = CHBOffset
7632  COLORXmarker = COLORtrace2
7633  elif MathXAxis == "I-A":
7634  Xconv1 = float(GRWXY/10) / CH1IpdvRange
7635  Xoffset1 = CHAIOffset
7636  COLORXmarker = COLORtrace3
7637  elif MathXAxis == "I-B":
7638  Xconv1 = float(GRWXY/10) / CH2IpdvRange
7639  Xoffset1 = CHBIOffset
7640  COLORXmarker = COLORtrace4
7641  else:
7642  Xconv1 = float(GRWXY/10) / CH1pdvRange
7643  Xoffset1 = CHAOffset
7644  COLORXmarker = COLORtrace1
7645 #
7646  if Ysignal.get() == 1 or Ysignal.get() == 6:
7647  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7648  Yoffset1 = CHAOffset
7649  COLORYmarker = COLORtrace1
7650  Y_label = " V"
7651  if Ysignal.get() == 2:
7652  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7653  Yoffset1 = CHAIOffset
7654  COLORYmarker = COLORtrace3
7655  Y_label = " mA"
7656  if Ysignal.get() == 3 or Ysignal.get() == 7:
7657  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
7658  Yoffset1 = CHBOffset
7659  COLORYmarker = COLORtrace2
7660  Y_label = " V"
7661  if Ysignal.get() == 4:
7662  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7663  Yoffset1 = CHBIOffset
7664  COLORYmarker = COLORtrace4
7665  Y_label = " mA"
7666  if Ysignal.get() == 5:
7667  Y_label = MathYUnits
7668  if MathYAxis == "V-A":
7669  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7670  Yoffset1 = CHAOffset
7671  COLORYmarker = COLORtrace1
7672  elif MathYAxis == "V-B":
7673  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
7674  Yoffset1 = CHBOffset
7675  COLORYmarker = COLORtrace2
7676  elif MathYAxis == "I-A":
7677  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7678  Yoffset1 = CHAIOffset
7679  COLORYmarker = COLORtrace3
7680  elif MathYAxis == "I-B":
7681  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7682  Yoffset1 = CHBIOffset
7683  COLORYmarker = COLORtrace4
7684  else:
7685  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7686  Yoffset1 = CHAOffset
7687  COLORYmarker = COLORtrace1
7688  if ShowXCur.get() > 0:
7689  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
7690  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
7691  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
7692  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
7693  XString = ' {0:.3f} '.format(xvolts)
7694  V_label = XString + X_label
7695  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
7696  if ShowYCur.get() > 0:
7697  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
7698  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
7699  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
7700  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
7701  V1String = ' {0:.3f} '.format(-yvolts)
7702  V_label = V1String + Y_label
7703  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
7704  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
7705  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
7706  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
7707  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
7708  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
7709  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
7710  XString = ' {0:.3f} '.format(xvolts)
7711  V_label = XString + X_label
7712  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
7713  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
7714  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
7715  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
7716  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
7717  V1String = ' {0:.3f} '.format(-yvolts)
7718  V_label = V1String + Y_label
7719  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
7720 #
7721 # General information on top of the grid
7722 # Sweep information
7723  sttxt = "Running"
7724  if TRACEmodeTime.get() == 1:
7725  sttxt = sttxt + " Averaging"
7726  if ManualTrigger.get() == 1:
7727  sttxt = "Manual Trigger"
7728  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
7729  sttxt = "Stopped"
7730  if ScreenXYrefresh.get() == 1:
7731  sttxt = sttxt + " Persistance ON"
7732  # Delete text at bottom of screen
7733  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
7734  for n in de:
7735  XYca.delete(n)
7736  # Delete text at top of screen
7737  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
7738  for n in de:
7739  XYca.delete(n)
7740  if LabelPlotText.get() > 0:
7741  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7742  else:
7743  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7744  x = X0LXY
7745  y = 12
7746  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7747  # digital I/O indicators
7748  x2 = X0LXY + GRWXY
7749  BoxColor = "#808080" # gray
7750  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
7751  if D0.get() == 0 and D4.get() == 0:
7752  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
7753  if Dval[0] == 1:
7754  BoxColor = "#00ff00" # 100% green
7755  elif Dval[0] == 0:
7756  BoxColor = "#ff0000" # 100% red
7757  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
7758  else:
7759  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
7760  if D1.get() == 0 and D5.get() == 0:
7761  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
7762  if Dval[0] == 1:
7763  BoxColor = "#00ff00" # 100% green
7764  elif Dval[0] == 0:
7765  BoxColor = "#ff0000" # 100% red
7766  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
7767  else:
7768  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
7769  if D2.get() == 0 and D6.get() == 0:
7770  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
7771  if Dval[0] == 1:
7772  BoxColor = "#00ff00" # 100% green
7773  elif Dval[0] == 0:
7774  BoxColor = "#ff0000" # 100% red
7775  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
7776  else:
7777  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
7778  if D3.get() == 0 and D7.get() == 0:
7779  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
7780  if Dval[0] == 1:
7781  BoxColor = "#00ff00" # 100% green
7782  elif Dval[0] == 0:
7783  BoxColor = "#ff0000" # 100% red
7784  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
7785  else:
7786  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
7787  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
7788  # print period and frequency of displayed channels
7789  txt = " "
7790  if Xsignal.get() == 1 or Xsignal.get() == 3:
7791  FindRisingEdge(VBuffA, VBuffB)
7792  if Xsignal.get() == 1:
7793  if MeasAHW.get() == 1:
7794  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
7795  if MeasALW.get() == 1:
7796  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
7797  if MeasADCy.get() == 1:
7798  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
7799  if MeasAPER.get() == 1:
7800  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
7801  if MeasAFREQ.get() == 1:
7802  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
7803  if Xsignal.get() == 3:
7804  if MeasBHW.get() == 1:
7805  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
7806  if MeasBLW.get() == 1:
7807  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
7808  if MeasBDCy.get() == 1:
7809  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
7810  if MeasBPER.get() == 1:
7811  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
7812  if MeasBFREQ.get() == 1:
7813  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
7814  if MeasPhase.get() == 1:
7815  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
7816 
7817  x = X0LXY
7818  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
7819  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7820  txt = " "
7821  if Xsignal.get() == 1 or Ysignal.get() == 1 or Xsignal.get() == 6:
7822  # Channel A information
7823  txt = "CHA: "
7824  txt = txt + str(CH1pdvRange) + " V/div"
7825  if MeasDCV1.get() == 1:
7826  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
7827  if MeasMaxV1.get() == 1:
7828  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
7829  if MeasTopV1.get() == 1:
7830  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
7831  if MeasMinV1.get() == 1:
7832  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
7833  if MeasBaseV1.get() == 1:
7834  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
7835  if MeasMidV1.get() == 1:
7836  MidV1 = (MaxV1+MinV1)/2
7837  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
7838  if MeasPPV1.get() == 1:
7839  PPV1 = MaxV1-MinV1
7840  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
7841  if MeasRMSV1.get() == 1:
7842  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
7843  if MeasUserA.get() == 1:
7844  try:
7845  TempValue = eval(UserAString)
7846  V1String = ' {0:.4f} '.format(TempValue)
7847  except:
7848  V1String = "####"
7849  txt = txt + UserALabel + " = " + V1String
7850  if Xsignal.get() == 2:
7851  txt = "CHA: "
7852  txt = txt + str(CH1IpdvRange) + " mA/div"
7853  elif (Xsignal.get() == 2):
7854  txt = txt + "CHA: "
7855  txt = txt + str(CH1IpdvRange) + " mA/div"
7856  if Xsignal.get() == 2 or Ysignal.get() == 2:
7857  if MeasDCI1.get() == 1:
7858  V1String = ' {0:.2f} '.format(DCI1)
7859  txt = txt + " AvgI = " + V1String
7860  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
7861  try:
7862  Resvalue = (DCV1/DCI1)*1000
7863  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7864  except:
7865  txt = txt + " Res = OverRange"
7866  if MeasMaxI1.get() == 1:
7867  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
7868  if MeasMinI1.get() == 1:
7869  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
7870  if MeasMidI1.get() == 1:
7871  MidI1 = (MaxI1+MinI1)/2
7872  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
7873  if MeasPPI1.get() == 1:
7874  PPI1 = MaxI1-MinI1
7875  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
7876  if MeasRMSI1.get() == 1:
7877  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
7878 
7879  x = X0LXY
7880  y = Y0TXY+GRHXY+int(4*FontSize) # 32
7881  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7882  txt= " "
7883  # Channel B information
7884  if Xsignal.get() == 3 or Ysignal.get() == 3 or Xsignal.get() == 7:
7885  txt = "CHB: "
7886  txt = txt + str(CH2pdvRange) + " V/div"
7887  if MeasDCV2.get() == 1:
7888  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
7889  if MeasMaxV2.get() == 1:
7890  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
7891  if MeasTopV2.get() == 1:
7892  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
7893  if MeasMinV2.get() == 1:
7894  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
7895  if MeasBaseV2.get() == 1:
7896  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
7897  if MeasMidV2.get() == 1:
7898  MidV2 = (MaxV2+MinV2)/2
7899  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
7900  if MeasPPV2.get() == 1:
7901  PPV2 = MaxV2-MinV2
7902  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
7903  if MeasRMSV2.get() == 1:
7904  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
7905  if MeasUserB.get() == 1:
7906  try:
7907  TempValue = eval(UserBString)
7908  V1String = ' {0:.4f} '.format(TempValue)
7909  except:
7910  V1String = "####"
7911  txt = txt + UserBLabel + " = " + V1String
7912  if Xsignal.get() == 4:
7913  txt = "CHB: "
7914  txt = txt + str(CH2IpdvRange) + " mA/div"
7915  elif Xsignal.get() == 4:
7916  txt = txt + "CHB: "
7917  txt = txt + str(CH2IpdvRange) + " mA/div"
7918  if Xsignal.get() == 4 or Ysignal.get() == 4:
7919  if MeasDCI2.get() == 1:
7920  V1String = ' {0:.2f} '.format(DCI2)
7921  txt = txt + " AvgI = " + V1String
7922  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
7923  try:
7924  Resvalue = (DCV2/DCI2)*1000
7925  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7926  except:
7927  txt = txt + " Res = OverRange"
7928  if MeasMaxI2.get() == 1:
7929  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
7930  if MeasMinI2.get() == 1:
7931  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
7932  if MeasMidI2.get() == 1:
7933  MidI2 = (MaxI2+MinI2)/2
7934  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
7935  if MeasPPI2.get() == 1:
7936  PPI2 = MaxI2-MinI2
7937  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
7938  if MeasRMSI2.get() == 1:
7939  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
7940 
7941  x = X0LXY
7942  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
7943  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7944 #
7946  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7947 
7948  if MarkerScale.get() != 1:
7949  MarkerScale.set(1)
7950  CHAlab.config(style="Rtrace1.TButton")
7951  CHBlab.config(style="Strace2.TButton")
7952  CHAIlab.config(style="Strace3.TButton")
7953  CHBIlab.config(style="Strace4.TButton")
7954  else:
7955  MarkerScale.set(0)
7956 #
7958  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7959 
7960  if MarkerScale.get() != 3:
7961  MarkerScale.set(3)
7962  CHAlab.config(style="Strace1.TButton")
7963  CHBlab.config(style="Strace2.TButton")
7964  CHAIlab.config(style="Rtrace3.TButton")
7965  CHBIlab.config(style="Strace4.TButton")
7966  else:
7967  MarkerScale.set(0)
7968 
7970  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7971 
7972  if MarkerScale.get() != 2:
7973  MarkerScale.set(2)
7974  CHAlab.config(style="Strace1.TButton")
7975  CHBlab.config(style="Rtrace2.TButton")
7976  CHAIlab.config(style="Strace3.TButton")
7977  CHBIlab.config(style="Strace4.TButton")
7978  else:
7979  MarkerScale.set(0)
7980 
7982  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7983 
7984  if MarkerScale.get() != 3:
7985  MarkerScale.set(4)
7986  CHAlab.config(style="Strace1.TButton")
7987  CHBlab.config(style="Strace2.TButton")
7988  CHAIlab.config(style="Strace3.TButton")
7989  CHBIlab.config(style="Rtrace4.TButton")
7990  else:
7991  MarkerScale.set(0)
7992 #
7994  global MarkerXYScale, CHAxylab, CHBxylab
7995 
7996  MarkerXYScale.set(1)
7997  CHAxylab.config(style="Rtrace1.TButton")
7998  CHBxylab.config(style="Strace2.TButton")
7999 
8001  global MarkerXYScale, CHAxylab, CHBxylab
8002 
8003  MarkerXYScale.set(2)
8004  CHBxylab.config(style="Rtrace2.TButton")
8005  CHAxylab.config(style="Strace1.TButton")
8006 #
8008  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
8009 
8010  TCursor = event.x
8011  VCursor = event.y
8012  if RUNstatus.get() == 0:
8014  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
8015 
8017  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca, MWcount
8018  global MeasGateStatus, MeasGateLeft, MeasGateRight, TIMEdiv, GRW
8019 
8020  ShiftKeyDwn = event.state & 1
8021  if event.widget == ca:
8022  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
8023  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
8024  # respond to Linux or Windows wheel event
8025  if event.num == 5 or event.delta == -120:
8026  TCursor -= 1
8027  if event.num == 4 or event.delta == 120:
8028  TCursor += 1
8029  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
8030  # respond to Linux or Windows wheel event
8031  if event.num == 5 or event.delta == -120:
8032  VCursor += 1
8033  if event.num == 4 or event.delta == 120:
8034  VCursor -= 1
8035 
8039  else:
8040  if MeasGateStatus.get() == 1:
8041  Tstep = (TIMEdiv / GRW) / 10 # time in mS per pixel
8042  if ShiftKeyDwn == 0:
8043  if event.num == 5 or event.delta == -120:
8044  MeasGateLeft = MeasGateLeft + (-100 * Tstep)
8045  if event.num == 4 or event.delta == 120:
8046  MeasGateLeft = MeasGateLeft + (100 * Tstep)
8047  # MeasGateLeft = MeasGateLeft + (event.delta * Tstep) #+ HoldOff
8048  if ShiftKeyDwn == 1:
8049  if event.num == 5 or event.delta == -120:
8050  MeasGateRight = MeasGateRight + (-100 * Tstep)
8051  if event.num == 4 or event.delta == 120:
8052  MeasGateRight = MeasGateRight + (100 * Tstep)
8053  #MeasGateRight = MeasGateRight + (event.delta * Tstep) #+ HoldOff
8054  try:
8055  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
8056  except:
8057  donothing()
8058  if RUNstatus.get() == 0:
8060 
8061 def onCanvasUpArrow(event):
8062  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
8063 
8064  shift_key = event.state & 1
8065  if event.widget == ca:
8066  if ShowVCur.get() > 0 and shift_key == 0:
8067  VCursor = VCursor - 1
8068  elif ShowVCur.get() > 0 and shift_key == 1:
8069  VCursor = VCursor - 5
8070  if RUNstatus.get() == 0:
8072  try:
8073  if event.widget == XYca:
8074  if ShowYCur.get() > 0 and shift_key == 0:
8075  YCursor = YCursor - 1
8076  elif ShowYCur.get() > 0 and shift_key == 1:
8077  YCursor = YCursor - 5
8078  if RUNstatus.get() == 0:
8079  UpdateXYScreen()
8080  except:
8081  donothing()
8082  try:
8083  if event.widget == Freqca:
8084  if ShowdBCur.get() > 0 and shift_key == 0:
8085  dBCursor = dBCursor - 1
8086  elif ShowdBCur.get() > 0 and shift_key == 1:
8087  dBCursor = dBCursor - 5
8088  if RUNstatus.get() == 0:
8090  except:
8091  donothing()
8092  try:
8093  if event.widget == Bodeca:
8094  if ShowBdBCur.get() > 0 and shift_key == 0:
8095  BdBCursor = BdBCursor - 1
8096  elif ShowBdBCur.get() > 0 and shift_key == 1:
8097  BdBCursor = BdBCursor - 5
8098  if RUNstatus.get() == 0:
8100  except:
8101  donothing()
8102 
8104  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
8105 
8106  shift_key = event.state & 1
8107  if event.widget == ca:
8108  if ShowVCur.get() > 0 and shift_key == 0:
8109  VCursor = VCursor + 1
8110  elif ShowVCur.get() > 0 and shift_key == 1:
8111  VCursor = VCursor + 5
8112  if RUNstatus.get() == 0:
8114  try:
8115  if event.widget == XYca:
8116  if ShowYCur.get() > 0 and shift_key == 0:
8117  YCursor = YCursor + 1
8118  elif ShowYCur.get() > 0 and shift_key == 1:
8119  YCursor = YCursor + 5
8120  if RUNstatus.get() == 0:
8121  UpdateXYScreen()
8122  except:
8123  donothing()
8124  try:
8125  if event.widget == Freqca:
8126  if ShowdBCur.get() > 0 and shift_key == 0:
8127  dBCursor = dBCursor + 1
8128  elif ShowdBCur.get() > 0 and shift_key == 1:
8129  dBCursor = dBCursor + 5
8130  if RUNstatus.get() == 0:
8132  except:
8133  donothing()
8134  try:
8135  if event.widget == Bodeca:
8136  if ShowBdBCur.get() > 0 and shift_key == 0:
8137  BdBCursor = BdBCursor + 1
8138  elif ShowBdBCur.get() > 0 and shift_key == 1:
8139  BdBCursor = BdBCursor + 5
8140  if RUNstatus.get() == 0:
8142  except:
8143  donothing()
8144 
8146  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
8147 
8148  shift_key = event.state & 1
8149  if event.widget == ca:
8150  if ShowTCur.get() > 0 and shift_key == 0:
8151  TCursor = TCursor - 1
8152  elif ShowTCur.get() > 0 and shift_key == 1:
8153  TCursor = TCursor - 5
8154  if RUNstatus.get() == 0:
8156  try:
8157  if event.widget == XYca:
8158  if ShowXCur.get() > 0 and shift_key == 0:
8159  XCursor = XCursor - 1
8160  elif ShowXCur.get() > 0 and shift_key == 1:
8161  XCursor = XCursor - 5
8162  if RUNstatus.get() == 0:
8163  UpdateXYScreen()
8164  except:
8165  donothing()
8166  try:
8167  if event.widget == Freqca:
8168  if ShowFCur.get() > 0 and shift_key == 0:
8169  FCursor = FCursor - 1
8170  elif ShowFCur.get() > 0 and shift_key == 1:
8171  FCursor = FCursor - 5
8172  if RUNstatus.get() == 0:
8174  except:
8175  donothing()
8176  try:
8177  if event.widget == Bodeca:
8178  if ShowBPCur.get() > 0 and shift_key == 0:
8179  BPCursor = BPCursor - 1
8180  elif ShowBPCur.get() > 0 and shift_key == 1:
8181  BPCursor = BPCursor - 5
8182  if RUNstatus.get() == 0:
8184  except:
8185  donothing()
8186 
8188  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
8189 
8190  shift_key = event.state & 1
8191  if event.widget == ca:
8192  if ShowTCur.get() > 0 and shift_key == 0:
8193  TCursor = TCursor + 1
8194  elif ShowTCur.get() > 0 and shift_key == 1:
8195  TCursor = TCursor + 5
8196  if RUNstatus.get() == 0:
8198  try:
8199  if event.widget == XYca:
8200  if ShowXCur.get() > 0 and shift_key == 0:
8201  XCursor = XCursor + 1
8202  elif ShowXCur.get() > 0 and shift_key == 1:
8203  XCursor = XCursor + 5
8204  if RUNstatus.get() == 0:
8205  UpdateXYScreen()
8206  except:
8207  donothing()
8208  try:
8209  if event.widget == Freqca:
8210  if ShowFCur.get() > 0 and shift_key == 0:
8211  FCursor = FCursor + 1
8212  elif ShowFCur.get() > 0 and shift_key == 1:
8213  FCursor = FCursor + 5
8214  if RUNstatus.get() == 0:
8216  except:
8217  donothing()
8218  try:
8219  if event.widget == Bodeca:
8220  if ShowBPCur.get() > 0 and shift_key == 0:
8221  BPCursor = BPCursor + 1
8222  elif ShowBPCur.get() > 0 and shift_key == 1:
8223  BPCursor = BPCursor + 5
8224  if RUNstatus.get() == 0:
8226  except:
8227  donothing()
8228 
8229 def onCanvasSpaceBar(event):
8230  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
8231 
8232  if event.widget == ca:
8233  if RUNstatus.get() == 0:
8234  BStart()
8235  elif RUNstatus.get() > 0:
8236  BStop()
8237  try:
8238  if event.widget == XYca:
8239  if RUNstatus.get() == 0:
8240  BStart()
8241  elif RUNstatus.get() > 0:
8242  BStop()
8243  except:
8244  donothing()
8245  try:
8246  if event.widget == IAca:
8247  if RUNstatus.get() == 0:
8248  BStart()
8249  elif RUNstatus.get() > 0:
8250  BStop()
8251  except:
8252  donothing()
8253  try:
8254  if event.widget == Freqca:
8255  if RUNstatus.get() == 0:
8256  BStartSA()
8257  elif RUNstatus.get() > 0:
8258  BStopSA()
8259  except:
8260  donothing()
8261  try:
8262  if event.widget == Bodeca:
8263  if RUNstatus.get() == 0:
8264  BStartBP()
8265  elif RUNstatus.get() > 0:
8266  BStopBP()
8267  except:
8268  donothing()
8269 #
8271  global X0L # Left top X value
8272  global Y0T # Left top Y value
8273  global GRW # Screenwidth
8274  global GRH # Screenheight
8275  global FontSize
8276  global ca, MarkerLoc, Mulx
8277  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
8278  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
8279  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
8280  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
8281  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
8282  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
8283  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
8284  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
8285  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
8286  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
8287 
8288  try:
8289  HoldOff = float(eval(HoldOffentry.get()))
8290  if HoldOff < 0:
8291  HoldOff = 0
8292  except:
8293  HoldOffentry.delete(0,END)
8294  HoldOffentry.insert(0, HoldOff)
8295  # get time scale
8296  try:
8297  TIMEdiv = float(eval(TMsb.get()))
8298  except:
8299  TIMEdiv = 0.5
8300  TMsb.delete(0,"end")
8301  TMsb.insert(0,TIMEdiv)
8302  # prevent divide by zero error
8303  if TIMEdiv < 0.0002:
8304  TIMEdiv = 0.01
8305  # add markers only if stopped
8306  if (RUNstatus.get() == 0):
8307  MarkerNum = MarkerNum + 1
8308  # get the vertical ranges
8309  try:
8310  CH1pdvRange = float(eval(CHAsb.get()))
8311  except:
8312  CHAsb.delete(0,END)
8313  CHAsb.insert(0, CH1vpdvRange)
8314  try:
8315  CH2pdvRange = float(eval(CHBsb.get()))
8316  except:
8317  CHBsb.delete(0,END)
8318  CHBsb.insert(0, CH2vpdvRange)
8319  try:
8320  CH1IpdvRange = float(eval(CHAIsb.get()))
8321  except:
8322  CHAIsb.delete(0,END)
8323  CHAIsb.insert(0, CH1IpdvRange)
8324  try:
8325  CH2IpdvRange = float(eval(CHBIsb.get()))
8326  except:
8327  CHBIsb.delete(0,END)
8328  CHBIsb.insert(0, CH2IpdvRange)
8329  # get the vertical offsets
8330  try:
8331  CHAOffset = float(eval(CHAVPosEntry.get()))
8332  except:
8333  CHAVPosEntry.delete(0,END)
8334  CHAVPosEntry.insert(0, CHAOffset)
8335  try:
8336  CHAIOffset = float(eval(CHAIPosEntry.get()))
8337  except:
8338  CHAIPosEntry.delete(0,END)
8339  CHAIPosEntry.insert(0, CHAIOffset)
8340  try:
8341  CHBOffset = float(eval(CHBVPosEntry.get()))
8342  except:
8343  CHBVPosEntry.delete(0,END)
8344  CHBVPosEntry.insert(0, CHBOffset)
8345  try:
8346  CHBIOffset = float(eval(CHBIPosEntry.get()))
8347  except:
8348  CHBIPosEntry.delete(0,END)
8349  CHBIPosEntry.insert(0, CHBIOffset)
8350  # prevent divide by zero error
8351  if CH1pdvRange < 0.001:
8352  CH1pdvRange = 0.001
8353  if CH2pdvRange < 0.001:
8354  CH2pdvRange = 0.001
8355  if CH1IpdvRange < 1.0:
8356  CH1IpdvRange = 1.0
8357  if CH2IpdvRange < 1.0:
8358  CH2IpdvRange = 1.0
8359 #
8360  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
8361  try:
8362  CHMApdvRange = float(eval(CHB_Asb.get()))
8363  except:
8364  CHB_Asb.delete(0,END)
8365  CHB_Asb.insert(0, CHMApdvRange)
8366  try:
8367  CHMBpdvRange = float(eval(CHB_Bsb.get()))
8368  except:
8369  CHB_Bsb.delete(0,END)
8370  CHB_Bsb.insert(0, CHMBpdvRange)
8371  try:
8372  CHMCpdvRange = float(eval(CHB_Csb.get()))
8373  except:
8374  CHB_Csb.delete(0,END)
8375  CHB_Csb.insert(0, CHMCpdvRange)
8376  try:
8377  CHMDpdvRange = float(eval(CHB_Dsb.get()))
8378  except:
8379  CHB_Dsb.delete(0,END)
8380  CHB_Dsb.insert(0, CHMDpdvRange)
8381  YconvMA = float(GRH/10.0) / CHMApdvRange
8382  YconvMB = float(GRH/10.0) / CHMBpdvRange
8383  YconvMC = float(GRH/10.0) / CHMCpdvRange
8384  YconvMD = float(GRH/10.0) / CHMDpdvRange
8385  try:
8386  CHBAOffset = float(eval(CHB_APosEntry.get()))
8387  except:
8388  CHB_APosEntry.delete(0,END)
8389  CHB_APosEntry.insert(0, CHBAOffset)
8390  try:
8391  CHBBOffset = float(eval(CHB_BPosEntry.get()))
8392  except:
8393  CHB_BPosEntry.delete(0,END)
8394  CHB_BPosEntry.insert(0, CHBBOffset)
8395  try:
8396  CHBCOffset = float(eval(CHB_CPosEntry.get()))
8397  except:
8398  CHB_CPosEntry.delete(0,END)
8399  CHB_CPosEntry.insert(0, CHBCOffset)
8400  try:
8401  CHBDOffset = float(eval(CHB_DPosEntry.get()))
8402  except:
8403  CHB_DPosEntry.delete(0,END)
8404  CHB_DPosEntry.insert(0, CHBDOffset)
8405  Yoffset1 = CHAOffset
8406  if MarkerScale.get() == 1:
8407  Yconv1 = float(GRH/10.0) / CH1pdvRange
8408  Yoffset1 = CHAOffset
8409  COLORmarker = COLORtrace1
8410  Units = " V"
8411  elif MarkerScale.get() == 2:
8412  Yconv1 = float(GRH/10.0) / CH2pdvRange
8413  Yoffset1 = CHBOffset
8414  COLORmarker = COLORtrace2
8415  Units = " V"
8416  elif MarkerScale.get() == 3:
8417  Yconv1 = float(GRH/10.0) / CH1IpdvRange
8418  Yoffset1 = CHAIOffset
8419  COLORmarker = COLORtrace3
8420  Units = " mA"
8421  elif MarkerScale.get() == 4:
8422  Yconv1 = float(GRH/10.0) / CH2IpdvRange
8423  Yoffset1 = CHBIOffset
8424  COLORmarker = COLORtrace4
8425  Units = " mA"
8426  # Aanalog Mux settings
8427  elif MarkerScale.get() == 5:
8428  Yconv1 = float(GRH/10.0) / CHMApdvRange
8429  Yoffset1 = CHBAOffset
8430  COLORmarker = COLORtrace2
8431  Units = " V"
8432  elif MarkerScale.get() == 6:
8433  Yconv1 = float(GRH/10.0) / CHMBpdvRange
8434  Yoffset1 = CHBBOffset
8435  COLORmarker = COLORtrace6
8436  Units = " V"
8437  elif MarkerScale.get() == 7:
8438  Yconv1 = float(GRH/10.0) / CHMCpdvRange
8439  Yoffset1 = CHBCOffset
8440  COLORmarker = COLORtrace7
8441  Units = " V"
8442  elif MarkerScale.get() == 8:
8443  Yconv1 = float(GRH/10.0) / CHMDpdvRange
8444  Yoffset1 = CHBDOffset
8445  COLORmarker = COLORtrace4
8446  Units = " V"
8447  else:
8448  Yconv1 = float(GRH/10.0) / CH1pdvRange
8449  Yoffset1 = CHAOffset
8450  COLORmarker = COLORtrace1
8451  Units = " V"
8452  #
8453  c1 = GRH / 2.0 + Y0T # fixed correction channel A
8454  xc1 = GRW / 2.0 + X0L
8455  c2 = GRH / 2.0 + Y0T # fixed correction channel B
8456  # draw X at marker point and number
8457  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
8458  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
8459  # DISsamples = (10.0 * TIMEdiv) # grid width in time
8460  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
8461  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
8462  #
8463  Tpoint = Tpoint/Mulx
8464  if Tpoint >= 1000:
8465  axis_value = Tpoint / 1000.0
8466  TString = ' {0:.2f} '.format(axis_value) + " S "
8467  if Tpoint < 1000 and Tpoint >= 1:
8468  axis_value = Tpoint
8469  TString = ' {0:.2f} '.format(axis_value) + " mS "
8470  if Tpoint < 1:
8471  axis_value = Tpoint * 1000.0
8472  TString = ' {0:.2f} '.format(axis_value) + " uS "
8473  # TString = ' {0:.2f} '.format(Tpoint)
8474  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
8475  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
8476  V1String = ' {0:.3f} '.format(-yvolts)
8477  else:
8478  V1String = ' {0:.1f} '.format(-yvolts)
8479  V_label = str(MarkerNum) + " " + TString + V1String
8480  V_label = V_label + Units
8481  if MarkerNum > 1:
8482  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
8483  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
8484  else:
8485  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
8486  DT = (Tpoint-PrevT)
8487  if Tpoint >= 1000:
8488  axis_value = DT / 1000.0
8489  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
8490  if Tpoint < 1000 and Tpoint >= 1:
8491  axis_value = DT
8492  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
8493  if Tpoint < 1:
8494  axis_value = DT * 1000.0
8495  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
8496  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
8497  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
8498  V_label = V_label + " Delta " + DeltaT + DeltaV
8499  V_label = V_label + Units
8500  V_label = V_label + ", Freq " + DFreq + " KHz"
8501  # place in upper left unless specified otherwise
8502  x = X0L + 5
8503  y = Y0T + 3 + (MarkerNum*10)
8504  Justify = 'w'
8505  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
8506  x = X0L + GRW - 5
8507  y = Y0T + 3 + (MarkerNum*10)
8508  Justify = 'e'
8509  if MarkerLoc == 'LL' or MarkerLoc == 'll':
8510  x = X0L + 5
8511  y = Y0T + GRH + 3 - (MarkerNum*10)
8512  Justify = 'w'
8513  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
8514  x = X0L + GRW - 5
8515  y = Y0T + GRH + 3 - (MarkerNum*10)
8516  Justify = 'e'
8517  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
8518  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
8519  PrevV = yvolts
8520  PrevT = Tpoint
8521  else:
8522  if MeasGateStatus.get() == 1:
8523  #DISsamples = (10.0 * TIMEdiv) # grid width in time
8524  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
8525  if MeasGateNum == 0:
8526  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
8527  MeasGateNum = 1
8528  else:
8529  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
8530  MeasGateNum = 0
8531  LeftGate = X0L + MeasGateLeft / Tstep
8532  RightGate = X0L + MeasGateRight / Tstep
8533  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
8534  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
8535 
8536 #
8537 def onCanvasOne(event):
8538  global ShowC1_V
8539 
8540  if ShowC1_V.get() == 0:
8541  ShowC1_V.set(1)
8542  else:
8543  ShowC1_V.set(0)
8544 #
8545 def onCanvasTwo(event):
8546  global ShowC2_V
8547 
8548  if ShowC2_V.get() == 0:
8549  ShowC2_V.set(1)
8550  else:
8551  ShowC2_V.set(0)
8552 #
8553 def onCanvasThree(event):
8554  global ShowC1_I
8555 
8556  if ShowC1_I.get() == 0:
8557  ShowC1_I.set(1)
8558  else:
8559  ShowC1_I.set(0)
8560 #
8561 def onCanvasFour(event):
8562  global ShowC2_I
8563 
8564  if ShowC2_I.get() == 0:
8565  ShowC2_I.set(1)
8566  else:
8567  ShowC2_I.set(0)
8568 #
8569 def onCanvasFive(event):
8570  global MathTrace
8571 
8572  MathTrace.set(1)
8573 #
8574 def onCanvasSix(event):
8575  global MathTrace
8576 
8577  MathTrace.set(2)
8578 #
8579 def onCanvasSeven(event):
8580  global MathTrace
8581 
8582  MathTrace.set(3)
8583 #
8584 def onCanvasEight(event):
8585  global MathTrace
8586 
8587  MathTrace.set(10)
8588 #
8589 def onCanvasNine(event):
8590  global MathTrace
8591 
8592  MathTrace.set(12)
8593 #
8594 def onCanvasZero(event):
8595  global MathTrace
8596 
8597  MathTrace.set(0)
8598 #
8599 def onCanvasTrising(event):
8600  global TgEdge
8601 
8602  TgEdge.set(0)
8603 #
8604 def onCanvasTfalling(event):
8605  global TgEdge
8606 
8607  TgEdge.set(1)
8608 #
8609 def onCanvasSnap(event):
8610 
8611  BSnapShot()
8612 #
8613 def onCanvasAverage(event):
8614  global TRACEmodeTime
8615 
8616  if TRACEmodeTime.get() == 0:
8617  TRACEmodeTime.set(1)
8618  else:
8619  TRACEmodeTime.set(0)
8620 #
8621 def onCanvasShowTcur(event):
8622  global ShowTCur
8623 
8624  if ShowTCur.get() == 0:
8625  ShowTCur.set(1)
8626  else:
8627  ShowTCur.set(0)
8628 #
8629 def onCanvasShowVcur(event):
8630  global ShowVCur
8631 
8632  if ShowVCur.get() == 0:
8633  ShowVCur.set(1)
8634  else:
8635  ShowVCur.set(0)
8636 #
8638  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
8639 
8640  XCursor = event.x
8641  YCursor = event.y
8642  if RUNstatus.get() == 0:
8643  UpdateXYScreen()
8644  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
8645 #
8647  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
8648  if event.widget == XYca:
8649  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
8650  ShiftKeyDwn = event.state & 1
8651  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
8652  # respond to Linux or Windows wheel event
8653  if event.num == 5 or event.delta == -120:
8654  XCursor -= 1
8655  if event.num == 4 or event.delta == 120:
8656  XCursor += 1
8657  # XCursor = XCursor + event.delta/100
8658  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
8659  # respond to Linux or Windows wheel event
8660  if event.num == 5 or event.delta == -120:
8661  YCursor += 1
8662  if event.num == 4 or event.delta == 120:
8663  YCursor -= 1
8664  #YCursor = YCursor - event.delta/100
8665  if RUNstatus.get() == 0:
8666  UpdateXYScreen()
8667 #
8669  global X0LXY # Left top X value
8670  global Y0TXY # Left top Y value
8671  global GRWXY # Screenwidth
8672  global GRHXY # Screenheight
8673  global FontSize
8674  global XYca
8675  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
8676  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
8677  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
8678  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
8679  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
8680  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
8681  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
8682  # add markers only if stopped
8683  #
8684  if (RUNstatus.get() == 0):
8685  MarkerNum = MarkerNum + 1
8686  try:
8687  CH1pdvRange = float(eval(CHAsbxy.get()))
8688  except:
8689  CHAsbxy.delete(0,END)
8690  CHAsbxy.insert(0, CH1vpdvRange)
8691  try:
8692  CH2pdvRange = float(eval(CHBsbxy.get()))
8693  except:
8694  CHBsb.delete(0,END)
8695  CHBsb.insert(0, CH2vpdvRange)
8696  try:
8697  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8698  except:
8699  CHAIsbxy.delete(0,END)
8700  CHAIsbxy.insert(0, CH1IpdvRange)
8701  try:
8702  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8703  except:
8704  CHBIsbxy.delete(0,END)
8705  CHBIsbxy.insert(0, CH2IpdvRange)
8706  # get the vertical offsets
8707  try:
8708  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8709  except:
8710  CHAVPosEntryxy.delete(0,END)
8711  CHAVPosEntryxy.insert(0, CHAOffset)
8712  try:
8713  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8714  except:
8715  CHAIPosEntryxy.delete(0,END)
8716  CHAIPosEntryxy.insert(0, CHAIOffset)
8717  try:
8718  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8719  except:
8720  CHBVPosEntryxy.delete(0,END)
8721  CHBVPosEntryxy.insert(0, CHBOffset)
8722  try:
8723  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8724  except:
8725  CHBIPosEntryxy.delete(0,END)
8726  CHBIPosEntryxy.insert(0, CHBIOffset)
8727  # prevent divide by zero error
8728  if CH1pdvRange < 0.001:
8729  CH1pdvRange = 0.001
8730  if CH2pdvRange < 0.001:
8731  CH2pdvRange = 0.001
8732  if CH1IpdvRange < 1.0:
8733  CH1IpdvRange = 1.0
8734  if CH2IpdvRange < 1.0:
8735  CH2IpdvRange = 1.0
8736  try:
8737  HoldOff = float(eval(HoldOffentry.get()))
8738  if HoldOff < 0:
8739  HoldOff = 0
8740  except:
8741  HoldOffentry.delete(0,END)
8742  HoldOffentry.insert(0, HoldOff)
8743  #
8744  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
8745  Xconv1 = float(GRWXY/10) / CH1pdvRange
8746  Yconv2 = float(GRHXY/10) / CH2pdvRange
8747  Xconv2 = float(GRWXY/10) / CH2pdvRange
8748  # YIconv1 = float(GRH/10) / CH1IpdvRange
8749  # YIconv2 = float(GRH/10) / CH2IpdvRange
8750  COLORmarker = COLORtext
8751  Yoffset1 = CHAOffset
8752  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
8753  xc1 = GRWXY / 2 + X0LXY
8754  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
8755  # draw X at marker point and number
8756  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
8757  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
8758  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
8759  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
8760  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
8761  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
8762  VyString = ' {0:.3f} '.format(-yvolts)
8763  VxString = ' {0:.3f} '.format(-xvolts)
8764  V_label = str(MarkerNum) + " " + VxString + " V, " + VyString + " V"
8765  if MarkerNum > 1:
8766  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
8767  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
8768  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
8769  x = X0LXY + 5
8770  y = Y0TXY + 3 + (MarkerNum*10)
8771  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
8772  PrevY = yvolts
8773  PrevX = xvolts
8774  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
8775  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
8776  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
8777  VyString = ' {0:.3f} '.format(-yvolts)
8778  VxString = ' {0:.3f} '.format(-xvolts)
8779  V_label = str(MarkerNum) + " " + VxString + " V, " + VyString + " V"
8780  if MarkerNum > 1:
8781  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
8782  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
8783  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
8784  x = X0LXY + 5
8785  y = Y0TXY + 3 + (MarkerNum*10)
8786  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
8787  PrevY = yvolts
8788  PrevX = xvolts
8789 #
8790 def Wrap(InArray, WrFactor):
8791  # Build new array by skipping WrFactor samples and wrapping back around
8792  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
8793  # effectively multiplies the frequency content by WrFactor
8794  OutArray = []
8795  OutArray = numpy.array(OutArray)
8796  InArray = numpy.array(InArray)
8797  EndIndex = len(InArray)
8798  StartIndex = 0
8799  while StartIndex < WrFactor:
8800  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
8801  StartIndex = StartIndex + 1
8802  return OutArray
8803 #
8804 def UnWrap(InArray, WrFactor):
8805  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
8806  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
8807  # effectively divided the frequency content by WrFactor
8808  OutArray = []
8809  InArray = numpy.array(InArray)
8810  EndIndex = int(len(InArray)/WrFactor)
8811  StartIndex = 0
8812  while StartIndex < EndIndex:
8813  LoopIndex = 0
8814  while LoopIndex < WrFactor:
8815  OutArray.append(InArray[StartIndex+LoopIndex])
8816  LoopIndex = LoopIndex + 1
8817  StartIndex = StartIndex + 1
8818  OutArray = numpy.array(OutArray)
8819  return OutArray
8820 #
8821 def Write_WAV(data, repeat, filename):
8822  global SAMPLErate
8823  # write data array to mono .wav file 100KSPS
8824  # copy buffer repeat times in output file
8825  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
8826  wavfile = wave.open(filename, "w")
8827  nchannels = 1
8828  sampwidth = 2
8829  framerate = SAMPLErate
8830  amplitude = 32766
8831  nframes = len(data)
8832  comptype = "NONE"
8833  compname = "not compressed"
8834  wavfile.setparams((nchannels,
8835  sampwidth,
8836  framerate,
8837  nframes,
8838  comptype,
8839  compname))
8840  # Normalize data
8841  ArrN = numpy.array(data)
8842  ArrN /= numpy.max(numpy.abs(data))
8843  frames = []
8844  for s in ArrN:
8845  mul = int(s * amplitude)
8846  # print "s: %f mul: %d" % (s, mul)
8847  frames.append(struct.pack('h', mul))
8848  print( len(frames))
8849  frames = ''.join(frames)
8850  print( len(frames))
8851  for x in xrange(0, repeat):
8852  print( x )
8853  wavfile.writeframes(frames)
8854  wavfile.close()
8855 
8856 # =========== Awg functions ==================
8857 def BAWGAAmpl(temp):
8858  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8859  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8860 
8861  try:
8862  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
8863  except:
8864  AWGAAmplEntry.delete(0,"end")
8865  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8866  #
8867  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
8868  if AWGAMode.get() == 0: # Source Voltage measure current mode
8869  if AWGAAmplvalue > 5.00:
8870  AWGAAmplvalue = 5.00
8871  AWGAAmplEntry.delete(0,"end")
8872  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8873  if AWGAAmplvalue < 0.00:
8874  AWGAAmplvalue = 0.00
8875  AWGAAmplEntry.delete(0,"end")
8876  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8877  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
8878  if AWGAMode.get() == 0: # Source Voltage measure current mode
8879  if AWGAAmplvalue > (2.5 / AWGA_Ext_Gain.get()):
8880  AWGAAmplvalue = 2.5 / AWGA_Ext_Gain.get()
8881  AWGAAmplEntry.delete(0,"end")
8882  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8883  if AWGAAmplvalue < (-2.50 / AWGA_Ext_Gain.get()):
8884  AWGAAmplvalue = -2.50 / AWGA_Ext_Gain.get()
8885  AWGAAmplEntry.delete(0,"end")
8886  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8887  if AWGAMode.get() == 1: # Source current measure voltage mode
8888  if AWGAAmplvalue > 200.00:
8889  AWGAAmplvalue = 200.00
8890  AWGAAmplEntry.delete(0,"end")
8891  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8892  if AWGAAmplvalue < -200.00:
8893  AWGAAmplvalue = -200.00
8894  AWGAAmplEntry.delete(0,"end")
8895  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8896 #
8897 def BAWGAOffset(temp):
8898  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8899  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8900 
8901  try:
8902  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
8903  except:
8904  AWGAOffsetEntry.delete(0,"end")
8905  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8906  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
8907  if AWGAMode.get() == 0: # Source Voltage measure current mode
8908  if AWGAOffsetvalue > 5.00:
8909  AWGAOffsetvalue = 5.00
8910  AWGAOffsetEntry.delete(0,"end")
8911  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8912  if AWGAOffsetvalue < 0.00:
8913  AWGAOffsetvalue = 0.00
8914  AWGAOffsetEntry.delete(0,"end")
8915  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8916  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
8917  if AWGAOffsetvalue > (2.50-AWGA_Ext_Offset.get()):
8918  AWGAOffsetvalue = 2.50-AWGA_Ext_Offset.get()
8919  AWGAOffsetEntry.delete(0,"end")
8920  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8921  if AWGAOffsetvalue < (-2.50-AWGA_Ext_Offset.get()):
8922  AWGAOffsetvalue = -2.50-AWGA_Ext_Offset.get()
8923  AWGAOffsetEntry.delete(0,"end")
8924  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8925  if AWGAMode.get() == 1: # Source current measure voltage mode
8926  if AWGAOffsetvalue > 200.00:
8927  AWGAOffsetvalue = 200.00
8928  AWGAOffsetEntry.delete(0,"end")
8929  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8930  if AWGAOffsetvalue < -200.00:
8931  AWGAOffsetvalue = -200.00
8932  AWGAOffsetEntry.delete(0,"end")
8933  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8934 #
8935 def BAWGAFreq(temp):
8936  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X
8937  global BodeScreenStatus, BodeDisp
8938 
8939  try:
8940  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
8941  except:
8942  AWGAFreqEntry.delete(0,"end")
8943  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8944  if AWG_2X.get() == 1:
8945  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
8946  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
8947  AWGAFreqvalue = 90000
8948  AWGAFreqEntry.delete(0,"end")
8949  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8950  else:
8951  if AWGAFreqvalue > 50000: # max freq is 50KHz
8952  AWGAFreqvalue = 50000
8953  AWGAFreqEntry.delete(0,"end")
8954  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8955  else:
8956  if AWGAFreqvalue > 25000: # max freq is 25KHz
8957  AWGAFreqvalue = 25000
8958  AWGAFreqEntry.delete(0,"end")
8959  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8960  if AWGAFreqvalue < 0: # Set negative frequency entry to 0
8961  AWGAFreqvalue = 10
8962  AWGAFreqEntry.delete(0,"end")
8963  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8964  #UpdateAWGA()
8965 
8967  global AWGAPhaseDelay, phasealab, awgaph, awgadel
8968 
8969  if AWGAPhaseDelay.get() == 0:
8970  phasealab.configure(text="Deg")
8971  awgaph.configure(style="WPhase.TRadiobutton")
8972  awgadel.configure(style="GPhase.TRadiobutton")
8973  elif AWGAPhaseDelay.get() == 1:
8974  phasealab.configure(text="mSec")
8975  awgaph.configure(style="GPhase.TRadiobutton")
8976  awgadel.configure(style="WPhase.TRadiobutton")
8977 
8978 def BAWGAPhase(temp):
8979  global AWGAPhaseEntry, AWGAPhasevalue
8980 
8981  try:
8982  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
8983  except:
8984  AWGAPhaseEntry.delete(0,"end")
8985  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8986 
8987  if AWGAPhasevalue > 360: # max phase is 360 degrees
8988  AWGAPhasevalue = 360
8989  AWGAPhaseEntry.delete(0,"end")
8990  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8991  if AWGAPhasevalue < 0: # min phase is 0 degrees
8992  AWGAPhasevalue = 0
8993  AWGAPhaseEntry.delete(0,"end")
8994  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8995 
8996 def BAWGADutyCycle(temp):
8997  global AWGADutyCycleEntry, AWGADutyCyclevalue
8998 
8999  try:
9000  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
9001  except:
9002  AWGADutyCycleEntry.delete(0,"end")
9003  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
9004 
9005  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
9006  AWGADutyCyclevalue = 1
9007  AWGADutyCycleEntry.delete(0,"end")
9008  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
9009  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
9010  AWGADutyCyclevalue = 0
9011  AWGADutyCycleEntry.delete(0,"end")
9012  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
9013  #UpdateAWGA()
9014 
9016  global AWGAShape, AWGAWave, phasealab, duty1lab
9017 
9018  if AWGAShape.get() == 0:
9019  AWGAWave = 'dc'
9020  duty1lab.config(text="%")
9021  BAWGAPhaseDelay()
9022  if AWGAShape.get() == 1:
9023  AWGAWave = 'sine'
9024  duty1lab.config(text="%")
9025  BAWGAPhaseDelay()
9026  if AWGAShape.get() == 2:
9027  AWGAWave = 'triangle'
9028  duty1lab.config(text="%")
9029  BAWGAPhaseDelay()
9030  if AWGAShape.get() == 3:
9031  AWGAWave = 'sawtooth'
9032  duty1lab.config(text="%")
9033  BAWGAPhaseDelay()
9034  if AWGAShape.get() == 4:
9035  AWGAWave = 'square'
9036  duty1lab.config(text="%")
9037  BAWGAPhaseDelay()
9038  if AWGAShape.get() == 5:
9039  AWGAWave = 'stairstep'
9040  duty1lab.config(text="%")
9041  BAWGAPhaseDelay()
9042  if AWGAShape.get() > 5:
9043  AWGAWave = 'arbitrary'
9044  # UpdateAWGA()
9045 
9047  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X
9048 
9049  # Read values from CVS file
9050  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
9051  try:
9052  CSVFile = open(filename)
9053  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
9054  CSVFile.seek(0)
9055  #csv_f = csv.reader(CSVFile, dialect)
9056  csv_f = csv.reader(CSVFile, csv.excel)
9057  except:
9058  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
9059  # print csv_f.dialect
9060  AWGAwaveform = []
9061  ColumnNum = 0
9062  ColumnSel = 0
9063  RowNum = 0
9064  for row in csv_f:
9065  # print 'found row = ', row
9066  if len(row) > 1 and ColumnSel == 0:
9067  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
9068  ColumnNum = int(RequestColumn) - 1
9069  ColumnLen = str(len(row))
9070  ColumnSel = 1
9071  try:
9072  colnum = 0
9073  for col in row:
9074  if colnum == ColumnNum:
9075  AWGAwaveform.append(float(col))
9076  colnum += 1
9077  except:
9078  print( 'skipping non-numeric row', RowNum)
9079  RowNum += 1
9080  AWGAwaveform = numpy.array(AWGAwaveform)
9082  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9083  CSVFile.close()
9084  UpdateAwgCont()
9085 
9086 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
9088  global AWG_2X, AWGA2X, AWGAwaveform
9089 
9090  if AWG_2X.get() == 1:
9091  Tempwaveform = []
9092  AWGA2X = []
9093  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
9094  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
9095  AWGAwaveform = Tempwaveform
9096 #
9098  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9099 
9100  if AWGABurstFlag.get() == 1:
9101  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
9102  if (AWGACyclesString == None): # If Cancel pressed, then None
9103  return
9104  AWGACycles = int(AWGACyclesString)
9105  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
9106  if (AWGADelayString == None): # If Cancel pressed, then None
9107  return
9108  AWGABurstDelay = float(AWGADelayString)
9109  ReMakeAWGwaves()
9110 #
9112  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
9113  global AWG_2X, AWGA2X
9114 
9115 # Read values from WAV file
9116  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
9117  try:
9118  spf = wave.open(filename,'r')
9119  except:
9120  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
9121  AWGAwaveform = []
9122  AWGBwaveform = []
9123  Length = spf.getnframes()
9124  if Length > 90000:
9125  Length = 90000
9126  # If Stereo put first channel in AWGA and second channel in AWGB
9127  if spf.getnchannels() == 2:
9128  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
9129  signal = spf.readframes(Length)
9130  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
9131  n = 0
9132  while n < Length*2:
9133  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
9134  n = n + 1
9135  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
9136  n = n + 1
9137  AWGAwaveform = numpy.array(AWGAwaveform)
9138  AWGBwaveform = numpy.array(AWGBwaveform)
9139  AWGALength.config(text = "L = " + str(len(AWGAwaveform))) # change displayed value
9140  AWGBLength.config(text = "L = " + str(len(AWGBwaveform))) # change displayed value
9141  AWGBShape.set(AWGAShape.get())
9142  else:
9143  #Extract Raw Audio from Wav File
9144  signal = spf.readframes(Length)
9145  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
9146  # offset and scale for 0 5 V range
9147  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
9148  AWGAwaveform = numpy.array(AWGAwaveform)
9150  AWGALength.config(text = "L = " + str(len(AWGAwaveform))) # change displayed value
9151  spf.close()
9152  UpdateAwgCont()
9153 
9155  global AWGAwaveform, AWGALength, awgwindow
9156 
9157  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
9158  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
9159 
9161  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
9162  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
9163  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
9164  global DFiltACoef, DFiltBCoef, AWGAShapeLabel
9165  global AWG_2X, AWGA2X
9166 
9167  TempString = AWGAMathString
9168  AWGAShapeLabel.config(text = "Math" ) # change displayed value
9169  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
9170  if (AWGAMathString == None): # If Cancel pressed, then None
9171  AWGAMathString = TempString
9172  return
9173  AWGAwaveform = eval(AWGAMathString)
9174  AWGAwaveform = numpy.array(AWGAwaveform)
9176  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9177  UpdateAwgCont()
9178 #
9180  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
9181  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
9182  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
9183  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9184 
9185  BAWGAAmpl(0)
9186  BAWGAOffset(0)
9187  BAWGAFreq(0)
9188  BAWGAPhase(0)
9189  BAWGADutyCycle(0)
9190 
9191  if AWGAFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
9192  AWGAShape.set(1)
9193  BAWGAShape()
9194  UpdateAwgCont()
9195  return
9196 
9197  if AWGAFreqvalue > 0.0:
9198  if AWG_2X.get() == 1:
9199  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
9200  else:
9201  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9202  else:
9203  AWGAperiodvalue = 10.0
9204 
9205  if AWGAPhaseDelay.get() == 0:
9206  if AWGAPhasevalue > 0:
9207  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9208  else:
9209  AWGAdelayvalue = 0.0
9210  elif AWGAPhaseDelay.get() == 1:
9211  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
9212  Cycles = int(32768/AWGAperiodvalue)
9213  if Cycles < 1:
9214  Cycles = 1
9215  RecLength = int(Cycles * AWGAperiodvalue)
9216  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9217  RecLength = RecLength + 1
9218  AWGAwaveform = []
9219  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
9220 
9221  if AWG_Amp_Mode.get() == 0:
9222  if AWGAMode.get() == 1: # convert to mA
9223  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
9224  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
9225  else:
9226  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
9227  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
9228  else:
9229  if AWGAMode.get() == 1: # convert to mA
9230  amplitude = AWGAAmplvalue/1000.0
9231  offset = AWGAOffsetvalue/1000.0
9232  else:
9233  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
9234  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
9235  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
9236  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9237 #
9239  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9240  BAWGAPhaseDelay()
9241  duty1lab.config(text="%")
9242  UpdateAwgCont()
9243 #
9245  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
9246  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
9247  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
9248  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9249 
9250  BAWGAAmpl(0)
9251  BAWGAOffset(0)
9252  BAWGAFreq(0)
9253 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
9254  duty1lab.config(text = "M Index")
9255  phasealab.config(text = "M Freq")
9256 
9257  if AWGAFreqvalue > 0.0:
9258  if AWG_2X.get() == 1:
9259  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
9260  else:
9261  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9262  else:
9263  AWGAperiodvalue = 10.0
9264 
9265  try:
9266  ModFreq = float(eval(AWGAPhaseEntry.get()))
9267  except:
9268  ModFreq = 10
9269  AWGAPhaseEntry.delete(0,"end")
9270  AWGAPhaseEntry.insert(0, ModFreq)
9271 
9272  if ModFreq < 10:
9273  ModFreq = 10
9274  AWGAPhaseEntry.delete(0,"end")
9275  AWGAPhaseEntry.insert(0, ModFreq)
9276 
9277  if AWG_2X.get() == 1:
9278  MODperiodvalue = (BaseSampleRate*2)/ModFreq
9279  else:
9280  MODperiodvalue = BaseSampleRate/ModFreq
9281 
9282  try:
9283  ModIndex = float(eval(AWGADutyCycleEntry.get()))
9284  except:
9285  ModIndex = 1.0
9286  AWGADutyCycleEntry.delete(0,"end")
9287  AWGADutyCycleEntry.insert(0, ModIndex)
9288 
9289  ModCycles = int(32768/MODperiodvalue) # find a whole number of cycles
9290  if ModCycles < 1:
9291  ModCycles = 1
9292  RecLength = int(ModCycles * MODperiodvalue)
9293  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9294  RecLength = RecLength + 1
9295  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
9296  AWGAwaveform = []
9297  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
9298  if AWG_Amp_Mode.get() == 0:
9299  if AWGAMode.get() == 1: # convert to mA
9300  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
9301  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
9302  else:
9303  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
9304  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
9305  else:
9306  if AWGAMode.get() == 1: # convert to mA
9307  amplitude = AWGAAmplvalue/1000.0
9308  offset = AWGAOffsetvalue/1000.0
9309  else:
9310  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
9311  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
9312  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
9313  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9314 #
9315  SplitAWGAwaveform() # if needed
9316  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9317  UpdateAwgCont()
9318 #
9320  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
9321  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
9322  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
9323  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9324 
9325  BAWGAAmpl(0)
9326  BAWGAOffset(0)
9327  BAWGAFreq(0)
9328 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
9329  duty1lab.config(text = "M Index")
9330  phasealab.config(text = "M Freq")
9331 
9332  if AWGAFreqvalue > 0.0:
9333  if AWG_2X.get() == 1:
9334  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
9335  else:
9336  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9337  else:
9338  AWGAperiodvalue = 10.0
9339 
9340  try:
9341  ModFreq = float(eval(AWGAPhaseEntry.get()))
9342  except:
9343  ModFreq = 10
9344  AWGAPhaseEntry.delete(0,"end")
9345  AWGAPhaseEntry.insert(0, ModFreq)
9346 
9347  if ModFreq < 10:
9348  ModFreq = 10
9349  AWGAPhaseEntry.delete(0,"end")
9350  AWGAPhaseEntry.insert(0, ModFreq)
9351 
9352  if AWG_2X.get() == 1:
9353  MODperiodvalue = (BaseSampleRate*2)/ModFreq
9354  else:
9355  MODperiodvalue = BaseSampleRate/ModFreq
9356 
9357  try:
9358  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
9359  except:
9360  ModIndex = 50.0
9361  AWGADutyCycleEntry.delete(0,"end")
9362  AWGADutyCycleEntry.insert(0, ModIndex)
9363 
9364  ModCycles = int(32768/MODperiodvalue) # find a whole number of cycles
9365  if ModCycles < 1:
9366  ModCycles = 1
9367  RecLength = int(ModCycles * MODperiodvalue)
9368  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9369  RecLength = RecLength + 1
9370  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
9371  AWGAwaveform = []
9372  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
9373  if AWG_Amp_Mode.get() == 0:
9374  if AWGAMode.get() == 1: # convert to mA
9375  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
9376  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
9377  else:
9378  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
9379  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
9380  else:
9381  if AWGAMode.get() == 1: # convert to mA
9382  amplitude = AWGAAmplvalue/1000.0
9383  offset = AWGAOffsetvalue/1000.0
9384  else:
9385  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
9386  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
9387  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
9388  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9389 #
9390  SplitAWGAwaveform() # if needed
9391  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9392  UpdateAwgCont()
9393 #
9395  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
9396  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9397  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9398  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9399 
9400  BAWGAAmpl(0)
9401  BAWGAOffset(0)
9402  BAWGAFreq(0)
9403  BAWGAPhase(0)
9404  BAWGADutyCycle(0)
9405 
9406  if AWGAFreqvalue > 0.0:
9407  if AWG_2X.get() == 1:
9408  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9409  else:
9410  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9411  else:
9412  AWGAperiodvalue = 0.0
9413  if AWG_Amp_Mode.get() == 1:
9414  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9415  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9416  else:
9417  MaxV = AWGAOffsetvalue
9418  MinV = AWGAAmplvalue
9419 
9420  PulseWidth = int(AWGADutyCyclevalue*100)
9421  PulseSamples = int(AWGAperiodvalue/PulseWidth)
9422  AWGAwaveform = []
9423  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
9424  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
9425  # print(v)
9426  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
9427  if j >= v:
9428  AWGAwaveform.append(MaxV) # j>=v?1:0
9429  else:
9430  AWGAwaveform.append(MinV) # j>=v?1:0
9432  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9433  duty1lab.config(text="PWidth")
9434  UpdateAwgCont()
9435 #
9437  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
9438  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9439  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9440  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9441 
9442  BAWGAAmpl(0)
9443  BAWGAOffset(0)
9444  BAWGAFreq(0)
9445  BAWGADutyCycle(0)
9446 
9447  Max_term = int(AWGADutyCyclevalue*100)
9448  if AWG_2X.get() == 1:
9449  TempRate = (BaseSampleRate*2)
9450  else:
9451  TempRate = BaseSampleRate
9452  AWGAwaveform = []
9453  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, TempRate/AWGAFreqvalue)) # the fundamental
9454  k = 3
9455  while k <= Max_term:
9456  # Add odd harmonics up to max_term
9457  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, TempRate/AWGAFreqvalue)))
9458  AWGAwaveform = AWGAwaveform + Harmonic
9459  k = k + 2 # skip even numbers
9460  if AWG_Amp_Mode.get() == 0:
9461  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
9462  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
9463  else:
9464  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
9465  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
9466  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
9468  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9469  duty1lab.config(text="Harmonics")
9470  UpdateAwgCont()
9471 #
9473  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
9474  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
9475  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9476  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9477 
9478  BAWGAAmpl(0)
9479  BAWGAOffset(0)
9480  BAWGAFreq(0)
9481  BAWGAPhase(0)
9482  BAWGADutyCycle(0)
9483 
9484  if AWGAFreqvalue > 0.0:
9485  if AWG_2X.get() == 1:
9486  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9487  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9488  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9489  AWGAperiodvalue = AWGAperiodvalue + 1
9490  else:
9491  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9492  SamplesPermS = int(BaseSampleRate/1000) # 100
9493  else:
9494  AWGAperiodvalue = 0.0
9495  if AWG_Amp_Mode.get() == 1:
9496  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9497  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9498  else:
9499  MaxV = AWGAOffsetvalue
9500  MinV = AWGAAmplvalue
9501 
9502  if AWGAPhaseDelay.get() == 0:
9503  if AWGAPhasevalue > 0:
9504  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9505  else:
9506  AWGAdelayvalue = 0.0
9507  elif AWGAPhaseDelay.get() == 1:
9508  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
9509 
9510  Cycles = int(AWGADutyCyclevalue*100)
9511  NCycles = -1 * Cycles
9512  AWGAwaveform = []
9513  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, SAMPLErate/AWGAFreqvalue))
9514  amplitude = (MaxV-MinV) / 2.0
9515  offset = (MaxV+MinV) / 2.0
9516  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
9517  Cycles = int(37500/AWGAperiodvalue)
9518  if Cycles < 1:
9519  Cycles = 1
9520  if Cycles > 1:
9521  Extend = int((Cycles-1.0)*AWGAperiodvalue/2.0)
9522  AWGAwaveform = numpy.pad(AWGAwaveform, (Extend,Extend), 'wrap')
9523  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9525  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9526  #BAWGAPhaseDelay()
9527  duty1lab.config(text="Cycles")
9528  UpdateAwgCont()
9529 #
9531  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9532  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9533  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9534  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9535  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9536 
9537  BAWGAAmpl(0)
9538  BAWGAOffset(0)
9539  BAWGAFreq(0)
9540  BAWGAPhase(0)
9541  BAWGADutyCycle(0)
9542 
9543  if AWGAFreqvalue > 0.0:
9544  if AWG_2X.get() == 1:
9545  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9546  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9547  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9548  AWGAperiodvalue = AWGAperiodvalue + 1
9549  else:
9550  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9551  SamplesPermS = int(BaseSampleRate/1000) # 100
9552  else:
9553  AWGAperiodvalue = 0.0
9554  if AWG_Amp_Mode.get() == 1:
9555  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9556  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9557  else:
9558  MaxV = AWGAOffsetvalue
9559  MinV = AWGAAmplvalue
9560  AWGAwaveform = []
9561  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
9562  if SlopeValue <= 0:
9563  SlopeValue = 1
9564  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9565  if PulseWidth <=0:
9566  PulseWidth = 1
9567  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
9568  if Remainder <= 0:
9569  Remainder = 1
9570  PulseWidth = PulseWidth - SlopeValue
9571  if PulseWidth <=0:
9572  PulseWidth = 1
9573  StepAmp = (MaxV - MinV)/2
9574  StepOff = (MaxV + MinV)/2
9575  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
9576  MidArray = numpy.ones(PulseWidth) * MinV
9577  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
9578  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
9579  if AWGABurstFlag.get() == 1:
9580  TempOneCycle = AWGAwaveform
9581  for i in range(AWGACycles-1):
9582  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9583  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9584  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9586  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9587  duty1lab.config(text="%")
9588  phasealab.config(text = "Rise Time")
9589  UpdateAwgCont()
9590 #
9592  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9593  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9594  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9595  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9596  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9597 
9598  BAWGAAmpl(0)
9599  BAWGAOffset(0)
9600  BAWGAFreq(0)
9601  BAWGAPhase(0)
9602  BAWGADutyCycle(0)
9603 
9604  if AWGAFreqvalue > 0.0:
9605  if AWG_2X.get() == 1:
9606  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9607  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9608  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9609  AWGAperiodvalue = AWGAperiodvalue + 1
9610  else:
9611  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9612  SamplesPermS = int(BaseSampleRate/1000) # 100
9613  else:
9614  AWGAperiodvalue = 0.0
9615  if AWG_Amp_Mode.get() == 1:
9616  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9617  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9618  else:
9619  MaxV = AWGAOffsetvalue
9620  MinV = AWGAAmplvalue
9621  AWGAwaveform = []
9622  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9623  if SlopeValue <= 0:
9624  SlopeValue = 1
9625  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9626  if PulseWidth <=0:
9627  PulseWidth = 1
9628  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
9629  if Remainder <= 0:
9630  Remainder = 1
9631  PulseWidth = PulseWidth - SlopeValue
9632  if PulseWidth <=0:
9633  PulseWidth = 1
9634  StepValue = (MaxV - MinV) / SlopeValue
9635  SampleValue = MinV
9636  for i in range(SlopeValue):
9637  AWGAwaveform.append(SampleValue)
9638  SampleValue = SampleValue + StepValue
9639  for i in range(PulseWidth):
9640  AWGAwaveform.append(MaxV)
9641  for i in range(SlopeValue):
9642  AWGAwaveform.append(SampleValue)
9643  SampleValue = SampleValue - StepValue
9644  for i in range(Remainder):
9645  AWGAwaveform.append(MinV)
9646  if AWGABurstFlag.get() == 1:
9647  TempOneCycle = AWGAwaveform
9648  for i in range(AWGACycles-1):
9649  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9650  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9651  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9653  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9654  duty1lab.config(text="%")
9655  phasealab.config(text = "Rise Time")
9656  UpdateAwgCont()
9657 #
9659  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9660  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9661  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9662  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9663  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9664 
9665  BAWGAAmpl(0)
9666  BAWGAOffset(0)
9667  BAWGAFreq(0)
9668  BAWGAPhase(0)
9669 
9670  try:
9671  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
9672  except:
9673  AWGADutyCycleEntry.delete(0,"end")
9674  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
9675 
9676  if AWGAFreqvalue > 0.0:
9677  if AWG_2X.get() == 1:
9678  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9679  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9680  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9681  AWGAperiodvalue = AWGAperiodvalue + 1
9682  else:
9683  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9684  SamplesPermS = int(BaseSampleRate/1000) # 100
9685  else:
9686  AWGAperiodvalue = 0.0
9687  if AWG_Amp_Mode.get() == 1:
9688  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9689  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9690  else:
9691  MaxV = AWGAOffsetvalue
9692  MinV = AWGAAmplvalue
9693  AWGAwaveform = []
9694  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9695  if SlopeValue <= 0:
9696  SlopeValue = 1
9697  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
9698  if PulseWidth <=0:
9699  PulseWidth = 1
9700  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
9701  if Remainder <= 0:
9702  Remainder = 1
9703  PulseWidth = PulseWidth - SlopeValue
9704  if PulseWidth <=0:
9705  PulseWidth = 1
9706  StepValue = (MaxV - MinV) / SlopeValue
9707  SampleValue = MinV
9708  for i in range(SlopeValue):
9709  AWGAwaveform.append(SampleValue)
9710  SampleValue = SampleValue + StepValue
9711  for i in range(PulseWidth):
9712  AWGAwaveform.append(MaxV)
9713  for i in range(SlopeValue):
9714  AWGAwaveform.append(SampleValue)
9715  SampleValue = SampleValue - StepValue
9716  for i in range(Remainder):
9717  AWGAwaveform.append(MinV)
9718  if AWGABurstFlag.get() == 1:
9719  TempOneCycle = AWGAwaveform
9720  for i in range(AWGACycles-1):
9721  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9722  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9723  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9725  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9726  duty1lab.config(text="Width mS")
9727  phasealab.config(text = "Rise Time")
9728  UpdateAwgCont()
9729 #
9731  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9732  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9733  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9734  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9735  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9736 
9737  BAWGAAmpl(0)
9738  BAWGAOffset(0)
9739  BAWGAFreq(0)
9740  BAWGAPhase(0)
9741  BAWGADutyCycle(0)
9742 
9743  if AWGAFreqvalue > 0.0:
9744  if AWG_2X.get() == 1:
9745  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9746  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9747  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9748  AWGAperiodvalue = AWGAperiodvalue + 1
9749  else:
9750  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9751  SamplesPermS = int(BaseSampleRate/1000) # 100
9752  else:
9753  AWGAperiodvalue = 0.0
9754  if AWG_Amp_Mode.get() == 1:
9755  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9756  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9757  else:
9758  MaxV = AWGAOffsetvalue
9759  MinV = AWGAAmplvalue
9760  AWGAwaveform = []
9761  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9762  if SlopeValue <= 0:
9763  SlopeValue = 1
9764  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9765  if PulseWidth <=0:
9766  PulseWidth = 1
9767  Remainder = int(AWGAperiodvalue - PulseWidth)
9768  if Remainder <= 0:
9769  Remainder = 1
9770  PulseWidth = PulseWidth - SlopeValue
9771  if PulseWidth <=0:
9772  PulseWidth = 1
9773  StepValue = (MaxV - MinV) / SlopeValue
9774  SampleValue = MinV
9775  for i in range(SlopeValue):
9776  AWGAwaveform.append(SampleValue)
9777  SampleValue = SampleValue + StepValue
9778  for i in range(PulseWidth):
9779  AWGAwaveform.append(MaxV)
9780  for i in range(Remainder):
9781  AWGAwaveform.append(MinV)
9782  if AWGABurstFlag.get() == 1:
9783  TempOneCycle = AWGAwaveform
9784  for i in range(AWGACycles-1):
9785  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9786  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9787  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9789  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9790  duty1lab.config(text="%")
9791  phasealab.config(text = "Slope Time")
9792  UpdateAwgCont()
9793 #
9795  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
9796  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9797  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9798  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9799  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9800 
9801  BAWGAAmpl(0)
9802  BAWGAOffset(0)
9803  BAWGAFreq(0)
9804  BAWGAPhase(0)
9805  BAWGADutyCycle(0)
9806 
9807  if AWGAFreqvalue > 0.0:
9808  if AWG_2X.get() == 1:
9809  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9810  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9811  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9812  AWGAperiodvalue = AWGAperiodvalue + 1
9813  else:
9814  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
9815  SamplesPermS = int(BaseSampleRate/1000) # 100
9816  else:
9817  AWGAperiodvalue = 0.0
9818  if AWG_Amp_Mode.get() == 1:
9819  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9820  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9821  else:
9822  MaxV = AWGAOffsetvalue
9823  MinV = AWGAAmplvalue
9824  #
9825  if AWGAPhaseDelay.get() == 0:
9826  if AWGAPhasevalue > 0:
9827  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9828  else:
9829  AWGAdelayvalue = 0.0
9830  elif AWGAPhaseDelay.get() == 1:
9831  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
9832  #
9833  AWGAwaveform = []
9834  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9835  if PulseWidth <=0:
9836  PulseWidth = 1
9837  Remainder = int(AWGAperiodvalue - PulseWidth)
9838  if Remainder <= 0:
9839  Remainder = 1
9840  UpStepValue = (MaxV - MinV) / PulseWidth
9841  DownStepValue = (MaxV - MinV) / Remainder
9842  SampleValue = MinV
9843  for i in range(PulseWidth):
9844  AWGAwaveform.append(SampleValue)
9845  SampleValue = SampleValue + UpStepValue
9846  for i in range(Remainder):
9847  AWGAwaveform.append(SampleValue)
9848  SampleValue = SampleValue - DownStepValue
9849  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9850  if AWGABurstFlag.get() == 1:
9851  TempOneCycle = AWGAwaveform
9852  for i in range(AWGACycles-1):
9853  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9854  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9855  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
9857  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9858  BAWGAPhaseDelay()
9859  duty1lab.config(text = "Symmetry")
9860  UpdateAwgCont()
9861 #
9863  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9864  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
9865  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9866  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9867  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9868 
9869  BAWGAAmpl(0)
9870  BAWGAOffset(0)
9871  BAWGAFreq(0)
9872  BAWGAPhase(0)
9873  BAWGADutyCycle(0)
9874 
9875  if AWGAFreqvalue > 0.0:
9876  if AWG_2X.get() == 1:
9877  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9878  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9879  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9880  AWGAperiodvalue = AWGAperiodvalue + 1
9881  else:
9882  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9883  SamplesPermS = int(BaseSampleRate/1000) # 100
9884  else:
9885  AWGAperiodvalue = 0.0
9886  if AWG_Amp_Mode.get() == 1:
9887  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9888  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9889  else:
9890  MaxV = AWGAOffsetvalue
9891  MinV = AWGAAmplvalue
9892  AWGAwaveform = []
9893  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
9894  if AWGAPhaseDelay.get() == 0:
9895  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
9896  elif AWGAPhaseDelay.get() == 1:
9897  DelayValue = int(AWGAPhasevalue*SamplesPermS)
9898  for i in range(DelayValue-PulseWidth):
9899  AWGAwaveform.append((MinV+MaxV)/2.0)
9900  for i in range(PulseWidth):
9901  AWGAwaveform.append(MaxV)
9902  for i in range(PulseWidth):
9903  AWGAwaveform.append(MinV)
9904  DelayValue = int(AWGAperiodvalue-DelayValue)
9905  for i in range(DelayValue-PulseWidth):
9906  AWGAwaveform.append((MinV+MaxV)/2.0)
9907  if AWGABurstFlag.get() == 1:
9908  TempOneCycle = AWGAwaveform
9909  for i in range(AWGACycles-1):
9910  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9911  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9912  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
9914  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9915  UpdateAwgCont()
9916 
9918  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
9919  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9920  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9921  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9922  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9923 
9924  BAWGAAmpl(0)
9925  BAWGAOffset(0)
9926  BAWGAFreq(0)
9927 
9928  if AWGAFreqvalue > 0.0:
9929  if AWG_2X.get() == 1:
9930  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9931  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9932  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9933  AWGAperiodvalue = AWGAperiodvalue + 1
9934  else:
9935  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9936  SamplesPermS = int(BaseSampleRate/1000) # 100
9937  else:
9938  AWGAperiodvalue = 0.0
9939  if AWG_Amp_Mode.get() == 1:
9940  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9941  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9942  else:
9943  if AWGAAmplvalue > AWGAOffsetvalue:
9944  MinV = AWGAOffsetvalue
9945  MaxV = AWGAAmplvalue
9946  else:
9947  MaxV = AWGAOffsetvalue
9948  MinV = AWGAAmplvalue
9949  AWGAwaveform = []
9950  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
9951  Mid = (MaxV+MinV)/2.0
9952  if AWGABurstFlag.get() == 1:
9953  TempOneCycle = AWGAwaveform
9954  for i in range(AWGACycles-1):
9955  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9956  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9957  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
9959  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9960  UpdateAwgCont()
9961 
9963  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
9964  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9965  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9966  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9967  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9968 
9969  BAWGAAmpl(0)
9970  BAWGAOffset(0)
9971  BAWGAFreq(0)
9972 
9973  if AWGAFreqvalue > 0.0:
9974  if AWG_2X.get() == 1:
9975  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9976  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9977  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9978  AWGAperiodvalue = AWGAperiodvalue + 1
9979  else:
9980  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9981  SamplesPermS = int(BaseSampleRate/1000) # 100
9982  else:
9983  AWGAperiodvalue = 0.0
9984  if AWG_Amp_Mode.get() == 1:
9985  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9986  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9987  else:
9988  if AWGAAmplvalue > AWGAOffsetvalue:
9989  MinV = AWGAOffsetvalue
9990  MaxV = AWGAAmplvalue
9991  else:
9992  MaxV = AWGAOffsetvalue
9993  MinV = AWGAAmplvalue
9994  AWGAwaveform = []
9995  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
9996  Mid = (MaxV+MinV)/2.0
9997  if AWGABurstFlag.get() == 1:
9998  TempOneCycle = AWGAwaveform
9999  for i in range(AWGACycles-1):
10000  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
10001  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
10002  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
10004  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
10005  UpdateAwgCont()
10006 
10008  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
10009  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10010 
10011  if AWGAMode.get() == 0: # Source Voltage measure current mode
10012  label_txt = "SVMI"
10013  elif AWGAMode.get() == 1: # Source current measure voltage mode
10014  label_txt = "SIMV"
10015  elif AWGAMode.get() == 2: # High impedance mode
10016  label_txt = "Hi-Z"
10017  if AWGAIOMode.get() > 0: # Split Input / Output mode
10018  if HWRevOne == "D":
10019  if AWGAMode.get() == 0:
10020  AWGAMode.set(1)
10021  CHA.set_mode('i') # channel must be in source current mode for rev D boards
10022  label_txt = "SIMV"
10023  label_txt = label_txt + " Split I/O"
10024  label_txt = label_txt + " Mode"
10025  AWGAModeLabel.config(text = label_txt ) # change displayed value
10026  ReMakeAWGwaves()
10027  #UpdateAwgCont()
10028 
10030  global AWGAAmplvalue, AWGAOffsetvalue
10031  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
10032  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
10033  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
10034  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10035  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
10036  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10037 
10038  BAWGAAmpl(0)
10039  BAWGAOffset(0)
10040  BAWGAFreq(0)
10041  BAWGAPhase(0)
10042  BAWGADutyCycle(0)
10043  BAWGAShape()
10044 
10045  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
10046  amp1lab.config(text = "Min Ch A" ) # change displayed value
10047  off1lab.config(text = "Max Ch A" ) # change displayed value
10048  else:
10049  amp1lab.config(text = "Amp Ch A" )
10050  off1lab.config(text = "Off Ch A" )
10051 
10052  if AWGAFreqvalue > 0.0:
10053  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
10054  else:
10055  AWGAperiodvalue = 0.0
10056 
10057  if AWGAPhaseDelay.get() == 0:
10058  if AWGAWave == 'square':
10059  AWGAPhasevalue = AWGAPhasevalue + 270.0
10060  if AWGAPhasevalue > 359:
10061  AWGAPhasevalue = AWGAPhasevalue - 360
10062  if AWGAPhasevalue > 0:
10063  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
10064  else:
10065  AWGAdelayvalue = 0.0
10066  elif AWGAPhaseDelay.get() == 1:
10067  AWGAdelayvalue = AWGAPhasevalue * 100
10068 
10069  if AWGATerm.get() == 0: # Open termination
10070  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
10071  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
10072  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
10073  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
10074  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
10075  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
10076  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
10077  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
10078 
10079  if AWGAWave == 'dc':
10080  if AWG_2X.get() == 2:
10081  AWGAWave == 'arbitrary'
10082  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
10083  else:
10084  if AWGAMode.get() == 0: # Source Voltage measure current mode
10085  if AWGAIOMode.get() == 0:
10086  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
10087  else:
10088  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
10089  CHA.constant(AWGAOffsetvalue)
10090  #
10091  if AWGAMode.get() == 1: # Source current measure voltage mode
10092  if AWGAIOMode.get() == 0:
10093  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
10094  else:
10095  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
10096  CHA.constant(AWGAOffsetvalue/1000)
10097  #
10098  if AWGAMode.get() == 2: # High impedance mode
10099  if AWGAIOMode.get() == 0:
10100  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
10101  else:
10102  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
10103  #
10104  if AWGAIOMode.get() > 0: # Split Input / Output mode
10105  if HWRevOne == "D":
10106  AWGAMode.set(1)
10107  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
10108 #
10109  else:
10110  if AWGAMode.get() == 0: # Source Voltage measure current mode
10111  if AWGAIOMode.get() == 0:
10112  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
10113  else:
10114  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
10115  if AWGAMode.get() == 1: # Source current measure voltage mode
10116  if AWGAIOMode.get() == 0:
10117  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
10118  else:
10119  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
10120  AWGAOffsetvalue = AWGAOffsetvalue/1000
10121  AWGAAmplvalue = AWGAAmplvalue/1000
10122  if AWGAMode.get() == 2: # High impedance mode
10123  if AWGAIOMode.get() == 0:
10124  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
10125  else:
10126  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
10127  else:
10128  if AWG_Amp_Mode.get() == 1:
10129  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10130  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10131  else:
10132  MaxV = AWGAOffsetvalue
10133  MinV = AWGAAmplvalue
10134  try:
10135  if AWGAWave == 'sine':
10136  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
10137  elif AWGAWave == 'triangle':
10138  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
10139  elif AWGAWave == 'sawtooth':
10140  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
10141  elif AWGAWave == 'square':
10142  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
10143  elif AWGAWave == 'stairstep':
10144  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
10145  elif AWGAWave == 'arbitrary':
10146  if AWGSync.get() == 0:
10147  AWGARepeatFlag.set(1)
10148  if AWG_2X.get() == 2:
10149  AWGAWave == 'arbitrary'
10150  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
10151  else:
10152  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
10153  except:
10154  donothing()
10155  if AWGAIOMode.get() > 0: # Split Input / Output mode
10156  if HWRevOne == "D":
10157  AWGAMode.set(1)
10158  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
10159 # AWG B functions
10161  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
10162  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
10163  global BisCompA
10164 
10165  # if BisCompA.get() == 1:
10166  # sawp Min and Max values
10167  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
10168  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
10169  AWGBAmplEntry.delete(0,"end")
10170  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
10171  AWGBOffsetEntry.delete(0,"end")
10172  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
10173  # copy everything else
10174  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
10175  AWGBFreqEntry.delete(0,"end")
10176  AWGBFreqEntry.insert(0, AWGBFreqvalue)
10177  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
10178  AWGBPhaseEntry.delete(0,"end")
10179  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
10180  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
10181  AWGBDutyCycleEntry.delete(0,"end")
10182  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
10183  AWGBShape.set(AWGAShape.get())
10184  #
10185 # ReMakeAWGwaves()
10186 # UpdateAwgCont()
10187 #
10189  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10190 
10191  if AWGBBurstFlag.get() == 1:
10192  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
10193  if (AWGBCyclesString == None): # If Cancel pressed, then None
10194  return
10195  AWGBCycles = int(AWGBCyclesString)
10196  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
10197  if (AWGBDelayString == None): # If Cancel pressed, then None
10198  return
10199  AWGBBurstDelay = float(AWGBDelayString)
10200  ReMakeAWGwaves()
10201 #
10202 def BAWGBAmpl(temp):
10203  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10204  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10205 
10206  try:
10207  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
10208  except:
10209  AWGBAmplEntry.delete(0,"end")
10210  AWGBAmplEntry.insert(0, AWGBAmplvalue)
10211  #
10212  if AWGBMode.get() == 0: # Source Voltage measure current mode
10213  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
10214  if AWGBAmplvalue > 5.00:
10215  AWGBAmplvalue = 5.00
10216  AWGBAmplEntry.delete(0,"end")
10217  AWGBAmplEntry.insert(0, AWGBAmplvalue)
10218  if AWGBAmplvalue < 0.00:
10219  AWGBAmplvalue = 0.00
10220  AWGBAmplEntry.delete(0,"end")
10221  AWGBAmplEntry.insert(0, AWGBAmplvalue)
10222  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10223  if AWGBAmplvalue > (2.5 / AWGB_Ext_Gain.get()):
10224  AWGBAmplvalue = 2.5 / AWGB_Ext_Gain.get()
10225  AWGBAmplEntry.delete(0,"end")
10226  AWGBAmplEntry.insert(0, AWGBAmplvalue)
10227  if AWGBAmplvalue < (-2.50 / AWGB_Ext_Gain.get()):
10228  AWGBAmplvalue = -2.50 / AWGB_Ext_Gain.get()
10229  AWGBAmplEntry.delete(0,"end")
10230  AWGBAmplEntry.insert(0, AWGBAmplvalue)
10231  elif AWGBMode.get() == 1: # Source current measure voltage mode
10232  if AWGBAmplvalue > 200.00:
10233  AWGBAmplvalue = 200.00
10234  AWGBAmplEntry.delete(0,"end")
10235  AWGBAmplEntry.insert(0, AWGBAmplvalue)
10236  if AWGBAmplvalue < -200.00:
10237  AWGBAmplvalue = -200.00
10238  AWGBAmplEntry.delete(0,"end")
10239  AWGBAmplEntry.insert(0, AWGBAmplvalue)
10240 #
10241 def BAWGBOffset(temp):
10242  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10243  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10244 
10245  try:
10246  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
10247  except:
10248  AWGBOffsetEntry.delete(0,"end")
10249  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
10250  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10251  if AWGBMode.get() == 0: # Source Voltage measure current mode
10252  if AWGBOffsetvalue > 5.00:
10253  AWGBOffsetvalue = 5.00
10254  AWGBOffsetEntry.delete(0,"end")
10255  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
10256  if AWGBOffsetvalue < 0.00:
10257  AWGBOffsetvalue = 0.00
10258  AWGBOffsetEntry.delete(0,"end")
10259  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
10260  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10261  if AWGBOffsetvalue > (2.50-AWGB_Ext_Offset.get()):
10262  AWGBOffsetvalue = 2.50-AWGB_Ext_Offset.get()
10263  AWGBOffsetEntry.delete(0,"end")
10264  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
10265  if AWGBOffsetvalue < (-2.50-AWGB_Ext_Offset.get()):
10266  AWGBOffsetvalue = -2.50-AWGB_Ext_Offset.get()
10267  AWGBOffsetEntry.delete(0,"end")
10268  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
10269  if AWGBMode.get() == 1: # Source current measure voltage mode
10270  if AWGBOffsetvalue > 200.00:
10271  AWGBOffsetvalue = 200.00
10272  AWGBOffsetEntry.delete(0,"end")
10273  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
10274  if AWGBOffsetvalue < -200.00:
10275  AWGBOffsetvalue = -200.00
10276  AWGBOffsetEntry.delete(0,"end")
10277  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
10278 #
10279 def BAWGBFreq(temp):
10280  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
10281  global BodeScreenStatus, BodeDisp
10282 
10283  try:
10284  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
10285  except:
10286  AWGBFreqEntry.delete(0,"end")
10287  AWGBFreqEntry.insert(0, AWGBFreqvalue)
10288  if AWG_2X.get() == 2:
10289  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
10290  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
10291  AWGBFreqvalue = 90000
10292  AWGBFreqEntry.delete(0,"end")
10293  AWGBFreqEntry.insert(0, AWGBFreqvalue)
10294  else:
10295  if AWGBFreqvalue > 50000: # max freq is 50KHz
10296  AWGBFreqvalue = 50000
10297  AWGBFreqEntry.delete(0,"end")
10298  AWGBFreqEntry.insert(0, AWGBFreqvalue)
10299  else:
10300  if AWGBFreqvalue > 25000: # max freq is 25KHz
10301  AWGBFreqvalue = 25000
10302  AWGBFreqEntry.delete(0,"end")
10303  AWGBFreqEntry.insert(0, AWGBFreqvalue)
10304  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
10305  AWGBFreqvalue = 10
10306  AWGBFreqEntry.delete(0,"end")
10307  AWGBFreqEntry.insert(0, AWGBFreqvalue)
10308  # UpdateAWGB()
10309 
10311  global AWGbPhaseDelay, phaseblab, awgbph, awgbdel
10312 
10313  if AWGBPhaseDelay.get() == 0:
10314  phaseblab.configure(text="Deg")
10315  awgbph.configure(style="WPhase.TRadiobutton")
10316  awgbdel.configure(style="GPhase.TRadiobutton")
10317  elif AWGBPhaseDelay.get() == 1:
10318  phaseblab.configure(text="mSec")
10319  awgbph.configure(style="GPhase.TRadiobutton")
10320  awgbdel.configure(style="WPhase.TRadiobutton")
10321 
10322 def BAWGBPhase(temp):
10323  global AWGBPhaseEntry, AWGBPhasevalue
10324 
10325  try:
10326  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
10327  except:
10328  AWGBPhaseEntry.delete(0,"end")
10329  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
10330 
10331  if AWGBPhasevalue > 360: # max phase is 360 degrees
10332  AWGBPhasevalue = 360
10333  AWGBPhaseEntry.delete(0,"end")
10334  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
10335  if AWGBPhasevalue < 0: # min phase is 0 degrees
10336  AWGBPhasevalue = 0
10337  AWGBPhaseEntry.delete(0,"end")
10338  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
10339 
10340 def BAWGBDutyCycle(temp):
10341  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
10342 
10343  try:
10344  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
10345  except:
10346  AWGBDutyCycleEntry.delete(0,"end")
10347  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
10348 
10349  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
10350  AWGBDutyCyclevalue = 1
10351  AWGBDutyCycleEntry.delete(0,"end")
10352  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
10353  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
10354  AWGBDutyCyclevalue = 0
10355  AWGBDutyCycleEntry.delete(0,"end")
10356  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
10357  # UpdateAWGB()
10358 
10360  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
10361 
10362  if AWGBShape.get() == 0:
10363  AWGBWave = 'dc'
10364  duty2lab.config(text="%")
10365  BAWGBPhaseDelay()
10366  if AWGBShape.get() == 1:
10367  AWGBWave = 'sine'
10368  duty2lab.config(text="%")
10369  BAWGBPhaseDelay()
10370  if AWGBShape.get() == 2:
10371  AWGBWave = 'triangle'
10372  duty2lab.config(text="%")
10373  BAWGBPhaseDelay()
10374  if AWGBShape.get() == 3:
10375  AWGBWave = 'sawtooth'
10376  duty2lab.config(text="%")
10377  BAWGBPhaseDelay()
10378  if AWGBShape.get() == 4:
10379  AWGBWave = 'square'
10380  duty2lab.config(text="%")
10381  BAWGBPhaseDelay()
10382  if AWGBShape.get() == 5:
10383  AWGBWave = 'stairstep'
10384  duty2lab.config(text="%")
10385  BAWGBPhaseDelay()
10386  if AWGBShape.get() > 5:
10387  AWGBWave = 'arbitrary'
10388  if AWG_2X.get() == 1:
10389  CHB.mode = CHA.mode
10390  AWGBWave = 'arbitrary'
10391  # UpdateAWGB()
10392 
10394  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X
10395 
10396  # Read values from CVS file
10397  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10398  try:
10399  CSVFile = open(filename)
10400  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
10401  CSVFile.seek(0)
10402  #csv_f = csv.reader(CSVFile, dialect)
10403  csv_f = csv.reader(CSVFile, csv.excel)
10404  except:
10405  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10406  AWGBwaveform = []
10407  ColumnNum = 0
10408  ColumnSel = 0
10409  RowNum = 0
10410  for row in csv_f:
10411  if len(row) > 1 and ColumnSel == 0:
10412  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
10413  ColumnNum = int(RequestColumn) - 1
10414  ColumnLen = str(len(row))
10415  ColumnSel = 1
10416  try:
10417  colnum = 0
10418  for col in row:
10419  if colnum == ColumnNum:
10420  AWGBwaveform.append(float(col))
10421  colnum += 1
10422  except:
10423  print( 'skipping non-numeric row', RowNum)
10424  RowNum += 1
10425  AWGBwaveform = numpy.array(AWGBwaveform)
10427  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10428  CSVFile.close()
10429  UpdateAwgCont()
10430 
10431 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
10433  global AWG_2X, AWGB2X, AWGBwaveform
10434 
10435  if AWG_2X.get() == 2:
10436  Tempwaveform = []
10437  AWGB2X = []
10438  AWGB2X = AWGBwaveform[::2] # even numbered samples
10439  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
10440  AWGBwaveform = Tempwaveform
10441 #
10443  global AWGBwaveform, AWGBLength, awgwindow
10444  global AWG_2X, AWGA2X
10445 
10446 # Read values from WAV file
10447  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
10448  try:
10449  spf = wave.open(filename,'r')
10450  except:
10451  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10452  AWGBwaveform = []
10453  #If Stereo
10454  if spf.getnchannels() == 2:
10455  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
10456  return()
10457  #Extract Raw Audio from Wav File
10458  Length = spf.getnframes()
10459  if Length > 90000: # limit to first 90K samples
10460  Length = 90000
10461  signal = spf.readframes(Length)
10462  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
10463  # offset and scale for 0 5 V range
10464  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
10465  AWGBwaveform = numpy.array(AWGBwaveform)
10467  AWGBLength.config(text = "L = " + str(len(AWGBwaveform))) # change displayed value
10468  spf.close()
10469  UpdateAwgCont()
10470 
10472  global AWGBwaveform, AWGBLength, awgwindow
10473 
10474  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10475  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
10476 
10478  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10479  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
10480  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
10481  global DFiltACoef, DFiltBCoef, AWGBShapeLabel
10482  global AWG_2X, AWGA2X
10483 
10484  TempString = AWGBMathString
10485  AWGBShapeLabel.config(text = "Math" ) # change displayed value
10486  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
10487  if (AWGBMathString == None): # If Cancel pressed, then None
10488  AWGBMathString = TempString
10489  return
10490  AWGBwaveform = eval(AWGBMathString)
10491  AWGBwaveform = numpy.array(AWGBwaveform)
10493  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10494  UpdateAwgCont()
10495 #
10497  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
10498  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10499  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10500  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10501 
10502  Max_term = int(AWGBDutyCyclevalue*100)
10503 
10504  BAWGBAmpl(0)
10505  BAWGBOffset(0)
10506  BAWGBFreq(0)
10507  if AWG_2X.get() == 1:
10508  TempRate = (BaseSampleRate*2)
10509  else:
10510  TempRate = BaseSampleRate
10511  AWGBwaveform = []
10512  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, TempRate/AWGBFreqvalue)) # the fundamental
10513  k = 3
10514  while k <= Max_term:
10515  # Add odd harmonics up to max_term
10516  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, TempRate/AWGBFreqvalue)))
10517  AWGBwaveform = AWGBwaveform + Harmonic
10518  k = k + 2 # skip even numbers
10519  if AWG_Amp_Mode.get() == 0:
10520  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
10521  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
10522  else:
10523  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
10524  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
10525  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10527  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10528  duty2lab.config(text="Harmonics")
10529  UpdateAwgCont()
10530 #
10532  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
10533  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
10534  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
10535  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10536 
10537  BAWGBAmpl(0)
10538  BAWGBOffset(0)
10539  BAWGBFreq(0)
10540  BAWGBPhase(0)
10541  BAWGBDutyCycle(0)
10542 
10543  if AWGBFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
10544  AWGBShape.set(1)
10545  BAWGBShape()
10546  UpdateAwgCont()
10547  return
10548 
10549  if AWGBFreqvalue > 0.0:
10550  if AWG_2X.get() == 2:
10551  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10552  else:
10553  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10554  else:
10555  AWGBperiodvalue = 10.0
10556 
10557  if AWGBPhaseDelay.get() == 0:
10558  if AWGBPhasevalue > 0:
10559  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10560  else:
10561  AWGBdelayvalue = 0.0
10562  elif AWGBPhaseDelay.get() == 1:
10563  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
10564  Cycles = int(32768/AWGBperiodvalue)
10565  if Cycles < 1:
10566  Cycles = 1
10567  RecLength = int(Cycles * AWGBperiodvalue)
10568  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10569  RecLength = RecLength + 1
10570  AWGBwaveform = []
10571  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
10572 
10573  if AWG_Amp_Mode.get() == 0:
10574  if AWGBMode.get() == 1: # convert to mA
10575  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
10576  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
10577  else:
10578  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
10579  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
10580  else:
10581  if AWGBMode.get() == 1: # convert to mA
10582  amplitude = AWGBAmplvalue/1000.0
10583  offset = AWGBOffsetvalue/1000.0
10584  else:
10585  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
10586  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
10587  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10588  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10589  #
10590  if AWG_2X.get() == 2:
10591  Tempwaveform = []
10592  AWGB2X = []
10593  AWGB2X = AWGBwaveform[::2] # even numbered samples
10594  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
10595  AWGBwaveform = Tempwaveform
10596  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10597  BAWGBPhaseDelay()
10598  duty2lab.config(text="%")
10599  UpdateAwgCont()
10600 #
10602  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
10603  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10604  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10605  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10606 
10607  BAWGBAmpl(0)
10608  BAWGBOffset(0)
10609  BAWGBFreq(0)
10610  BAWGBPhase(0)
10611  BAWGBDutyCycle(0)
10612 
10613  if AWGBFreqvalue > 0.0:
10614  if AWG_2X.get() == 2:
10615  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10616  else:
10617  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10618  else:
10619  AWGBperiodvalue = 0.0
10620  if AWG_Amp_Mode.get() == 1:
10621  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10622  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10623  else:
10624  MaxV = AWGBOffsetvalue
10625  MinV = AWGBAmplvalue
10626 
10627  PulseWidth = int(AWGBDutyCyclevalue*100)
10628  PulseSamples = int(AWGBperiodvalue/PulseWidth)
10629  AWGBwaveform = []
10630  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
10631  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
10632  # print(v)
10633  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
10634  if j >= v:
10635  AWGBwaveform.append(MaxV) # j>=v?1:0
10636  else:
10637  AWGBwaveform.append(MinV) # j>=v?1:0
10639  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10640  duty2lab.config(text="PWidth")
10641  UpdateAwgCont()
10642 #
10644  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
10645  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
10646  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10647  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10648 
10649  BAWGBAmpl(0)
10650  BAWGBOffset(0)
10651  BAWGBFreq(0)
10652  BAWGBPhase(0)
10653  BAWGBDutyCycle(0)
10654 
10655  if AWGBFreqvalue > 0.0:
10656  if AWG_2X.get() == 1:
10657  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
10658  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10659  AWGBperiodvalue = AWGBperiodvalue + 1
10660  else:
10661  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10662  else:
10663  AWGBperiodvalue = 0.0
10664  if AWG_Amp_Mode.get() == 1:
10665  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10666  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10667  else:
10668  MaxV = AWGBOffsetvalue
10669  MinV = AWGBAmplvalue
10670 
10671  if AWGBPhaseDelay.get() == 0:
10672  if AWGBPhasevalue > 0:
10673  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10674  else:
10675  AWGBdelayvalue = 0.0
10676  elif AWGBPhaseDelay.get() == 1:
10677  AWGBdelayvalue = AWGBPhasevalue * SampleRate / 1000
10678 
10679  Cycles = int(AWGBDutyCyclevalue*100)
10680  NCycles = -1 * Cycles
10681  AWGBwaveform = []
10682  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, SAMPLErate/AWGBFreqvalue))
10683  amplitude = (MaxV-MinV) / 2.0
10684  offset = (MaxV+MinV) / 2.0
10685  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10686  Cycles = int(37500/AWGBperiodvalue)
10687  if Cycles < 1:
10688  Cycles = 1
10689  if Cycles > 1:
10690  Extend = int((Cycles-1.0)*AWGBperiodvalue/2.0)
10691  AWGBwaveform = numpy.pad(AWGBwaveform, (Extend,Extend), 'wrap')
10692  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10694  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10695  #BAWGAPhaseDelay()
10696  duty2lab.config(text="Cycles")
10697  UpdateAwgCont()
10698 #
10700  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10701  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10702  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10703  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10704  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10705  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10706 
10707  BAWGBAmpl(0)
10708  BAWGBOffset(0)
10709  BAWGBFreq(0)
10710  BAWGBPhase(0)
10711  BAWGBDutyCycle(0)
10712 
10713  if AWGBFreqvalue > 0.0:
10714  if AWG_2X.get() == 2:
10715  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10716  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10717  else:
10718  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10719  SamplesPermS = int(BaseSampleRate/1000) # 100
10720  else:
10721  AWGBperiodvalue = 0.0
10722  if AWG_Amp_Mode.get() == 1:
10723  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10724  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10725  else:
10726  MaxV = AWGBOffsetvalue
10727  MinV = AWGBAmplvalue
10728  AWGBwaveform = []
10729  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
10730  if SlopeValue <= 0:
10731  SlopeValue = 1
10732  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10733  if PulseWidth <=0:
10734  PulseWidth = 1
10735  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
10736  if Remainder <= 0:
10737  Remainder = 1
10738  PulseWidth = PulseWidth - SlopeValue
10739  if PulseWidth <=0:
10740  PulseWidth = 1
10741  StepAmp = (MaxV - MinV)/2
10742  StepOff = (MaxV + MinV)/2
10743  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
10744  MidArray = numpy.ones(PulseWidth) * MinV
10745  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
10746  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
10747  if AWGBBurstFlag.get() == 1:
10748  TempOneCycle = AWGBwaveform
10749  for i in range(AWGBCycles-1):
10750  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10751  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10752  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10754  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10755  duty2lab.config(text="%")
10756  phaseblab.config(text = "Rise Time")
10757  UpdateAwgCont()
10758 #
10760  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10761  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10762  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10763  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10764  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10765  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10766 
10767  BAWGBAmpl(0)
10768  BAWGBOffset(0)
10769  BAWGBFreq(0)
10770  BAWGBPhase(0)
10771  BAWGBDutyCycle(0)
10772 
10773  if AWGBFreqvalue > 0.0:
10774  if AWG_2X.get() == 2:
10775  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10776  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10777  else:
10778  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10779  SamplesPermS = int(BaseSampleRate/1000) # 100
10780  else:
10781  AWGBperiodvalue = 0.0
10782  if AWG_Amp_Mode.get() == 1:
10783  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10784  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10785  else:
10786  MaxV = AWGBOffsetvalue
10787  MinV = AWGBAmplvalue
10788  AWGBwaveform = []
10789  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
10790  if SlopeValue <= 0:
10791  SlopeValue = 1
10792  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10793  if PulseWidth <=0:
10794  PulseWidth = 1
10795  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
10796  if Remainder <= 0:
10797  Remainder = 1
10798  PulseWidth = PulseWidth - SlopeValue
10799  if PulseWidth <=0:
10800  PulseWidth = 1
10801  StepValue = (MaxV - MinV) / SlopeValue
10802  SampleValue = MinV
10803  for i in range(SlopeValue):
10804  AWGBwaveform.append(SampleValue)
10805  SampleValue = SampleValue + StepValue
10806  for i in range(PulseWidth):
10807  AWGBwaveform.append(MaxV)
10808  for i in range(SlopeValue):
10809  AWGBwaveform.append(SampleValue)
10810  SampleValue = SampleValue - StepValue
10811  for i in range(Remainder):
10812  AWGBwaveform.append(MinV)
10813  if AWGBBurstFlag.get() == 1:
10814  TempOneCycle = AWGBwaveform
10815  for i in range(AWGBCycles-1):
10816  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10817  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10818  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10820  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10821  duty2lab.config(text="%")
10822  phaseblab.config(text = "Rise Time")
10823  UpdateAwgCont()
10824 #
10826  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10827  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10828  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10829  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10830  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10831  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10832 
10833  BAWGBAmpl(0)
10834  BAWGBOffset(0)
10835  BAWGBFreq(0)
10836  BAWGBPhase(0)
10837 
10838  try:
10839  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
10840  except:
10841  AWGBDutyCycleEntry.delete(0,"end")
10842  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
10843 
10844  if AWGBFreqvalue > 0.0:
10845  if AWG_2X.get() == 2:
10846  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10847  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10848  else:
10849  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10850  SamplesPermS = int(BaseSampleRate/1000) # 100
10851  else:
10852  AWGBperiodvalue = 0.0
10853  if AWG_Amp_Mode.get() == 1:
10854  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10855  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10856  else:
10857  MaxV = AWGBOffsetvalue
10858  MinV = AWGBAmplvalue
10859  AWGBwaveform = []
10860  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
10861  if SlopeValue <= 0:
10862  SlopeValue = 1
10863  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
10864  if PulseWidth <=0:
10865  PulseWidth = 1
10866  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
10867  if Remainder <= 0:
10868  Remainder = 1
10869  PulseWidth = PulseWidth - SlopeValue
10870  if PulseWidth <=0:
10871  PulseWidth = 1
10872  StepValue = (MaxV - MinV) / SlopeValue
10873  SampleValue = MinV
10874  for i in range(SlopeValue):
10875  AWGBwaveform.append(SampleValue)
10876  SampleValue = SampleValue + StepValue
10877  for i in range(PulseWidth):
10878  AWGBwaveform.append(MaxV)
10879  for i in range(SlopeValue):
10880  AWGBwaveform.append(SampleValue)
10881  SampleValue = SampleValue - StepValue
10882  for i in range(Remainder):
10883  AWGBwaveform.append(MinV)
10884  if AWGBBurstFlag.get() == 1:
10885  TempOneCycle = AWGBwaveform
10886  for i in range(AWGBCycles-1):
10887  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10888  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10889  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10891  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10892  duty2lab.config(text="Width mS")
10893  phaseblab.config(text = "Rise Time")
10894  UpdateAwgCont()
10895 #
10897  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10898  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10899  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10900  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10901  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10902  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10903 
10904  BAWGBAmpl(0)
10905  BAWGBOffset(0)
10906  BAWGBFreq(0)
10907  BAWGBPhase(0)
10908  BAWGBDutyCycle(0)
10909 
10910  if AWGBFreqvalue > 0.0:
10911  if AWG_2X.get() == 2:
10912  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10913  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10914  else:
10915  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10916  SamplesPermS = int(BaseSampleRate/1000) # 100
10917  else:
10918  AWGBperiodvalue = 0.0
10919  if AWG_Amp_Mode.get() == 1:
10920  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10921  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10922  else:
10923  MaxV = AWGBOffsetvalue
10924  MinV = AWGBAmplvalue
10925  AWGBwaveform = []
10926  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
10927  if SlopeValue <= 0:
10928  SlopeValue = 1
10929  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10930  if PulseWidth <=0:
10931  PulseWidth = 1
10932  Remainder = int(AWGBperiodvalue - PulseWidth)
10933  if Remainder <= 0:
10934  Remainder = 1
10935  PulseWidth = PulseWidth - SlopeValue
10936  if PulseWidth <=0:
10937  PulseWidth = 1
10938  StepValue = (MaxV - MinV) / SlopeValue
10939  SampleValue = MinV
10940  for i in range(SlopeValue):
10941  AWGBwaveform.append(SampleValue)
10942  SampleValue = SampleValue + StepValue
10943  for i in range(PulseWidth):
10944  AWGBwaveform.append(MaxV)
10945  for i in range(Remainder):
10946  AWGBwaveform.append(MinV)
10947  if AWGBBurstFlag.get() == 1:
10948  TempOneCycle = AWGBwaveform
10949  for i in range(AWGBCycles-1):
10950  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10951  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10952  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10954  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10955  duty2lab.config(text="%")
10956  phaseblab.config(text = "Slope Time")
10957  UpdateAwgCont()
10958 #
10960  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10961  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10962  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10963  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10964  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10965  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10966 
10967  BAWGBAmpl(0)
10968  BAWGBOffset(0)
10969  BAWGBFreq(0)
10970  BAWGBPhase(0)
10971  BAWGBDutyCycle(0)
10972 
10973  if AWGBFreqvalue > 0.0:
10974  if AWG_2X.get() == 2:
10975  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10976  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10977  else:
10978  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10979  SamplesPermS = int(BaseSampleRate/1000) # 100
10980  else:
10981  AWGBperiodvalue = 0.0
10982  if AWG_Amp_Mode.get() == 1:
10983  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10984  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10985  else:
10986  MaxV = AWGBOffsetvalue
10987  MinV = AWGBAmplvalue
10988  #
10989  if AWGBPhaseDelay.get() == 0:
10990  if AWGBPhasevalue > 0:
10991  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10992  else:
10993  AWGBdelayvalue = 0.0
10994  elif AWGBPhaseDelay.get() == 1:
10995  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
10996  #
10997  AWGBwaveform = []
10998  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10999  if PulseWidth <=0:
11000  PulseWidth = 1
11001  Remainder = int(AWGBperiodvalue - PulseWidth)
11002  if Remainder <= 0:
11003  Remainder = 1
11004  UpStepValue = (MaxV - MinV) / PulseWidth
11005  DownStepValue = (MaxV - MinV) / Remainder
11006  SampleValue = MinV
11007  for i in range(PulseWidth):
11008  AWGBwaveform.append(SampleValue)
11009  SampleValue = SampleValue + UpStepValue
11010  for i in range(Remainder):
11011  AWGBwaveform.append(SampleValue)
11012  SampleValue = SampleValue - DownStepValue
11013  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
11014  if AWGBBurstFlag.get() == 1:
11015  TempOneCycle = AWGBwaveform
11016  for i in range(AWGBCycles-1):
11017  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
11018  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
11019  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
11021  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
11022  BAWGBPhaseDelay()
11023  duty2lab.config(text = "Symmetry")
11024  UpdateAwgCont()
11025 #
11027  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
11028  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
11029  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11030  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
11031  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
11032  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11033 
11034  BAWGBAmpl(0)
11035  BAWGBOffset(0)
11036  BAWGBFreq(0)
11037  BAWGBPhase(0)
11038  BAWGBDutyCycle(0)
11039 
11040  if AWGBFreqvalue > 0.0:
11041  if AWG_2X.get() == 2:
11042  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
11043  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11044  else:
11045  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
11046  SamplesPermS = int(BaseSampleRate/1000) # 100
11047  else:
11048  AWGBperiodvalue = 0.0
11049  if AWG_Amp_Mode.get() == 1:
11050  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
11051  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
11052  else:
11053  MaxV = AWGBOffsetvalue
11054  MinV = AWGBAmplvalue
11055  AWGBwaveform = []
11056  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
11057  if AWGBPhaseDelay.get() == 0:
11058  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
11059  elif AWGBPhaseDelay.get() == 1:
11060  DelayValue = int(AWGBPhasevalue*SamplesPermS)
11061  for i in range(DelayValue-PulseWidth):
11062  AWGBwaveform.append((MinV+MaxV)/2)
11063  for i in range(PulseWidth):
11064  AWGBwaveform.append(MaxV)
11065  for i in range(PulseWidth):
11066  AWGBwaveform.append(MinV)
11067  DelayValue = int(AWGBperiodvalue-DelayValue)
11068  for i in range(DelayValue-PulseWidth):
11069  AWGBwaveform.append((MinV+MaxV)/2)
11070  if AWGBBurstFlag.get() == 1:
11071  TempOneCycle = AWGBwaveform
11072  for i in range(AWGBCycles-1):
11073  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
11074  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
11075  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
11077  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
11078  UpdateAwgCont()
11079 
11081  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
11082  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11083  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
11084  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
11085  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11086 
11087  BAWGBAmpl(0)
11088  BAWGBOffset(0)
11089  BAWGBFreq(0)
11090 
11091  if AWGBFreqvalue > 0.0:
11092  if AWG_2X.get() == 2:
11093  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
11094  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11095  else:
11096  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
11097  SamplesPermS = int(BaseSampleRate/1000) # 100
11098  else:
11099  AWGBperiodvalue = 0.0
11100 
11101  if AWGBAmplvalue > AWGBOffsetvalue:
11102  MinV = AWGBOffsetvalue
11103  MaxV = AWGBAmplvalue
11104  else:
11105  MaxV = AWGBOffsetvalue
11106  MinV = AWGBAmplvalue
11107  if AWG_Amp_Mode.get() == 1:
11108  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
11109  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
11110  AWGBwaveform = []
11111  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
11112  Mid = (MaxV+MinV)/2
11113  if AWGBBurstFlag.get() == 1:
11114  TempOneCycle = AWGBwaveform
11115  for i in range(AWGBCycles-1):
11116  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
11117  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
11118  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11120  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
11121  UpdateAwgCont()
11122 
11124  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
11125  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11126  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
11127  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
11128  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11129 
11130  BAWGBAmpl(0)
11131  BAWGBOffset(0)
11132  BAWGBFreq(0)
11133 
11134  if AWGBFreqvalue > 0.0:
11135  if AWG_2X.get() == 2:
11136  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
11137  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11138  else:
11139  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
11140  SamplesPermS = int(BaseSampleRate/1000) # 100
11141  else:
11142  AWGBperiodvalue = 0.0
11143  if AWGBAmplvalue > AWGBOffsetvalue:
11144  MinV = AWGBOffsetvalue
11145  MaxV = AWGBAmplvalue
11146  else:
11147  MaxV = AWGBOffsetvalue
11148  MinV = AWGBAmplvalue
11149  if AWG_Amp_Mode.get() == 1:
11150  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
11151  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
11152  AWGBwaveform = []
11153  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
11154  Mid = (MaxV+MinV)/2
11155  if AWGBBurstFlag.get() == 1:
11156  TempOneCycle = AWGBwaveform
11157  for i in range(AWGBCycles-1):
11158  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
11159  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
11160  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11162  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
11163  UpdateAwgCont()
11164 
11166  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
11167 
11168  if AWGBMode.get() == 0: # Source Voltage measure current mode
11169  label_txt = "SVMI"
11170  elif AWGBMode.get() == 1: # Source current measure voltage mode
11171  label_txt = "SIMV"
11172  elif AWGBMode.get() == 2: # High impedance mode
11173  label_txt = "Hi-Z"
11174  if AWGBIOMode.get() > 0: # Split Input / Output mode
11175  if HWRevOne == "D":
11176  if AWGBMode.get() == 0:
11177  AWGBMode.set(1)
11178  CHB.set_mode('i') # channel must be in source current mode for rev D boards
11179  label_txt = "SIMV"
11180  label_txt = label_txt + " Split I/O"
11181  label_txt = label_txt + " Mode"
11182  AWGBModeLabel.config(text = label_txt ) # change displayed value
11183  ReMakeAWGwaves()
11184  #UpdateAwgCont()
11185 
11187  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
11188  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
11189  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
11190  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
11191  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
11192  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11193  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag
11194  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11195 
11196  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
11197  amp2lab.config(text = "Min Ch B" ) # change displayed value
11198  off2lab.config(text = "Max Ch B" ) # change displayed value
11199  else:
11200  amp2lab.config(text = "Amp Ch B" )
11201  off2lab.config(text = "Off Ch B" )
11202 #
11203  if AWG_2X.get() == 1:
11204  AWGBWave = 'arbitrary'
11205  if AWGBFreqvalue > 0.0:
11206  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
11207  else:
11208  AWGBperiodvalue = 0.0
11209 #
11210  if AWGBPhaseDelay.get() == 0:
11211  if AWGBWave == 'square':
11212  AWGBPhasevalue = AWGBPhasevalue + 270.0
11213  if AWGBPhasevalue > 359:
11214  AWGBPhasevalue = AWGBPhasevalue - 360
11215  if AWGBPhasevalue > 0:
11216  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
11217  else:
11218  AWGBdelayvalue = 0.0
11219  elif AWGBPhaseDelay.get() == 1:
11220  AWGBdelayvalue = AWGBPhasevalue * 100
11221 #
11222  if AWGBTerm.get() == 0: # Open termination
11223  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
11224  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
11225  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
11226  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
11227  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
11228  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
11229  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
11230  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
11231 
11232  if AWGBWave == 'dc':
11233  if AWG_2X.get() == 1:
11234  AWGBWave == 'arbitrary'
11235  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
11236  else:
11237  if AWGBMode.get() == 0: # Source Voltage measure current mode
11238  if AWGBIOMode.get() == 0:
11239  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
11240  else:
11241  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
11242  CHB.constant(AWGBOffsetvalue)
11243  if AWGBMode.get() == 1: # Source current measure Voltage mode
11244  if AWGBIOMode.get() == 0:
11245  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
11246  else:
11247  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
11248  CHB.constant(AWGBOffsetvalue/1000)
11249  if AWGBMode.get() == 2: # Hi impedance mode
11250  if AWGBIOMode.get() == 0:
11251  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
11252  else:
11253  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
11254 #
11255  if AWGBIOMode.get() > 0: # Split Input / Output mode
11256  if HWRevOne == "D":
11257  AWGBMode.set(1)
11258  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11259 #
11260  else:
11261  if AWGBMode.get() == 0: # Source Voltage measure current mode
11262  if AWGBIOMode.get() == 0:
11263  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
11264  else:
11265  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
11266  if AWGBMode.get() == 1: # Source current measure Voltage mode
11267  if AWGBIOMode.get() == 0:
11268  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
11269  else:
11270  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
11271  AWGBOffsetvalue = AWGBOffsetvalue/1000
11272  AWGBAmplvalue = AWGBAmplvalue/1000
11273  if AWGBMode.get() == 2: # Hi impedance mode
11274  if AWGBIOMode.get() == 0:
11275  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
11276  else:
11277  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
11278  else:
11279  if AWG_Amp_Mode.get() == 1:
11280  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
11281  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
11282  else:
11283  MaxV = AWGBOffsetvalue
11284  MinV = AWGBAmplvalue
11285  try: # keep going even if low level library returns an error
11286  if AWGBWave == 'sine':
11287  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
11288  elif AWGBWave == 'triangle':
11289  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
11290  elif AWGBWave == 'sawtooth':
11291  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
11292  elif AWGBWave == 'square':
11293  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
11294  elif AWGBWave == 'stairstep':
11295  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
11296  elif AWGBWave == 'arbitrary':
11297  if AWGSync.get() == 0:
11298  AWGBRepeatFlag.set(1)
11299  if AWG_2X.get() == 1:
11300  AWGBWave == 'arbitrary'
11301  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
11302  else:
11303  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
11304  except:
11305  donothing()
11306  if AWGBIOMode.get() > 0: # Split Input / Output mode
11307  if HWRevOne == "D":
11308  AWGBMode.set(1)
11309  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11310 #
11312  global session, CHA, CHB, AWGSync
11313  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
11314  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
11315  if session.continuous:
11316  session.end()
11317  BAWGEnab() # set-up new AWG settings
11318  time.sleep(0.01) # wait awhile here for some reason
11319  session.start(0)
11320 #
11322  ReMakeAWGwaves()
11323 
11324 def BAWGEnab():
11325  global AWGAMode, AWGBMode, AWGSync
11326  global CHA, CHB, discontloop, contloop, session
11327 
11328  # Stream = False
11329  # print "Updateing AWGs"
11330  BAWGAAmpl(0)
11331  BAWGAOffset(0)
11332  BAWGAFreq(0)
11333  BAWGAPhase(0)
11334  BAWGADutyCycle(0)
11335  BAWGAShape()
11336  BAWGBAmpl(0)
11337  BAWGBOffset(0)
11338  BAWGBFreq(0)
11339  BAWGBPhase(0)
11340  BAWGBDutyCycle(0)
11341  BAWGBShape()
11342  UpdateAWGA()
11343  UpdateAWGB()
11344 
11345 def BAWGSync():
11346  global RUNstatus, AWGSync, session, CHA, CHB, IAScreenStatus, IADisp
11347 
11348  if (RUNstatus.get() == 1): # do this only if running
11349  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
11350  AWGSync.set(1)
11351  return
11352  if AWGSync.get() == 0:
11353  #UpdateAwgCont()
11354  session.flush()
11355  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
11356  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
11357  BAWGEnab()
11358  session.start(0)
11359  time.sleep(0.02) # wait awhile here for some reason
11360  elif session.continuous:
11361  session.end()
11362  session.flush()
11363  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
11364  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
11365 
11366 # ======= Spectrum Analyzer functions ===========
11367 #
11369  global CANVASwidthF, CANVASheightF, freqwindow
11370  global COLORtext
11371  # ask for file name
11372  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
11373  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
11374  if MarkerNum > 0 or ColorMode.get() > 0:
11375  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
11376  else: # temp change text color to black
11377  COLORtext = "#000000"
11379  # save postscript file
11380  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
11381  #
11382  COLORtext = "#ffffff"
11384 #
11385 def Bnot():
11386  print( "Routine not made yet")
11387 
11389  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
11390  ShowC1_VdB.set(1)
11391  ShowC1_P.set(1)
11392  ShowC2_VdB.set(1)
11393  ShowC2_P.set(1)
11394 
11396  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
11397  ShowC1_VdB.set(0)
11398  ShowC1_P.set(0)
11399  ShowC2_VdB.set(0)
11400  ShowC2_P.set(0)
11401 
11403  global RUNstatus
11404  global FreqTraceMode
11405 
11406  FreqTraceMode.set(1)
11407  if RUNstatus.get() == 0: # Update if stopped
11409  if RUNstatus.get() == 2: # Restart if running
11410  RUNstatus.set(4)
11411 
11413  global RUNstatus
11414  global FreqTraceMode
11415 
11416  FreqTraceMode.set(2)
11417  if RUNstatus.get() == 0: # Update if stopped
11419  if RUNstatus.get() == 2: # Restart if running
11420  RUNstatus.set(4)
11421 
11423  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
11424 
11425  FreqTraceMode.set(3)
11426 
11427  if RUNstatus.get() == 0: # Update if stopped
11429  if RUNstatus.get() == 2: # Restart if running
11430  RUNstatus.set(4)
11431 
11433  global FreqTraceMode, TRACEresetFreq
11434 
11435  if FreqTraceMode.get()==3:
11436  TRACEresetFreq = True
11437 
11439  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
11440  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
11441  global T1Pline, T2Pline, T1PRline, T2PRline
11442  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
11443  global PeakxM, PeakyM, PeakMdb, PeakfreqM
11444  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
11445  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
11446  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
11447 
11448  if ShowC1_VdB.get() == 1:
11449  T1FRline = T1Fline
11450  PeakxRA = PeakxA
11451  PeakyRA = PeakyA
11452  PeakdbRA = PeakdbA
11453  PeakfreqRA = PeakfreqA
11454  if ShowC2_VdB.get() == 1:
11455  T2FRline = T2Fline
11456  PeakxRB = PeakxB
11457  PeakyRB = PeakyB
11458  PeakdbRB = PeakdbB
11459  PeakfreqRB = PeakfreqB
11460  if ShowC1_P.get() == 1:
11461  T1PRline = T1Pline
11462  if ShowC2_P.get() == 1:
11463  T2PRline = T2Pline
11464  if ShowMathSA.get() > 0:
11465  TFRMline = TFMline
11466  PeakxRM = PeakxM
11467  PeakyRM = PeakyM
11468  PeakRMdb = PeakMdb
11469  PeakfreqRM = PeakfreqM
11470 
11471  UpdateFreqTrace() # Always Update
11472 #
11474  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
11475  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
11476  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
11477  global TAPline, TBPline, TAPRline, TBPRline
11478  global TIARline, TIAXline, TIAMagline, TIAAngline
11479  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
11480  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
11481  global PeakxM, PeakyM, PeakMdb, PeakfreqM
11482  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
11483  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
11484  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
11485 
11486  if ShowCA_VdB.get() == 1:
11487  TAFRline = TAFline
11488  PeakxRA = PeakxA
11489  PeakyRA = PeakyA
11490  PeakdbRA = PeakdbA
11491  PeakfreqRA = PeakfreqA
11492  if ShowCB_VdB.get() == 1:
11493  TBFRline = TBFline
11494  PeakxRB = PeakxB
11495  PeakyRB = PeakyB
11496  PeakdbRB = PeakdbB
11497  PeakfreqRB = PeakfreqB
11498  if ShowCA_P.get() == 1:
11499  TAPRline = TAPline
11500  if ShowCB_P.get() == 1:
11501  TBPRline = TBPline
11502  if ShowMathBP.get() > 0:
11503  TBPRMline = TBPMline
11504  PeakxRM = PeakxM
11505  PeakyRM = PeakyM
11506  PeakRMdb = PeakMdb
11507  PeakfreqRM = PeakfreqM
11508  if Show_Rseries.get() > 0:
11509  RefIARline = TIARline
11510  if Show_Xseries.get() > 0:
11511  RefIAXline = TIAXline
11512  if Show_Magnitude.get() > 0:
11513  RefIAMagline = TIAMagline
11514  if Show_Angle.get() > 0:
11515  RefIAAngline = TIAAngline
11516  UpdateBodeTrace() # Always Update
11517 #
11518 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
11519  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
11520  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11521 
11522  # Set the TRACEsize variable
11523  if ShowCA_VdB.get() == 1:
11524  TRACEsize = len(FSweepAdB) # Set the trace length
11525  elif ShowCA_VdB.get() == 1:
11526  TRACEsize = len(FSweepBdB)
11527  if TRACEsize == 0: # If no trace, skip rest of this routine
11528  return()
11529 # ask if save as magnitude or dB
11530  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
11531 # Yes 1 = dB, No 0 = Mag
11532  # Make the file name and open it
11533  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
11534  filename = "Bode-" + tme
11535  filename = filename + ".csv"
11536  # open file to save data
11537  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
11538  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
11539  DataFile = open(filename,'a') # Open output file
11540  HeaderString = 'Frequency-#, '
11541  if ShowCA_VdB.get() == 1:
11542  if dB == 1:
11543  HeaderString = HeaderString + 'CA-dB, '
11544  if dB == 0:
11545  HeaderString = HeaderString + 'CA-Mag, '
11546  if ShowCB_VdB.get() == 1:
11547  if dB == 1:
11548  HeaderString = HeaderString + 'CB-dB, '
11549  if dB == 0:
11550  HeaderString = HeaderString + 'CB-Mag, '
11551  if ShowCA_P.get() == 1:
11552  HeaderString = HeaderString + 'Phase A-B, '
11553  if ShowCB_P.get() == 1:
11554  HeaderString = HeaderString + 'Phase B-A, '
11555  HeaderString = HeaderString + '\n'
11556  DataFile.write( HeaderString )
11557 
11558  n = 0
11559  while n < len(FSweepAdB):
11560  F = FBins[FStep[n]] # look up frequency bin in list of bins
11561  txt = str(F)
11562  if ShowCA_VdB.get() == 1:
11563  V = 10 * math.log10(float(FSweepAdB[n])) + 17 # Add 17 dB for max value of +10 dB
11564  if dB == 0:
11565  V = 10.0**(V/20.0)
11566  txt = txt + "," + str(V)
11567  if ShowCB_VdB.get() == 1:
11568  V = 10 * math.log10(float(FSweepBdB[n])) + 17 # Add 17 dB for max value of +10 dB
11569  if dB == 0:
11570  V = 10.0**(V/20.0)
11571  txt = txt + "," + str(V)
11572  if ShowCA_P.get() == 1:
11573  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
11574  if RelPhase > 180:
11575  RelPhase = RelPhase - 360
11576  elif RelPhase < -180:
11577  RelPhase = RelPhase + 360
11578  txt = txt + "," + str(RelPhase)
11579  if ShowCB_P.get() == 1:
11580  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
11581  if RelPhase > 180:
11582  RelPhase = RelPhase - 360
11583  elif RelPhase < -180:
11584  RelPhase = RelPhase + 360
11585  txt = txt + "," + str(RelPhase)
11586  txt = txt + "\n"
11587  DataFile.write(txt)
11588  n = n + 1
11589 
11590  DataFile.close() # Close the file
11591 
11593  global iawindow, FStep, FBins
11594  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
11595 
11596  if NetworkScreenStatus.get() > 0:
11597  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
11598  filename = "Impedance-" + tme
11599  filename = filename + ".csv"
11600  # open file to save data
11601  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
11602  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
11603  DataFile = open(filename,'a') # Open output file
11604  HeaderString = 'Frequency, Series R, Seriec X, Series Z, Series Angle'
11605  HeaderString = HeaderString + '\n'
11606  DataFile.write( HeaderString )
11607 
11608  n = 0
11609  while n < len(NSweepSeriesR):
11610  F = FBins[FStep[n]] # look up frequency bin in list of bins
11611  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
11612  txt = txt + "\n"
11613  DataFile.write(txt)
11614  n = n + 1
11615  DataFile.close() # Close the file
11616  else:
11617  return
11618 #
11619 def BStartSA():
11620  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
11621  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
11622  global Two_X_Sample, ADC_Mux_Mode
11623 
11624  #AWGSync.set(0) # always run in continuous mode
11625  if DevID == "No Device":
11626  showwarning("WARNING","No Device Plugged In!")
11627  elif FWRevOne == 0.0:
11628  showwarning("WARNING","Out of data Firmware!")
11629  else:
11630  if PowerStatus == 0:
11631  PowerStatus = 1
11632  PwrBt.config(style="Pwr.TButton",text="PWR-On")
11633  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
11634 
11635  if ShowC1_VdB.get() == 0 and ShowC2_VdB.get() == 0 and ShowMathSA.get() == 0 and ShowC1_P.get() == 0 and ShowC2_P.get() == 0:
11636  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
11637  return()
11638  try:
11639  StopFrequency = float(StopFreqEntry.get())
11640  except:
11641  StopFreqEntry.delete(0,"end")
11642  StopFreqEntry.insert(0,50000)
11643  StopFrequency = 50000
11644  if FWRevOne > 2.16:
11645  if StopFrequency >= 50000:
11646  Two_X_Sample.set(1)
11647  else:
11648  Two_X_Sample.set(0)
11649  ADC_Mux_Mode.set(0)
11650  SetADC_Mux()
11651  #
11652  BStart()
11653 #
11654  UpdateFreqAll() # Always Update
11655 
11656 def BStopSA():
11657  global RUNstatus, session, AWGSync
11658 
11659  if (RUNstatus.get() == 1):
11660  RUNstatus.set(0)
11661  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11662  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
11663  if AWGSync.get() == 0: # running in continuous mode
11664  CHA.constant(0.0)
11665  CHB.constant(0.0)
11666  # print "Stoping continuous mode"
11667  if session.continuous:
11668  # print "Stoping Is Continuous? ", session.continuous
11669  time.sleep(0.02)
11670  #print "Is Continuous? ", session.continuous
11671  else:
11672  contloop = 0
11673  discontloop = 1
11674  session.cancel()
11675  elif (RUNstatus.get() == 2):
11676  RUNstatus.set(3)
11677  elif (RUNstatus.get() == 3):
11678  RUNstatus.set(3)
11679  elif (RUNstatus.get() == 4):
11680  RUNstatus.set(3)
11681  UpdateFreqAll() # Always Update
11682 
11683 def Blevel1():
11684  global DBlevel
11685  global RUNstatus
11686 
11687  DBlevel.set(DBlevel.get() - 1)
11688 
11689  if RUNstatus.get() == 0: # Update if stopped
11690  UpdateFreqTrace()
11691 
11692 def Blevel2():
11693  global DBlevel
11694  global RUNstatus
11695 
11696  DBlevel.set(DBlevel.get() + 1)
11697 
11698  if RUNstatus.get() == 0: # Update if stopped
11699  UpdateFreqTrace()
11700 
11701 def Blevel3():
11702  global DBlevel
11703  global RUNstatus
11704 
11705  DBlevel.set(DBlevel.get() - 10)
11706 
11707  if RUNstatus.get() == 0: # Update if stopped
11708  UpdateFreqTrace()
11709 
11710 def Blevel4():
11711  global DBlevel
11712  global RUNstatus
11713 
11714  DBlevel.set(DBlevel.get() + 10)
11715 
11716  if RUNstatus.get() == 0: # Update if stopped
11717  UpdateFreqTrace()
11718 #
11720  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
11721  global SMPfftpwrTwo, SMPfft, FFTwindow
11722  global TRACEresetFreq, PhAScreenStatus
11723 
11724  if FFTwindow.get() != 8:
11725  if (SMPfftpwrTwo.get() > 6): # Min 64
11726  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
11727  TRACEresetFreq = True # Reset trace peak and trace average
11728  SMPfft = 2 ** int(SMPfftpwrTwo.get())
11729 
11730  if RUNstatus.get() == 0: # Update if stopped
11731  if SpectrumScreenStatus.get() > 0:
11733  if IAScreenStatus.get() > 0:
11734  UpdateIAScreen()
11735  if PhAScreenStatus.get() > 0:
11736  UpdatePhAScreen()
11737  if RUNstatus.get() == 2: # Restart if running
11738  RUNstatus.set(4)
11739 
11741  global RUNstatus, PhAScreenStatus
11742  global SMPfftpwrTwo, SMPfft, FFTwindow
11743  global TRACEresetFreq, SpectrumScreenStatus, IAScreenStatus
11744 
11745  if FFTwindow.get() != 8:
11746  if (SMPfftpwrTwo.get() < 16): # Max 65536
11747  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
11748  TRACEresetFREQ = True # Reset trace peak and trace average
11749  SMPfft = 2 ** int(SMPfftpwrTwo.get())
11750 
11751  if RUNstatus.get() == 0: # Update if stopped
11752  if SpectrumScreenStatus.get() > 0:
11754  if IAScreenStatus.get() > 0:
11755  UpdateIAScreen()
11756  if PhAScreenStatus.get() > 0:
11757  UpdatePhAScreen()
11758  if RUNstatus.get() == 2: # Restart if running
11759  RUNstatus.set(4)
11760 
11761 def BDBdiv1():
11762  global DBdivindex
11763  global RUNstatus
11764 
11765  if (DBdivindex.get() >= 1):
11766  DBdivindex.set(DBdivindex.get() - 1)
11767 
11768  if RUNstatus.get() == 0: # Update if stopped
11769  UpdateFreqTrace()
11770 
11771 def BDBdiv2():
11772  global DBdivindex
11773  global DBdivlist
11774  global RUNstatus
11775 
11776  if (DBdivindex.get() < len(DBdivlist) - 1):
11777  DBdivindex.set(DBdivindex.get() + 1)
11778 
11779  if RUNstatus.get() == 0: # Update if stopped
11780  UpdateFreqTrace()
11781 #----- Bode Plot controls
11782 def BStartBP():
11783  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
11784  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
11785  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
11786  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
11787  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
11788  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
11789  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
11790  global BeginIndex, EndIndex
11791 
11792  if DevID == "No Device":
11793  showwarning("WARNING","No Device Plugged In!")
11794  elif FWRevOne == 0.0:
11795  showwarning("WARNING","Out of data Firmware!")
11796  else:
11797  if PowerStatus == 0:
11798  PowerStatus = 1
11799  PwrBt.config(style="Pwr.TButton",text="PWR-On")
11800  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
11801 
11802  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
11803  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
11804  return()
11805  #
11806  if ZEROstuffing.get() < 3:
11807  ZEROstuffing.set(3)
11808  CutDC.set(1) # set to remove DC
11809  try:
11810  EndFreq = float(StopBodeEntry.get())
11811  except:
11812  StopBodeEntry.delete(0,"end")
11813  StopBodeEntry.insert(0,10000)
11814  EndFreq = 10000
11815  if FWRevOne > 2.16:
11816  if EndFreq >= 20000:
11817  Two_X_Sample.set(1)
11818  FBins = numpy.linspace(0, 100000, num=16384)
11819  else:
11820  Two_X_Sample.set(0)
11821  FBins = numpy.linspace(0, 50000, num=16384)
11822  ADC_Mux_Mode.set(0)
11823  SetADC_Mux()
11824  try:
11825  BeginFreq = float(StartBodeEntry.get())
11826  except:
11827  StartBodeEntry.delete(0,"end")
11828  StartBodeEntry.insert(0,100)
11829  BeginFreq = 100
11830  #
11831  if FSweepMode.get() == 1:
11832  if AWGAMode.get() == 2:
11833  AWGAMode.set(0) # Set AWG A to SVMI
11834  AWGAShape.set(18) # Set Shape to Sine
11835  if Two_X_Sample.get() == 1:
11836  AWGBIOMode.set(1)
11837  AWGBMode.set(0)
11838  else:
11839  AWGBMode.set(2) # Set AWG B to Hi-Z
11840  AWG_2X.set(0)
11841  BAWG2X()
11842  Reset_Freq = AWGAFreqEntry.get()
11843  if FSweepMode.get() == 2:
11844  if AWGBMode.get() == 2:
11845  AWGBMode.set(0) # Set AWG B to SVMI
11846  AWGBShape.set(18) # Set Shape to Sine
11847  if Two_X_Sample.get() == 1:
11848  AWGAIOMode.set(1)
11849  AWGAMode.set(0)
11850  else:
11851  AWGAMode.set(2) # Set AWG A to Hi-Z
11852  AWG_2X.set(0)
11853  BAWG2X()
11854  Reset_Freq = AWGBFreqEntry.get()
11855  if FSweepMode.get() == 3: # using external Minigen
11856  AWGAMode.set(2) # Set AWG A to Hi-Z
11857  AWGBMode.set(2) # Set AWG B to Hi-Z
11858  try:
11859  NSteps.set(float(SweepStepBodeEntry.get()))
11860  except:
11861  SweepStepBodeEntry.delete(0,"end")
11862  SweepStepBodeEntry.insert(0, NSteps.get())
11863  #
11864  if FSweepMode.get() > 0:
11865  BAWGAModeLabel() # make sure AWG screen labels reflect any changes to the modes
11866  BAWGBModeLabel()
11867  LoopNum.set(1)
11868  NyquistFreq = SAMPLErate/2
11869  BeginIndex = int((BeginFreq/NyquistFreq)*16384)
11870  EndIndex = int((EndFreq/NyquistFreq)*16384)
11871  if NSteps.get() < 5:
11872  NSteps.set(5)
11873  if HScaleBP.get() == 1:
11874  LogFStop = math.log10(EndIndex)
11875  try:
11876  LogFStart = math.log10(BeginIndex)
11877  except:
11878  LogFStart = 1.0
11879  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
11880  else:
11881  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
11882  BStart()
11883  # UpdateBodeAll() # Always Update
11884 #
11885 def BStopBP():
11886  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
11887 
11888  if FSweepMode.get() == 1:
11889  AWGAFreqEntry.delete(0,"end")
11890  AWGAFreqEntry.insert(0, Reset_Freq)
11891  if FSweepMode.get() == 2:
11892  AWGBFreqEntry.delete(0,"end")
11893  AWGBFreqEntry.insert(0, Reset_Freq)
11894 #
11895  if (RUNstatus.get() == 1):
11896  RUNstatus.set(0)
11897  if AWGSync.get() == 0: # running in continuous mode
11898  session.cancel() # cancel continuous session mode while paused
11899  elif (RUNstatus.get() == 2):
11900  RUNstatus.set(3)
11901  elif (RUNstatus.get() == 3):
11902  RUNstatus.set(3)
11903  elif (RUNstatus.get() == 4):
11904  RUNstatus.set(3)
11905  UpdateBodeAll() # Always Update
11906 #
11908  global DBlevelBP
11909  global RUNstatus
11910 
11911  DBlevelBP.set(DBlevelBP.get() - 1)
11912 
11913  if RUNstatus.get() == 0: # Update if stopped
11914  UpdateBodeTrace()
11915 
11917  global DBlevelBP
11918  global RUNstatus
11919 
11920  DBlevelBP.set(DBlevelBP.get() + 1)
11921 
11922  if RUNstatus.get() == 0: # Update if stopped
11923  UpdateBodeTrace()
11924 
11926  global DBlevelBP
11927  global RUNstatus
11928 
11929  DBlevelBP.set(DBlevelBP.get() - 10)
11930 
11931  if RUNstatus.get() == 0: # Update if stopped
11932  UpdateBodeTrace()
11933 
11935  global DBlevelBP
11936  global RUNstatus
11937 
11938  DBlevelBP.set(DBlevelBP.get() + 10)
11939 
11940  if RUNstatus.get() == 0: # Update if stopped
11941  UpdateBodeTrace()
11942 
11944  global DBdivindexBP
11945  global RUNstatus
11946 
11947  if (DBdivindexBP.get() >= 1):
11948  DBdivindexBP.set(DBdivindexBP.get() - 1)
11949 
11950  if RUNstatus.get() == 0: # Update if stopped
11951  UpdateBodeTrace()
11952 
11954  global DBdivindexBP
11955  global DBdivlist
11956  global RUNstatus
11957 
11958  if (DBdivindexBP.get() < len(DBdivlist) - 1):
11959  DBdivindexBP.set(DBdivindexBP.get() + 1)
11960 
11961  if RUNstatus.get() == 0: # Update if stopped
11962  UpdateBodeTrace()
11963 #
11965  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11966  ShowCA_VdB.set(1)
11967  ShowCA_P.set(1)
11968  ShowCB_VdB.set(1)
11969  ShowCB_P.set(1)
11970 
11972  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11973  ShowCA_VdB.set(0)
11974  ShowCA_P.set(0)
11975  ShowCB_VdB.set(0)
11976  ShowCB_P.set(0)
11977 # Bode Plot refresh
11978 def UpdateBodeAll(): # Update Data, trace and screen
11979  global FFTBuffA, FFTBuffB
11980  global SMPfft
11981 
11982  # DoFFT() # Fast Fourier transformation
11983  MakeBodeTrace() # Update the traces
11984  UpdateBodeScreen() # Update the screen
11985 
11986 def UpdateBodeTrace(): # Update trace and screen
11987  MakeBodeTrace() # Update traces
11988  UpdateBodeScreen() # Update the screen
11989 
11990 def UpdateBodeScreen(): # Update screen with trace and text
11991  MakeBodeScreen() # Update the screen
11992 
11993 # ============================================ Freq Main routine ====================================================
11994 
11995 def UpdateFreqAll(): # Update Data, trace and screen
11996  global FFTBuffA, FFTBuffB
11997  global SMPfft
11998 
11999  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
12000  return
12001 
12002  # DoFFT() # Fast Fourier transformation
12003  MakeFreqTrace() # Update the traces
12004  UpdateFreqScreen() # Update the screen
12005 
12006 def UpdateFreqTrace(): # Update trace and screen
12007  MakeFreqTrace() # Update traces
12008  UpdateFreqScreen() # Update the screen
12009 
12010 def UpdateFreqScreen(): # Update screen with trace and text
12011  MakeFreqScreen() # Update the screen
12012 
12013 def DoFFT(): # Fast Fourier transformation
12014  global FFTBuffA, FFTBuffB
12015  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
12016  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
12017  global FFTmemoryB, FFTresultB
12018  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
12019  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
12020  global FFTwindowshape, FFTbandwidth
12021  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
12022  global SMPfft, LoopNum, IA_Ext_Conf
12023  global STARTsample, STOPsample
12024  global TRACEaverage, FreqTraceMode, FSweepMode
12025  global TRACEresetFreq, ZEROstuffing
12026  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
12027  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
12028 
12029  # T1 = time.time() # For time measurement of FFT routine
12030  REX = []
12031  PhaseA = []
12032  PhaseB = []
12033  # Convert list to numpy array REX for faster Numpy calculations
12034  # Take the first fft samples
12035  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
12036 
12037  # Set Analog level display value MAX value is 5 volts for ALM1000
12038  REX = REX / 5.0
12039 
12040  # Do the FFT window function
12041  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
12042 
12043  # Zero stuffing of array for better interpolation of peak level of signals
12044  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
12045  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
12046 
12047  # Save previous trace in memory for max or average trace
12048  FFTmemoryA = FFTresultA
12049  if FreqTraceMode.get() == 3:
12050  PhaseMemoryA = PhaseA
12051 
12052  # FFT with numpy
12053  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
12054  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
12055  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
12056  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
12057 
12058  le = int(len(ALL) / 2) # Only half is used, other half is mirror
12059  ALL = ALL[0:le] # So take only first half of the array
12060  PhaseA = PhaseA[0:le]
12061  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
12062  Totalcorr = Totalcorr * Totalcorr # For POWER!
12063  FFTresultA = Totalcorr * ALL
12064 #
12065  REX = []
12066  # Convert list to numpy array REX for faster Numpy calculations
12067  # Take the first fft samples
12068  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
12069 
12070  # Set level display value MAX value is 5 volts for ALM1000
12071  REX = REX / 5.0
12072 
12073  # Do the FFT window function
12074  try:
12075  REX = REX * FFTwindowshape # The windowing shape function only over the samples
12076  except:
12077  return
12078  # Zero stuffing of array for better interpolation of peak level of signals
12079  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
12080  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
12081 
12082  # Save previous trace in memory for max or average trace
12083  FFTmemoryB = FFTresultB
12084  if FreqTraceMode.get() == 3:
12085  PhaseMemoryB = PhaseB
12086  # FFT with numpy
12087  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
12088  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
12089  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
12090  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
12091 
12092  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
12093  ALL = ALL[0:le] # So take only first half of the array
12094  PhaseB = PhaseB[0:le]
12095  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
12096  Totalcorr = Totalcorr * Totalcorr # For POWER!
12097  FFTresultB = Totalcorr * ALL
12098 #
12099  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
12100  REX = []
12101  PhaseAB = []
12102  # Convert list to numpy array REX for faster Numpy calculations
12103  # Take the first fft samples
12104  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
12105 
12106  # Set level display value MAX value is 5 volts for ALM1000
12107  REX = REX / 5.0
12108 
12109  # Do the FFT window function
12110  REX = REX * FFTwindowshape # The windowing shape function only over the samples
12111 
12112  # Zero stuffing of array for better interpolation of peak level of signals
12113  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
12114  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
12115 
12116  # Save previous trace in memory for max or average trace
12117  # FFTmemoryB = FFTresultB
12118  # if FreqTraceMode.get() == 3:
12119  # PhaseMemoryB = PhaseB
12120  # FFT with numpy
12121  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
12122  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
12123  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
12124  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
12125 
12126  le = len(ALL) / 2 # Only half is used, other half is mirror
12127  ALL = ALL[:le] # So take only first half of the array
12128  PhaseAB = PhaseAB[:le]
12129  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
12130  Totalcorr = Totalcorr * Totalcorr # For POWER!
12131  FFTresultAB = Totalcorr * ALL
12132 #
12133  TRACEsize = int(len(FFTresultB))
12134  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
12135  if SpectrumScreenStatus.get() > 0:
12136  try:
12137  StartFrequency = float(StartFreqEntry.get())
12138  except:
12139  StartFreqEntry.delete(0,"end")
12140  StartFreqEntry.insert(0,100)
12141  StartFrequency = 100
12142  STARTsample = int(StartFrequency / Fsample)
12143  else:
12144  STARTsample = 0
12145  if LoopNum.get() == 1:
12146  PhaseMemoryB = PhaseB
12147  FSweepAdB = []
12148  FSweepBdB = []
12149  FSweepAPh = []
12150  FSweepBPh = []
12151  if NetworkScreenStatus.get() > 0:
12152  NSweepSeriesR = []
12153  NSweepSeriesX = []
12154  NSweepSeriesMag = [] # in ohms
12155  NSweepSeriesAng = [] # in degrees
12156  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
12157  if FSweepMode.get() == 1:
12158  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
12159  if ptmax > STARTsample:
12160  STARTsample = ptmax
12161  i = 0
12162  while i < 6:
12163  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
12164  i = i + 1
12165  if FSweepMode.get() == 2:
12166  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
12167  if ptmax > STARTsample:
12168  STARTsample = ptmax
12169  i = 0
12170  while i < 6:
12171  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
12172  i = i + 1
12173 
12174  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
12175  if FSweepMode.get() == 1:
12176  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
12177  if ptmax > STARTsample:
12178  STARTsample = ptmax
12179  i = 0
12180  while i < 6:
12181  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
12182  i = i + 1
12183  if FSweepMode.get() == 2:
12184  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
12185  if ptmax > STARTsample:
12186  STARTsample = ptmax
12187  i = 0
12188  while i < 6:
12189  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
12190  i = i + 1
12191  if len(FFTresultB) == len(FFTmemoryB):
12192  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
12193  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
12194  try:
12195  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
12196  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
12197  except:
12198  FFTmemoryB = FFTresultB
12199  PhaseMemoryB = PhaseB
12200 #
12201  TRACEsize = int(len(FFTresultA))
12202  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
12203  if SpectrumScreenStatus.get() > 0:
12204  STARTsample = int(StartFrequency / Fsample)
12205  else:
12206  STARTsample = 0
12207  if LoopNum.get() == 1:
12208  PhaseMemoryA = PhaseA
12209  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
12210  if FSweepMode.get() == 1:
12211  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
12212  if ptmax > STARTsample:
12213  STARTsample = ptmax
12214  i = 0
12215  while i < 6:
12216  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
12217  i = i + 1
12218  if FSweepMode.get() == 2:
12219  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
12220  if ptmax > STARTsample:
12221  STARTsample = ptmax
12222  i = 0
12223  while i < 6:
12224  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
12225  i = i + 1
12226 
12227  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
12228  if FSweepMode.get() == 1:
12229  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
12230  if ptmax > STARTsample:
12231  STARTsample = ptmax
12232  i = 0
12233  while i < 6:
12234  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
12235  i = i + 1
12236  if FSweepMode.get() == 2:
12237  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
12238  if ptmax > STARTsample:
12239  STARTsample = ptmax
12240  i = 0
12241  while i < 6:
12242  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
12243  i = i + 1
12244 #
12245  if len(FFTresultA) == len(FFTmemoryA):
12246  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
12247  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
12248  try:
12249  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
12250  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
12251  except:
12252  FFTmemoryA = FFTresultA
12253  PhaseMemoryA = PhaseA
12254 #
12255  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
12256  FSweepAdB.append(numpy.amax(FFTresultA))
12257  FSweepBdB.append(numpy.amax(FFTresultB))
12258  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
12259  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
12260 
12261  TRACEresetFreq = False # Trace reset done
12262 
12263 def MakeFreqTrace(): # Update the grid and trace
12264  global FFTmemoryA, FFTresultA
12265  global FFTmemoryB, FFTresultB
12266  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
12267  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
12268  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
12269  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12270  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
12271  global PeakfreqA, PeakfreqB, Two_X_Sample
12272  global DBdivindex # Index value
12273  global DBdivlist # dB per division list
12274  global DBlevel # Reference level
12275  global GRHF,GRWF # Screenheight, Screenwidth
12276  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
12277  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
12278  global STARTsample, STOPsample, LoopNum, FSweepMode
12279  global FreqTraceMode
12280  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline
12281  global Vdiv # Number of vertical divisions
12282  global X0LF, Y0TF # Left top X value, Left top Y value
12283 
12284  # Set the TRACEsize variable
12285  TRACEsize = 0
12286  try:
12287  StartFrequency = float(StartFreqEntry.get())
12288  except:
12289  StartFreqEntry.delete(0,"end")
12290  StartFreqEntry.insert(0,100)
12291  StartFrequency = 100
12292  try:
12293  StopFrequency = float(StopFreqEntry.get())
12294  except:
12295  StopFreqEntry.delete(0,"end")
12296  StopFreqEntry.insert(0,50000)
12297  StopFrequency = 50000
12298  if StartFrequency > StopFrequency :
12299  StopFreqEntry.delete(0,"end")
12300  StopFreqEntry.insert(0,50000)
12301  StopFrequency = 50000
12302  if StopFrequency < StartFrequency :
12303  StopFreqEntry.delete(0,"end")
12304  StopFreqEntry.insert(0,50000)
12305  StopFrequency = 50000
12306  try:
12307  Phasecenter = int(PhCenFreqEntry.get())
12308  RelPhaseCenter.set(Phasecenter)
12309  except:
12310  PhCenFreqEntry.delete(0,"end")
12311  PhCenFreqEntry.insert(0,0)
12312  RelPhaseCenter.set(0)
12313  Phasecenter = 0
12314  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
12315  TRACEsize = len(FFTresultA) # Set the trace length
12316  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
12317  TRACEsize = len(FFTresultB)
12318  if TRACEsize == 0: # If no trace, skip rest of this routine
12319  return()
12320  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
12321  PhaseA = PhaseMemoryA
12322  PhaseB = PhaseMemoryB
12323  # Vertical conversion factors (level dBs) and border limits
12324  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
12325  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
12326  Ymin = Y0TF # Minimum position of screen grid (top)
12327  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
12328  Yphconv = float(GRHF) / 360
12329  Yp = float(Y0TF) + Yphconv + 180
12330  # Horizontal conversion factors (frequency Hz) and border limits
12331  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
12332  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
12333  LogFStop = math.log10(StopFrequency)
12334  try:
12335  LogFStart = math.log10(StartFrequency)
12336  except:
12337  LogFStart = 0.0
12338  LogFpixel = (LogFStop - LogFStart) / GRWF
12339  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
12340  STARTsample = int(math.ceil(STARTsample)) # First within screen range
12341 
12342  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
12343  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
12344 
12345  MAXsample = TRACEsize # Just an out of range check
12346  if STARTsample > (MAXsample - 1):
12347  STARTsample = MAXsample - 1
12348 
12349  if STOPsample > MAXsample:
12350  STOPsample = MAXsample
12351 
12352  T1Fline = []
12353  T2Fline = []
12354  T1Pline = []
12355  T2Pline = []
12356  TFMline = []
12357  n = STARTsample
12358  PeakIndexA = PeakIndexB = n
12359  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
12360  while n <= STOPsample:
12361  F = n * Fsample
12362  if HScale.get() == 1:
12363  try:
12364  LogF = math.log10(F) # convet to log Freq
12365  x = X0LF + (LogF - LogFStart)/LogFpixel
12366  except:
12367  x = X0LF
12368  else:
12369  x = X0LF + (F - StartFrequency) / Fpixel
12370  if ShowC1_VdB.get() == 1:
12371  T1Fline.append(int(x + 0.5))
12372  try:
12373  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
12374  ya = Yc - Yconv * dbA # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12375  except:
12376  ya = Ymax
12377  if (ya < Ymin):
12378  ya = Ymin
12379  if (ya > Ymax):
12380  ya = Ymax
12381  if dbA > PeakdbA:
12382  PeakdbA = dbA
12383  PeakyA = int(ya + 0.5)
12384  PeakxA = int(x + 0.5)
12385  PeakfreqA = F
12386  PeakIndexA = n
12387  T1Fline.append(int(ya + 0.5))
12388  if ShowC2_VdB.get() == 1:
12389  T2Fline.append(int(x + 0.5))
12390  try:
12391  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12392  yb = Yc - Yconv * dbB
12393  except:
12394  yb = Ymax
12395  if (yb < Ymin):
12396  yb = Ymin
12397  if (yb > Ymax):
12398  yb = Ymax
12399  if dbB > PeakdbB:
12400  PeakdbB = dbB
12401  PeakyB = int(yb + 0.5)
12402  PeakxB = int(x + 0.5)
12403  PeakfreqB = F
12404  PeakIndexB = n
12405  T2Fline.append(int(yb + 0.5))
12406  if ShowC1_P.get() == 1:
12407  T1Pline.append(int(x + 0.5))
12408  if FSweepMode.get() > 0:
12409  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
12410  else:
12411  RelPhase = PhaseA[n]-PhaseB[n]
12412  RelPhase = RelPhase - Phasecenter
12413  if RelPhase > 180:
12414  RelPhase = RelPhase - 360
12415  elif RelPhase < -180:
12416  RelPhase = RelPhase + 360
12417  if Two_X_Sample.get() == 0:
12418  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
12419  RelPhase = RelPhase + PhErr - 12.0
12420  else:
12421  RelPhase = RelPhase - 9.0
12422  ya = Yp - Yphconv * RelPhase
12423  T1Pline.append(int(ya + 0.5))
12424  if ShowC2_P.get() == 1:
12425  T2Pline.append(int(x + 0.5))
12426  if FSweepMode.get() > 0:
12427  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
12428  else:
12429  RelPhase = PhaseB[n]-PhaseA[n]
12430  RelPhase = RelPhase - Phasecenter
12431  if RelPhase > 180:
12432  RelPhase = RelPhase - 360
12433  elif RelPhase < -180:
12434  RelPhase = RelPhase + 360
12435  if Two_X_Sample.get() == 0:
12436  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
12437  RelPhase = RelPhase - PhErr - 12.0
12438  else:
12439  RelPhase = RelPhase - 9.0
12440  ya = Yp - Yphconv * RelPhase
12441  T2Pline.append(int(ya + 0.5))
12442  if ShowMathSA.get() > 0:
12443  TFMline.append(int(x + 0.5))
12444  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
12445  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12446  if ShowMathSA.get() == 1:
12447  MdB = dbA - dbB
12448  elif ShowMathSA.get() == 2:
12449  MdB = dbB - dbA
12450  yb = Yc - Yconv * MdB
12451  if (yb < Ymin):
12452  yb = Ymin
12453  if (yb > Ymax):
12454  yb = Ymax
12455  if MdB > PeakMdb:
12456  PeakMdb = MdB
12457  PeakyM = int(yb + 0.5)
12458  PeakxM = int(x + 0.5)
12459  PeakfreqM = F
12460  TFMline.append(int(yb + 0.5))
12461  n = n + 1
12462 # make Bode Plot Traces
12463 def MakeBodeTrace(): # Update the grid and trace
12464  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
12465  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
12466  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12467  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12468  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
12469  global DBdivindexBP # Index value
12470  global DBdivlist # dB per division list
12471  global DBlevelBP # Reference level
12472  global GRHBP # Screenheight
12473  global GRWBP # Screenwidth
12474  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
12475  global StartBodeEntry, StopBodeEntry
12476  global STARTsample, STOPsample, LoopNum, FSweepMode
12477  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
12478  global TAFline, TBFline, TBPMline, TAPline, TBPline
12479  global Vdiv # Number of vertical divisions
12480  global X0LBP # Left top X value
12481  global Y0TBP # Left top Y value
12482  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
12483  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
12484  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
12485 
12486  # Set the TRACEsize variable
12487  TRACEsize = 0
12488  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
12489  TRACEsize = len(FStep) # Set the trace length
12490  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
12491  TRACEsize = len(FStep)
12492  if TRACEsize == 0: # If no trace, skip rest of this routine
12493  return()
12494  #
12495  try:
12496  EndFreq = float(StopBodeEntry.get())
12497  except:
12498  StopBodeEntry.delete(0,"end")
12499  StopBodeEntry.insert(0,10000)
12500  EndFreq = 10000
12501  try:
12502  BeginFreq = float(StartBodeEntry.get())
12503  except:
12504  StartBodeEntry.delete(0,"end")
12505  StartBodeEntry.insert(0,100)
12506  BeginFreq = 100
12507  try:
12508  Phasecenter = int(PhCenBodeEntry.get())
12509  RelPhaseCenter.set(Phasecenter)
12510  except:
12511  PhCenBodeEntry.delete(0,"end")
12512  PhCenBodeEntry.insert(0,0)
12513  RelPhaseCenter.set(0)
12514  Phasecenter = 0
12515  try:
12516  Impedcenter = int(ImCenBodeEntry.get())
12517  ImpedanceCenter.set(Impedcenter)
12518  except:
12519  ImCenBodeEntry.delete(0,"end")
12520  ImCenBodeEntry.insert(0,0)
12521  ImpedanceCenter.set(0)
12522  Impedcenter = 0
12523  #
12524  HalfSAMPLErate = SAMPLErate/2
12525  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
12526  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
12527  CurrentFreqX = X0LBP + 14
12528  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
12529  # Vertical conversion factors (level dBs) and border limits
12530  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
12531  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
12532  Ymin = Y0TBP # Minimum position of screen grid (top)
12533  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
12534  Yphconv = float(GRHBP) / 360 # degrees per pixel
12535  Yp = float(Y0TBP) + Yphconv + 180
12536  x1 = X0LBP + 14
12537  # Horizontal conversion factors (frequency Hz) and border limits
12538  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
12539  LogFStop = math.log10(EndFreq)
12540  try:
12541  LogFStart = math.log10(BeginFreq)
12542  except:
12543  LogFStart = 0.0
12544  LogFpixel = (LogFStop - LogFStart) / GRWBP
12545  TAFline = []
12546  TBFline = []
12547  TAPline = []
12548  TBPline = []
12549  TIARline = []
12550  TIAXline = []
12551  TIAMagline = []
12552  TIAAngline = []
12553  TBPMline = []
12554  PeakdbA = -200
12555  PeakdbB = -200
12556  PeakMdb = -200
12557  n = 0
12558  for n in range(len(FSweepAdB)): # while n < len(FStep):
12559  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
12560  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
12561  else:
12562  F = FBins[int(FStep[0])]
12563  if F >= BeginFreq and F <= EndFreq:
12564  if HScaleBP.get() == 1:
12565  try:
12566  LogF = math.log10(F) # convet to log Freq
12567  x = x1 + (LogF - LogFStart)/LogFpixel
12568  except:
12569  x = x1
12570  else:
12571  x = x1 + (F - BeginFreq) / Fpixel
12572  CurrentFreqX = x
12573  if ShowCA_VdB.get() == 1:
12574  TAFline.append(int(x + 0.5))
12575  try:
12576  dbA = (10 * math.log10(float(FSweepAdB[n])) + 17) # Convert power to DBs, except for log(0) error
12577  ya = Yc - Yconv * dbA # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12578  except:
12579  ya = Ymax
12580  if (ya < Ymin):
12581  ya = Ymin
12582  if (ya > Ymax):
12583  ya = Ymax
12584  if dbA > PeakdbA:
12585  PeakdbA = dbA
12586  PeakyA = int(ya + 0.5)
12587  PeakxA = int(x + 0.5)
12588  PeakfreqA = F
12589  TAFline.append(int(ya + 0.5))
12590  if ShowCB_VdB.get() == 1:
12591  TBFline.append(int(x + 0.5))
12592  try:
12593  dbB = (10 * math.log10(float(FSweepBdB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12594  yb = Yc - Yconv * dbB
12595  except:
12596  yb = Ymax
12597  if (yb < Ymin):
12598  yb = Ymin
12599  if (yb > Ymax):
12600  yb = Ymax
12601  if dbB > PeakdbB:
12602  PeakdbB = dbB
12603  PeakyB = int(yb + 0.5)
12604  PeakxB = int(x + 0.5)
12605  PeakfreqB = F
12606  TBFline.append(int(yb + 0.5))
12607  if ShowCA_P.get() == 1:
12608  TAPline.append(int(x + 0.5))
12609  RelPhase = FSweepAPh[n] - FSweepBPh[n]
12610  RelPhase = RelPhase - Phasecenter
12611  if RelPhase > 180:
12612  RelPhase = RelPhase - 360
12613  elif RelPhase < -180:
12614  RelPhase = RelPhase + 360
12615  if Two_X_Sample.get() == 0:
12616  PhErr = 0.0018 * F # calculate phase error due half sample period offset
12617  RelPhase = RelPhase + PhErr - PhaseOffset1x
12618  else:
12619  RelPhase = RelPhase - PhaseOffset2x
12620  ya = Yp - Yphconv * RelPhase
12621  TAPline.append(int(ya + 0.5))
12622  if ShowCB_P.get() == 1:
12623  TBPline.append(int(x + 0.5))
12624  RelPhase = FSweepBPh[n] - FSweepAPh[n]
12625  RelPhase = RelPhase - Phasecenter
12626  if RelPhase > 180:
12627  RelPhase = RelPhase - 360
12628  elif RelPhase < -180:
12629  RelPhase = RelPhase + 360
12630  if Two_X_Sample.get() == 0:
12631  PhErr = 0.0018 * F # calculate phase error due half sample period offset
12632  RelPhase = RelPhase - PhErr - PhaseOffset1x
12633  else:
12634  RelPhase = RelPhase - PhaseOffset2x
12635  ya = Yp - Yphconv * RelPhase
12636  TBPline.append(int(ya + 0.5))
12637  if ShowMathBP.get() > 0:
12638  TBPMline.append(int(x + 0.5))
12639  dbA = (10 * math.log10(float(FSweepAdB[n])) + 17) # Convert power to DBs, except for log(0) error
12640  dbB = (10 * math.log10(float(FSweepBdB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12641  if ShowMathBP.get() == 1:
12642  MdB = dbA - dbB
12643  elif ShowMathBP.get() == 2:
12644  MdB = dbB - dbA
12645  yb = Yc - Yconv * MdB
12646  if (yb < Ymin):
12647  yb = Ymin
12648  if (yb > Ymax):
12649  yb = Ymax
12650  if MdB > PeakMdb:
12651  PeakMdb = MdB
12652  PeakyM = int(yb + 0.5)
12653  PeakxM = int(x + 0.5)
12654  PeakfreqM = F
12655  TBPMline.append(int(yb + 0.5))
12656 # draw impedance trace if necessary
12657  if NetworkScreenStatus.get() > 0:
12658  ycenter = Y0TBP + (GRHBP/2)
12659  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
12660  n = 0
12661  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
12662  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
12663  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
12664  else:
12665  F = FBins[int(FStep[0])]
12666  if F >= BeginFreq and F <= EndFreq:
12667  if HScaleBP.get() == 1:
12668  try:
12669  LogF = math.log10(F) # convet to log Freq
12670  x = x1 + (LogF - LogFStart)/LogFpixel
12671  except:
12672  x = x1
12673  else:
12674  x = x1 + (F - BeginFreq) / Fpixel
12675  if Show_Rseries.get() == 1:
12676  TIARline.append(int(x + 0.5))
12677  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
12678  if (y1 < Ymin):
12679  y1 = Ymin
12680  if (y1 > Ymax):
12681  y1 = Ymax
12682  TIARline.append(y1)
12683  if Show_Xseries.get() == 1:
12684  TIAXline.append(int(x + 0.5))
12685  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
12686  if (y1 < Ymin):
12687  y1 = Ymin
12688  if (y1 > Ymax):
12689  y1 = Ymax
12690  TIAXline.append(y1)
12691  if Show_Magnitude.get() == 1:
12692  TIAMagline.append(int(x + 0.5))
12693  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
12694  if (y1 < Ymin):
12695  y1 = Ymin
12696  if (y1 > Ymax):
12697  y1 = Ymax
12698  TIAMagline.append(y1)
12699  if Show_Angle.get() == 1:
12700  TIAAngline.append(int(x + 0.5))
12701  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
12702  if (y1 < Ymin):
12703  y1 = Ymin
12704  if (y1 > Ymax):
12705  y1 = Ymax
12706  TIAAngline.append(y1)
12707 #
12708 def MakeBodeScreen(): # Update the screen with traces and text
12709  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
12710  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12711  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12712  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12713  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12714  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12715  global COLORgrid # The colors
12716  global COLORsignalband, COLORtext
12717  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
12718  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
12719  global DBdivindexBP # Index value
12720  global DBdivlist # dB per division list
12721  global DBlevelBP # Reference level
12722  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
12723  global X0LBP # Left top X value
12724  global Y0TBP # Left top Y value
12725  global GRWBP # Screenwidth
12726  global GRHBP # Screenheight
12727  global FontSize
12728  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
12729  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
12730  global SMPfft # number of FFT samples
12731  global StartBodeEntry, StopBodeEntry
12732  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
12733  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
12734  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
12735  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
12736  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
12737  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
12738  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
12739  global TAPRline, TBPRline
12740  global TRACEaverage # Number of traces for averageing
12741  global FreqTraceMode # 1 normal 2 max 3 average
12742  global Vdiv, ResScale # Number of vertical divisions
12743  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
12744  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
12745 
12746  # Delete all items on the screen
12747  MarkerFreqNum = 0
12748  Bodeca.delete(ALL) # remove all items
12749 
12750  try:
12751  EndFreq = float(StopBodeEntry.get())
12752  except:
12753  StopBodeEntry.delete(0,"end")
12754  StopBodeEntry.insert(0,10000)
12755  EndFreq = 10000
12756  try:
12757  BeginFreq = float(StartBodeEntry.get())
12758  except:
12759  StartBodeEntry.delete(0,"end")
12760  StartBodeEntry.insert(0,100)
12761  BeginFreq = 100
12762  try:
12763  Phasecenter = int(PhCenBodeEntry.get())
12764  RelPhaseCenter.set(Phasecenter)
12765  except:
12766  PhCenBodeEntry.delete(0,"end")
12767  PhCenBodeEntry.insert(0,0)
12768  RelPhaseCenter.set(0)
12769  Phasecenter = 0
12770  try:
12771  Impedcenter = int(ImCenBodeEntry.get())
12772  ImpedanceCenter.set(Impedcenter)
12773  except:
12774  ImCenBodeEntry.delete(0,"end")
12775  ImCenBodeEntry.insert(0,0)
12776  ImpedanceCenter.set(0)
12777  Impedcenter = 0
12778  #
12779  # Draw horizontal grid lines
12780  i = 0
12781  x1 = X0LBP + 14
12782  x2 = x1 + GRWBP
12783  while (i <= Vdiv.get()):
12784  y = Y0TBP + i * GRHBP/Vdiv.get()
12785  Dline = [x1,y,x2,y]
12786  if i == 0 or i == Vdiv.get():
12787  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12788  else:
12789  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12790  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
12791  Vaxis_label = str(Vaxis_value)
12792  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
12793  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
12794  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
12795  Vaxis_label = str(Vaxis_value)
12796  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
12797  if NetworkScreenStatus.get() > 0:
12798  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
12799  RperDiv = float(ResScale.get())
12800  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
12801  if Vaxis_value > 500 or Vaxis_value < -500:
12802  Vaxis_value = Vaxis_value/1000.0
12803  if Vaxis_value > 5 or Vaxis_value < -5:
12804  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
12805  else:
12806  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
12807  else:
12808  Vaxis_label = ' {0:.0f} '.format(Vaxis_value)
12809  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
12810  i = i + 1
12811  # Draw vertical grid lines
12812  i = 0
12813  y1 = Y0TBP
12814  y2 = Y0TBP + GRHBP
12815  if HScaleBP.get() == 1:
12816  F = 1.0
12817  LogFStop = math.log10(EndFreq)
12818  try:
12819  LogFStart = math.log10(BeginFreq)
12820  except:
12821  LogFStart = 0.0
12822  LogFpixel = (LogFStop - LogFStart) / GRWBP
12823  # draw left and right edges
12824  while F <= EndFreq:
12825  if F >= BeginFreq:
12826  try:
12827  LogF = math.log10(F) # convet to log Freq
12828  x = x1 + (LogF - LogFStart)/LogFpixel
12829  except:
12830  x = x1
12831  Dline = [x,y1,x,y2]
12832  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
12833  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12834  axis_label = str(F)
12835  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
12836  else:
12837  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12838 
12839  if F < 10:
12840  F = F + 1
12841  elif F < 100:
12842  F = F + 10
12843  elif F < 1000:
12844  F = F + 100
12845  elif F < 1000:
12846  F = F + 100
12847  elif F < 10000:
12848  F = F + 1000
12849  elif F < 100000:
12850  F = F + 10000
12851  elif F < 200000:
12852  F = F + 10000
12853  else:
12854  Freqdiv = (EndFreq - BeginFreq) / 10
12855  while (i < 11):
12856  x = x1 + i * GRWBP/10
12857  Dline = [x,y1,x,y2]
12858  if i == 0 or i == 10:
12859  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12860  else:
12861  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12862  axis_value = BeginFreq + (i * Freqdiv)
12863  axis_label = str(axis_value)
12864  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
12865  i = i + 1
12866  # Draw X - Y cursors if needed
12867  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
12868  LogFStop = math.log10(EndFreq)
12869  try:
12870  LogFStart = math.log10(BeginFreq)
12871  except:
12872  LogFStart = 0.0
12873  LogFpixel = (LogFStop - LogFStart) / GRWBP
12874  if ShowBPCur.get() > 0:
12875  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
12876  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
12877  # Horizontal conversion factors (frequency Hz) and border limits
12878  if HScaleBP.get() == 1:
12879  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
12880  else:
12881  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
12882  XFString = ' {0:.2f} '.format(xfreq)
12883  V_label = XFString + " Hz"
12884  Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
12885 #
12886  if ShowBdBCur.get() > 0:
12887  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
12888  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
12889  if ShowBdBCur.get() == 1:
12890  # Vertical conversion factors (level dBs) and border limits
12891  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
12892  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
12893  yvdB = ((Yc-BdBCursor)/Yconv)
12894  VdBString = ' {0:.1f} '.format(yvdB)
12895  V_label = VdBString + " dBV"
12896  else:
12897  # Vertical conversion factors (level degrees) and border limits
12898  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
12899  Yc = float(Y0TBP) # Yc is the 180 degree position
12900  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
12901  VdBString = ' {0:.1f} '.format(yvdB)
12902  V_label = VdBString + " Deg"
12903  Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
12904  #
12905  SmoothBool = SmoothCurvesBP.get()
12906  # Draw traces
12907  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
12908  # Write the trace CHA
12909  if OverRangeFlagA == 1:
12910  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12911  else:
12912  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12913  if ShowMarkerBP.get() == 1:
12914  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
12915  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
12916  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
12917  # Write the trace CHB
12918  if OverRangeFlagB == 1:
12919  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12920  else:
12921  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12922  if ShowMarkerBP.get() == 1:
12923  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
12924  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
12925  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
12926  # Write the phase trace A-B
12927  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12928  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
12929  # Write the phase trace A-B
12930  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12931  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
12932  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12933  if ShowMarkerBP.get() == 1:
12934  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
12935  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
12936  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
12937  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12938  if ShowMarkerBP.get() == 1:
12939  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
12940  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
12941  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
12942  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12943  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
12944  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12945  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
12946  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12947  if ShowMarkerBP.get() == 1:
12948  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
12949  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
12950  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
12951  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12952  if ShowMarkerBP.get() == 1:
12953  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
12954  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
12955  if Show_Rseries.get() == 1 and len(TIARline) > 4:
12956  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12957  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
12958  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12959  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
12960  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12961  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
12962  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12963  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
12964  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12965  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
12966  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12967  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
12968  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12969  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
12970  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12971 
12972  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
12973  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
12974  if HScaleBP.get() == 1:
12975  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
12976  else:
12977  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
12978  XFString = ' {0:.0f} '.format(xfreq)
12979  V_label = XFString + " Hz"
12980  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
12981  # General information on top of the grid
12982 
12983  txt = " Sample rate: " + str(SAMPLErate)
12984  txt = txt + " FFT samples: " + str(SMPfft)
12985 
12986  txt = txt + " " + FFTwindowname
12987 
12988  x = X0LBP
12989  y = 12
12990  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12991 
12992  # Start and stop frequency and dB/div and trace mode
12993  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
12994  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
12995  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
12996  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
12997 
12998  x = X0LBP
12999  y = Y0TBP+GRHBP+23
13000  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13001 
13002  if FreqTraceMode.get() == 1:
13003  txt ="Normal mode "
13004 
13005  if FreqTraceMode.get() == 2:
13006  txt = "Peak hold mode "
13007 
13008  if FreqTraceMode.get() == 3:
13009  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
13010 
13011  if ZEROstuffing.get() > 0:
13012  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
13013  # Runstatus and level information
13014  if (RUNstatus.get() == 0):
13015  txt = txt + " Stopped "
13016  else:
13017  if BodeDisp.get() == 1:
13018  txt = txt + " Running "
13019  else:
13020  txt = txt + " Display off "
13021  if FSweepMode.get() > 0:
13022  txt = txt + " Freq Step = " + str(LoopNum.get())
13023  x = X0LBP
13024  y = Y0TBP+GRHBP+34
13025  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13026 
13027 # Impedance analyzer routines -----
13028 def UpdateIAAll(): # Update Data, trace and screen
13029  global FFTBuffA, FFTBuffB
13030  global SMPfft
13031 
13032  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13033  return
13034 
13035  MakeIATrace() # Update the traces
13036  UpdateIAScreen() # Update the screen
13037 
13038 def UpdateIATrace(): # Update trace and screen
13039  MakeIATrace() # Update traces
13040  UpdateIAScreen() # Update the screen
13041 
13042 def UpdateIAScreen(): # Update screen with trace and text
13043  MakeIAScreen() # Update the screen
13044  root.update() # Activate updated screens
13045 #
13047 
13048 # Input Variables
13049  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
13050  #(VZ/VA)from vector voltmeter
13051  # global VVangle # angle in degrees between VZ and VA
13052  global RsystemEntry # resistance of series resistor or power divider
13053 # Computed outputs
13054  # global VVangleCosine # cosine of vector voltmeter angle
13055  global ImpedanceMagnitude # in ohms
13056  global ImpedanceAngle # in degrees
13057  global ImpedanceRseries, ImpedanceXseries # in ohms
13058  global IA_Ext_Conf
13059 
13060  DEG2RAD = (math.pi / 180.0)
13061  SMALL = 1E-20
13062  try:
13063  ResValue = float(RsystemEntry.get())
13064  except:
13065  ResValue = 1000.0
13066 
13067  VA = math.pow(10,(PeakdbA/20))
13068  VB = math.pow(10,(PeakdbB/20))
13069  VVangleCosine = math.cos(math.radians(PeakRelPhase))
13070  if IA_Ext_Conf.get() == 1:
13071  VAB = math.pow(10,(PeakdbAB/20))
13072  VZ = VAB # VZ=VA-VB
13073  # VI = VB
13074  else:
13075  VZ = VB # VZ=VB
13076  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
13077  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
13078  Za = ResValue * VA / VI
13079  ImpedanceRseries = Za * costheta - ResValue
13080  ImpedanceMagnitude = ResValue * VZ / VI
13081  # don't try to take square root of a negative number)
13082  ImpedanceXseries = math.sqrt(abs(ImpedanceMagnitude**2 - ImpedanceRseries**2))
13083 
13084  if(PeakRelPhase < 0.0):
13085  ImpedanceXseries = -ImpedanceXseries
13086  if IA_Ext_Conf.get() == 1:
13087  ImpedanceRseries = -ImpedanceRseries
13088  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
13089 #
13090 def MakeIATrace(): # Update the grid and trace
13091  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
13092  global FFTmemoryB, FFTresultB
13093  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
13094  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
13095  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
13096  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
13097  global DBdivindex # Index value
13098  global DBdivlist # dB per division list
13099  global DBlevel # Reference level
13100  global GRHIA # Screenheight
13101  global GRWIA # Screenwidth
13102  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
13103  global STARTsample, STOPsample, LoopNum, FSweepMode
13104  global TRACEmode, Two_X_Sample, IA_Ext_Conf
13105  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
13106  global Vdiv # Number of vertical divisions
13107  global X0LIA # Left top X value
13108  global Y0TIA # Left top Y value
13109  global ImpedanceMagnitude # in ohms
13110  global ImpedanceAngle # in degrees
13111  global ImpedanceRseries, ImpedanceXseries # in ohms
13112 
13113  # Set the TRACEsize variable
13114  TRACEsize = len(FFTresultA) # Set the trace length
13115  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
13116  # Horizontal conversion factors (frequency Hz) and border limits
13117  STARTsample = 0 # First sample in FFTresult[] that is used
13118  STARTsample = int(math.ceil(STARTsample)) # First within screen range
13119  if Two_X_Sample.get() == 0:
13120  STOPsample = 45000 / Fsample # Last sample in FFTresult[] that is used
13121  else:
13122  STOPsample = 90000 / Fsample
13123  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
13124 #
13125  try:
13126  GainCorrection = float(eval(GainCorEntry.get()))
13127  except:
13128  GainCorEntry.delete(0,END)
13129  GainCorEntry.insert(0, GainCorrection)
13130 
13131  try:
13132  PhaseCorrection = float(eval(PhaseCorEntry.get()))
13133  except:
13134  PhaseCorEntry.delete(0,END)
13135  PhaseCorEntry.insert(0, PhaseCorrection)
13136 
13137  MAXsample = TRACEsize # Just an out of range check
13138  if STARTsample > (MAXsample - 1):
13139  STARTsample = MAXsample - 1
13140 
13141  if STOPsample > MAXsample:
13142  STOPsample = MAXsample
13143 
13144  n = STARTsample
13145  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
13146  PeakphaseA = PhaseA[n]
13147  PeakphaseB = PhaseB[n]
13148  #PeakphaseAB = PhaseAB[n]
13149  PeakSample = n
13150 
13151  PeakdbA = (10 * math.log10(float(FFTresultA[n])) + 17)
13152  PeakdbB = (10 * math.log10(float(FFTresultB[n])) + 17)
13153  PeakMdb = PeakdbA - PeakdbB
13154  if IA_Ext_Conf.get() == 1:
13155  PeakdbAB = (10 * math.log10(float(FFTresultAB[n])) + 17)
13156  while n <= STOPsample:
13157  F = n * Fsample
13158  try:
13159  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
13160  except:
13161  dbA = -200
13162  if dbA > PeakdbA:
13163  PeakdbA = dbA
13164  PeakfreqA = F
13165  PeakphaseA = PhaseA[n]
13166  PeakSample = n
13167 
13168  try:
13169  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13170  except:
13171  dbB = -200
13172  if dbB > PeakdbB:
13173  PeakdbB = dbB
13174  PeakfreqB = F
13175  PeakphaseB = PhaseB[n]
13176 
13177  if IA_Ext_Conf.get() == 1:
13178  try:
13179  dbAB = (10 * math.log10(float(FFTresultAB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13180  except:
13181  dbAB = -200
13182  if dbAB > PeakdbAB:
13183  PeakdbAB = dbAB
13184  PeakphaseAB = PhaseAB[n]
13185  RelPhase = PhaseA[n]-PhaseB[n]
13186  if RelPhase > 180:
13187  RelPhase = RelPhase - 360
13188  elif RelPhase < -180:
13189  RelPhase = RelPhase + 360
13190  if Two_X_Sample.get() == 0:
13191  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
13192  RelPhase = RelPhase + PhErr - 12.0
13193  else:
13194  RelPhase = RelPhase - 9.0
13195  n = n + 1
13196  if IA_Ext_Conf.get() == 1:
13197  PeakRelPhase = PeakphaseAB-PeakphaseA
13198  else:
13199  PeakRelPhase = PeakphaseB-PeakphaseA
13200 #
13201  if PeakRelPhase > 180:
13202  PeakRelPhase = PeakRelPhase - 360
13203  elif PeakRelPhase < -180:
13204  PeakRelPhase = PeakRelPhase + 360
13205  if Two_X_Sample.get() == 0:
13206  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
13207  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
13208  else:
13209  PeakRelPhase = PeakRelPhase + PhaseCorrection
13210  PeakdbB = PeakdbB + GainCorrection
13211  DoImpedance()
13212 
13214 def MakeIAScreen(): # Update the screen with traces and text
13215  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
13216  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13217  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
13218  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
13219  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
13220  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
13221  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry
13222  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
13223  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
13224  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
13225  global ResScale, DisplaySeries # Ohms per div
13226  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
13227  global X0LIA # Left top X value
13228  global Y0TIA # Left top Y value
13229  global GRWIA # Screenwidth
13230  global GRHIA # Screenheight
13231  global FontSize
13232  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
13233  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
13234  global SMPfft # number of FFT samples
13235  global TRACEaverage # Number of traces for averageing
13236  global FreqTraceMode # 1 normal 2 max 3 average
13237  global Vdiv # Number of vertical divisions
13238  global ImpedanceMagnitude # in ohms
13239  global ImpedanceAngle # in degrees
13240  global ImpedanceRseries, ImpedanceXseries # in ohms
13241  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
13242 
13243  if LoopNum.get() > 1:
13244  if NetworkScreenStatus.get() > 0:
13245  NSweepSeriesR.append(ImpedanceRseries)
13246  NSweepSeriesX.append(ImpedanceXseries)
13247  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
13248  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
13249  # Delete all items on the screen
13250  IAca.delete(ALL) # remove all items
13251  SmoothBool = SmoothCurvesBP.get()
13252  # Draw circular grid lines
13253  i = 1
13254  xcenter = GRWIA/2
13255  ycenter = GRHIA/2
13256  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
13257  OhmsperPixel = float(ResScale.get())/Radius
13258  TRadius = Radius * Vdiv.get() # 5
13259  x1 = X0LIA
13260  x2 = X0LIA + GRWIA
13261  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
13262  while (i <= Vdiv.get()):
13263  x0 = xcenter - ( i * Radius )
13264  x1 = xcenter + ( i * Radius )
13265  y0 = ycenter - ( i * Radius )
13266  y1 = ycenter + ( i * Radius )
13267  ResTxt = '{0:.1f}'.format(float(ResScale.get()) * i)
13268  IAca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
13269  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
13270  IAca.create_text(xright, y0, text=str(ResTxt), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13271  #
13272  i = i + 1
13273  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
13274  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
13275  RAngle = math.radians(45)
13276  y = TRadius*math.sin(RAngle)
13277  x = TRadius*math.cos(RAngle)
13278  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13279  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13280  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
13281  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13282  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
13283  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
13284 # Draw traces
13285  # Add saved line if there
13286  if IASweepSaved.get() > 0:
13287  if len(TIAMRline) > 4:
13288  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13289 #
13290  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
13291  if x1 > 1500:
13292  x1 = xright
13293  elif x1 < -500:
13294  x1 = xcenter - xright
13295  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
13296  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
13297  if y1 > 1500:
13298  y1 = xright
13299  elif y1 < -500:
13300  y1 = ycenter - xright
13301  xmag = x1
13302  ymag = y1
13303  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())
13304  MagRadius = ImpedanceMagnitude / OhmsperPixel
13305  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
13306  if y1 > 1500:
13307  y1 = xright
13308  elif y1 < -500:
13309  y1 = ycenter - xright
13310  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
13311  if x1 > 1500:
13312  x1 = xright
13313  elif x1 < -500:
13314  x1 = xcenter - xright
13315  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
13316 #
13317  TIAMline = []
13318  if len(NSweepSeriesMag) > 2:
13319  index = 0
13320  while index < len(NSweepSeriesMag):
13321  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
13322  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
13323  if y1 > 1500:
13324  y1 = xright
13325  elif y1 < -500:
13326  y1 = ycenter - xright
13327  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
13328  if x1 > 1500:
13329  x1 = xright
13330  elif x1 < -500:
13331  x1 = xcenter - xright
13332  TIAMline.append(x1)
13333  TIAMline.append(y1)
13334  index = index + 1
13335  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13336 # display warning if input out of range
13337  if OverRangeFlagA == 1:
13338  x = X0LIA+GRWIA+10
13339  y = Y0TIA+GRHIA-40
13340  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
13341  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
13342  if OverRangeFlagB == 1:
13343  x = X0LIA+GRWIA+10
13344  y = Y0TIA+GRHIA-10
13345  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
13346  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
13347  # General information on top of the grid
13348 
13349  txt = " Sample rate: " + str(SAMPLErate)
13350  txt = txt + " FFT samples: " + str(SMPfft)
13351 
13352  txt = txt + " " + FFTwindowname
13353 
13354  x = X0LIA
13355  y = 12
13356  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13357  #
13358  x = X0LIA + GRWIA + 4
13359  y = 24
13360  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
13361  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13362  y = y + 24
13363  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
13364  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13365  y = y + 24
13366  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
13367  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13368  y = y + 24
13369  txt = "Impedance Magnitude"
13370  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13371  y = y + 24
13372  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
13373  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13374  y = y + 24
13375  txt = "Impedance Angle"
13376  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13377  y = y + 24
13378  txt = ' {0:.1f} '.format(ImpedanceAngle)
13379  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13380  y = y + 24
13381  txt = "Impedance R series"
13382  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13383  y = y + 24
13384  txt = ' {0:.1f} '.format(ImpedanceRseries)
13385  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13386  y = y + 24
13387  txt = "Impedance X series"
13388  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13389  y = y + 24
13390  txt = ' {0:.1f} '.format(ImpedanceXseries)
13391  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
13392 #
13393  if ImpedanceXseries < 0: # calculate series capacitance
13394  y = y + 24
13395  try:
13396  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
13397  except:
13398  Cseries = 0
13399  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
13400  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
13401  Cparallel = Cparallel * 1E6 # convert to micro Farads
13402  Rparallel = ImpedanceRseries * (1+Qseries**2)
13403  Cseries = Cseries * 1E6 # convert to micro Farads
13404  if DisplaySeries.get() == 0:
13405  txt = "Series Capacitance"
13406  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13407  y = y + 20
13408  if Cseries < 1:
13409  Cseries = Cseries * 1E3
13410  if Cseries < 1:
13411  Cseries = Cseries * 1E3
13412  txt = ' {0:.1f} '.format(Cseries) + "pF"
13413  else:
13414  txt = ' {0:.3f} '.format(Cseries) + "nF"
13415  else:
13416  txt = ' {0:.3f} '.format(Cseries) + "uF"
13417  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13418  else:
13419  txt = "Parallel"
13420  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13421  y = y + 20
13422  if Cparallel < 1:
13423  Cparallel = Cparallel * 1E3
13424  if Cparallel < 1:
13425  Cparallel = Cparallel * 1E3
13426  txt = "Capacitance " + ' {0:.1f} '.format(Cparallel) + "pF"
13427  else:
13428  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "nF"
13429  else:
13430  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
13431  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13432  y = y + 20
13433  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
13434  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13435  y = y + 20
13436  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
13437  txt = 'D = {0:.2f} '.format(dissp) + " %"
13438  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13439 
13440  elif ImpedanceXseries > 0: # calculate series inductance
13441  y = y + 24
13442  try:
13443  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
13444  except:
13445  Lseries = 0
13446  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
13447  if Qseries == 0.0: # Check if divide by zero
13448  Qseries = 0.00001
13449  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
13450  Lparallel = Lparallel * 1E3 # convert to millihenry
13451  Rparallel = ImpedanceRseries * (1+Qseries**2)
13452  Lseries = Lseries * 1E3 # in millihenry
13453  if DisplaySeries.get() == 0:
13454  txt = "Series Inductance"
13455  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13456  y = y + 22
13457  if Lseries < 1:
13458  Lseries = Lseries * 1E3
13459  txt = ' {0:.2f} '.format(Lseries) + "uH"
13460  else:
13461  txt = ' {0:.2f} '.format(Lseries) + "mH"
13462  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13463  else:
13464  txt = "Parallel"
13465  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13466  y = y + 20
13467  if Lparallel < 1:
13468  Lparallel = Lparallel * 1E3
13469  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "uH"
13470  else:
13471  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
13472  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13473  y = y + 20
13474  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
13475  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13476  y = y + 20
13477  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
13478  txt = 'Q = {0:.2f} '.format(qf)
13479  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13480  # Start and stop frequency and trace mode
13481  if Two_X_Sample.get() == 0:
13482  txt = "0.0 to 45000 Hz"
13483  else:
13484  txt = "0.0 to 90000 Hz"
13485  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
13486 
13487  x = X0LIA
13488  y = Y0TIA+GRHIA-13
13489  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13490  txt = " "
13491  if FreqTraceMode.get() == 1:
13492  txt ="Normal mode "
13493 
13494  if FreqTraceMode.get() == 2:
13495  txt = "Peak hold mode "
13496 
13497  if FreqTraceMode.get() == 3:
13498  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
13499 
13500  if ZEROstuffing.get() > 0:
13501  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
13502  # Runstatus and level information
13503  if (RUNstatus.get() == 0):
13504  txt = txt + " Stopped "
13505  else:
13506  txt = txt + " Running "
13507  y = Y0TIA+GRHIA
13508  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13509 #
13510 def IACaresize(event):
13511  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
13512 
13513  CANVASwidthIA = event.width - 4
13514  CANVASheightIA = event.height - 4
13515  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
13516  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
13517  UpdateIAAll()
13518 #
13519 # ================ Make IA Window ==========================
13521  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
13522  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode
13523  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
13524  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev
13525  global NetworkScreenStatus, IASweepSaved
13526 
13527  if IAScreenStatus.get() == 0:
13528  IAScreenStatus.set(1)
13529  IADisp.set(1)
13530  IACheckBox()
13531  CutDC.set(1) # set to remove DC
13532  CANVASwidthIA = 170 + GRWIA + 2 * X0LIA # The canvas width
13533  CANVASheightIA = GRHIA + Y0TIA + 10 # The canvas height
13534  AWGAMode.set(0) # Set AWG A to SVMI
13535  AWGAShape.set(1) # Set Shape to Sine
13536  AWGBMode.set(2) # Set AWG B to Hi-Z
13537  AWGSync.set(1) # Set AWGs to run sync
13538  iawindow = Toplevel()
13539  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
13540  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
13541  frame2iar = Frame(iawindow, borderwidth=5, relief=RIDGE)
13542  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13543 
13544  frame2ia = Frame(iawindow, borderwidth=5, relief=RIDGE)
13545  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
13546 
13547  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
13548  IAca.bind("<Configure>", IACaresize)
13549  IAca.bind("<Return>", DoNothing)
13550  IAca.bind("<space>", onCanvasSpaceBar)
13551  IAca.pack(side=TOP, expand=YES, fill=BOTH)
13552 
13553  # menu buttons
13554  # right side drop down menu buttons
13555  dropmenu = Frame( frame2iar )
13556  dropmenu.pack(side=TOP)
13557  # File menu
13558  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
13559  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
13560  IAFilemenu["menu"] = IAFilemenu.menu
13561  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
13562  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
13563  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
13564  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
13565  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
13566  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
13567  IAFilemenu.menu.add_command(label="Help", command=BHelp)
13568  IAFilemenu.pack(side=LEFT, anchor=W)
13569  #
13570  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
13571  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
13572  IAOptionmenu["menu"] = IAOptionmenu.menu
13573  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
13574  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
13575  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
13576  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
13577  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
13578  if DeBugMode == 1:
13579  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
13580  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
13581  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
13582  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
13583  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
13584  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
13585  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
13586  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
13587  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
13588  IAOptionmenu.pack(side=LEFT, anchor=W)
13589  #
13590  rsemenu = Frame( frame2iar )
13591  rsemenu.pack(side=TOP)
13592  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
13593  rseb2.pack(side=RIGHT)
13594  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
13595  rseb3.pack(side=RIGHT)
13596  #
13597  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
13598  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
13599  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
13600  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
13601  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
13602  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
13603  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
13604  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
13605  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
13606  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
13607  IAFFTwindmenu.pack(side=TOP)
13608  #
13609  smpmenu = Frame( frame2iar )
13610  smpmenu.pack(side=TOP)
13611  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
13612  smpb1.pack(side=LEFT)
13613  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
13614  smpb2.pack(side=LEFT)
13615  # Temp set source resistance to 1000
13616  rsystem = Frame( frame2iar )
13617  rsystem.pack(side=TOP)
13618  rsystemlab = Label(rsystem, text="Ext Res")
13619  rsystemlab.pack(side=LEFT, anchor=W)
13620  RsystemEntry = Entry(rsystem, width=7)
13621  RsystemEntry.bind('<Return>', onTextKey)
13622  RsystemEntry.bind('<MouseWheel>', onTextScroll)
13623  RsystemEntry.bind("<Button-4>", onTextScroll)# with Linux OS
13624  RsystemEntry.bind("<Button-5>", onTextScroll)
13625  RsystemEntry.bind('<Key>', onTextKey)
13626  RsystemEntry.pack(side=LEFT, anchor=W)
13627  RsystemEntry.delete(0,"end")
13628  RsystemEntry.insert(4,1000)
13629  # Res Sacle Spinbox
13630  ressb = Frame( frame2iar )
13631  ressb.pack(side=TOP)
13632  reslab = Label(ressb, text="Ohms/div ")
13633  reslab.pack(side=LEFT)
13634  ResScale = Spinbox(ressb, width=7, values=ResScalediv)
13635  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
13636  ResScale.pack(side=LEFT)
13637  ResScale.delete(0,"end")
13638  ResScale.insert(0,500)
13639  #
13640  GainCor = Frame( frame2iar )
13641  GainCor.pack(side=TOP)
13642  GainCorlab = Label(GainCor, text="Gain Cor dB")
13643  GainCorlab.pack(side=LEFT, anchor=W)
13644  GainCorEntry = Entry(GainCor, width=7)
13645  GainCorEntry.bind('<Return>', onTextKey)
13646  GainCorEntry.bind('<MouseWheel>', onTextScroll)
13647  GainCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
13648  GainCorEntry.bind("<Button-5>", onTextScroll)
13649  GainCorEntry.bind('<Key>', onTextKey)
13650  GainCorEntry.pack(side=LEFT, anchor=W)
13651  GainCorEntry.delete(0,"end")
13652  GainCorEntry.insert(4,0.0)
13653  #
13654  PhaseCor = Frame( frame2iar )
13655  PhaseCor.pack(side=TOP)
13656  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
13657  PhaseCorlab.pack(side=LEFT, anchor=W)
13658  PhaseCorEntry = Entry(PhaseCor, width=7)
13659  PhaseCorEntry.bind('<Return>', onTextKey)
13660  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
13661  PhaseCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
13662  PhaseCorEntry.bind("<Button-5>", onTextScroll)
13663  PhaseCorEntry.bind('<Key>', onTextKey)
13664  PhaseCorEntry.pack(side=LEFT, anchor=W)
13665  PhaseCorEntry.delete(0,"end")
13666  PhaseCorEntry.insert(4,0.0)
13667  #
13668  srclab = Label(frame2iar, text="Source")
13669  srclab.pack(side=TOP)
13670  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
13671  extsrc1.pack(side=TOP)
13672  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
13673  extsrc2.pack(side=TOP)
13674 
13675  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
13676  dismiss1button.pack(side=TOP)
13677  # add ADI logo
13678  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
13679  ADI1.pack(side=TOP)
13680 #
13682  global iawindow, IAScreenStatus, IAca, IADisp
13683 
13684  IAScreenStatus.set(0)
13685  IADisp.set(0)
13686  IACheckBox()
13687  iawindow.destroy()
13688 #
13690  global TIAMline, TIAMRline, IASweepSaved
13691 
13692  if IASweepSaved.get() > 0:
13693  TIAMRline = TIAMline
13694 #
13696  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
13697  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
13698  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
13699  global NetworkScreenStatus, NqPSweepSaved
13700 
13701  if NqPScreenStatus.get() == 0:
13702  NqPScreenStatus.set(1)
13703  NqPDisp.set(1)
13704  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
13705  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
13706  nqpwindow = Toplevel()
13707  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
13708  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
13709  #frame2iar = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13710  #frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13711 
13712  frame2nqp = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13713  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
13714 
13715  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
13716  NqPca.bind("<Configure>", NqPCaresize)
13717  NqPca.bind("<Return>", DoNothing)
13718  NqPca.bind("<space>", onCanvasSpaceBar)
13719  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
13720 #
13722  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
13723 
13724  NqPScreenStatus.set(0)
13725  NqPDisp.set(0)
13726  nqpwindow.destroy()
13727 #
13728 def NqPCaresize(event):
13729  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
13730 
13731  CANVASwidthNqP = event.width - 4
13732  CANVASheightNqP = event.height - 4
13733  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
13734  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
13735  UpdateNqPAll()
13736 
13739  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
13740  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
13741  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
13742  global Vdiv, FBins, FStep
13743  global FontSize
13744 
13745  # Delete all items on the canvas
13746  NqPca.delete(ALL) # remove all items
13747  SmoothBool = SmoothCurvesBP.get()
13748  # Draw circular grid lines
13749  i = 1
13750  xcenter = GRWNqP/2
13751  ycenter = GRHNqP/2
13752  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
13753  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
13754  TRadius = Radius * Vdiv.get() # 5
13755  x1 = X0LNqP
13756  x2 = X0LNqP + GRWNqP
13757  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
13758  while (i <= Vdiv.get()):
13759  x0 = xcenter - ( i * Radius )
13760  x1 = xcenter + ( i * Radius )
13761  y0 = ycenter - ( i * Radius )
13762  y1 = ycenter + ( i * Radius )
13763  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
13764  NqPca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
13765  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
13766  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13767  #
13768  i = i + 1
13769  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
13770  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
13771  RAngle = math.radians(45)
13772  y = TRadius*math.sin(RAngle)
13773  x = TRadius*math.cos(RAngle)
13774  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13775  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13776  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
13777  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13778  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
13779  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
13780  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
13781 # Draw traces
13782  NqPline = []
13783  if len(FSweepAdB) > 4:
13784  for index in range(len(FSweepAdB)): # while n < len(FStep):
13785  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
13786  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
13787  else:
13788  F = FBins[int(FStep[0])]
13789  # Mag value
13790  dbA = (10 * math.log10(float(FSweepAdB[index])) + 17) # Convert power to DBs, except for log(0) error
13791  dbB = (10 * math.log10(float(FSweepBdB[index])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13792  if ShowMathBP.get() == 1:
13793  MdB = dbA - dbB
13794  elif ShowMathBP.get() == 2:
13795  MdB = dbB - dbA
13796  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
13797  # Phase Value
13798  RelPhase = FSweepBPh[index] - FSweepAPh[index]
13799  if RelPhase > 180:
13800  RelPhase = RelPhase - 360
13801  elif RelPhase < -180:
13802  RelPhase = RelPhase + 360
13803  if Two_X_Sample.get() == 0:
13804  PhErr = 0.0018 * F # calculate phase error due half sample period offset
13805  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
13806  else:
13807  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
13808  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
13809  if y1 > 1500:
13810  y1 = xright
13811  elif y1 < -500:
13812  y1 = ycenter - xright
13813  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
13814  if x1 > 1500:
13815  x1 = xright
13816  elif x1 < -500:
13817  x1 = xcenter - xright
13818  NqPline.append(x1)
13819  NqPline.append(y1)
13820  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13821 #
13823  global NiCScreenStatus, NiCDisp
13824  global nicwindow, NiCca, logo, SWRev
13825  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
13826  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
13827  global NetworkScreenStatus, NiCSweepSaved
13828 
13829  if NiCScreenStatus.get() == 0:
13830  NiCScreenStatus.set(1)
13831  NiCDisp.set(1)
13832  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
13833  CANVASheightNic = GRHNiC + 60 # The canvas height
13834  nicwindow = Toplevel()
13835  nicwindow.title("Nichols Plot " + SWRev + RevDate)
13836  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
13837  #frame2iar = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13838  #frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13839 
13840  frame2nic = Frame(nicwindow, borderwidth=5, relief=RIDGE)
13841  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
13842 
13843  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
13844  NiCca.bind("<Configure>", NiCCaresize)
13845  NiCca.bind("<Return>", DoNothing)
13846  NiCca.bind("<space>", onCanvasSpaceBar)
13847  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
13848 #
13850  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
13851 
13852  NiCScreenStatus.set(0)
13853  NiCDisp.set(0)
13854  nicwindow.destroy()
13855 #
13856 def NiCCaresize(event):
13857  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
13858 
13859  CANVASwidthNic = event.width - 4
13860  CANVASheightNic = event.height - 4
13861  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
13862  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
13863  UpdateNiCAll()
13864 
13867  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
13868  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
13869  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
13870  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
13871  global FontSize
13872 
13873  Ymin = Y0TNiC # Minimum position of XY grid (top)
13874  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
13875  Xmin = X0LNiC # Minimum position of XY grid (left)
13876  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
13877  try:
13878  Phasecenter = int(PhCenBodeEntry.get())
13879  RelPhaseCenter.set(Phasecenter)
13880  except:
13881  PhCenBodeEntry.delete(0,"end")
13882  PhCenBodeEntry.insert(0,0)
13883  RelPhaseCenter.set(0)
13884  Phasecenter = 0
13885  # Delete all items on the screen
13886  MarkerNum = 0
13887  SmoothBool = SmoothCurvesBP.get()
13888  NiCca.delete(ALL) # remove all items
13889  # Draw horizontal grid lines Rel Gain Magnitude
13890  i = 0
13891  x1 = X0LNiC
13892  x2 = X0TNiC = X0LNiC + GRWNiC
13893  mg_siz = GRWNiC/10.0
13894  mg_inc = mg_siz/5.0
13895  DegPerDiv = 360 / 10
13896  while (i < Vdiv.get()+1):
13897  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
13898  y = Y0TNiC + i * GRHNiC/Vdiv.get()
13899  Dline = [x1,y,x2,y]
13900  if dBaxis_value == 0:
13901  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
13902  k = 0
13903  while (k < 10):
13904  l = 1
13905  while (l < 5): # add tick marks
13906  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
13907  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13908  l = l + 1
13909  k = k + 1
13910  else:
13911  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13912  dBaxis_label = str(dBaxis_value)
13913  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
13914 
13915  i = i + 1
13916  # Draw vertical grid lines (phase -180 to 180 10 div)
13917  i = 0
13918  y1 = Y0TNiC
13919  y2 = Y0TNiC + GRHNiC
13920  mg_siz = GRHNiC/10.0
13921  mg_inc = mg_siz/5.0
13922  #
13923  while (i < 11):
13924  x = X0LNiC + i * GRWNiC/10.0
13925  Dline = [x,y1,x,y2]
13926  axis_value = Phasecenter - 180 + (i * DegPerDiv)
13927  axis_label = str(axis_value)
13928  if ( axis_value == 0):
13929  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
13930  k = 0
13931  while (k < 10):
13932  l = 1
13933  while (l < 5): # add tick marks
13934  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
13935  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13936  l = l + 1
13937  k = k + 1
13938  else:
13939  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13940  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
13941  i = i + 1
13942  # Draw traces
13943  # Vertical conversion factors (level dBs) and border limits
13944  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13945  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
13946  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
13947  Xp = float(X0LNiC) + Xphconv * 180.0
13948  x1 = X0LNiC + 14
13949  # Horizontal conversion factors (phase deg) and border limits
13950  NiCline = []
13951  if len(FSweepAdB) > 4:
13952  index = 0
13953  for index in range(len(FSweepAdB)): # while n < len(FStep):
13954  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
13955  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
13956  else:
13957  F = FBins[int(FStep[0])]
13958  # Mag value
13959  dbA = (10 * math.log10(float(FSweepAdB[index])) + 17) # Convert power to DBs, except for log(0) error
13960  dbB = (10 * math.log10(float(FSweepBdB[index])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13961  if ShowMathBP.get() == 1:
13962  MdB = dbA - dbB
13963  elif ShowMathBP.get() == 2:
13964  MdB = dbB - dbA
13965  yb = Yc - Yconv * MdB
13966  if (yb < Ymin):
13967  yb = Ymin
13968  if (yb > Ymax):
13969  yb = Ymax
13970  # Phase Value
13971  RelPhase = FSweepBPh[index] - FSweepAPh[index]
13972  RelPhase = RelPhase - Phasecenter
13973  if RelPhase > 180:
13974  RelPhase = RelPhase - 360
13975  elif RelPhase < -180:
13976  RelPhase = RelPhase + 360
13977  if Two_X_Sample.get() == 0:
13978  PhErr = 0.0018 * F # calculate phase error due half sample period offset
13979  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
13980  else:
13981  RelPhase = RelPhase # - PhaseOffset2x
13982  xa = Xp + Xphconv * RelPhase
13983  if (xa < Xmin):
13984  xa = Ymin
13985  if (xa > Xmax):
13986  xa = Xmax
13987  NiCline.append(int(xa + 0.5))
13988  NiCline.append(int(yb + 0.5))
13989  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13990 #
13991 def UpdateNqPAll(): # Update Data, trace and screen
13992  global FFTBuffA, FFTBuffB
13993  global SMPfft
13994 
13995  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13996  return
13997  #MakeNqPTrace() # Update the traces
13998  UpdateNqPScreen() # Update the screen
13999 
14000 def UpdateNqPTrace(): # Update trace and screen
14001 
14002  #MakeNqPTrace() # Update traces
14003  UpdateNqPScreen() # Update the screen
14004 
14005 def UpdateNqPScreen(): # Update screen with trace and text
14006 
14007  MakeNqPScreen() # Update the screen
14008  root.update() # Activate updated screens
14009 #
14010 def UpdateNiCAll(): # Update Data, trace and screen
14011  global FFTBuffA, FFTBuffB
14012  global SMPfft
14013 
14014  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
14015  return
14016  #MakeNiCTrace() # Update the traces
14017  UpdateNiCScreen() # Update the screen
14018 
14019 def UpdateNiCTrace(): # Update trace and screen
14020 
14021  #MakeNiCTrace() # Update traces
14022  UpdateNiCScreen() # Update the screen
14023 
14024 def UpdateNiCScreen(): # Update screen with trace and text
14025 
14026  MakeNiCScreen() # Update the screen
14027  root.update() # Activate updated screens
14028 #
14029 #
14030 def VAtoggle():
14031  global vat_btn
14032 
14033  if vat_btn.config('text')[-1] == 'ON':
14034  vat_btn.config(text='OFF', style="Stop.TButton")
14035  else:
14036  vat_btn.config(text='ON', style="Run.TButton")
14037 #
14039  global vabt_btn
14040 
14041  if vabt_btn.config('text')[-1] == 'ON':
14042  vabt_btn.config(text='OFF', style="Stop.TButton")
14043  else:
14044  vabt_btn.config(text='ON', style="Run.TButton")
14045 #
14046 def VBtoggle():
14047  global vbt_btn
14048 
14049  if vbt_btn.config('text')[-1] == 'ON':
14050  vbt_btn.config(text='OFF', style="Stop.TButton")
14051  else:
14052  vbt_btn.config(text='ON', style="Run.TButton")
14053 #
14054 def IAtoggle():
14055  global iat_btn
14056 
14057  if iat_btn.config('text')[-1] == 'ON':
14058  iat_btn.config(text='OFF', style="Stop.TButton")
14059  else:
14060  iat_btn.config(text='ON', style="Run.TButton")
14061 #
14062 def IBtoggle():
14063  global ibt_btn
14064 
14065  if ibt_btn.config('text')[-1] == 'ON':
14066  ibt_btn.config(text='OFF', style="Stop.TButton")
14067  else:
14068  ibt_btn.config(text='ON', style="Run.TButton")
14069 #
14070 # ================ Make Phase Ana Window ==========================
14072  global phawindow, PhAca, logo, PhAScreenStatus, PhADisp, AWGSync
14073  global COLORcanvas, CANVASwidthPhA, CANVASheightPhA, RevDate, AWGAMode, AWGAShape, AWGBMode
14074  global FFTwindow, CutDC, ColorMode, RefPhase, CHvpdiv, CHipdiv
14075  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, DeBugMode, SWRev, PhAPlotMode
14076  global VScale, IScale, RefphEntry, MuxScreenStatus, AppendPhAData
14077  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
14078  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
14079 
14080  if PhAScreenStatus.get() == 0:
14081  PhAScreenStatus.set(1)
14082  PhADisp.set(1)
14083  PhACheckBox()
14084  CutDC.set(1) # set to remove DC
14085  CANVASwidthPhA = 170 + GRWPhA + 2 * X0LPhA # The canvas width
14086  CANVASheightPhA = GRHPhA + Y0TPhA + 10 # The canvas height
14087  phawindow = Toplevel()
14088  phawindow.title("Phase Analyzer " + SWRev + RevDate)
14089  phawindow.protocol("WM_DELETE_WINDOW", DestroyPhAScreen)
14090  frame2phar = Frame(phawindow, borderwidth=5, relief=RIDGE)
14091  frame2phar.pack(side=RIGHT, expand=NO, fill=BOTH)
14092 
14093  frame2pha = Frame(phawindow, borderwidth=5, relief=RIDGE)
14094  frame2pha.pack(side=TOP, expand=YES, fill=BOTH)
14095 
14096  PhAca = Canvas(frame2pha, width=CANVASwidthPhA, height=CANVASheightPhA, background=COLORcanvas, cursor='cross')
14097  PhAca.bind("<Configure>", PhACaresize)
14098  PhAca.bind("<Return>", DoNothing)
14099  PhAca.bind("<space>", onCanvasSpaceBar)
14100  PhAca.pack(side=TOP, expand=YES, fill=BOTH)
14101 
14102  # menu buttons
14103  # right side drop down menu buttons
14104  dropmenu = Frame( frame2phar )
14105  dropmenu.pack(side=TOP)
14106  # File menu
14107  PhAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
14108  PhAFilemenu.menu = Menu(PhAFilemenu, tearoff = 0 )
14109  PhAFilemenu["menu"] = PhAFilemenu.menu
14110  PhAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
14111  PhAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
14112  PhAFilemenu.menu.add_command(label="Save Data", command=BSavePhAData)
14113  PhAFilemenu.menu.add_checkbutton(label=' - Append', variable=AppendPhAData)
14114  PhAFilemenu.menu.add_command(label="Plot From File", command=PlotPhAFromFile)
14115  PhAFilemenu.menu.add_radiobutton(label=' - Vectors', variable=PhAPlotMode, value=0)
14116  PhAFilemenu.menu.add_radiobutton(label=' - Outline', variable=PhAPlotMode, value=1)
14117  PhAFilemenu.menu.add_command(label="Help", command=BHelp)
14118  PhAFilemenu.pack(side=LEFT, anchor=W)
14119  #
14120  PhAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
14121  PhAOptionmenu.menu = Menu(PhAOptionmenu, tearoff = 0 )
14122  PhAOptionmenu["menu"] = PhAOptionmenu.menu
14123  PhAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
14124  PhAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
14125  PhAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
14126 
14127  PhAOptionmenu.menu.add_command(label="-Background-", command=donothing)
14128  PhAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
14129  PhAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
14130  PhAOptionmenu.pack(side=LEFT, anchor=W)
14131  #
14132  rsphmenu = Frame( frame2phar )
14133  rsphmenu.pack(side=TOP)
14134  rsphb2 = Button(rsphmenu, text="Stop", style="Stop.TButton", command=BStop)
14135  rsphb2.pack(side=RIGHT)
14136  rsphb3 = Button(rsphmenu, text="Run", style="Run.TButton", command=BStart)
14137  rsphb3.pack(side=RIGHT)
14138  #
14139  PhAFFTwindmenu = Menubutton(frame2phar, text="FFTwindow", style="W11.TButton")
14140  PhAFFTwindmenu.menu = Menu(PhAFFTwindmenu, tearoff = 0 )
14141  PhAFFTwindmenu["menu"] = PhAFFTwindmenu.menu
14142  PhAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
14143  PhAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
14144  PhAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
14145  PhAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
14146  PhAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
14147  PhAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
14148  PhAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
14149  PhAFFTwindmenu.pack(side=TOP)
14150  #
14151  FFTwindow.set(6) # default to Flat top window (6)
14152  #
14153  smphmenu = Frame( frame2phar )
14154  smphmenu.pack(side=TOP)
14155  smphb1 = Button(smphmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
14156  smphb1.pack(side=LEFT)
14157  smphb2 = Button(smphmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
14158  smphb2.pack(side=LEFT)
14159  #
14160  refph = Frame( frame2phar )
14161  refph.pack(side=TOP)
14162  refphlab = Label(refph, text="Ref Phase")
14163  refphlab.pack(side=LEFT, anchor=W)
14164  RefphEntry = Spinbox(refph, width=5, values=RefPhase)
14165  RefphEntry.bind('<MouseWheel>', onSpinBoxScroll)
14166  RefphEntry.pack(side=LEFT, anchor=W)
14167  RefphEntry.delete(0,"end")
14168  RefphEntry.insert(0,"CA-V")
14169  vatb = Frame( frame2phar )
14170  vatb.pack(side=TOP)
14171  vatblab = Label(vatb, text="CA-V ")
14172  vatblab.pack(side=LEFT)
14173  vat_btn = Button(vatb, text="OFF", style="Stop.TButton", width=4, command=VAtoggle)
14174  vat_btn.pack(side=LEFT)
14175  vbtb = Frame( frame2phar )
14176  vbtb.pack(side=TOP)
14177  if MuxScreenStatus.get() == 0:
14178  vbtblab = Label(vbtb, text="CB-V ")
14179  vbtblab.pack(side=LEFT)
14180  vbt_btn = Button(vbtb, text="OFF", style="Stop.TButton", width=4, command=VBtoggle)
14181  vbt_btn.pack(side=LEFT)
14182  vabtb = Frame( frame2phar )
14183  vabtb.pack(side=TOP)
14184  vabtblab = Label(vabtb, text="CA-B V ")
14185  vabtblab.pack(side=LEFT)
14186  vabt_btn = Button(vabtb, text="OFF", style="Stop.TButton", width=4, command=VABtoggle)
14187  vabt_btn.pack(side=LEFT)
14188  else:
14189  RefphEntry.configure(state=DISABLED)
14190  amuxlab = Label(frame2phar, text="Analog Mux In")
14191  amuxlab.pack(side=TOP)
14192  phbt1 = Checkbutton(frame2phar, text='CB-A ', style="Strace2.TCheckbutton", variable=ShowPB_A)
14193  phbt1.pack(side=TOP)
14194  phbt2 = Checkbutton(frame2phar, text='CB-B ', style="Strace6.TCheckbutton", variable=ShowPB_B) #, command=TraceSelectADC_Mux)
14195  phbt2.pack(side=TOP)
14196  phbt3 = Checkbutton(frame2phar, text='CB-C ', style="Strace7.TCheckbutton", variable=ShowPB_C) #, command=TraceSelectADC_Mux)
14197  phbt3.pack(side=TOP)
14198  phbt4 = Checkbutton(frame2phar, text='CB-D ', style="Strace4.TCheckbutton", variable=ShowPB_D) #, command=TraceSelectADC_Mux)
14199  phbt4.pack(side=TOP)
14200 #
14201  # Voltage Scale Spinbox
14202  vssb = Frame( frame2phar )
14203  vssb.pack(side=TOP)
14204  vslab = Label(vssb, text="Volts/div ")
14205  vslab.pack(side=LEFT)
14206  VScale = Spinbox(vssb, width=7, values=CHvpdiv)
14207  VScale.bind('<MouseWheel>', onSpinBoxScroll)
14208  VScale.pack(side=LEFT)
14209  VScale.delete(0,"end")
14210  VScale.insert(0,0.5)
14211  #
14212  iatb = Frame( frame2phar )
14213  iatb.pack(side=TOP)
14214  iatblab = Label(iatb, text="CA-I ")
14215  iatblab.pack(side=LEFT)
14216  iat_btn = Button(iatb, text="OFF", style="Stop.TButton", width=4, command=IAtoggle)
14217  iat_btn.pack(side=LEFT)
14218  ibtb = Frame( frame2phar )
14219  ibtb.pack(side=TOP)
14220  ibtblab = Label(ibtb, text="CB-I ")
14221  ibtblab.pack(side=LEFT)
14222  ibt_btn = Button(ibtb, text="OFF", style="Stop.TButton", width=4, command=IBtoggle)
14223  ibt_btn.pack(side=LEFT)
14224  # Current Scale Spinbox
14225  issb = Frame( frame2phar )
14226  issb.pack(side=TOP)
14227  islab = Label(issb, text="mA/div ")
14228  islab.pack(side=LEFT)
14229  IScale = Spinbox(issb, width=7, values=CHipdiv)
14230  IScale.bind('<MouseWheel>', onSpinBoxScroll)
14231  IScale.pack(side=LEFT)
14232  IScale.delete(0,"end")
14233  IScale.insert(0,10.0)
14234 
14235  dismiss1button = Button(frame2phar, text="Dismiss", style="W8.TButton", command=DestroyPhAScreen)
14236  dismiss1button.pack(side=TOP)
14237  # add ADI logo
14238  ADI1 = Label(frame2phar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
14239  ADI1.pack(side=TOP)
14240 #
14241 # Destroy Phase Analizer window
14243  global phawindow, PhAScreenStatus, PhAca, PhADisp
14244 
14245  PhAScreenStatus.set(0)
14246  PhADisp.set(0)
14247  PhACheckBox()
14248  phawindow.destroy()
14249 #
14250 # Resize Phase Analizer window
14251 def PhACaresize(event):
14252  global PhAca, GRWPhA, XOLPhA, GRHPhA, Y0TPhA, CANVASwidthPhA, CANVASheightPhA, FontSize
14253 
14254  CANVASwidthPhA = event.width - 4
14255  CANVASheightPhA = event.height - 4
14256  GRWPhA = CANVASwidthPhA - (2 * X0LPhA) - int(21.25 * FontSize) # 170 new grid width
14257  GRHPhA = CANVASheightPhA - Y0TPhA - int(2.25 * FontSize) # 10 new grid height
14258  UpdatePhAAll()
14259 #
14260 def UpdatePhAAll(): # Update Data, trace and screen
14261 
14262  MakePhATrace() # Update the traces
14263  UpdatePhAScreen() # Update the screen
14264 
14265 def UpdatePhATrace(): # Update trace and screen
14266  MakePhATrace() # Update traces
14267  UpdatePhAScreen() # Update the screen
14268 
14269 def UpdatePhAScreen(): # Update screen with trace and text
14270  MakePhAScreen() # Update the screen
14271  root.update() # Activate updated screens
14272 #
14273 # Place holder
14274 def MakePhATrace(): # Update the grid and trace
14275  global VAresult, VBresult, IAresult, IBresult, VABresult, PhaseIA, PhaseIB, PhaseVA, PhaseVB, PhaseVAB
14276  global VMAresult, VMBresult, VMCresult, VMDresult, PhaseVMD, PhaseVMA, PhaseVMB, PhaseVMC
14277  global PeakVA, PeakVB, PeakIA, PeakIB, PeakVAB
14278  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
14279  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
14280  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB, PeakphaseVAB
14281  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
14282  global GRHPhA # Screenheight
14283  global GRWPhA # Screenwidth
14284  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
14285  global STARTsample, STOPsample, LoopNum, FSweepMode
14286  global TRACEmode, Two_X_Sample, MuxScreenStatus, MuxChan
14287  global Vdiv # Number of vertical divisions
14288  global X0LPhA # Left top X value
14289  global Y0TPhA # Left top Y value
14290 
14291  # Set the TRACEsize variable
14292  if len(VAresult) < 32:
14293  return
14294  TRACEsize = len(VAresult) # Set the trace length
14295  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
14296  # Horizontal conversion factors (frequency Hz) and border limits
14297  STARTsample = 0 # First sample in FFTresult[] that is used
14298  STARTsample = int(math.ceil(STARTsample)) # First within screen range
14299  if Two_X_Sample.get() == 0:
14300  STOPsample = 45000 / Fsample # Last sample in FFTresult that is used
14301  else:
14302  STOPsample = 90000 / Fsample
14303  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
14304 #
14305 
14306  MAXsample = TRACEsize # Just an out of range check
14307  if STARTsample > (MAXsample - 1):
14308  STARTsample = MAXsample - 1
14309 
14310  if STOPsample > MAXsample:
14311  STOPsample = MAXsample
14312 
14313  n = STARTsample +1
14314  PeakVA = PeakVB = PeakIA = PeakIB = PeakVAB = 0.0
14315  PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = F = n * Fsample
14316  PeakphaseVA = PhaseVA[n]
14317  if MuxScreenStatus.get() == 0:
14318  PeakphaseVB = PhaseVB[n]
14319  PeakphaseIA = PhaseIA[n]
14320  PeakphaseIB = PhaseIB[n]
14321  PeakSampleVB = PeakSampleVA = PeakSampleIA = PeakSampleIB = n
14322  if MuxChan == 0: #
14323  PeakVMA = 0
14324  PeakphaseVMA = PhaseVMA[n]
14325  PeakSampleVMA = 0
14326  PeakfreqVMA = PeakfreqVA
14327  if MuxChan == 1: #
14328  PeakVMB = 0
14329  PeakphaseVMB = PhaseVMB[n]
14330  PeakSampleVMB = 0
14331  PeakfreqVMB = PeakfreqVA
14332  if MuxChan == 2: #
14333  PeakVMC = 0
14334  PeakphaseVMC = PhaseVMC[n]
14335  PeakSampleVMC = 0
14336  PeakfreqVMC = PeakfreqVA
14337  if MuxChan == 3: #
14338  PeakVMD = 0
14339  PeakphaseVMD = PhaseVMD[n]
14340  PeakSampleVMD = 0
14341  PeakfreqVMD = PeakfreqVA
14342 
14343  while n <= STOPsample: # search for peaks
14344  F = n * Fsample
14345  try:
14346  VA = float(VAresult[n]) #
14347  except:
14348  VA = 0.0
14349  if VA > PeakVA:
14350  PeakVA = VA
14351  PeakfreqVA = F
14352  PeakphaseVA = PhaseVA[n]
14353  PeakSampleVA = n
14354 
14355  if MuxScreenStatus.get() == 0:
14356  try:
14357  VAB = float(VABresult[n]) #
14358  except:
14359  VAB = 0.0
14360  if VAB > PeakVAB:
14361  PeakVAB = VAB
14362  PeakfreqVAB = F
14363  PeakphaseVAB = PhaseVAB[n]
14364  PeakSampleVAB = n
14365 
14366  try:
14367  VB = float(VBresult[n]) #
14368  except:
14369  VB = 0.0
14370  if VB > PeakVB:
14371  PeakVB = VB
14372  PeakfreqVB = F
14373  PeakphaseVB = PhaseVB[n]
14374  PeakSampleVB = n
14375  else:
14376  if MuxChan == 0: #
14377  try:
14378  VMA = float(VMAresult[n]) #
14379  except:
14380  VMA = 0.0
14381  if VMA > PeakVMA:
14382  PeakVMA = VMA
14383  PeakfreqVMA = F
14384  PeakphaseVMA = PhaseVMA[n]
14385  PeakSampleVMA = n
14386  if MuxChan == 1: #
14387  try:
14388  VMB = float(VMBresult[n]) #
14389  except:
14390  VMB = 0.0
14391  if VMB > PeakVMB:
14392  PeakVMB = VMB
14393  PeakfreqVMB = F
14394  PeakphaseVMB = PhaseVMB[n]
14395  PeakSampleVMB = n
14396  if MuxChan == 2: #
14397  try:
14398  VMC = float(VMCresult[n]) #
14399  except:
14400  VMC = 0.0
14401  if VMC > PeakVMC:
14402  PeakVMC = VMC
14403  PeakfreqVMC = F
14404  PeakphaseVMC = PhaseVMC[n]
14405  PeakSampleVMC = n
14406  if MuxChan == 3: #
14407  try:
14408  VMD = float(VMDresult[n]) #
14409  except:
14410  VMD = 0.0
14411  if VMD > PeakVMD:
14412  PeakVMD = VMD
14413  PeakfreqVMD = F
14414  PeakphaseVMD = PhaseVMD[n]
14415  PeakSampleVMD = n
14416  try:
14417  IA = float(IAresult[n]) #
14418  except:
14419  IA = 0.0
14420  if IA > PeakIA:
14421  PeakIA = IA
14422  PeakfreqIA = F
14423  PeakphaseIA = PhaseIA[n]
14424  PeakSampleIA = n
14425 
14426  try:
14427  IB = float(IBresult[n]) #
14428  except:
14429  IB = 0.0
14430  if IB > PeakIB:
14431  PeakIB = IB
14432  PeakfreqIB = F
14433  PeakphaseIB = PhaseIB[n]
14434  PeakSampleIB = n
14435 
14436  n = n + 1
14437  # Check to see that V and I peaks are in same frequency bin?
14438  if PeakSampleVA != PeakSampleIA:
14439  PeakphaseIA = PhaseIA[PeakSampleVA]
14440  PeakIA = IAresult[PeakSampleVA]
14441  if PeakSampleVB != PeakSampleIB:
14442  PeakphaseIB = PhaseIB[PeakSampleVB]
14443  PeakIB = IBresult[PeakSampleVB]
14444 #
14445 # Draw the Phase Analyzer screen
14446 def MakePhAScreen(): # Update the screen with traces and text
14447  global PeakVA, PeakVB, PeakIA, PeakIB
14448  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
14449  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB
14450  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
14451  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
14452  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
14453  global CMAphase, CMBphase, CMCphase, CMDphase
14454  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth
14455  global COLORsignalband, COLORtext, COLORgrid # The colors
14456  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
14457  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
14458  global X0LPhA # Left top X value
14459  global Y0TPhA # Left top Y value
14460  global GRWPhA # Screenwidth
14461  global GRHPhA # Screenheight
14462  global FontSize, MuxScreenStatus, MuxChan, Mulx
14463  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
14464  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
14465  global SMPfft # number of FFT samples
14466  global TRACEaverage # Number of traces for averageing
14467  global FreqTraceMode # 1 normal 2 max 3 average
14468  global Vdiv, VScale, IScale # Number of vertical divisions
14469  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
14470  global AWGBMode, AWGBIOMode, ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
14471  global ShowC1_V, ShowC2_V, ShowC1_I, ShowC2_I, CHA_RC_HP, CHB_RC_HP
14472  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
14473  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
14474  global InOffA, InGainA, InOffB, InGainB
14475  global CurOffA, CurOffB, CurGainA, CurGainB
14476  # Analog Mux channel measurement variables
14477  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
14478  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
14479  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
14480  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
14481  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
14482  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
14483  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
14484  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
14485  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
14486  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
14487  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
14488  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
14489 
14490  # Delete all items on the screen
14491  PhAca.delete(ALL) # remove all items
14492  # SmoothBool = SmoothCurvesBP.get()
14493  # Draw circular grid lines
14494  i = 1
14495  xcenter = GRWPhA/2
14496  ycenter = (GRHPhA/2) + 14
14497  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
14498  VoltsperPixel = float(VScale.get())/Radius
14499  mAperPixel = float(IScale.get())/Radius
14500  TRadius = Radius * Vdiv.get() # 5
14501  x1 = X0LPhA
14502  x2 = X0LPhA + GRWPhA
14503  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
14504  while (i <= Vdiv.get()):
14505  x0 = xcenter - ( i * Radius )
14506  x1 = xcenter + ( i * Radius )
14507  y0 = ycenter - ( i * Radius )
14508  y1 = ycenter + ( i * Radius )
14509  VTxt = '{0:.2f}'.format(float(VScale.get()) * i)
14510  ITxt = '{0:.2f}'.format(float(IScale.get()) * i)
14511  TOffset = xright+(4*FontSize)
14512  PhAca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
14513  PhAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
14514  PhAca.create_text(xright, y0, text=str(VTxt), fill=COLORtrace1, anchor="w", font=("arial", FontSize+2 ))
14515  if iat_btn.config('text')[-1] == 'ON' or ibt_btn.config('text')[-1] == 'ON':
14516  PhAca.create_text(TOffset, y0, text=str(ITxt), fill=COLORtrace3, anchor="w", font=("arial", FontSize+2 ))
14517  #
14518  i = i + 1
14519  PhAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
14520  PhAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
14521  RAngle = math.radians(45)
14522  y = TRadius*math.sin(RAngle)
14523  x = TRadius*math.cos(RAngle)
14524  PhAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
14525  PhAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
14526  PhAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
14527  PhAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
14528  PhAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
14529  PhAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
14530  YBot = y1
14531  # calculate phase error due half sample period offset 0.0018
14532  if Two_X_Sample.get() == 0:
14533  if AWGBMode.get() == 2 or AWGBIOMode.get() > 0:
14534  PhErr = 0.001675 * PeakfreqVA
14535  else:
14536  PhErr = 0.0
14537  else:
14538  PhErr = 0.0
14539 # Draw traces
14540 #
14541  if RefphEntry.get() == "CA-V":
14542  CAVphase = 0.0
14543  CBVphase = PeakphaseVA - PeakphaseVB + PhErr
14544  CAIphase = PeakphaseVA - PeakphaseIA
14545  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
14546  CABVphase = PeakphaseVA - PeakphaseVAB
14547  elif RefphEntry.get() == "CB-V":
14548  CBVphase = 0.0
14549  CAVphase = PeakphaseVB - PeakphaseVA - PhErr
14550  CAIphase = PeakphaseVB - PeakphaseIA - PhErr
14551  CBIphase = PeakphaseVB - PeakphaseIB
14552  CABVphase = PeakphaseVB - PeakphaseVAB
14553  elif RefphEntry.get() == "CA-I":
14554  CAIphase = 0.0
14555  CAVphase = PeakphaseIA - PeakphaseVA
14556  CBVphase = PeakphaseIA - PeakphaseVB + PhErr
14557  CBIphase = PeakphaseIA - PeakphaseIB + PhErr
14558  CABVphase = PeakphaseIA - PeakphaseVAB
14559  elif RefphEntry.get() == "CB-I":
14560  CBIphase = 0.0
14561  CAVphase = PeakphaseIB - PeakphaseVA - PhErr
14562  CBVphase = PeakphaseIB - PeakphaseVB
14563  CAIphase = PeakphaseIB - PeakphaseIA - PhErr
14564  CABVphase = PeakphaseIB - PeakphaseVAB
14565  #
14566  if CAVphase > 180:
14567  CAVphase = CAVphase - 360
14568  elif CAVphase < -180:
14569  CAVphase = CAVphase + 360
14570  if CBVphase > 180:
14571  CBVphase = CBVphase - 360
14572  elif CBVphase < -180:
14573  CBVphase = CBVphase + 360
14574  if CAIphase > 180:
14575  CAIphase = CAIphase - 360
14576  elif CAIphase < -180:
14577  CAIphase = CAIphase + 360
14578  if CBIphase > 180:
14579  CBIphase = CBIphase - 360
14580  elif CBIphase < -180:
14581  CBIphase = CBIphase + 360
14582  #
14583  if vat_btn.config('text')[-1] == 'ON':
14584  MagRadius = PeakVA / VoltsperPixel
14585 
14586  y1 = ycenter - MagRadius*math.sin(math.radians(CAVphase))
14587  if y1 > 1500:
14588  y1 = xright
14589  elif y1 < -500:
14590  y1 = ycenter - xright
14591  x1 = xcenter + MagRadius*math.cos(math.radians(CAVphase))
14592  if x1 > 1500:
14593  x1 = xright
14594  elif x1 < -500:
14595  x1 = xcenter - xright
14596  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
14597  if MuxScreenStatus.get() == 0:
14598  if vbt_btn.config('text')[-1] == 'ON':
14599  MagRadius = PeakVB / VoltsperPixel
14600  y1 = ycenter - MagRadius*math.sin(math.radians(CBVphase))
14601  if y1 > 1500:
14602  y1 = xright
14603  elif y1 < -500:
14604  y1 = ycenter - xright
14605  x1 = xcenter + MagRadius*math.cos(math.radians(CBVphase))
14606  if x1 > 1500:
14607  x1 = xright
14608  elif x1 < -500:
14609  x1 = xcenter - xright
14610  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
14611  else:
14612  if ShowPB_A.get() > 0:
14613  CMAphase = PeakphaseVA - PeakphaseVMA + PhErr
14614  if CMAphase > 180:
14615  CMAphase = CMAphase - 360
14616  elif CMAphase < -180:
14617  CMAphase = CMAphase + 360
14618  MagRadius = PeakVMA / VoltsperPixel
14619  y1 = ycenter - MagRadius*math.sin(math.radians(CMAphase))
14620  if y1 > 1500:
14621  y1 = xright
14622  elif y1 < -500:
14623  y1 = ycenter - xright
14624  x1 = xcenter + MagRadius*math.cos(math.radians(CMAphase))
14625  if x1 > 1500:
14626  x1 = xright
14627  elif x1 < -500:
14628  x1 = xcenter - xright
14629  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())#
14630  if ShowPB_B.get() > 0:
14631  CMBphase = PeakphaseVA - PeakphaseVMB + PhErr
14632  if CMBphase > 180:
14633  CMBphase = CMBphase - 360
14634  elif CMBphase < -180:
14635  CMBphase = CMBphase + 360
14636  MagRadius = PeakVMB / VoltsperPixel
14637  y1 = ycenter - MagRadius*math.sin(math.radians(CMBphase))
14638  if y1 > 1500:
14639  y1 = xright
14640  elif y1 < -500:
14641  y1 = ycenter - xright
14642  x1 = xcenter + MagRadius*math.cos(math.radians(CMBphase))
14643  if x1 > 1500:
14644  x1 = xright
14645  elif x1 < -500:
14646  x1 = xcenter - xright
14647  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())#
14648  if ShowPB_C.get() > 0:
14649  CMCphase = PeakphaseVA - PeakphaseVMC + PhErr
14650  if CMCphase > 180:
14651  CMCphase = CMCphase - 360
14652  elif CMCphase < -180:
14653  CMCphase = CMCphase + 360
14654  MagRadius = PeakVMC / VoltsperPixel
14655  y1 = ycenter - MagRadius*math.sin(math.radians(CMCphase))
14656  if y1 > 1500:
14657  y1 = xright
14658  elif y1 < -500:
14659  y1 = ycenter - xright
14660  x1 = xcenter + MagRadius*math.cos(math.radians(CMCphase))
14661  if x1 > 1500:
14662  x1 = xright
14663  elif x1 < -500:
14664  x1 = xcenter - xright
14665  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace7, arrow="last", width=TRACEwidth.get())#
14666  if ShowPB_D.get() > 0:
14667  CMDphase = PeakphaseVA - PeakphaseVMD + PhErr
14668  if CMDphase > 180:
14669  CMDphase = CMDphase - 360
14670  elif CMDphase < -180:
14671  CMDphase = CMDphase + 360
14672  MagRadius = PeakVMD / VoltsperPixel
14673  y1 = ycenter - MagRadius*math.sin(math.radians(CMDphase))
14674  if y1 > 1500:
14675  y1 = xright
14676  elif y1 < -500:
14677  y1 = ycenter - xright
14678  x1 = xcenter + MagRadius*math.cos(math.radians(CMDphase))
14679  if x1 > 1500:
14680  x1 = xright
14681  elif x1 < -500:
14682  x1 = xcenter - xright
14683  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())#
14684  if iat_btn.config('text')[-1] == 'ON':
14685  MagRadius = PeakIA / mAperPixel
14686  y1 = ycenter - MagRadius*math.sin(math.radians(CAIphase))
14687  if y1 > 1500:
14688  y1 = xright
14689  elif y1 < -500:
14690  y1 = ycenter - xright
14691  x1 = xcenter + MagRadius*math.cos(math.radians(CAIphase))
14692  if x1 > 1500:
14693  x1 = xright
14694  elif x1 < -500:
14695  x1 = xcenter - xright
14696  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace3, arrow="last", width=TRACEwidth.get())
14697  if ibt_btn.config('text')[-1] == 'ON':
14698  MagRadius = PeakIB / mAperPixel
14699  y1 = ycenter - MagRadius*math.sin(math.radians(CBIphase))
14700  if y1 > 1500:
14701  y1 = xright
14702  elif y1 < -500:
14703  y1 = ycenter - xright
14704  x1 = xcenter + MagRadius*math.cos(math.radians(CBIphase))
14705  if x1 > 1500:
14706  x1 = xright
14707  elif x1 < -500:
14708  x1 = xcenter - xright
14709  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())
14710  if MuxScreenStatus.get() == 0:
14711  if vabt_btn.config('text')[-1] == 'ON':
14712  MagRadius = PeakVAB / VoltsperPixel
14713 
14714  y1 = ycenter - MagRadius*math.sin(math.radians(CABVphase))
14715  if y1 > 1500:
14716  y1 = xright
14717  elif y1 < -500:
14718  y1 = ycenter - xright
14719  x1 = xcenter + MagRadius*math.cos(math.radians(CABVphase))
14720  if x1 > 1500:
14721  x1 = xright
14722  elif x1 < -500:
14723  x1 = xcenter - xright
14724  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
14725 # display warning if input out of range
14726  if OverRangeFlagA == 1:
14727  x = X0LPhA+GRWPhA+10
14728  y = Y0TPhA+GRHPhA-40
14729  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
14730  PhAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
14731  if OverRangeFlagB == 1:
14732  x = X0LPhA+GRWPhA+10
14733  y = Y0TPhA+GRHPhA-10
14734  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
14735  PhAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
14736 # General information on top of the grid
14737  txt = " Sample rate: " + str(SAMPLErate)
14738  txt = txt + " FFT samples: " + str(SMPfft)
14739  txt = txt + " " + FFTwindowname
14740 
14741  x = X0LPhA
14742  y = 12
14743  idTXT = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14744  #
14745  x = X0LPhA + GRWPhA + 4
14746  y = 24
14747  txt = "CA " + ' {0:.3f} '.format(PeakVA) + " RMS V"
14748  TXT9 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
14749  y = y + 24
14750  if MuxScreenStatus.get() == 0:
14751  txt = "CB " + ' {0:.3f} '.format(PeakVB) + " RMS V"
14752  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
14753  y = y + 24
14754  else:
14755  if ShowPB_A.get() > 0:
14756  txt = "Mux A " + ' {0:.3f} '.format(PeakVMA) + " RMS V"
14757  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
14758  y = y + 24
14759  if ShowPB_B.get() > 0:
14760  txt = "Mux B " + ' {0:.3f} '.format(PeakVMB) + " RMS V"
14761  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
14762  y = y + 24
14763  if ShowPB_C.get() > 0:
14764  txt = "Mux C " + ' {0:.3f} '.format(PeakVMC) + " RMS V"
14765  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
14766  y = y + 24
14767  if ShowPB_D.get() > 0:
14768  txt = "Mux D " + ' {0:.3f} '.format(PeakVMD) + " RMS V"
14769  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
14770  y = y + 24
14771  if iat_btn.config('text')[-1] == 'ON':
14772  txt = "CA " + ' {0:.2f} '.format(PeakIA) + " RMS mA"
14773  TXT11 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
14774  y = y + 24
14775  if ibt_btn.config('text')[-1] == 'ON':
14776  txt = "CB " + ' {0:.2f} '.format(PeakIB) + " RMS mA"
14777  TXT12 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
14778  y = y + 24
14779  txt = "CA V Phase " + ' {0:.1f} '.format(CAVphase) + " Degrees"
14780  TXT13 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
14781  y = y + 24
14782  if MuxScreenStatus.get() == 0:
14783  txt = "CB V Phase " + ' {0:.1f} '.format(CBVphase) + " Degrees"
14784  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
14785  y = y + 24
14786  else:
14787  if ShowPB_A.get() > 0:
14788  txt = "Mux A Phase " + ' {0:.1f} '.format(CMAphase) + " Degrees"
14789  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
14790  y = y + 24
14791  if ShowPB_B.get() > 0:
14792  txt = "Mux B Phase " + ' {0:.1f} '.format(CMBphase) + " Degrees"
14793  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
14794  y = y + 24
14795  if ShowPB_C.get() > 0:
14796  txt = "Mux C Phase " + ' {0:.1f} '.format(CMCphase) + " Degrees"
14797  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
14798  y = y + 24
14799  if ShowPB_D.get() > 0:
14800  txt = "Mux D Phase " + ' {0:.1f} '.format(CMDphase) + " Degrees"
14801  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
14802  y = y + 24
14803  if iat_btn.config('text')[-1] == 'ON':
14804  txt = "CA I Phase " + ' {0:.1f} '.format(CAIphase) + " Degrees"
14805  TXT15 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
14806  y = y + 24
14807  if ibt_btn.config('text')[-1] == 'ON':
14808  txt = "CB I Phase " + ' {0:.1f} '.format(CBIphase) + " Degrees"
14809  TXT16 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
14810  y = y + 24
14811  #
14812  txt = "CA-V Freq " + ' {0:.1f} '.format(PeakfreqVA) + " Hertz"
14813  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
14814  y = y + 24
14815 #
14816  txt = " "
14817 # print time domin measured period and frequency of displayed channels
14818  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
14819  if ETSDisp.get() > 0:
14820  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
14821  else:
14822  FindRisingEdge(VBuffA,VBuffB)
14823  if ShowC1_V.get() == 1:
14824  if MeasAHW.get() == 1:
14825  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
14826  if MeasALW.get() == 1:
14827  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
14828  if MeasADCy.get() == 1:
14829  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
14830  if MeasAPER.get() == 1:
14831  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
14832  if MeasAFREQ.get() == 1:
14833  txt = txt + " CA Freq = "
14834  ChaF = CHAfreq*Mulx
14835  if ChaF < 1000:
14836  V1String = ' {0:.1f} '.format(ChaF)
14837  txt = txt + str(V1String) + " Hz "
14838  if ChaF > 1000 and ChaF < 1000000:
14839  V1String = ' {0:.1f} '.format(ChaF/1000)
14840  txt = txt + str(V1String) + " KHz "
14841  if ChaF > 1000000:
14842  V1String = ' {0:.1f} '.format(ChaF/1000000)
14843  txt = txt + str(V1String) + " MHz "
14844  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
14845  if ShowC2_V.get() == 1:
14846  if MeasBHW.get() == 1:
14847  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
14848  if MeasBLW.get() == 1:
14849  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
14850  if MeasBDCy.get() == 1:
14851  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
14852  if MeasBPER.get() == 1:
14853  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
14854  if MeasBFREQ.get() == 1:
14855  txt = txt + " CB Freq = "
14856  ChaF = CHBfreq*Mulx
14857  if ChaF < 1000:
14858  V1String = ' {0:.1f} '.format(ChaF)
14859  txt = txt + str(V1String) + " Hz "
14860  if ChaF > 1000 and ChaF < 1000000:
14861  V1String = ' {0:.1f} '.format(ChaF/1000)
14862  txt = txt + str(V1String) + " KHz "
14863  if ChaF > 1000000:
14864  V1String = ' {0:.1f} '.format(ChaF/1000000)
14865  txt = txt + str(V1String) + " MHz "
14866  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
14867  if MuxScreenStatus.get() == 0:
14868  if MeasPhase.get() == 1:
14869  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
14870  if MeasDelay.get() == 1:
14871  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
14872 
14873  x = X0LPhA
14874  y = YBot + int(2.5 *FontSize) #
14875  TXT18 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
14876  txt = " "
14877  if ShowC1_V.get() == 1:
14878  # Channel A information
14879  if CHA_RC_HP.get() == 1:
14880  txt = "CHA: HP "
14881  else:
14882  txt = "CHA: "
14883  if MeasDCV1.get() == 1:
14884  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
14885  if MeasMaxV1.get() == 1:
14886  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
14887  if MeasTopV1.get() == 1:
14888  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
14889  if MeasMinV1.get() == 1:
14890  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
14891  if MeasBaseV1.get() == 1:
14892  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
14893  if MeasMidV1.get() == 1:
14894  MidV1 = (MaxV1+MinV1)/2.0
14895  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
14896  if MeasPPV1.get() == 1:
14897  PPV1 = MaxV1-MinV1
14898  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
14899  if MeasRMSV1.get() == 1:
14900  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
14901  if MeasRMSVA_B.get() == 1:
14902  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
14903  if MeasDiffAB.get() == 1:
14904  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
14905  if MeasUserA.get() == 1:
14906  try:
14907  TempValue = eval(UserAString)
14908  V1String = ' {0:.4f} '.format(TempValue)
14909  except:
14910  V1String = "####"
14911  txt = txt + UserALabel + " = " + V1String
14912  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
14913  txt = "CHA: "
14914  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
14915  txt = txt + "CHA: "
14916 
14917  if ShowC1_I.get() == 1:
14918  if MeasDCI1.get() == 1:
14919  V1String = ' {0:.2f} '.format(DCI1)
14920  txt = txt + " AvgI = " + V1String
14921  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
14922  try:
14923  Resvalue = (DCV1/DCI1)*1000
14924  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
14925  except:
14926  txt = txt + " Res = OverRange"
14927  if MeasMaxI1.get() == 1:
14928  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
14929  if MeasMinI1.get() == 1:
14930  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
14931  if MeasMidI1.get() == 1:
14932  MidI1 = (MaxI1+MinI1)/2.0
14933  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
14934  if MeasPPI1.get() == 1:
14935  PPI1 = MaxI1-MinI1
14936  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
14937  if MeasRMSI1.get() == 1:
14938  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
14939 
14940  x = X0LPhA
14941  y = YBot + int(4*FontSize) #
14942  TXT19 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
14943  txt= " "
14944  # Channel B information
14945  if MuxScreenStatus.get() == 1:
14946  txt = "CHB-Mux: "
14947  if Show_CBA.get() > 0:
14948  FindRisingEdge(VBuffA,VBuffMA)
14949  elif Show_CBB.get() > 0:
14950  FindRisingEdge(VBuffA,VBuffMB)
14951  elif Show_CBC.get() > 0:
14952  FindRisingEdge(VBuffA,VBuffMC)
14953  elif Show_CBD.get() > 0:
14954  FindRisingEdge(VBuffA,VBuffMD)
14955  if MeasPhase.get() == 1:
14956  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
14957  if MeasDelay.get() == 1:
14958  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
14959  if MeasUserB.get() == 1:
14960  try:
14961  TempValue = eval(UserBString)
14962  V1String = ' {0:.4f} '.format(TempValue)
14963  except:
14964  V1String = "####"
14965  txt = txt + UserBLabel + " = " + V1String
14966  if ShowC2_V.get() == 1:
14967  if CHB_RC_HP.get() == 1:
14968  txt = "CHB: HP "
14969  else:
14970  txt = "CHB: "
14971  if MeasDCV2.get() == 1:
14972  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
14973  if MeasMaxV2.get() == 1:
14974  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
14975  if MeasTopV2.get() == 1:
14976  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
14977  if MeasMinV2.get() == 1:
14978  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
14979  if MeasBaseV2.get() == 1:
14980  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
14981  if MeasMidV2.get() == 1:
14982  MidV2 = (MaxV2+MinV2)/2.0
14983  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
14984  if MeasPPV2.get() == 1:
14985  PPV2 = MaxV2-MinV2
14986  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
14987  if MeasRMSV2.get() == 1:
14988  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
14989  if MeasDiffBA.get() == 1:
14990  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
14991  if MeasUserB.get() == 1:
14992  try:
14993  TempValue = eval(UserBString)
14994  V1String = ' {0:.4f} '.format(TempValue)
14995  except:
14996  V1String = "####"
14997  txt = txt + UserBLabel + " = " + V1String
14998  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
14999  txt = "CHB: "
15000  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
15001  txt = txt + "CHB: "
15002  if ShowC2_I.get() == 1:
15003  if MeasDCI2.get() == 1:
15004  V1String = ' {0:.2f} '.format(DCI2)
15005  txt = txt + " AvgI = " + V1String
15006  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
15007  try:
15008  Resvalue = (DCV2/DCI2)*1000
15009  R1String = ' {0:.1f} '.format(Resvalue)
15010  txt = txt + " Res = " + R1String
15011  except:
15012  txt = txt + " Res = OverRange"
15013  if MeasMaxI2.get() == 1:
15014  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
15015  if MeasMinI2.get() == 1:
15016  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
15017  if MeasMidI2.get() == 1:
15018  MidI2 = (MaxI2+MinI2)/2.0
15019  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
15020  if MeasPPI2.get() == 1:
15021  PPI2 = MaxI2-MinI2
15022  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
15023  if MeasRMSI2.get() == 1:
15024  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
15025 
15026  x = X0LPhA
15027  y = YBot + int(5.5 *FontSize) #
15028  TXT20 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
15029 #
15031  global PeakVA, PeakVB, PeakIA, PeakIB
15032  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
15033  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
15034  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
15035  global CMAphase, CMBphase, CMCphase, CMDphase
15036  global MuxScreenStatus, AppendPhAData, PhADatafilename
15037  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
15038  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
15039 
15040  # open file to save data
15041  if AppendPhAData.get() == 0:
15042  PhADatafilename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
15043  DataFile = open(PhADatafilename, 'a')
15044  DataFile.write( 'Amplitude, Phase, @ ' + str(PeakfreqVA) + ' Hertz\n')
15045 
15046  if vat_btn.config('text')[-1] == 'ON':
15047  DataFile.write( str(PeakVA) + ', ' + str(CAVphase) + ', CA-V\n')
15048  if MuxScreenStatus.get() == 0:
15049  if vbt_btn.config('text')[-1] == 'ON':
15050  DataFile.write( str(PeakVB) + ', ' + str(CBVphase) + ', CB-V\n')
15051  else:
15052  if ShowPB_A.get() > 0:
15053  DataFile.write( str(PeakVMA) + ', ' + str(CMAphase) + ', Mux A\n')
15054  if ShowPB_B.get() > 0:
15055  DataFile.write( str(PeakVMB) + ', ' + str(CMBphase) + ', Mux B\n')
15056  if ShowPB_C.get() > 0:
15057  DataFile.write( str(PeakVMC) + ', ' + str(CMCphase) + ', Mux C\n')
15058  if ShowPB_D.get() > 0:
15059  DataFile.write( str(PeakVMD) + ', ' + str(CMDphase) + ', Mux D\n')
15060  if iat_btn.config('text')[-1] == 'ON':
15061  DataFile.write( str(PeakIA) + ', ' + str(CAIphase) + ', CA-I\n')
15062  if ibt_btn.config('text')[-1] == 'ON':
15063  DataFile.write( str(PeakIB) + ', ' + str(CBIphase) + ', CB-I\n')
15064  DataFile.close()
15065 #
15067  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth, PhAPlotMode
15068  global COLORsignalband, COLORtext, COLORgrid, SmoothCurves # The colors
15069  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
15070  global GRWPhA, GRHPhA, X0LPhA, Vdiv, VScale, IScale
15071 # open file to read data from
15072  filename = askopenfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
15073  i = 1
15074  xcenter = GRWPhA/2
15075  ycenter = (GRHPhA/2) + 14
15076  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
15077  VoltsperPixel = float(VScale.get())/Radius
15078  mAperPixel = float(IScale.get())/Radius
15079  TRadius = Radius * Vdiv.get() # 5
15080  x1 = X0LPhA
15081  x2 = X0LPhA + GRWPhA
15082  PhATrace = []
15083 # Read values from CVS file
15084  try:
15085  CSVFile = open(filename)
15086  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
15087  CSVFile.seek(0)
15088  csv_f = csv.reader(CSVFile, dialect)
15089  for row in csv_f:
15090  try:
15091  PeakMag = float(row[0])
15092  PeakPhase = float(row[1])
15093  if row[2] == "CA-I" or row[2] == "CB-I":
15094  MagRadius = PeakMag / mAperPixel
15095  else:
15096  MagRadius = PeakMag / VoltsperPixel
15097 
15098  y1 = ycenter - MagRadius*math.sin(math.radians(PeakPhase))
15099  if y1 > 1500:
15100  y1 = xright
15101  elif y1 < -500:
15102  y1 = ycenter - xright
15103  x1 = xcenter + MagRadius*math.cos(math.radians(PeakPhase))
15104  if x1 > 1500:
15105  x1 = xright
15106  elif x1 < -500:
15107  x1 = xcenter - xright
15108  if PhAPlotMode.get() == 0:
15109  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
15110  else:
15111  PhATrace.append(x1)
15112  PhATrace.append(y1)
15113  except:
15114  print( 'skipping non-numeric row')
15115  if PhAPlotMode.get() == 1:
15116  PhAca.create_line(PhATrace, fill=COLORtrace5, smooth=SmoothCurves.get(), splinestep=5, width=TRACEwidth.get())
15117  CSVFile.close()
15118  except:
15119  showwarning("WARNING","No such file found or wrong format!")
15120 #
15121 #
15122 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
15123  global FFTmemoryA, FFTresultA
15124  global FFTmemoryB, FFTresultB
15125  global PhaseA, PhaseB, freqwindow
15126  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
15127 
15128  # Set the TRACEsize variable
15129  if ShowC1_VdB.get() == 1:
15130  TRACEsize = len(FFTresultA) # Set the trace length
15131  elif ShowC2_VdB.get() == 1:
15132  TRACEsize = len(FFTresultB)
15133  if TRACEsize == 0: # If no trace, skip rest of this routine
15134  return()
15135 # ask if save as magnitude or dB
15136  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
15137  # Make the file name and open it
15138  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
15139  filename = "Spectrum-" + tme
15140  filename = filename + ".csv"
15141  # open file to save data
15142  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
15143  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
15144  DataFile = open(filename,'a') # Open output file
15145  HeaderString = 'Frequency-#, '
15146  if ShowC1_VdB.get() == 1:
15147  if dB == 1:
15148  HeaderString = HeaderString + 'CA-dB, '
15149  if dB == 0:
15150  HeaderString = HeaderString + 'CA-Mag, '
15151  if ShowC2_VdB.get() == 1:
15152  if dB == 1:
15153  HeaderString = HeaderString + 'CB-dB, '
15154  if dB == 0:
15155  HeaderString = HeaderString + 'CB-Mag, '
15156  if ShowC1_P.get() == 1:
15157  HeaderString = HeaderString + 'Phase A-B, '
15158  if ShowC2_P.get() == 1:
15159  HeaderString = HeaderString + 'Phase B-A, '
15160  HeaderString = HeaderString + '\n'
15161  DataFile.write( HeaderString )
15162 
15163  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
15164 
15165  n = 0
15166  while n < TRACEsize:
15167  F = n * Fsample
15168  txt = str(F)
15169  if ShowC1_VdB.get() == 1:
15170  V = 10 * math.log10(float(FFTresultA[n])) + 17 # Add 17 dB for max value of +10 dB
15171  if dB == 0:
15172  V = 10.0**(V/20.0)
15173  txt = txt + "," + str(V)
15174  if ShowC2_VdB.get() == 1:
15175  V = 10 * math.log10(float(FFTresultB[n])) + 17 # Add 17 dB for max value of +10 dB
15176  if dB == 0:
15177  V = 10.0**(V/20.0)
15178  txt = txt + "," + str(V)
15179  if ShowC1_P.get() == 1:
15180  RelPhase = PhaseA[n]-PhaseB[n]
15181  if RelPhase > 180:
15182  RelPhase = RelPhase - 360
15183  elif RelPhase < -180:
15184  RelPhase = RelPhase + 360
15185  txt = txt + "," + str(RelPhase)
15186  if ShowC2_P.get() == 1:
15187  RelPhase = PhaseB[n]-PhaseA[n]
15188  if RelPhase > 180:
15189  RelPhase = RelPhase - 360
15190  elif RelPhase < -180:
15191  RelPhase = RelPhase + 360
15192  txt = txt + "," + str(RelPhase)
15193  txt = txt + "\n"
15194  DataFile.write(txt)
15195  n = n + 1
15196 
15197  DataFile.close() # Close the file
15198 
15200 def MakeFreqScreen(): # Update the screen with traces and text
15201  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
15202  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
15203  global PeakxM, PeakyM, PeakMdb, PeakfreqM
15204  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
15205  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
15206  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
15207  global COLORgrid # The colors
15208  global COLORsignalband, COLORtext
15209  global COLORtrace1, COLORtrace2
15210  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
15211  global DBdivindex # Index value
15212  global DBdivlist # dB per division list
15213  global DBlevel # Reference level
15214  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
15215  global X0LF # Left top X value
15216  global Y0TF # Left top Y value
15217  global GRWF # Screenwidth
15218  global GRHF # Screenheight
15219  global FontSize
15220  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
15221  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
15222  global SMPfft # number of FFT samples
15223  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
15224  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
15225  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp
15226  global ShowFCur, ShowdBCur, FCursor, dBCursor
15227  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
15228  global T1PRline, T2PRline
15229  global TRACEaverage # Number of traces for averageing
15230  global FreqTraceMode # 1 normal 2 max 3 average
15231  global Vdiv # Number of vertical divisions
15232 
15233  # Delete all items on the screen
15234  MarkerFreqNum = 0
15235  Freqca.delete(ALL) # remove all items
15236  try:
15237  StartFrequency = float(StartFreqEntry.get())
15238  except:
15239  StartFreqEntry.delete(0,"end")
15240  StartFreqEntry.insert(0,100)
15241  StartFrequency = 100
15242  try:
15243  StopFrequency = float(StopFreqEntry.get())
15244  except:
15245  StopFreqEntry.delete(0,"end")
15246  StopFreqEntry.insert(0,10000)
15247  StopFrequency = 10000
15248  try:
15249  Phasecenter = int(PhCenFreqEntry.get())
15250  RelPhaseCenter.set(Phasecenter)
15251  except:
15252  PhCenFreqEntry.delete(0,"end")
15253  PhCenFreqEntry.insert(0,0)
15254  RelPhaseCenter.set(0)
15255  Phasecenter = 0
15256  # Draw horizontal grid lines
15257  i = 0
15258  x1 = X0LF
15259  x2 = X0LF + GRWF
15260  while (i <= Vdiv.get()):
15261  y = Y0TF + i * GRHF/Vdiv.get()
15262  Dline = [x1,y,x2,y]
15263  if i == 0 or i == Vdiv.get():
15264  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15265  else:
15266  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15267  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
15268  Vaxis_label = str(Vaxis_value)
15269  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
15270  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
15271  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
15272  Vaxis_value = Vaxis_value + Phasecenter
15273  Vaxis_label = str(Vaxis_value)
15274  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
15275  i = i + 1
15276  # Draw vertical grid lines
15277  i = 0
15278  y1 = Y0TF
15279  y2 = Y0TF + GRHF
15280  if HScale.get() == 1:
15281  F = 1.0
15282  LogFStop = math.log10(StopFrequency)
15283  try:
15284  LogFStart = math.log10(StartFrequency)
15285  except:
15286  LogFStart = 0.0
15287  LogFpixel = (LogFStop - LogFStart) / GRWF
15288  # draw left and right edges
15289  while F <= StopFrequency:
15290  if F >= StartFrequency:
15291  try:
15292  LogF = math.log10(F) # convet to log Freq
15293  x = X0LF + (LogF - LogFStart)/LogFpixel
15294  except:
15295  x = X0LF
15296  Dline = [x,y1,x,y2]
15297  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
15298  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15299  axis_label = str(F)
15300  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
15301  else:
15302  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15303 
15304  if F < 10:
15305  F = F + 1
15306  elif F < 100:
15307  F = F + 10
15308  elif F < 1000:
15309  F = F + 100
15310  elif F < 1000:
15311  F = F + 100
15312  elif F < 10000:
15313  F = F + 1000
15314  elif F < 100000:
15315  F = F + 10000
15316  elif F < 200000:
15317  F = F + 10000
15318  else:
15319  Freqdiv = (StopFrequency - StartFrequency) / 10
15320  while (i < 11):
15321  x = X0LF + i * GRWF/10.0
15322  Dline = [x,y1,x,y2]
15323  if i == 0 or i == 10:
15324  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15325  else:
15326  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15327  axis_value = (StartFrequency + (i * Freqdiv))
15328  axis_label = str(axis_value)
15329  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
15330  i = i + 1
15331  # Draw X - Y cursors if needed
15332  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15333  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
15334  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
15335  if ShowFCur.get() > 0:
15336  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
15337  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
15338  # Horizontal conversion factors (frequency Hz) and border limits
15339  if HScale.get() == 1:
15340  LogFStop = math.log10(StopFrequency)
15341  try:
15342  LogFStart = math.log10(StartFrequency)
15343  except:
15344  LogFStart = 0.0
15345  LogFpixel = (LogFStop - LogFStart) / GRWF
15346  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
15347  else:
15348  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
15349  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
15350  XFString = ' {0:.2f} '.format(xfreq)
15351  V_label = XFString + " Hz"
15352  Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
15353 #
15354  if ShowdBCur.get() > 0:
15355  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
15356  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
15357  # Vertical conversion factors (level dBs) and border limits
15358  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15359  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
15360  yvdB = ((Yc-dBCursor)/Yconv)
15361  VdBString = ' {0:.1f} '.format(yvdB)
15362  V_label = VdBString + " dBV"
15363  Freqca.create_text(FCursor+1, dBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
15364  #
15365  SmoothBool = SmoothCurvesSA.get()
15366  # Draw traces
15367  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
15368  # Write the trace CHA
15369  if OverRangeFlagA == 1:
15370  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15371  else:
15372  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15373  if ShowMarker.get() > 0:
15374  k = 1
15375  while k <= HarmonicMarkers.get():
15376  try:
15377  dbA = (10 * math.log10(float(FFTresultA[PeakIndexA*k])) + 17)
15378  FreqA = k*PeakIndexA*Fsample
15379  if ShowMarker.get() == 2 and k > 1:
15380  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
15381  else:
15382  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
15383  if HScale.get() == 1:
15384  try:
15385  LogF = math.log10(FreqA) # convet to log Freq
15386  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
15387  except:
15388  xA = X0LF
15389  else:
15390  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
15391  yA = Yc - Yconv * dbA
15392  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
15393  k = k + 1
15394  except:
15395  k = k + 1
15396  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
15397  # Write the trace CHB
15398  if OverRangeFlagB == 1:
15399  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15400  else:
15401  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15402  if ShowMarker.get() > 0:
15403  k = 1
15404  while k <= HarmonicMarkers.get():
15405  try:
15406  dbB = (10 * math.log10(float(FFTresultB[PeakIndexB*k])) + 17)
15407  FreqB = k*PeakIndexB*Fsample
15408  if ShowMarker.get() == 2 and k > 1:
15409  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
15410  else:
15411  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
15412  if HScale.get() == 1:
15413  try:
15414  LogF = math.log10(FreqB) # convet to log Freq
15415  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
15416  except:
15417  xB = X0LF
15418  else:
15419  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
15420  yB = Yc - Yconv * dbB
15421  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
15422  k = k + 1
15423  except:
15424  k = k + 1
15425  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
15426  # Write the phase trace A-B
15427  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15428  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
15429  # Write the phase trace A-B
15430  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15431  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
15432  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15433  if ShowMarker.get() == 1:
15434  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
15435  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
15436  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
15437  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15438  if ShowMarker.get() == 1:
15439  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
15440  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
15441  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
15442  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15443  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
15444  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15445  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
15446  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15447  if ShowMarker.get() ==1:
15448  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
15449  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
15450  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
15451  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15452  if ShowMarker.get() ==1:
15453  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
15454  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
15455  # General information on top of the grid
15456 
15457  txt = " Sample rate: " + str(SAMPLErate)
15458  txt = txt + " FFT samples: " + str(SMPfft)
15459 
15460  txt = txt + " " + FFTwindowname
15461 
15462  x = X0LF
15463  y = 12
15464  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15465 
15466  # Start and stop frequency and dB/div and trace mode
15467  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
15468  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
15469  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
15470  if FFTwindow.get() < 7:
15471  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
15472  else:
15473  txt = txt + " FFT Bandwidth = ???"
15474 
15475  x = X0LF
15476  y = Y0TF+GRHF+23
15477  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15478 
15479  if FreqTraceMode.get() == 1:
15480  txt ="Normal mode "
15481 
15482  if FreqTraceMode.get() == 2:
15483  txt = "Peak hold mode "
15484 
15485  if FreqTraceMode.get() == 3:
15486  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
15487 
15488  if ZEROstuffing.get() > 0:
15489  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
15490  # Runstatus and level information
15491  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
15492  txt = txt + " Stopped "
15493  elif SingleShotSA.get() == 1:
15494  txt = txt + " Single Shot Trace "
15495  else:
15496  if FreqDisp.get() == 1:
15497  txt = txt + " Running "
15498  else:
15499  txt = txt + " Display off "
15500  x = X0LF
15501  y = Y0TF+GRHF+34
15502  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15503 
15505  global SMPfft, FFTwindow
15506  global SMPfftpwrTwo, BodeDisp
15507  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
15508 
15509  # First some subroutines to set specific variables
15510  if BodeDisp.get() == 0:
15511  if FFTwindow.get() != 8:
15512  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
15513 
15515  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
15516  TRACEresetFreq = True # Clear the memory for averaging or peak
15517  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
15518  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
15519 
15520 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
15521  global FFTbandwidth # The FFT bandwidth
15522  global FFTwindow # Which FFT window number is selected
15523  global FFTwindowname # The name of the FFT window function
15524  global FFTwindowshape # The window shape
15525  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
15526  global SMPfft # Number of FFT samples
15527  global LastWindow, LastSMPfft
15528 
15529  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
15530  # recalculate window only if something changed
15531  return
15532  # FFTname and FFTbandwidth in milliHz
15533  FFTwindowname = "No such window"
15534  FFTbw = 0
15535 
15536  if FFTwindow.get() == 0:
15537  FFTwindowname = " Rectangular (no) window (B=1) "
15538  FFTbw = 1.0
15539 
15540  if FFTwindow.get() == 1:
15541  FFTwindowname = " Cosine window (B=1.24) "
15542  FFTbw = 1.24
15543 
15544  if FFTwindow.get() == 2:
15545  FFTwindowname = " Triangular window (B=1.33) "
15546  FFTbw = 1.33
15547 
15548  if FFTwindow.get() == 3:
15549  FFTwindowname = " Hann window (B=1.5) "
15550  FFTbw = 1.5
15551 
15552  if FFTwindow.get() == 4:
15553  FFTwindowname = " Blackman window (B=1.73) "
15554  FFTbw = 1.73
15555 
15556  if FFTwindow.get() == 5:
15557  FFTwindowname = " Nuttall window (B=2.02) "
15558  FFTbw = 2.02
15559 
15560  if FFTwindow.get() == 6:
15561  FFTwindowname = " Flat top window (B=3.77) "
15562  FFTbw = 3.77
15563 
15564  if FFTwindow.get() == 7:
15565  FFTwindowname = FFTUserWindowString
15566  FFTbw = 0.0
15567  try:
15568  FFTwindowshape = eval(FFTUserWindowString)
15569  except:
15570  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
15571  print( "Filling FFT window with Ones")
15572  elif FFTwindow.get() == 8: # window shape array read from csv file
15573  FFTwindowname = "Window Shape From file"
15574  FFTbw = 0.0
15575  else:
15576  FFTbandwidth = int(FFTbw * SAMPLErate / float(SMPfft))
15577  # Calculate the shape
15578  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
15579  n = 0
15580  while n < SMPfft:
15581  # Cosine window function - medium-dynamic range B=1.24
15582  if FFTwindow.get() == 1:
15583  w = math.sin(math.pi * n / (SMPfft - 1))
15584  FFTwindowshape[n] = w * 1.571
15585  # Triangular non-zero endpoints - medium-dynamic range B=1.33
15586  if FFTwindow.get() == 2:
15587  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
15588  FFTwindowshape[n] = w * 2.0
15589  # Hann window function - medium-dynamic range B=1.5
15590  if FFTwindow.get() == 3:
15591  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
15592  FFTwindowshape[n] = w * 2.000
15593  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
15594  if FFTwindow.get() == 4:
15595  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
15596  FFTwindowshape[n] = w * 2.381
15597  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
15598  if FFTwindow.get() == 5:
15599  w = 0.355768 - 0.487396 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.144232 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.012604 * math.cos(6 * math.pi * n / (SMPfft - 1))
15600  FFTwindowshape[n] = w * 2.811
15601  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
15602  if FFTwindow.get() == 6:
15603  w = 1.0 - 1.93 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 1.29 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.388 * math.cos(6 * math.pi * n / (SMPfft - 1)) + 0.032 * math.cos(8 * math.pi * n / (SMPfft - 1))
15604  FFTwindowshape[n] = w * 1.000
15605  n = n + 1
15606  LastWindow = FFTwindow.get()
15607  LastSMPfft = SMPfft
15608 
15610  global FFTUserWindowString, freqwindow
15611 
15612  TempString = FFTUserWindowString
15613  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
15614  if (FFTUserWindowString == None): # If Cancel pressed, then None
15615  FFTUserWindowString = TempString
15616 
15618  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
15619 
15620  # Read values from CVS file
15621  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
15622  try:
15623  CSVFile = open(filename)
15624  csv_f = csv.reader(CSVFile)
15625  FFTwindowshape = []
15626  for row in csv_f:
15627  try:
15628  FFTwindowshape.append(float(row[0]))
15629  except:
15630  print( 'skipping non-numeric row')
15631  FFTwindowshape = numpy.array(FFTwindowshape)
15632  CSVFile.close()
15633  SMPfft = len(FFTwindowshape)
15634  LastSMPfft = SMPfft
15635  LastWindow = FFTwindow.get()
15636  print( SMPfft)
15637  except:
15638  showwarning("WARNING","No such file found or wrong format!")
15639 #
15641  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
15642 
15643  FCursor = event.x
15644  dBCursor = event.y
15645  if RUNstatus.get() == 0:
15647  Freqca.bind('<MouseWheel>', onCanvasFreqClickScroll)
15648  Freqca.bind("<Button-4>", onCanvasFreqClickScroll)# with Linux OS
15649  Freqca.bind("<Button-5>", onCanvasFreqClickScroll)
15650 #
15652  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
15653  if event.widget == Freqca:
15654  ShiftKeyDwn = event.state & 1
15655  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
15656  # respond to Linux or Windows wheel event
15657  if event.num == 5 or event.delta == -120:
15658  FCursor -= 1
15659  if event.num == 4 or event.delta == 120:
15660  FCursor += 1
15661  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
15662  # respond to Linux or Windows wheel event
15663  if event.num == 5 or event.delta == -120:
15664  dBCursor += 1
15665  if event.num == 4 or event.delta == 120:
15666  dBCursor -= 1
15667  if RUNstatus.get() == 0:
15669 #
15671  global X0LF # Left top X value
15672  global Y0TF # Left top Y value
15673  global GRWF # Screenwidth
15674  global GRHF # Screenheight
15675  global FontSize
15676  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
15677  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
15678  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
15679  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
15680 
15681  if (RUNstatus.get() == 0):
15682  MarkerFreqNum = MarkerFreqNum + 1
15683  COLORmarker = COLORgrid
15684  if ShowC1_VdB.get() == 1:
15685  COLORmarker = COLORtrace1
15686  elif ShowC2_VdB.get() == 1:
15687  COLORmarker = COLORtrace2
15688  try:
15689  StartFrequency = float(StartFreqEntry.get())
15690  except:
15691  StartFreqEntry.delete(0,"end")
15692  StartFreqEntry.insert(0,100)
15693  StartFrequency = 100
15694  try:
15695  StopFrequency = float(StopFreqEntry.get())
15696  except:
15697  StopFreqEntry.delete(0,"end")
15698  StopFreqEntry.insert(0,100)
15699  StopFrequency = 100
15700  # draw X at marker point and number
15701  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
15702  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
15703  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
15704  # Vertical conversion factors (level dBs) and border limits
15705  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15706  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
15707  Yphconv = float(GRHF) / 360
15708  Yp = float(Y0TF) + Yphconv + 180
15709  # Horizontal conversion factors (frequency Hz) and border limits
15710  if HScale.get() == 1:
15711  LogFStop = math.log10(StopFrequency)
15712  try:
15713  LogFStart = math.log10(StartFrequency)
15714  except:
15715  LogFStart = 0.0
15716  LogFpixel = (LogFStop - LogFStart) / GRWF
15717  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
15718  else:
15719  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
15720  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
15721 
15722  yvdB = ((Yc-event.y)/Yconv)
15723  VdBString = ' {0:.1f} '.format(yvdB)
15724  XFString = ' {0:.2f} '.format(xfreq)
15725  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
15726  if MarkerFreqNum > 1:
15727  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
15728  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
15729  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
15730  x = X0LF + 5
15731  y = Y0TF + 3 + (MarkerFreqNum*10)
15732  Justify = 'w'
15733  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
15734  x = X0LF + GRWF - 5
15735  y = Y0TF + 3 + (MarkerFreqNum*10)
15736  Justify = 'e'
15737  if MarkerLoc == 'LL' or MarkerLoc == 'll':
15738  x = X0LF + 5
15739  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
15740  Justify = 'w'
15741  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
15742  x = X0LF + GRWF - 5
15743  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
15744  Justify = 'e'
15745  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
15746  PrevdBV = yvdB
15747  PrevF = xfreq
15748 #
15749 def onCanvasSAOne(event):
15750  global ShowC1_VdB
15751  if ShowC1_VdB.get() == 0:
15752  ShowC1_VdB.set(1)
15753  else:
15754  ShowC1_VdB.set(0)
15755 #
15756 def onCanvasSATwo(event):
15757  global ShowC2_VdB
15758  if ShowC2_VdB.get() == 0:
15759  ShowC2_VdB.set(1)
15760  else:
15761  ShowC2_VdB.set(0)
15762 #
15763 def onCanvasSAThree(event):
15764  global ShowC1_P
15765  if ShowC1_P.get() == 0:
15766  ShowC1_P.set(1)
15767  else:
15768  ShowC1_P.set(0)
15769 #
15770 def onCanvasSAFour(event):
15771  global ShowC2_P
15772  if ShowC2_P.get() == 0:
15773  ShowC2_P.set(1)
15774  else:
15775  ShowC2_P.set(0)
15776 #
15777 def onCanvasSAFive(event):
15778  global ShowMarker
15779  if ShowMarker.get() == 0:
15780  ShowMarker.set(1)
15781  else:
15782  ShowMarker.set(0)
15783 #
15784 def onCanvasSASix(event):
15785  global ShowRA_VdB
15786  if ShowRA_VdB.get() == 0:
15787  ShowRA_VdB.set(1)
15788  else:
15789  ShowRA_VdB.set(0)
15790 #
15791 def onCanvasSASeven(event):
15792  global ShowRB_VdB
15793  if ShowRB_VdB.get() == 0:
15794  ShowRB_VdB.set(1)
15795  else:
15796  ShowRB_VdB.set(0)
15797 #
15798 def onCanvasSAEight(event):
15799  global ShowMathSA
15800  ShowMathSA.set(2)
15801 #
15802 def onCanvasSANine(event):
15803  global ShowMathSA
15804  ShowMathSA.set(1)
15805 #
15806 def onCanvasSAZero(event):
15807  global ShowMathSA
15808  ShowMathSA.set(0)
15809 #
15810 def onCanvasSASnap(event):
15811  BSTOREtraceSA()
15812 #
15813 def onCanvasSANormal(event):
15814  BNormalmode()
15815 #
15816 def onCanvasSAPeak(event):
15817  BPeakholdmode()
15818 
15819 def onCanvasSAReset(event):
15820  BResetFreqAvg()
15821 #
15823  BAveragemode()
15824 #
15825 def onCanvasShowFcur(event):
15826  global ShowFCur
15827  if ShowFCur.get() == 0:
15828  ShowFCur.set(1)
15829  else:
15830  ShowFCur.set(0)
15831 #
15833  global ShowdBCur
15834  if ShowdBCur.get() == 1:
15835  ShowdBCur.set(0)
15836  else:
15837  ShowdBCur.set(1)
15838 #
15839 def onCanvasShowPcur(event):
15840  global ShowdBCur
15841  if ShowdBCur.get() == 2:
15842  ShowdBCur.set(0)
15843  else:
15844  ShowdBCur.set(2)
15845 #
15847  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
15848 
15849  BPCursor = event.x
15850  BdBCursor = event.y
15851  if RUNstatus.get() == 0:
15853  #Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
15854  Bodeca.bind('<MouseWheel>', onCanvasBodeClickScroll)
15855  Bodeca.bind("<Button-4>", onCanvasBodeClickScroll)# with Linux OS
15856  Bodeca.bind("<Button-5>", onCanvasBodeClickScroll)
15857 #
15859  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
15860 
15861  # print event.state
15862  shift_key = event.state & 1
15863  if ShowBPCur.get() > 0 and shift_key == 0:
15864  # respond to Linux or Windows wheel event
15865  if event.num == 5 or event.delta == -120:
15866  BPCursor -= 1
15867  if event.num == 4 or event.delta == 120:
15868  BPCursor += 1
15869  elif ShowBdBCur.get() > 0 or shift_key == 1:
15870  # respond to Linux or Windows wheel event
15871  if event.num == 5 or event.delta == -120:
15872  BdBCursor += 1
15873  if event.num == 4 or event.delta == 120:
15874  BdBCursor -= 1
15875  if RUNstatus.get() == 0:
15877 #
15879  global X0LBP # Left top X value
15880  global Y0TBP # Left top Y value
15881  global GRWBP # Screenwidth
15882  global GRHBP # Screenheight
15883  global FontSize
15884  global Bodeca, MarkerLoc, SAMPLErate
15885  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
15886  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
15887  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
15888 
15889  if (RUNstatus.get() == 0):
15890  MarkerFreqNum = MarkerFreqNum + 1
15891  COLORmarker = COLORtrace6 # COLORgrid
15892  if ShowCA_VdB.get() == 1:
15893  COLORmarker = COLORtrace1
15894  elif ShowCB_VdB.get() == 1:
15895  COLORmarker = COLORtrace2
15896  try:
15897  EndFreq = float(StopBodeEntry.get())
15898  except:
15899  StopBodeEntry.delete(0,"end")
15900  StopBodeEntry.insert(0,10000)
15901  EndFreq = 10000
15902  try:
15903  BeginFreq = float(StartBodeEntry.get())
15904  except:
15905  StartBodeEntry.delete(0,"end")
15906  StartBodeEntry.insert(0,100)
15907  BeginFreq = 100
15908  # draw X at marker point and number
15909  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
15910  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
15911  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
15912  # Vertical conversion factors (level dBs) and border limits
15913  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15914  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
15915  Yphconv = float(GRHBP) / 360
15916  Yp = float(Y0TBP) + Yphconv + 180
15917  x1 = X0LBP + 14
15918  x2 = x1 + GRWBP
15919  # Horizontal conversion factors (frequency Hz) and border limits
15920  if HScaleBP.get() == 1:
15921  LogFStop = math.log10(EndFreq)
15922  try:
15923  LogFStart = math.log10(BeginFreq)
15924  except:
15925  LogFStart = 0.0
15926  LogFpixel = (LogFStop - LogFStart) / GRWBP
15927  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
15928  else:
15929  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
15930  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
15931 
15932  yvdB = ((Yc-event.y)/Yconv)
15933  VdBString = ' {0:.1f} '.format(yvdB)
15934  XFString = ' {0:.2f} '.format(xfreq)
15935  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
15936  if MarkerFreqNum > 1:
15937  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
15938  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
15939  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
15940  x = x1 + 5
15941  y = Y0TBP + 3 + (MarkerFreqNum*10)
15942  Justify = 'w'
15943  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
15944  x = x2 - 5
15945  y = Y0TBP + 3 + (MarkerFreqNum*10)
15946  Justify = 'e'
15947  if MarkerLoc == 'LL' or MarkerLoc == 'll':
15948  x = x1 + 5
15949  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
15950  Justify = 'w'
15951  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
15952  x = x2 - 5
15953  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
15954  Justify = 'e'
15955  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
15956  PrevdBV = yvdB
15957  PrevF = xfreq
15958 #
15959 def onCanvasBdOne(event):
15960  global ShowCA_VdB
15961  if ShowCA_VdB.get() == 0:
15962  ShowCA_VdB.set(1)
15963  else:
15964  ShowCA_VdB.set(0)
15965 #
15966 def onCanvasBdTwo(event):
15967  global ShowCB_VdB
15968  if ShowCB_VdB.get() == 0:
15969  ShowCB_VdB.set(1)
15970  else:
15971  ShowCB_VdB.set(0)
15972 #
15973 def onCanvasBdThree(event):
15974  global ShowCA_P
15975  if ShowCA_P.get() == 0:
15976  ShowCA_P.set(1)
15977  else:
15978  ShowCA_P.set(0)
15979 #
15980 def onCanvasBdFour(event):
15981  global ShowCB_P
15982  if ShowCB_P.get() == 0:
15983  ShowCB_P.set(1)
15984  else:
15985  ShowCB_P.set(0)
15986 #
15987 def onCanvasBdFive(event):
15988  global ShowMarkerBP
15989  if ShowMarkerBP.get() == 0:
15990  ShowMarkerBP.set(1)
15991  else:
15992  ShowMarkerBP.set(0)
15993 #
15994 def onCanvasBdSix(event):
15995  global ShowRA_VdB
15996  if ShowRA_VdB.get() == 0:
15997  ShowRA_VdB.set(1)
15998  else:
15999  ShowRA_VdB.set(0)
16000 #
16001 def onCanvasBdSeven(event):
16002  global ShowRB_VdB
16003  if ShowRB_VdB.get() == 0:
16004  ShowRB_VdB.set(1)
16005  else:
16006  ShowRB_VdB.set(0)
16007 #
16008 def onCanvasBdEight(event):
16009  global ShowMathBP
16010  ShowMathBP.set(2)
16011 #
16012 def onCanvasBdNine(event):
16013  global ShowMathBP
16014  ShowMathBP.set(1)
16015 #
16016 def onCanvasBdZero(event):
16017  global ShowMathBP
16018  ShowMathBP.set(0)
16019 #
16020 def onCanvasBdSnap(event):
16021  BSTOREtraceBP()
16022 #
16024  global ShowBPCur
16025  if ShowBPCur.get() == 0:
16026  ShowBPCur.set(1)
16027  else:
16028  ShowBPCur.set(0)
16029 #
16031  global ShowBdBCur
16032  if ShowBdBCur.get() == 1:
16033  ShowBdBCur.set(0)
16034  else:
16035  ShowBdBCur.set(1)
16036 #
16038  global ShowBdBCur
16039  if ShowBdBCur.get() == 2:
16040  ShowBdBCur.set(0)
16041  else:
16042  ShowBdBCur.set(2)
16043 #
16044 def onAWGAscroll(event):
16045  global AWGAShape
16046 
16047  onTextScroll(event)
16048  time.sleep(0.05)
16049  ReMakeAWGwaves()
16050  time.sleep(0.05)
16051 #
16052 def onAWGBscroll(event):
16053  global AWGBShape
16054 
16055  onTextScroll(event)
16056  time.sleep(0.05)
16057  ReMakeAWGwaves()
16058  time.sleep(0.05)
16059 #
16060 def onTextScroll(event): # Use mouse wheel to scroll entry values, august 7
16061  button = event.widget
16062  cursor_position = button.index(INSERT) # get current cursor position
16063  Pos = cursor_position
16064  OldVal = button.get() # get current entry string
16065  OldValfl = float(OldVal) # and its value
16066  Len = len(OldVal)
16067  Dot = OldVal.find (".") # find decimal point position
16068  Decimals = Len - Dot - 1
16069  if Dot == -1 : # no point
16070  Decimals = 0
16071  Step = 10**(Len - Pos)
16072  elif Pos <= Dot : # no point left of position
16073  Step = 10**(Dot - Pos)
16074  else:
16075  Step = 10**(Dot - Pos + 1)
16076  # respond to Linux or Windows wheel event
16077  if event.num == 5 or event.delta == -120:
16078  NewVal = OldValfl - Step
16079  if event.num == 4 or event.delta == 120:
16080  NewVal = OldValfl + Step
16081  FormatStr = "{0:." + str(Decimals) + "f}"
16082  NewStr = FormatStr.format(NewVal)
16083  NewDot = NewStr.find (".")
16084  NewPos = Pos + NewDot - Dot
16085  if Decimals == 0 :
16086  NewLen = len(NewStr)
16087  NewPos = Pos + NewLen - Len
16088  button.delete(0, END) # remove old entry
16089  button.insert(0, NewStr) # insert new entry
16090  button.icursor(NewPos) # resets the insertion cursor
16091 #
16092 def onAWGAkey(event):
16093  global AWGAShape
16094 
16095  onTextKey(event)
16096  ReMakeAWGwaves()
16097 #
16098 def onAWGBkey(event):
16099  global AWGBShape
16100 
16101  onTextKey(event)
16102  ReMakeAWGwaves()
16103 #
16104 def onTextKeyAWG(event):
16105  onTextKey(event)
16106  ReMakeAWGwaves()
16107 #
16108 # Use Arriw keys to inc dec entry values
16109 def onTextKey(event):
16110  button = event.widget
16111  cursor_position = button.index(INSERT) # get current cursor position
16112  Pos = cursor_position
16113  OldVal = button.get() # get current entry string
16114  OldValfl = float(OldVal) # and its value
16115  Len = len(OldVal)
16116  Dot = OldVal.find (".") # find decimal point position
16117  Decimals = Len - Dot - 1
16118  if Dot == -1 : # no point
16119  Decimals = 0
16120  Step = 10**(Len - Pos)
16121  elif Pos <= Dot : # no point left of position
16122  Step = 10**(Dot - Pos)
16123  else:
16124  Step = 10**(Dot - Pos + 1)
16125  if platform.system() == "Windows":
16126  if event.keycode == 38: # increment digit for up arrow key
16127  NewVal = OldValfl + Step
16128  elif event.keycode == 40: # decrement digit for down arrow
16129  NewVal = OldValfl - Step
16130  else:
16131  return
16132  elif platform.system() == "Linux":
16133  if event.keycode == 111: # increment digit for up arrow key
16134  NewVal = OldValfl + Step
16135  elif event.keycode == 116: # decrement digit for down arrow
16136  NewVal = OldValfl - Step
16137  else:
16138  return
16139 #
16140  FormatStr = "{0:." + str(Decimals) + "f}"
16141  NewStr = FormatStr.format(NewVal)
16142  NewDot = NewStr.find (".")
16143  NewPos = Pos + NewDot - Dot
16144  if Decimals == 0 :
16145  NewLen = len(NewStr)
16146  NewPos = Pos + NewLen - Len
16147  button.delete(0, END) # remove old entry
16148  button.insert(0, NewStr) # insert new entry
16149  button.icursor(NewPos) # resets the insertion cursor
16150 #
16151 #
16152 def onSpinBoxScroll(event):
16153  spbox = event.widget
16154  if sys.version_info[0] == 3: # Spin Boxes do this automatically in Python 3 apparently
16155  return
16156  if event.delta > 0: # increment digit
16157  spbox.invoke('buttonup')
16158  else: # decrement digit
16159  spbox.invoke('buttondown')
16160 #
16161 # ================ Make awg sub window ==========================
16163  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
16164  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
16165  global AWGABurstFlag, AWGBBurstFlag, AWGAShapeLabel, AWGBShapeLabel, AWGShowAdvanced
16166  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
16167  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
16168  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
16169  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
16170  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
16171  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
16172 
16173  if AWGScreenStatus.get() == 0:
16174  AWGScreenStatus.set(1)
16175 
16176  awgwindow = Toplevel()
16177  awgwindow.title("AWG Controls " + SWRev + RevDate)
16178  awgwindow.resizable(FALSE,FALSE)
16179  awgwindow.geometry('+0+100')
16180  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
16181  #
16182  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
16183  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
16184  #
16185  if AwgLayout == "Horz":
16186  frame2.pack(side=LEFT, expand=1, fill=X)
16187  frame3.pack(side=LEFT, expand=1, fill=X)
16188  else:
16189  frame2.pack(side=TOP, expand=1, fill=Y)
16190  frame3.pack(side=TOP, expand=1, fill=Y)
16191  # now AWG A
16192  # AWG enable sub frame
16193  AWGAMode = IntVar(0) # AWG A mode variable
16194  AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
16195  AWGATerm = IntVar(0) # AWG A termination variable
16196  AWGAShape = IntVar(0) # AWG A Wave shape variable
16197  AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
16198  AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
16199  AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
16200  AWGAMode.set(2)
16201  AWGSync = IntVar(0) # Sync start both AWG channels
16202  AWGSync.set(1)
16203  awg1eb = Frame( frame2 )
16204  awg1eb.pack(side=TOP)
16205  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
16206  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
16207  ModeAMenu["menu"] = ModeAMenu.menu
16208  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
16209  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
16210  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
16211  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
16212  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
16213  ModeAMenu.menu.add_separator()
16214  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
16215  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
16216  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
16217  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
16218  ModeAMenu.pack(side=LEFT, anchor=W)
16219  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W6.TButton")
16220  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
16221  ShapeAMenu["menu"] = ShapeAMenu.menu
16222  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
16223  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
16224  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
16225  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
16226  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
16227  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
16228  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
16229  if AWGShowAdvanced.get() > 0:
16230  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
16231  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
16232  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
16233  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
16234  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
16235  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
16236  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
16237  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
16238  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
16239  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
16240  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
16241  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
16242  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
16243  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
16244  else:
16245  ShapeAMenu.menu.add_separator()
16246  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
16247  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
16248  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
16249  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
16250  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
16251  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
16252  ShapeAMenu.pack(side=LEFT, anchor=W)
16253  #
16254  AWGAModeLabel = Label(frame2, text="AWG A Mode")
16255  AWGAModeLabel.pack(side=TOP)
16256  AWGAShapeLabel = Label(frame2, text="AWG A Shape")
16257  AWGAShapeLabel.pack(side=TOP)
16258  #
16259  awg1ampl = Frame( frame2 )
16260  awg1ampl.pack(side=TOP)
16261  AWGAAmplEntry = Entry(awg1ampl, width=5)
16262  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
16263  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
16264  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
16265  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
16266  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
16267  AWGAAmplEntry.pack(side=LEFT, anchor=W)
16268  AWGAAmplEntry.delete(0,"end")
16269  AWGAAmplEntry.insert(0,0.0)
16270  amp1lab = Label(awg1ampl) #, text="Min Ch A")
16271  amp1lab.pack(side=LEFT, anchor=W)
16272  #
16273  awg1off = Frame( frame2 )
16274  awg1off.pack(side=TOP)
16275  AWGAOffsetEntry = Entry(awg1off, width=5)
16276  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
16277  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
16278  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
16279  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
16280  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
16281  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
16282  AWGAOffsetEntry.delete(0,"end")
16283  AWGAOffsetEntry.insert(0,0.0)
16284  off1lab = Label(awg1off) #, text="Max Ch A")
16285  off1lab.pack(side=LEFT, anchor=W)
16286  if AWG_Amp_Mode.get() == 0:
16287  amp1lab.config(text = "Min Ch A" ) # change displayed value
16288  off1lab.config(text = "Max Ch A" ) # change displayed value
16289  else:
16290  amp1lab.config(text = "Amp Ch A" )
16291  off1lab.config(text = "Off Ch A" )
16292  # AWG Frequency sub frame
16293  awg1freq = Frame( frame2 )
16294  awg1freq.pack(side=TOP)
16295  AWGAFreqEntry = Entry(awg1freq, width=7)
16296  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
16297  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
16298  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
16299  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
16300  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
16301  AWGAFreqEntry.pack(side=LEFT, anchor=W)
16302  AWGAFreqEntry.delete(0,"end")
16303  AWGAFreqEntry.insert(0,100.0)
16304  freq1lab = Label(awg1freq, text="Freq Ch A")
16305  freq1lab.pack(side=LEFT, anchor=W)
16306  # AWG Phase or delay select sub frame
16307  AWGAPhaseDelay = IntVar(0) #
16308  awgadelay = Frame( frame2 )
16309  awgadelay.pack(side=TOP)
16310  awgaph = Radiobutton(awgadelay, text="Phase", style="WPhase.TRadiobutton", variable=AWGAPhaseDelay, value=0, command=BAWGAPhaseDelay)
16311  awgaph.pack(side=LEFT, anchor=W)
16312  awgadel = Radiobutton(awgadelay, text="Delay", style="GPhase.TRadiobutton", variable=AWGAPhaseDelay, value=1, command=BAWGAPhaseDelay)
16313  awgadel.pack(side=LEFT, anchor=W)
16314  # AWG Phase entry sub frame
16315  awg1phase = Frame( frame2 )
16316  awg1phase.pack(side=TOP)
16317  AWGAPhaseEntry = Entry(awg1phase, width=5)
16318  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
16319  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
16320  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
16321  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
16322  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
16323  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
16324  AWGAPhaseEntry.delete(0,"end")
16325  AWGAPhaseEntry.insert(0,0)
16326  phasealab = Label(awg1phase, text="Deg")
16327  phasealab.pack(side=LEFT, anchor=W)
16328  # AWG duty cycle frame
16329  awg1dc = Frame( frame2 )
16330  awg1dc.pack(side=TOP)
16331  AWGADutyCycleEntry = Entry(awg1dc, width=5)
16332  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
16333  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
16334  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
16335  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
16336  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
16337  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
16338  AWGADutyCycleEntry.delete(0,"end")
16339  AWGADutyCycleEntry.insert(0,50)
16340  duty1lab = Label(awg1dc, text="%")
16341  duty1lab.pack(side=LEFT, anchor=W)
16342  #
16343  AWGALength = Label(frame2, text="Length")
16344  AWGALength.pack(side=TOP)
16345  #
16346  if FWRevOne > 2.16:
16347  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
16348  awg2x1.pack(side=TOP)
16349  awg2x2 = Radiobutton(frame2, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
16350  awg2x2.pack(side=TOP)
16351  awg2x3 = Radiobutton(frame2, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
16352  awg2x3.pack(side=TOP)
16353  else:
16354  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
16355  awgsync.pack(side=TOP)
16356  # now AWG B
16357  # AWG enable sub frame
16358  AWGBMode = IntVar(0) # AWG B mode variable
16359  AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
16360  AWGBTerm = IntVar(0) # AWG B termination variable
16361  AWGBShape = IntVar(0) # AWG B Wave shape variable
16362  AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
16363  AWGBMode.set(2)
16364  awg2eb = Frame( frame3 )
16365  awg2eb.pack(side=TOP)
16366  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
16367  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
16368  ModeBMenu["menu"] = ModeBMenu.menu
16369  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
16370  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
16371  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
16372  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
16373  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
16374  ModeBMenu.menu.add_separator()
16375  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
16376  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
16377  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
16378  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
16379  ModeBMenu.pack(side=LEFT, anchor=W)
16380  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W6.TButton")
16381  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
16382  ShapeBMenu["menu"] = ShapeBMenu.menu
16383  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
16384  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
16385  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
16386  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
16387  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
16388  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
16389  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
16390  if AWGShowAdvanced.get() > 0:
16391  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
16392  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
16393  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
16394  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
16395  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
16396  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
16397  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
16398  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
16399  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
16400  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
16401  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
16402  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
16403  else:
16404  ShapeBMenu.menu.add_separator()
16405  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
16406  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
16407  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
16408  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
16409  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
16410  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
16411  ShapeBMenu.pack(side=LEFT, anchor=W)
16412  #
16413  AWGBModeLabel = Label(frame3, text="AWG B Mode")
16414  AWGBModeLabel.pack(side=TOP)
16415  AWGBShapeLabel = Label(frame3, text="AWG B Shape")
16416  AWGBShapeLabel.pack(side=TOP)
16417  #
16418  awg2ampl = Frame( frame3 )
16419  awg2ampl.pack(side=TOP)
16420  AWGBAmplEntry = Entry(awg2ampl, width=5)
16421  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
16422  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
16423  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
16424  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
16425  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
16426  AWGBAmplEntry.pack(side=LEFT, anchor=W)
16427  AWGBAmplEntry.delete(0,"end")
16428  AWGBAmplEntry.insert(0,0.0)
16429  amp2lab = Label(awg2ampl) #, text="Min Ch B")
16430  amp2lab.pack(side=LEFT, anchor=W)
16431  #
16432  awg2off = Frame( frame3 )
16433  awg2off.pack(side=TOP)
16434  AWGBOffsetEntry = Entry(awg2off, width=5)
16435  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
16436  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
16437  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
16438  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
16439  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
16440  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
16441  AWGBOffsetEntry.delete(0,"end")
16442  AWGBOffsetEntry.insert(0,0.0)
16443  off2lab = Label(awg2off) #, text="Max Ch B")
16444  off2lab.pack(side=LEFT, anchor=W)
16445  if AWG_Amp_Mode.get() == 0:
16446  amp2lab.config(text = "Min Ch B" ) # change displayed value
16447  off2lab.config(text = "Max Ch B" ) # change displayed value
16448  else:
16449  amp2lab.config(text = "Amp Ch B" )
16450  off2lab.config(text = "Off Ch B" )
16451  # AWG Frequency sub frame
16452  awg2freq = Frame( frame3 )
16453  awg2freq.pack(side=TOP)
16454  AWGBFreqEntry = Entry(awg2freq, width=7)
16455  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
16456  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
16457  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
16458  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
16459  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
16460  AWGBFreqEntry.pack(side=LEFT, anchor=W)
16461  AWGBFreqEntry.delete(0,"end")
16462  AWGBFreqEntry.insert(0,100.0)
16463  freq2lab = Label(awg2freq, text="Freq Ch B")
16464  freq2lab.pack(side=LEFT, anchor=W)
16465  # AWG Phase or delay select sub frame
16466  AWGBPhaseDelay = IntVar(0) #
16467  awgbdelay = Frame( frame3 )
16468  awgbdelay.pack(side=TOP)
16469  awgbph = Radiobutton(awgbdelay, text="Phase", style="WPhase.TRadiobutton", variable=AWGBPhaseDelay, value=0, command=BAWGBPhaseDelay)
16470  awgbph.pack(side=LEFT, anchor=W)
16471  awgbdel = Radiobutton(awgbdelay, text="Delay", style="GPhase.TRadiobutton", variable=AWGBPhaseDelay, value=1, command=BAWGBPhaseDelay)
16472  awgbdel.pack(side=LEFT, anchor=W)
16473  # AWG Phase sub frame
16474  awg2phase = Frame( frame3 )
16475  awg2phase.pack(side=TOP)
16476  AWGBPhaseEntry = Entry(awg2phase, width=5)
16477  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
16478  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
16479  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
16480  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
16481  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
16482  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
16483  AWGBPhaseEntry.delete(0,"end")
16484  AWGBPhaseEntry.insert(0,0)
16485  phaseblab = Label(awg2phase, text="Deg")
16486  phaseblab.pack(side=LEFT, anchor=W)
16487  # AWG duty cycle frame
16488  awg2dc = Frame( frame3 )
16489  awg2dc.pack(side=TOP)
16490  AWGBDutyCycleEntry = Entry(awg2dc, width=5)
16491  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
16492  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
16493  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
16494  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
16495  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
16496  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
16497  AWGBDutyCycleEntry.delete(0,"end")
16498  AWGBDutyCycleEntry.insert(0,50)
16499  duty2lab = Label(awg2dc, text="%")
16500  duty2lab.pack(side=LEFT, anchor=W)
16501  #
16502  AWGBLength = Label(frame3, text="Length")
16503  AWGBLength.pack(side=TOP)
16504  #
16505  BisCompA = IntVar(0) # Sync start both AWG channels
16506  BisCompA.set(0)
16507  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
16508  bcompa.pack(side=TOP)
16509  if FWRevOne > 2.16:
16510  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
16511  awgsync.pack(side=TOP)
16512  #
16513  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
16514  dismissbutton.pack(side=TOP)
16515  else:
16516  awgwindow.deiconify()
16517 #
16518 def BAWG2X():
16519  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
16520 
16521  ReMakeAWGwaves()
16522  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
16523  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
16524  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
16525  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
16526  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
16527  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
16528  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
16529  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
16530  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
16531  BisCompA.set(0)
16532  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
16533  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
16534  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
16535  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
16536  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
16537  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
16538  BisCompA.set(0)
16539 #
16541  global awgwindow, AWGScreenStatus
16542 
16543  # AWGScreenStatus.set(0)
16544  awgwindow.iconify()
16545 #
16546 # ===== Channel B Mux Mode sub Window =======
16548  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
16549  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
16550  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
16551  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
16552  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev
16553  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg, DualMuxMode
16554 
16555  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
16556  MuxScreenStatus.set(1)
16557  #
16558  BAWGEnab() # update AWG settings
16559  #
16560  muxwindow = Toplevel()
16561  muxwindow.title("CH-B Mux " + SWRev + RevDate)
16562  muxwindow.resizable(FALSE,FALSE)
16563  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
16564  #
16565  frameM = LabelFrame(muxwindow, text="CH B Mux", style="A10B.TLabel") #, font="Arial 10 bold", borderwidth=5, relief=RIDGE)
16566  frameM.pack(side=LEFT, expand=1, fill=Y)
16567  #
16568  # Voltage channel CHB-A
16569  frameA = Frame(frameM)
16570  frameA.pack(side=TOP)
16571  cba = Checkbutton(frameA, text='CB-A', variable=Show_CBA, command=UpdateTimeTrace)
16572  cba.pack(side=LEFT, anchor=W)
16573  CHB_Asb = Spinbox(frameA, width=4, values=CHvpdiv, command=UpdateTimeTrace)
16574  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
16575  CHB_Asb.pack(side=LEFT)
16576  CHB_Asb.delete(0,"end")
16577  CHB_Asb.insert(0,0.5)
16578  #
16579  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
16580  CHB_Alab.pack(side=LEFT)
16581  CHB_APosEntry = Entry(frameA, width=5)
16582  CHB_APosEntry.bind('<Return>', onTextKey)
16583  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
16584  CHB_APosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16585  CHB_APosEntry.bind("<Button-5>", onTextScroll)
16586  CHB_APosEntry.bind('<Key>', onTextKey)
16587  CHB_APosEntry.pack(side=LEFT)
16588  CHB_APosEntry.delete(0,"end")
16589  CHB_APosEntry.insert(0,2.5)
16590  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
16591  CHB_Aofflab.pack(side=LEFT)
16592  # Voltage channel CHB-B
16593  frameB = Frame(frameM)
16594  frameB.pack(side=TOP)
16595  cbb = Checkbutton(frameB, text='CB-B', variable=Show_CBB, command=UpdateTimeTrace)
16596  cbb.pack(side=LEFT, anchor=W)
16597  CHB_Bsb = Spinbox(frameB, width=4, values=CHvpdiv, command=UpdateTimeTrace)
16598  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
16599  CHB_Bsb.pack(side=LEFT)
16600  CHB_Bsb.delete(0,"end")
16601  CHB_Bsb.insert(0,0.5)
16602  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
16603  CHB_Blab.pack(side=LEFT)
16604  CHB_BPosEntry = Entry(frameB, width=5)
16605  CHB_BPosEntry.bind('<Return>', onTextKey)
16606  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
16607  CHB_BPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16608  CHB_BPosEntry.bind("<Button-5>", onTextScroll)
16609  CHB_BPosEntry.bind('<Key>', onTextKey)
16610  CHB_BPosEntry.pack(side=LEFT)
16611  CHB_BPosEntry.delete(0,"end")
16612  CHB_BPosEntry.insert(0,2.5)
16613  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
16614  CHB_Bofflab.pack(side=LEFT)
16615  # Voltage channel B-C
16616  frameC = Frame(frameM)
16617  frameC.pack(side=TOP)
16618  cbc = Checkbutton(frameC, text='CB-C', variable=Show_CBC, command=UpdateTimeTrace)
16619  cbc.pack(side=LEFT, anchor=W)
16620  CHB_Csb = Spinbox(frameC, width=4, values=CHvpdiv, command=UpdateTimeTrace)
16621  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
16622  CHB_Csb.pack(side=LEFT)
16623  CHB_Csb.delete(0,"end")
16624  CHB_Csb.insert(0,0.5)
16625  #
16626  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
16627  CHB_Clab.pack(side=LEFT)
16628  CHB_CPosEntry = Entry(frameC, width=5)
16629  CHB_CPosEntry.bind('<Return>', onTextKey)
16630  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
16631  CHB_CPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16632  CHB_CPosEntry.bind("<Button-5>", onTextScroll)
16633  CHB_CPosEntry.bind('<Key>', onTextKey)
16634  CHB_CPosEntry.pack(side=LEFT)
16635  CHB_CPosEntry.delete(0,"end")
16636  CHB_CPosEntry.insert(0,2.5)
16637  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
16638  CHB_Cofflab.pack(side=LEFT)
16639  # Voltage channel B-D
16640  frameD = Frame(frameM)
16641  frameD.pack(side=TOP)
16642  cbd = Checkbutton(frameD, text='CB-D', variable=Show_CBD, command=UpdateTimeTrace)
16643  cbd.pack(side=LEFT, anchor=W)
16644  CHB_Dsb = Spinbox(frameD, width=4, values=CHvpdiv, command=UpdateTimeTrace)
16645  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
16646  CHB_Dsb.pack(side=LEFT)
16647  CHB_Dsb.delete(0,"end")
16648  CHB_Dsb.insert(0,0.5)
16649  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
16650  CHB_Dlab.pack(side=LEFT)
16651  CHB_DPosEntry = Entry(frameD, width=5)
16652  CHB_DPosEntry.bind('<Return>', onTextKey)
16653  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
16654  CHB_DPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16655  CHB_DPosEntry.bind("<Button-5>", onTextScroll)
16656  CHB_DPosEntry.bind('<Key>', onTextKey)
16657  CHB_DPosEntry.pack(side=LEFT)
16658  CHB_DPosEntry.delete(0,"end")
16659  CHB_DPosEntry.insert(0,2.5)
16660  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
16661  CHB_Dofflab.pack(side=LEFT)
16662  frameE = Frame(frameM)
16663  frameE.pack(side=TOP)
16664  MuxEnb = IntVar(0)
16665  MuxSync = IntVar(0)
16666  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
16667  muxenab.pack(side=LEFT)
16668  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
16669  SyncButton.pack(side=LEFT)
16670  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
16671  dismissbutton.pack(side=LEFT)
16672  frameF = Frame(frameM)
16673  frameF.pack(side=TOP)
16674  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
16675  dmx.pack(side=LEFT)
16676  # Gray out main Channel B controls
16677  CHBlab.config(style="SGray.TButton")
16678  CHBofflab.config(style="SGray.TButton")
16679 #
16681  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
16682  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab
16683 
16684  if DualMuxMode.get() == 1:
16685  AWGAIOMode.set(1) # force awg A split I/O mode
16686  AWGBIOMode.set(1) # force awg A split I/O mode
16687  ShowC1_V.set(0) # force A voltage trace off
16688  CHB_Clab.config(text="CA-C V/Div")
16689  CHB_Dlab.config(text="CA-D V/Div")
16690  CHB_Cofflab.config(text="CA-C Pos")
16691  CHB_Dofflab.config(text="CA-D Pos")
16692  BAWGEnab() # update AWG settings
16693  # Gray out main Channel A controls
16694  CHAlab.config(style="SGray.TButton")
16695  CHAofflab.config(style="SGray.TButton")
16696  else:
16697  ShowC1_V.set(1) # force A voltage trace on
16698  CHB_Clab.config(text="CB-C V/Div")
16699  CHB_Dlab.config(text="CB-D V/Div")
16700  CHB_Cofflab.config(text="CB-C Pos")
16701  CHB_Dofflab.config(text="CB-D Pos")
16702  # Reset main Channel A control colors
16703  CHAlab.config(style="Rtrace1.TButton")
16704  CHAofflab.config(style="Rtrace1.TButton")
16705 #
16707  global MuxSync, hipulseimg, lowpulseimg, SyncButton
16708 
16709  if MuxSync.get() == 0:
16710  SyncButton.config(image=hipulseimg)
16711  else:
16712  SyncButton.config(image=lowpulseimg)
16713 
16715  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
16716 
16717  MuxScreenStatus.set(0)
16718  awgsync.config(state=NORMAL)
16719  # Reset main Channel B control colors
16720  CHBlab.config(style="Rtrace2.TButton")
16721  CHBofflab.config(style="Rtrace2.TButton")
16722  CHAlab.config(style="Rtrace1.TButton")
16723  CHAofflab.config(style="Rtrace1.TButton")
16724  muxwindow.destroy()
16725 #
16726 def BodeCaresize(event):
16727  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
16728 
16729  CANVASwidthBP = event.width - 4
16730  CANVASheightBP = event.height - 4
16731  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
16732  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
16733  UpdateBodeAll()
16734 #
16736  global FStepSync, DevOne
16737 
16738  if FStepSync.get() == 0:
16739  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
16740  elif FStepSync.get() == 1:
16741  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
16742  elif FStepSync.get() == 2:
16743  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
16744 #
16746  global FSweepSync, DevOne
16747 
16748  if FSweepSync.get() == 0:
16749  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
16750  elif FSweepSync.get() == 1:
16751  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
16752  elif FSweepSync.get() == 2:
16753  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
16754 #
16756  global BDSweepFile, FileSweepFreq, FileSweepAmpl
16757 
16758  if BDSweepFile.get() > 0:
16759  # Read values from CVS file
16760  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
16761  try:
16762  CSVFile = open(filename)
16763  csv_f = csv.reader(CSVFile)
16764  FileSweepFreq = []
16765  FileSweepAmpl = []
16766  for row in csv_f:
16767  try:
16768  FileSweepFreq.append(float(row[0]))
16769  FileSweepAmpl.append(float(row[1]))
16770  except:
16771  print( 'skipping non-numeric row')
16772  FileSweepFreq = numpy.array(FileSweepFreq)
16773  FileSweepAmpl = numpy.array(FileSweepAmpl)
16774  MaxAmpl = numpy.amax(FileSweepAmpl)
16775  NormAmpl = MaxAmpl
16776  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
16777  if (s == None): # If Cancel pressed, then None
16778  return()
16779  try: # Error if for example no numeric characters or OK pressed without input (s = "")
16780  v = int(s)
16781  except:
16782  s = "error"
16783 
16784  if s != "error":
16785  NormAmpl = MaxAmpl - v
16786  else:
16787  NormAmpl = MaxAmpl
16788  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
16789  CSVFile.close()
16790  StopBodeEntry.delete(0,"end")
16791  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
16792  StartBodeEntry.delete(0,"end")
16793  StartBodeEntry.insert(0,FileSweepFreq[0])
16794  SweepStepBodeEntry.delete(0,"end")
16795  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
16796  except:
16797  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
16798 #
16799 # ========== Make Bode Plot Window =============
16801  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
16802  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
16803  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
16804  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
16805  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
16806  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
16807  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
16808  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
16809  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
16810 
16811  if BodeScreenStatus.get() == 0:
16812  BodeScreenStatus.set(1)
16813  BodeDisp.set(1)
16814  BodeCheckBox()
16815  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
16816  CANVASheightBP = GRHBP + 80 # The ode canvas height
16817  CutDC.set(1) # set to remove DC
16818  AWGAMode.set(0) # Set AWG A to SVMI
16819  AWGAShape.set(1) # Set Shape to Sine
16820  AWGBMode.set(2) # Set AWG B to Hi-Z
16821  bodewindow = Toplevel()
16822  bodewindow.title("Bode Plotter " + SWRev + RevDate)
16823  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
16824  frame2bp = Frame(bodewindow, borderwidth=5, relief=RIDGE)
16825  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
16826 
16827  frame2b = Frame(bodewindow, borderwidth=5, relief=RIDGE)
16828  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
16829 
16830  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
16831  Bodeca.bind('<Configure>', BodeCaresize)
16832  Bodeca.bind('<1>', onCanvasBodeLeftClick)
16833  Bodeca.bind('<3>', onCanvasBodeRightClick)
16834  Bodeca.bind("<Up>", onCanvasUpArrow)
16835  Bodeca.bind("<Down>", onCanvasDownArrow)
16836  Bodeca.bind("<Left>", onCanvasLeftArrow)
16837  Bodeca.bind("<Right>", onCanvasRightArrow)
16838  Bodeca.bind("<space>", onCanvasSpaceBar)
16839  Bodeca.bind("1", onCanvasBdOne)
16840  Bodeca.bind("2", onCanvasBdTwo)
16841  Bodeca.bind("3", onCanvasBdThree)
16842  Bodeca.bind("4", onCanvasBdFour)
16843  Bodeca.bind("5", onCanvasBdFive)
16844  Bodeca.bind("6", onCanvasBdSix)
16845  Bodeca.bind("7", onCanvasBdSeven)
16846  Bodeca.bind("8", onCanvasBdEight)
16847  Bodeca.bind("9", onCanvasBdNine)
16848  Bodeca.bind("0", onCanvasBdZero)
16849  Bodeca.bind("f", onCanvasShowBPcur)
16850  Bodeca.bind("d", onCanvasShowBdBcur)
16851  Bodeca.bind("h", onCanvasShowPdBcur)
16852  Bodeca.bind("s", onCanvasBdSnap)
16853  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
16854 
16855  # right side drop down menu buttons
16856  dropmenu = Frame( frame2bp )
16857  dropmenu.pack(side=TOP)
16858  # File menu
16859  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
16860  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
16861  BodeFilemenu["menu"] = BodeFilemenu.menu
16862  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
16863  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
16864  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
16865  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
16866  BodeFilemenu.pack(side=LEFT, anchor=W)
16867  #
16868  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
16869  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
16870  BodeOptionmenu["menu"] = BodeOptionmenu.menu
16871  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
16872  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
16873  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
16874  BodeOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceBP)
16875  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
16876  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
16877  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
16878  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
16879  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
16880  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
16881  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
16882  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
16883  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
16884  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
16885  BodeOptionmenu.pack(side=LEFT, anchor=W)
16886  #
16887  RUNframe = Frame( frame2bp )
16888  RUNframe.pack(side=TOP)
16889  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
16890  rbode.pack(side=LEFT)
16891  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
16892  sbode.pack(side=LEFT)
16893  #
16894  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
16895  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
16896  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
16897  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
16898  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
16899  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
16900  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
16901  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
16902  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
16903  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
16904  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
16905  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
16906  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
16907  BodeFFTwindmenu.pack(side=TOP)
16908  #
16909  tracemenu = Frame( frame2bp )
16910  tracemenu.pack(side=TOP)
16911  # Curves menu
16912  # Show channels menu
16913  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
16914  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
16915  BodeShowmenu["menu"] = BodeShowmenu.menu
16916  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
16917  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
16918  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
16919  BodeShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowCA_VdB, command=UpdateBodeAll)
16920  BodeShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowCB_VdB, command=UpdateBodeAll)
16921  BodeShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowCA_P, command=UpdateBodeAll)
16922  BodeShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowCB_P, command=UpdateBodeAll)
16923  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
16924  BodeShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathBP, value=0, command=UpdateBodeAll)
16925  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathBP, value=1, command=UpdateBodeAll)
16926  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathBP, value=2, command=UpdateBodeAll)
16927  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
16928  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
16929  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
16930  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
16931  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
16932  BodeShowmenu.menu.add_separator()
16933  BodeShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowCA_RdB, command=UpdateBodeAll)
16934  BodeShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowCB_RdB, command=UpdateBodeAll)
16935  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
16936  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
16937  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
16938  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
16939  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
16940  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
16941  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
16942  BodeShowmenu.pack(side=LEFT, anchor=W)
16943  #
16944  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
16945  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
16946  BodeMarkmenu["menu"] = BodeMarkmenu.menu
16947  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
16948  BodeMarkmenu.menu.add_checkbutton(label='Marker [5]', variable=ShowMarkerBP, command=UpdateBodeAll)
16949  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
16950  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
16951  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
16952  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowBdBCur, value=1)
16953  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowBdBCur, value=2)
16954  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowBPCur)
16955  BodeMarkmenu.pack(side=LEFT, anchor=W)
16956  #
16957  # Horz Scale
16958  HScaleBP = IntVar(0)
16959  HScaleBP.set(1)
16960  HzScale = Frame( frame2bp )
16961  HzScale.pack(side=TOP)
16962  rb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
16963  rb1.pack(side=LEFT)
16964  rb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
16965  rb2.pack(side=LEFT)
16966 
16967  DBrange = Frame( frame2bp )
16968  DBrange.pack(side=TOP)
16969  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
16970  bd3.pack(side=LEFT)
16971  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
16972  bd4.pack(side=LEFT)
16973 
16974  LVBrange = Frame( frame2bp )
16975  LVBrange.pack(side=TOP)
16976  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
16977  bd5.pack(side=LEFT)
16978  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
16979  bd6.pack(side=LEFT)
16980 
16981  LVSrange = Frame( frame2bp )
16982  LVSrange.pack(side=TOP)
16983  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
16984  bd7.pack(side=LEFT)
16985  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
16986  bd8.pack(side=LEFT)
16987 
16988  PhaseCenter = Frame( frame2bp )
16989  PhaseCenter.pack(side=TOP)
16990  PhCenlab = Label(PhaseCenter, text="Center Phase on")
16991  PhCenlab.pack(side=LEFT)
16992  PhCenBodeEntry = Entry(PhaseCenter, width=5)
16993  PhCenBodeEntry.bind('<Return>', onTextKey)
16994  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
16995  PhCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
16996  PhCenBodeEntry.bind("<Button-5>", onTextScroll)
16997  PhCenBodeEntry.bind('<Key>', onTextKey)
16998  PhCenBodeEntry.pack(side=LEFT)
16999  PhCenBodeEntry.delete(0,"end")
17000  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
17001  #
17002  ImpedCenter = Frame( frame2bp )
17003  ImpedCenter.pack(side=TOP)
17004  ImCenlab = Label(ImpedCenter, text="Center Imped on")
17005  ImCenlab.pack(side=LEFT)
17006  ImCenBodeEntry = Entry(ImpedCenter, width=5)
17007  ImCenBodeEntry.bind('<Return>', onTextKey)
17008  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
17009  ImCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
17010  ImCenBodeEntry.bind("<Button-5>", onTextScroll)
17011  ImCenBodeEntry.bind('<Key>', onTextKey)
17012  ImCenBodeEntry.pack(side=LEFT)
17013  ImCenBodeEntry.delete(0,"end")
17014  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
17015  # sweep generator mode menu buttons
17016  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
17017  FSweepmenu.pack(side=TOP)
17018 
17019  Frange1 = Frame( frame2bp )
17020  Frange1.pack(side=TOP)
17021  startfreqlab = Label(Frange1, text="Startfreq")
17022  startfreqlab.pack(side=LEFT)
17023  StartBodeEntry = Entry(Frange1, width=5)
17024  StartBodeEntry.bind('<Return>', onTextKey)
17025  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
17026  StartBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
17027  StartBodeEntry.bind("<Button-5>", onTextScroll)
17028  StartBodeEntry.bind('<Key>', onTextKey)
17029  StartBodeEntry.pack(side=LEFT)
17030  StartBodeEntry.delete(0,"end")
17031  StartBodeEntry.insert(0,10)
17032 
17033  Frange2 = Frame( frame2bp )
17034  Frange2.pack(side=TOP)
17035  stopfreqlab = Label(Frange2, text="Stopfreq")
17036  stopfreqlab.pack(side=LEFT)
17037  StopBodeEntry = Entry(Frange2, width=5)
17038  StopBodeEntry.bind('<Return>', onTextKey)
17039  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
17040  StopBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
17041  StopBodeEntry.bind("<Button-5>", onTextScroll)
17042  StopBodeEntry.bind('<Key>', onTextKey)
17043  StopBodeEntry.pack(side=LEFT)
17044  StopBodeEntry.delete(0,"end")
17045  StopBodeEntry.insert(0,10000)
17046 
17047  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
17048  sgrb1.pack(side=TOP)
17049  Frange4 = Frame( frame2bp )
17050  Frange4.pack(side=TOP)
17051  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
17052  sgrb2.pack(side=LEFT)
17053  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
17054  sgrb3.pack(side=LEFT)
17055  if MinigenScreenStatus.get() > 0:
17056  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
17057  sgrb1.pack(side=TOP)
17058  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
17059  ffcb.pack(side=TOP)
17060  Frange3 = Frame( frame2bp )
17061  Frange3.pack(side=TOP)
17062  sweepsteplab = Label(Frange3, text="Sweep Steps")
17063  sweepsteplab.pack(side=LEFT)
17064  SweepStepBodeEntry = Entry(Frange3, width=5)
17065  SweepStepBodeEntry.bind('<Return>', onTextKey)
17066  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
17067  SweepStepBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
17068  SweepStepBodeEntry.bind("<Button-5>", onTextScroll)
17069  SweepStepBodeEntry.bind('<Key>', onTextKey)
17070  SweepStepBodeEntry.pack(side=LEFT)
17071  SweepStepBodeEntry.delete(0,"end")
17072  SweepStepBodeEntry.insert(0,100)
17073 
17074  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
17075  sgrb5.pack(side=TOP)
17076  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
17077  sgrb6.pack(side=TOP)
17078  Plotsframe = Frame( frame2bp )
17079  Plotsframe.pack(side=TOP)
17080  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
17081  nyquistplotbutton.pack(side=LEFT)
17082  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
17083  nicholsplotbutton.pack(side=LEFT)
17084  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
17085  bodismiss1button.pack(side=TOP)
17086 
17087  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
17088  ADI2.pack(side=TOP)
17089  if ShowBallonHelp > 0:
17090  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
17091  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
17092  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
17093  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
17094  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
17095  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
17096  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
17097  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
17098  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
17099 #
17101  global bodewindow, BodeScreenStatus, ca, FSweepMode
17102 
17103  BodeScreenStatus.set(0)
17104  FSweepMode.set(0)
17105  BodeDisp.set(0)
17106  BodeCheckBox()
17107  bodewindow.destroy()
17108  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
17109 #
17110 def FreqCaresize(event):
17111  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
17112 
17113  CANVASwidthF = event.width - 4
17114  CANVASheightF = event.height - 4
17115  GRWF = CANVASwidthF - (2 * X0LF) # new grid width
17116  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
17117  UpdateFreqAll()
17118 #
17119 # ================ Make spectrum sub window ==========================
17121  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
17122  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp
17123  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA
17124  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate
17125  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
17126  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
17127 
17128  if SpectrumScreenStatus.get() == 0:
17129  SpectrumScreenStatus.set(1)
17130  FreqDisp.set(1)
17131  FreqCheckBox()
17132  CANVASwidthF = GRWF + 2 * X0LF # The spectrum canvas width
17133  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
17134  freqwindow = Toplevel()
17135  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
17136  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
17137  frame2fr = Frame(freqwindow, borderwidth=5, relief=RIDGE)
17138  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
17139 
17140  frame2f = Frame(freqwindow, borderwidth=5, relief=RIDGE)
17141  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
17142 
17143  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
17144  Freqca.bind('<Configure>', FreqCaresize)
17145  Freqca.bind('<1>', onCanvasFreqLeftClick)
17146  Freqca.bind('<3>', onCanvasFreqRightClick)
17147  Freqca.bind("<Up>", onCanvasUpArrow)
17148  Freqca.bind("<Down>", onCanvasDownArrow)
17149  Freqca.bind("<Left>", onCanvasLeftArrow)
17150  Freqca.bind("<Right>", onCanvasRightArrow)
17151  Freqca.bind("<space>", onCanvasSpaceBar)
17152  Freqca.bind("1", onCanvasSAOne)
17153  Freqca.bind("2", onCanvasSATwo)
17154  Freqca.bind("3", onCanvasSAThree)
17155  Freqca.bind("4", onCanvasSAFour)
17156  Freqca.bind("5", onCanvasSAFive)
17157  Freqca.bind("6", onCanvasSASix)
17158  Freqca.bind("7", onCanvasSASeven)
17159  Freqca.bind("8", onCanvasSAEight)
17160  Freqca.bind("9", onCanvasSANine)
17161  Freqca.bind("0", onCanvasSAZero)
17162  Freqca.bind("a", onCanvasSAAverage)
17163  Freqca.bind("n", onCanvasSANormal)
17164  Freqca.bind("p", onCanvasSAPeak)
17165  Freqca.bind("r", onCanvasSAReset)
17166  Freqca.bind("f", onCanvasShowFcur)
17167  Freqca.bind("d", onCanvasShowdBcur)
17168  Freqca.bind("h", onCanvasShowPcur)
17169  Freqca.bind("s", onCanvasSASnap)
17170  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
17171  # right side drop down menu buttons
17172  dropmenu = Frame( frame2fr )
17173  dropmenu.pack(side=TOP)
17174  # File menu
17175  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
17176  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
17177  SAFilemenu["menu"] = SAFilemenu.menu
17178  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
17179  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
17180  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
17181  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
17182  SAFilemenu.pack(side=LEFT, anchor=W)
17183  #
17184  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
17185  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
17186  SAOptionmenu["menu"] = SAOptionmenu.menu
17187  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
17188  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
17189  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
17190  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
17191  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
17192  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
17193  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
17194  SAOptionmenu.pack(side=LEFT, anchor=W)
17195  #
17196  RUNframe = Frame( frame2fr )
17197  RUNframe.pack(side=TOP)
17198  rb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
17199  rb.pack(side=LEFT)
17200  sb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
17201  sb.pack(side=LEFT)
17202  #
17203  Modeframe = Frame( frame2fr )
17204  Modeframe.pack(side=TOP)
17205  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
17206  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
17207  Modemenu["menu"] = Modemenu.menu
17208  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
17209  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
17210  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
17211  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
17212  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
17213  Modemenu.pack(side=LEFT)
17214  #
17215  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
17216  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
17217  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
17218  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
17219  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
17220  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
17221  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
17222  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
17223  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
17224  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
17225  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
17226  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
17227  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
17228  SAFFTwindmenu.pack(side=LEFT)
17229  #
17230  SamplesMenu = Frame( frame2fr )
17231  SamplesMenu.pack(side=TOP)
17232  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
17233  bless.pack(side=LEFT)
17234  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
17235  bmore.pack(side=LEFT)
17236  #
17237  # Show channels menu
17238  ShowC1_VdB = IntVar(0) # curves to display variables
17239  ShowC1_P = IntVar(0)
17240  ShowC2_VdB = IntVar(0)
17241  ShowC2_P = IntVar(0)
17242  ShowMarker = IntVar(0)
17243  ShowRA_VdB = IntVar(0)
17244  ShowRA_P = IntVar(0)
17245  ShowRB_VdB = IntVar(0)
17246  ShowRB_P = IntVar(0)
17247  ShowMathSA = IntVar(0)
17248  ShowRMath = IntVar(0)
17249  #
17250  MarkersMenu = Frame( frame2fr )
17251  MarkersMenu.pack(side=TOP)
17252  SAShowmenu = Menubutton(MarkersMenu, text="Curves", style="W7.TButton")
17253  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
17254  SAShowmenu["menu"] = SAShowmenu.menu
17255  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
17256  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
17257  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
17258  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
17259  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
17260  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
17261  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
17262  SAShowmenu.menu.add_command(label="-Math-", command=donothing)
17263  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
17264  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
17265  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
17266  SAShowmenu.menu.add_command(label="-Ref Trace-", command=donothing)
17267  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
17268  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
17269  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
17270  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
17271  SAShowmenu.menu.add_checkbutton(label='Ref Math', variable=ShowRMath, command=UpdateFreqAll)
17272  SAShowmenu.pack(side=LEFT)
17273  SACursormenu = Menubutton(MarkersMenu, text="Cursors", style="W7.TButton")
17274  SACursormenu.menu = Menu(SACursormenu, tearoff = 0 )
17275  SACursormenu["menu"] = SACursormenu.menu
17276  SACursormenu.menu.add_command(label="-Marker-", command=donothing)
17277  SACursormenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
17278  SACursormenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
17279  SACursormenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
17280  SACursormenu.menu.add_command(label="-Cursors-", command=donothing)
17281  SACursormenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
17282  SACursormenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
17283  SACursormenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
17284  SACursormenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
17285  SACursormenu.pack(side=LEFT)
17286  # HScale
17287  Frange1 = Frame( frame2fr )
17288  Frange1.pack(side=TOP)
17289  startfreqlab = Label(Frange1, text="Startfreq")
17290  startfreqlab.pack(side=LEFT)
17291  StartFreqEntry = Entry(Frange1, width=5)
17292  StartFreqEntry.bind('<Return>', onTextKey)
17293  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
17294  StartFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
17295  StartFreqEntry.bind("<Button-5>", onTextScroll)
17296  StartFreqEntry.bind('<Key>', onTextKey)
17297  StartFreqEntry.pack(side=LEFT)
17298  StartFreqEntry.delete(0,"end")
17299  StartFreqEntry.insert(0,10)
17300 
17301  Frange2 = Frame( frame2fr )
17302  Frange2.pack(side=TOP)
17303  stopfreqlab = Label(Frange2, text="Stopfreq")
17304  stopfreqlab.pack(side=LEFT)
17305  StopFreqEntry = Entry(Frange2, width=7)
17306  StopFreqEntry.bind('<Return>', onTextKey)
17307  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
17308  StopFreqEntry.bind("<Button-4>", onStopfreqScroll)# with Linux OS
17309  StopFreqEntry.bind("<Button-5>", onStopfreqScroll)
17310  StopFreqEntry.bind('<Key>', onTextKey)
17311  StopFreqEntry.pack(side=LEFT)
17312  StopFreqEntry.delete(0,"end")
17313  StopFreqEntry.insert(0,10000)
17314 
17315  HScale = IntVar(0)
17316  HzScale = Frame( frame2fr )
17317  HzScale.pack(side=TOP)
17318  rb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
17319  rb1.pack(side=LEFT)
17320  rb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
17321  rb2.pack(side=LEFT)
17322  #
17323  PhaseCenter = Frame( frame2fr )
17324  PhaseCenter.pack(side=TOP)
17325  PhCenlab = Label(PhaseCenter, text="Center Phase on")
17326  PhCenlab.pack(side=LEFT)
17327  PhCenFreqEntry = Entry(PhaseCenter, width=5)
17328  PhCenFreqEntry.bind('<Return>', onTextKey)
17329  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
17330  PhCenFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
17331  PhCenFreqEntry.bind("<Button-5>", onTextScroll)
17332  PhCenFreqEntry.bind('<Key>', onTextKey)
17333  PhCenFreqEntry.pack(side=LEFT)
17334  PhCenFreqEntry.delete(0,"end")
17335  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
17336  #
17337  DBrange = Frame( frame2fr )
17338  DBrange.pack(side=TOP)
17339  b3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
17340  b3.pack(side=LEFT)
17341  b4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
17342  b4.pack(side=LEFT)
17343 
17344  LVBrange = Frame( frame2fr )
17345  LVBrange.pack(side=TOP)
17346  b5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
17347  b5.pack(side=LEFT)
17348  b6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
17349  b6.pack(side=LEFT)
17350 
17351  LVSrange = Frame( frame2fr )
17352  LVSrange.pack(side=TOP)
17353  b7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
17354  b7.pack(side=LEFT)
17355  b8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
17356  b8.pack(side=LEFT)
17357 
17358  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
17359  sadismiss1button.pack(side=TOP)
17360 
17361  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
17362  ADI2.pack(side=TOP)
17363  if ShowBallonHelp > 0:
17364  sb_tip = CreateToolTip(sb, 'Stop acquiring data')
17365  rb_tip = CreateToolTip(rb, 'Start acquiring data')
17366  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
17367  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
17368  b3_tip = CreateToolTip(b3, 'Increase number of dB/Div')
17369  b4_tip = CreateToolTip(b4, 'Decrease number of dB/Div')
17370  b5_tip = CreateToolTip(b5, 'Increase Ref Level by 10 dB')
17371  b6_tip = CreateToolTip(b6, 'Decrease Ref Level by 10 dB')
17372  b7_tip = CreateToolTip(b7, 'Increase Ref Level by 1 dB')
17373  b8_tip = CreateToolTip(b8, 'Decrease Ref Level by 1 dB')
17374  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
17375 
17377  global freqwindow, SpectrumScreenStatus, ca
17378 
17379  SpectrumScreenStatus.set(0)
17380  FreqDisp.set(0)
17381  FreqCheckBox()
17382  freqwindow.destroy()
17383  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
17384 #
17385 def XYcaresize(event):
17386  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
17387  global YminXY, YmaxXY, XminXY, XmaxXY
17388 
17389  CANVASwidthXY = event.width - 4
17390  CANVASheightXY = event.height - 4
17391  GRWXY = CANVASwidthXY - int(2.25 * FontSize) - X0LXY # 18 new grid width
17392  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
17393  YminXY = Y0TXY # Minimum position of time grid (top)
17394  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
17395  XminXY = X0LXY # Minimum position of time grid (left)
17396  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
17397  UpdateXYAll()
17398 #
17399 # ================ Make XY Plot sub window ==========================
17401  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, Ysignal, ShowRXY
17402  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
17403  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
17404  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
17405  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
17406 
17407  if XYScreenStatus.get() == 0:
17408  XYScreenStatus.set(1)
17409  XYDisp.set(1)
17410  XYCheckBox()
17411  YminXY = Y0TXY # Minimum position of XY grid (top)
17412  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
17413  XminXY = X0LXY # Minimum position of XY grid (left)
17414  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
17415  CANVASwidthXY = GRWXY + 18 + X0LXY # The XY canvas width
17416  CANVASheightXY = GRHXY + 80 # The XY canvas height
17417  xywindow = Toplevel()
17418  xywindow.title("X-Y Plot " + SWRev + RevDate)
17419  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
17420  frame2xyr = Frame(xywindow, borderwidth=5, relief=RIDGE)
17421  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
17422 
17423  frame2xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
17424  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
17425 
17426  frame3xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
17427  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
17428 
17429  frame4xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
17430  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
17431 
17432  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
17433  XYca.bind('<Configure>', XYcaresize)
17434  XYca.bind('<1>', onCanvasXYLeftClick)
17435  XYca.bind('<3>', onCanvasXYRightClick)
17436  XYca.bind("<Motion>",onCanvasMouse_xy)
17437  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
17438  XYca.bind("<Button-4>", onCanvasXYScrollClick)# with Linux OS
17439  XYca.bind("<Button-5>", onCanvasXYScrollClick)
17440  XYca.bind("<Up>", onCanvasUpArrow)
17441  XYca.bind("<Down>", onCanvasDownArrow)
17442  XYca.bind("<Left>", onCanvasLeftArrow)
17443  XYca.bind("<Right>", onCanvasRightArrow)
17444  XYca.bind("<space>", onCanvasSpaceBar)
17445  XYca.bind("a", onCanvasAverage)
17446  XYca.pack(side=TOP, fill=BOTH, expand=YES)
17447  #
17448  RUNframe = Frame( frame2xyr )
17449  RUNframe.pack(side=TOP)
17450  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
17451  rbxy.pack(side=LEFT)
17452  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
17453  sbxy.pack(side=LEFT)
17454  # Open Math trace menu
17455  mathbt = Button(frame2xyr, text="Math", style="W5.TButton", command = NewEnterMathControls)
17456  mathbt.pack(side=TOP) #, anchor=W)
17457  # Disply mode menu
17458  # X - Y mode signal select
17459  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
17460  AxisLabX.pack(side=TOP)
17461  chaxmenu = Frame( frame2xyr )
17462  chaxmenu.pack(side=TOP)
17463  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
17464  rbx2.pack(side=LEFT, anchor=W)
17465  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
17466  rbx3.pack(side=LEFT, anchor=W)
17467  chbxmenu = Frame( frame2xyr )
17468  chbxmenu.pack(side=TOP)
17469  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
17470  rbx4.pack(side=LEFT, anchor=W)
17471  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
17472  rbx5.pack(side=LEFT, anchor=W)
17473  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
17474  rbx7.pack(side=TOP)
17475  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
17476  rbx8.pack(side=TOP)
17477  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
17478  rbx6.pack(side=TOP)
17479  #
17480  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
17481  AxisLabY.pack(side=TOP)
17482  chaymenu = Frame( frame2xyr )
17483  chaymenu.pack(side=TOP)
17484  rby2 = Radiobutton(chaymenu, text='CA-V', variable=Ysignal, value=1, command=UpdateXYTrace)
17485  rby2.pack(side=LEFT, anchor=W)
17486  rby3 = Radiobutton(chaymenu, text='CA-I', variable=Ysignal, value=2, command=UpdateXYTrace)
17487  rby3.pack(side=LEFT, anchor=W)
17488  chbymenu = Frame( frame2xyr )
17489  chbymenu.pack(side=TOP)
17490  rby4 = Radiobutton(chbymenu, text='CB-V', variable=Ysignal, value=3, command=UpdateXYTrace)
17491  rby4.pack(side=LEFT, anchor=W)
17492  rby5 = Radiobutton(chbymenu, text='CB-I', variable=Ysignal, value=4, command=UpdateXYTrace)
17493  rby5.pack(side=LEFT, anchor=W)
17494  rby6 = Radiobutton(frame2xyr, text='Math', variable=Ysignal, value=5, command=UpdateXYTrace)
17495  rby6.pack(side=TOP)
17496  # show cursor menu buttons
17497  cursormenu = Frame( frame2xyr )
17498  cursormenu.pack(side=TOP)
17499  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
17500  cb1.pack(side=LEFT, anchor=W)
17501  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
17502  cb2.pack(side=LEFT, anchor=W)
17503  cb3 = Checkbutton(frame2xyr, text='RX-Y', variable=ShowRXY, command=UpdateXYTrace)
17504  cb3.pack(side=TOP)
17505  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
17506  cb4.pack(side=TOP)
17507  #
17508  snapbutton = Button(frame2xyr, style="W11.TButton", text="SnapShot", command=BSnapShot)
17509  snapbutton.pack(side=TOP)
17510  savebutton = Button(frame2xyr, style="W11.TButton", text="Save Screen", command=BSaveScreenXY)
17511  savebutton.pack(side=TOP)
17512  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
17513  dismissxybutton.pack(side=TOP)
17514  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
17515  ADI1xy.pack(side=TOP)
17516 
17517  # Bottom Buttons
17518  MarkerXYScale = IntVar(0)
17519  MarkerXYScale.set(1)
17520  # Voltage channel A
17521  CHAsbxy = Spinbox(frame3xy, width=4, values=CHvpdiv)
17522  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
17523  CHAsbxy.pack(side=LEFT)
17524  CHAsbxy.delete(0,"end")
17525  CHAsbxy.insert(0,0.5)
17526  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
17527  CHAxylab.pack(side=LEFT)
17528 
17529  CHAVPosEntryxy = Entry(frame3xy, width=5)
17530  CHAVPosEntryxy.bind('<Return>', onTextKey)
17531  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
17532  CHAVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
17533  CHAVPosEntryxy.bind("<Button-5>", onTextScroll)
17534  CHAVPosEntryxy.bind('<Key>', onTextKey)
17535  CHAVPosEntryxy.pack(side=LEFT)
17536  CHAVPosEntryxy.delete(0,"end")
17537  CHAVPosEntryxy.insert(0,2.5)
17538  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
17539  CHAofflabxy.pack(side=LEFT)
17540  # Current channel A
17541  CHAIsbxy = Spinbox(frame3xy, width=4, values=CHipdiv)
17542  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
17543  CHAIsbxy.pack(side=LEFT)
17544  CHAIsbxy.delete(0,"end")
17545  CHAIsbxy.insert(0,50.0)
17546  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
17547  CHAIlabxy.pack(side=LEFT)
17548 
17549  CHAIPosEntryxy = Entry(frame3xy, width=5)
17550  CHAIPosEntryxy.bind('<Return>', onTextKey)
17551  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
17552  CHAIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
17553  CHAIPosEntryxy.bind("<Button-5>", onTextScroll)
17554  CHAIPosEntryxy.bind('<Key>', onTextKey)
17555  CHAIPosEntryxy.pack(side=LEFT)
17556  CHAIPosEntryxy.delete(0,"end")
17557  CHAIPosEntryxy.insert(0,0.0)
17558  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
17559  CHAIofflabxy.pack(side=LEFT)
17560  # Voltage channel B
17561  CHBsbxy = Spinbox(frame4xy, width=4, values=CHvpdiv)
17562  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
17563  CHBsbxy.pack(side=LEFT)
17564  CHBsbxy.delete(0,"end")
17565  CHBsbxy.insert(0,0.5)
17566  #
17567  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
17568  CHBxylab.pack(side=LEFT)
17569 
17570  CHBVPosEntryxy = Entry(frame4xy, width=5)
17571  CHBVPosEntryxy.bind('<Return>', onTextKey)
17572  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
17573  CHBVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
17574  CHBVPosEntryxy.bind("<Button-5>", onTextScroll)
17575  CHBVPosEntryxy.bind('<Key>', onTextKey)
17576  CHBVPosEntryxy.pack(side=LEFT)
17577  CHBVPosEntryxy.delete(0,"end")
17578  CHBVPosEntryxy.insert(0,2.5)
17579  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
17580  CHBofflabxy.pack(side=LEFT)
17581  # Current channel B
17582  CHBIsbxy = Spinbox(frame4xy, width=4, values=CHipdiv) #
17583  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
17584  CHBIsbxy.pack(side=LEFT)
17585  CHBIsbxy.delete(0,"end")
17586  CHBIsbxy.insert(0,50.0)
17587  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
17588  CHBIlabxy.pack(side=LEFT)
17589 
17590  CHBIPosEntryxy = Entry(frame4xy, width=5)
17591  CHBIPosEntryxy.bind('<Return>', onTextKey)
17592  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
17593  CHBIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
17594  CHBIPosEntryxy.bind("<Button-5>", onTextScroll)
17595  CHBIPosEntryxy.bind('<Key>', onTextKey)
17596  CHBIPosEntryxy.pack(side=LEFT)
17597  CHBIPosEntryxy.delete(0,"end")
17598  CHBIPosEntryxy.insert(0,0.0)
17599  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
17600  CHBIofflabxy.pack(side=LEFT)
17601  #
17602  if ShowBallonHelp > 0:
17603  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
17604  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
17605  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
17606  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
17607  math_tip = CreateToolTip(mathbt, 'Open Math window')
17608  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
17609  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
17610  snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
17611  savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
17612  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
17613  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
17614  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
17615  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
17616  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
17617  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
17618  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
17619 
17621  global xywindow, XYScreenStatus, ca, XYDisp
17622 
17623  XYScreenStatus.set(0)
17624  XYDisp.set(0)
17625  XYCheckBox()
17626  xywindow.destroy()
17627  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
17628 #
17629 # Optional Calibration procedure routine
17630 #
17632  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
17633  global discontloop, contloop, session, AWGSync, SWRev
17634  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
17635  # setup cal results window
17636  if FWRevOne < 2.06: # Check firmware revision level > 2.06
17637  showwarning("WARNING","Out of date Firmware Revision!")
17638  return
17639  calwindow = Toplevel()
17640  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
17641  # display wigets
17642  prlab = Label(calwindow, text="Channel Gain / Offset calibration")
17643  prlab.grid(row=0, column=0, columnspan=2, sticky=W)
17644  labelA0 = Label(calwindow, style="A12B.TLabel")
17645  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
17646  labelA0.config(text = "CA gnd Volts")
17647  labelAMax = Label(calwindow, style="A12B.TLabel")
17648  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
17649  labelAMax.config(text = "CA 584 Volts")
17650  labelAMin = Label(calwindow, style="A12B.TLabel")
17651  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
17652  labelAMin.config(text = "CA 5V Src I ")
17653  labelB0 = Label(calwindow, style="A12B.TLabel")
17654  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
17655  labelB0.config(text = "CA gnd Volts")
17656  labelBMax = Label(calwindow, style="A12B.TLabel")
17657  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
17658  labelBMax.config(text = "CB 584 Volts")
17659  labelBMin = Label(calwindow, style="A12B.TLabel")
17660  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
17661  labelBMin.config(text = "CB 5V Src I ")
17662  labelAB = Label(calwindow, style="A12B.TLabel")
17663  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
17664  labelAB.config(text = "CA 0V Src I")
17665  labelBA = Label(calwindow, style="A12B.TLabel")
17666  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
17667  labelBA.config(text = "CA 0V Src I")
17668  labelSIA0 = Label(calwindow, style="A12B.TLabel")
17669  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
17670  labelSIA0.config(text = "CA 2.5 Src 0 I")
17671  labelSIA = Label(calwindow, style="A12B.TLabel")
17672  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
17673  labelSIA.config(text = "CA 50 Src 100 ")
17674  labelSIAN = Label(calwindow, style="A12B.TLabel")
17675  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
17676  labelSIAN.config(text = "CA 50 Src -45")
17677  labelSIB0 = Label(calwindow, style="A12B.TLabel")
17678  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
17679  labelSIB0.config(text = "CB 2.5 Src 0 I")
17680  labelSIB = Label(calwindow, style="A12B.TLabel")
17681  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
17682  labelSIB.config(text = "CB 50 Src 100 ")
17683  labelSIBN = Label(calwindow, style="A12B.TLabel")
17684  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
17685  labelSIBN.config(text = "CB 50 Src -45")
17686  # set to default mux and dac settings
17687  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
17688  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
17689  AWGSync.set(1)
17690  BAWGSync()
17691  if session.continuous:
17692  print( "ending session")
17693  session.end()
17694  # Setup ADALM1000
17695  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
17696  #print(devx.calibration)
17697  try:
17698  devx.write_calibration("calib_default.txt")
17699  #print "wrote calib_default.txt"
17700  except:
17701  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
17702  devx.write_calibration(filename)
17703  #print(devx.calibration)
17704  #
17705  devidstr = DevID[17:31]
17706  filename = "calib" + devidstr + ".txt"
17707  if os.path.isfile(filename):
17708  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
17709  devx.write_calibration(filename)
17710  #print "wrote old ", filename
17711  calwindow.destroy()
17712  return
17713  else:
17714  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
17715  donothing()
17716  else:
17717  calwindow.destroy()
17718  return
17719  #
17720  CalFile = open(filename, "w")
17721  #
17722  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
17723  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
17724  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
17725  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
17726  ADsignal1 = [] # Ain signal array channel
17727  ADsignal1 = devx.get_samples(1010)
17728  # Pause whie user connects external voltage reference AD584
17729  BadData = 1
17730  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
17731  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
17732  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
17733  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
17734  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
17735  try:
17736  AD584act = float(RequestVRef)*1.0
17737  except:
17738  AD584act = 3.3
17739  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
17740  while (BadData): # loop till good reading
17741  # Get A and B AD584 data
17742  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
17743  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
17744  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17745  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
17746  # get_samples returns a list of values for voltage [0] and current [1]
17747  for index in range(1000): # calculate average
17748  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17749  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17750 
17751  CHA584Raw = CHA584Raw / 1000.0 # calculate average
17752  CHB584Raw = CHB584Raw / 1000.0 # calculate average
17753  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
17754  labelAMax.config(text = VString) # change displayed value
17755  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
17756  labelBMax.config(text = VString) # change displayed value
17757  Lower = AD584act - 0.3
17758  Upper = AD584act + 0.3
17759  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
17760  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
17761  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
17762  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
17763  contloop = 0
17764  discontloop = 1
17765  calwindow.destroy()
17766  return
17767  else:
17768  BadData = 0
17769  #
17770  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
17771  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
17772  # Get A GND and B GND data
17773  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
17774  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
17775  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
17776  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
17777  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
17778  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
17779  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17780  # get_samples returns a list of values for voltage [0] and current [1]
17781  for index in range(1000): # calculate average
17782  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17783  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17784  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
17785  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
17786 
17787  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
17788  CHAI0gRaw = CHAI0gRaw / 1000.0
17789  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
17790  CHBI0gRaw = CHBI0gRaw / 1000.0
17791  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
17792  labelA0.config(text = VString) # change displayed value
17793  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
17794  labelB0.config(text = VString) # change displayed value
17795  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
17796  # Get A and B data for internal 2.5 rail
17797  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
17798  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
17799  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
17800  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
17801  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
17802  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
17803  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17804  # get_samples returns a list of values for voltage [0] and current [1]
17805  for index in range(1000): # calculate average
17806  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17807  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17808  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
17809  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
17810 
17811  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
17812  CHAI02p5Raw = CHAI02p5Raw / 1000.0
17813  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
17814  CHBI02p5Raw = CHBI02p5Raw / 1000.0
17815  # Get A force 0V and B force 0V data
17816  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
17817  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
17818  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
17819  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
17820  CHA.mode = Mode.SVMI
17821  CHA.constant(0.0)
17822  CHB.mode = Mode.SVMI
17823  CHB.constant(0.0)
17824  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17825  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
17826  # get_samples returns a list of values for voltage [0] and current [1]
17827  for index in range(1000): # calculate average
17828  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17829  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17830  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
17831  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
17832 
17833  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
17834  CHAI0F0Raw = CHAI0F0Raw / 1000.0
17835  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
17836  CHBI0F0Raw = CHBI0F0Raw / 1000.0
17837  # Get A force 2.5V and B force 2.5V data
17838  CHA.mode = Mode.SVMI
17839  CHA.constant(4.5)
17840  CHB.mode = Mode.SVMI
17841  CHB.constant(4.5)
17842  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17843  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
17844  # get_samples returns a list of values for voltage [0] and current [1]
17845  for index in range(1000): # calculate average
17846  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17847  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17848  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
17849  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
17850 
17851  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
17852  CHAI0F25Raw = CHAI0F25Raw / 1000.0
17853  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
17854  CHBI0F25Raw = CHBI0F25Raw / 1000.0
17855  #
17856  # Get A and B measure current data for int 50 res to gnd at 5V
17857  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
17858  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
17859  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
17860  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
17861  CHA.mode = Mode.SVMI
17862  CHA.constant(5.0)
17863  CHB.mode = Mode.SVMI
17864  CHB.constant(5.0)
17865  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17866  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
17867  for index in range(1000): # calculate average
17868  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17869  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17870  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
17871  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
17872 
17873  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
17874  CHAISr5vRaw = CHAISr5vRaw / 1000.0
17875  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
17876  CHBISr5vRaw = CHBISr5vRaw / 1000.0
17877  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
17878  labelAMin.config(text = VString) # change displayed value
17879  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
17880  labelBMin.config(text = VString) # change displayed value
17881  # Get A and B measure current data for int 50 res to 2.5 V at 0V
17882  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
17883  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
17884  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
17885  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
17886  CHA.mode = Mode.SVMI
17887  CHA.constant(0.001)
17888  CHB.mode = Mode.SVMI
17889  CHB.constant(0.001)
17890  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17891  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
17892  for index in range(1000): # calculate average
17893  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17894  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17895  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
17896  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
17897 
17898  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
17899  CHAISr0vRaw = CHAISr0vRaw / 1000.0
17900  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
17901  CHBISr0vRaw = CHBISr0vRaw / 1000.0
17902  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
17903  labelAB.config(text = VString) # change displayed value
17904  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
17905  labelBA.config(text = VString) # change displayed value
17906 
17907  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
17908  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
17909  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
17910  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
17911  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
17912  CHA.mode = Mode.SIMV
17913  CHA.constant(0.0)
17914  CHB.mode = Mode.SIMV
17915  CHB.constant(0.0)
17916  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17917  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
17918  for index in range(1000): # calculate average
17919  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17920  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17921  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
17922  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
17923 
17924  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
17925  CHAISr0iRaw = CHAISr0iRaw / 1000.0
17926  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
17927  CHBISr0iRaw = CHBISr0iRaw / 1000.0
17928  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
17929  labelSIA0.config(text = VString) # change displayed value
17930  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
17931  labelSIB0.config(text = VString) # change displayed value
17932  #
17933  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
17934  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
17935  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
17936  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
17937  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
17938  CHA.mode = Mode.SIMV
17939  CHA.constant(0.045)
17940  CHB.mode = Mode.SIMV
17941  CHB.constant(0.045)
17942  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17943  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
17944  for index in range(1000): # calculate average
17945  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17946  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17947  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
17948  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
17949 
17950  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
17951  CHAISr100Raw = CHAISr100Raw / 1000.0
17952  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
17953  CHBISr100Raw = CHBISr100Raw / 1000.0
17954  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
17955  labelSIA.config(text = VString) # change displayed value
17956  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
17957  labelSIB.config(text = VString) # change displayed value
17958  #
17959  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
17960  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
17961  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
17962  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
17963  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
17964  CHA.mode = Mode.SIMV
17965  CHA.constant(-0.045)
17966  CHB.mode = Mode.SIMV
17967  CHB.constant(-0.045)
17968  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
17969  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
17970  for index in range(1000): # calculate average
17971  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
17972  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
17973  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
17974  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
17975 
17976  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
17977  CHAISrN45Raw = CHAISrN45Raw / 1000.0
17978  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
17979  CHBISrN45Raw = CHBISrN45Raw / 1000.0
17980  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
17981  labelSIAN.config(text = VString) # change displayed value
17982  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
17983  labelSIBN.config(text = VString) # change displayed value
17984  # return all switches to open
17985  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
17986  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
17987  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
17988  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
17989  # Caculate voltage gain errors
17990  #
17991  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
17992  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
17993  #
17994  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
17995  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
17996  #
17997  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
17998  # print "calculated fixed 2.5 from CHA ", CHA2p5
17999  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
18000  # print "calculated fixed 2.5 from CHB ", CHB2p5
18001  #
18002  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
18003  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
18004  #
18005  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
18006  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
18007  #
18008  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
18009  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
18010  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
18011  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
18012  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
18013  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
18014  #
18015  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
18016  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
18017  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
18018  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
18019  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
18020  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
18021  # Write cal factors to file
18022  #
18023  CalFile.write('# Channel A, measure V\n')
18024  CalFile.write('</>\n')
18025  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
18026  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
18027  CalFile.write('<>\n')
18028  CalFile.write('\n')
18029  #
18030  CalFile.write('# Channel A, measure I\n')
18031  CalFile.write('</>\n')
18032  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
18033  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
18034  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
18035  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
18036  CalFile.write('<>\n')
18037  CalFile.write('\n')
18038  #
18039  CalFile.write('# Channel A, source V\n')
18040  CalFile.write('</>\n')
18041  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
18042  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
18043  CalFile.write('<>\n')
18044  CalFile.write('\n')
18045  #
18046  CalFile.write('# Channel A, source I\n')
18047  CalFile.write('</>\n')
18048  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
18049  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
18050  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
18051  CalFile.write('<>\n')
18052  CalFile.write('\n')
18053  #
18054  CalFile.write('# Channel B, measure V\n')
18055  CalFile.write('</>\n')
18056  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
18057  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
18058  CalFile.write('<>\n')
18059  CalFile.write('\n')
18060  #
18061  CalFile.write('# Channel B, measure I\n')
18062  CalFile.write('</>\n')
18063  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
18064  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
18065  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
18066  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
18067  CalFile.write('<>\n')
18068  CalFile.write('\n')
18069  #
18070  CalFile.write('# Channel B, source V\n')
18071  CalFile.write('</>\n')
18072  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
18073  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
18074  CalFile.write('<>\n')
18075  CalFile.write('\n')
18076  #
18077  CalFile.write('# Channel B source I\n')
18078  CalFile.write('</>\n')
18079  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
18080  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
18081  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
18082  CalFile.write('<>\n')
18083  #
18084  CalFile.close()
18085  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
18086  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
18087  devx.write_calibration(filename)
18088  #print "wrote new " , filename
18089  #
18090  # session.end()
18091  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
18092  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
18093  contloop = 0
18094  discontloop = 1
18095  # session.cancel()
18096  calwindow.destroy()
18097 #
18099  global cal, DevID, devx
18100 
18101  devidstr = DevID[17:31]
18102  filename = "calib" + devidstr + "test.txt"
18103  if os.path.isfile(filename):
18104  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
18105  return
18106  else:
18107  if askyesno("Continue?", "Continure with save calibration file?"): #, parent=calwindow):
18108  donothing()
18109  else:
18110  calwindow.destroy()
18111  return
18112  #
18113  CalFile = open(filename, "w")
18114  #
18115  # Write cal factors to file
18116  # [0]
18117  CalFile.write('# Channel A, measure V\n')
18118  CalFile.write('</>\n')
18119  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
18120  CHAgp = (5.0/cal[0][1])+cal[0][0]
18121  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
18122  CalFile.write('<>\n')
18123  CalFile.write('\n')
18124  # [1]
18125  CalFile.write('# Channel A, measure I\n')
18126  CalFile.write('</>\n')
18127  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
18128  CHAgp = (0.1/cal[0][1])+cal[1][0]
18129  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
18130  CHAgn = (-0.1/cal[0][2])+cal[1][0]
18131  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
18132  CalFile.write('<>\n')
18133  CalFile.write('\n')
18134  # [2]
18135  CalFile.write('# Channel A, source V\n')
18136  CalFile.write('</>\n')
18137  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
18138  CHAgp = (5.0/cal[2][1])+cal[2][0]
18139  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
18140  CalFile.write('<>\n')
18141  CalFile.write('\n')
18142  # [3]
18143  CalFile.write('# Channel A, source I\n')
18144  CalFile.write('</>\n')
18145  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
18146  CHAgp = (0.1/cal[3][1])+cal[3][0]
18147  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
18148  CHAgn = (-0.1/cal[3][2])+cal[3][0]
18149  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
18150  CalFile.write('<>\n')
18151  CalFile.write('\n')
18152  # [4]
18153  CalFile.write('# Channel B, measure V\n')
18154  CalFile.write('</>\n')
18155  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
18156  CHAgp = (5.0/cal[4][1])+cal[4][0]
18157  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
18158  CalFile.write('<>\n')
18159  CalFile.write('\n')
18160  # [5]
18161  CalFile.write('# Channel B, measure I\n')
18162  CalFile.write('</>\n')
18163  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
18164  CHAgp = (0.1/cal[5][1])+cal[5][0]
18165  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
18166  CHAgn = (-0.1/cal[5][2])+cal[5][0]
18167  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
18168  CalFile.write('<>\n')
18169  CalFile.write('\n')
18170  # [6]
18171  CalFile.write('# Channel B, source V\n')
18172  CalFile.write('</>\n')
18173  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
18174  CHAgp = (5.0/cal[6][1])+cal[6][0]
18175  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
18176  CalFile.write('<>\n')
18177  CalFile.write('\n')
18178  # [7]
18179  CalFile.write('# Channel B source I\n')
18180  CalFile.write('</>\n')
18181  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
18182  CHAgp = (0.1/cal[7][1])+cal[7][0]
18183  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
18184  CHAgn = (-0.1/cal[7][2])+cal[7][0]
18185  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
18186  CalFile.write('<>\n')
18187  #
18188  CalFile.close()
18189 
18191 def SPIShiftOut(DValue):
18192  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
18193 
18194  binstr = bin(DValue)
18195  binlen = len(binstr)
18196  datastr = binstr[2:binlen]
18197  datalen = len(datastr)
18198  if datalen < 16:
18199  datastr = str.rjust(datastr , 16 , '0')
18200  datalen = len(datastr)
18201  i = 1
18202  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
18203  while i < datalen+1:
18204  # sending 0x50 = set to 0, 0x51 = set to 1
18205  D1code = 0x50 + int(datastr[i-1])
18206  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
18207  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
18208  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
18209  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
18210  i = i + 1
18211  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
18212 #
18213 def SetAD9833(temp):
18214  global FminEntry, HtMulEntry, MinigenFout, MinigenMode, etssrlab, EnableMinigenMode # , Fclk, Fout
18215  global Two28, mclk, EnableHSsampling, MinigenScreenStatus, ETSts, Two_X_Sample
18216 
18217  #
18218  if MinigenScreenStatus.get() == 0:
18219  #SRstring = "ET Sample Rate = " + str(SAMPLErate*MulX)
18220  #etssrlab.config(text=SRstring)
18221  return
18222  #
18223  if EnableMinigenMode == 2:
18224  MinigenMode.set(40)
18225  #
18226  try:
18227  FminE = float(eval(FminEntry.get()))*1000
18228  except:
18229  if EnableHSsampling > 0:
18230  FminEntry.delete(0,END)
18231  FminEntry.insert(0, FminE/1000)
18232  if MulX == 1:
18233  Fmin = FminE
18234  else:
18235  Fmin = FminE - (FminE/MulX)
18236  #
18237  MinigenFout.delete(0,"end")
18238  MinigenFout.insert(0,Fmin)
18239  #
18240  BSendMG()
18241 
18243 def BSendMG():
18244  global MinigenFclk, MinigenFout, MinigenMode
18245  global Two28, SCLKPort, SDATAPort, SLATCHPort
18246 
18247  DValue = 8192 + MinigenMode.get()
18248  SPIShiftOut(DValue)
18249  try:
18250  fout = float(eval(MinigenFout.get()))
18251  except:
18252  MinigenFout.delete(0,"end")
18253  MinigenFout.insert(0,100)
18254  try:
18255  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
18256  except:
18257  MingenFclk.delete(0,"end")
18258  MinigenFclk.insert(0,16)
18259  Freg = int((fout*Two28)/mclk)
18260  Foutstr = bin(Freg)
18261  Foutlen = len(Foutstr)
18262  datastr = Foutstr[2:Foutlen]
18263  datalen = len(datastr)
18264  if datalen < 28:
18265  datastr = str.rjust(datastr , 28 , '0')
18266  datalen = len(datastr)
18267  Fmsb = '0b01' + datastr[0:14]
18268  Flsb = '0b01' + datastr[14:]
18269  FValue = int(eval(Flsb))
18270  SPIShiftOut(FValue)
18271  FValue = int(eval(Fmsb))
18272  SPIShiftOut(FValue)
18273 
18276  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
18277  global SCLKPort, SDATAPort, SLATCHPort
18278  global GenericSerialStatus
18279  global PIO_0, PIO_1, PIO_2, PIO_3
18280 
18281  if GenericSerialStatus.get() == 1:
18282  GenericSerialStatus.set(0)
18284  if MinigenScreenStatus.get() == 0:
18285  MinigenScreenStatus.set(1)
18286  minigenwindow = Toplevel()
18287  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
18288  minigenwindow.resizable(FALSE,FALSE)
18289  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
18290  #
18291  MinigenMode = IntVar(0)
18292  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
18293  mgb1.grid(row=1, column=0, sticky=W)
18294  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
18295  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
18296  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
18297  mgb3.grid(row=2, column=0, sticky=W)
18298  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
18299  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
18300  f0lab = Label(minigenwindow, text="Mclk in MHz")
18301  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
18302  MinigenFclk = Entry(minigenwindow, width=5)
18303  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
18304  MinigenFclk.delete(0,"end")
18305  MinigenFclk.insert(0,16)
18306  f1lab = Label(minigenwindow, text="Output Freq")
18307  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
18308  MinigenFout = Entry(minigenwindow, width=8)
18309  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
18310  MinigenFout.bind("<Button-4>", onMiniGenScroll)# with Linux OS
18311  MinigenFout.bind("<Button-5>", onMiniGenScroll)
18312  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
18313  MinigenFout.delete(0,"end")
18314  MinigenFout.insert(0,100)
18315  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
18316  bsn1.grid(row=5, column=0, sticky=W, pady=4)
18317  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
18318  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
18319  #
18320  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
18321  label3.grid(row=6, column=0, sticky=W)
18322  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
18323  sclk1.grid(row=6, column=1, sticky=W)
18324  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
18325  sclk2.grid(row=6, column=2, sticky=W)
18326  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
18327  sclk3.grid(row=6, column=3, sticky=W)
18328  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
18329  sclk4.grid(row=6, column=4, sticky=W)
18330  #
18331  label4 = Label(minigenwindow,text="SData PI/O Port ")
18332  label4.grid(row=7, column=0, sticky=W)
18333  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
18334  sdat1.grid(row=7, column=1, sticky=W)
18335  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
18336  sdat2.grid(row=7, column=2, sticky=W)
18337  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
18338  sdat3.grid(row=7, column=3, sticky=W)
18339  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
18340  sdat4.grid(row=7, column=4, sticky=W)
18341  #
18342  label5 = Label(minigenwindow,text="FSync PI/O Port ")
18343  label5.grid(row=8, column=0, sticky=W)
18344  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
18345  slth1.grid(row=8, column=1, sticky=W)
18346  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
18347  slth2.grid(row=8, column=2, sticky=W)
18348  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
18349  slth3.grid(row=8, column=3, sticky=W)
18350  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
18351  slth4.grid(row=8, column=4, sticky=W)
18352  #
18353 
18356  global minigenwindow, MinigenScreenStatus
18357 
18358  MinigenScreenStatus.set(0)
18359  minigenwindow.destroy()
18360 #
18361 def onMiniGenScroll(event):
18362  global ETSStatus, ETSDisp
18363 
18364  onTextScroll(event)
18365  BSendMG()
18366 
18368 def DA1ShiftOut(D1Value, D2Value):
18369  global devx
18370  global PIO_0, PIO_1, PIO_2, PIO_3
18371 
18372  binstr = bin(D1Value)
18373  binlen = len(binstr)
18374  data1str = binstr[2:binlen]
18375  datalen = len(data1str)
18376  if datalen < 16:
18377  data1str = str.rjust(data1str , 16 , '0')
18378  datalen = len(data1str)
18379  #
18380  binstr = bin(D2Value)
18381  binlen = len(binstr)
18382  data2str = binstr[2:binlen]
18383  datalen = len(data2str)
18384  if datalen < 16:
18385  data2str = str.rjust(data2str , 16 , '0')
18386  datalen = len(data2str)
18387  # sync --> PIO 0
18388  # D0 --> PIO 1
18389  # D1 --> PIO 2
18390  # SCLK --> PIO 3
18391  i = 1
18392 #
18393  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
18394  while i < datalen+1:
18395  # sending 0x50 = set to 0, 0x51 = set to 1
18396  D1code = 0x50 + int(data1str[i-1])
18397  D2code = 0x50 + int(data2str[i-1])
18398  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
18399  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
18400  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
18401  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
18402  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
18403  i = i + 1
18404  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
18405  #
18406 def BSendDA1():
18407  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
18408 
18409  try:
18410  RefValue = float(eval(REFEntry.get()))
18411  except:
18412  RefValue = 3.3
18413  try:
18414  D1Value = float(eval(DAC1Entry.get()))
18415  except:
18416  D1Value = 0.0129
18417  D1Code = int((D1Value/RefValue)*255)
18418  if D1Code > 255:
18419  D1Code = 255
18420  D1Code = D1Code + 0x2000
18421  try:
18422  D2Value = float(eval(DAC2Entry.get()))
18423  except:
18424  D2Value = 0.0129
18425  D2Code = int((D2Value/RefValue)*255)
18426  if D2Code > 255:
18427  D2Code = 255
18428  D2Code = D2Code + 0x2400
18429  try:
18430  D3Value = float(eval(DAC3Entry.get()))
18431  except:
18432  D3Value = 0.0129
18433  D3Code = int((D3Value/RefValue)*255)
18434  if D3Code > 255:
18435  D3Code = 255
18436  D3Code = D3Code + 0x2000
18437  try:
18438  D4Value = float(eval(DAC4Entry.get()))
18439  except:
18440  D4Value = 0.0129
18441  D4Code = int((D4Value/RefValue)*255)
18442  if D4Code > 255:
18443  D4Code = 255
18444  D4Code = D4Code + 0x2400
18445  #
18446  DA1ShiftOut(D1Code, D3Code)
18447  DA1ShiftOut(D2Code, D4Code)
18448 
18451  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
18452  global REFEntry, RevDate, SWRev
18453 
18454  if DA1ScreenStatus.get() == 0:
18455  DA1ScreenStatus.set(1)
18456  da1window = Toplevel()
18457  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
18458  da1window.resizable(FALSE,FALSE)
18459  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
18460 #
18461  d1lab = Label(da1window, text="DAC A1 output")
18462  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
18463  DAC1Entry = Entry(da1window, width=5)
18464  DAC1Entry.grid(row=0, column=1, sticky=W)
18465  DAC1Entry.delete(0,"end")
18466  DAC1Entry.insert(0,0)
18467  d2lab = Label(da1window, text="DAC B1 output")
18468  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
18469  DAC2Entry = Entry(da1window, width=5)
18470  DAC2Entry.grid(row=1, column=1, sticky=W)
18471  DAC2Entry.delete(0,"end")
18472  DAC2Entry.insert(0,0)
18473 
18474  d3lab = Label(da1window, text="DAC A2 output")
18475  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
18476  DAC3Entry = Entry(da1window, width=5)
18477  DAC3Entry.grid(row=2, column=1, sticky=W)
18478  DAC3Entry.delete(0,"end")
18479  DAC3Entry.insert(0,0)
18480 
18481  d4lab = Label(da1window, text="DAC B2 output")
18482  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
18483  DAC4Entry = Entry(da1window, width=5)
18484  DAC4Entry.grid(row=3, column=1, sticky=W)
18485  DAC4Entry.delete(0,"end")
18486  DAC4Entry.insert(0,0)
18487 
18488  d5lab = Label(da1window, text="Reference V")
18489  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
18490  REFEntry = Entry(da1window, width=5)
18491  REFEntry.grid(row=4, column=1, sticky=W)
18492  REFEntry.delete(0,"end")
18493  REFEntry.insert(0,3.3)
18494 
18495  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
18496  bsn1.grid(row=5, column=0, sticky=W)
18497  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
18498  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
18499 
18502  global da1window, DA1ScreenStatus
18503 
18504  DA1ScreenStatus.set(0)
18505  da1window.destroy()
18506 
18507 def DigPotShiftOut(DValue):
18508  global devx, SingleDualPot
18509  global PIO_0, PIO_1, PIO_2, PIO_3
18510 
18511  binstr = bin(DValue)
18512  binlen = len(binstr)
18513  datastr = binstr[2:binlen]
18514  datalen = len(datastr)
18515  if SingleDualPot.get() == 0: # send 10 bits of data
18516  if datalen < 10:
18517  datastr = str.rjust(datastr , 10 , '0')
18518  datalen = len(datastr)
18519  if SingleDualPot.get() == 1: # send 8 bits of data
18520  if datalen < 8:
18521  datastr = str.rjust(datastr , 8 , '0')
18522  datalen = len(datastr)
18523  if SingleDualPot.get() == 2: # send 8 bits of data
18524  if datalen < 8:
18525  datastr = str.rjust(datastr , 8 , '0')
18526  datalen = len(datastr)
18527  i = 1
18528  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
18529  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
18530  while i < datalen+1:
18531  # CS --> PIO 0
18532  # D0 --> PIO 1
18533  # D1 --> PIO 2
18534  # SCLK --> PIO 3
18535  D1code = 0x50 + int(datastr[i-1])
18536  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
18537  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
18538  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
18539  i = i + 1
18540  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
18541  #
18542 def DigPotSend(Temp):
18543  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
18544  global SingleDualPot
18545 
18546  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
18547  NumTaps = 255
18548  if SingleDualPot.get() == 2:
18549  NumTaps = 63
18550  try:
18551  DValue1 = DigPot1.get()
18552  if DValue1 > NumTaps:
18553  DValue1 = NumTaps
18554  except:
18555  DValue1 = 0
18556  try:
18557  DValue2 = DigPot2.get()
18558  if DValue2 > NumTaps:
18559  DValue2 = NumTaps
18560  except:
18561  DValue2 = 0
18562  try:
18563  DValue3 = DigPot3.get()
18564  if DValue3 > NumTaps:
18565  DValue3 = NumTaps
18566  except:
18567  DValue3 = 0
18568  try:
18569  DValue4 = DigPot4.get()
18570  if DValue4 > NumTaps:
18571  DValue4 = NumTaps
18572  except:
18573  DValue4 = 0
18574  if SendPot1.get() > 0:
18575  DigPotShiftOut(DValue1)
18576  if SendPot2.get() > 0:
18577  DigPotShiftOut(DValue2+NumTaps+1)
18578  if SendPot3.get() > 0:
18579  DigPotShiftOut(DValue3+2*(NumTaps+1))
18580  if SendPot4.get() > 0:
18581  DigPotShiftOut(DValue4+3*(NumTaps+1))
18582 
18584  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
18585 
18586  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
18587  DPotlabel.config(text="Enter number from 0 to 255")
18588  DigPot1.config(from_=0, to=255, length=256)
18589  DigPot2.config(from_=0, to=255, length=256)
18590  DigPot3.config(from_=0, to=255, length=256)
18591  DigPot4.config(from_=0, to=255, length=256)
18592  if SingleDualPot.get() == 2:
18593  DPotlabel.config(text="Enter number from 0 to 63")
18594  DigPot1.config(from_=0, to=63, length=64)
18595  DigPot2.config(from_=0, to=63, length=64)
18596  DigPot3.config(from_=0, to=63, length=64)
18597  DigPot4.config(from_=0, to=63, length=64)
18598 
18601  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
18602  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
18603  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
18604 
18605  if DigPotScreenStatus.get() == 0:
18606  DigPotScreenStatus.set(1)
18607  digpotwindow = Toplevel()
18608  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
18609  digpotwindow.resizable(FALSE,FALSE)
18610  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
18611  #
18612  SendPot1 = IntVar(0)
18613  SendPot1.set(1)
18614  SendPot2 = IntVar(0)
18615  SendPot2.set(1)
18616  SendPot3 = IntVar(0)
18617  SendPot3.set(0)
18618  SendPot4 = IntVar(0)
18619  SendPot4.set(0)
18620  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
18621  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
18622 
18623  SingleDualPot = IntVar(0)
18624  SingleDualPot.set(0)
18625  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
18626  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
18627  CompMenu["menu"] = CompMenu.menu
18628  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
18629  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
18630  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
18631  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
18632  lab1 = Checkbutton(digpotwindow,text="Pot 1", pady=0, variable=SendPot1)
18633  lab1.grid(row=2, column=0, sticky=W)
18634  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
18635  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
18636  lab2 = Checkbutton(digpotwindow,text="Pot 2", pady=0, variable=SendPot2)
18637  lab2.grid(row=4, column=0, sticky=W)
18638  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
18639  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
18640  lab3 = Checkbutton(digpotwindow,text="Pot 3", pady=0, variable=SendPot3)
18641  lab3.grid(row=6, column=0, sticky=W)
18642  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
18643  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
18644  lab4 = Checkbutton(digpotwindow,text="Pot 4", pady=0, variable=SendPot4)
18645  lab4.grid(row=8, column=0, sticky=W)
18646  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
18647  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
18648  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
18649  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
18650 
18652  global digpotwindow, DigPotScreenStatus
18653 
18654  DigPotScreenStatus.set(0)
18655  digpotwindow.destroy()
18656 
18657 def BSendGS():
18658  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
18659  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
18660 
18661  if AD5626SerialStatus.get() == 0:
18662  try:
18663  DValue = int(eval(DataBitsEntry.get()))
18664  if DValue < 0:
18665  DValue = 0
18666  except:
18667  DValue = 0
18668  try:
18669  NumBits = int(NumBitsEntry.get())
18670  if NumBits < 1:
18671  NumBits = 1
18672  except:
18673  NumBits = 8
18674  else:
18675  try:
18676  DValue = int(eval(AD5626Entry.get())*1000)
18677  if DValue < 0:
18678  DValue = 0
18679  AD5626Entry.delete(0,"end")
18680  AD5626Entry.insert(0,'0.000')
18681  if DValue > 4095:
18682  DValue = 4095
18683  AD5626Entry.delete(0,"end")
18684  AD5626Entry.insert(0,DValue/1000.0)
18685  except:
18686  DValue = 0
18687  AD5626Entry.delete(0,"end")
18688  AD5626Entry.insert(0,'0.000')
18689  NumBits = 12
18690  # print DValue
18691  binstr = bin(DValue)
18692  binlen = len(binstr)
18693  datastr = binstr[2:binlen]
18694  datalen = len(datastr)
18695  if datalen < NumBits:
18696  datastr = str.rjust(datastr , NumBits , '0')
18697  datalen = len(datastr)
18698  if SLatchPhase.get() == 0:
18699  LatchInt = 0x50
18700  LatchEnd = 0x51
18701  else:
18702  LatchInt = 0x51
18703  LatchEnd = 0x50
18704  if AD5626SerialStatus.get() > 0:
18705  LatchInt = 0x51
18706  LatchEnd = 0x50
18707  if SClockPhase.get() == 0:
18708  ClockInt = 0x50
18709  ClockEnd = 0x51
18710  else:
18711  ClockInt = 0x51
18712  ClockEnd = 0x50
18713  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
18714  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
18715  i = 1
18716  while i < datalen+1:
18717  if SerDirection.get() == 1: # for MSB first
18718  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
18719  else:
18720  D1code = 0x50 + int(datastr[i-1]) # for LSB first
18721  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
18722  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
18723  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
18724  i = i + 1
18725  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
18726  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
18727  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
18728  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
18729 
18732  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
18733  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
18734  global PIO_0, PIO_1, PIO_2, PIO_3
18735 
18736  if GenericSerialStatus.get() == 1:
18737  GenericSerialStatus.set(0)
18739  if AD5626SerialStatus.get() == 0:
18740  AD5626SerialStatus.set(1)
18741  ad5626window = Toplevel()
18742  ad5626window.title("AD5626 Output " + SWRev + RevDate)
18743  ad5626window.resizable(FALSE,FALSE)
18744  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
18745 #
18746  SLatchPhase = IntVar(0)
18747  SLatchPhase.set(0)
18748  SClockPhase = IntVar(0)
18749  SClockPhase.set(1)
18750  SerDirection = IntVar(0)
18751  SerDirection.set(0)
18752  #
18753  label2 = Label(ad5626window,text="Enter Output Volts")
18754  label2.grid(row=1, column=0, columnspan=1, sticky=W)
18755  AD5626Entry = Entry(ad5626window, width=10)
18756  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
18757  AD5626Entry.bind("<Button-4>", onAD5626Scroll)# with Linux OS
18758  AD5626Entry.bind("<Button-5>", onAD5626Scroll)
18759  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
18760  AD5626Entry.delete(0,"end")
18761  AD5626Entry.insert(0,'0.000')
18762  #
18763  label3 = Label(ad5626window,text="SCLK PI/O Port ")
18764  label3.grid(row=2, column=0, columnspan=1, sticky=W)
18765  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
18766  sclk1.grid(row=2, column=1, sticky=W)
18767  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
18768  sclk2.grid(row=2, column=2, sticky=W)
18769  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
18770  sclk3.grid(row=2, column=3, sticky=W)
18771  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
18772  sclk4.grid(row=2, column=4, sticky=W)
18773  #
18774  label4 = Label(ad5626window,text="SData PI/O Port ")
18775  label4.grid(row=3, column=0, columnspan=1, sticky=W)
18776  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
18777  sdat1.grid(row=3, column=1, sticky=W)
18778  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
18779  sdat2.grid(row=3, column=2, sticky=W)
18780  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
18781  sdat3.grid(row=3, column=3, sticky=W)
18782  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
18783  sdat4.grid(row=3, column=4, sticky=W)
18784  #
18785  label5 = Label(ad5626window,text="Latch PI/O Port ")
18786  label5.grid(row=4, column=0, columnspan=1, sticky=W)
18787  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
18788  slth1.grid(row=4, column=1, sticky=W)
18789  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
18790  slth2.grid(row=4, column=2, sticky=W)
18791  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
18792  slth3.grid(row=4, column=3, sticky=W)
18793  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
18794  slth4.grid(row=4, column=4, sticky=W)
18795  #
18796  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
18797  bsn1.grid(row=5, column=0, sticky=W)
18798  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
18799  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
18800 #
18801 def onAD5626Scroll(event):
18802  onTextScroll(event)
18803  BSendGS()
18804 
18806  global ad5626window, AD5626SerialStatus
18807 
18808  AD5626SerialStatus.set(0)
18809  ad5626window.destroy()
18810 
18812  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
18813  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
18814  global PIO_0, PIO_1, PIO_2, PIO_3
18815 
18816  if GenericSerialStatus.get() == 0:
18817  GenericSerialStatus.set(1)
18818  serialwindow = Toplevel()
18819  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
18820  serialwindow.resizable(FALSE,FALSE)
18821  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
18822  #
18823  SCLKPort = IntVar(0)
18824  SCLKPort.set(PIO_2)
18825  SDATAPort = IntVar(0)
18826  SDATAPort.set(PIO_1)
18827  SLATCHPort = IntVar(0)
18828  SLATCHPort.set(PIO_0)
18829  SLatchPhase = IntVar(0)
18830  SClockPhase = IntVar(0)
18831  SerDirection = IntVar(0)
18832  label = Label(serialwindow,text="Enter number of Bits")
18833  label.grid(row=1, column=0, columnspan=2, sticky=W)
18834  NumBitsEntry = Entry(serialwindow, width=3)
18835  NumBitsEntry.grid(row=1, column=2, sticky=W)
18836  NumBitsEntry.delete(0,"end")
18837  NumBitsEntry.insert(0,8)
18838  #
18839  label2 = Label(serialwindow,text="Enter Data Word")
18840  label2.grid(row=2, column=0, columnspan=1, sticky=W)
18841  DataBitsEntry = Entry(serialwindow, width=10)
18842  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
18843  DataBitsEntry.delete(0,"end")
18844  DataBitsEntry.insert(0,0)
18845  #
18846  label3 = Label(serialwindow,text="SCLK PI/O Port ")
18847  label3.grid(row=3, column=0, columnspan=1, sticky=W)
18848  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
18849  sclk1.grid(row=3, column=1, sticky=W)
18850  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
18851  sclk2.grid(row=3, column=2, sticky=W)
18852  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
18853  sclk3.grid(row=3, column=3, sticky=W)
18854  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
18855  sclk4.grid(row=3, column=4, sticky=W)
18856  #
18857  label4 = Label(serialwindow,text="SData PI/O Port ")
18858  label4.grid(row=4, column=0, columnspan=1, sticky=W)
18859  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
18860  sdat1.grid(row=4, column=1, sticky=W)
18861  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
18862  sdat2.grid(row=4, column=2, sticky=W)
18863  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
18864  sdat3.grid(row=4, column=3, sticky=W)
18865  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
18866  sdat4.grid(row=4, column=4, sticky=W)
18867  #
18868  label5 = Label(serialwindow,text="Latch PI/O Port ")
18869  label5.grid(row=5, column=0, columnspan=1, sticky=W)
18870  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
18871  slth1.grid(row=5, column=1, sticky=W)
18872  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
18873  slth2.grid(row=5, column=2, sticky=W)
18874  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
18875  slth3.grid(row=5, column=3, sticky=W)
18876  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
18877  slth4.grid(row=5, column=4, sticky=W)
18878  #
18879  label6 = Label(serialwindow,text="Latch Phase ")
18880  label6.grid(row=6, column=0, columnspan=1, sticky=W)
18881  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
18882  sph1.grid(row=6, column=1, sticky=W)
18883  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
18884  sph2.grid(row=6, column=2, sticky=W)
18885  #
18886  label7 = Label(serialwindow,text="Clock Phase ")
18887  label7.grid(row=7, column=0, columnspan=1, sticky=W)
18888  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
18889  sph7.grid(row=7, column=1, sticky=W)
18890  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
18891  sph8.grid(row=7, column=2, sticky=W)
18892  #
18893  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
18894  sdir1.grid(row=8, column=0, sticky=W)
18895  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
18896  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
18897 
18898  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
18899  bsn1.grid(row=9, column=0, sticky=W)
18900  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
18901  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
18902 
18904  global serialwindow, GenericSerialStatus
18905 
18906  GenericSerialStatus.set(0)
18907  serialwindow.destroy()
18908 
18911  global digfltwindow, DigFiltStatus, RevDate, SWRev
18912  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
18913  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
18914 
18915  if DigFiltStatus.get() == 0:
18916  DigFiltStatus.set(1)
18917  digfltwindow = Toplevel()
18918  digfltwindow.title("Digital Filter " + SWRev + RevDate)
18919  digfltwindow.resizable(FALSE,FALSE)
18920  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
18921  #
18922  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
18923  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
18924  frame2.pack(side=LEFT, expand=1, fill=X)
18925  frame3.pack(side=LEFT, expand=1, fill=X)
18926  #
18927  digfilta = Frame( frame2 )
18928  digfilta.pack(side=TOP)
18929  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
18930  #titlab.grid(row=0, column=0, sticky=W)
18931  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
18932  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
18933  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
18934  lab3.grid(row=1, column=0, sticky=W)
18935  BCALenEntry = Entry(digfilta, width=3)
18936  BCALenEntry.bind("<Return>", onRetDigFiltA)
18937  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
18938  BCALenEntry.bind("<Button-4>", onDigFiltAScroll)# with Linux OS
18939  BCALenEntry.bind("<Button-5>", onDigFiltAScroll)
18940  # BCALenEntry.bind('<Key>', onTextKey)
18941  BCALenEntry.grid(row=1, column=1, sticky=W)
18942  BCALenEntry.delete(0,"end")
18943  BCALenEntry.insert(0,2)
18944  bcalab = Label(digfilta, text="Length")
18945  bcalab.grid(row=1, column=2, sticky=W)
18946  DifFiltALength = Label(digfilta, text="Length = 0 ")
18947  DifFiltALength.grid(row=2, column=0, sticky=W)
18948  DifFiltAFile = Label(digfilta, text="File Name, none ")
18949  DifFiltAFile.grid(row=3, column=0, sticky=W)
18950  cald = Button(digfilta, text='Load CH A Filter Coef', command=BLoadDFiltA)
18951  cald.grid(row=4, column=0, columnspan=2, sticky=W)
18952  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
18953  camath.grid(row=5, column=0, columnspan=2, sticky=W)
18954  #
18955  digfiltb = Frame( frame3 )
18956  digfiltb.pack(side=TOP)
18957  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
18958  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
18959  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
18960  lab4.grid(row=1, column=0, sticky=W)
18961  BCBLenEntry = Entry(digfiltb, width=3)
18962  BCBLenEntry.bind("<Return>", onRetDigFiltB)
18963  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
18964  BCBLenEntry.bind("<Button-4>", onDigFiltBScroll)# with Linux OS
18965  BCBLenEntry.bind("<Button-5>", onDigFiltBScroll)
18966  # BCALenEntry.bind('<Key>', onTextKey)
18967  BCBLenEntry.grid(row=1, column=1, sticky=W)
18968  BCBLenEntry.delete(0,"end")
18969  BCBLenEntry.insert(0,2)
18970  bcblab = Label(digfiltb, text="Length")
18971  bcblab.grid(row=1, column=2, sticky=W)
18972  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
18973  DifFiltBLength.grid(row=2, column=0, sticky=W)
18974  DifFiltBFile = Label(digfiltb,text="File Name, none ")
18975  DifFiltBFile.grid(row=3, column=0, sticky=W)
18976  camath.grid(row=8, column=0, sticky=W)
18977  cbld = Button(digfiltb, text='Load CH B Filter Coef', command=BLoadDFiltB)
18978  cbld.grid(row=4, column=0, sticky=W)
18979  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
18980  cbmath.grid(row=5, column=0, sticky=W)
18981  dismissdfbutton = Button(digfiltb, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
18982  dismissdfbutton.grid(row=6, column=0, columnspan=1, sticky=W)
18983  #
18984 def onRetDigFiltA(event):
18985  BuildBoxCarA()
18986 
18987 def onDigFiltAScroll(event):
18988  onTextScroll(event)
18989  BuildBoxCarA()
18990 
18992  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
18993 
18994  if DigFiltABoxCar.get() == 0:
18995  return
18996 
18997  FLength = int(BCALenEntry.get())
18998  if FLength < 2:
18999  return
19000 
19001  DFiltACoef = [] # empty coef array
19002 
19003  for n in range(FLength):
19004  DFiltACoef.append(float(1.0/FLength))
19005 
19006  DFiltACoef = numpy.array(DFiltACoef)
19007  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
19008 
19009 def onRetDigFiltB(event):
19010  BuildBoxCarB()
19011 
19012 def onDigFiltBScroll(event):
19013  onTextScroll(event)
19014  BuildBoxCarB()
19015 
19017  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
19018 
19019  if DigFiltBBoxCar.get() == 0:
19020  return
19021 
19022  FLength = int(BCBLenEntry.get())
19023  if FLength < 2:
19024  return
19025 
19026  DFiltBCoef = [] # empty coef array
19027 
19028  for n in range(FLength):
19029  DFiltBCoef.append(float(1.0/FLength))
19030 
19031  DFiltBCoef = numpy.array(DFiltBCoef)
19032  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
19033 
19035  global digfltwindow, DigFiltStatus
19036 
19037  DigFiltStatus.set(0)
19038  digfltwindow.destroy()
19039 
19041  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
19042 
19043 # Read values from CVS file
19044  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
19045  try:
19046  CSVFile = open(filename)
19047  csv_f = csv.reader(CSVFile)
19048  except:
19049  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
19050  return
19051  DFiltACoef = []
19052 
19053  for row in csv_f:
19054  try:
19055  DFiltACoef.append(float(row[0]))
19056  except:
19057  print( 'skipping non-numeric row')
19058  DFiltACoef = numpy.array(DFiltACoef)
19059  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
19060  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
19061  CSVFile.close()
19062 #
19064  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
19065 
19066  TempString = DigFilterAString
19067  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
19068  if (DigFilterAString == None): # If Cancel pressed, then None
19069  DigFilterAString = TempString
19070  return
19071  DFiltACoef = eval(DigFilterAString)
19072  DFiltACoef = numpy.array(DFiltACoef)
19073  coefsum = numpy.sum(DFiltACoef)
19074  DFiltACoef = DFiltACoef / coefsum
19075  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
19076  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
19077 
19079  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
19080 
19081 # Read values from CVS file
19082  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
19083  try:
19084  CSVFile = open(filename)
19085  csv_f = csv.reader(CSVFile)
19086  except:
19087  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
19088  return
19089  DFiltBCoef = []
19090 
19091  for row in csv_f:
19092  try:
19093  DFiltBCoef.append(float(row[0]))
19094  except:
19095  print( 'skipping non-numeric row')
19096  DFiltBCoef = numpy.array(DFiltBCoef)
19097  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
19098  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
19099  CSVFile.close()
19100 #
19102  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
19103 
19104  TempString = DigFilterBString
19105  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
19106  if (DigFilterBString == None): # If Cancel pressed, then None
19107  DigFilterBString = TempString
19108  return
19109  DFiltBCoef = eval(DigFilterBString)
19110  DFiltBCoef = numpy.array(DFiltBCoef)
19111  coefsum = numpy.sum(DFiltBCoef)
19112  DFiltBCoef = DFiltBCoef / coefsum
19113  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
19114  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
19115 #
19117  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
19118 
19119  if CommandStatus.get() == 0:
19120  CommandStatus.set(1)
19121  commandwindow = Toplevel()
19122  commandwindow.title("Command Line " + SWRev + RevDate)
19123  commandwindow.resizable(FALSE,FALSE)
19124  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
19125  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
19126  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
19127  cl1 = Label(commandwindow,text="Last command:")
19128  cl1.grid(row=1, column=0, sticky=W)
19129  LastCommand = Label(commandwindow,text=" ")
19130  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
19131  ExecString = Entry(commandwindow, width=40)
19132  ExecString.bind("<Return>", RExecuteFromString)
19133  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
19134  ExecString.delete(0,"end")
19135  ExecString.insert(0,"global ; ")
19136  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
19137  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
19138  #
19139  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
19140  dismissclbutton.grid(row=4, column=1, sticky=W, pady=7)
19141 
19143  global commandwindow, CommandStatus
19144 
19145  CommandStatus.set(0)
19146  commandwindow.destroy()
19147 
19149 
19151 
19152 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
19153  global ExecString, LastCommand
19154 
19155  try:
19156  exec( ExecString.get() )
19157  LastCommand.config(text = ExecString.get() ) # change displayed last command
19158  except:
19159  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
19160  return()
19161 #
19162 def CAresize(event):
19163  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
19164 
19165  XOL = FontSize * 7
19166  CANVASwidth = event.width - 4
19167  CANVASheight = event.height - 4
19168  GRW = CANVASwidth - (2 * X0L) # new grid width
19169  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
19170  UpdateTimeAll()
19171 #
19173  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
19174  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
19175  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
19176  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
19177  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
19178  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
19179 
19180  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
19181  ChaValue1.config(text = ValueText)
19182  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
19183  ChaValue2.config(text = ValueText)
19184  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
19185  ChaValue3.config(text = ValueText)
19186  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
19187  ChaValue4.config(text = ValueText)
19188  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
19189  ChaValue5.config(text = ValueText)
19190  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
19191  ChaValue6.config(text = ValueText)
19192  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
19193  ChbValue1.config(text = ValueText)
19194  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
19195  ChbValue2.config(text = ValueText)
19196  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
19197  ChbValue3.config(text = ValueText)
19198  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
19199  ChbValue4.config(text = ValueText)
19200  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
19201  ChbValue5.config(text = ValueText)
19202  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
19203  ChbValue6.config(text = ValueText)
19204 #
19206  global measurewindow, MeasureStatus, RevDate, SWRev
19207  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
19208  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
19209  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
19210  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
19211  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
19212  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
19213 
19214  if MeasureStatus.get() == 0:
19215  MeasureStatus.set(1)
19216  measurewindow = Toplevel()
19217  measurewindow.title("Measurements " + SWRev + RevDate)
19218  measurewindow.resizable(FALSE,FALSE)
19219  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
19220  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
19221  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
19222  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
19223  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
19224  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19225  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
19226  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
19227  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
19228  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19229  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
19230  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
19231  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
19232  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19233  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
19234  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
19235  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
19236  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19237  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
19238  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
19239  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
19240  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19241  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
19242  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
19243  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
19244  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19245  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
19246  #
19247  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
19248  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
19249  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19250  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
19251  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
19252  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
19253  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19254  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
19255  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
19256  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
19257  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19258  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
19259  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
19260  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
19261  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19262  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
19263  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
19264  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
19265  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19266  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
19267  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
19268  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
19269  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
19270  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
19271 #
19273  global measurewindow, MeasureStatus
19274 
19275  MeasureStatus.set(0)
19276  measurewindow.destroy()
19277 #
19279  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
19280  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
19281 
19282  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
19283  if BoardStatus.get() == 0:
19284  BoardStatus.set(1)
19285  boardwindow = Toplevel()
19286  boardwindow.title("Select Board " + RevDate)
19287  boardwindow.resizable(FALSE,FALSE)
19288  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
19289  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
19290  toplab.pack(side=TOP)
19291  for idx, devx in enumerate(session.devices):
19292  BrdText = "Board # " + str(idx)
19293  if idx == 0:
19294  devx.set_led(0b010) # LED.green
19295  FWRevOne = float(devx.fwver)
19296  HWRevOne = devx.hwver
19297  dev0 = devx #session.devices[0]
19298  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
19299  elif idx == 1:
19300  devx.set_led(0b100) # LED.blue,
19301  FWRevTwo = float(devx.fwver)
19302  HWRevTwo = devx.hwver
19303  dev1 = devx #session.devices[1]
19304  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
19305  elif idx == 2:
19306  devx.set_led(0b001) # LED.red,
19307  FWRevThree = float(devx.fwver)
19308  HWRevThree = devx.hwver
19309  dev2 = devx #session.devices[2]
19310  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
19311  else:
19312  dev3 = session.devices[3]
19313  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
19314  brd.pack(side=TOP)
19315  else:
19316  devx = session.devices[0]
19317  # devx.ignore_dataflow = True
19318  devx.set_led(0b010) # if only one board set LED.green
19319  try:
19320  FWRevOne = float(devx.fwver)
19321  HWRevOne = devx.hwver
19322  except:
19323  FWRevOne = "Before 2.06"
19324  HWRevOne = "?"
19325  dev0 = session.devices[0]
19326 #
19328  global boardwindow, BoardStatus
19329 
19330  BoardStatus.set(0)
19331  boardwindow.destroy()
19332 #
19334  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
19335  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
19336 
19337  if DevID == "No Device" or DevID == "m1k":
19338  #print("Request sample rate: " + str(SAMPLErate))
19339  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
19340  # session.add_all()
19341  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
19342  if not session.devices:
19343  print( 'No Device plugged IN!')
19344  DevID = "No Device"
19345  FWRevOne = 0.0
19346  bcon.configure(text="Recon", style="RConn.TButton")
19347  return
19348  session.configure(sample_rate=SAMPLErate)
19349  # print("Session sample rate: " + str(session.sample_rate))
19350  MakeBoardScreen()
19351  SelectBoard()
19352  bcon.configure(text="Conn", style="GConn.TButton")
19353  devx.set_adc_mux(0)
19354  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
19355  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
19356 
19360  session.start(0)
19361 #
19363  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
19364  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
19365  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
19366 
19367  if RUNstatus.get() == 1:
19368  BStop()
19369  print( "STOP")
19370 
19371  if BrdSel.get() == 0:
19372  try:
19373  session.remove(dev1)
19374  print( "Removing dev1")
19375  except:
19376  print( "Skipping dev1")
19377  try:
19378  session.remove(dev2)
19379  print( "Removing dev2")
19380  except:
19381  print( "Skipping dev2")
19382  session.add(dev0)
19383  devx = dev0
19384  #session.add(devx)
19385  if BrdSel.get() == 1:
19386  try:
19387  session.remove(dev0)
19388  print( "Removing dev0")
19389  except:
19390  print( "Skipping dev0")
19391  try:
19392  session.remove(dev2)
19393  print( "Removing dev2")
19394  except:
19395  print( "Skipping dev2")
19396  session.add(dev1)
19397  devx = dev1
19398  #session.add(devx)
19399  DevID = devx.serial
19400  print( DevID)
19401  FWRevOne = float(devx.fwver)
19402  HWRevOne = str(devx.hwver)
19403  print( FWRevOne, HWRevOne)
19404  # print("Session sample rate: " + str(session.sample_rate))
19405 
19406  if IgnoreFirmwareCheck == 0:
19407  if FWRevOne < 2.17:
19408  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
19409  UpdateFirmware()
19410  cal = devx.calibration
19411  CHA = devx.channels['A'] # Open CHA
19412  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
19413  CHB = devx.channels['B'] # Open CHB
19414  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
19415  #
19416  # if session.continuous == 0:
19417  #session.start(0)
19418 
19427  devx.set_adc_mux(0)
19428  if devx.hwver == "F":
19429  print( "Rev F Board I/O ports set")
19430  PIO_0 = 28
19431  PIO_1 = 29
19432  PIO_2 = 47
19433  PIO_3 = 3
19434  PIO_4 = 4
19435  PIO_5 = 5
19436  PIO_6 = 6
19437  PIO_7 = 7
19438  else:
19439  PIO_0 = 0
19440  PIO_1 = 1
19441  PIO_2 = 2
19442  PIO_3 = 3
19443  PIO_4 = 4
19444  PIO_5 = 5
19445  PIO_6 = 6
19446  PIO_7 = 7
19447 #
19448  SDATAPort.set(PIO_1)
19449  SCLKPort.set(PIO_2)
19450  SLATCHPort.set(PIO_0)
19451 
19453  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
19454  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
19455  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
19456 
19457  if SampleRateStatus.get() == 0:
19458  SampleRateStatus.set(1)
19459  SampleRatewindow = Toplevel()
19460  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
19461  SampleRatewindow.resizable(FALSE,FALSE)
19462  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
19463  frame1 = Frame(SampleRatewindow, borderwidth=5, relief=RIDGE)
19464  frame1.grid(row=0, column=0, sticky=W)
19465  #
19466  BaseRATE = Frame( frame1 )
19467  BaseRATE.grid(row=0, column=0, sticky=W)
19468  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
19469  baseratelab.pack(side=LEFT)
19470  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
19471  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
19472  BaseRatesb.bind("<Button-4>", onSrateScroll)# with Linux OS
19473  BaseRatesb.bind("<Button-5>", onSrateScroll)
19474  BaseRatesb.bind("<Return>", onRetSrate)
19475  BaseRatesb.pack(side=LEFT)
19476  BaseRatesb.delete(0,"end")
19477  BaseRatesb.insert(0,BaseSampleRate)
19478  #
19479  nextrow = 2
19480  if FWRevOne > 2.16:
19481  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
19482  twoX.grid(row=1, column=0, sticky=W)
19483  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
19484  muxlab1.grid(row=2, column=0, sticky=W)
19485  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
19486  AltSweep.grid(row=3, column=0, sticky=W)
19487  chabuttons = Frame( frame1 )
19488  chabuttons.grid(row=4, column=0, sticky=W)
19489  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
19490  muxrb1.pack(side=LEFT)
19491  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
19492  muxrb2.pack(side=LEFT)
19493  chcbuttons = Frame( frame1 )
19494  chcbuttons.grid(row=5, column=0, sticky=W)
19495  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
19496  muxrb5.pack(side=LEFT)
19497  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
19498  muxrb6.pack(side=LEFT)
19499  nextrow = 6
19500  if DeBugMode == 1:
19501  chbbuttons = Frame( frame1 )
19502  chbbuttons.grid(row=nextrow, column=0, sticky=W)
19503  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
19504  muxrb3.pack(side=LEFT)
19505  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
19506  muxrb4.pack(side=LEFT)
19507  nextrow = nextrow + 1
19508  #
19509  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
19510  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
19511 #
19513  global SampleRatewindow, SampleRateStatus
19514 
19515  SampleRateStatus.set(0)
19516  SampleRatewindow.destroy()
19517 #
19518 #
19519 def onSrateScroll(event):
19520 
19521  #onTextScroll
19522  onSpinBoxScroll(event)
19523  SetSampleRate()
19524 #
19525 def onRetSrate(event):
19526 
19527  SetSampleRate()
19528 #
19530  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
19531  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
19532 
19533  #
19534  WasRunning = 0
19535  if (RUNstatus.get() == 1):
19536  WasRunning = 1
19537  BStop() # Force Stop loop if running
19538  try:
19539  NewRate = int(BaseRatesb.get())
19540  if NewRate <= 100000: # rate has to be less than or equal to 100,000
19541  BaseSampleRate = NewRate
19542  else:
19543  BaseSampleRate = 100000
19544  BaseRatesb.delete(0,"end")
19545  BaseRatesb.insert(0,BaseSampleRate)
19546  SAMPLErate = BaseSampleRate # Scope sample rate
19547  except:
19548  donothing()
19549  session.configure(sample_rate=BaseSampleRate)
19550  BaseSampleRate = session.sample_rate
19551  #print("Session sample rate: " + str(session.sample_rate), BaseSampleRate)
19552  SAMPLErate = BaseSampleRate # Scope sample rate
19553  #print("Session sample rate: " + str(session.sample_rate), SAMPLErate)
19554  AWGSAMPLErate = BaseSampleRate
19555  if ETSStatus.get() > 0:
19556  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
19557  rtsrlab.config(text=SRstring)
19558  ETSUpdate()
19559  BaseRatesb.delete(0,"end")
19560  BaseRatesb.insert(0,BaseSampleRate)
19561  ReMakeAWGwaves() # remake AWG waveforms for new rate
19562  if (WasRunning == 1):
19563  WasRunning = 0
19564  BStart() # restart loop if was running
19565 #
19566 def onStopfreqScroll(event):
19567  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
19568 
19569  onTextScroll(event)
19570  try:
19571  StopFrequency = float(StopFreqEntry.get())
19572  except:
19573  StopFreqEntry.delete(0,"end")
19574  StopFreqEntry.insert(0,50000)
19575  StopFrequency = 50000
19576  if FWRevOne > 2.16:
19577  if StopFrequency >= 50000:
19578  Two_X_Sample.set(1)
19579  ADC_Mux_Mode.set(0)
19580  SetADC_Mux()
19581  else:
19582  Two_X_Sample.set(0)
19583  ADC_Mux_Mode.set(0)
19584  SetADC_Mux()
19585 #
19586 def onStopBodeScroll(event):
19587  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
19588 
19589  onTextScroll(event)
19590  try:
19591  StopFrequency = float(StopBodeEntry.get())
19592  except:
19593  StopBodeEntry.delete(0,"end")
19594  StopBodeEntry.insert(0,20000)
19595  StopFrequency = 20000
19596  if FWRevOne > 2.16:
19597  if StopFrequency >= 20000:
19598  Two_X_Sample.set(1)
19599  ADC_Mux_Mode.set(0)
19600  SetADC_Mux()
19601  else:
19602  Two_X_Sample.set(0)
19603  ADC_Mux_Mode.set(0)
19604  SetADC_Mux()
19605 #
19607  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
19608  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
19609 
19610  if Two_X_Sample.get() == 1:
19611  if ADC_Mux_Mode.get() == 0: # VA and VB
19612  devx.set_adc_mux(1)
19613  elif ADC_Mux_Mode.get() == 1: # IA and IB
19614  devx.set_adc_mux(2)
19615  elif ADC_Mux_Mode.get() == 2: # VA and IB
19616  # cycle trhough default mux values as starting point
19617  devx.set_adc_mux(2)
19618  # now set new mux values
19619  devx.set_adc_mux(7)
19620  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
19621  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
19622  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
19623  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
19624  time.sleep(0.1)
19625  elif ADC_Mux_Mode.get() == 3: # VB and IA
19626  # cycle trhough default mux values as starting point
19627  # now set new mux values
19628  devx.set_adc_mux(7)
19629  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
19630  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
19631  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
19632  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
19633  time.sleep(0.1)
19634  elif ADC_Mux_Mode.get() == 4: # VA and IA
19635  # now set new mux values
19636  devx.set_adc_mux(4)
19637  elif ADC_Mux_Mode.get() == 5: # VB and IB
19638  # now set new mux values
19639  devx.set_adc_mux(5)
19640  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
19641  else:
19642  devx.set_adc_mux(0)
19643  SAMPLErate = BaseSampleRate
19644 #
19646  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
19647 
19648  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
19649  ADC_Mux_Mode.set(0) # All four traces
19650  Alternate_Sweep_Mode.set(1)
19651  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
19652  ADC_Mux_Mode.set(0) # three traces
19653  Alternate_Sweep_Mode.set(1)
19654  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
19655  ADC_Mux_Mode.set(0) # three traces
19656  Alternate_Sweep_Mode.set(1)
19657  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
19658  ADC_Mux_Mode.set(0) # three traces
19659  Alternate_Sweep_Mode.set(1)
19660  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
19661  ADC_Mux_Mode.set(0) # three traces
19662  Alternate_Sweep_Mode.set(1)
19663  #
19664  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
19665  ADC_Mux_Mode.set(1) # IA and IB
19666  Alternate_Sweep_Mode.set(0)
19667  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
19668  ADC_Mux_Mode.set(1) # just IA
19669  Alternate_Sweep_Mode.set(0)
19670  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
19671  ADC_Mux_Mode.set(1) # just IB
19672  Alternate_Sweep_Mode.set(0)
19673  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
19674  ADC_Mux_Mode.set(4) # VA and IA
19675  Alternate_Sweep_Mode.set(0)
19676  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
19677  ADC_Mux_Mode.set(5) # VB and IB
19678  Alternate_Sweep_Mode.set(0)
19679  else:
19680  ADC_Mux_Mode.set(0)
19681  Alternate_Sweep_Mode.set(0)
19682  SetADC_Mux()
19683  UpdateTimeTrace()
19684 #
19686  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
19687  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
19688 
19689  RUNstatus.set(0)
19690  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
19691  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
19692  print( filename)
19693  #print DevID
19694  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
19695  try:
19696  print( "Cancel current session.")
19697  session.cancel()
19698  print( session.cancelled)
19699  session.end()
19700  print( "Waiting 5...")
19701  time.sleep(5)
19702  print( "Put board in Samba mode and flash firmware.")
19703  session.flash_firmware(filename)
19704  except:
19705  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
19706 
19714  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
19715  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
19716  Bcloseexit()
19717 
19727  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
19728  global CHATestVEntry, CHATestREntry, SWRev, AWGSync, OnBoardRes
19729 
19730  if OhmStatus.get() == 0:
19731  AWGSync.set(1)
19732  OhmStatus.set(1)
19733  OhmDisp.set(1)
19734  OhmCheckBox()
19735  ohmwindow = Toplevel()
19736  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
19737  ohmwindow.resizable(FALSE,FALSE)
19738  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
19739  frame1 = Frame(ohmwindow, borderwidth=5, relief=RIDGE)
19740  frame1.grid(row=0, column=0, sticky=W)
19741  #
19742  buttons = Frame( frame1 )
19743  buttons.grid(row=0, column=0, sticky=W)
19744  rb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
19745  rb2.pack(side=LEFT)
19746  rb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
19747  rb1.pack(side=LEFT)
19748  #
19749  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
19750  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
19751  OhmA0.config(text = "0.000 Ohms")
19752 
19753  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
19754  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
19755  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
19756  #
19757  TestVA = Frame( frame1 )
19758  TestVA.grid(row=3, column=0, sticky=W)
19759  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
19760  chatestvlab.pack(side=LEFT)
19761  CHATestVEntry = Entry(TestVA, width=6) #
19762  CHATestVEntry.pack(side=LEFT)
19763  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
19764  CHATestVEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19765  CHATestVEntry.bind("<Button-5>", onTextScroll)
19766  CHATestVEntry.delete(0,"end")
19767  CHATestVEntry.insert(0,5.0)
19768  #
19769  RMode = IntVar(0)
19770  RMode.set(1)
19771  TestMode = Frame( frame1 )
19772  TestMode.grid(row=4, column=0, sticky=W)
19773  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
19774  modelab.pack(side=LEFT)
19775  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
19776  rm3.pack(side=LEFT)
19777  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
19778  rm4.pack(side=LEFT)
19779  #
19780  TestRA = Frame( frame1 )
19781  TestRA.grid(row=5, column=0, sticky=W)
19782  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
19783  chatestrlab.pack(side=LEFT)
19784  CHATestREntry = Entry(TestRA, width=6) #
19785  CHATestREntry.pack(side=LEFT)
19786  CHATestREntry.bind('<MouseWheel>', onTextScroll)
19787  CHATestREntry.bind("<Button-4>", onTextScroll)# with Linux OS
19788  CHATestREntry.bind("<Button-5>", onTextScroll)
19789  CHATestREntry.delete(0,"end")
19790  CHATestREntry.insert(0,OnBoardRes)
19791  #
19792  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
19793  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
19794 #
19796  global ohmwindow, OhmStatus, OhmDisp
19797 
19798  OhmStatus.set(0)
19799  OhmDisp.set(0)
19800  OhmCheckBox()
19801  ohmwindow.destroy()
19802 #
19804  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
19805  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
19806  global MinigenScreenStatus, DeBugMode
19807 
19808  #
19809  if ETSStatus.get() == 0:
19810  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
19811  ETSStatus.set(1)
19812  ETSDisp.set(0)
19813  etswindow = Toplevel()
19814  etswindow.title("ETS Controls " + SWRev + RevDate)
19815  etswindow.resizable(FALSE,FALSE)
19816  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
19817  frame1 = Frame(etswindow, borderwidth=5, relief=RIDGE)
19818  frame1.grid(row=0, column=0, sticky=W)
19819  # Sampling controls Widgets
19820  SRstring = "RT Sample Rate = " + str(SAMPLErate)
19821  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
19822  rtsrlab.grid(row=1, column=0, sticky=W)
19823  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
19824  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
19825  etssrlab.grid(row=2, column=0, sticky=W)
19826  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
19827  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
19828  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
19829  enb1.grid(row=4, column=0, sticky=W)
19830  #
19831  Divx = Frame( frame1 )
19832  Divx.grid(row=5, column=0, sticky=W)
19833  DivXEntry = Entry(Divx, width=6)
19834  DivXEntry.bind('<MouseWheel>', ETSscroll)
19835  DivXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
19836  DivXEntry.bind("<Button-5>", ETSscroll)
19837  DivXEntry.pack(side=RIGHT)
19838  DivXEntry.delete(0,"end")
19839  DivXEntry.insert(0,2)
19840  divxlab = Label( Divx, text = "Divide Factor")
19841  divxlab.pack(side=RIGHT)
19842  GridRow = 5
19843  #
19844  if DeBugMode > 0:
19845  FOffEntry = Label(frame1, text="Samples")
19846  FOffEntry.grid(row=GridRow+1, column=0, sticky=W)
19847  MulXEntry = Label( frame1, text = "Rec Len Mul")
19848  MulXEntry.grid(row=GridRow+2, column=0, sticky=W)
19849  GridRow = GridRow + 2
19850  #
19851  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
19852  eqivsamplerate.grid(row=GridRow+1, column=0, sticky=W)
19853  #
19854  FConv = Frame( frame1 )
19855  FConv.grid(row=GridRow+2, column=0, sticky=W)
19856  FMulXEntry = Entry(FConv, width=3)
19857  FMulXEntry.bind('<MouseWheel>', ETSscroll)
19858  FMulXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
19859  FMulXEntry.bind("<Button-5>", ETSscroll)
19860  FMulXEntry.pack(side=RIGHT)
19861  FMulXEntry.delete(0,"end")
19862  FMulXEntry.insert(0,1)
19863  fminlab = Label( FConv, text = "Freq Multiplier")
19864  fminlab.pack(side=RIGHT)
19865  #
19866  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
19867  FminDisp.grid(row=GridRow+3, column=0, sticky=W)
19868  #
19869  if MinigenScreenStatus.get() > 0:
19870  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
19871  mgloadbutton.grid(row=GridRow+4, column=0, sticky=W)
19872  GridRow = GridRow + 1
19873  #
19874  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
19875  dirlab.grid(row=GridRow+5, column=0, sticky=W)
19876  DataMode = Frame( frame1 )
19877  DataMode.grid(row=GridRow+6, column=0, sticky=W)
19878  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
19879  dm3.pack(side=LEFT)
19880  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
19881  dm4.pack(side=LEFT)
19882  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
19883  tclab.grid(row=GridRow+7, column=0, sticky=W)
19884  TSMode = Frame( frame1 )
19885  TSMode.grid(row=GridRow+8, column=0, sticky=W)
19886  ETSts = Entry(TSMode, width=6)
19887  ETSts.bind('<MouseWheel>', ETSscroll)
19888  ETSts.bind("<Button-4>", ETSscroll)# with Linux OS
19889  ETSts.bind("<Button-5>", ETSscroll)
19890  ETSts.pack(side=RIGHT)
19891  ETSts.delete(0,"end")
19892  ETSts.insert(0,1)
19893  ETStslab = Label( TSMode, text = "Factor")
19894  ETStslab.pack(side=RIGHT)
19895  #
19896  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
19897  etsdismissclbutton.grid(row=GridRow+9, column=0, sticky=W, pady=7)
19898  ETSDisp.set(0)
19899  ETSCheckBox()
19900 #
19902  global etswindow, ETSStatus, ETSDisp
19903 
19904  ETSStatus.set(0)
19905  ETSDisp.set(0)
19906  ETSCheckBox()
19907  etswindow.destroy()
19908 #
19909 def MGLoad():
19910  global MinigenFout, Fmin, ETSDir
19911 
19912  MinigenFout.delete(0,"end")
19913  if ETSDir.get() == 0:
19914  MinigenFout.insert(0,Fmin+20)
19915  else:
19916  MinigenFout.insert(0,Fmin-20)
19917  BSendMG()
19918 #
19919 def ETSscroll(event):
19920  onTextScroll(event)
19921  ETSUpdate()
19922 #
19923 def onFminScroll(event):
19924  onTextScroll(event)
19925  ETSUpdate()
19926  SetETSComp()
19927  SetAD9833(event)
19928 
19929 def onMulXScroll(event):
19930  global Two_X_Sample, HtMulEntry, ETSts, etssrlab, SAMPLErate
19931 
19932  onTextScroll(event)
19933  # ETSUpdate()
19934  try:
19935  TscaleX = float(HtMulEntry.get())
19936  except:
19937  HtMulEntry.delete(0,END)
19938  HtMulEntry.insert(0, 1)
19939  if Two_X_Sample.get() == 0:
19940  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
19941  else:
19942  ToffsetX = 0
19943  ETSts.delete(0,"end")
19944  ETSts.insert(0,ToffsetX)
19945  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
19946  etssrlab.config(text=SRstring)
19947  #
19948  SetETSComp()
19949  SetAD9833(event)
19950 #
19952  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
19953  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
19954  global FminEntry, HtMulEntry, Two_X_Sample, DeBugMode
19955 
19956  if TIMEdiv > 0.2:
19957  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
19958  else:
19959  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
19960  if (MaxETSrecord*100) > MaxSamples:
19961  MaxETSrecord = MaxSamples / 100
19962  try:
19963  DivX = float(eval(DivXEntry.get()))
19964  if DivX < 2:
19965  DivX = 2
19966  if DivX > 75:
19967  DivX = 75
19968  DivXEntry.delete(0,END)
19969  DivXEntry.insert(0, DivX)
19970  except:
19971  DivXEntry.delete(0,END)
19972  DivXEntry.insert(0, DivX)
19973  #
19974  FOff = 25
19975  MulX = (DivX*SAMPLErate)/(100*FOff)
19976  while MulX > MaxETSrecord:
19977  FOff = FOff + 5
19978  MulX = (DivX*SAMPLErate)/(100*FOff)
19979  FOff = 0 - FOff
19980  if DeBugMode > 0:
19981  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
19982  MulXEntry.config(text = SRstring) # change displayed value
19983  SRstring = "Offset = " + str(FOff) + " samples"
19984  FOffEntry.config(text = SRstring) # change displayed value
19985  baseFreq = SAMPLErate/DivX
19986  try:
19987  FMul = float(eval(FMulXEntry.get()))
19988  if FMul < 1:
19989  FMul = 1
19990  FMulXEntry.delete(0,END)
19991  FMulXEntry.insert(0, int(FMul))
19992  if FMul > 75:
19993  FMul = 75
19994  FMulXEntry.delete(0,END)
19995  FMulXEntry.insert(0, int(FMul))
19996  except:
19997  FMulXEntry.delete(0,END)
19998  FMulXEntry.insert(0, int(FMul))
19999  FreqMin = baseFreq * FMul
20000  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
20001  FminDisp.config(text = SRstring) # change displayed value
20002  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
20003  eqivsamplerate.config(text = SRstring) # change displayed value
20004  # calculate time scale multiplication factor
20005  try:
20006  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
20007  except:
20008  FminEntry.delete(0,END)
20009  FminEntry.insert(0, 25)
20010  #
20011  try: # catch for divide by zero
20012  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
20013  except:
20014  TscaleX = 1
20015 
20016  if TscaleX > 0:
20017  ETSDir.set(0) # set sample direction to forward if positive
20018  else:
20019  ETSDir.set(1) # set sample direction to reverse if negative
20020  TscaleX = abs(TscaleX)
20021  if Two_X_Sample.get() == 0:
20022  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
20023  else:
20024  ToffsetX = 0
20025  ETSts.delete(0,"end")
20026  ETSts.insert(0,ToffsetX)
20027 
20028  HtMulEntry.delete(0,END)
20029  HtMulEntry.insert(0, TscaleX)
20030  SRstring = "RT Sample Rate = " + str(SAMPLErate)
20031  rtsrlab.config(text=SRstring)
20032  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
20033  etssrlab.config(text=SRstring)
20034 #
20035 def Settingsscroll(event):
20036  onTextScroll(event)
20037  SettingsUpdate()
20038 #
20039 def SettingsTextKey(event):
20040  onTextKey(event)
20041  SettingsUpdate()
20042 #
20044  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
20045  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
20046  global AWG_Amp_Mode, SWRev, EnableHSsampling, Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
20047  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry, TrgLPFEntry, Trigger_LPF_length
20048  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
20049  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
20050  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
20051  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
20052 
20053  if SettingsStatus.get() == 0:
20054  SettingsStatus.set(1)
20055  Settingswindow = Toplevel()
20056  Settingswindow.title("Settings " + SWRev + RevDate)
20057  Settingswindow.resizable(FALSE,FALSE)
20058  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
20059  frame1 = Frame(Settingswindow, borderwidth=5, relief=RIDGE)
20060  frame1.grid(row=0, column=0, sticky=W)
20061  #
20062  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
20063  zstlab.grid(row=0, column=0, sticky=W)
20064  zstMode = Frame( frame1 )
20065  zstMode.grid(row=0, column=1, sticky=W)
20066  ZSTuff = Entry(zstMode, width=4)
20067  ZSTuff.bind("<Return>", SettingsTextKey)
20068  ZSTuff.bind('<MouseWheel>', Settingsscroll)
20069  ZSTuff.bind("<Button-4>", Settingsscroll)# with Linux OS
20070  ZSTuff.bind("<Button-5>", Settingsscroll)
20071  ZSTuff.bind('<Key>', SettingsTextKey)
20072  ZSTuff.pack(side=RIGHT)
20073  ZSTuff.delete(0,"end")
20074  ZSTuff.insert(0,ZEROstuffing.get())
20075  #
20076  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
20077  Avglab.grid(row=1, column=0, sticky=W)
20078  AvgMode = Frame( frame1 )
20079  AvgMode.grid(row=1, column=1, sticky=W)
20080  TAvg = Entry(AvgMode, width=4)
20081  TAvg.bind("<Return>", SettingsTextKey)
20082  TAvg.bind('<MouseWheel>', Settingsscroll)
20083  TAvg.bind("<Button-4>", Settingsscroll)# with Linux OS
20084  TAvg.bind("<Button-5>", Settingsscroll)
20085  TAvg.bind('<Key>', SettingsTextKey)
20086  TAvg.pack(side=RIGHT)
20087  TAvg.delete(0,"end")
20088  TAvg.insert(0,TRACEaverage.get())
20089  #
20090  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
20091  HarMlab.grid(row=2, column=0, sticky=W)
20092  HarMMode = Frame( frame1 )
20093  HarMMode.grid(row=2, column=1, sticky=W)
20094  HarMon = Entry(HarMMode, width=4)
20095  HarMon.bind("<Return>", SettingsTextKey)
20096  HarMon.bind('<MouseWheel>', Settingsscroll)
20097  HarMon.bind("<Button-4>", Settingsscroll)# with Linux OS
20098  HarMon.bind("<Button-5>", Settingsscroll)
20099  HarMon.bind('<Key>', SettingsTextKey)
20100  HarMon.pack(side=RIGHT)
20101  HarMon.delete(0,"end")
20102  HarMon.insert(0,HarmonicMarkers.get())
20103  #
20104  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
20105  Vdivlab.grid(row=3, column=0, sticky=W)
20106  VdivMode = Frame( frame1 )
20107  VdivMode.grid(row=3, column=1, sticky=W)
20108  VDivE = Entry(VdivMode, width=4)
20109  VDivE.bind("<Return>", SettingsTextKey)
20110  VDivE.bind('<MouseWheel>', Settingsscroll)
20111  VDivE.bind("<Button-4>", Settingsscroll)# with Linux OS
20112  VDivE.bind("<Button-5>", Settingsscroll)
20113  VDivE.bind('<Key>', SettingsTextKey)
20114  VDivE.pack(side=RIGHT)
20115  VDivE.delete(0,"end")
20116  VDivE.insert(0,Vdiv.get())
20117  #
20118  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
20119  Twdthlab.grid(row=4, column=0, sticky=W)
20120  TwdthMode = Frame( frame1 )
20121  TwdthMode.grid(row=4, column=1, sticky=W)
20122  TwdthE = Entry(TwdthMode, width=4)
20123  TwdthE.bind("<Return>", SettingsTextKey)
20124  TwdthE.bind('<MouseWheel>', Settingsscroll)
20125  TwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
20126  TwdthE.bind("<Button-5>", Settingsscroll)
20127  TwdthE.bind('<Key>', SettingsTextKey)
20128  TwdthE.pack(side=RIGHT)
20129  TwdthE.delete(0,"end")
20130  TwdthE.insert(0,TRACEwidth.get())
20131  #
20132  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
20133  Gwdthlab.grid(row=5, column=0, sticky=W)
20134  GwdthMode = Frame( frame1 )
20135  GwdthMode.grid(row=5, column=1, sticky=W)
20136  GwdthE = Entry(GwdthMode, width=4)
20137  GwdthE.bind("<Return>", SettingsTextKey)
20138  GwdthE.bind('<MouseWheel>', Settingsscroll)
20139  GwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
20140  GwdthE.bind("<Button-5>", Settingsscroll)
20141  GwdthE.bind('<Key>', SettingsTextKey)
20142  GwdthE.pack(side=RIGHT)
20143  GwdthE.delete(0,"end")
20144  GwdthE.insert(0,GridWidth.get())
20145  #
20146  trglpflab = Label(frame1, text="Trigger LPF Length", style= "A10B.TLabel")
20147  trglpflab.grid(row=6, column=0, sticky=W)
20148  TrgLPFMode = Frame( frame1 )
20149  TrgLPFMode.grid(row=6, column=1, sticky=W)
20150  TrgLPFEntry = Entry(TrgLPFMode, width=4)
20151  TrgLPFEntry.bind("<Return>", SettingsTextKey)
20152  TrgLPFEntry.bind('<MouseWheel>', Settingsscroll)
20153  TrgLPFEntry.bind("<Button-4>", Settingsscroll)# with Linux OS
20154  TrgLPFEntry.bind("<Button-5>", Settingsscroll)
20155  TrgLPFEntry.bind('<Key>', SettingsTextKey)
20156  TrgLPFEntry.pack(side=RIGHT)
20157  TrgLPFEntry.delete(0,"end")
20158  TrgLPFEntry.insert(0,Trigger_LPF_length.get())
20159  #
20160  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
20161  AwgAmplrb1.grid(row=7, column=0, sticky=W)
20162  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
20163  AwgAmplrb2.grid(row=7, column=1, sticky=W)
20164  #
20165  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
20166  cha_Rcomplab.grid(row=8, column=0, sticky=W)
20167  cha_RcomplabMode = Frame( frame1 )
20168  cha_RcomplabMode.grid(row=8, column=1, sticky=W)
20169  cha_TC1Entry = Entry(cha_RcomplabMode, width=5)
20170  cha_TC1Entry.bind("<Return>", SettingsTextKey)
20171  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
20172  cha_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20173  cha_TC1Entry.bind("<Button-5>", Settingsscroll)
20174  cha_TC1Entry.bind('<Key>', SettingsTextKey)
20175  cha_TC1Entry.pack(side=LEFT)
20176  cha_TC1Entry.delete(0,"end")
20177  cha_TC1Entry.insert(0,CHA_TC1.get())
20178  cha_A1Entry = Entry(cha_RcomplabMode, width=5)
20179  cha_A1Entry.bind("<Return>", SettingsTextKey)
20180  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
20181  cha_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20182  cha_A1Entry.bind("<Button-5>", Settingsscroll)
20183  cha_A1Entry.bind('<Key>', SettingsTextKey)
20184  cha_A1Entry.pack(side=LEFT)
20185  cha_A1Entry.delete(0,"end")
20186  cha_A1Entry.insert(0,CHA_A1.get())
20187  #
20188  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
20189  cha_Ccomplab.grid(row=9, column=0, sticky=W)
20190  cha_CcomplabMode = Frame( frame1 )
20191  cha_CcomplabMode.grid(row=9, column=1, sticky=W)
20192  cha_TC2Entry = Entry(cha_CcomplabMode, width=5)
20193  cha_TC2Entry.bind("<Return>", SettingsTextKey)
20194  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
20195  cha_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20196  cha_TC2Entry.bind("<Button-5>", Settingsscroll)
20197  cha_TC2Entry.bind('<Key>', SettingsTextKey)
20198  cha_TC2Entry.pack(side=LEFT)
20199  cha_TC2Entry.delete(0,"end")
20200  cha_TC2Entry.insert(0,CHA_TC2.get())
20201  cha_A2Entry = Entry(cha_CcomplabMode, width=5)
20202  cha_A2Entry.bind("<Return>", SettingsTextKey)
20203  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
20204  cha_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20205  cha_A2Entry.bind("<Button-5>", Settingsscroll)
20206  cha_A2Entry.bind('<Key>', SettingsTextKey)
20207  cha_A2Entry.pack(side=LEFT)
20208  cha_A2Entry.delete(0,"end")
20209  cha_A2Entry.insert(0,CHA_A2.get())
20210  #
20211  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
20212  chb_Rcomplab.grid(row=10, column=0, sticky=W)
20213  chb_RcomplabMode = Frame( frame1 )
20214  chb_RcomplabMode.grid(row=10, column=1, sticky=W)
20215  chb_TC1Entry = Entry(chb_RcomplabMode, width=5)
20216  chb_TC1Entry.bind("<Return>", SettingsTextKey)
20217  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
20218  chb_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20219  chb_TC1Entry.bind("<Button-5>", Settingsscroll)
20220  chb_TC1Entry.bind('<Key>', SettingsTextKey)
20221  chb_TC1Entry.pack(side=LEFT)
20222  chb_TC1Entry.delete(0,"end")
20223  chb_TC1Entry.insert(0,CHB_TC1.get())
20224  chb_A1Entry = Entry(chb_RcomplabMode, width=5)
20225  chb_A1Entry.bind("<Return>", SettingsTextKey)
20226  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
20227  chb_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20228  chb_A1Entry.bind("<Button-5>", Settingsscroll)
20229  chb_A1Entry.bind('<Key>', SettingsTextKey)
20230  chb_A1Entry.pack(side=LEFT)
20231  chb_A1Entry.delete(0,"end")
20232  chb_A1Entry.insert(0,CHB_A1.get())
20233  #
20234  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
20235  chb_Ccomplab.grid(row=11, column=0, sticky=W)
20236  chb_CcomplabMode = Frame( frame1 )
20237  chb_CcomplabMode.grid(row=11, column=1, sticky=W)
20238  chb_TC2Entry = Entry(chb_CcomplabMode, width=5)
20239  chb_TC2Entry.bind("<Return>", SettingsTextKey)
20240  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
20241  chb_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20242  chb_TC2Entry.bind("<Button-5>", Settingsscroll)
20243  chb_TC2Entry.bind('<Key>', SettingsTextKey)
20244  chb_TC2Entry.pack(side=LEFT)
20245  chb_TC2Entry.delete(0,"end")
20246  chb_TC2Entry.insert(0,CHB_TC2.get())
20247  chb_A2Entry = Entry(chb_CcomplabMode, width=5)
20248  chb_A2Entry.bind("<Return>", SettingsTextKey)
20249  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
20250  chb_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20251  chb_A2Entry.bind("<Button-5>", Settingsscroll)
20252  chb_A2Entry.bind('<Key>', SettingsTextKey)
20253  chb_A2Entry.pack(side=LEFT)
20254  chb_A2Entry.delete(0,"end")
20255  chb_A2Entry.insert(0,CHB_A2.get())
20256  #
20257  if EnableHSsampling > 0:
20258  hs_ckb1 = Checkbutton(frame1, text="Auto Set ETS Comp", variable=Auto_ETS_Comp, command=SetETSComp)
20259  hs_ckb1.grid(row=12, column=0, sticky=W)
20260  hs1_Complab = Label(frame1, text="ETS Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
20261  hs1_Complab.grid(row=13, column=0, sticky=W)
20262  hs1_ComplabMode = Frame( frame1 )
20263  hs1_ComplabMode.grid(row=13, column=1, sticky=W)
20264  ets_TC1Entry = Entry(hs1_ComplabMode, width=5)
20265  ets_TC1Entry.bind("<Return>", SettingsTextKey)
20266  ets_TC1Entry.bind('<MouseWheel>', Settingsscroll)
20267  ets_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20268  ets_TC1Entry.bind("<Button-5>", Settingsscroll)
20269  ets_TC1Entry.bind('<Key>', SettingsTextKey)
20270  ets_TC1Entry.pack(side=LEFT)
20271  ets_TC1Entry.delete(0,"end")
20272  ets_TC1Entry.insert(0,ETS_TC1.get())
20273  ets_A1Entry = Entry(hs1_ComplabMode, width=5)
20274  ets_A1Entry.bind("<Return>", SettingsTextKey)
20275  ets_A1Entry.bind('<MouseWheel>', Settingsscroll)
20276  ets_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20277  ets_A1Entry.bind("<Button-5>", Settingsscroll)
20278  ets_A1Entry.bind('<Key>', SettingsTextKey)
20279  ets_A1Entry.pack(side=LEFT)
20280  ets_A1Entry.delete(0,"end")
20281  ets_A1Entry.insert(0,ETS_A1.get())
20282  #
20283  hs2_Complab = Label(frame1, text="ETS Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
20284  hs2_Complab.grid(row=14, column=0, sticky=W)
20285  hs2_ComplabMode = Frame( frame1 )
20286  hs2_ComplabMode.grid(row=14, column=1, sticky=W)
20287  ets_TC2Entry = Entry(hs2_ComplabMode, width=5)
20288  ets_TC2Entry.bind("<Return>", SettingsTextKey)
20289  ets_TC2Entry.bind('<MouseWheel>', Settingsscroll)
20290  ets_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20291  ets_TC2Entry.bind("<Button-5>", Settingsscroll)
20292  ets_TC2Entry.bind('<Key>', SettingsTextKey)
20293  ets_TC2Entry.pack(side=LEFT)
20294  ets_TC2Entry.delete(0,"end")
20295  ets_TC2Entry.insert(0,ETS_TC2.get())
20296  ets_A2Entry = Entry(hs2_ComplabMode, width=5)
20297  ets_A2Entry.bind("<Return>", SettingsTextKey)
20298  ets_A2Entry.bind('<MouseWheel>', Settingsscroll)
20299  ets_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
20300  ets_A2Entry.bind("<Button-5>", Settingsscroll)
20301  ets_A2Entry.bind('<Key>', SettingsTextKey)
20302  ets_A2Entry.pack(side=LEFT)
20303  ets_A2Entry.delete(0,"end")
20304  ets_A2Entry.insert(0,ETS_A2.get())
20305  #
20306  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
20307  Settingsdismissbutton.grid(row=15, column=0, sticky=W, pady=7)
20308  else:
20309  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
20310  Settingsdismissbutton.grid(row=12, column=0, sticky=W, pady=7)
20311 #
20313  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
20314  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
20315  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
20316  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
20317  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
20318  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
20319 
20320  if Auto_ETS_Comp.get() == 1:
20321  try:
20322  MulX = float(HtMulEntry.get())
20323  #
20324  Value = float(ets_TC1Entry.get()) * MulX
20325  cha_TC1Entry.delete(0,"end")
20326  cha_TC1Entry.insert(0, Value)
20327  cha_A1Entry.delete(0,"end")
20328  cha_A1Entry.insert(0, ets_A1Entry.get())
20329  chb_TC1Entry.delete(0,"end")
20330  chb_TC1Entry.insert(0, Value)
20331  chb_A1Entry.delete(0,"end")
20332  chb_A1Entry.insert(0, ets_A1Entry.get())
20333  #
20334  Value = float(ets_TC2Entry.get()) * MulX
20335  cha_TC2Entry.delete(0,"end")
20336  cha_TC2Entry.insert(0, Value)
20337  cha_A2Entry.delete(0,"end")
20338  cha_A2Entry.insert(0, ets_A2Entry.get())
20339  chb_TC2Entry.delete(0,"end")
20340  chb_TC2Entry.insert(0, Value)
20341  chb_A2Entry.delete(0,"end")
20342  chb_A2Entry.insert(0, ets_A2Entry.get())
20343  except:
20344  MulX = 1.0
20345 
20347 
20348  UpdateAWGA()
20349  UpdateAWGB()
20350  ReMakeAWGwaves()
20351 
20353  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
20354  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
20355  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
20356  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, TrgLPFEntry, Trigger_LPF_length
20357  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
20358  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
20359 
20360  try:
20361  GW = int(eval(GwdthE.get()))
20362  if GW < 1:
20363  GW = 1
20364  GwdthE.delete(0,END)
20365  GwdthE.insert(0, int(GW))
20366  if GW > 5:
20367  GW = 5
20368  GwdthE.delete(0,END)
20369  GwdthE.insert(0, int(GW))
20370  except:
20371  GwdthE.delete(0,END)
20372  GwdthE.insert(0, GridWidth.get())
20373  GridWidth.set(GW)
20374  #
20375  try:
20376  T_length = int(eval(TrgLPFEntry.get()))
20377  if T_length < 1:
20378  T_length = 1
20379  TrgLPFEntry.delete(0,END)
20380  TrgLPFEntry.insert(0, int(GW))
20381  if T_length > 100:
20382  T_length = 100
20383  TrgLPFEntry.delete(0,END)
20384  TrgLPFEntry.insert(0, int(GW))
20385  except:
20386  TrgLPFEntry.delete(0,END)
20387  TrgLPFEntry.insert(0, Trigger_LPF_length.get())
20388  Trigger_LPF_length.set(T_length)
20389  #
20390  try:
20391  TW = int(eval(TwdthE.get()))
20392  if TW < 1:
20393  TW = 1
20394  TwdthE.delete(0,END)
20395  TwdthE.insert(0, int(TW))
20396  if TW > 5:
20397  TW = 5
20398  TwdthE.delete(0,END)
20399  TwdthE.insert(0, int(TW))
20400  except:
20401  TwdthE.delete(0,END)
20402  TwdthE.insert(0, TRACEwidth.get())
20403  TRACEwidth.set(TW)
20404  # Number of average sweeps for average mode
20405  try:
20406  TA = int(eval(TAvg.get()))
20407  if TA < 1:
20408  TA = 1
20409  TAvg.delete(0,END)
20410  TAvg.insert(0, int(TA))
20411  if TA > 16:
20412  TA = 16
20413  TAvg.delete(0,END)
20414  TAvg.insert(0, int(TA))
20415  except:
20416  TAvg.delete(0,END)
20417  TAvg.insert(0, TRACEaverage.get())
20418  TRACEaverage.set(TA)
20419  # Number of vertical divisions for spectrum / Bode
20420  try:
20421  VDv = int(eval(VDivE.get()))
20422  if VDv < 1:
20423  VDv = 1
20424  VDivE.delete(0,END)
20425  VDivE.insert(0, int(VDv))
20426  if VDv > 16:
20427  VDv = 16
20428  VDivE.delete(0,END)
20429  VDivE.insert(0, int(VDv))
20430  except:
20431  VDivE.delete(0,END)
20432  VDivE.insert(0, Vdiv.get())
20433  Vdiv.set(VDv)
20434  # number of Harmonic Markers in SA
20435  try:
20436  HM = int(eval(HarMon.get()))
20437  if HM < 1:
20438  HM = 1
20439  HarMon.delete(0,END)
20440  HarMon.insert(0, int(HM))
20441  if HM > 9:
20442  HM =9
20443  HarMon.delete(0,END)
20444  HarMon.insert(0, int(HM))
20445  except:
20446  HarMon.delete(0,END)
20447  HarMon.insert(0, HarmonicMarkers.get())
20448  HarmonicMarkers.set(HM)
20449  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
20450  try:
20451  ZST = int(eval(ZSTuff.get()))
20452  if ZST < 1:
20453  ZST = 1
20454  ZSTuff.delete(0,END)
20455  ZSTuff.insert(0, int(ZST))
20456  if ZST > 5:
20457  ZST = 5
20458  ZSTuff.delete(0,END)
20459  ZSTuff.insert(0, int(ZST))
20460  except:
20461  ZSTuff.delete(0,END)
20462  ZSTuff.insert(0, ZEROstuffing.get())
20463  ZEROstuffing.set(ZST)
20464 #
20465  try:
20466  TC1A = float(cha_TC1Entry.get())
20467  CHA_TC1.set(TC1A)
20468  if TC1A < 0:
20469  TC1A = 0
20470  cha_TC1Entry.delete(0,END)
20471  cha_TC1Entry.insert(0, TC1A)
20472  except:
20473  cha_TC1Entry.delete(0,END)
20474  cha_TC1Entry.insert(0, CHA_TC1.get())
20475  try:
20476  TC2A = float(cha_TC2Entry.get())
20477  CHA_TC2.set(TC2A)
20478  if TC2A < 0:
20479  TC2A = 0
20480  cha_TC2Entry.delete(0,END)
20481  cha_TC2Entry.insert(0, TC2A)
20482  except:
20483  cha_TC2Entry.delete(0,END)
20484  cha_TC2Entry.insert(0, CHA_TC2.get())
20485  #
20486  try:
20487  Gain1A = float(cha_A1Entry.get())
20488  CHA_A1.set(Gain1A)
20489  except:
20490  cha_A1Entry.delete(0,END)
20491  cha_A1Entry.insert(0, CHA_A1.get())
20492  try:
20493  Gain2A = float(cha_A2Entry.get())
20494  CHA_A2.set(Gain2A)
20495  except:
20496  cha_A2Entry.delete(0,END)
20497  cha_A2Entry.insert(0, CHA_A2.get())
20498  #
20499  try:
20500  TC1B = float(chb_TC1Entry.get())
20501  CHB_TC1.set(TC1B)
20502  if TC1B < 0:
20503  TC1B = 0
20504  chb_TC1Entry.delete(0, END)
20505  chb_TC1Entry.insert(0, TC1B)
20506  except:
20507  chb_TC1Entry.delete(0,END)
20508  chb_TC1Entry.insert(0, CHB_TC1.get())
20509  try:
20510  TC2B = float(chb_TC2Entry.get())
20511  CHB_TC2.set(TC2B)
20512  if TC2B < 0:
20513  TC2B = 0
20514  chb_TC2Entry.delete(0, END)
20515  chb_TC2Entry.insert(0, TC2B)
20516  except:
20517  chb_TC2Entry.delete(0,END)
20518  chb_TC2Entry.insert(0, CHB_TC2.get())
20519  #
20520  try:
20521  Gain1B = float(chb_A1Entry.get())
20522  CHB_A1.set(Gain1B)
20523  except:
20524  chb_A1Entry.delete(0,END)
20525  chb_A1Entry.insert(0, CHB_A1.get())
20526  try:
20527  Gain2B = float(chb_A2Entry.get())
20528  CHB_A2.set(Gain2B)
20529  except:
20530  chb_A2Entry.delete(0,END)
20531  chb_A2Entry.insert(0, CHB_A2.get())
20532  # set ETS base comp
20533  #
20534  SetETSComp()
20535 #
20537  global Settingswindow, SettingsStatus
20538 
20539  SettingsStatus.set(0)
20540  SettingsUpdate()
20541  Settingswindow.destroy()
20542 #
20543 def onCanvasMouse_xy(event):
20544  global MouseX, MouseY, MouseWidget
20545 
20546  MouseWidget = event.widget
20547  MouseX, MouseY = event.x, event.y
20548 #
20549 def BSetFmin():
20550  global FminEntry, CHAfreq
20551 
20552  if CHAfreq > 0:
20553  String = '{0:.3f}'.format(CHAfreq/1000)
20554  FminEntry.delete(0,"end")
20555  FminEntry.insert(0,String)
20556 #
20557 # ================ Make main Screen ==========================
20558 TgInput = IntVar(0) # Trigger Input variable
20559 SingleShot = IntVar(0) # variable for single shot triger
20560 ManualTrigger = IntVar(0) # variable for Manual trigger
20561 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
20562 ShowC1_V = IntVar(0) # curves to display variables
20563 TgEdge = IntVar(0) # Trigger edge variable
20564 # Show channels variables
20565 ShowC1_V = IntVar(0) # curves to display variables
20566 ShowC1_I = IntVar(0)
20567 ShowC2_V = IntVar(0)
20568 ShowC2_I = IntVar(0)
20569 ShowAV_I = IntVar(0)
20570 ShowBV_I = IntVar(0)
20571 ShowRA_V = IntVar(0)
20572 ShowRA_I = IntVar(0)
20573 ShowRB_V = IntVar(0)
20574 ShowRB_I = IntVar(0)
20575 ShowMath = IntVar(0)
20576 ShowPB_A = IntVar(0)
20577 ShowPB_B = IntVar(0)
20578 ShowPB_C = IntVar(0)
20579 ShowPB_D = IntVar(0)
20580 Show_MathX = IntVar(0)
20581 Show_MathY = IntVar(0)
20582 AutoCenterA = IntVar(0)
20583 AutoCenterB = IntVar(0)
20584 SmoothCurves = IntVar(0)
20585 ZOHold = IntVar(0)
20586 TRACEmodeTime = IntVar(0)
20587 TRACEmodeTime.set(0)
20588 ColorMode = IntVar(0)
20589 DecimateOption = IntVar(0)
20590 MathTrace = IntVar(0)
20591 # define vertical measurment variables
20592 MeasDCV1 = IntVar(0)
20593 MeasMinV1 = IntVar(0)
20594 MeasMaxV1 = IntVar(0)
20595 MeasMidV1 = IntVar(0)
20596 MeasPPV1 = IntVar(0)
20597 MeasRMSV1 = IntVar(0)
20598 MeasRMSVA_B = IntVar(0)
20599 MeasDCI1 = IntVar(0)
20600 MeasMinI1 = IntVar(0)
20601 MeasMaxI1 = IntVar(0)
20602 MeasMidI1 = IntVar(0)
20603 MeasPPI1 = IntVar(0)
20604 MeasRMSI1 = IntVar(0)
20605 MeasDiffAB = IntVar(0)
20606 MeasDCV2 = IntVar(0)
20607 MeasMinV2 = IntVar(0)
20608 MeasMaxV2 = IntVar(0)
20609 MeasMidV2 = IntVar(0)
20610 MeasPPV2 = IntVar(0)
20611 MeasRMSV2 = IntVar(0)
20612 MeasDCI2 = IntVar(0)
20613 MeasMinI2 = IntVar(0)
20614 MeasMaxI2 = IntVar(0)
20615 MeasMidI2 = IntVar(0)
20616 MeasPPI2 = IntVar(0)
20617 MeasRMSI2 = IntVar(0)
20618 MeasDiffBA = IntVar(0)
20619 MeasUserA = IntVar(0)
20620 MeasAHW = IntVar(0)
20621 MeasALW = IntVar(0)
20622 MeasADCy = IntVar(0)
20623 MeasAPER = IntVar(0)
20624 MeasAFREQ = IntVar(0)
20625 MeasBHW = IntVar(0)
20626 MeasBLW = IntVar(0)
20627 MeasBDCy = IntVar(0)
20628 MeasBPER = IntVar(0)
20629 MeasBFREQ = IntVar(0)
20630 MeasPhase = IntVar(0)
20631 MeasTopV1 = IntVar(0)
20632 MeasBaseV1 = IntVar(0)
20633 MeasTopV2 = IntVar(0)
20634 MeasBaseV2 = IntVar(0)
20635 MeasUserB = IntVar(0)
20636 MeasDelay = IntVar(0)
20637 TimeDisp = IntVar(0)
20638 TimeDisp.set(1)
20639 XYDisp = IntVar(0)
20640 FreqDisp = IntVar(0)
20641 PhADisp = IntVar(0)
20642 BodeDisp = IntVar(0)
20643 IADisp = IntVar(0)
20644 OhmDisp = IntVar(0)
20645 PhAScreenStatus = IntVar(0)
20646 PhAScreenStatus.set(0)
20647 AppendPhAData = IntVar(0)
20648 AppendPhAData.set(0)
20649 PhAPlotMode = IntVar(0)
20650 PhADatafilename = "PhaseData.csv"
20651 BodeScreenStatus = IntVar(0)
20652 BodeScreenStatus.set(0)
20653 DigScreenStatus = IntVar(0)
20654 DigScreenStatus.set(0)
20655 DacScreenStatus = IntVar(0)
20656 DacScreenStatus.set(0)
20657 MuxScreenStatus = IntVar(0)
20658 MuxScreenStatus.set(0)
20659 DualMuxMode = IntVar(0)
20660 MinigenScreenStatus = IntVar(0)
20661 MinigenScreenStatus.set(0)
20662 DA1ScreenStatus = IntVar(0)
20663 DA1ScreenStatus.set(0)
20664 DigPotScreenStatus = IntVar(0)
20665 DigPotScreenStatus.set(0)
20666 GenericSerialStatus = IntVar(0)
20667 GenericSerialStatus.set(0)
20668 AD5626SerialStatus = IntVar(0)
20669 AD5626SerialStatus.set(0)
20670 DigFiltStatus = IntVar(0)
20671 DigFiltStatus.set(0)
20672 CommandStatus = IntVar(0)
20673 CommandStatus.set(0)
20674 MeasureStatus = IntVar(0)
20675 MeasureStatus.set(0)
20676 MarkerScale = IntVar(0)
20677 MarkerScale.set(1)
20678 SettingsStatus = IntVar(0)
20679 CHA_RC_HP = IntVar(0)
20680 CHB_RC_HP = IntVar(0)
20681 CHAI_RC_HP = IntVar(0)
20682 CHBI_RC_HP = IntVar(0)
20683 #
20684 frame2r = Frame(root, borderwidth=5, relief=RIDGE)
20685 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
20686 
20687 frame1 = Frame(root, borderwidth=5, relief=RIDGE)
20688 frame1.pack(side=TOP, fill=BOTH, expand=NO)
20689 
20690 frame2 = Frame(root, borderwidth=5, relief=RIDGE)
20691 frame2.pack(side=TOP, fill=BOTH, expand=YES)
20692 
20693 frame3 = Frame(root, borderwidth=5, relief=RIDGE)
20694 frame3.pack(side=TOP, fill=BOTH, expand=NO)
20695 # define custom buttons
20696 root.style.configure("W3.TButton", width=3, relief=RAISED)
20697 root.style.configure("W4.TButton", width=4, relief=RAISED)
20698 root.style.configure("W5.TButton", width=5, relief=RAISED)
20699 root.style.configure("W6.TButton", width=6, relief=RAISED)
20700 root.style.configure("W7.TButton", width=7, relief=RAISED)
20701 root.style.configure("W8.TButton", width=8, relief=RAISED)
20702 root.style.configure("W9.TButton", width=9, relief=RAISED)
20703 root.style.configure("W10.TButton", width=10, relief=RAISED)
20704 root.style.configure("W11.TButton", width=11, relief=RAISED)
20705 root.style.configure("W16.TButton", width=16, relief=RAISED)
20706 root.style.configure("W17.TButton", width=17, relief=RAISED)
20707 root.style.configure("Stop.TButton", background=ButtonRed, width=4, relief=RAISED)
20708 root.style.configure("Run.TButton", background=ButtonGreen, width=4, relief=RAISED)
20709 root.style.configure("Pwr.TButton", background=ButtonGreen, width=7, relief=RAISED)
20710 root.style.configure("PwrOff.TButton", background=ButtonRed, width=7, relief=RAISED)
20711 root.style.configure("RConn.TButton", background=ButtonRed, width=5, relief=RAISED)
20712 root.style.configure("GConn.TButton", background=ButtonGreen, width=5, relief=RAISED)
20713 root.style.configure("Rtrace1.TButton", background=COLORtrace1, width=7, relief=RAISED)
20714 root.style.configure("Strace1.TButton", background=COLORtrace1, width=7, relief=SUNKEN)
20715 root.style.configure("Rtrace2.TButton", background=COLORtrace2, width=7, relief=RAISED)
20716 root.style.configure("Strace2.TButton", background=COLORtrace2, width=7, relief=SUNKEN)
20717 root.style.configure("Rtrace3.TButton", background=COLORtrace3, width=7, relief=RAISED)
20718 root.style.configure("Strace3.TButton", background=COLORtrace3, width=7, relief=SUNKEN)
20719 root.style.configure("Rtrace4.TButton", background=COLORtrace4, width=7, relief=RAISED)
20720 root.style.configure("Strace4.TButton", background=COLORtrace4, width=7, relief=SUNKEN)
20721 root.style.configure("Rtrace6.TButton", background=COLORtrace6, width=7, relief=RAISED)
20722 root.style.configure("Strace6.TButton", background=COLORtrace6, width=7, relief=SUNKEN)
20723 root.style.configure("Rtrace7.TButton", background=COLORtrace7, width=7, relief=RAISED)
20724 root.style.configure("Strace7.TButton", background=COLORtrace7, width=7, relief=SUNKEN)
20725 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
20726 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
20727 root.style.configure("A10R1.TLabelframe.Label", foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
20728 root.style.configure("A10R1.TLabelframe", borderwidth=5, relief=RIDGE)
20729 root.style.configure("A10R2.TLabelframe.Label", foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
20730 root.style.configure("A10R2.TLabelframe", borderwidth=5, relief=RIDGE)
20731 root.style.configure("A10B.TLabel", foreground=COLORcanvas, font="Arial 10 bold") # Black text
20732 root.style.configure("A10R.TLabel", foreground=ButtonRed, font="Arial 10 bold") # Red text
20733 root.style.configure("A10G.TLabel", foreground=ButtonGreen, font="Arial 10 bold") # Red text
20734 root.style.configure("A12B.TLabel", foreground=COLORcanvas, font="Arial 12 bold") # Black text
20735 root.style.configure("A16B.TLabel", foreground=COLORcanvas, font="Arial 16 bold") # Black text
20736 root.style.configure("Stop.TRadiobutton", background=ButtonRed)
20737 root.style.configure("Run.TRadiobutton", background=ButtonGreen)
20738 root.style.configure("Disab.TCheckbutton", indicatorcolor=ButtonRed)
20739 root.style.configure("Enab.TCheckbutton", indicatorcolor=ButtonGreen)
20740 root.style.configure("Strace1.TCheckbutton", background=COLORtrace1)
20741 root.style.configure("Strace2.TCheckbutton", background=COLORtrace2)
20742 root.style.configure("Strace3.TCheckbutton", background=COLORtrace3)
20743 root.style.configure("Strace4.TCheckbutton", background=COLORtrace4)
20744 root.style.configure("Strace6.TCheckbutton", background=COLORtrace6)
20745 root.style.configure("Strace7.TCheckbutton", background=COLORtrace7)
20746 root.style.configure("WPhase.TRadiobutton", width=5, background="white", indicatorcolor=("red", "green"))
20747 root.style.configure("GPhase.TRadiobutton", width=5, background="gray", indicatorcolor=("red", "green"))
20748 # create a pulldown menu
20749 # Trigger signals
20750 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
20751 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
20752 Triggermenu["menu"] = Triggermenu.menu
20753 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
20754 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
20755 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
20756 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
20757 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
20758 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
20759 Triggermenu.menu.add_checkbutton(label='Low Pass Filter', variable=LPFTrigger)
20760 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
20761 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
20762 Triggermenu.pack(side=LEFT)
20763 #
20764 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
20765 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
20766 Edgemenu["menu"] = Edgemenu.menu
20767 Edgemenu.menu.add_radiobutton(label='Rising [+]', variable=TgEdge, value=0)
20768 Edgemenu.menu.add_radiobutton(label='Falling [-]', variable=TgEdge, value=1)
20769 Edgemenu.pack(side=LEFT)
20770 #
20771 tlab = Label(frame1, text="Trig Level")
20772 tlab.pack(side=LEFT)
20773 TRIGGERentry = Entry(frame1, width=5)
20774 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
20775 TRIGGERentry.bind("<Button-4>", onTextScroll)# with Linux OS
20776 TRIGGERentry.bind("<Button-5>", onTextScroll)
20777 TRIGGERentry.bind("<Return>", BTriglevel)
20778 TRIGGERentry.bind('<Key>', onTextKey)
20779 TRIGGERentry.pack(side=LEFT)
20780 TRIGGERentry.delete(0,"end")
20781 TRIGGERentry.insert(0,0.0)
20782 #
20783 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
20784 tgb.pack(side=LEFT)
20785 #
20786 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
20787 hldlab.pack(side=LEFT)
20788 HoldOffentry = Entry(frame1, width=4)
20789 HoldOffentry.bind('<MouseWheel>', onTextScroll)
20790 HoldOffentry.bind("<Button-4>", onTextScroll)# with Linux OS
20791 HoldOffentry.bind("<Button-5>", onTextScroll)
20792 HoldOffentry.bind("<Return>", BHoldOff)
20793 HoldOffentry.bind('<Key>', onTextKey)
20794 HoldOffentry.pack(side=LEFT)
20795 HoldOffentry.delete(0,"end")
20796 HoldOffentry.insert(0,0.0)
20797 #
20798 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
20799 hozlab.pack(side=LEFT)
20800 HozPossentry = Entry(frame1, width=4)
20801 HozPossentry.bind('<MouseWheel>', onTextScroll)
20802 HozPossentry.bind("<Button-4>", onTextScroll)# with Linux OS
20803 HozPossentry.bind("<Button-5>", onTextScroll)
20804 HozPossentry.bind("<Return>", BHozPoss)
20805 HozPossentry.bind('<Key>', onTextKey)
20806 HozPossentry.pack(side=LEFT)
20807 HozPossentry.delete(0,"end")
20808 HozPossentry.insert(0,0.0)
20809 #
20810 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
20811 bexit.pack(side=RIGHT)
20812 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
20813 bstop.pack(side=RIGHT)
20814 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
20815 brun.pack(side=RIGHT)
20816 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
20817 PwrBt.pack(side=RIGHT)
20818 # Curves Menu , background="#A0A0A0"
20819 Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
20820 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
20821 Showmenu["menu"] = Showmenu.menu
20822 Showmenu.menu.add_command(label="-Show-", foreground="blue", command=donothing)
20823 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
20824 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
20825 Showmenu.menu.add_checkbutton(label='CA-V [1]', background=COLORtrace1, variable=ShowC1_V, command=TraceSelectADC_Mux)
20826 Showmenu.menu.add_checkbutton(label='CA-I [3]', background=COLORtrace3, variable=ShowC1_I, command=TraceSelectADC_Mux)
20827 Showmenu.menu.add_checkbutton(label='CB-V [2]', background=COLORtrace2, variable=ShowC2_V, command=TraceSelectADC_Mux)
20828 Showmenu.menu.add_checkbutton(label='CB-I [4]', background=COLORtrace4,variable=ShowC2_I, command=TraceSelectADC_Mux)
20829 Showmenu.menu.add_checkbutton(label='Math-X', background=COLORtrace6, variable=Show_MathX, command=UpdateTimeTrace)
20830 Showmenu.menu.add_checkbutton(label='Math-Y', background=COLORtrace7, variable=Show_MathY, command=UpdateTimeTrace)
20831 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
20832 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
20833 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
20834 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
20835 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
20836 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
20837 if EnableHSsampling > 0:
20838  Showmenu.menu.add_checkbutton(label='Comp CA-I', variable=CHAI_RC_HP)
20839  Showmenu.menu.add_checkbutton(label='Comp CB-I', variable=CHBI_RC_HP)
20840 Showmenu.menu.add_separator()
20841 Showmenu.menu.add_checkbutton(label='RA-V', background=COLORtraceR1, variable=ShowRA_V, command=UpdateTimeTrace)
20842 Showmenu.menu.add_checkbutton(label='RA-I', background=COLORtraceR3, variable=ShowRA_I, command=UpdateTimeTrace)
20843 Showmenu.menu.add_checkbutton(label='RB-V', background=COLORtraceR2, variable=ShowRB_V, command=UpdateTimeTrace)
20844 Showmenu.menu.add_checkbutton(label='RB-I', background=COLORtraceR4, variable=ShowRB_I, command=UpdateTimeTrace)
20845 Showmenu.menu.add_checkbutton(label='RMath', background=COLORtraceR5, variable=ShowMath, command=UpdateTimeTrace)
20846 Showmenu.menu.add_separator()
20847 Showmenu.menu.add_checkbutton(label='T Cursor [t]', variable=ShowTCur, command=UpdateTimeTrace)
20848 Showmenu.menu.add_checkbutton(label='V Cursor [v]', variable=ShowVCur, command=UpdateTimeTrace)
20849 Showmenu.pack(side=RIGHT)
20850 #
20851 if ShowBallonHelp > 0:
20852  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
20853  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
20854  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
20855  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
20856  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
20857  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
20858  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
20859  brun_tip = CreateToolTip(brun, 'Start acquiring data')
20860  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
20861  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
20862 
20863 # Sampling controls Widgets
20864 if EnableHSsampling > 0:
20865  fminlab2 = Label(frame1, text="KHz")
20866  fminlab2.pack(side=RIGHT)
20867  FminEntry = Entry(frame1, width=6)
20868  FminEntry.bind('<MouseWheel>', onFminScroll)
20869  FminEntry.bind("<Button-4>", onFminScroll)# with Linux OS
20870  FminEntry.bind("<Button-5>", onFminScroll)
20871  FminEntry.bind("<Return>", SetAD9833)
20872  FminEntry.pack(side=RIGHT)
20873  FminEntry.delete(0,"end")
20874  FminEntry.insert(0,25)
20875  fminlab = Button(frame1, text="Fmin", style="W5.TButton", command=BSetFmin)
20876  fminlab.pack(side=RIGHT)
20877  #
20878  HtMulEntry = Entry(frame1, width=4)
20879  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
20880  HtMulEntry.bind("<Button-4>", onMulXScroll)# with Linux OS
20881  HtMulEntry.bind("<Button-5>", onMulXScroll)
20882  HtMulEntry.bind("<Return>", SetAD9833)
20883  HtMulEntry.pack(side=RIGHT)
20884  HtMulEntry.delete(0,"end")
20885  HtMulEntry.insert(0,1)
20886  mulxlab = Label( frame1, text = "Mul X")
20887  mulxlab.pack(side=RIGHT)
20888 #
20889 # Time per Div
20890 TMsb = Spinbox(frame1, width=5, values= TMpdiv, command=BTime)
20891 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
20892 TMsb.pack(side=RIGHT)
20893 TMsb.delete(0,"end")
20894 TMsb.insert(0,0.5)
20895 TMlab = Label(frame1, text="Time mS/Div")
20896 TMlab.pack(side=RIGHT)
20897 #
20898 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
20899 # add mouse left and right button click to canvas
20900 ca.bind('<Configure>', CAresize)
20901 ca.bind('<1>', onCanvasClickLeft)
20902 ca.bind('<3>', onCanvasClickRight)
20903 ca.bind("<Motion>",onCanvasMouse_xy)
20904 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
20905 ca.bind("<Down>", onCanvasDownArrow)
20906 ca.bind("<Left>", onCanvasLeftArrow)
20907 ca.bind("<Right>", onCanvasRightArrow)
20908 ca.bind("<space>", onCanvasSpaceBar)
20909 ca.bind("1", onCanvasOne)
20910 ca.bind("2", onCanvasTwo)
20911 ca.bind("3", onCanvasThree)
20912 ca.bind("4", onCanvasFour)
20913 ca.bind("5", onCanvasFive)
20914 ca.bind("6", onCanvasSix)
20915 ca.bind("7", onCanvasSeven)
20916 ca.bind("8", onCanvasEight)
20917 ca.bind("9", onCanvasNine)
20918 ca.bind("0", onCanvasZero)
20919 ca.bind("a", onCanvasAverage)
20920 ca.bind("t", onCanvasShowTcur)
20921 ca.bind("v", onCanvasShowVcur)
20922 ca.bind("s", onCanvasSnap)
20923 ca.bind("+", onCanvasTrising)
20924 ca.bind("-", onCanvasTfalling)
20925 ca.bind('<MouseWheel>', onCanvasClickScroll)
20926 ca.bind("<Button-4>", onCanvasClickScroll)# with Linux OS
20927 ca.bind("<Button-5>", onCanvasClickScroll)
20928 ca.pack(side=TOP, fill=BOTH, expand=YES)
20929 MouseWidget = ca
20930 # right side menu buttons
20931 dropmenu = Frame( frame2r )
20932 dropmenu.pack(side=TOP)
20933 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
20934 bcon.pack(side=LEFT, anchor=W)
20935 # File menu
20936 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
20937 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
20938 Filemenu["menu"] = Filemenu.menu
20939 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
20940 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
20941 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
20942 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
20943 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
20944 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
20945 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
20946 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
20947 Filemenu.menu.add_command(label="Help", command=BHelp)
20948 Filemenu.menu.add_command(label="About", command=BAbout)
20949 Filemenu.pack(side=LEFT, anchor=W)
20950 # Options Menu
20951 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
20952 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
20953 Optionmenu["menu"] = Optionmenu.menu
20954 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
20955 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
20956 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
20957 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
20958 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
20959 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
20960 Optionmenu.menu.add_checkbutton(label='Trace Avg [a]', variable=TRACEmodeTime)
20961 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
20962 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
20963 Optionmenu.menu.add_command(label='Change Plot Label', command=BUserCustomPlotText)
20964 Optionmenu.menu.add_command(label="SnapShot [s]", command=BSnapShot)
20965 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
20966 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
20967 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
20968 if AllowFlashFirmware == 1:
20969  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
20970  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
20971 Optionmenu.pack(side=LEFT, anchor=W)
20972 #
20973 dropmenu2 = Frame( frame2r )
20974 dropmenu2.pack(side=TOP)
20975 # Open Math trace menu
20976 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
20977 mathbt.pack(side=RIGHT, anchor=W)
20978 # Measurments menu
20979 measlab = Label(dropmenu2, text="Meas")
20980 measlab.pack(side=LEFT, anchor=W)
20981 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
20982 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
20983 MeasmenuA["menu"] = MeasmenuA.menu
20984 MeasmenuA.menu.add_command(label="-CA-V-", foreground="blue", command=donothing)
20985 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
20986 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
20987 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
20988 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
20989 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
20990 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
20991 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
20992 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
20993 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
20994 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
20995 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
20996 #MeasmenuA.menu.add_separator()
20997 MeasmenuA.menu.add_command(label="-CA-I-", foreground="blue", command=donothing)
20998 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
20999 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
21000 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
21001 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
21002 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
21003 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
21004 #MeasmenuA.menu.add_separator()
21005 MeasmenuA.menu.add_command(label="-CA-Time-", foreground="blue", command=donothing)
21006 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
21007 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
21008 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
21009 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
21010 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
21011 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
21012 #
21013 MeasmenuA.pack(side=LEFT)
21014 #
21015 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
21016 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
21017 MeasmenuB["menu"] = MeasmenuB.menu
21018 MeasmenuB.menu.add_command(label="-CB-V-", foreground="blue", command=donothing)
21019 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
21020 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
21021 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
21022 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
21023 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
21024 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
21025 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
21026 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
21027 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
21028 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
21029 #MeasmenuB.menu.add_separator()
21030 MeasmenuB.menu.add_command(label="-CB-I-", foreground="blue", command=donothing)
21031 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
21032 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
21033 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
21034 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
21035 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
21036 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
21037 #MeasmenuB.menu.add_separator()
21038 MeasmenuB.menu.add_command(label="-CB-Time-", foreground="blue", command=donothing)
21039 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
21040 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
21041 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
21042 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
21043 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
21044 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
21045 MeasmenuB.pack(side=LEFT)
21046 #
21047 BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
21048 BuildAWGScreen.pack(side=TOP)
21049 # Mode selector
21050 timebtn = Frame( frame2r )
21051 timebtn.pack(side=TOP)
21052 ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
21053 ckb1.pack(side=LEFT)
21054 timelab = Label(timebtn, text="Time Plot")
21055 timelab.pack(side=LEFT)
21056 if EnableXYPlotter > 0:
21057  xybtn = Frame( frame2r )
21058  xybtn.pack(side=TOP)
21059  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
21060  ckb2.pack(side=LEFT)
21061  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
21062  BuildXYScreen.pack(side=TOP)
21063 #
21064 if EnablePhaseAnalizer > 0:
21065  phasebtn = Frame( frame2r )
21066  phasebtn.pack(side=TOP)
21067  phckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
21068  phckb.pack(side=LEFT)
21069  BuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
21070  BuildPhAScreen.pack(side=LEFT)
21071 #
21072 if EnableSpectrumAnalizer > 0:
21073  freqbtn = Frame( frame2r )
21074  freqbtn.pack(side=TOP)
21075  ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
21076  ckb3.pack(side=LEFT)
21077  BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
21078  BuildSpectrumScreen.pack(side=LEFT)
21079 #
21080 if EnableBodePlotter > 0:
21081  bodebtn = Frame( frame2r )
21082  bodebtn.pack(side=TOP)
21083  ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
21084  ckb5.pack(side=LEFT)
21085  BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
21086  BuildBodeScreen.pack(side=LEFT)
21087 #
21088 if EnableImpedanceAnalizer > 0:
21089  impdbtn = Frame( frame2r )
21090  impdbtn.pack(side=TOP)
21091  ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
21092  ckb4.pack(side=LEFT)
21093  BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
21094  BuildIAScreen.pack(side=LEFT)
21095 #
21096 if EnableOhmMeter > 0:
21097  dcohmbtn = Frame( frame2r )
21098  dcohmbtn.pack(side=TOP)
21099  ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
21100  ckb6.pack(side=LEFT)
21101  BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
21102  BuildOhmScreen.pack(side=LEFT)
21103 #
21104 if ShowTraceControls > 0:
21105  ckbt1 = Checkbutton(frame2r, text='CA-V [1]', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
21106  ckbt1.pack(side=TOP)
21107  ckbt2 = Checkbutton(frame2r, text='CA-I [3]', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
21108  ckbt2.pack(side=TOP)
21109  ckbt3 = Checkbutton(frame2r, text='CB-V [2]', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
21110  ckbt3.pack(side=TOP)
21111  ckbt4 = Checkbutton(frame2r, text='CB-I [4]', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
21112  ckbt4.pack(side=TOP)
21113 
21114 if ShowBallonHelp > 0:
21115  math_tip = CreateToolTip(mathbt, 'Open Math window')
21116  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
21117  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
21118  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open spectrum analyzer window')
21119  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
21120  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance analyzer window')
21121  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
21122 # Digital Input / Output Option screens
21123 DigScreenStatus = IntVar(0)
21124 DigScreenStatus.set(0)
21125 if EnableDigIO > 0:
21126  BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
21127  BuildDigScreen.pack(side=TOP)
21128 #
21129 # Optional plugin tools
21130 if EnablePIODACMode > 0:
21131  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
21132  BuildDacScreen.pack(side=TOP)
21133 if EnableMuxMode > 0:
21134  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
21135  BuildMuxScreen.pack(side=TOP)
21136 if EnableMinigenMode > 0:
21137  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
21138  BuildMinigenScreen.pack(side=TOP)
21139 if EnablePmodDA1Mode > 0:
21140  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
21141  BuildDA1Screen.pack(side=TOP)
21142 if EnableDigPotMode >0:
21143  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
21144  BuildDigPotScreen.pack(side=TOP)
21145 if EnableGenericSerialMode >0:
21146  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
21147  GenericSerialScreen.pack(side=TOP)
21148 if EnableAD5626SerialMode >0:
21149  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
21150  AD5626SerialScreen.pack(side=TOP)
21151 if EnableDigitalFilter >0:
21152  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
21153  DigFiltScreen.pack(side=TOP)
21154 if EnableCommandInterface > 0:
21155  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
21156  CommandLineScreen.pack(side=TOP)
21157 if EnableMeasureScreen > 0:
21158  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
21159  MeasureScreen.pack(side=TOP)
21160 if EnableETSScreen > 0:
21161  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
21162  ETSScreen.pack(side=TOP)
21163 # input probe wigets
21164 prlab = Label(frame2r, text="Adjust Gain / Offset")
21165 prlab.pack(side=TOP)
21166 # Input Probes sub frame
21167 ProbeA = Frame( frame2r )
21168 ProbeA.pack(side=TOP)
21169 gain1lab = Label(ProbeA, text="CA-V")
21170 gain1lab.pack(side=LEFT)
21171 CHAVGainEntry = Entry(ProbeA, width=5)
21172 CHAVGainEntry.bind('<Return>', onTextKey)
21173 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
21174 CHAVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21175 CHAVGainEntry.bind("<Button-5>", onTextScroll)
21176 CHAVGainEntry.bind('<Key>', onTextKey)
21177 CHAVGainEntry.pack(side=LEFT)
21178 CHAVGainEntry.delete(0,"end")
21179 CHAVGainEntry.insert(0,1.0)
21180 CHAVOffsetEntry = Entry(ProbeA, width=5)
21181 CHAVOffsetEntry.bind('<Return>', onTextKey)
21182 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
21183 CHAVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21184 CHAVOffsetEntry.bind("<Button-5>", onTextScroll)
21185 CHAVOffsetEntry.bind('<Key>', onTextKey)
21186 CHAVOffsetEntry.pack(side=LEFT)
21187 CHAVOffsetEntry.delete(0,"end")
21188 CHAVOffsetEntry.insert(0,0.0)
21189 #
21190 ProbeB = Frame( frame2r )
21191 ProbeB.pack(side=TOP)
21192 gain2lab = Label(ProbeB, text="CB-V")
21193 gain2lab.pack(side=LEFT)
21194 CHBVGainEntry = Entry(ProbeB, width=5)
21195 CHBVGainEntry.bind('<Return>', onTextKey)
21196 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
21197 CHBVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21198 CHBVGainEntry.bind("<Button-5>", onTextScroll)
21199 CHBVGainEntry.bind('<Key>', onTextKey)
21200 CHBVGainEntry.pack(side=LEFT)
21201 CHBVGainEntry.delete(0,"end")
21202 CHBVGainEntry.insert(0,1.0)
21203 CHBVOffsetEntry = Entry(ProbeB, width=5)
21204 CHBVOffsetEntry.bind('<Return>', onTextKey)
21205 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
21206 CHBVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21207 CHBVOffsetEntry.bind("<Button-5>", onTextScroll)
21208 CHBVOffsetEntry.bind('<Key>', onTextKey)
21209 CHBVOffsetEntry.pack(side=LEFT)
21210 CHBVOffsetEntry.delete(0,"end")
21211 CHBVOffsetEntry.insert(0,0.0)
21212 #
21213 ProbeAI = Frame( frame2r )
21214 ProbeAI.pack(side=TOP)
21215 gainailab = Label(ProbeAI, text="CA-I")
21216 gainailab.pack(side=LEFT)
21217 CHAIGainEntry = Entry(ProbeAI, width=5)
21218 CHAIGainEntry.bind('<Return>', onTextKey)
21219 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
21220 CHAIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21221 CHAIGainEntry.bind("<Button-5>", onTextScroll)
21222 CHAIGainEntry.bind('<Key>', onTextKey)
21223 CHAIGainEntry.pack(side=LEFT)
21224 CHAIGainEntry.delete(0,"end")
21225 CHAIGainEntry.insert(0,1.0)
21226 CHAIOffsetEntry = Entry(ProbeAI, width=5)
21227 CHAIOffsetEntry.bind('<Return>', onTextKey)
21228 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
21229 CHAIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21230 CHAIOffsetEntry.bind("<Button-5>", onTextScroll)
21231 CHAIOffsetEntry.bind('<Key>', onTextKey)
21232 CHAIOffsetEntry.pack(side=LEFT)
21233 CHAIOffsetEntry.delete(0,"end")
21234 CHAIOffsetEntry.insert(0,0.0)
21235 #
21236 ProbeBI = Frame( frame2r )
21237 ProbeBI.pack(side=TOP)
21238 gainbilab = Label(ProbeBI, text="CB-I")
21239 gainbilab.pack(side=LEFT)
21240 CHBIGainEntry = Entry(ProbeBI, width=5)
21241 CHBIGainEntry.bind('<Return>', onTextKey)
21242 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
21243 CHBIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21244 CHBIGainEntry.bind("<Button-5>", onTextScroll)
21245 CHBIGainEntry.bind('<Key>', onTextKey)
21246 CHBIGainEntry.pack(side=LEFT)
21247 CHBIGainEntry.delete(0,"end")
21248 CHBIGainEntry.insert(0,1.0)
21249 CHBIOffsetEntry = Entry(ProbeBI, width=5)
21250 CHBIOffsetEntry.bind('<Return>', onTextKey)
21251 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
21252 CHBIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21253 CHBIOffsetEntry.bind("<Button-5>", onTextScroll)
21254 CHBIOffsetEntry.bind('<Key>', onTextKey)
21255 CHBIOffsetEntry.pack(side=LEFT)
21256 CHBIOffsetEntry.delete(0,"end")
21257 CHBIOffsetEntry.insert(0,0.0)
21258 # add ADI logo Don't mess with this bit map data!
21259 ADIlogo = """
21260 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
21261 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
21262 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
21263 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
21264 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
21265 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
21266 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
21267 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
21268 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
21269 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
21270 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
21271 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
21272 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
21273 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
21274 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
21275 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
21276 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
21277 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
21278 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
21279 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
21280 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
21281 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
21282 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
21283 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
21284 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
21285 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
21286 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
21287 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
21288 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
21289 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
21290 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
21291 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
21292 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
21293 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
21294 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
21295 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
21296 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
21297 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
21298 """
21299 logo = PhotoImage(data=ADIlogo)
21300 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
21301 ADI1.pack(side=TOP)
21302 
21303 # Bottom Buttons
21304 # Voltage channel A
21305 CHAsb = Spinbox(frame3, width=4, values=CHvpdiv, command=BCHAlevel)
21306 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
21307 CHAsb.pack(side=LEFT)
21308 CHAsb.delete(0,"end")
21309 CHAsb.insert(0,0.5)
21310 #
21311 CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
21312 CHAlab.pack(side=LEFT)
21313 
21314 CHAVPosEntry = Entry(frame3, width=5)
21315 CHAVPosEntry.bind("<Return>", BOffsetA)
21316 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
21317 CHAVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21318 CHAVPosEntry.bind("<Button-5>", onTextScroll)
21319 CHAVPosEntry.bind('<Key>', onTextKey)
21320 CHAVPosEntry.pack(side=LEFT)
21321 CHAVPosEntry.delete(0,"end")
21322 CHAVPosEntry.insert(0,2.5)
21323 CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
21324 CHAofflab.pack(side=LEFT)
21325 # Current channel A
21326 CHAIsb = Spinbox(frame3, width=4, values=CHipdiv, command=BCHAIlevel)
21327 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
21328 CHAIsb.pack(side=LEFT)
21329 CHAIsb.delete(0,"end")
21330 CHAIsb.insert(0,50.0)
21331 CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
21332 CHAIlab.pack(side=LEFT)
21333 
21334 CHAIPosEntry = Entry(frame3, width=5)
21335 CHAIPosEntry.bind("<Return>", BIOffsetA)
21336 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
21337 CHAIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21338 CHAIPosEntry.bind("<Button-5>", onTextScroll)
21339 CHAIPosEntry.bind('<Key>', onTextKey)
21340 CHAIPosEntry.pack(side=LEFT)
21341 CHAIPosEntry.delete(0,"end")
21342 CHAIPosEntry.insert(0,0.0)
21343 CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
21344 CHAIofflab.pack(side=LEFT)
21345 # Voltage channel B
21346 CHBsb = Spinbox(frame3, width=4, values=CHvpdiv, command=BCHBlevel)
21347 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
21348 CHBsb.pack(side=LEFT)
21349 CHBsb.delete(0,"end")
21350 CHBsb.insert(0,0.5)
21351 #
21352 CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
21353 CHBlab.pack(side=LEFT)
21354 
21355 CHBVPosEntry = Entry(frame3, width=5)
21356 CHBVPosEntry.bind("<Return>", BOffsetB)
21357 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
21358 CHBVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21359 CHBVPosEntry.bind("<Button-5>", onTextScroll)
21360 CHBVPosEntry.bind('<Key>', onTextKey)
21361 CHBVPosEntry.pack(side=LEFT)
21362 CHBVPosEntry.delete(0,"end")
21363 CHBVPosEntry.insert(0,2.5)
21364 CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
21365 CHBofflab.pack(side=LEFT)
21366 # Current channel B
21367 CHBIsb = Spinbox(frame3, width=4, values=CHipdiv, command=BCHBIlevel)
21368 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
21369 CHBIsb.pack(side=LEFT)
21370 CHBIsb.delete(0,"end")
21371 CHBIsb.insert(0,50.0)
21372 CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
21373 CHBIlab.pack(side=LEFT)
21374 
21375 CHBIPosEntry = Entry(frame3, width=5)
21376 CHBIPosEntry.bind("<Return>", BIOffsetB)
21377 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
21378 CHBIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21379 CHBIPosEntry.bind("<Button-5>", onTextScroll)
21380 CHBIPosEntry.bind('<Key>', onTextKey)
21381 CHBIPosEntry.pack(side=LEFT)
21382 CHBIPosEntry.delete(0,"end")
21383 CHBIPosEntry.insert(0,0.0)
21384 CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
21385 CHBIofflab.pack(side=LEFT)
21386 #
21387 if ShowBallonHelp > 0:
21388  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
21389  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
21390  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
21391  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
21392  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
21393  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
21394  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
21395  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
21396 #
21397 root.geometry('+300+0')
21398 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
21399 #===== Initalize device ======
21400 if not numpy_found:
21401  root.update()
21402  showwarning("WARNING","Numpy not found!")
21403  root.destroy()
21404  exit()
21405 #
21406 BrdSel = IntVar(0)
21407 BoardStatus = IntVar(0)
21408 if pysmu_found:
21409  ConnectDevice()
21410  #session.hotplug_attach(ConnectDevice)
21411  #session.hotplug_detach(ConnectDevice)
21412  MakeAWGWindow() # always build AWG window
21413  BLoadConfig("alice-last-config.cfg") # load configuration from last session
21414 # ================ Call main routine ===============================
21415  root.update() # Activate updated screens
21416 #
21417 
21418 # Start sampling
21419  Analog_In()
21420 else:
21421  root.update()
21422  showwarning("WARNING","Pysmu not found!")
21423  root.destroy()
21424  exit()
21425 
alice-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-desktop-1.3.pyw:13991
alice-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-desktop-1.3.pyw:10896
alice-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-desktop-1.3.pyw:13849
alice-desktop-1.SetETSComp
def SetETSComp()
Definition: alice-desktop-1.3.pyw:20312
alice-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-desktop-1.3.pyw:20536
alice-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-desktop-1.3.pyw:13738
alice-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-desktop-1.3.pyw:11432
alice-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-desktop-1.3.pyw:8537
alice-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digital I/O screen.
Definition: alice-desktop-1.3.pyw:4814
alice-desktop-1.MGLoad
def MGLoad()
Definition: alice-desktop-1.3.pyw:19909
alice-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-desktop-1.3.pyw:4921
alice-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-desktop-1.3.pyw:1377
alice-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-desktop-1.3.pyw:4684
alice-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-desktop-1.3.pyw:19116
alice-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-desktop-1.3.pyw:14024
alice-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-desktop-1.3.pyw:15651
alice-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-desktop-1.3.pyw:20543
alice-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-desktop-1.3.pyw:8609
alice-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-desktop-1.3.pyw:16001
alice-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-desktop-1.3.pyw:15756
alice-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-desktop-1.3.pyw:2310
alice-desktop-1.shift_buffer
def shift_buffer(arr, num, fill_value=numpy.nan)
Function to left (-num) or right (+num) shift buffer and fill with a value returns same length buffer...
Definition: alice-desktop-1.3.pyw:4162
alice-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-desktop-1.3.pyw:2642
alice-desktop-1.VAtoggle
def VAtoggle()
Definition: alice-desktop-1.3.pyw:14030
alice-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Pause / start on space bar.
Definition: alice-desktop-1.3.pyw:8229
alice-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-desktop-1.3.pyw:8000
alice-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-desktop-1.3.pyw:16162
alice-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-desktop-1.3.pyw:12263
alice-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-desktop-1.3.pyw:16755
alice-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-desktop-1.3.pyw:2352
alice-desktop-1.sel
def sel()
Definition: alice-desktop-1.3.pyw:4820
alice-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-desktop-1.3.pyw:13695
alice-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-desktop-1.3.pyw:17400
alice-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-desktop-1.3.pyw:10959
alice-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-desktop-1.3.pyw:13046
alice-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-desktop-1.3.pyw:10241
alice-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-desktop-1.3.pyw:16052
alice-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-desktop-1.3.pyw:17120
alice-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-desktop-1.3.pyw:20352
alice-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-desktop-1.3.pyw:10310
alice-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-desktop-1.3.pyw:7238
alice-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-desktop-1.3.pyw:19685
alice-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-desktop-1.3.pyw:11990
alice-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-desktop-1.3.pyw:11186
alice-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-desktop-1.3.pyw:16800
alice-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-desktop-1.3.pyw:2628
alice-desktop-1.CAresize
def CAresize(event)
Definition: alice-desktop-1.3.pyw:19162
alice-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-desktop-1.3.pyw:16745
alice-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-desktop-1.3.pyw:19063
alice-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-desktop-1.3.pyw:7945
alice-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-desktop-1.3.pyw:16714
alice-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-desktop-1.3.pyw:2370
alice-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:1653
alice-desktop-1.PlotPhAFromFile
def PlotPhAFromFile()
Definition: alice-desktop-1.3.pyw:15066
alice-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-desktop-1.3.pyw:18368
alice-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-desktop-1.3.pyw:2815
alice-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-desktop-1.3.pyw:2783
alice-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-desktop-1.3.pyw:13689
alice-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-desktop-1.3.pyw:9658
alice-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2183
alice-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-desktop-1.3.pyw:9794
alice-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-desktop-1.3.pyw:15832
alice-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-desktop-1.3.pyw:18805
alice-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-desktop-1.3.pyw:9087
alice-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-desktop-1.3.pyw:2562
alice-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-desktop-1.3.pyw:10160
alice-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-desktop-1.3.pyw:15822
alice-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-desktop-1.3.pyw:19803
alice-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-desktop-1.3.pyw:10432
alice-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-desktop-1.3.pyw:18406
alice-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-desktop-1.3.pyw:2424
alice-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-desktop-1.3.pyw:11123
alice-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-desktop-1.3.pyw:2700
alice-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-desktop-1.3.pyw:19919
alice-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-desktop-1.3.pyw:11719
alice-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-desktop-1.3.pyw:8996
alice-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-desktop-1.3.pyw:16518
alice-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-desktop-1.3.pyw:16030
alice-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-desktop-1.3.pyw:19525
alice-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-desktop-1.3.pyw:11422
alice-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-desktop-1.3.pyw:7981
alice-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-desktop-1.3.pyw:10471
alice-desktop-1.Blevel4
def Blevel4()
Definition: alice-desktop-1.3.pyw:11710
alice-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-desktop-1.3.pyw:1741
alice-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-desktop-1.3.pyw:15200
alice-desktop-1.Blevel1
def Blevel1()
Definition: alice-desktop-1.3.pyw:11683
alice-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-desktop-1.3.pyw:4525
alice-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-desktop-1.3.pyw:5086
alice-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-desktop-1.3.pyw:15959
alice-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:1634
alice-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-desktop-1.3.pyw:14010
alice-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-desktop-1.3.pyw:11916
alice-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-desktop-1.3.pyw:16152
alice-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-desktop-1.3.pyw:15810
alice-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-desktop-1.3.pyw:11324
alice-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-desktop-1.3.pyw:2743
alice-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-desktop-1.3.pyw:2406
alice-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-desktop-1.3.pyw:10643
alice-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-desktop-1.3.pyw:10442
alice-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-desktop-1.3.pyw:5081
alice-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-desktop-1.3.pyw:15791
alice-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-desktop-1.3.pyw:2466
alice-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-desktop-1.3.pyw:9394
alice-desktop-1.CreateToolTip.tw
tw
Definition: alice-desktop-1.3.pyw:740
alice-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-desktop-1.3.pyw:13520
alice-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-desktop-1.3.pyw:7969
alice-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-desktop-1.3.pyw:7993
alice-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-desktop-1.3.pyw:19645
alice-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-desktop-1.3.pyw:2454
alice-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-desktop-1.3.pyw:19529
alice-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-desktop-1.3.pyw:1372
alice-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-desktop-1.3.pyw:4484
alice-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-desktop-1.3.pyw:7957
alice-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-desktop-1.3.pyw:15617
alice-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-desktop-1.3.pyw:2328
alice-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-desktop-1.3.pyw:11165
alice-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-desktop-1.3.pyw:12006
alice-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-desktop-1.3.pyw:15670
alice-desktop-1.DoFFT
def DoFFT()
Definition: alice-desktop-1.3.pyw:12013
alice-desktop-1.Digital_RC_High_Pass
def Digital_RC_High_Pass(InBuff, TC1, Gain)
Digital filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3.pyw:4124
alice-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-desktop-1.3.pyw:16020
alice-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-desktop-1.3.pyw:20035
alice-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-desktop-1.3.pyw:2710
alice-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-desktop-1.3.pyw:16098
alice-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-desktop-1.3.pyw:19929
alice-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-desktop-1.3.pyw:11321
alice-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2126
alice-desktop-1.VBtoggle
def VBtoggle()
Definition: alice-desktop-1.3.pyw:14046
alice-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-desktop-1.3.pyw:1602
alice-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-desktop-1.3.pyw:14019
alice-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-desktop-1.3.pyw:19951
alice-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-desktop-1.3.pyw:16547
alice-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-desktop-1.3.pyw:11964
font
alice-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-desktop-1.3.pyw:17631
alice-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-desktop-1.3.pyw:2267
alice-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-desktop-1.3.pyw:19009
alice-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-desktop-1.3.pyw:11740
alice-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-desktop-1.3.pyw:2491
alice-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-desktop-1.3.pyw:15858
alice-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-desktop-1.3.pyw:11907
alice-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-desktop-1.3.pyw:13822
alice-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-desktop-1.3.pyw:9319
alice-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-desktop-1.3.pyw:19901
alice-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-desktop-1.3.pyw:9436
alice-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-desktop-1.3.pyw:18811
alice-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-desktop-1.3.pyw:11311
alice-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-desktop-1.3.pyw:19148
alice-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-desktop-1.3.pyw:18991
alice-desktop-1.MakePhAScreen
def MakePhAScreen()
Definition: alice-desktop-1.3.pyw:14446
alice-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-desktop-1.3.pyw:8966
alice-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-desktop-1.3.pyw:10279
alice-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-desktop-1.3.pyw:13510
alice-desktop-1.CreateToolTip.widget
widget
Definition: alice-desktop-1.3.pyw:734
alice-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-desktop-1.3.pyw:6392
alice-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-desktop-1.3.pyw:16092
alice-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-desktop-1.3.pyw:2235
alice-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-desktop-1.3.pyw:10496
alice-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-desktop-1.3.pyw:10340
alice-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-desktop-1.3.pyw:19726
alice-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-desktop-1.3.pyw:8613
alice-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-desktop-1.3.pyw:15784
alice-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-desktop-1.3.pyw:15122
alice-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-desktop-1.3.pyw:1780
alice-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-desktop-1.3.pyw:19205
alice-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-desktop-1.3.pyw:1937
alice-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-desktop-1.3.pyw:18275
alice-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-desktop-1.3.pyw:17376
alice-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-desktop-1.3.pyw:15770
alice-desktop-1.sel2
def sel2(temp)
Definition: alice-desktop-1.3.pyw:4993
alice-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-desktop-1.3.pyw:18098
alice-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-desktop-1.3.pyw:13728
alice-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-desktop-1.3.pyw:2301
alice-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-desktop-1.3.pyw:8637
alice-desktop-1.BStepSync
def BStepSync()
Definition: alice-desktop-1.3.pyw:16735
alice-desktop-1.BSendGS
def BSendGS()
Definition: alice-desktop-1.3.pyw:18657
alice-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-desktop-1.3.pyw:8545
alice-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-desktop-1.3.pyw:18450
alice-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-desktop-1.3.pyw:732
alice-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-desktop-1.3.pyw:4533
alice-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-desktop-1.3.pyw:15878
alice-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-desktop-1.3.pyw:2442
alice-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-desktop-1.3.pyw:15763
alice-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-desktop-1.3.pyw:2579
alice-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-desktop-1.3.pyw:10759
alice-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-desktop-1.3.pyw:2227
alice-desktop-1.sel0
def sel0(temp)
Definition: alice-desktop-1.3.pyw:4927
alice-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-desktop-1.3.pyw:15802
alice-desktop-1.Bnot
def Bnot()
Definition: alice-desktop-1.3.pyw:11385
alice-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-desktop-1.3.pyw:16044
alice-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-desktop-1.3.pyw:15846
alice-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-desktop-1.3.pyw:2544
alice-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-desktop-1.3.pyw:11943
alice-desktop-1.DestroyPhAScreen
def DestroyPhAScreen()
Definition: alice-desktop-1.3.pyw:14242
alice-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-desktop-1.3.pyw:15980
alice-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-desktop-1.3.pyw:11761
alice-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-desktop-1.3.pyw:9472
alice-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-desktop-1.3.pyw:2448
alice-desktop-1.MakePhAWindow
def MakePhAWindow()
Definition: alice-desktop-1.3.pyw:14071
alice-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-desktop-1.3.pyw:8804
alice-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-desktop-1.3.pyw:19333
alice-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-desktop-1.3.pyw:18903
alice-desktop-1.Blevel2
def Blevel2()
Definition: alice-desktop-1.3.pyw:11692
alice-desktop-1.SelectBoard
def SelectBoard()
temp = 0 print "read ADM1177 controler" print devx.ctrl_transfer( 0xa0, 0x17, 0, 0,...
Definition: alice-desktop-1.3.pyw:19362
alice-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-desktop-1.3.pyw:2775
alice-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-desktop-1.3.pyw:2436
alice-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3.pyw:1829
alice-desktop-1.SettingsTextKey
def SettingsTextKey(event)
Definition: alice-desktop-1.3.pyw:20039
alice-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-desktop-1.3.pyw:8594
alice-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-desktop-1.3.pyw:18507
alice-desktop-1.CreateToolTip.id
id
Definition: alice-desktop-1.3.pyw:739
alice-desktop-1.BStopBP
def BStopBP()
Definition: alice-desktop-1.3.pyw:11885
alice-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-desktop-1.3.pyw:1706
alice-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-desktop-1.3.pyw:16104
alice-desktop-1.BHelp
def BHelp()
Open User Guide in Browser open a URL, in this case, the ALICE desk-top-users-guide.
Definition: alice-desktop-1.3.pyw:1775
alice-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-desktop-1.3.pyw:11345
alice-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-desktop-1.3.pyw:9015
alice-desktop-1.BSetFmin
def BSetFmin()
Definition: alice-desktop-1.3.pyw:20549
alice-desktop-1.Analog_Phase_In
def Analog_Phase_In()
Definition: alice-desktop-1.3.pyw:3166
alice-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-desktop-1.3.pyw:1583
alice-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-desktop-1.3.pyw:2690
alice-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-desktop-1.3.pyw:11978
alice-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-desktop-1.3.pyw:16012
alice-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-desktop-1.3.pyw:2945
alice-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-desktop-1.3.pyw:5101
alice-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-desktop-1.3.pyw:19327
alice-desktop-1.BStopSA
def BStopSA()
Definition: alice-desktop-1.3.pyw:11656
alice-desktop-1.donothing
def donothing()
Nop.
Definition: alice-desktop-1.3.pyw:2213
alice-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2197
alice-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-desktop-1.3.pyw:11934
alice-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-desktop-1.3.pyw:18910
alice-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-desktop-1.3.pyw:9862
alice-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-desktop-1.3.pyw:8589
alice-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-desktop-1.3.pyw:9111
alice-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-desktop-1.3.pyw:9962
alice-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3.pyw:1901
alice-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:1672
alice-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-desktop-1.3.pyw:18501
alice-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-desktop-1.3.pyw:19795
alice-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-desktop-1.3.pyw:1595
alice-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Move Time curcors left 1 or 5.
Definition: alice-desktop-1.3.pyw:8145
alice-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-desktop-1.3.pyw:8821
alice-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-desktop-1.3.pyw:5059
alice-desktop-1.BTriglevel
def BTriglevel(event)
evalute trigger level entry string to a numerical value and set new trigger level
Definition: alice-desktop-1.3.pyw:2279
alice-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-desktop-1.3.pyw:10601
alice-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-desktop-1.3.pyw:2804
alice-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-desktop-1.3.pyw:13721
alice-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-desktop-1.3.pyw:11473
alice-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-desktop-1.3.pyw:2204
alice-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-desktop-1.3.pyw:10202
alice-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-desktop-1.3.pyw:753
alice-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-desktop-1.3.pyw:18731
alice-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-desktop-1.3.pyw:15987
alice-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-desktop-1.3.pyw:8599
alice-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-desktop-1.3.pyw:15640
alice-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-desktop-1.3.pyw:16037
alice-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-desktop-1.3.pyw:8935
alice-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-desktop-1.3.pyw:2670
alice-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-desktop-1.3.pyw:13090
alice-desktop-1.IAtoggle
def IAtoggle()
Definition: alice-desktop-1.3.pyw:14054
alice-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-desktop-1.3.pyw:2732
alice-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-desktop-1.3.pyw:8007
alice-desktop-1.SyncImage
def SyncImage()
Definition: alice-desktop-1.3.pyw:16706
alice-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-desktop-1.3.pyw:2216
alice-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-desktop-1.3.pyw:11518
alice-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-desktop-1.3.pyw:19586
alice-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:1689
alice-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-desktop-1.3.pyw:13866
alice-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-desktop-1.3.pyw:10359
alice-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-desktop-1.3.pyw:9097
alice-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-desktop-1.3.pyw:19512
alice-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-desktop-1.3.pyw:18542
alice-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-desktop-1.3.pyw:19034
alice-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-desktop-1.3.pyw:742
alice-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-desktop-1.3.pyw:9591
alice-desktop-1.Analog_Slow_time
def Analog_Slow_time()
Right now this is a failed attempt to plot slow sweeps.
Definition: alice-desktop-1.3.pyw:3383
alice-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-desktop-1.3.pyw:11592
alice-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-desktop-1.3.pyw:10825
alice-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-desktop-1.3.pyw:4858
alice-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Move Vertical cursors down 1 or 5.
Definition: alice-desktop-1.3.pyw:8103
alice-desktop-1.sel1
def sel1(temp)
Definition: alice-desktop-1.3.pyw:4960
alice-desktop-1.Analog_Freq_In
def Analog_Freq_In()
Main SA and Bode loop Read from the stream and store the data into the arrays.
Definition: alice-desktop-1.3.pyw:4176
alice-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-desktop-1.3.pyw:2292
alice-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-desktop-1.3.pyw:731
alice-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-desktop-1.3.pyw:15504
alice-desktop-1.BStartBP
def BStartBP()
Definition: alice-desktop-1.3.pyw:11782
alice-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-desktop-1.3.pyw:15806
alice-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-desktop-1.3.pyw:9917
alice-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-desktop-1.3.pyw:10322
alice-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-desktop-1.3.pyw:15609
alice-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-desktop-1.3.pyw:2394
alice-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-desktop-1.3.pyw:10477
alice-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-desktop-1.3.pyw:15749
alice-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-desktop-1.3.pyw:16109
alice-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-desktop-1.3.pyw:18801
alice-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-desktop-1.3.pyw:8569
alice-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-desktop-1.3.pyw:2358
alice-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-desktop-1.3.pyw:2346
alice-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-desktop-1.3.pyw:2680
alice-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-desktop-1.3.pyw:16726
alice-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-desktop-1.3.pyw:8897
alice-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-desktop-1.3.pyw:1920
alice-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-desktop-1.3.pyw:5106
alice-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-desktop-1.3.pyw:1577
alice-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-desktop-1.3.pyw:8646
alice-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-desktop-1.3.pyw:15816
alice-desktop-1.CreateToolTip.text
text
Definition: alice-desktop-1.3.pyw:735
alice-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-desktop-1.3.pyw:11412
alice-desktop-1.PhACheckBox
def PhACheckBox()
Definition: alice-desktop-1.3.pyw:2790
alice-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-desktop-1.3.pyw:15839
alice-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-desktop-1.3.pyw:15966
alice-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-desktop-1.3.pyw:8270
alice-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-desktop-1.3.pyw:9179
alice-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-desktop-1.3.pyw:2241
alice-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-desktop-1.3.pyw:8857
alice-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-desktop-1.3.pyw:15798
alice-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-desktop-1.3.pyw:733
alice-desktop-1.MakePhATrace
def MakePhATrace()
Definition: alice-desktop-1.3.pyw:14274
alice-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-desktop-1.3.pyw:10531
messagebox
alice-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-desktop-1.3.pyw:12463
alice-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-desktop-1.3.pyw:2418
alice-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-desktop-1.3.pyw:19012
alice-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2190
alice-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-desktop-1.3.pyw:20346
alice-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-desktop-1.3.pyw:16016
alice-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-desktop-1.3.pyw:9046
alice-desktop-1.BSavePhAData
def BSavePhAData()
Definition: alice-desktop-1.3.pyw:15030
alice-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-desktop-1.3.pyw:13681
alice-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-desktop-1.3.pyw:745
alice-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-desktop-1.3.pyw:17100
alice-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-desktop-1.3.pyw:18583
alice-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-desktop-1.3.pyw:15973
alice-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-desktop-1.3.pyw:18984
alice-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-desktop-1.3.pyw:11995
alice-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-desktop-1.3.pyw:9160
alice-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Move Vertical cursors up 1 or 5.
Definition: alice-desktop-1.3.pyw:8061
alice-desktop-1.UpdatePhATrace
def UpdatePhATrace()
Definition: alice-desktop-1.3.pyw:14265
alice-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-desktop-1.3.pyw:19566
alice-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-desktop-1.3.pyw:19272
alice-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-desktop-1.3.pyw:11395
alice-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-desktop-1.3.pyw:18987
alice-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-desktop-1.3.pyw:2382
alice-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-desktop-1.3.pyw:17385
alice-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-desktop-1.3.pyw:2754
alice-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-desktop-1.3.pyw:2219
alice-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-desktop-1.3.pyw:19101
alice-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-desktop-1.3.pyw:19040
alice-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-desktop-1.3.pyw:11026
alice-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-desktop-1.3.pyw:2119
alice-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-desktop-1.3.pyw:15520
alice-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-desktop-1.3.pyw:1458
alice-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-desktop-1.3.pyw:11953
alice-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-desktop-1.3.pyw:2721
alice-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-desktop-1.3.pyw:9730
alice-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-desktop-1.3.pyw:11771
alice-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2145
alice-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-desktop-1.3.pyw:11971
alice-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-desktop-1.3.pyw:9530
alice-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-desktop-1.3.pyw:19452
alice-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-desktop-1.3.pyw:2460
alice-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-desktop-1.3.pyw:8584
alice-desktop-1.Blevel3
def Blevel3()
Definition: alice-desktop-1.3.pyw:11701
alice-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-desktop-1.3.pyw:9244
alice-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-desktop-1.3.pyw:8579
alice-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-desktop-1.3.pyw:1366
alice-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-desktop-1.3.pyw:4695
alice-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-desktop-1.3.pyw:8978
alice-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-desktop-1.3.pyw:1354
alice-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-desktop-1.3.pyw:5111
alice-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-desktop-1.3.pyw:8553
alice-desktop-1.BStartSA
def BStartSA()
Definition: alice-desktop-1.3.pyw:11619
alice-desktop-1.BUserCustomPlotText
def BUserCustomPlotText()
Ask user to enter custom plot label string.
Definition: alice-desktop-1.3.pyw:1955
alice-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-desktop-1.3.pyw:2595
alice-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-desktop-1.3.pyw:15994
alice-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-desktop-1.3.pyw:18243
alice-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-desktop-1.3.pyw:1719
alice-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-desktop-1.3.pyw:15777
alice-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-desktop-1.3.pyw:13038
alice-desktop-1.VABtoggle
def VABtoggle()
Definition: alice-desktop-1.3.pyw:14038
alice-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-desktop-1.3.pyw:759
alice-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-desktop-1.3.pyw:8574
alice-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-desktop-1.3.pyw:18355
alice-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-desktop-1.3.pyw:14000
alice-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-desktop-1.3.pyw:15825
alice-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-desktop-1.3.pyw:19172
alice-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-desktop-1.3.pyw:8629
alice-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-desktop-1.3.pyw:18213
alice-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-desktop-1.3.pyw:11368
alice-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-desktop-1.3.pyw:18600
alice-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-desktop-1.3.pyw:8621
alice-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-desktop-1.3.pyw:11080
alice-desktop-1.Analog_Time_In
def Analog_Time_In()
Scope time main loop Read the analog data and store the data into the arrays.
Definition: alice-desktop-1.3.pyw:3067
alice-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-desktop-1.3.pyw:8790
alice-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Move Time curcors right 1 or 5.
Definition: alice-desktop-1.3.pyw:8187
alice-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-desktop-1.3.pyw:8561
alice-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-desktop-1.3.pyw:15819
alice-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-desktop-1.3.pyw:11438
alice-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-desktop-1.3.pyw:2761
alice-desktop-1.Digital_RC_Low_Pass
def Digital_RC_Low_Pass(InBuff, TC1, Gain)
Digital filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3.pyw:4142
alice-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-desktop-1.3.pyw:19078
alice-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-desktop-1.3.pyw:11986
alice-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-desktop-1.3.pyw:18651
alice-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-desktop-1.3.pyw:11402
alice-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-desktop-1.3.pyw:8604
alice-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-desktop-1.3.pyw:10029
alice-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-desktop-1.3.pyw:13856
ttk
alice-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-desktop-1.3.pyw:20043
alice-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-desktop-1.3.pyw:1799
alice-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-desktop-1.3.pyw:18191
alice-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-desktop-1.3.pyw:729
alice-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-desktop-1.3.pyw:15813
alice-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-desktop-1.3.pyw:14005
alice-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-desktop-1.3.pyw:19142
alice-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-desktop-1.3.pyw:2797
alice-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-desktop-1.3.pyw:10007
alice-desktop-1.onCanvasClickScroll
def onCanvasClickScroll(event)
Shift Time or vertical cursors if on or shift gated measurement cursors if enabled.
Definition: alice-desktop-1.3.pyw:8016
alice-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-desktop-1.3.pyw:19923
alice-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-desktop-1.3.pyw:19519
alice-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2164
alice-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-desktop-1.3.pyw:1589
alice-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-desktop-1.3.pyw:16680
alice-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-desktop-1.3.pyw:19278
alice-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-desktop-1.3.pyw:2364
alice-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-desktop-1.3.pyw:16060
alice-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-desktop-1.3.pyw:9154
alice-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-desktop-1.3.pyw:11925
alice-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-desktop-1.3.pyw:19606
alice-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-desktop-1.3.pyw:749
alice-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-desktop-1.3.pyw:10188
alice-desktop-1.IBtoggle
def IBtoggle()
Definition: alice-desktop-1.3.pyw:14062
alice-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-desktop-1.3.pyw:12708
alice-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-desktop-1.3.pyw:5096
alice-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-desktop-1.3.pyw:2768
alice-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-desktop-1.3.pyw:17620
alice-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-desktop-1.3.pyw:783
alice-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-desktop-1.3.pyw:12010
alice-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-desktop-1.3.pyw:10699
alice-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-desktop-1.3.pyw:17110
alice-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-desktop-1.3.pyw:1360
alice-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-desktop-1.3.pyw:10393
alice-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-desktop-1.3.pyw:5091
alice-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-desktop-1.3.pyw:13028
alice-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-desktop-1.3.pyw:13042
alice-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-desktop-1.3.pyw:16540
alice-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-desktop-1.3.pyw:1966
alice-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-desktop-1.3.pyw:13214
alice-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-desktop-1.3.pyw:2430
alice-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-desktop-1.3.pyw:6145
alice-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-desktop-1.3.pyw:8668
alice-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-desktop-1.3.pyw:774
alice-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-desktop-1.3.pyw:19152
alice-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-desktop-1.3.pyw:16008
alice-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-desktop-1.3.pyw:11388
alice-desktop-1.Analog_Fast_time
def Analog_Fast_time()
routine for time scales faster than 500 mSec/Div
Definition: alice-desktop-1.3.pyw:3520
alice-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-desktop-1.3.pyw:18361
alice-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-desktop-1.3.pyw:16023
alice-desktop-1.PhACaresize
def PhACaresize(event)
Definition: alice-desktop-1.3.pyw:14251
alice-desktop-1.UpdatePhAAll
def UpdatePhAAll()
Definition: alice-desktop-1.3.pyw:14260
alice-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-desktop-1.3.pyw:19016
alice-desktop-1.sel3
def sel3(temp)
Definition: alice-desktop-1.3.pyw:5026
alice-desktop-1.UpdatePhAScreen
def UpdatePhAScreen()
Definition: alice-desktop-1.3.pyw:14269