ALICE 1.3  1.0
Develpoer documentation
alice-desktop-1.3-old.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 = "(6 July 2020)"
60 SWRev = "1.3 "
61 Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.6/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 
74 GRW = 720 # Width of the time grid 720 default
75 GRH = 390 # Height of the time grid 390 default
76 X0L = 55 # Left top X value of time grid
77 Y0T = 25 # Left top Y value of time grid
78 #
79 GRWF = 720 # Width of the spectrum grid 720 default
80 GRHF = 390 # Height of the spectrum grid 390 default
81 X0LF = 37 # Left top X value of spectrum grid
82 Y0TF = 25 # Left top Y value of spectrum grid
83 #
84 GRWBP = 720 # Width of the Bode Plot grid 720 default
85 GRHBP = 390 # Height of the Bode Plot grid 390 default
86 X0LBP = 37 # Left top X value of Bode Plot grid
87 Y0TBP = 25 # Left top Y value of Bode Plot grid
88 #
89 GRWXY = 420 # Width of the XY grid 420 default
90 GRHXY = 390 # Height of the XY grid 390 default
91 X0LXY = 37 # Left top X value of XY grid
92 Y0TXY = 25 # Left top Y value of XY grid
93 #
94 GRWIA = 400 # Width of the grid 400 default
95 GRHIA = 400 # Height of the grid 400 default
96 X0LIA = 37 # Left top X value of grid
97 Y0TIA = 25 # Left top Y value of grid
98 #
99 GRWNqP = 400 # Width of the Nyquist plot grid 400 default
100 GRHNqP = 400 # Height of the grid 400 default
101 X0LNqP = 25 # Left top X value of grid
102 Y0TNqP = 25 # Left top Y value of grid
103 #
104 GRWNiC = 400 # Width of the Nichols plot grid 400 default
105 GRHNiC = 400 # Height of the grid 400 default
106 X0LNiC = 25 # Left top X value of grid
107 Y0TNiC = 25 # Left top Y value of grid
108 #
109 FontSize = 8
110 MouseX = MouseY = -10
111 MouseCAV = MouseCAI = MouseCBV = MouseCBI = MouseMuxA = MouseMuxB = MouseMuxC = MouseMuxD = -10
112 
113 COLORframes = "#000080" # Color = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
114 COLORcanvas = "#000000" # 100% black
115 COLORgrid = "#808080" # 50% Gray
116 COLORzeroline = "#0000ff" # 100% blue
117 COLORtrace1 = "#00ff00" # 100% green
118 COLORtrace2 = "#ff8000" # 100% orange
119 COLORtrace3 = "#00ffff" # 100% cyan
120 COLORtrace4 = "#ffff00" # 100% yellow
121 COLORtrace5 = "#ff00ff" # 100% magenta
122 COLORtrace6 = "#C80000" # 90% red
123 COLORtrace7 = "#8080ff" # 100% purple
124 COLORtraceR1 = "#008000" # 50% green
125 COLORtraceR2 = "#905000" # 50% orange
126 COLORtraceR3 = "#008080" # 50% cyan
127 COLORtraceR4 = "#808000" # 50% yellow
128 COLORtraceR5 = "#800080" # 50% magenta
129 COLORtraceR6 = "#800000" # 80% red
130 COLORtraceR7 = "#4040a0" # 80% purple
131 COLORtext = "#ffffff" # 100% white
132 COLORtrigger = "#ff0000" # 100% red
133 COLORsignalband = "#ff0000" # 100% red
134 
135 OnBoardRes = 50.83
136 AD584act = 2.5
137 # Set sample buffer size
138 HoldOff = 0.0
139 LShift = 0
140 BaseSampleRate = 100000
141 AWGSAMPLErate = BaseSampleRate # Sample rate of the AWG channels
142 SAMPLErate = BaseSampleRate # Scope sample rate can be decimated
143 MinSamples = 2000
144 MaxSamples = 200000
145 ETSrecord = 2000
146 DISsamples = GRW
147 # set initial trigger conditions
148 TRIGGERlevel = 2.5 # Triggerlevel in volts
149 
150 MathString = "VBuffA[t] + VBuffB[t]"
151 MathUnits = " V"
152 MathXString = "VBuffA[t]"
153 MathXUnits = " V"
154 MathYString = "VBuffB[t]"
155 MathYUnits = " V"
156 UserAString = "MaxV1-VATop"
157 UserALabel = "OverShoot"
158 UserBString = "MinV2-VBBase"
159 UserBLabel = "UnderShoot"
160 MathAxis = "V-A"
161 MathXAxis = "V-A"
162 MathYAxis = "V-B"
163 AWGAMathString = "(VBuffA + VBuffB)/2"
164 AWGBMathString = "(VBuffA + VBuffB)/2"
165 FFTUserWindowString = "numpy.kaiser(SMPfft, 14) * 3"
166 DigFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
167 DigFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
168 ChaMeasString1 = "DCV1"
169 ChaMeasString2 = "DCI1"
170 ChaMeasString3 = "SV1"
171 ChaMeasString4 = "MaxV1-MinV1"
172 ChaMeasString5 = "MaxI1-MinI1"
173 ChaMeasString6 = "math.sqrt(SV1**2 - DCV1**2)"
174 ChbMeasString1 = "DCV2"
175 ChbMeasString2 = "DCI2"
176 ChbMeasString3 = "SV2"
177 ChbMeasString4 = "MaxV2-MinV2"
178 ChbMeasString5 = "MaxI2-MinI2"
179 ChbMeasString6 = "math.sqrt(SV2**2 - DCV2**2)"
180 ChaLableSrring1 = "CHA-DCV "
181 ChaLableSrring2 = "CHA-DCI "
182 ChaLableSrring3 = "CHA-TRMS "
183 ChaLableSrring4 = "CHA-VP-P "
184 ChaLableSrring5 = "CHA-IP-P "
185 ChaLableSrring6 = "CHA-ACRMS "
186 ChbLableSrring1 = "CHB-DCV "
187 ChbLableSrring2 = "CHB-DCI "
188 ChbLableSrring3 = "CHB-TRMS "
189 ChbLableSrring4 = "CHB-VP-P "
190 ChbLableSrring5 = "CHB-IP-P "
191 ChbLableSrring6 = "CHB-ACRMS "
192 
193 GridWidth = IntVar(0)
194 GridWidth.set(1)
195 TRACEwidth = IntVar(0)
196 TRACEwidth.set(1)
197 TRACEaverage = IntVar(0) # Number of average sweeps for average mode
198 TRACEaverage.set(8)
199 Vdiv = IntVar(0)
200 Vdiv.set(10) # Number of vertical divisions for spectrum / Bode
201 LPFTrigger = IntVar(0) # trigger lpf on/off
202 Trigger_LPF_length = IntVar(0)
203 Trigger_LPF_length.set(10) # Length of Trigger box car LPF in samples
204 HarmonicMarkers = IntVar(0)
205 HarmonicMarkers.set(3)
206 AWG_Amp_Mode = IntVar(0)
207 AWG_Amp_Mode.set(0) # 0 = Min/Max mode, 1 = Amp/Offset
208 AWGA_Ext_Gain = DoubleVar(0)
209 AWGA_Ext_Gain.set(1.0)
210 AWGA_Ext_Offset = DoubleVar(0)
211 AWGA_Ext_Offset.set(0.0)
212 AWGB_Ext_Gain = DoubleVar(0)
213 AWGB_Ext_Gain.set(1.0)
214 AWGB_Ext_Offset = DoubleVar(0)
215 AWGB_Ext_Offset.set(0.0)
216 AWG_2X = IntVar(0) # selection variable to set AWG DAC channes for 2X samplerate modes
217 Two_X_Sample = IntVar(0) # selection variable to set ADC channes for 2X samplerate mode
218 Two_X_Sample.set(0)
219 ADC_Mux_Mode = IntVar(0) # selection variable to set ADC CHA for voltagr or current 2X samplerate mode
220 ADC_Mux_Mode.set(0)
221 Last_ADC_Mux_Mode = 0
222 Alternate_Sweep_Mode = IntVar(0) # alternate sweeps when in 2X samplerate mode
223 Alternate_Sweep_Mode.set(0)
224 #
225 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
226 ZEROstuffing.set(1)
227 FFTwindow = IntVar(0) # FFT window function variable
228 FFTwindow.set(5) # FFTwindow 0=None (rectangular B=1), 1=Cosine (B=1.24), 2=Triangular non-zero endpoints (B=1.33),
229  # 3=Hann (B=1.5), 4=Blackman (B=1.73), 5=Nuttall (B=2.02), 6=Flat top (B=3.77)
230 RelPhaseCorrection = 15 # Relative Phase error seems to be a random number each time board is powered up
231 RelPhaseCenter = IntVar(0)
232 RelPhaseCenter.set(0) # Center line value for phase plots
233 ImpedanceCenter = IntVar(0)
234 ImpedanceCenter.set(0) # Center line value for impedance plots
235 MultipleBoards = IntVar(0)
236 MultipleBoards.set(0) # Turn on access for multiple m1k boards
237 IgnoreFirmwareCheck = 0
238 EnableCommandInterface = 0
239 EnableMuxMode = 1
240 EnablePIODACMode = 1
241 EnableMinigenMode = 0
242 EnablePmodDA1Mode = 0
243 EnableDigPotMode = 0
244 EnableGenericSerialMode = 0
245 EnableAD5626SerialMode = 0
246 EnableDigitalFilter = 0
247 EnableMeasureScreen = 0
248 EnableETSScreen = 0
249 EnableHSsampling = 0
250 AllowFlashFirmware = 0
251 DeBugMode = 0
252 # ADC Mux defaults
253 v1_adc_conf = 0x20F1
254 i1_adc_conf = 0x20F7
255 v2_adc_conf = 0x20F7
256 i2_adc_conf = 0x20F1
257 #
258 MouseFocus = 1
259 HistAsPercent = 0
260 ShowBallonHelp = 0
261 contloop = 0
262 discontloop = 0
263 AwgLayout = "Horz"
264 Style_String = 'alt'
265 MarkerLoc = 'UL' # can be UL, UR, LL or LR
266 CHA_TC1 = DoubleVar(0)
267 CHA_TC1.set(1)
268 CHA_TC2 = DoubleVar(0)
269 CHA_TC2.set(1)
270 CHB_TC1 = DoubleVar(0)
271 CHB_TC1.set(1)
272 CHB_TC2 = DoubleVar(0)
273 CHB_TC2.set(1)
274 CHA_A1 = DoubleVar(0)
275 CHA_A1.set(1)
276 CHA_A2 = DoubleVar(0)
277 CHA_A2.set(1)
278 CHB_A1 = DoubleVar(0)
279 CHB_A1.set(1)
280 CHB_A2 = DoubleVar(0)
281 CHB_A2.set(1)
282 Auto_ETS_Comp = IntVar(0)
283 ETS_TC1 = DoubleVar(0)
284 ETS_TC1.set(0.18333)
285 ETS_A1 = DoubleVar(0)
286 ETS_A1.set(5.0)
287 ETS_TC2 = DoubleVar(0)
288 ETS_TC2.set(0.03)
289 ETS_A2 = DoubleVar(0)
290 ETS_A2.set(5.0)
291 PhaseOffset1x = 37
292 PhaseOffset2x = 37
293 # Check if there is an alice_init.ini file to read in
294 try:
295  InitFile = open("alice_init.ini")
296  for line in InitFile:
297  try:
298  exec( line.rstrip() )
299  except:
300  print("Skiping " + line.rstrip())
301  InitFile.close()
302 except:
303  print( "No Init File Read")
304 #
305 X0L = FontSize * 7
306 XOLF = XOLBP = XOLXY = XOLIA = int(FontSize * 4.625)
307 XOLNqP = XOLNiC = int(FontSize * 3.125)
308 root.style = Style()
309 #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
310 try:
311  root.style.theme_use(Style_String)
312 except:
313  root.style.theme_use('default')
314 if MouseFocus == 1:
315  root.tk_focusFollowsMouse()
316 #
317 DevID = "m1k"
318 #
319 if sys.version_info[0] == 2:
320  default_font = tkFont.nametofont("TkDefaultFont")
321 if sys.version_info[0] == 3:
322  default_font = tkinter.font.nametofont("TkDefaultFont")
323 default_font.configure(size=FontSize)
324 
325 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)
326 
327 CHipdiv = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
328 
329 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)
330 ResScalediv = (1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000)
331 SampRateList = (1024, 2048, 4096, 8192, 16384, 32765, 64000, 93023, 93385, 93750, 94118,
332  96385, 96774, 97166, 97561, 97959, 98361, 98765, 99174, 99585, 100000)
333 
334 AWGAAmplvalue = 0.0
335 AWGAOffsetvalue = 0.0
336 AWGAFreqvalue = 0.0
337 AWGAPhasevalue = 0
338 AWGAdelayvalue = 0
339 AWGADutyCyclevalue = 50
340 AWGAWave = 'dc'
341 AWGBAmplvalue = 0.0
342 AWGBOffsetvalue = 0.0
343 AWGBFreqvalue = 0.0
344 AWGBPhasevalue = 0
345 AWGBdelayvalue = 0
346 AWGBDutyCyclevalue = 50
347 AWGBWave = 'dc'
348 AWGACycles = 1
349 AWGBCycles = 1
350 AWGABurstDelay = 0
351 AWGBBurstDelay = 0
352 Reset_Freq = 300
353 MeasGateLeft = 0.0
354 MeasGateRight = 0.0 # in mSec
355 MeasGateNum = 0
356 MeasGateStatus = IntVar(0)
357 MeasGateStatus.set(0)
358 #
359 DCV1 = DCV2 = MinV1 = MaxV1 = MinV2 = MaxV2 = MidV1 = PPV1 = MidV2 = PPV2 = SV1 = SI1 = 0
360 
361 DCVMuxA = MinVMuxA = MaxVMuxA = MidVMuxA = PPVMuxA = SVMuxA = 0
362 DCVMuxB = MinVMuxB = MaxVMuxB = MidVMuxB = PPVMuxB = SVMuxB = 0
363 DCVMuxC = MinVMuxC = MaxVMuxC = MidVMuxC = PPVMuxC = SVMuxC = 0
364 DCVMuxD = MinVMuxD = MaxVMuxD = MidVMuxD = PPVMuxD = SVMuxD = 0
365 CHADCy = CHBDCy = 0
366 DCI1 = DCI2 = MinI1 = MaxI1 = MinI2 = MaxI2 = MidI1 = PPI1 = MidI2 = PPI2 = SV2 = SI2 = 0
367 CHAperiod = CHAfreq = CHBperiod = CHBfreq = 0
368 # Calibration coefficients
369 CHAVGain = CHBVGain = 1.0
370 CHAVOffset = CHBVOffset = 0.0
371 # Initialisation of general variables
372 CHAOffset = CHBOffset = CHBAOffset = CHBBOffset = CHBCOffset = CHBDOffset = 2.5
373 CHAIOffset = CHBIOffset = InOffA = InGainA = InOffB = InGainB = 0.0
374 # Other global variables required in various routines
375 CANVASwidth = GRW + 2 * X0L # The canvas width
376 CANVASheight = GRH + Y0T + (FontSize * 7) # The canvas height
377 
378 ADsignal1 = [] # Ain signal array channel A and B
379 VBuffA = []
380 VBuffB = []
381 IBuffA = []
382 IBuffB = []
383 VBuffMA = []
384 VBuffMB = []
385 VBuffMC = []
386 VBuffMD = []
387 VmemoryMuxA = []
388 VmemoryMuxB = []
389 VmemoryMuxC = []
390 VmemoryMuxD = []
391 #
392 DFiltACoef = [1]
393 DFiltBCoef = [1]
394 DigFiltA = IntVar(0)
395 DigFiltA.set(0)
396 DigFiltABoxCar = IntVar(0)
397 DigFiltBBoxCar = IntVar(0)
398 DigFiltB = IntVar(0)
399 DigFiltB.set(0)
400 DigBuffA = IntVar(0)
401 DigBuffB = IntVar(0)
402 DigBuffA.set(0)
403 DigBuffB.set(0)
404 VFilterA = {}
405 VFilterB = {}
406 SampleRateStatus = IntVar(0)
407 ETSStatus = IntVar(0)
408 ETSDisp = IntVar(0)
409 ETSDir = IntVar(0)
410 #
411 AWGAwaveform = []
412 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
413 AWGBwaveform = []
414 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
415 VmemoryA = numpy.ones(1) # The memory for averaging
416 VmemoryB = numpy.ones(1)
417 ImemoryA = numpy.ones(1) # The memory for averaging
418 ImemoryB = numpy.ones(1)
419 TRACEresetTime = True # True for first new trace, false for averageing
420 TRACEresetFreq = True # True for first new trace, false for averageing
421 AWGScreenStatus = IntVar(0)
422 
423 T1Vline = [] # Voltage Trace line channel A
424 T2Vline = [] # Voltage Trace line channel B
425 T1Iline = [] # Current Trace line channel A
426 T2Iline = [] # Current Trace line channel B
427 TMAVline = [] # Voltage Trace line MUX channel A
428 TMBVline = [] # Voltage Trace line MUX channel B
429 TMCVline = [] # Voltage Trace line MUX channel C
430 TMDVline = [] # Voltage Trace line MUX channel D
431 TMBRline = [] # V reference Trace line MUX channel B
432 TMCRline = [] # V reference line MUX channel C
433 TXYline = [] # XY Trace line
434 TXYRline = [] # XY reference trace line
435 Tmathline = [] # Math trace line
436 TMXline = [] # X math Trace line
437 TMYline = [] # Y math Trace line
438 T1VRline = [] # V reference Trace line channel A
439 T2VRline = [] # V reference Trace line channel B
440 T1IRline = [] # I reference Trace line channel A
441 T2IRline = [] # I reference Trace line channel B
442 TMRline = [] # Math reference Trace line
443 Triggerline = [] # Triggerline
444 Triggersymbol = [] # Trigger symbol
445 #
446 SHOWsamples = 4000 # Number of samples on the screen
447 SCstart = 0 # Start sample of the trace
448 HozPoss = 0.0
449 Is_Triggered = 0
450 #
451 TRACES = 1 # Number of traces 1 or 2
452 TRACESread = 0 # Number of traces that have been read from ALM
453 ScreenTrefresh = IntVar(0)
454 ScreenXYrefresh = IntVar(0)
455 #
456 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
457 ZEROstuffing.set(1)
458 NSteps = IntVar(0) # number of frequency sweep steps
459 NSteps.set(128)
460 LoopNum = IntVar(0)
461 LoopNum.set(1)
462 LastWindow = -1
463 LastSMPfft = 0
464 CurrentFreqX = X0LBP + 14
465 FBins = numpy.linspace(0, 50000, num=16384)
466 FStep = numpy.linspace(0, 16384, num=NSteps.get())
467 FSweepMode = IntVar(0)
468 FSweepCont = IntVar(0)
469 FStepSync = IntVar(0)
470 FSweepSync = IntVar(0)
471 ShowCA_VdB = IntVar(0) # curves to display variables
472 ShowCA_P = IntVar(0)
473 ShowCB_VdB = IntVar(0)
474 ShowCB_P = IntVar(0)
475 ShowMarkerBP = IntVar(0)
476 ShowCA_RdB = IntVar(0)
477 ShowCA_RP = IntVar(0)
478 ShowCB_RdB = IntVar(0)
479 ShowCB_RP = IntVar(0)
480 ShowMathBP = IntVar(0)
481 ShowRMathBP = IntVar(0)
482 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
483 FSweepAdB = []
484 FSweepBdB = []
485 FSweepAPh = []
486 FSweepBPh = []
487 NSweepSeriesR = []
488 NSweepSeriesX = []
489 NSweepSeriesMag = [] # in ohms
490 NSweepSeriesAng = [] # in degrees
491 NetworkScreenStatus = IntVar(0)
492 BDSweepFile = IntVar(0)
493 FileSweepFreq = []
494 FileSweepAmpl = []
495 #
496 MarkerNum = MarkerFreqNum = 0
497 ShowTCur = IntVar(0)
498 ShowVCur = IntVar(0)
499 TCursor = VCursor = 0
500 ShowXCur = IntVar(0)
501 ShowYCur = IntVar(0)
502 XCursor = YCursor = 0
503 ShowFCur = IntVar(0)
504 ShowdBCur = IntVar(0)
505 FCursor = dBCursor = 0
506 ShowBPCur = IntVar(0)
507 ShowBdBCur = IntVar(0)
508 BPCursor = BdBCursor = 0
509 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
510 PowerStatus = 1
511 TRIGGERsample = 0 # AD sample trigger point
512 DX = 0 # interpolated trigger point
513 
514 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
515 DBdivindex = IntVar(0) # 10 dB/div as initial value
516 DBdivindex.set(4)
517 DBlevel = IntVar(0) # Reference level
518 DBlevel.set(0)
519 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
520 DBdivindexBP.set(4)
521 DBlevelBP = IntVar(0) # Reference level
522 DBlevelBP.set(0)
523 hldn = 0
524 SpectrumScreenStatus = IntVar(0)
525 SmoothCurvesSA = IntVar(0)
526 SmoothCurvesBP = IntVar(0)
527 CutDC = IntVar(0)
528 IAScreenStatus = IntVar(0)
529 NqPScreenStatus = IntVar(0)
530 NqPDisp = IntVar(0)
531 NiCScreenStatus = IntVar(0)
532 NiCDisp = IntVar(0)
533 ImpedanceMagnitude = 0.0 # in ohms
534 ImpedanceAngle = 0.0 # in degrees
535 ImpedanceRseries = 0.0 # in ohms
536 ImpedanceXseries = 0.0 # in ohms
537 Show_Rseries = IntVar(0)
538 Show_Xseries = IntVar(0)
539 Show_Magnitude = IntVar(0)
540 Show_Angle = IntVar(0)
541 Show_RseriesRef = IntVar(0)
542 Show_XseriesRef = IntVar(0)
543 Show_MagnitudeRef = IntVar(0)
544 Show_AngleRef = IntVar(0)
545 
546 TIARline = []
547 TIAXline = []
548 TIAMagline = []
549 TIAAngline = []
550 TIAMline = []
551 TIAMRline = []
552 RefIARline = []
553 RefIAXline = []
554 RefIAMagline = []
555 RefIAAngline = []
556 IASource = IntVar(0)
557 
558 DisplaySeries = IntVar(0)
559 IA_Ext_Conf = IntVar(0)
560 IASweepSaved = IntVar(0)
561 OverRangeFlagA = 0
562 OverRangeFlagB = 0
563 PeakdbA = 10
564 PeakdbB = 10
565 PeakRelPhase = 0.0
566 PeakfreqA = 100
567 PeakfreqB = 1000
568 OhmStatus = IntVar(0)
569 OhmRunStatus = IntVar(0)
570 FFTbandwidth = 0 # The FFT bandwidth
571 FFTBuffA = [] # Clear the FFTBuff array for trace A
572 FFTBuffB = [] # Clear the FFTBuff array for trace B
573 FFTresultA = [] # FFT result CHA
574 PhaseA = []
575 FFTresultB = [] # FFT result CHB
576 PhaseB = []
577 FFTresultAB = []
578 FFTwindowname = "--" # The FFT window name
579 FFTmemoryA = numpy.ones(1) # The memory for averaging
580 PhaseMemoryA = numpy.ones(1)
581 FFTmemoryB = numpy.ones(1) # The memory for averaging
582 PhaseMemoryB = numpy.ones(1)
583 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
584 SMPfftpwrTwo.set(11)
585 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
586 Two28 = 268435456
587 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
588 
589 T1Fline = [] # Frequency Trace line channel A
590 T2Fline = [] # Frequency Trace line channel B
591 T1Pline = [] # Phase angle Trace line channel A - B
592 T2Pline = [] # Phase angle Trace line channel B - A
593 T1FRline = [] # F reference Trace line channel A
594 T2FRline = [] # F reference Trace line channel B
595 T1PRline = [] # Phase reference Trace line channel A - B
596 T2PRline = [] # Phase reference Trace line channel B - A
597 TFMline = [] # Frequency Math Trace
598 TFRMline = [] # Frequency reference Math Trace
599 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
600 FreqTraceMode.set(1)
601 
602 TAFline = [] # Bode Freq Trace line channel A
603 TBFline = [] # Bode Freq Trace line channel B
604 TAPline = [] # Bode Phase angle Trace line channel A - B
605 TBPline = [] # Bode Phase angle Trace line channel B - A
606 TAFRline = [] # Bode F reference Trace line channel A
607 TBFRline = [] # Bode F reference Trace line channel B
608 TAPRline = [] # Bode Phase reference Trace line channel A - B
609 TBPRline = [] # Bode Phase reference Trace line channel B - A
610 TBPMline = [] # Bode Frequency Math Trace
611 TBPRMline = [] # Bode Frequency reference Math Trace
612 #
613 MinSamplesSA = 64
614 MaxSamplesSA = 65536
615 #
616 MathScreenStatus = IntVar(0)
617 #
618 XYScreenStatus = IntVar(0)
619 Xsignal = IntVar(0) # Signal for X axis variable
620 Xsignal.set(1)
621 Ysignal = IntVar(0) # Signal for X axis variable
622 Ysignal.set(3)
623 ShowRXY = IntVar(0) # show reference XY trace
624 # show Analog Input Mux Variables
625 Show_CBA = IntVar(0)
626 Show_CBB = IntVar(0)
627 Show_CBC = IntVar(0)
628 Show_CBD = IntVar(0)
629 D0 = IntVar(0)
630 D1 = IntVar(0)
631 D2 = IntVar(0)
632 D3 = IntVar(0)
633 D4 = IntVar(0)
634 D5 = IntVar(0)
635 D6 = IntVar(0)
636 D7 = IntVar(0)
637 PIO_0 = 28
638 PIO_1 = 29
639 PIO_2 = 47
640 PIO_3 = 3
641 PIO_4 = 4
642 PIO_5 = 5
643 PIO_6 = 6
644 PIO_7 = 7
645 #
646 SCLKPort = IntVar(0)
647 SDATAPort = IntVar(0)
648 SLATCHPort = IntVar(0)
649 
650 
651 hipulse = """
652 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
653 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
654 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
655 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
656 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
657 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
658 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
659 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
660 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
661 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
662 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
663 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
664 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
665 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
666 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
667 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
668 """
669 hipulseimg = PhotoImage(data=hipulse)
670 
671 lowpulse = """
672 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
673 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
674 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
675 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
676 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
677 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
678 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
679 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
680 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
681 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
682 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
683 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
684 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
685 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
686 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
687 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
688 """
689 lowpulseimg = PhotoImage(data=lowpulse)
690 
691 class CreateToolTip(object):
692 
693  def __init__(self, widget, text='widget info'):
694  self.waittime = 500 #miliseconds
695  self.wraplength = 100 #pixels
696  self.widget = widget
697  self.text = text
698  self.widget.bind("<Enter>", self.enter)
699  self.widget.bind("<Leave>", self.leave)
700  self.widget.bind("<ButtonPress>", self.leave)
701  self.id = None
702  self.tw = None
703 
704  def enter(self, event=None):
705  self.schedule()
706 
707  def leave(self, event=None):
708  self.unschedule()
709  self.hidetip()
710 
711  def schedule(self):
712  self.unschedule()
713  self.id = self.widget.after(self.waittime, self.showtip)
714 
715  def unschedule(self):
716  id = self.id
717  self.id = None
718  if id:
719  self.widget.after_cancel(id)
720 
721  def showtip(self, event=None):
722  x = y = 0
723  x, y, cx, cy = self.widget.bbox("insert")
724  x += self.widget.winfo_rootx() + 25
725  y += self.widget.winfo_rooty() + 20
726  # creates a toplevel window
727  self.tw = Toplevel(self.widget)
728  # Leaves only the label and removes the app window
729  self.tw.wm_overrideredirect(True)
730  self.tw.wm_geometry("+%d+%d" % (x, y))
731  label = Label(self.tw, text=self.text, justify='left',
732  background="#ffffe0", relief='solid', borderwidth=1,
733  wraplength = self.wraplength)
734  label.pack(ipadx=1)
735 
736  def hidetip(self):
737  tw = self.tw
738  self.tw= None
739  if tw:
740  tw.destroy()
741 #
742 # =========== Start widgets routines =============================
743 
745 def BSaveConfig(filename):
746  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
747  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
748  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
749  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
750  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
751  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
752  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
753  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
754  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
755  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
756  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
757  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
758  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
759  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
760  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
761  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
762  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
763  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
764  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
765  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
766  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
767  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
768  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
769  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
770  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
771  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
772  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
773  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
774  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
775  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode
776  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
777  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
778  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
779  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
780  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
781  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
782  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
783  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
784  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
785  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
786  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
787  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
788  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
789  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
790  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
791  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
792  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
793  global AWGABurstFlag, AWGACycles, AWGABurstDelay
794  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
795  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
796  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
797  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
798  global DigFiltStatus, DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
799 
800  # open Config file for Write?
801  try:
802  ConfgFile = open(filename, "w")
803  except: # didn't work? then just return
804  return
805  # Save Window placements
806  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
807  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
808  ConfgFile.write('global GRW; GRW = ' + str(GRW) + '\n')
809  ConfgFile.write('global GRH; GRH = ' + str(GRH) + '\n')
810  # Windows configuration
811  ConfgFile.write('global MathString; MathString = "' + MathString + '"\n')
812  ConfgFile.write('global MathUnits; MathUnits = "' + MathUnits + '"\n')
813  ConfgFile.write('global MathAxis; MathAxis = "' + MathAxis + '"\n')
814  ConfgFile.write('global MathXString; MathXString = "' + MathXString + '"\n')
815  ConfgFile.write('global MathXUnits; MathXUnits = "' + MathXUnits + '"\n')
816  ConfgFile.write('global MathXAxis; MathXAxis = "' + MathXAxis + '"\n')
817  ConfgFile.write('global MathYString; MathYString = "' + MathYString + '"\n')
818  ConfgFile.write('global MathYUnits; MathYUnits = "' + MathYUnits + '"\n')
819  ConfgFile.write('global MathYAxis; MathYAxis = "' + MathYAxis + '"\n')
820  if MathScreenStatus.get() > 0:
821  ConfgFile.write('NewEnterMathControls()\n')
822  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
823  else:
824  ConfgFile.write('DestroyMathScreen()\n')
825  if XYScreenStatus.get() > 0:
826  ConfgFile.write('global GRWXY; GRWXY = ' + str(GRWXY) + '\n')
827  ConfgFile.write('global GRHXY; GRHXY = ' + str(GRHXY) + '\n')
828  ConfgFile.write('MakeXYWindow()\n')
829  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
830  ConfgFile.write('CHAsbxy.delete(0,END)\n')
831  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
832  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
833  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
834  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
835  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
836  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
837  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
838  ConfgFile.write('CHBsbxy.delete(0,END)\n')
839  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
840  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
841  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
842  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
843  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
844  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
845  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
846  else:
847  ConfgFile.write('DestroyXYScreen()\n')
848  if IAScreenStatus.get() > 0:
849  ConfgFile.write('global GRWIA; GRWIA = ' + str(GRWIA) + '\n')
850  ConfgFile.write('global GRHIA; GRHIA = ' + str(GRHIA) + '\n')
851  ConfgFile.write('MakeIAWindow()\n')
852  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
853  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
854  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
855  ConfgFile.write('RsystemEntry.delete(0,END)\n')
856  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
857  ConfgFile.write('ResScale.delete(0,END)\n')
858  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
859  ConfgFile.write('GainCorEntry.delete(0,END)\n')
860  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
861  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
862  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
863  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
864  else:
865  ConfgFile.write('DestroyIAScreen()\n')
866  if SpectrumScreenStatus.get() > 0:
867  ConfgFile.write('global GRWF; GRWF = ' + str(GRWF) + '\n')
868  ConfgFile.write('global GRHF; GRHF = ' + str(GRHF) + '\n')
869  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
870  ConfgFile.write('MakeSpectrumWindow()\n')
871  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
872  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
873  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
874  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
875  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
876  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
877  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
878  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
879  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
880  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
881  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
882  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
883  else:
884  ConfgFile.write('DestroySpectrumScreen()\n')
885  if DacScreenStatus.get() > 0:
886  ConfgFile.write('MakeDacScreen()\n')
887  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
888  else:
889  ConfgFile.write('DestroyDacScreen()\n')
890  if DigScreenStatus.get() > 0:
891  ConfgFile.write('MakeDigScreen()\n')
892  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
893  else:
894  ConfgFile.write('DestroyDigScreen()\n')
895  if EnableHSsampling > 0:
896  ConfgFile.write('FminEntry.delete(0,"end")\n')
897  ConfgFile.write('FminEntry.insert(0, ' + FminEntry.get() + ')\n')
898  ConfgFile.write('HtMulEntry.delete(0,"end")\n')
899  ConfgFile.write('HtMulEntry.insert(0, ' + HtMulEntry.get() + ')\n')
900  ConfgFile.write('Auto_ETS_Comp.set(' + str(Auto_ETS_Comp.get()) + ')\n')
901  try:
902  ConfgFile.write('ets_TC1Entry.delete(0,"end")\n')
903  ConfgFile.write('ets_TC1Entry.insert(0, ' + ets_TC1Entry.get() + ')\n')
904  ConfgFile.write('ETS_TC1.set(' + ets_TC1Entry.get() + ')\n')
905  ConfgFile.write('ets_A1Entry.delete(0,"end")\n')
906  ConfgFile.write('ets_A1Entry.insert(0, ' + ets_A1Entry.get() + ')\n')
907  ConfgFile.write('ETS_A1.set(' + ets_A1Entry.get() + ')\n')
908  ConfgFile.write('ets_TC2Entry.delete(0,"end")\n')
909  ConfgFile.write('ets_TC2Entry.insert(0, ' + ets_TC2Entry.get() + ')\n')
910  ConfgFile.write('ETS_TC2.set(' + ets_TC2Entry.get() + ')\n')
911  ConfgFile.write('ets_A2Entry.delete(0,"end")\n')
912  ConfgFile.write('ets_A2Entry.insert(0, ' + ets_A2Entry.get() + ')\n')
913  ConfgFile.write('ETS_A2.set(' + ets_A2Entry.get() + ')\n')
914  except:
915  ConfgFile.write('ETS_TC1.set(' + str(ETS_TC1.get()) + ')\n')
916  ConfgFile.write('ETS_A1.set(' + str(ETS_A1.get()) + ')\n')
917  ConfgFile.write('ETS_TC2.set(' + str(ETS_TC2.get()) + ')\n')
918  ConfgFile.write('ETS_A2.set(' + str(ETS_A2.get()) + ')\n')
919  if DigFiltStatus.get() == 1:
920  ConfgFile.write('MakeDigFiltWindow()\n')
921  ConfgFile.write('DigFiltABoxCar.set(' + str(DigFiltABoxCar.get()) + ')\n')
922  ConfgFile.write('DigFiltBBoxCar.set(' + str(DigFiltBBoxCar.get()) + ')\n')
923  ConfgFile.write('BCALenEntry.delete(0,"end")\n')
924  ConfgFile.write('BCALenEntry.insert(0, ' + BCALenEntry.get() + ')\n')
925  ConfgFile.write('BCBLenEntry.delete(0,"end")\n')
926  ConfgFile.write('BCBLenEntry.insert(0, ' + BCBLenEntry.get() + ')\n')
927  ConfgFile.write('BuildBoxCarA()\n')
928  ConfgFile.write('BuildBoxCarB()\n')
929  else:
930  ConfgFile.write('DestroyDigFiltScreen()\n')
931  if MinigenScreenStatus.get() == 1:
932  ConfgFile.write('MakeMinigenWindow()\n')
933  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
934  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
935  ConfgFile.write('MinigenFout.delete(0,END)\n')
936  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
937  ConfgFile.write('MinigenFclk.delete(0,END)\n')
938  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
939  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
940  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
941  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
942  else:
943  ConfgFile.write('DestroyMinigenScreen()\n')
944  if MuxScreenStatus.get() == 1:
945  ConfgFile.write('MakeMuxModeWindow()\n')
946  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
947  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
948  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
949  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
950  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
951  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
952  ConfgFile.write('CHB_Asb.delete(0,END)\n')
953  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
954  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
955  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
956  ConfgFile.write('CHB_Csb.delete(0,END)\n')
957  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
958  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
959  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
960  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
961  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
962  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
963  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
964  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
965  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
966  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
967  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
968  else:
969  ConfgFile.write('DestroyMuxScreen()\n')
970  if BodeScreenStatus.get() == 1:
971  ConfgFile.write('global GRWBP; GRWBP = ' + str(GRWBP) + '\n')
972  ConfgFile.write('global GRHBP; GRHBP = ' + str(GRHBP) + '\n')
973  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
974  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
975  ConfgFile.write('MakeBodeWindow()\n')
976  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
977  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
978  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
979  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
980  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
981  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
982  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
983  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
984  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
985  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
986  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
987  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
988  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
989  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
990  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
991  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
992  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
993  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
994  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
995  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
996  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
997  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
998  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
999  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
1000  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
1001  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
1002  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
1003  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
1004  else:
1005  ConfgFile.write('DestroyBodeScreen()\n')
1006  if MeasureStatus.get() == 1:
1007  # Save strings
1008  ConfgFile.write('global ChaLableSrring1; ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
1009  ConfgFile.write('global ChaLableSrring2; ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
1010  ConfgFile.write('global ChaLableSrring3; ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
1011  ConfgFile.write('global ChaLableSrring4; ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
1012  ConfgFile.write('global ChaLableSrring5; ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
1013  ConfgFile.write('global ChaLableSrring6; ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
1014  ConfgFile.write('global ChbLableSrring1; ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
1015  ConfgFile.write('global ChbLableSrring2; ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
1016  ConfgFile.write('global ChbLableSrring3; ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
1017  ConfgFile.write('global ChbLableSrring4; ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
1018  ConfgFile.write('global ChbLableSrring5; ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
1019  ConfgFile.write('global ChbLableSrring6; ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
1020  ConfgFile.write('global ChaMeasString1; ChaMeasString1 = "' + ChaMeasString1 + '"\n')
1021  ConfgFile.write('global ChaMeasString2; ChaMeasString2 = "' + ChaMeasString2 + '"\n')
1022  ConfgFile.write('global ChaMeasString3; ChaMeasString3 = "' + ChaMeasString3 + '"\n')
1023  ConfgFile.write('global ChaMeasString4; ChaMeasString4 = "' + ChaMeasString4 + '"\n')
1024  ConfgFile.write('global ChaMeasString5; ChaMeasString5 = "' + ChaMeasString5 + '"\n')
1025  ConfgFile.write('global ChaMeasString6; ChaMeasString6 = "' + ChaMeasString6 + '"\n')
1026  ConfgFile.write('global ChbMeasString1; ChbMeasString1 = "' + ChbMeasString1 + '"\n')
1027  ConfgFile.write('global ChbMeasString2; ChbMeasString2 = "' + ChbMeasString2 + '"\n')
1028  ConfgFile.write('global ChbMeasString3; ChbMeasString3 = "' + ChbMeasString3 + '"\n')
1029  ConfgFile.write('global ChbMeasString4; ChbMeasString4 = "' + ChbMeasString4 + '"\n')
1030  ConfgFile.write('global ChbMeasString5; ChbMeasString5 = "' + ChbMeasString5 + '"\n')
1031  ConfgFile.write('global ChbMeasString6; ChbMeasString6 = "' + ChbMeasString6 + '"\n')
1032  ConfgFile.write('MakeMeasureScreen()\n')
1033  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
1034  else:
1035  ConfgFile.write('DestroyMeasuewScreen()\n')
1036  if ETSStatus.get() == 1: #
1037  ConfgFile.write('MakeETSWindow()\n')
1038  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
1039  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
1040  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
1041  ConfgFile.write('FMulXEntry.delete(0,END)\n')
1042  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
1043  ConfgFile.write('DivXEntry.delete(0,END)\n')
1044  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
1045  ConfgFile.write('ETSts.delete(0,END)\n')
1046  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
1047  else:
1048  ConfgFile.write('DestroyETSScreen()\n')
1049  #
1050  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
1051  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
1052  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
1053  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
1054  ConfgFile.write('HozPossentry.delete(0,"end")\n')
1055  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
1056  ConfgFile.write('TMsb.delete(0,END)\n')
1057  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
1058  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
1059  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
1060  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
1061  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
1062  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
1063  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
1064  ConfgFile.write('Ysignal.set(' + str(Ysignal.get()) + ')\n')
1065  #
1066  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
1067  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
1068  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
1069  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
1070  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
1071  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
1072  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
1073  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
1074  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
1075  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
1076  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
1077  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
1078  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
1079  #
1080  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
1081  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
1082  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
1083  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1084  ConfgFile.write('CHAsb.delete(0,END)\n')
1085  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1086  ConfgFile.write('CHAIsb.delete(0,END)\n')
1087  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1088  #
1089  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1090  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1091  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1092  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1093  ConfgFile.write('CHBsb.delete(0,END)\n')
1094  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1095  ConfgFile.write('CHBIsb.delete(0,END)\n')
1096  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1097  # AWG stuff
1098  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1099  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1100  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1101  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1102  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1103  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1104  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1105  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1106  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1107  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1108  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1109  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1110  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1111  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1112  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1113  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1114  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1115  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1116  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1117  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1118  #
1119  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1120  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1121  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1122  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1123  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1124  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1125  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1126  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1127  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1128  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1129  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1130  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1131  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1132  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1133  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1134  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1135  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1136  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1137  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1138  #
1139  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1140  #
1141  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1142  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1143  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1144  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1145  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1146  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1147  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1148  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1149  #
1150  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1151  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1152  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1153  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1154  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1155  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1156  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1157  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1158  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1159  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1160  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1161  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1162  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1163  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1164  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1165  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1166  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1167  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1168  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1169  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1170  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1171  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1172  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1173  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1174  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1175  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1176  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1177  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1178  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1179  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1180  #
1181  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1182  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1183  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1184  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1185  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1186  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1187  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1188  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1189  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1190  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1191  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1192  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1193  #
1194  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1195  #
1196  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1197  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1198  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1199  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1200  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1201  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1202  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1203  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1204  # Save strings
1205  ConfgFile.write('global UserAString; UserAString = "' + UserAString + '"\n')
1206  ConfgFile.write('global UserALabel; UserALabel = "' + UserALabel + '"\n')
1207  ConfgFile.write('global UserBString; UserBString = "' + UserBString + '"\n')
1208  ConfgFile.write('global UserBLabel; UserBLabel = "' + UserBLabel + '"\n')
1209  ConfgFile.write('global AWGAMathString; AWGAMathString = "' + AWGAMathString + '"\n')
1210  ConfgFile.write('global AWGBMathString; AWGBMathString = "' + AWGBMathString + '"\n')
1211  ConfgFile.write('global FFTUserWindowString; FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1212  ConfgFile.write('global DigFilterAString; DigFilterAString = "' + DigFilterAString + '"\n')
1213  ConfgFile.write('global DigFilterBString; DigFilterBString = "' + DigFilterBString + '"\n')
1214  # save channel AC frequency compensation settings
1215  try:
1216  CHA_TC1.set(float(cha_TC1Entry.get()))
1217  CHA_TC2.set(float(cha_TC2Entry.get()))
1218  CHB_TC1.set(float(chb_TC1Entry.get()))
1219  CHB_TC2.set(float(chb_TC2Entry.get()))
1220  CHA_A1.set(float(cha_A1Entry.get()))
1221  CHA_A2.set(float(cha_A2Entry.get()))
1222  CHB_A1.set(float(chb_A1Entry.get()))
1223  CHB_A2.set(float(chb_A2Entry.get()))
1224  except:
1225  donothing()
1226  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1227  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1228  ConfgFile.write('CHAI_RC_HP.set(' + str(CHAI_RC_HP.get()) + ')\n')
1229  ConfgFile.write('CHBI_RC_HP.set(' + str(CHBI_RC_HP.get()) + ')\n')
1230  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1231  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1232  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1233  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1234  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1235  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1236  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1237  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1238  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1239  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1240  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1241  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1242  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1243  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1244  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1245  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1246  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1247  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1248  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1249  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1250  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1251  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1252  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1253  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1254 
1255  # extra Spectrum stuff
1256  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1257  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1258  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1259  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1260  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1261  #
1262  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1263  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1264  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1265  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1266  #
1267  ConfgFile.close()
1268 
1270  global iawindow
1271 
1272  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1273  BSaveConfig(filename)
1274 
1276  global freqwindow
1277 
1278  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1279  BSaveConfig(filename)
1280 
1282  global bodewindow
1283 
1284  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1285  BSaveConfig(filename)
1286 
1288  global root
1289  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1290  BSaveConfig(filename)
1291 
1292 def BLoadConfig(filename):
1293  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1294  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1295  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
1296  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1297  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1298  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1299  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1300  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1301  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1302  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1303  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1304  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1305  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1306  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1307  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1308  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1309  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1310  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1311  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1312  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1313  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1314  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1315  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1316  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1317  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1318  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1319  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1320  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
1321  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1322  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1323  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1324  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1325  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1326  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1327  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1328  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1329  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1330  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1331  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1332  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1333  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1334  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1335  global AWGABurstFlag, AWGACycles, AWGABurstDelay
1336  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
1337  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1338 
1339  # Read configuration values from file
1340  try:
1341  ConfgFile = open(filename)
1342  for line in ConfgFile:
1343  try:
1344  exec( line.rstrip() )
1345  except:
1346  print( "Skipping " + line.rstrip())
1347  ConfgFile.close()
1348  if DevID != "No Device":
1349  BAWGAModeLabel()
1350  BAWGBModeLabel()
1351  BAWGAPhaseDelay()
1352  BAWGBPhaseDelay()
1353  UpdateAWGWin()
1354  TimeCheckBox()
1355  XYCheckBox()
1356  FreqCheckBox()
1357  BodeCheckBox()
1358  IACheckBox()
1359  OhmCheckBox()
1360 #
1361  time.sleep(0.05)
1362  ReMakeAWGwaves()
1363  session.end() # Add this to turn off outputs after first tiem loading a config?
1364  BTime()
1365  except:
1366  print( "Config File Not Found.")
1367 
1368 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1369  global AWGAShape, AWGBShape, BisCompA
1370 
1371  if AWGAShape.get()==9:
1372  AWGAMakeImpulse()
1373  elif AWGAShape.get()==11:
1375  elif AWGAShape.get()==15:
1376  AWGAMakeSSQ()
1377  elif AWGAShape.get()==16:
1378  AWGAMakeRamp()
1379  elif AWGAShape.get()==17:
1380  AWGAMakePWMSine()
1381  elif AWGAShape.get()==18:
1383  elif AWGAShape.get()==12:
1385  elif AWGAShape.get()==14:
1386  AWGAMakeFourier()
1387  elif AWGAShape.get()==19:
1388  AWGAMakeSinc()
1389  elif AWGAShape.get()==20:
1390  AWGAMakePulse()
1391  elif AWGAShape.get()==21:
1392  AWGAMakeFMSine()
1393  elif AWGAShape.get()==22:
1394  AWGAMakeAMSine()
1395  elif AWGAShape.get()==7:
1396  AWGAMakeUUNoise()
1397  elif AWGAShape.get()==8:
1398  AWGAMakeUGNoise()
1399 #
1400  if BisCompA.get() == 1:
1401  SetBCompA()
1402  if AWGBShape.get()==9:
1403  AWGBMakeImpulse()
1404  elif AWGBShape.get()==11:
1406  elif AWGBShape.get()==15:
1407  AWGBMakeSSQ()
1408  elif AWGBShape.get()==16:
1409  AWGBMakeRamp()
1410  elif AWGBShape.get()==17:
1411  AWGBMakePWMSine()
1412  elif AWGBShape.get()==18:
1414  elif AWGBShape.get()==12:
1416  elif AWGBShape.get()==14:
1417  AWGBMakeFourier()
1418  elif AWGBShape.get()==19:
1419  AWGBMakeSinc()
1420  elif AWGBShape.get()==20:
1421  AWGBMakePulse()
1422  elif AWGBShape.get()==7:
1423  AWGBMakeUUNoise()
1424  elif AWGBShape.get()==8:
1425  AWGBMakeUGNoise()
1426  else:
1427  UpdateAwgCont()
1428  time.sleep(0.05)
1429 
1431  global iawindow
1432 
1433  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1434  BLoadConfig(filename)
1435 
1437  global freqwindow
1438 
1439  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1440  BLoadConfig(filename)
1441 
1443  global bodewindow
1444 
1445  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1446  BLoadConfig(filename)
1447 
1449  global root
1450 
1451  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1452  BLoadConfig(filename)
1453  UpdateTimeTrace()
1454 
1455 def BgColor():
1456  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus
1457  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
1458 
1459  if ColorMode.get() > 0:
1460  COLORtext = "#000000" # 100% black
1461  COLORtrace4 = "#a0a000" # 50% yellow
1462  COLORtraceR4 = "#606000" # 25% yellow
1463  COLORcanvas = "#ffffff" # 100% white
1464  else:
1465  COLORcanvas = "#000000" # 100% black
1466  COLORtrace4 = "#ffff00" # 100% yellow
1467  COLORtraceR4 = "#808000" # 50% yellow
1468  COLORtext = "#ffffff" # 100% white
1469  ca.config(background=COLORcanvas)
1471  if SpectrumScreenStatus.get() > 0:
1472  Freqca.config(background=COLORcanvas)
1474  if XYScreenStatus.get() > 0:
1475  XYca.config(background=COLORcanvas)
1476  UpdateXYScreen()
1477  if IAScreenStatus.get() > 0:
1478  IAca.config(background=COLORcanvas)
1479  UpdateIAScreen()
1480  if BodeScreenStatus.get() > 0:
1481  Bodeca.config(background=COLORcanvas)
1483 
1485  global CANVASwidth, CANVASheight
1486  global COLORtext, MarkerNum, ColorMode
1487  # ask for file name
1488  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
1489  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
1490  if MarkerNum > 0 or ColorMode.get() > 0:
1491  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
1492  else: # temp chnage text corlor to black
1493  COLORtext = "#000000"
1495  # first save postscript file
1496  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
1497  # now convert to bit map
1498  # img = Image.open("screen_shot.eps")
1499  # img.save("screen_shot.gif", "gif")
1500  COLORtext = "#ffffff"
1502 
1504  global CANVASwidthXY, CANVASheightXY, xywindow
1505  global COLORtext, MarkerNum, ColorMode, XYca
1506  # ask for file name
1507  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
1508  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
1509  if MarkerNum > 0 or ColorMode.get() > 0:
1510  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
1511  else: # temp chnage text corlor to black
1512  COLORtext = "#000000"
1513  UpdateXYScreen()
1514  # first save postscript file
1515  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
1516  # now convert to bit map
1517  # img = Image.open("screen_shot.eps")
1518  # img.save("screen_shot.gif", "gif")
1519  COLORtext = "#ffffff"
1520  UpdateXYScreen()
1521 
1523  global CANVASwidthIA, CANVASheightIA
1524  global COLORtext, IAca, ColorMode, iawindow
1525  # ask for file name
1526  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
1527  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
1528  if ColorMode.get() > 0:
1529  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
1530  else: # temp change text color to black for Black BG
1531  COLORtext = "#000000"
1532  UpdateIAScreen()
1533  # save postscript file
1534  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
1535  #
1536  COLORtext = "#ffffff"
1537  UpdateIAScreen()
1538 
1540  global CANVASwidthBP, CANVASheightBP
1541  global COLORtext, Bodeca, bodewindow
1542  # ask for file name
1543  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
1544  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
1545  if MarkerNum > 0 or ColorMode.get() > 0:
1546  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
1547  else: # temp change text color to black
1548  COLORtext = "#000000"
1550  # save postscript file
1551  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
1552  #
1553  COLORtext = "#ffffff"
1555 
1557  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
1558 
1559  # open file to save data
1560  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
1561  DataFile = open(filename, 'w')
1562  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
1563  for index in range(len(VBuffA)):
1564  TimePnt = float((index+0.0)/SAMPLErate)
1565  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
1566  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
1567  DataFile.close()
1568 
1570  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
1571 
1572  # ask user for channel to save
1573  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I or CB-I\n\nChannel:\n", initialvalue="CA-V")
1574  if (Channel == None): # If Cancel pressed, then None
1575  return
1576  # open file to save data
1577  filename = asksaveasfilename(defaultextension = ".txt", filetypes=[("Text Columns", "*.txt")])
1578  DataFile = open(filename, 'w')
1579  for index in range(len(VBuffA)):
1580  TimePnt = float((index+0.0)/SAMPLErate)
1581  if Channel == "CA-V":
1582  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
1583  elif Channel == "CA-I":
1584  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
1585  elif Channel == "CB-V":
1586  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
1587  elif Channel == "CB-I":
1588  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
1589  DataFile.close()
1590 
1592  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
1593 
1594  # Read values from CVS file
1595  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
1596  try:
1597  CSVFile = open(filename)
1598  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
1599  CSVFile.seek(0)
1600  csv_f = csv.reader(CSVFile, dialect)
1601  VBuffA = []
1602  VBuffB = []
1603  IBuffA = []
1604  IBuffB = []
1605  SHOWsamples = 0
1606  for row in csv_f:
1607  try:
1608  VBuffA.append(float(row[1]))
1609  IBuffA.append(float(row[2]))
1610  VBuffB.append(float(row[3]))
1611  IBuffB.append(float(row[4]))
1612  SHOWsamples = SHOWsamples + 1
1613  except:
1614  print( 'skipping non-numeric row')
1615  VBuffA = numpy.array(VBuffA)
1616  IBuffA = numpy.array(IBuffA)
1617  VBuffB = numpy.array(VBuffB)
1618  IBuffB = numpy.array(IBuffB)
1619  CSVFile.close()
1620  UpdateTimeTrace()
1621  except:
1622  showwarning("WARNING","No such file found or wrong format!")
1623 
1625 def BHelp():
1626 
1627  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
1628  webbrowser.open(url,new=2)
1629 
1630 def BAbout():
1631  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
1632 #Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.4/alice-desktop-1.3-setup.exe'
1633  try:
1634  if sys.version_info[0] == 2:
1635  u = urllib2.urlopen(Version_url)
1636  if sys.version_info[0] == 3:
1637  u = urllib.request.urlopen(Version_url)
1638  meta = u.info()
1639  time_string = str(meta.getheaders("Last-Modified"))
1640  except:
1641  time_string = "Unavailable"
1642  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
1643  "Last Released Version: " + time_string[7:18] + "\n" +
1644  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
1645  "Firmware Rev " + str(FWRevOne) + "\n" +
1646  "Board Serial Number " + DevID + "\n" +
1647  "Software is provided as is without any Warranty")
1648 
1650  global T1Vline, T2Vline, T1Iline, T2Iline
1651  global TXYline, Tmathline, TMRline, TXYRline
1652  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
1653  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
1654  global MuxScreenStatus, TMCRline, TMBRline, TMAVline, TMBVline, TMCVline, TMDVline
1655  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
1656 
1657  if ShowC1_V.get() == 1:
1658  T1VRline = T1Vline # V reference Trace line channel A
1659  if ShowC2_V.get() == 1:
1660  T2VRline = T2Vline # V reference Trace line channel B
1661  if ShowC1_I.get() == 1:
1662  T1IRline = T1Iline # I reference Trace line channel A
1663  if ShowC2_I.get() == 1:
1664  T2IRline = T2Iline # I reference Trace line channel B
1665  if MathTrace.get() > 0:
1666  TMRline = Tmathline # Math reference Trace line
1667  if MuxScreenStatus.get() > 0:
1668  if Show_CBA.get() > 0:
1669  T2VRline = TMAVline # V reference Trace line Mux channel A
1670  if Show_CBB.get() > 0:
1671  TMBRline = TMBVline # V reference Trace line Mux channel B
1672  if Show_CBC.get() > 0:
1673  TMCRline = TMCVline # V reference Trace line Mux channel C
1674  if Show_CBD.get() > 0:
1675  T2IRline = TMDVline # V reference Trace line Mux channel D
1676  if len(TXYline) > 4:
1677  TXYRline = TXYline # XY reference trace line
1678 
1679 def BSaveCal():
1680  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1681  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1682  global DevID
1683  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1684  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
1685  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1686  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1687 
1688  devidstr = DevID[17:31]
1689  filename = devidstr + "_O.cal"
1690  CalFile = open(filename, "w")
1691  #
1692  CalFile.write('CHAVGainEntry.delete(0,END)\n')
1693  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1694  CalFile.write('CHBVGainEntry.delete(0,END)\n')
1695  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1696  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
1697  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1698  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
1699  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1700  #
1701  CalFile.write('CHAIGainEntry.delete(0,END)\n')
1702  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1703  CalFile.write('CHBIGainEntry.delete(0,END)\n')
1704  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1705  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
1706  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1707  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
1708  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1709  #
1710  # save channel AC frequency compensation settings
1711  try:
1712  CHA_TC1.set(float(cha_TC1Entry.get()))
1713  CHA_TC2.set(float(cha_TC2Entry.get()))
1714  CHB_TC1.set(float(chb_TC1Entry.get()))
1715  CHB_TC2.set(float(chb_TC2Entry.get()))
1716  CHA_A1.set(float(cha_A1Entry.get()))
1717  CHA_A2.set(float(cha_A2Entry.get()))
1718  CHB_A1.set(float(chb_A1Entry.get()))
1719  CHB_A2.set(float(chb_A2Entry.get()))
1720  except:
1721  donothing()
1722  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1723  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1724  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1725  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1726  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1727  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1728  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1729  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1730  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1731  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1732  CalFile.write('cha_TC1Entry.delete(0,END)\n')
1733  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1734  CalFile.write('cha_TC2Entry.delete(0,END)\n')
1735  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1736  CalFile.write('chb_TC1Entry.delete(0,END)\n')
1737  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1738  CalFile.write('chb_TC2Entry.delete(0,END)\n')
1739  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1740  CalFile.write('cha_A1Entry.delete(0,END)\n')
1741  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1742  CalFile.write('cha_A2Entry.delete(0,END)\n')
1743  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1744  CalFile.write('chb_A1Entry.delete(0,END)\n')
1745  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1746  CalFile.write('chb_A2Entry.delete(0,END)\n')
1747  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1748 
1749  CalFile.close()
1750 
1751 def BLoadCal():
1752  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1753  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1754  global DevID
1755  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1756  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
1757  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1758  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1759 
1760  devidstr = DevID[17:31]
1761  filename = devidstr + "_O.cal"
1762  try:
1763  CalFile = open(filename)
1764  for line in CalFile:
1765  exec( line.rstrip() )
1766  CalFile.close()
1767  except:
1768  print( "Cal file for this device not found")
1769 
1771  global UserAString, UserALabel, MeasUserA
1772 
1773  TempString = UserALabel
1774  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
1775  if (UserALabel == None): # If Cancel pressed, then None
1776  MeasUserA.set(0)
1777  UserALabel = TempString
1778  return
1779  TempString = UserAString
1780  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
1781  if (UserAString == None): # If Cancel pressed, then None
1782  MeasUserA.set(0)
1783  UserAString = TempString
1784  return
1785  MeasUserA.set(1)
1786 
1788  global UserBString, UserBLabel, MeasUserB
1789 
1790  TempString = UserBLabel
1791  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
1792  if (UserBLabel == None): # If Cancel pressed, then None
1793  MeasUserB.set(0)
1794  UserBLabel = TempString
1795  return
1796  TempString = UserBString
1797  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
1798  if (UserBString == None): # If Cancel pressed, then None
1799  MeasUserB.set(0)
1800  UserBString = TempString
1801  return
1802  MeasUserB.set(1)
1803 
1805  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
1806  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
1807  global MathAxis, MathXAxis, MathYAxis, MathTrace
1808  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
1809  global formlab, xformlab, yformlab
1810 
1811  if MathScreenStatus.get() == 0:
1812  MathScreenStatus.set(1)
1813  #
1814  MathWindow = Toplevel()
1815  MathWindow.title("Math Formula " + SWRev + RevDate)
1816  MathWindow.resizable(FALSE,FALSE)
1817  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
1818  frame1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10R1.TLabelframe")
1819  frame2 = LabelFrame(MathWindow, text="Math Trace", style="A10R1.TLabelframe")
1820  frame3 = LabelFrame(MathWindow, text="X Math Trace", style="A10R1.TLabelframe")
1821  frame4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10R1.TLabelframe")
1822  # frame1.grid(row=0, column=0, sticky=W)
1823  #
1824  frame1.grid(row = 0, column=0, rowspan=3, sticky=W)
1825  frame2.grid(row = 0, column=1, sticky=W)
1826  frame3.grid(row = 1, column=1, sticky=W)
1827  frame4.grid(row = 2, column=1, sticky=W)
1828  #
1829  # Built in functions
1830  #
1831  rb1 = Radiobutton(frame1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
1832  rb1.grid(row=0, column=0, sticky=W)
1833  rb2 = Radiobutton(frame1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
1834  rb2.grid(row=1, column=0, sticky=W)
1835  rb3 = Radiobutton(frame1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
1836  rb3.grid(row=2, column=0, sticky=W)
1837  rb4 = Radiobutton(frame1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
1838  rb4.grid(row=3, column=0, sticky=W)
1839  rb5 = Radiobutton(frame1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
1840  rb5.grid(row=4, column=0, sticky=W)
1841  rb6 = Radiobutton(frame1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
1842  rb6.grid(row=5, column=0, sticky=W)
1843  rb7 = Radiobutton(frame1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
1844  rb7.grid(row=6, column=0, sticky=W)
1845  rb8 = Radiobutton(frame1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
1846  rb8.grid(row=7, column=0, sticky=W)
1847  rb9 = Radiobutton(frame1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
1848  rb9.grid(row=8, column=0, sticky=W)
1849  rb10 = Radiobutton(frame1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
1850  rb10.grid(row=9, column=0, sticky=W)
1851  rb11 = Radiobutton(frame1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
1852  rb11.grid(row=10, column=0, sticky=W)
1853  rb12 = Radiobutton(frame1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
1854  rb12.grid(row=11, column=0, sticky=W)
1855  rb13 = Radiobutton(frame1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
1856  rb13.grid(row=12, column=0, sticky=W)
1857  #
1858  # Math trace formula sub frame2
1859  #
1860  sframe2a = Frame( frame2 )
1861  sframe2a.pack(side=TOP)
1862  formlab = Label(sframe2a, text=" Formula ", style= "A10B.TLabel")
1863  formlab.pack(side=LEFT)
1864  formentry = Entry(sframe2a, width=23)
1865  formentry.pack(side=LEFT)
1866  formentry.delete(0,"end")
1867  formentry.insert(0,MathString)
1868  sframe2b = Frame( frame2 )
1869  sframe2b.pack(side=TOP)
1870  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
1871  unitslab.pack(side=LEFT)
1872  unitsentry = Entry(sframe2b, width=6)
1873  unitsentry.pack(side=LEFT)
1874  unitsentry.delete(0,"end")
1875  unitsentry.insert(0,MathUnits)
1876  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
1877  checkbt.pack(side=LEFT)
1878  sframe2c = Frame( frame2 )
1879  sframe2c.pack(side=TOP)
1880  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
1881  axislab.pack(side=LEFT)
1882  axisentry = Entry(sframe2c, width=3)
1883  axisentry.pack(side=LEFT)
1884  axisentry.delete(0,"end")
1885  axisentry.insert(0,MathAxis)
1886  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
1887  applybt.pack(side=LEFT)
1888  #
1889  # X Math trace formula sub frame3
1890  #
1891  sframe3a = Frame( frame3 )
1892  sframe3a.pack(side=TOP)
1893  xformlab = Label(sframe3a, text="X Formula ", style= "A10B.TLabel")
1894  xformlab.pack(side=LEFT)
1895  xformentry = Entry(sframe3a, width=23)
1896  xformentry.pack(side=LEFT)
1897  xformentry.delete(0,"end")
1898  xformentry.insert(0, MathXString)
1899  sframe3b = Frame( frame3 )
1900  sframe3b.pack(side=TOP)
1901  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
1902  xunitslab.pack(side=LEFT)
1903  xunitsentry = Entry(sframe3b, width=6)
1904  xunitsentry.pack(side=LEFT)
1905  xunitsentry.delete(0,"end")
1906  xunitsentry.insert(0, MathXUnits)
1907  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
1908  xcheckbt.pack(side=LEFT)
1909  sframe3c = Frame( frame3 )
1910  sframe3c.pack(side=TOP)
1911  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
1912  xaxislab.pack(side=LEFT)
1913  xaxisentry = Entry(sframe3c, width=3)
1914  xaxisentry.pack(side=LEFT)
1915  xaxisentry.delete(0,"end")
1916  xaxisentry.insert(0, MathXAxis)
1917  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
1918  xapplybt.pack(side=LEFT)
1919  #
1920  # Math trace formula sub frame4
1921  #
1922  sframe4a = Frame( frame4 )
1923  sframe4a.pack(side=TOP)
1924  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
1925  yformlab.pack(side=LEFT)
1926  yformentry = Entry(sframe4a, width=23)
1927  yformentry.pack(side=LEFT)
1928  yformentry.delete(0,"end")
1929  yformentry.insert(0,MathYString)
1930  sframe4b = Frame( frame4 )
1931  sframe4b.pack(side=TOP)
1932  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
1933  yunitslab.pack(side=LEFT)
1934  yunitsentry = Entry(sframe4b, width=6)
1935  yunitsentry.pack(side=LEFT)
1936  yunitsentry.delete(0,"end")
1937  yunitsentry.insert(0,MathYUnits)
1938  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
1939  ycheckbt.pack(side=LEFT)
1940  sframe4c = Frame( frame4 )
1941  sframe4c.pack(side=TOP)
1942  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
1943  yaxislab.pack(side=LEFT)
1944  yaxisentry = Entry(sframe4c, width=3)
1945  yaxisentry.pack(side=LEFT)
1946  yaxisentry.delete(0,"end")
1947  yaxisentry.insert(0,MathYAxis)
1948  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
1949  yapplybt.pack(side=LEFT)
1950 
1951  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
1952  dismissbutton.grid(row=3, column=0, sticky=W)
1953 
1954  if RUNstatus.get() > 0:
1955  UpdateTimeTrace()
1956 
1958  global MathScreenStatus, MathWindow
1959 
1960  if MathScreenStatus.get() == 1:
1961  MathScreenStatus.set(0)
1962  MathWindow.destroy()
1963 
1965  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
1966  global VBuffA, VBuffB, IBuffA, IBuffB
1967  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
1968  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
1969  global FFTBuffA, FFTBuffB, FFTwindowshape
1970  global AWGAwaveform, AWGBwaveform
1971  global Show_MathX, Show_MathY
1972  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
1973  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
1974 
1975  t = 0
1976  TempString = formentry.get()
1977  try:
1978  MathResult = eval(TempString)
1979  formlab.configure(text="Formula ", style= "A10G.TLabel")
1980  except:
1981  formlab.configure(text="Formula ", style= "A10R.TLabel")
1982 
1984  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
1985  global VBuffA, VBuffB, IBuffA, IBuffB
1986  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
1987  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
1988  global FFTBuffA, FFTBuffB, FFTwindowshape
1989  global AWGAwaveform, AWGBwaveform
1990  global Show_MathX, Show_MathY
1991  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
1992  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
1993 
1994  t = 0
1995  TempString = xformentry.get()
1996  try:
1997  MathResult = eval(TempString)
1998  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
1999  except:
2000  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
2001 
2003  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
2004  global VBuffA, VBuffB, IBuffA, IBuffB
2005  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2006  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2007  global FFTBuffA, FFTBuffB, FFTwindowshape
2008  global AWGAwaveform, AWGBwaveform
2009  global Show_MathX, Show_MathY
2010  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2011  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2012 
2013  t = 0
2014  TempString = yformentry.get()
2015  try:
2016  MathResult = eval(TempString)
2017  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
2018  except:
2019  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
2020 
2022  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
2023 
2024  MathString = formentry.get()
2025  MathUnits = unitsentry.get()
2026  MathAxis = axisentry.get()
2027 
2029  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
2030 
2031  MathXString = xformentry.get()
2032  MathXUnits = xunitsentry.get()
2033  MathXAxis = xaxisentry.get()
2034 
2036  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
2037 
2038  MathYString = yformentry.get()
2039  MathYUnits = yunitsentry.get()
2040  MathYAxis = yaxisentry.get()
2041 
2043  global MarkerLoc
2044 
2045  TempString = MarkerLoc
2046  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
2047  if (MarkerLoc == None): # If Cancel pressed, then None
2048  MarkerLoc = TempString
2049  UpdateTimeTrace()
2050 
2052  global RUNstatus
2053 
2054 def DoNothing(event):
2055  global RUNstatus
2056 
2058  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
2059  ShowC1_V.set(1)
2060  ShowC1_I.set(1)
2061  ShowC2_V.set(1)
2062  ShowC2_I.set(1)
2063  UpdateTimeTrace()
2064 
2066  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
2067  ShowC1_V.set(0)
2068  ShowC1_I.set(0)
2069  ShowC2_V.set(0)
2070  ShowC2_I.set(0)
2071  UpdateTimeTrace()
2072 
2074  global TgEdge
2075 
2076 # TRIGCOND trigcondRisingPositive = 0
2077 # TRIGCOND trigcondFallingNegative = 1
2078 
2080  global TgInput, TRIGGERlevel, TRIGGERentry
2081  global MaxV1, MinV1, MaxV2, MinV2
2082  global MaxI1, MinI1, MaxI2, MinI2
2083  # set new trigger level to mid point of waveform
2084  MidV1 = (MaxV1+MinV1)/2
2085  MidV2 = (MaxV2+MinV2)/2
2086  MidI1 = (MaxI1+MinI1)/2
2087  MidI2 = (MaxI2+MinI2)/2
2088  if (TgInput.get() == 0):
2089  DCString = "0.0"
2090  elif (TgInput.get() == 1 ):
2091  DCString = ' {0:.2f} '.format(MidV1)
2092  elif (TgInput.get() == 2 ):
2093  DCString = ' {0:.2f} '.format(MidI1)
2094  elif (TgInput.get() == 3 ):
2095  DCString = ' {0:.2f} '.format(MidV2)
2096  elif (TgInput.get() == 4 ):
2097  DCString = ' {0:.2f} '.format(MidI2)
2098 
2099  TRIGGERlevel = eval(DCString)
2100  TRIGGERentry.delete(0,END)
2101  TRIGGERentry.insert(4, DCString)
2102 
2103  UpdateTimeTrace() # Always Update
2104 
2106  global TgInput
2107 
2108 # if (TgInput.get() == 0):
2109  # no trigger
2110 # elif (TgInput.get() == 1):
2111  # trigger source set to detector of analog in channels
2112  # auto trigger timeout value
2113 # elif (TgInput.get() == 2):
2114  # trigger source set to detector of analog in channels
2115  # 0 disables auto trigger
2116 
2117 def BTriglevel(event):
2118  global TRIGGERlevel, TRIGGERentry
2119 
2120  # evalute entry string to a numerical value
2121  try:
2122  TRIGGERlevel = float(eval(TRIGGERentry.get()))
2123  except:
2124  TRIGGERentry.delete(0,END)
2125  TRIGGERentry.insert(0, TRIGGERlevel)
2126  # set new trigger level
2127 
2128  UpdateTimeTrace() # Always Update
2129 
2130 def BHoldOff(event):
2131  global HoldOff, HoldOffentry
2132 
2133  try:
2134  HoldOff = float(eval(HoldOffentry.get()))
2135  except:
2136  HoldOffentry.delete(0,END)
2137  HoldOffentry.insert(0, HoldOff)
2138 # Set Horx possition from entry widget
2139 def BHozPoss(event):
2140  global HozPoss, HozPossentry
2141 
2142  try:
2143  HozPoss = float(eval(HozPossentry.get()))
2144  except:
2145  HozPossentry.delete(0,END)
2146  HozPossentry.insert(0, HozPoss)
2147 #
2149  global HozPossentry, TgInput, TMsb
2150 
2151  # get time scale
2152  try:
2153  TIMEdiv = float(eval(TMsb.get()))
2154  except:
2155  TIMEdiv = 0.5
2156  TMsb.delete(0,"end")
2157  TMsb.insert(0,TIMEdiv)
2158  # prevent divide by zero error
2159  if TIMEdiv < 0.0002:
2160  TIMEdiv = 0.01
2161  if TgInput.get() > 0:
2162  HozPoss = -5 * TIMEdiv
2163  HozPossentry.delete(0,END)
2164  HozPossentry.insert(0, HozPoss)
2165 #
2167  global HoldOffentry, HoldOff, TgInput, TMsb
2168 
2169 # get time scale
2170  try:
2171  TIMEdiv = float(eval(TMsb.get()))
2172  except:
2173  TIMEdiv = 0.5
2174  TMsb.delete(0,"end")
2175  TMsb.insert(0,TIMEdiv)
2176  # prevent divide by zero error
2177  if TIMEdiv < 0.0002:
2178  TIMEdiv = 0.01
2179  if TgInput.get() == 0:
2180  HoldOff = HoldOff + TIMEdiv
2181  HoldOffentry.delete(0,END)
2182  HoldOffentry.insert(0, HoldOff)
2183 
2185  global CHB_APosEntry, DCVMuxA
2186 
2187  CHB_APosEntry.delete(0,"end")
2188  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
2189 #
2191  global CHB_BPosEntry, DCVMuxB
2192 
2193  CHB_BPosEntry.delete(0,"end")
2194  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
2195 #
2197  global CHB_CPosEntry, DCVMuxC
2198 
2199  CHB_CPosEntry.delete(0,"end")
2200  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
2201 #
2203  global CHD_BPosEntry, DCVMuxD
2204 
2205  CHB_DPosEntry.delete(0,"end")
2206  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
2207 #
2209  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2210 
2211  if MarkerScale.get() != 1:
2212  MarkerScale.set(5)
2213  CHB_Alab.config(style="Rtrace2.TButton")
2214  CHB_Blab.config(style="Strace6.TButton")
2215  CHB_Clab.config(style="Strace7.TButton")
2216  CHB_Dlab.config(style="Strace4.TButton")
2217  else:
2218  MarkerScale.set(0)
2219 #
2221  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2222 
2223  if MarkerScale.get() != 1:
2224  MarkerScale.set(6)
2225  CHB_Alab.config(style="Strace2.TButton")
2226  CHB_Blab.config(style="Rtrace6.TButton")
2227  CHB_Clab.config(style="Strace7.TButton")
2228  CHB_Dlab.config(style="Strace4.TButton")
2229  else:
2230  MarkerScale.set(0)
2231 #
2233  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2234 
2235  if MarkerScale.get() != 1:
2236  MarkerScale.set(7)
2237  CHB_Alab.config(style="Strace2.TButton")
2238  CHB_Blab.config(style="Strace6.TButton")
2239  CHB_Clab.config(style="Rtrace7.TButton")
2240  CHB_Dlab.config(style="Strace4.TButton")
2241  else:
2242  MarkerScale.set(0)
2243 #
2245  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2246 
2247  if MarkerScale.get() != 1:
2248  MarkerScale.set(8)
2249  CHB_Alab.config(style="Strace2.TButton")
2250  CHB_Blab.config(style="Strace6.TButton")
2251  CHB_Clab.config(style="Strace7.TButton")
2252  CHB_Dlab.config(style="Rtrace4.TButton")
2253  else:
2254  MarkerScale.set(0)
2255 #
2257  global CHAVPosEntry, DCV1
2258 
2259  CHAVPosEntry.delete(0,"end")
2260  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
2261 #
2263  global CHBVPosEntry, DCV2
2264 
2265  CHBVPosEntry.delete(0,"end")
2266  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
2267 #
2269  global CHAIPosEntry, DCI1
2270 
2271  CHAIPosEntry.delete(0,"end")
2272  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
2273 #
2275  global CHBIPosEntry, DCI2
2276 
2277  CHBIPosEntry.delete(0,"end")
2278  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
2279 #
2281  global CHAVPosEntryxy, DCV1
2282 
2283  CHAVPosEntryxy.delete(0,"end")
2284  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
2285 #
2287  global CHBVPosEntryxy, DCV2
2288 
2289  CHBVPosEntryxy.delete(0,"end")
2290  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
2291 #
2293  global CHAIPosEntryxy, DCI1
2294 
2295  CHAIPosEntryxy.delete(0,"end")
2296  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
2297 #
2299  global CHBIPosEntryxy, DCI2
2300 
2301  CHBIPosEntryxy.delete(0,"end")
2302  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
2303 
2305  global RUNstatus, session, CHA, CHB, devx, AWG_2X
2306 
2307  RUNstatus.set(0)
2308  # BSaveConfig("alice-last-config.cfg")
2309  try:
2310  # try to write last config file
2311  BSaveConfig("alice-last-config.cfg")
2312  # Put channels in Hi-Z and exit
2313  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2314  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2315  devx.set_adc_mux(0) # set ADC mux conf to default
2316  AWG_2X.set(0)
2317  BAWG2X()
2318  CHA.constant(0.0)
2319  CHB.constant(0.0)
2320  if session.continuous:
2321  session.end()
2322  except:
2323  donothing()
2324 
2325  root.destroy()
2326  exit()
2327 
2328 def BStart():
2329  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
2330  global contloop, discontloop, TIMEdiv, First_Slow_sweep
2331 
2332  if DevID == "No Device":
2333  showwarning("WARNING","No Device Plugged In!")
2334  elif FWRevOne == 0.0:
2335  showwarning("WARNING","Out of data Firmware!")
2336  else:
2337  if PowerStatus == 0:
2338  PowerStatus = 1
2339  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2340  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2341  if (RUNstatus.get() == 0):
2342  RUNstatus.set(1)
2343  if AWGSync.get() == 0:
2344  session.flush()
2345  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2346  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2347  BAWGEnab()
2348  if not session.continuous:
2349  session.start(0)
2350  time.sleep(0.02) # wait awhile here for some reason
2351  elif session.continuous:
2352  session.end()
2353  session.flush()
2354  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2355  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2356 
2368  BAWGEnab()
2369  else:
2370  contloop = 0
2371  discontloop = 1
2372  if session.continuous:
2373  session.end() # end continuous session mode
2374 
2375  # UpdateTimeScreen() # Always Update
2376  if TIMEdiv >= 100:
2377  First_Slow_sweep = 0
2378  else:
2379  First_Slow_sweep = 1
2380 #$ Start running Ohmmeter tool
2382  global session, AWGSync
2383 
2384  AWGSync.set(1)
2385  if AWGSync.get() == 0:
2386  session.flush()
2387  if not session.continuous:
2388  session.start(0)
2389  time.sleep(0.02) # wait awhile here for some reason
2390  elif session.continuous:
2391  session.end()
2392  session.flush()
2393  else:
2394  contloop = 0
2395  discontloop = 1
2396  if session.continuous:
2397  session.end() # end continuous session mode
2398 
2399 def BStartIA():
2400  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne
2401 
2402  try:
2403  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
2404  except:
2405  AWGAFreqEntry.delete(0,"end")
2406  AWGAFreqEntry.insert(0, AWGAFreqvalue)
2407  if FWRevOne > 2.16:
2408  if AWGAFreqvalue > 20000.0:
2409  Two_X_Sample.set(1)
2410  else:
2411  Two_X_Sample.set(0)
2412  SetADC_Mux()
2413  IASourceSet()
2414  BStart()
2415 
2417  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode
2418 
2419  if IASource.get() == 1:
2420  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
2421  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
2422  AWGAMode.set(2) # Set AWG A to Hi-Z
2423  else:
2424  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
2425  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
2426  AWGAMode.set(0) # Set AWG A to SVMI
2427  if AWGBIOMode.get() == 0: # if not in split I/O mode
2428  AWGBMode.set(2) # Set AWG B to Hi-Z
2429 
2430 def BStop():
2431  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
2432  global CHA, CHB, contloop, discontloop
2433 
2434  if (RUNstatus.get() == 1):
2435  # print("Stoping")
2436  RUNstatus.set(0)
2437  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2438  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2439  if AWGSync.get() == 0: # running in continuous mode
2440  CHA.constant(0.0)
2441  CHB.constant(0.0)
2442  # print("Stoping continuous mode")
2443  # session.cancel() # cancel continuous session mode while paused
2444  if session.continuous:
2445  #print( "Is Continuous? ", session.continuous)
2446  session.end()
2447  #time.sleep(0.02)
2448  #print( "Is Continuous? ", session.continuous)
2449  else:
2450  contloop = 0
2451  discontloop = 1
2452  session.cancel()
2453 #
2454  if TimeDisp.get() > 0:
2455  UpdateTimeScreen() # Always Update screens as necessary
2456  if XYDisp.get() > 0:
2457  UpdateXYScreen()
2458  if FreqDisp.get() > 0:
2460  if IADisp.get() > 0:
2461  UpdateIAScreen()
2462 
2463 def BPower():
2464  global RUNstatus, PowerStatus, devx, PwrBt
2465 
2466  if (RUNstatus.get() == 1):
2467  BStop()
2468  if PowerStatus == 1:
2469  PowerStatus = 0
2470  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
2471  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
2472  else:
2473  PowerStatus = 1
2474  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2475  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2476 
2477 def BTime():
2478  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne
2479 
2480  try: # get time scale in mSec/div
2481  TIMEdiv = float(eval(TMsb.get()))
2482  if TIMEdiv < 0.0002:
2483  TIMEdiv = 0.01
2484  TMsb.delete(0,"end")
2485  TMsb.insert(0,TIMEdiv)
2486  except:
2487  TIMEdiv = 0.5
2488  TMsb.delete(0,"end")
2489  TMsb.insert(0,TIMEdiv)
2490  # Switch to 2X sampleling if time scale small enough and not runing ETS
2491  if ETSDisp.get() == 0:
2492  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
2493  if FWRevOne > 2.16:
2494  if Samples_per_div < 20.0:
2495  Two_X_Sample.set(1)
2496  else:
2497  Two_X_Sample.set(0)
2498  SetADC_Mux()
2499  #
2500  if RUNstatus.get() == 2: # Restart if running
2501  RUNstatus.set(4)
2502 
2503  UpdateTimeTrace() # Always Update
2504 
2506  global CHAsb
2507 
2508  try:
2509  CH1vpdvLevel = float(eval(CHAsb.get()))
2510  except:
2511  CHAsb.delete(0,END)
2512  CHAsb.insert(0, CH1vpdvLevel)
2513  UpdateTimeTrace() # Always Update
2514 
2516  global CHAIsb
2517 
2518  try:
2519  CH1ipdvLevel = float(eval(CHAIsb.get()))
2520  except:
2521  CHAIsb.delete(0,END)
2522  CHAIsb.insert(0, CH1ipdvLevel)
2523  UpdateTimeTrace() # Always Update
2524 
2526  global CHBsb
2527 
2528  try:
2529  CH2vpdvLevel = float(eval(CHBsb.get()))
2530  except:
2531  CHBsb.delete(0,END)
2532  CHBsb.insert(0, CH2vpdvLevel)
2533  UpdateTimeTrace() # Always Update
2534 
2536  global CHBIsb
2537 
2538  try:
2539  CH2ipdvLevel = float(eval(CHBIsb.get()))
2540  except:
2541  CHBIsb.delete(0,END)
2542  CHBIsb.insert(0, CH2ipdvLevel)
2543  UpdateTimeTrace() # Always Update
2544 
2545 def BOffsetA(event):
2546  global CHAOffset, CHAVPosEntry
2547 
2548  try:
2549  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
2550  except:
2551  CHAVPosEntry.delete(0,END)
2552  CHAVPosEntry.insert(0, CHAOffset)
2553  # set new offset level
2554  UpdateTimeTrace() # Always Update
2555 
2556 def BIOffsetA(event):
2557  global CHAIOffset, CHAIPosEntry
2558 
2559  try:
2560  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
2561  except:
2562  CHAIPosEntry.delete(0,END)
2563  CHAIPosEntry.insert(0, CHAIOffset)
2564  # set new offset level
2565  UpdateTimeTrace() # Always Update
2566 
2567 def BOffsetB(event):
2568  global CHBOffset, CHBVPosEntry
2569 
2570  try:
2571  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
2572  except:
2573  CHBVPosEntry.delete(0,END)
2574  CHBVPosEntry.insert(0, CHBOffset)
2575  # set new offset level
2576  UpdateTimeTrace() # Always Update
2577 
2578 def BIOffsetB(event):
2579  global CHBIOffset, CHBIPosEntry
2580 
2581  try:
2582  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
2583  except:
2584  CHBIPosEntry.delete(0,END)
2585  CHBIPosEntry.insert(0, CHBIOffset)
2586  # set new offset level
2587  UpdateTimeTrace() # Always Update
2588 
2590  global TimeDisp, ckb1
2591  if TimeDisp.get() == 1:
2592  ckb1.config(style="Enab.TCheckbutton")
2593  else:
2594  ckb1.config(style="Disab.TCheckbutton")
2595 #
2597  global XYDisp, ckb2
2598  if XYDisp.get() == 1:
2599  ckb2.config(style="Enab.TCheckbutton")
2600  else:
2601  ckb2.config(style="Disab.TCheckbutton")
2602 #
2604  global FreqDisp, ckb3
2605  if FreqDisp.get() == 1:
2606  ckb3.config(style="Enab.TCheckbutton")
2607  else:
2608  ckb3.config(style="Disab.TCheckbutton")
2609 #
2611  global BodeDisp, ckb5, AWGSync
2612  if BodeDisp.get() == 1:
2613  AWGSync.set(1)
2614  ckb5.config(style="Enab.TCheckbutton")
2615  else:
2616  ckb5.config(style="Disab.TCheckbutton")
2617 #
2619  global IADisp, ckb4
2620  if IADisp.get() == 1:
2621  ckb4.config(style="Enab.TCheckbutton")
2622  else:
2623  ckb4.config(style="Disab.TCheckbutton")
2624 #
2626  global OhmDisp, ckb6
2627  if OhmDisp.get() == 1:
2628  ckb6.config(style="Enab.TCheckbutton")
2629  else:
2630  ckb6.config(style="Disab.TCheckbutton")
2631 #
2633  global ETSDisp, enb1
2634  if ETSDisp.get() == 1:
2635  enb1.config(style="Enab.TCheckbutton")
2636  else:
2637  try:
2638  enb1.config(style="Disab.TCheckbutton")
2639  except:
2640  donothing()
2641 # ========================= Main routine ====================================
2642 
2644  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
2645  global IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
2646  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
2647  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
2648  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
2649  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
2650  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2651  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2652  global SV1, SI1, SV2, SI2, SVA_B
2653  global FregPoint, FBins, FStep
2654  # Analog Mux channel measurement variables
2655  global TRACEresetTime, TRACEmodeTime
2656  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
2657  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
2658  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
2659  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
2660  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
2661  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
2662 
2663  while (True): # Main loop
2664  # RUNstatus = 1 : Open Acquisition
2665  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
2666  if TimeDisp.get() > 0 or XYDisp.get() > 0:
2667  if MuxScreenStatus.get() == 0:
2668  MuxChan = -1
2669  Analog_Time_In()
2670  else:
2671  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
2672  AWGAIOMode.set(1)
2673  AWGBIOMode.set(1)
2674  ShowC1_V.set(0) # force A voltage trace off
2675  ShowC2_V.set(0) # force B voltage trace off
2676  if HWRevOne == "D" :
2677  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
2678  AWGBMode.set(2)
2679  if AWGBIOMode.get() == 0: # if not in split I/O mode
2680  ShowC2_I.set(0) # no need to show CH-B current
2681  if MuxEnb.get() == 1:
2682  PIO2 = 0x51
2683  else:
2684  PIO2 = 0x50
2685  if MuxSync.get() == 0:
2686  PIO3 = 0x51
2687  PIO3x = 0x50
2688  else:
2689  PIO3 = 0x50
2690  PIO3x = 0x51
2691  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
2692  TRACEresetTime = True # Clear the memory for averaging
2693  elif TRACEmodeTime.get() == 1:
2694  if TRACEresetTime == True:
2695  TRACEresetTime = False
2696  # Save previous trace in memory for average trace
2697  VmemoryMuxA = VBuffMA
2698  VmemoryMuxB = VBuffMB
2699  VmemoryMuxC = VBuffMC
2700  ImemoryMuxD = VBuffMD
2701  if Show_CBA.get() == 1:
2702  MuxChan = 0
2703  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2704  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2705  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
2706  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
2707  time.sleep(0.002)
2708  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2709  Analog_Time_In()
2710  # Average mode 1, add difference / TRACEaverage to arrayif :
2711  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2712  try:
2713  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
2714  except:
2715  # buffer size mismatch so reset memory buffers
2716  VmemoryMuxA = VBuffMA
2717  if Show_CBB.get() == 1:
2718  MuxChan = 1
2719  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2720  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2721  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2722  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2723  time.sleep(0.002)
2724  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
2725  Analog_Time_In()
2726  # Average mode 1, add difference / TRACEaverage to arrayif :
2727  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2728  try:
2729  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
2730  except:
2731  # buffer size mismatch so reset memory buffers
2732  VmemoryMuxB = VBuffMB
2733  if Show_CBC.get() == 1:
2734  MuxChan = 2
2735  if DualMuxMode.get() == 1:
2736  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2737  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2738  else:
2739  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2740  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
2741  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2742  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2743  time.sleep(0.002)
2744  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2745  Analog_Time_In()
2746  # Average mode 1, add difference / TRACEaverage to arrayif :
2747  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2748  try:
2749  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
2750  except:
2751  # buffer size mismatch so reset memory buffers
2752  VmemoryMuxC = VBuffMC
2753  if Show_CBD.get() == 1:
2754  MuxChan = 3
2755  if DualMuxMode.get() == 1:
2756  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2757  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2758  else:
2759  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2760  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
2761  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2762  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2763  time.sleep(0.002)
2764  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2765  Analog_Time_In()
2766  # Average mode 1, add difference / TRACEaverage to arrayif :
2767  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2768  try:
2769  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
2770  except:
2771  # buffer size mismatch so reset memory buffers
2772  VmemoryMuxD = VBuffMD
2773  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:
2774  Analog_Time_In()
2775  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
2776  if IADisp.get() > 0 or BodeDisp.get() > 0:
2777  CutDC.set(1) # remove DC portion of waveform
2778  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
2779  if BodeDisp.get() > 0:
2780  if LoopNum.get() <= len(FStep):
2781  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
2782  if FregPoint < 100.0:
2783  SMPfft = 16384
2784  elif FregPoint < 500.0:
2785  SMPfft = 8192
2786  elif FregPoint < 2000.0:
2787  SMPfft = 4096
2788  else:
2789  SMPfft = 2048
2790  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
2791  SMPfft = SMPfft * 2
2792 
2793  Analog_Freq_In()
2794  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
2795  Ohm_Analog_In()
2796  root.update_idletasks()
2797  root.update()
2798 
2800  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
2801  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
2802  global AWGAIOMode, AWGBIOMode, Two_X_Sample
2803 
2804 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
2805  try:
2806  InOffA = float(eval(CHAVOffsetEntry.get()))
2807  except:
2808  CHAVOffsetEntry.delete(0,END)
2809  CHAVOffsetEntry.insert(0, InOffA)
2810  try:
2811  InGainA = float(eval(CHAVGainEntry.get()))
2812  except:
2813  CHAVGainEntry.delete(0,END)
2814  CHAVGainEntry.insert(0, InGainA)
2815  try:
2816  InOffB = float(eval(CHBVOffsetEntry.get()))
2817  except:
2818  CHBVOffsetEntry.delete(0,END)
2819  CHBVOffsetEntry.insert(0, InOffB)
2820  try:
2821  InGainB = float(eval(CHBVGainEntry.get()))
2822  except:
2823  CHBVGainEntry.delete(0,END)
2824  CHBVGainEntry.insert(0, InGainB)
2825  try:
2826  CurOffA = float(CHAIOffsetEntry.get())
2827  except:
2828  CurOffA = 0.0
2829  try:
2830  CurOffB = float(CHBIOffsetEntry.get())
2831  except:
2832  CurOffB = 0.0
2833  try:
2834  CurGainA = float(CHAIGainEntry.get())
2835  except:
2836  CurGainA = 1.0
2837  try:
2838  CurGainB = float(CHBIGainEntry.get())
2839  except:
2840  CurGainB = 1.0
2841  try:
2842  chatestv = float(eval(CHATestVEntry.get()))
2843  if chatestv > 5.0:
2844  chatestv = 5.0
2845  CHATestVEntry.delete(0,END)
2846  CHATestVEntry.insert(0, chatestv)
2847  except:
2848  CHATestVEntry.delete(0,END)
2849  CHATestVEntry.insert(0, chatestv)
2850  try:
2851  chatestr = float(eval(CHATestREntry.get()))
2852  except:
2853  CHATestREntry.delete(0,END)
2854  CHATestREntry.insert(0, chatestr)
2855  #
2856  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
2857  RIN = 1000000 # nominal ALM1000 input resistance is 1 Mohm
2858  Two_X_Sample.set(0) # make sure we are in 1V sample rate mode
2859  SetADC_Mux()
2860  # set A and B channels
2861  AWGAMode.set(0) # Set AWG A to SVMI
2862  AWGAShape.set(0) # DC
2863  AWGBMode.set(2) # Set AWG B to Hi-Z
2864  AWGAIOMode.set(0) # turn off Split I/O mode
2865  AWGBIOMode.set(0) # turn off Split I/O mode
2866  AWGAOffsetEntry.delete(0,"end")
2867  AWGAOffsetEntry.insert(0, chatestv)
2868  BAWGAModeLabel()
2869  BAWGBModeLabel() # update AWG labels
2870 
2871  if RMode.get() == 0:
2872  AWGBTerm.set(0)
2873  else:
2874  AWGBTerm.set(1)
2875  #
2876  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
2877  if discontloop > 0:
2878  session.flush()
2879  else:
2880  discontloop = 1
2881  time.sleep(0.01)
2882  BAWGEnab()
2883  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
2884  # time.sleep(1000.0/SHOWsamples)
2885  else: # running in continuous mode
2886  if session.continuous:
2887  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
2888  #
2889  # get_samples returns a list of values for voltage [0] and current [1]
2890  for index in range(200): # calculate average
2891  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
2892  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
2893  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
2894  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
2895 
2896  DCVA0 = DCVA0 / 200.0 # calculate average
2897  DCVB0 = DCVB0 / 200.0 # calculate average
2898  DCIA0 = DCIA0 / 200.0 # calculate average
2899  DCIB0 = DCIB0 / 200.0 # calculate average
2900  DCVA0 = (DCVA0 - InOffA) * InGainA
2901  DCVB0 = (DCVB0 - InOffB) * InGainB
2902  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
2903  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
2904  if RMode.get() == 0: # external resistor
2905  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
2906  DCR = (DCM * RIN) / (RIN - DCM) # correct for channel B input resistance
2907  else: # use internal 50 ohm resistor
2908  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
2909  if DCR < 1000:
2910  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
2911  else:
2912  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
2913  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
2914  OhmA0.config(text = OhmString) # change displayed value
2915  OhmA1.config(text = IAString) # change displayed value
2916 #
2917  time.sleep(0.1)
2918  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
2919 
2922  global TIMEdiv, TMsb
2923  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
2924  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
2925  global InOffA, InGainA, InOffB, InGainB
2926  global CurOffA, CurOffB, CurGainA, CurGainB
2927 
2928  # get time scale
2929  try:
2930  TIMEdiv = eval(TMsb.get())
2931  except:
2932  TIMEdiv = 0.5
2933  TMsb.delete(0,"end")
2934  TMsb.insert(0,TIMEdiv)
2935  if TIMEdiv < 0.0002:
2936  TIMEdiv = 0.01
2937  #
2938 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
2939  try:
2940  InOffA = float(eval(CHAVOffsetEntry.get()))
2941  except:
2942  CHAVOffsetEntry.delete(0,END)
2943  CHAVOffsetEntry.insert(0, InOffA)
2944  try:
2945  InGainA = float(eval(CHAVGainEntry.get()))
2946  except:
2947  CHAVGainEntry.delete(0,END)
2948  CHAVGainEntry.insert(0, InGainA)
2949  try:
2950  InOffB = float(eval(CHBVOffsetEntry.get()))
2951  except:
2952  CHBVOffsetEntry.delete(0,END)
2953  CHBVOffsetEntry.insert(0, InOffB)
2954  try:
2955  InGainB = float(eval(CHBVGainEntry.get()))
2956  except:
2957  CHBVGainEntry.delete(0,END)
2958  CHBVGainEntry.insert(0, InGainB)
2959  try:
2960  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
2961  except:
2962  CurOffA = 0.0
2963  try:
2964  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
2965  except:
2966  CurOffB = 0.0
2967  try:
2968  CurGainA = float(CHAIGainEntry.get())
2969  except:
2970  CurGainA = 1.0
2971  try:
2972  CurGainB = float(CHBIGainEntry.get())
2973  except:
2974  CurGainB = 1.0
2975 # Dedecide which Fast or Slow sweep routine to call
2976  if TIMEdiv > 500:
2978  else:
2980 
2983  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
2984  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2985  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
2986  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
2987  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
2988  global CHA, CHB, session, devx, discontloop, contloop
2989  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, ShiftPointer
2990  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
2991  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered
2992  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
2993  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
2994  global SCREENrefresh, DCrefresh
2995  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2996  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2997  global SV1, SI1, SV2, SI2, SVA_B
2998  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2999  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
3000  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
3001  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
3002  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
3003  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3004  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3005  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3006  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3007  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
3008  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
3009  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
3010  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
3011  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
3012  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
3013  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3014  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3015  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3016  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3017  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3018  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3019 
3020  # Starting acquisition
3021  DCVA0 = DCVB0 = DCIA0 = DCIB0= 0.0 # initalize measurment variable
3022  #
3023  NumSamples = 1 # int(SAMPLErate/TIMEdiv)
3024  if First_Slow_sweep == 0:
3025  BufferLen = TIMEdiv*12.0
3026  VBuffA = numpy.ones(BufferLen)
3027  VBuffB = numpy.ones(BufferLen)
3028  IBuffA = numpy.ones(BufferLen)
3029  IBuffB = numpy.ones(BufferLen)
3030  First_Slow_sweep = 1
3031  #
3032  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3033  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3034  if discontloop > 0:
3035  session.flush()
3036  else:
3037  discontloop = 1
3038  BAWGEnab()
3039  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
3040  # waite to finish then return to open termination
3041  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3042  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3043  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3044  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3045 
3046  else: # running in continuous mode
3047  if session.continuous:
3048  if MuxScreenStatus.get() > 0:
3049  devx.flush(-1, True)
3050  DummySamples = NumSamples*2
3051  if DummySamples < 10000:
3052  DummySamples = 10000
3053  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
3054  ADsignal1 = devx.read(NumSamples, -1, True) # get samples for both channel A and B
3055  #
3056  else:
3057  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
3058 
3059  # get_samples returns a list of values for voltage [0] and current [1]
3060  for index in range(NumSamples): # calculate average
3061  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
3062  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
3063  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
3064  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
3065  DCVA0 = DCVA0/(NumSamples) # calculate V average
3066  DCVB0 = DCVB0/(NumSamples) # calculate V average
3067  DCVA0 = (DCVA0 - InOffA) * InGainA
3068  DCVB0 = (DCVB0 - InOffB) * InGainB
3069  DCIA0 = DCIA0/(NumSamples) # calculate I average
3070  DCIB0 = DCIB0/(NumSamples) # calculate I average
3071  DCIA0 = DCIA0 * 1000 # convert to mA
3072  DCIB0 = DCIB0 * 1000 # convert to mA
3073  DCIA0 = (DCIA0 - CurOffA) * CurGainA
3074  DCIB0 = (DCIB0 - CurOffB) * CurGainB
3075 # Shift in next new sample
3076  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
3077  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
3078  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
3079  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
3080 # Calculate measurement values
3081  DCV1 = numpy.mean(VBuffA)
3082  DCV2 = numpy.mean(VBuffB)
3083  DCI1 = numpy.mean(IBuffA)
3084  DCI2 = numpy.mean(IBuffB)
3085 # find min and max values
3086  MinV1 = numpy.amin(VBuffA)
3087  MaxV1 = numpy.amax(VBuffA)
3088  MinV2 = numpy.amin(VBuffB)
3089  MaxV2 = numpy.amax(VBuffB)
3090  MinI1 = numpy.amin(IBuffA)
3091  MaxI1 = numpy.amax(IBuffA)
3092  MinI2 = numpy.amin(IBuffB)
3093  MaxI2 = numpy.amax(IBuffB)
3094 # RMS value = square root of average of the data record squared
3095  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA)))
3096  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA)))
3097  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB)))
3098  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB)))
3099  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA-VBuffB)))
3100 #
3101  if TimeDisp.get() > 0:
3102  UpdateTimeAll() # Update Data, trace and time screen
3103  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3104  UpdateXYAll() # Update Data, trace and XY screen
3105  if MeasureStatus.get() > 0:
3107  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
3108  if RUNstatus.get() == 3:
3109  RUNstatus.set(0)
3110  if RUNstatus.get() == 4:
3111  RUNstatus.set(1)
3112  if TimeDisp.get() > 0:
3114  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3115  UpdateXYScreen()
3116  # update screens
3117 
3120  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
3121  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3122  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
3123  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
3124  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
3125  global CHA, CHB, session, devx, discontloop, contloop, DeBugMode
3126  global TRACES, TRACESread, TRACEsize
3127  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
3128  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, Trigger_LPF_length, LPFTrigger
3129  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
3130  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
3131  global SCREENrefresh, DCrefresh, ETSrecord
3132  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3133  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3134  global SV1, SI1, SV2, SI2, SVA_B
3135  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3136  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
3137  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
3138  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
3139  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
3140  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
3141  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3142  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3143  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3144  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
3145  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
3146  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
3147  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
3148  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
3149  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
3150  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3151  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3152  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3153  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3154  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3155  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3156 
3157  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3158  TRACEresetTime = True # Clear the memory for averaging
3159  elif TRACEmodeTime.get() == 1:
3160  if TRACEresetTime == True:
3161  TRACEresetTime = False
3162  # Save previous trace in memory for average trace
3163  VmemoryA = VBuffA
3164  VmemoryB = VBuffB
3165  ImemoryA = IBuffA
3166  ImemoryB = IBuffB
3167 
3168  try:
3169  HoldOff = float(eval(HoldOffentry.get()))
3170  if HoldOff < 0:
3171  HoldOff = 0
3172  HoldOffentry.delete(0,END)
3173  HoldOffentry.insert(0, HoldOff)
3174  except:
3175  HoldOffentry.delete(0,END)
3176  HoldOffentry.insert(0, HoldOff)
3177 #
3178  try:
3179  HozPoss = float(eval(HozPossentry.get()))
3180  except:
3181  HozPossentry.delete(0,END)
3182  HozPossentry.insert(0, HozPoss)
3183 
3184  hldn = int(HoldOff * SAMPLErate/1000 )
3185  hozpos = int(HozPoss * SAMPLErate/1000 )
3186  if hozpos < 0:
3187  hozpos = 0
3188  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
3189  onescreen = int(twoscreens/2)
3190  if hldn+hozpos > MaxSamples-twoscreens:
3191  hldn = MaxSamples-twoscreens-hozpos
3192  HoldOffentry.delete(0,END)
3193  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
3194  if ETSDisp.get() > 0:
3195  if TIMEdiv > 0.2:
3196  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
3197  else:
3198  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
3199  if (MaxETSrecord*100) > MaxSamples:
3200  MaxETSrecord = MaxSamples / 100
3201  try:
3202  DivX = float(eval(DivXEntry.get()))
3203  if DivX < 2:
3204  DivX = 2
3205  if DivX > 75:
3206  DivX = 75
3207  DivXEntry.delete(0,END)
3208  DivXEntry.insert(0, DivX)
3209  except:
3210  DivXEntry.delete(0,END)
3211  DivXEntry.insert(0, DivX)
3212  FOff = 25
3213  MulX = (DivX*SAMPLErate)/(100*FOff)
3214  while MulX > MaxETSrecord:
3215  FOff = FOff + 5
3216  MulX = (DivX*SAMPLErate)/(100*FOff)
3217  FOff = 0 - FOff
3218  if DeBugMode > 0:
3219  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
3220  MulXEntry.config(text = SRstring) # change displayed value
3221  SRstring = "Offset = " + str(FOff) + " samples"
3222  FOffEntry.config(text = SRstring) # change displayed value
3223  SHOWsamples = int(MulX * 100)
3224  else:
3225  SHOWsamples = twoscreens + hldn + hozpos
3226  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
3227  SHOWsamples = MaxSamples
3228  if SHOWsamples < MinSamples: # or a Min of 1000 samples
3229  SHOWsamples = MinSamples
3230  if hozpos >= 0:
3231  TRIGGERsample = hldn
3232  else:
3233  TRIGGERsample = abs(hozpos)
3234  TRIGGERsample = TRIGGERsample + hozpos #
3235 # Starting acquisition
3236  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3237  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3238  if discontloop > 0:
3239  session.flush()
3240  else:
3241  discontloop = 1
3242  time.sleep(0.01)
3243  BAWGEnab()
3244  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3245  # waite to finish then return to open termination
3246  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3247  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3248  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3249  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3250  else: # running in continuous mode
3251  if session.continuous:
3252  if MuxScreenStatus.get() > 0:
3253  devx.flush(-1, True)
3254  DummySamples = SHOWsamples*2
3255  if DummySamples < 20000:
3256  DummySamples = 20000
3257  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
3258  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
3259  #
3260  else:
3261  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
3262  # waite to finish then return to open termination
3263  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3264  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3265  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3266  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3267  #
3268  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
3269  if ADC_Mux_Mode.get() == 0: # VA and VB
3270  VBuffA = [] # Clear the V Buff array for trace A
3271  VBuffB = [] # Clear the V Buff array for trace B
3272  elif ADC_Mux_Mode.get() == 1: # IA and IB
3273  IBuffA = [] # Clear the I Buff array for trace A
3274  IBuffB = [] # Clear the I Buff array for trace B
3275  elif ADC_Mux_Mode.get() == 4: # VA and IA
3276  VBuffA = [] # Clear the V Buff array for trace A
3277  IBuffA = [] # Clear the I Buff array for trace A
3278  elif ADC_Mux_Mode.get() == 5: # VB and IB
3279  VBuffB = [] # Clear the V Buff array for trace B
3280  IBuffB = [] # Clear the I Buff array for trace B
3281  else:
3282  VBuffA = [] # Clear the V Buff array for trace A
3283  IBuffA = [] # Clear the I Buff array for trace A
3284  VBuffB = [] # Clear the V Buff array for trace B
3285  IBuffB = [] # Clear the I Buff array for trace B
3286  increment = 1
3287  # SAMPLErate = 200000 #AWGSAMPLErate
3288  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
3289  increment = 2
3290  SAMPLErate = int(AWGSAMPLErate/increment)
3291  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
3292  increment = 4
3293  SAMPLErate = int(AWGSAMPLErate/increment)
3294  index = 0
3295  if SHOWsamples != len(ADsignal1):
3296  SHOWsamples = len(ADsignal1)
3297  while index < SHOWsamples: # build arrays and decimate if needed
3298  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
3299  if ADC_Mux_Mode.get() == 0: # VA and VB
3300  VBuffA.append(ADsignal1[index][0][0])
3301  VBuffA.append(ADsignal1[index][1][1])
3302  VBuffB.append(ADsignal1[index][0][1])
3303  VBuffB.append(ADsignal1[index][1][0])
3304  if Alternate_Sweep_Mode.get() == 0:
3305  IBuffA.append(0.0) # fill as a place holder
3306  IBuffA.append(0.0) # fill as a place holder
3307  IBuffB.append(0.0) # fill as a place holder
3308  IBuffB.append(0.0) # fill as a place holder
3309  elif ADC_Mux_Mode.get() == 1: # IA and IB
3310  IBuffA.append(ADsignal1[index][0][1])
3311  IBuffA.append(ADsignal1[index][1][0])
3312  IBuffB.append(ADsignal1[index][0][0])
3313  IBuffB.append(ADsignal1[index][1][1])
3314  if Alternate_Sweep_Mode.get() == 0:
3315  VBuffA.append(0.0) # fill as a place holder
3316  VBuffA.append(0.0) # fill as a place holder
3317  VBuffB.append(0.0) # fill as a place holder
3318  VBuffB.append(0.0) # fill as a place holder
3319  elif ADC_Mux_Mode.get() == 2: # VA and IB
3320  VBuffA.append((ADsignal1[index][0][1])/1024.0)
3321  VBuffA.append((ADsignal1[index][1][0])/1024.0)
3322  #
3323  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
3324  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
3325  #
3326  if Alternate_Sweep_Mode.get() == 0:
3327  VBuffB.append(0.0) # fill as a place holder
3328  VBuffB.append(0.0) # fill as a place holder
3329  IBuffA.append(0.0) # fill as a place holder
3330  IBuffA.append(0.0) # fill as a place holder
3331  elif ADC_Mux_Mode.get() == 3: # VB and IA
3332  VBuffB.append((ADsignal1[index][0][0])/1024.0)
3333  VBuffB.append((ADsignal1[index][1][1])/1024.0)
3334  #
3335  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
3336  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
3337  #
3338  if Alternate_Sweep_Mode.get() == 0:
3339  VBuffA.append(0.0) # fill as a place holder
3340  VBuffA.append(0.0) # fill as a place holder
3341  IBuffB.append(0.0) # fill as a place holder
3342  IBuffB.append(0.0) # fill as a place holder
3343  elif ADC_Mux_Mode.get() == 4: # VA and IA
3344  VBuffA.append(ADsignal1[index][0][0])
3345  VBuffA.append(ADsignal1[index][1][1])
3346  IBuffA.append(ADsignal1[index][0][1])
3347  IBuffA.append(ADsignal1[index][1][0])
3348  if Alternate_Sweep_Mode.get() == 0:
3349  VBuffB.append(0.0) # fill as a place holder
3350  VBuffB.append(0.0) # fill as a place holder
3351  IBuffB.append(0.0) # fill as a place holder
3352  IBuffB.append(0.0) # fill as a place holder
3353  elif ADC_Mux_Mode.get() == 5: # VB and IB
3354  VBuffB.append(ADsignal1[index][0][1])
3355  VBuffB.append(ADsignal1[index][1][0])
3356  IBuffB.append(ADsignal1[index][0][0])
3357  IBuffB.append(ADsignal1[index][1][1])
3358  if Alternate_Sweep_Mode.get() == 0:
3359  VBuffA.append(0.0) # fill as a place holder
3360  VBuffA.append(0.0) # fill as a place holder
3361  IBuffA.append(0.0) # fill as a place holder
3362  IBuffA.append(0.0) # fill as a place holder
3363  else:
3364  VBuffA.append(ADsignal1[index][0][0])
3365  IBuffA.append(ADsignal1[index][0][1])
3366  VBuffB.append(ADsignal1[index][1][0])
3367  IBuffB.append(ADsignal1[index][1][1])
3368  index = index + increment
3369 #
3370  SHOWsamples = len(VBuffA)
3371  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
3372  if ADC_Mux_Mode.get() == 0: # VA and VB
3373  VBuffA = numpy.array(VBuffA)
3374  VBuffB = numpy.array(VBuffB)
3375  VBuffA = (VBuffA - InOffA) * InGainA
3376  VBuffB = (VBuffB - InOffB) * InGainB
3377  ADC_Mux_Mode.set(1) # switch mode
3378  Last_ADC_Mux_Mode = 0
3379  elif ADC_Mux_Mode.get() == 1: # IA and IB
3380  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3381  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3382  IBuffA = (IBuffA - CurOffA) * CurGainA
3383  IBuffB = (IBuffB - CurOffB) * CurGainB
3384  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
3385  elif ADC_Mux_Mode.get() == 4: # VA and IA
3386  VBuffA = numpy.array(VBuffA)
3387  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3388  IBuffA = (IBuffA - CurOffA) * CurGainA
3389  VBuffA = (VBuffA - InOffA) * InGainA
3390  ADC_Mux_Mode.set(1) # switch mode
3391  Last_ADC_Mux_Mode = 4
3392  elif ADC_Mux_Mode.get() == 5: # VB and IB
3393  VBuffB = numpy.array(VBuffB)
3394  VBuffB = (VBuffB - InOffB) * InGainB
3395  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3396  IBuffB = (IBuffB - CurOffB) * CurGainB
3397  ADC_Mux_Mode.set(1) # switch mode
3398  Last_ADC_Mux_Mode = 5
3399  SetADC_Mux()
3400  #
3401  else:
3402  VBuffA = numpy.array(VBuffA)
3403  VBuffB = numpy.array(VBuffB)
3404  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3405  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3406  VBuffA = (VBuffA - InOffA) * InGainA
3407  VBuffB = (VBuffB - InOffB) * InGainB
3408  IBuffA = (IBuffA - CurOffA) * CurGainA
3409  IBuffB = (IBuffB - CurOffB) * CurGainB
3410  TRACESread = 2
3411 # temp ETS calculations
3412  if ETSDisp.get() > 0:
3413  baseFreq = SAMPLErate/DivX
3414  #
3415  VAets = []
3416  VBets = []
3417  IAets = []
3418  IBets = []
3419  index = 0
3420  try:
3421  FMul = float(eval(FminEntry.get()))
3422  if FMul < 1:
3423  FMul = 1
3424  FMulXEntry.delete(0,END)
3425  FMulXEntry.insert(0, int(FMul))
3426  if FMul > 75:
3427  FMul = 75
3428  FMulXEntry.delete(0,END)
3429  FMulXEntry.insert(0, int(FMul))
3430  except:
3431  FMulXEntry.delete(0,END)
3432  FMulXEntry.insert(0, int(FMul))
3433  Fmin = baseFreq * FMul
3434  FminE = float(SAMPLErate + FOff)
3435  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
3436  # length of record set my Multiplcation factor
3437  tot_cycles = int((MulX*100)/Samples_Cycle)
3438  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
3439  ETSrecord = int((MulX*50)/Samples_Cycle)
3440  if tot_cycles > SHOWsamples:
3441  tot_cycles = SHOWsamples-1
3442  # now sort RT data into ETS sample buffers
3443  while index < SHOWsamples:
3444  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
3445  IndexValue = int(tot_cycles * Dpart)
3446  if IndexValue > SHOWsamples:
3447  IndexValue = SHOWsamples-1
3448  if IndexValue > tot_cycles:
3449  IndexValue = tot_cycles
3450  if ETSDir.get() == 0:
3451  VAets.append(VBuffA[IndexValue])
3452  VBets.append(VBuffB[IndexValue])
3453  IAets.append(IBuffA[IndexValue])
3454  IBets.append(IBuffB[IndexValue])
3455  else:
3456  VAets.append(VBuffA[tot_cycles-IndexValue])
3457  VBets.append(VBuffB[tot_cycles-IndexValue])
3458  IAets.append(IBuffA[tot_cycles-IndexValue])
3459  IBets.append(IBuffB[tot_cycles-IndexValue])
3460  index = index + 1
3461  SHiftFact = 5
3462  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
3463  VBuffA = VAets
3464  VBuffB = VBets
3465  IBuffA = IAets
3466  IBuffB = IBets
3467  VBuffA = numpy.array(VBuffA)
3468  VBuffB = numpy.array(VBuffB)
3469  IBuffA = numpy.array(IBuffA)
3470  IBuffB = numpy.array(IBuffB)
3471  try:
3472  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
3473  except:
3474  TimeCorrection = SHiftFact
3475  if ETSDir.get() == 0:
3476  VBuffB = numpy.roll(VBuffB, TimeCorrection)
3477  IBuffB = numpy.roll(IBuffB, TimeCorrection)
3478  else:
3479  VBuffB = numpy.roll(VBuffB, TimeCorrection)
3480  IBuffB = numpy.roll(IBuffB, TimeCorrection)
3481  SHOWsamples = twoscreens + hldn + hozpos
3482 # Check if Input channel RC high pass compensation checked
3483  if CHA_RC_HP.get() == 1 or CHAI_RC_HP.get() == 1:
3484  try:
3485  TC1A = float(cha_TC1Entry.get())
3486  if TC1A < 0:
3487  TC1A = 0
3488  cha_TC1Entry.delete(0,END)
3489  cha_TC1Entry.insert(0, TC1A)
3490  except:
3491  TC1A = CHA_TC1.get()
3492  try:
3493  TC2A = float(cha_TC2Entry.get())
3494  if TC2A < 0:
3495  TC2A = 0
3496  cha_TC2Entry.delete(0,END)
3497  cha_TC2Entry.insert(0, TC2A)
3498  except:
3499  TC2A = CHA_TC2.get()
3500  #
3501  try:
3502  Gain1A = float(cha_A1Entry.get())
3503  except:
3504  Gain1A = CHA_A1.get()
3505  try:
3506  Gain2A = float(cha_A2Entry.get())
3507  except:
3508  Gain2A = CHA_A2.get()
3509  #
3510  if len(VBuffA) > 4:
3511  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
3512  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
3513  if CHAI_RC_HP.get() == 1:
3514  IBuffA = Digital_RC_High_Pass( IBuffA, TC1A, Gain1A )
3515  #IBuffA = Digital_RC_High_Pass( IBuffA, TC2A, Gain2A )
3516  if CHB_RC_HP.get() == 1 or CHBI_RC_HP.get() == 1:
3517  try:
3518  TC1B = float(chb_TC1Entry.get())
3519  if TC1B < 0:
3520  TC1B = 0
3521  chb_TC1Entry.delete(0, END)
3522  chb_TC1Entry.insert(0, TC1B)
3523  except:
3524  TC1B = CHB_TC1.get()
3525  try:
3526  TC2B = float(chb_TC2Entry.get())
3527  if TC2B < 0:
3528  TC2B = 0
3529  chb_TC2Entry.delete(0, END)
3530  chb_TC2Entry.insert(0, TC2B)
3531  except:
3532  TC2B = CHB_TC2.get()
3533  #
3534  try:
3535  Gain1B = float(chb_A1Entry.get())
3536  except:
3537  Gain1B = CHB_A1.get()
3538  try:
3539  Gain2B = float(chb_A2Entry.get())
3540  except:
3541  Gain2B = CHB_A2.get()
3542  #
3543  if len(VBuffB) > 4:
3544  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
3545  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
3546  if CHBI_RC_HP.get() == 1:
3547  IBuffB = Digital_RC_High_Pass( IBuffB, TC1B, Gain1B )
3548  #IBuffB = Digital_RC_High_Pass( IBuffB, TC2B, Gain2B )
3549 # check if digital filter box checked
3550  if DigFiltA.get() == 1:
3551  if len(DFiltACoef) > 1:
3552  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
3553  if DigFiltB.get() == 1:
3554  if len(DFiltBCoef) > 1:
3555  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
3556 # Find trigger sample point if necessary
3557  LShift = 0
3558  if TgInput.get() == 1:
3559  FindTriggerSample(VBuffA)
3560  if TgInput.get() == 2:
3561  FindTriggerSample(IBuffA)
3562  if TgInput.get() == 3:
3563  FindTriggerSample(VBuffB)
3564  if TgInput.get() == 4:
3565  FindTriggerSample(IBuffB)
3566  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
3567  # Average mode 1, add difference / TRACEaverage to array
3568  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
3569  LShift = 0 - TRIGGERsample
3570  VBuffA = numpy.roll(VBuffA, LShift)
3571  VBuffB = numpy.roll(VBuffB, LShift)
3572  IBuffA = numpy.roll(IBuffA, LShift)
3573  IBuffB = numpy.roll(IBuffB, LShift)
3574  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
3575  try:
3576  if DualMuxMode.get() == 0 and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
3577  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
3578  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
3579  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
3580  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
3581  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
3582  except:
3583  # buffer size mismatch so reset memory buffers
3584  VmemoryA = VBuffA
3585  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
3586  VmemoryB = VBuffB
3587  ImemoryA = IBuffA
3588  ImemoryB = IBuffB
3589  if TgInput.get() == 1:
3590  ReInterploateTrigger(VBuffA)
3591  if TgInput.get() == 2:
3592  ReInterploateTrigger(IBuffA)
3593  if TgInput.get() == 3:
3594  ReInterploateTrigger(VBuffB)
3595  if TgInput.get() == 4:
3596  ReInterploateTrigger(IBuffB)
3597 # DC value = average of the data record
3598  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
3599  Endsample = hldn+onescreen # average over only one screen's worth of samples
3600  else:
3601  Endsample = SHOWsamples - 10 # average over all samples
3602  if MeasGateStatus.get() == 1:
3603  if (MeasGateRight-MeasGateLeft) > 0:
3604  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
3605  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
3606  if Endsample <= hldn:
3607  Endsample = hldn + 2
3608  DCV1 = numpy.mean(VBuffA[hldn:Endsample])
3609  DCV2 = numpy.mean(VBuffB[hldn:Endsample])
3610  # convert current values to mA
3611  DCI1 = numpy.mean(IBuffA[hldn:Endsample])
3612  DCI2 = numpy.mean(IBuffB[hldn:Endsample])
3613 # find min and max values
3614  MinV1 = numpy.amin(VBuffA[hldn:Endsample])
3615  MaxV1 = numpy.amax(VBuffA[hldn:Endsample])
3616  MinV2 = numpy.amin(VBuffB[hldn:Endsample])
3617  MaxV2 = numpy.amax(VBuffB[hldn:Endsample])
3618  MinI1 = numpy.amin(IBuffA[hldn:Endsample])
3619  MaxI1 = numpy.amax(IBuffA[hldn:Endsample])
3620  MinI2 = numpy.amin(IBuffB[hldn:Endsample])
3621  MaxI2 = numpy.amax(IBuffB[hldn:Endsample])
3622 # RMS value = square root of average of the data record squared
3623  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample])))
3624  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[hldn:Endsample])))
3625  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[hldn:Endsample])))
3626  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[hldn:Endsample])))
3627  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample]-VBuffB[hldn:Endsample])))
3628 # Transfer to mux buffers as necessary
3629  if TgInput.get() > 0 and MuxChan > -1 and TRACEmodeTime.get() != 1:
3630  # if triggering left shift all arrays such that trigger point is at index 0
3631  LShift = 0 - TRIGGERsample
3632  VBuffA = numpy.roll(VBuffA, LShift)
3633  VBuffB = numpy.roll(VBuffB, LShift)
3634  IBuffA = numpy.roll(IBuffA, LShift)
3635  IBuffB = numpy.roll(IBuffB, LShift)
3636  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
3637  if MuxChan > -1:
3638  Dval0 = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
3639  Dval1 = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
3640  if Show_CBA.get() == 1 and Dval0[0] == 0 and Dval1[0] == 0:
3641  DCVMuxA = DCV2
3642  MinVMuxA = MinV2
3643  MaxVMuxA = MaxV2
3644  MidVMuxA = (MaxV2+MinV2)/2.0
3645  PPVMuxA = MaxV2-MinV2
3646  SVMuxA = SV2
3647  VBuffMA = VBuffB
3648  if Show_CBB.get() == 1 and Dval0[0] == 1 and Dval1[0] == 0:
3649  DCVMuxB = DCV2
3650  MinVMuxB = MinV2
3651  MaxVMuxB = MaxV2
3652  MidVMuxB = (MaxV2+MinV2)/2.0
3653  PPVMuxB = MaxV2-MinV2
3654  SVMuxB = SV2
3655  VBuffMB = VBuffB
3656  if Show_CBC.get() == 1 and Dval0[0] == 0 and Dval1[0] == 1:
3657  if DualMuxMode.get() == 1:
3658  DCVMuxC = DCV1
3659  MinVMuxC = MinV1
3660  MaxVMuxC = MaxV1
3661  MidVMuxC = (MaxV1+MinV1)/2.0
3662  PPVMuxC = MaxV1-MinV1
3663  SVMuxC = SV1
3664  VBuffMC = VBuffA
3665  else:
3666  DCVMuxC = DCV2
3667  MinVMuxC = MinV2
3668  MaxVMuxC = MaxV2
3669  MidVMuxC = (MaxV2+MinV2)/2.0
3670  PPVMuxC = MaxV2-MinV2
3671  SVMuxC = SV2
3672  VBuffMC = VBuffB
3673  if Show_CBD.get() == 1 and Dval0[0] == 1 and Dval1[0] == 1:
3674  if DualMuxMode.get() == 1:
3675  DCVMuxD = DCV1
3676  MinVMuxD = MinV1
3677  MaxVMuxD = MaxV1
3678  MidVMuxD = (MaxV1+MinV1)/2.0
3679  PPVMuxD = MaxV1-MinV1
3680  SVMuxD = SV1
3681  VBuffMD = VBuffA
3682  else:
3683  DCVMuxD = DCV2
3684  MinVMuxD = MinV2
3685  MaxVMuxD = MaxV2
3686  MidVMuxD = (MaxV2+MinV2)/2.0
3687  PPVMuxD = MaxV2-MinV2
3688  SVMuxD = SV2
3689  VBuffMD = VBuffB
3690 #
3691  if TimeDisp.get() > 0:
3692  UpdateTimeAll() # Update Data, trace and time screen
3693  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3694  UpdateXYAll() # Update Data, trace and XY screen
3695  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
3696  BStop() #
3697  SingleShot.set(0)
3698  if ManualTrigger.get() == 1: # Manual trigger is on
3699  BStop() #
3700  if MeasureStatus.get() > 0:
3702  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
3703  if RUNstatus.get() == 3:
3704  RUNstatus.set(0)
3705  if RUNstatus.get() == 4:
3706  RUNstatus.set(1)
3707  if TimeDisp.get() > 0:
3709  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3710  UpdateXYScreen()
3711  # update screens
3712 #
3713 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
3714 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
3715 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
3716 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
3717 
3718 
3720 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
3721  global SAMPLErate
3722 
3723  OutBuff = []
3724  n = len(InBuff)
3725  Delta = 1.0/SAMPLErate
3726  TC = TC1 * 1.0E-6
3727  Alpha = TC / (TC + Delta)
3728  OutBuff.append(InBuff[1]-InBuff[0]) # set inital sample to derivative (difference of first two samples)
3729  i = 1
3730  while i < n:
3731  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
3732  i += 1
3733  OutBuff = numpy.array(OutBuff)
3734  OutBuff = InBuff + (OutBuff * Gain)
3735  return OutBuff
3736 
3738 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
3739  global SAMPLErate
3740 
3741  OutBuff = []
3742  n = len(InBuff)
3743  Delta = 1.0/SAMPLErate
3744  TC = TC1 * 1.0E-6
3745  Alpha = Delta / (TC + Delta)
3746  i = 1
3747  OutBuff.append(Alpha*InBuff[0])
3748  while i < n:
3749  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
3750  i += 1
3751  OutBuff = numpy.array(OutBuff)
3752  OutBuff = (OutBuff * Gain)
3753  return OutBuff
3754 
3758 def shift_buffer(arr, num, fill_value=numpy.nan):
3759  result = numpy.empty_like(arr)
3760  if num > 0:
3761  result[:num] = fill_value
3762  result[num:] = arr[:-num]
3763  elif num < 0:
3764  result[num:] = fill_value
3765  result[:num] = arr[-num:]
3766  else:
3767  result[:] = arr
3768  return result
3769 
3770 
3773  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
3774  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
3775  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
3776  global NSteps, LoopNum, FSweepMode, FStep, FBins
3777  global StartFreqEntry, StopFreqEntry, HoldOffentry
3778  global session, CHA, CHB, devx, MaxSamples, discontloop
3779  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
3780  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
3781  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
3782  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
3783  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
3784  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3785  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
3786  global BDSweepFile, FileSweepFreq, FileSweepAmpl
3787  global PIO_0, PIO_1, PIO_2, PIO_3
3788  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3789  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3790  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3791  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3792  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
3793 
3794  HalfSAMPLErate = SAMPLErate/2
3795  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3796  try:
3797  InOffA = float(eval(CHAVOffsetEntry.get()))
3798  except:
3799  CHAVOffsetEntry.delete(0,END)
3800  CHAVOffsetEntry.insert(0, InOffA)
3801  try:
3802  InGainA = float(eval(CHAVGainEntry.get()))
3803  except:
3804  CHAVGainEntry.delete(0,END)
3805  CHAVGainEntry.insert(0, InGainA)
3806  try:
3807  InOffB = float(eval(CHBVOffsetEntry.get()))
3808  except:
3809  CHBVOffsetEntry.delete(0,END)
3810  CHBVOffsetEntry.insert(0, InOffB)
3811  try:
3812  InGainB = float(eval(CHBVGainEntry.get()))
3813  except:
3814  CHBVGainEntry.delete(0,END)
3815  CHBVGainEntry.insert(0, InGainB)
3816  try:
3817  HoldOff = float(eval(HoldOffentry.get()))
3818  if HoldOff < 0:
3819  HoldOff = 0
3820  HoldOffentry.delete(0,END)
3821  HoldOffentry.insert(0, HoldOff)
3822  except:
3823  HoldOffentry.delete(0,END)
3824  HoldOffentry.insert(0, HoldOff)
3825  #
3826  INITIALIZEstart()
3827  # Starting acquisition This is a HACK to get around non-continous AWG mode!
3828  # restart AWGs if indicated
3829  if BodeDisp.get() == 0: # make new noise waveforms each sweep
3830  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
3831  AWGAMakeUUNoise()
3832  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
3833  AWGAMakeUGNoise()
3834  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
3835  AWGBMakeUUNoise()
3836  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
3837  AWGBMakeUGNoise()
3838  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
3839  if BDSweepFile.get() == 0:
3840  if LoopNum.get() <= len(FStep):
3841  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
3842  else:
3843  FregPoint = FBins[FStep[0]]
3844  else:
3845  if LoopNum.get() <= len(FileSweepFreq): #
3846  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
3847  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
3848  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
3849  else:
3850  FregPoint = FBins[FileSweepFreq[0]]
3851  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
3852  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
3853  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
3854  if FSweepMode.get() == 1: # set new CH-A amplitude
3855  AWGAAmplEntry.delete(0,END)
3856  AWGAAmplEntry.insert(4, VMin)
3857  AWGAOffsetEntry.delete(0,END)
3858  AWGAOffsetEntry.insert(4, VMax)
3859  if FSweepMode.get() == 2: # set new CH-B amplitude
3860  AWGBAmplEntry.delete(0,END)
3861  AWGBAmplEntry.insert(4, VMin)
3862  AWGBOffsetEntry.delete(0,END)
3863  AWGBOffsetEntry.insert(4, VMax)
3864  if FSweepMode.get() == 1: # set new CH-A frequency
3865  AWGAFreqEntry.delete(0,END)
3866  AWGAFreqEntry.insert(4, FregPoint)
3868  if FSweepMode.get() == 2: # set new CH-B frequency
3869  AWGBFreqEntry.delete(0,END)
3870  AWGBFreqEntry.insert(4, FregPoint)
3872  if FSweepMode.get() == 3: # set new MiniGen frequency
3873  MinigenFout.delete(0,END)
3874  MinigenFout.insert(4, FregPoint)
3875  BSendMG()
3876  if AWGSync.get() > 0:
3877  if IAScreenStatus.get() > 0 and IASource.get() == 0:
3878  if Two_X_Sample.get() == 1:
3879  AWGBIOMode.set(1)
3880  AWGBMode.set(0)
3881  else:
3882  AWGBMode.set(2)
3883  # BAWGEnab()
3884 #
3885  hldn = int(HoldOff * 100 )
3886  if hldn > MaxSamples-SMPfft:
3887  hldn = MaxSamples-SMPfft
3888  HoldOffentry.delete(0,END)
3889  HoldOffentry.insert(0, hldn/100)
3890  if hldn < 128:
3891  hldn = 128
3892  SHOWsamples = SMPfft + hldn # get holf off extra samples
3893  if BodeDisp.get() > 0: # check if doing Bode Plot
3894  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
3895  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3896  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3897  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3898  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
3899  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3900  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3901  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3902  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
3903  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3904  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3905  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3906  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
3907  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3908  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3909  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3910  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3911  if IAScreenStatus.get() > 0 and IASource.get() == 0:
3912  if Two_X_Sample.get() == 1:
3913  AWGBIOMode.set(1)
3914  AWGBMode.set(0)
3915  else:
3916  AWGBMode.set(2)
3917  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3918  if discontloop > 0:
3919  session.flush()
3920  else:
3921  discontloop = 1
3922  BAWGEnab()
3923  try:
3924  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3925  except:
3926  donothing()
3927  # waite to finish then return to open termination
3928  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3929  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3930  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3931  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3932  else: # running in continuous mode
3933  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
3934  #
3935  else:
3936  if session.continuous:
3937  ADsignal1 = devx.read(SHOWsamples, -1, True)
3938  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3939  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3940  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3941  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3942  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3943  FFTBuffA = [] # Clear the FFTBuff array for trace A
3944  FFTBuffB = [] # Clear the FFTBuff array for trace B
3945  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
3946  index = hldn # skip first hldn samples
3947  if SHOWsamples != len(ADsignal1):
3948  SHOWsamples = len(ADsignal1)
3949  while index < SHOWsamples:
3950  if Two_X_Sample.get() == 1:
3951  if ADC_Mux_Mode.get() == 0: # VA and VB
3952  FFTBuffA.append(ADsignal1[index][0][0])
3953  FFTBuffA.append(ADsignal1[index][1][1])
3954  FFTBuffB.append(ADsignal1[index][0][1])
3955  FFTBuffB.append(ADsignal1[index][1][0])
3956  else:
3957  VAdata = ADsignal1[index][0][0]
3958  FFTBuffA.append(VAdata)
3959  VBdata = ADsignal1[index][1][0]
3960  FFTBuffB.append(VBdata)
3961  if VAdata > 5.0 or VAdata < 0.0:
3962  OverRangeFlagA = 1
3963 
3964  if VBdata > 5.0 or VBdata < 0.0:
3965  OverRangeFlagB = 1
3966  index = index + 1
3967 
3968  FFTBuffA = numpy.array(FFTBuffA)
3969  FFTBuffB = numpy.array(FFTBuffB)
3970  FFTBuffA = (FFTBuffA - InOffA) * InGainA
3971  FFTBuffB = (FFTBuffB - InOffB) * InGainB
3972  DCA = numpy.average(FFTBuffA)
3973  DCB = numpy.average(FFTBuffB)
3974  if CutDC.get() == 1:
3975  FFTBuffA = FFTBuffA - DCA
3976  FFTBuffB = FFTBuffB - DCB
3977 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3978  if CHA_RC_HP.get() == 1:
3979  try:
3980  TC1A = float(cha_TC1Entry.get())
3981  if TC1A < 0:
3982  TC1A = 0
3983  cha_TC1Entry.delete(0,END)
3984  cha_TC1Entry.insert(0, TC1A)
3985  except:
3986  TC1A = CHA_TC1.get()
3987  try:
3988  TC2A = float(cha_TC2Entry.get())
3989  if TC2A < 0:
3990  TC2A = 0
3991  cha_TC2Entry.delete(0,END)
3992  cha_TC2Entry.insert(0, TC2A)
3993  except:
3994  TC2A = CHA_TC2.get()
3995  #
3996  try:
3997  Gain1A = float(cha_A1Entry.get())
3998  except:
3999  Gain1A = CHA_A1.get()
4000  try:
4001  Gain2A = float(cha_A2Entry.get())
4002  except:
4003  Gain2A = CHA_A2.get()
4004  #
4005  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
4006  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
4007  if CHB_RC_HP.get() == 1:
4008  try:
4009  TC1B = float(chb_TC1Entry.get())
4010  if TC1B < 0:
4011  TC1B = 0
4012  chb_TC1Entry.delete(0, END)
4013  chb_TC1Entry.insert(0, TC1B)
4014  except:
4015  TC1B = CHB_TC1.get()
4016  try:
4017  TC2B = float(chb_TC2Entry.get())
4018  if TC2B < 0:
4019  TC2B = 0
4020  chb_TC2Entry.delete(0, END)
4021  chb_TC2Entry.insert(0, TC2B)
4022  except:
4023  TC2B = CHB_TC2.get()
4024  #
4025  try:
4026  Gain1B = float(chb_A1Entry.get())
4027  except:
4028  Gain1B = CHB_A1.get()
4029  try:
4030  Gain2B = float(chb_A2Entry.get())
4031  except:
4032  Gain2B = CHB_A2.get()
4033  #
4034  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
4035  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
4036 # check if digital filter box checked
4037  if DigFiltA.get() == 1:
4038  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
4039  if DigFiltB.get() == 1:
4040  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
4041  DoFFT()
4042  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
4043  UpdateFreqAll() # Update spectrum Data, trace and screen
4044  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
4045  UpdateIAAll()
4046  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
4047  UpdateBodeAll()
4048  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
4049  UpdateNqPAll()
4050  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
4051  UpdateNiCAll()
4052  if SingleShotSA.get() == 1: # Single shot sweep is on
4053  RUNstatus.set(0)
4054 # RUNstatus = 3: Stop
4055 # RUNstatus = 4: Stop and restart
4056  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
4057  if RUNstatus.get() == 3:
4058  RUNstatus.set(0) # Status is stopped
4059  if RUNstatus.get() == 4:
4060  RUNstatus.set(1) # Status is (re)start
4061  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
4062  UpdateFreqScreen() # Freq UpdateScreen() call
4063  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
4064  UpdateIAScreen()
4065  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
4066  LoopNum.set(LoopNum.get() + 1)
4067  if LoopNum.get() > NSteps.get():
4068  if FSweepMode.get() == 1:
4069  AWGAFreqEntry.delete(0,"end")
4070  AWGAFreqEntry.insert(0, Reset_Freq)
4071  if FSweepMode.get() == 2:
4072  AWGBFreqEntry.delete(0,"end")
4073  AWGBFreqEntry.insert(0, Reset_Freq)
4074 #
4075  LoopNum.set(1)
4076  if FSweepCont.get() == 0:
4077  RUNstatus.set(0)
4078 
4080  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
4081  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
4082  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
4083  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4084  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4085  global VABase, VATop, VBBase, VBTop
4086 
4087  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
4088  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
4089  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
4090  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
4091  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
4092  LowerPeak = 0
4093  UpperPeak = 0
4094  b = 0
4095  while (b < 4999):
4096  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
4097  LowerPeak = b
4098  VABase = HBuffA[1][b]
4099  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
4100  UpperPeak = b
4101  VATop = HBuffA[1][b]
4102  b = b + 1
4103  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
4104  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
4105  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
4106  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
4107  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
4108  LowerPeak = 0
4109  UpperPeak = 0
4110  b = 0
4111  while (b < 4999):
4112  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
4113  LowerPeak = b
4114  VBBase = HBuffB[1][b]
4115  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
4116  UpperPeak = b
4117  VBTop = HBuffB[1][b]
4118  b = b + 1
4119 
4121  global HistAsPercent
4122 
4123  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
4124  HistAsPercent = 1
4125  else:
4126  HistAsPercent = 0
4127 
4128 def FindRisingEdge(Trace1, Trace2):
4129  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
4130  global ETSrecord, DISsamples
4131  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
4132  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
4133  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
4134 
4135  anr1 = bnr1 = 0
4136  anf1 = bnf1 = 1
4137  anr2 = bnr2 = 2
4138  hldn = int(HoldOff * SAMPLErate/1000)
4139  # print(DISsamples, len(Trace1))
4140  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
4141  Trace1 = numpy.roll(Trace1, -LShift)
4142  Trace2 = numpy.roll(Trace2, -LShift)
4143  else:
4144  Trace1 = numpy.roll(Trace1, -hldn)
4145  Trace2 = numpy.roll(Trace2, -hldn)
4146  try:
4147  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
4148  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
4149  except:
4150  MidV1 = (MinV1+MaxV1)/2
4151  MidV2 = (MinV2+MaxV2)/2
4152 # search Trace 1
4153 
4160  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
4161  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
4162  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
4163  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
4164 
4165  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
4166  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
4167 # Catch zero length array?
4168  try:
4169  Dummy_read = Arising[0]
4170  except:
4171  return
4172  if len(Arising) > 0 or len(Afalling) > 0:
4173  if Arising[0] > 0:
4174  try:
4175  anr1 = AIrising[0]
4176  except:
4177  anr1 = 0
4178  try:
4179  anr2 = AIrising[1]
4180  except:
4181  anr2 = SHOWsamples
4182  try:
4183  if AIfalling[0] < AIrising[0]:
4184  anf1 = AIfalling[1]
4185  else:
4186  anf1 = AIfalling[0]
4187  except:
4188  anf1 = 1
4189  else:
4190  try:
4191  anr1 = AIrising[1]
4192  except:
4193  anr1 = 0
4194  try:
4195  anr2 = AIrising[2]
4196  except:
4197  anr2 = SHOWsamples
4198  try:
4199  if AIfalling[1] < AIrising[1]:
4200  anf1 = AIfalling[2]
4201  else:
4202  anf1 = AIfalling[1]
4203  except:
4204  anf1 = 1
4205 # search Trace 2
4206 
4213  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
4214  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
4215  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
4216  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
4217 
4218  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
4219  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
4220 # Catch zero length array?
4221  try:
4222  Dummy_read = Brising[0]
4223  except:
4224  return
4225  if len(Brising) > 0 or len(Bfalling) > 0:
4226  if Brising[0] > 0:
4227  try:
4228  bnr1 = BIrising[0]
4229  except:
4230  bnr1 = 0
4231  try:
4232  bnr2 = BIrising[1]
4233  except:
4234  bnr2 = SHOWsamples
4235  try:
4236  if BIfalling[0] < BIrising[0]:
4237  bnf1 = BIfalling[1]
4238  else:
4239  bnf1 = BIfalling[0]
4240  except:
4241  bnf1 = 1
4242  else:
4243  try:
4244  bnr1 = BIrising[1]
4245  except:
4246  bnr1 = 0
4247  try:
4248  bnr2 = BIrising[2]
4249  except:
4250  bnr2 = SHOWsamples
4251  try:
4252  if BIfalling[1] < BIrising[1]:
4253  bnf1 = BIfalling[2]
4254  else:
4255  bnf1 = BIfalling[1]
4256  except:
4257  bnf1 = 1
4258  #
4259  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
4260  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
4261  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
4262  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
4263  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
4264  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
4265 #
4266  if bnr1 > anr1:
4267  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
4268  else:
4269  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
4270  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
4271  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
4272  try:
4273  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
4274  except:
4275  CHABphase = 0.0
4276  if CHABphase < 0.0:
4277  CHABphase = CHABphase + 360.0
4278 
4280  global DX, TRIGGERsample, TRIGGERlevel
4281 
4282  DX = 0
4283  n = TRIGGERsample
4284  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
4285  if DY != 0.0:
4286  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
4287  else:
4288  DX = 0
4289 
4290 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
4291  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
4292  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
4293  global Trigger_LPF_length, LPFTrigger
4294 
4295  # Set the TRACEsize variable
4296  TRACEsize = SHOWsamples # Set the trace length
4297  DX = 0
4298  Is_Triggered = 0
4299  if LPFTrigger.get() > 0:
4300  TFiltCoef = [] # empty coef array
4301  for n in range(Trigger_LPF_length.get()):
4302  TFiltCoef.append(float(1.0/Trigger_LPF_length.get()))
4303  TFiltCoef = numpy.array(TFiltCoef)
4304  TrgBuff = numpy.convolve(TrgBuff, TFiltCoef)
4305 
4306  if len(TrgBuff) == 0:
4307  return
4308  try:
4309  TrgMin = numpy.amin(TrgBuff)
4310  except:
4311  TrgMin = 0.0
4312  try:
4313  TrgMax = numpy.amax(TrgBuff)
4314  except:
4315  TrgMax = 0.0
4316 # Find trigger sample
4317  try:
4318  if AutoLevel.get() == 1:
4319  TRIGGERlevel = (TrgMin + TrgMax)/2
4320  TRIGGERentry.delete(0,"end")
4321  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
4322  else:
4323  TRIGGERlevel = eval(TRIGGERentry.get())
4324  except:
4325  TRIGGERentry.delete(0,END)
4326  TRIGGERentry.insert(0, TRIGGERlevel)
4327 # Start from first sample after HoldOff
4328  try:
4329  HoldOff = float(eval(HoldOffentry.get()))
4330  if HoldOff < 0:
4331  HoldOff = 0
4332  HoldOffentry.delete(0,END)
4333  HoldOffentry.insert(0, HoldOff)
4334  except:
4335  HoldOffentry.delete(0,END)
4336  HoldOffentry.insert(0, HoldOff)
4337 # slide trace left right by HozPoss
4338  try:
4339  HozPoss = float(eval(HozPossentry.get()))
4340  except:
4341  HozPossentry.delete(0,END)
4342  HozPossentry.insert(0, HozPoss)
4343 
4344  hldn = int(HoldOff * SAMPLErate/1000)
4345  hozpos = int(HozPoss * SAMPLErate/1000)
4346  if hozpos >= 0:
4347  TRIGGERsample = hldn
4348  else:
4349  TRIGGERsample = abs(hozpos)
4350 #
4351  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
4352  DX = 0
4353  n = TRIGGERsample
4354  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
4355  if TRIGGERlevel2 < TrgMin:
4356  TRIGGERlevel2 = TrgMin
4357  if TRIGGERlevel2 > TrgMax:
4358  TRIGGERlevel2 = TrgMax
4359  ChInput = TrgBuff[int(n)]
4360  Prev = ChInput
4361  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
4362  n = n + 1
4363  ChInput = TrgBuff[int(n)]
4364  while (ChInput <= TRIGGERlevel) and n < Nmax:
4365  Prev = ChInput
4366  n = n + 1
4367  ChInput = TrgBuff[int(n)]
4368  DY = ChInput - Prev
4369  if DY != 0.0:
4370  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
4371  else:
4372  DX = 0
4373  if TgEdge.get() == 1:
4374  TRIGGERlevel2 = 1.01 * TRIGGERlevel
4375  if TRIGGERlevel2 < TrgMin:
4376  TRIGGERlevel2 = TrgMin
4377  if TRIGGERlevel2 > TrgMax:
4378  TRIGGERlevel2 = TrgMax
4379  ChInput = TrgBuff[int(n)]
4380  Prev = ChInput
4381  while (ChInput <= TRIGGERlevel2) and n < Nmax:
4382  n = n + 1
4383  ChInput = TrgBuff[int(n)]
4384  while (ChInput >= TRIGGERlevel) and n < Nmax:
4385  Prev = ChInput
4386  n = n + 1
4387  ChInput = TrgBuff[int(n)]
4388  DY = Prev - ChInput
4389  try:
4390  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
4391  except:
4392  DX = 0
4393 
4394 # check to insure trigger point is in bounds
4395  if n < Nmax:
4396  TRIGGERsample = n - 1
4397  Is_Triggered = 1
4398  elif n > Nmax: # Didn't find edge in first 2/3 of data set
4399  TRIGGERsample = 1 + hldn # reset to begining
4400  Is_Triggered = 0
4401  if DX > 1:
4402  DX = 1 # never more than 100% of a sample period
4403  elif DX < 0:
4404  DX = 0 # never less than 0% of a sample period
4405  if math.isnan(DX):
4406  DX = 0
4407  TRIGGERsample = TRIGGERsample + hozpos
4408 
4410  global win2, DigScreenStatus
4411 
4412  DigScreenStatus.set(0)
4413  win2.destroy()
4414 
4415 def sel():
4416  global devx, DevID
4417  global D0, D1, D2, D3, D4, D5, D6, D7
4418  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4419  # sending 0x50 = set to 0, 0x51 = set to 1
4420  if D0.get() > 0:
4421  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
4422  else:
4423  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
4424  if D1.get() > 0:
4425  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
4426  else:
4427  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
4428  if D2.get() > 0:
4429  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
4430  else:
4431  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
4432  if D3.get() > 0:
4433  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
4434  else:
4435  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
4436  if D4.get() > 0:
4437  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
4438  else:
4439  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
4440  if D5.get() > 0:
4441  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
4442  else:
4443  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
4444  if D6.get() > 0:
4445  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
4446  else:
4447  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
4448  if D7.get() > 0:
4449  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
4450  else:
4451  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
4452 
4454  global D0, D1, D2, D3, D4, D5, D6, D7
4455  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4456  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
4457  # setup Dig output window
4458  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
4459  DigScreenStatus.set(1)
4460  win2 = Toplevel()
4461  win2.title("Dig Out")
4462  win2.resizable(FALSE,FALSE)
4463  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
4464  rb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
4465  rb1.grid(row=2, column=0, sticky=W)
4466  rb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
4467  rb0z.grid(row=2, column=1, sticky=W)
4468  rb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
4469  rb2.grid(row=2, column=2, sticky=W)
4470  rb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
4471  rb3.grid(row=3, column=0, sticky=W)
4472  rb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
4473  rb3z.grid(row=3, column=1, sticky=W)
4474  rb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
4475  rb4.grid(row=3, column=2, sticky=W)
4476  rb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
4477  rb5.grid(row=4, column=0, sticky=W)
4478  rb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
4479  rb5z.grid(row=4, column=1, sticky=W)
4480  rb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
4481  rb6.grid(row=4, column=2, sticky=W)
4482  rb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
4483  rb7.grid(row=5, column=0, sticky=W)
4484  rb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
4485  rb7z.grid(row=5, column=1, sticky=W)
4486  rb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
4487  rb8.grid(row=5, column=2, sticky=W)
4488  rb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
4489  rb9.grid(row=6, column=0, sticky=W)
4490  rb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
4491  rb9z.grid(row=6, column=1, sticky=W)
4492  rb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
4493  rb10.grid(row=6, column=2, sticky=W)
4494  rb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
4495  rb11.grid(row=7, column=0, sticky=W)
4496  rb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
4497  rb11z.grid(row=7, column=1, sticky=W)
4498  rb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
4499  rb12.grid(row=7, column=2, sticky=W)
4500  rb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
4501  rb13.grid(row=8, column=0, sticky=W)
4502  rb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
4503  rb13z.grid(row=8, column=1, sticky=W)
4504  rb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
4505  rb13.grid(row=8, column=2, sticky=W)
4506  rb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
4507  rb14.grid(row=9, column=0, sticky=W)
4508  rb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
4509  rb14z.grid(row=9, column=1, sticky=W)
4510  rb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
4511  rb15.grid(row=9, column=2, sticky=W)
4512 
4513  dismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
4514  dismissbutton.grid(row=10, column=0, sticky=W)
4515 
4517  global win1, DacScreenStatus
4518 
4519  DacScreenStatus.set(0)
4520  win1.destroy()
4521 
4522 def sel0(temp):
4523  global devx, DevID
4524  global PIO_0, PIO_4
4525  global DAC0
4526  # sending 0x50 = set to 0, 0x51 = set to 1
4527  if DAC0.get() == 1:
4528  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4529  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
4530  elif DAC0.get() == 4:
4531  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4532  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
4533  elif DAC0.get() == 2:
4534  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4535  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4536  elif DAC0.get() == 3:
4537  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
4538  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
4539  elif DAC0.get() == 5:
4540  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
4541  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4542  elif DAC0.get() == 7:
4543  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
4544  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
4545  elif DAC0.get() == 8:
4546  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
4547  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4548  elif DAC0.get() == 6:
4549  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
4550  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
4551  elif DAC0.get() == 9:
4552  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
4553  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
4554 
4555 def sel1(temp):
4556  global devx, DevID
4557  global PIO_1, PIO_5
4558  global DAC1
4559  # sending 0x50 = set to 0, 0x51 = set to 1
4560  if DAC1.get() == 1:
4561  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4562  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
4563  elif DAC1.get() == 4:
4564  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4565  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
4566  elif DAC1.get() == 2:
4567  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4568  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4569  elif DAC1.get() == 3:
4570  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4571  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
4572  elif DAC1.get() == 5:
4573  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4574  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4575  elif DAC1.get() == 7:
4576  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4577  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
4578  elif DAC1.get() == 8:
4579  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
4580  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4581  elif DAC1.get() == 6:
4582  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
4583  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
4584  elif DAC1.get() == 9:
4585  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
4586  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
4587 
4588 def sel2(temp):
4589  global devx, DevID
4590  global PIO_2, PIO_6
4591  global DAC2
4592  # sending 0x50 = set to 0, 0x51 = set to 1
4593  if DAC2.get() == 1:
4594  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4595  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
4596  elif DAC2.get() == 4:
4597  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4598  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
4599  elif DAC2.get() == 2:
4600  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4601  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4602  elif DAC2.get() == 3:
4603  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4604  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
4605  elif DAC2.get() == 5:
4606  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4607  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4608  elif DAC2.get() == 7:
4609  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4610  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
4611  elif DAC2.get() == 8:
4612  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
4613  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4614  elif DAC2.get() == 6:
4615  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
4616  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
4617  elif DAC2.get() == 9:
4618  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
4619  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
4620 
4621 def sel3(temp):
4622  global devx, DevID
4623  global PIO_3, PIO_7
4624  global DAC3
4625  # sending 0x50 = set to 0, 0x51 = set to 1
4626  if DAC3.get() == 1:
4627  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4628  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
4629  elif DAC3.get() == 4:
4630  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4631  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
4632  elif DAC3.get() == 2:
4633  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4634  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4635  elif DAC3.get() == 3:
4636  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4637  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
4638  elif DAC3.get() == 5:
4639  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4640  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4641  elif DAC3.get() == 7:
4642  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4643  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
4644  elif DAC3.get() == 8:
4645  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
4646  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4647  elif DAC3.get() == 6:
4648  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
4649  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
4650  elif DAC3.get() == 9:
4651  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
4652  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
4653 
4655  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
4656  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
4657  # setup Dig output window
4658  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
4659  DacScreenStatus.set(1)
4660  win1 = Toplevel()
4661  win1.title("DAC Out "+ SWRev + RevDate)
4662  win1.resizable(FALSE,FALSE)
4663  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
4664  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
4665  DAC0.grid(row=0, column=0, sticky=W)
4666  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
4667  DAC1.grid(row=0, column=1, sticky=W)
4668  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
4669  DAC2.grid(row=0, column=2, sticky=W)
4670  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
4671  DAC3.grid(row=0, column=3, sticky=W)
4672 
4673  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
4674  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
4675 
4677 
4678  MakeTimeTrace() # Update the traces
4679  UpdateTimeScreen() # Update the screen
4680 
4682 
4683  MakeTimeTrace() # Update traces
4684  UpdateTimeScreen() # Update the screen
4685 
4687 
4688  MakeTimeScreen() # Update the screen
4689  root.update() # Activate updated screens
4690 
4692 
4693  MakeXYTrace() # Update the traces
4694  UpdateXYScreen() # Update the screen
4695 
4697 
4698  MakeXYTrace() # Update traces
4699  UpdateXYScreen() # Update the screen
4700 
4702 
4703  MakeXYScreen() # Update the screen
4704  root.update() # Activate updated screens
4705 
4707  global VBuffA, VBuffB, IBuffA, IBuffB
4708  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus
4709  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4710  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4711  global FFTBuffA, FFTBuffB, FFTwindowshape
4712  global AWGAwaveform, AWGBwaveform
4713  global T1Vline, T2Vline, T1Iline, T2Iline
4714  global TMAVline, TMBVline, TMCVline, TMDVline
4715  global Tmathline, TMXline, TMYline
4716  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
4717  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
4718  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
4719  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
4720  global SHOWsamples, ZOHold, AWGBMode
4721  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
4722  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4723  global Show_MathX, Show_MathY
4724  global TRACES, TRACESread, RUNstatus
4725  global AutoCenterA, AutoCenterB
4726  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
4727  global TMpdiv # Array with time / div values in ms
4728  global TMsb # Time per div spin box variable
4729  global TIMEdiv # current spin box value
4730  global SAMPLErate, SCstart, Two_X_Sample, DISsamples
4731  global TRIGGERsample, TRACEsize, DX
4732  global TRIGGERlevel, TRIGGERentry, AutoLevel
4733  global InOffA, InGainA, InOffB, InGainB
4734  global CurOffA, CurOffB, CurGainA, CurGainB
4735  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4736  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4737  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4738  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
4739  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4740  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
4741  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
4742  global HozPoss, HozPossentry
4743 
4744  # Set the TRACEsize variable
4745  if len(VBuffA) < 100:
4746  return
4747  TRACEsize = SHOWsamples # Set the trace length
4748  SCstart = 0
4749  ylo = 0.0
4750  xlo = 0.0
4751  Ymin = Y0T # Minimum position of time grid (top)
4752  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
4753  Xmin = X0L # Minimum position of time grid (left)
4754  Xmax = X0L + GRW # Maximum position of time grid (right)
4755 
4756  # prevent divide by zero error
4757  if TIMEdiv < 0.0002:
4758  TIMEdiv = 0.01
4759  # Check for Auto Centering
4760  if AutoCenterA.get() > 0:
4761  CHAOffset = DCV1
4762  CHAVPosEntry.delete(0,END)
4763  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
4764  if AutoCenterB.get() > 0:
4765  CHBOffset = DCV2
4766  CHBVPosEntry.delete(0,END)
4767  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
4768  # get the vertical ranges
4769  try:
4770  CH1pdvRange = float(eval(CHAsb.get()))
4771  except:
4772  CHAsb.delete(0,END)
4773  CHAsb.insert(0, CH1vpdvRange)
4774  try:
4775  CH2pdvRange = float(eval(CHBsb.get()))
4776  except:
4777  CHBsb.delete(0,END)
4778  CHBsb.insert(0, CH2vpdvRange)
4779  try:
4780  CH1IpdvRange = float(eval(CHAIsb.get()))
4781  except:
4782  CHAIsb.delete(0,END)
4783  CHAIsb.insert(0, CH1IpdvRange)
4784  try:
4785  CH2IpdvRange = float(eval(CHBIsb.get()))
4786  except:
4787  CHBIsb.delete(0,END)
4788  CHBIsb.insert(0, CH2IpdvRange)
4789  # get the vertical offsets
4790  try:
4791  CHAOffset = float(eval(CHAVPosEntry.get()))
4792  except:
4793  CHAVPosEntry.delete(0,END)
4794  CHAVPosEntry.insert(0, CHAOffset)
4795  try:
4796  CHAIOffset = float(eval(CHAIPosEntry.get()))
4797  except:
4798  CHAIPosEntry.delete(0,END)
4799  CHAIPosEntry.insert(0, CHAIOffset)
4800  try:
4801  CHBOffset = float(eval(CHBVPosEntry.get()))
4802  except:
4803  CHBVPosEntry.delete(0,END)
4804  CHBVPosEntry.insert(0, CHBOffset)
4805  try:
4806  CHBIOffset = float(eval(CHBIPosEntry.get()))
4807  except:
4808  CHBIPosEntry.delete(0,END)
4809  CHBIPosEntry.insert(0, CHBIOffset)
4810  # prevent divide by zero error
4811  if CH1pdvRange < 0.001:
4812  CH1pdvRange = 0.001
4813  if CH2pdvRange < 0.001:
4814  CH2pdvRange = 0.001
4815  if CH1IpdvRange < 0.1:
4816  CH1IpdvRange = 0.1
4817  if CH2IpdvRange < 0.1:
4818  CH2IpdvRange = 0.1
4819 #
4820  try:
4821  HoldOff = float(eval(HoldOffentry.get()))
4822  if HoldOff < 0:
4823  HoldOff = 0
4824  HoldOffentry.delete(0,END)
4825  HoldOffentry.insert(0, HoldOff)
4826  except:
4827  HoldOffentry.delete(0,END)
4828  HoldOffentry.insert(0, HoldOff)
4829 #
4830  try:
4831  HozPoss = float(eval(HozPossentry.get()))
4832  except:
4833  HozPossentry.delete(0,END)
4834  HozPossentry.insert(0, HozPoss)
4835 #
4836  hldn = int(HoldOff * SAMPLErate/1000 )
4837  hozpos = int(HozPoss * SAMPLErate/1000 )
4838  if hozpos < 0:
4839  hozpos = 0
4840  # drawing the traces
4841  if TRACEsize == 0: # If no trace, skip rest of this routine
4842  T1Vline = [] # Trace line channel A V
4843  T2Vline = [] # Trace line channel B V
4844  T1Iline = []
4845  T2Iline = []
4846  TMAVline = [] # V Trace line Mux channel A
4847  TMBVline = [] # V Trace line Mux channel B
4848  TMCVline = [] # V Trace line Mux channel C
4849  TMDVline = [] # V Trace line Mux channel D
4850  Tmathline = [] # math trce line
4851  return()
4852 
4853  # set and/or corrected for in range
4854  if TgInput.get() > 0:
4855  SCmin = int(-1 * TRIGGERsample)
4856  SCmax = int(TRACEsize - TRIGGERsample - 0)
4857  else:
4858  SCmin = 0 # hldn
4859  SCmax = TRACEsize - 1
4860  if SCstart < SCmin: # No reading before start of array
4861  SCstart = SCmin
4862  if SCstart > SCmax: # No reading after end of array
4863  SCstart = SCmax
4864 
4865  # Make Trace lines etc.
4866 
4867  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
4868  Yconv2 = float(GRH/10.0) / CH2pdvRange
4869  YIconv1 = float(GRH/10.0) / CH1IpdvRange
4870  YIconv2 = float(GRH/10.0) / CH2IpdvRange
4871  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
4872  Xconv2 = float(GRW/10.0) / CH2pdvRange
4873  XIconv1 = float(GRW/10.0) / CH1IpdvRange
4874  XIconv2 = float(GRW/10.0) / CH2IpdvRange
4875  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
4876  try:
4877  CHMApdvRange = float(eval(CHB_Asb.get()))
4878  except:
4879  CHB_Asb.delete(0,END)
4880  CHB_Asb.insert(0, CHMApdvRange)
4881  try:
4882  CHMBpdvRange = float(eval(CHB_Bsb.get()))
4883  except:
4884  CHB_Bsb.delete(0,END)
4885  CHB_Bsb.insert(0, CHMBpdvRange)
4886  try:
4887  CHMCpdvRange = float(eval(CHB_Csb.get()))
4888  except:
4889  CHB_Csb.delete(0,END)
4890  CHB_Csb.insert(0, CHMCpdvRange)
4891  try:
4892  CHMDpdvRange = float(eval(CHB_Dsb.get()))
4893  except:
4894  CHB_Dsb.delete(0,END)
4895  CHB_Dsb.insert(0, CHMDpdvRange)
4896  YconvMA = float(GRH/10.0) / CHMApdvRange
4897  YconvMB = float(GRH/10.0) / CHMBpdvRange
4898  YconvMC = float(GRH/10.0) / CHMCpdvRange
4899  YconvMD = float(GRH/10.0) / CHMDpdvRange
4900  try:
4901  CHBAOffset = float(eval(CHB_APosEntry.get()))
4902  except:
4903  CHB_APosEntry.delete(0,END)
4904  CHB_APosEntry.insert(0, CHBAOffset)
4905  try:
4906  CHBBOffset = float(eval(CHB_BPosEntry.get()))
4907  except:
4908  CHB_BPosEntry.delete(0,END)
4909  CHB_BPosEntry.insert(0, CHBBOffset)
4910  try:
4911  CHBCOffset = float(eval(CHB_CPosEntry.get()))
4912  except:
4913  CHB_CPosEntry.delete(0,END)
4914  CHB_CPosEntry.insert(0, CHBCOffset)
4915  try:
4916  CHBDOffset = float(eval(CHB_DPosEntry.get()))
4917  except:
4918  CHB_DPosEntry.delete(0,END)
4919  CHB_DPosEntry.insert(0, CHBDOffset)
4920  if MathAxis == "V-A":
4921  YconvM = Yconv1
4922  CHMOffset = CHAOffset
4923  elif MathAxis == "V-B":
4924  YconvM = Yconv2
4925  CHMOffset = CHBOffset
4926  elif MathAxis == "I-A":
4927  YconvM = YIconv1
4928  CHMOffset = CHAIOffset
4929  elif MathAxis == "I-B":
4930  YconvM = YIconv2
4931  CHMOffset = CHBIOffset
4932  else:
4933  YconvM = Yconv1
4934  CHMOffset = CHAOffset
4935 # include ploting X and Y math formulas vs time
4936  if MathYAxis == "V-A":
4937  YconvMxy = Yconv1
4938  CHMYOffset = CHAOffset
4939  elif MathYAxis == "V-B":
4940  YconvMxy = Yconv2
4941  CHMYOffset = CHBOffset
4942  elif MathYAxis == "I-A":
4943  YconvMxy = YIconv1
4944  CHMYOffset = CHAIOffset
4945  elif MathYAxis == "I-B":
4946  YconvMxy = YIconv2
4947  CHMYOffset = CHBIOffset
4948  else:
4949  YconvMxy = Yconv1
4950  CHMYOffset = CHAOffset
4951 #
4952  if MathXAxis == "V-A":
4953  XconvMxy = Yconv1
4954  CHMXOffset = CHAOffset
4955  elif MathXAxis == "V-B":
4956  XconvMxy = Yconv2
4957  CHMXOffset = CHBOffset
4958  elif MathXAxis == "I-A":
4959  XconvMxy = YIconv1
4960  CHMXOffset = CHAIOffset
4961  elif MathXAxis == "I-B":
4962  XconvMxy = YIconv2
4963  CHMXOffset = CHBIOffset
4964  else:
4965  XconvMxy = Yconv1
4966  CHMXOffset = CHAOffset
4967 #
4968  c1 = GRH / 2.0 + Y0T # fixed correction channel A
4969  c2 = GRH / 2.0 + Y0T # fixed correction channel B
4970 
4971  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
4972  T1Vline = [] # V Trace line channel A
4973  T2Vline = [] # V Trace line channel B
4974  T1Iline = [] # I Trace line channel A
4975  T2Iline = [] # I Trace line channel B
4976  TMAVline = [] # V Trace line Mux channel A
4977  TMBVline = [] # V Trace line Mux channel B
4978  TMCVline = [] # V Trace line Mux channel C
4979  TMDVline = [] # V Trace line Mux channel D
4980  Tmathline = [] # math trce line
4981  TMXline = [] # X math Trace line
4982  TMYline = [] # Y math Trace line
4983  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
4984  return
4985  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
4986  if t < 0:
4987  t = 0
4988  x = 0 # Horizontal screen pixel
4989 #
4990  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
4991  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
4992  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
4993  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
4994  DvY1 = DvY2 = DiY1 = DiY2 = 0
4995 #
4996  if (DISsamples <= GRW):
4997  Xstep = GRW / DISsamples
4998  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
4999  xa = int((Xstep/-2.5) - (Xstep*DX))
5000  else:
5001  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
5002  x = 0 - int(Xstep*DX)
5003  Tstep = 1
5004  x1 = 0 # x position of trace line
5005  xa1 = 0
5006  y1 = 0.0 # y position of trace line
5007  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
5008  ytemp = IBuffA[t]
5009  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
5010  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
5011  if MuxScreenStatus.get() == 1:
5012  if len(VBuffMA) > 4:
5013  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
5014  if len(VBuffMB) > 4:
5015  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
5016  if len(VBuffMC) > 4:
5017  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
5018  if len(VBuffMD) > 4:
5019  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
5020  ytemp = IBuffB[t]
5021  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
5022  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
5023  if TgInput.get() == 0:
5024  Xlimit = GRW
5025  else:
5026  Xlimit = GRW+Xstep
5027  while x <= Xlimit:
5028  if t < TRACEsize:
5029  xa1 = xa + X0L
5030  x1 = x + X0L
5031  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
5032  ytemp = IBuffA[t]
5033  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
5034 
5035  if y1 < Ymin: # clip waveform if going off grid
5036  y1 = Ymin
5037  if y1 > Ymax:
5038  y1 = Ymax
5039  if yi1 < Ymin:
5040  yi1 = Ymin
5041  if yi1 > Ymax:
5042  yi1 = Ymax
5043  if ShowC1_V.get() == 1 :
5044  if ZOHold.get() == 1:
5045  T1Vline.append(int(xa1))
5046  T1Vline.append(int(ypv1))
5047  T1Vline.append(int(xa1))
5048  T1Vline.append(int(y1))
5049  else:
5050  T1Vline.append(int(xa1))
5051  T1Vline.append(int(y1))
5052  DvY1 = ypv1 - y1
5053  ypv1 = y1
5054  if ShowC1_I.get() == 1:
5055  if ZOHold.get() == 1:
5056  T1Iline.append(int(xa1))
5057  T1Iline.append(int(ypi1))
5058  T1Iline.append(int(xa1))
5059  T1Iline.append(int(yi1))
5060  else:
5061  T1Iline.append(int(xa1))
5062  T1Iline.append(int(yi1))
5063  DiY1 = ypi1 - yi1
5064  ypi1 = yi1
5065  if ShowC2_V.get() == 1:
5066  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
5067  if y1 < Ymin: # clip waveform if going off grid
5068  y1 = Ymin
5069  if y1 > Ymax:
5070  y1 = Ymax
5071  if ZOHold.get() == 1:
5072  T2Vline.append(int(x1))
5073  T2Vline.append(int(ypv2))
5074  T2Vline.append(int(x1))
5075  T2Vline.append(int(y1))
5076  else:
5077  T2Vline.append(int(x1))
5078  T2Vline.append(int(y1))
5079  DvY2 = ypv2 - y1
5080  ypv2 = y1
5081  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
5082  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
5083  if y1 < Ymin: # clip waveform if going off grid
5084  y1 = Ymin
5085  if y1 > Ymax:
5086  y1 = Ymax
5087  if ZOHold.get() == 1:
5088  TMAVline.append(int(x1))
5089  TMAVline.append(int(ypvma))
5090  TMAVline.append(int(x1))
5091  TMAVline.append(int(y1))
5092  else:
5093  TMAVline.append(int(x1))
5094  TMAVline.append(int(y1))
5095  ypvma = y1
5096  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5097  Xfine = MouseX - X0L - x
5098  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
5099  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
5100  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
5101  if y1 < Ymin: # clip waveform if going off grid
5102  y1 = Ymin
5103  if y1 > Ymax:
5104  y1 = Ymax
5105  if ZOHold.get() == 1:
5106  TMBVline.append(int(x1))
5107  TMBVline.append(int(ypvmb))
5108  TMBVline.append(int(x1))
5109  TMBVline.append(int(y1))
5110  else:
5111  TMBVline.append(int(x1))
5112  TMBVline.append(int(y1))
5113  ypvmb = y1
5114  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5115  Xfine = MouseX - X0L - x
5116  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
5117  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
5118  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
5119  if y1 < Ymin: # clip waveform if going off grid
5120  y1 = Ymin
5121  if y1 > Ymax:
5122  y1 = Ymax
5123  if ZOHold.get() == 1:
5124  TMCVline.append(int(x1))
5125  TMCVline.append(int(ypvmc))
5126  TMCVline.append(int(x1))
5127  TMCVline.append(int(y1))
5128  else:
5129  TMCVline.append(int(x1))
5130  TMCVline.append(int(y1))
5131  ypvmc = y1
5132  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5133  Xfine = MouseX - X0L - x
5134  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
5135  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
5136  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
5137  if y1 < Ymin: # clip waveform if going off grid
5138  y1 = Ymin
5139  if y1 > Ymax:
5140  y1 = Ymax
5141  if ZOHold.get() == 1:
5142  TMDVline.append(int(x1))
5143  TMDVline.append(int(ypvmd))
5144  TMDVline.append(int(x1))
5145  TMDVline.append(int(y1))
5146  else:
5147  TMDVline.append(int(x1))
5148  TMDVline.append(int(y1))
5149  ypvmd = y1
5150  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5151  Xfine = MouseX - X0L - x
5152  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
5153  if ShowC2_I.get() == 1:
5154  ytemp = IBuffB[t]
5155  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
5156  if yi1 < Ymin:
5157  yi1 = Ymin
5158  if yi1 > Ymax:
5159  yi1 = Ymax
5160  if (ZOHold.get() == 1):
5161  T2Iline.append(int(x1))
5162  T2Iline.append(int(ypi2))
5163  T2Iline.append(int(x1))
5164  T2Iline.append(int(yi1))
5165  else:
5166  T2Iline.append(int(x1))
5167  T2Iline.append(int(yi1))
5168  DiY2 = ypi2 - yi1
5169  ypi2 = yi1
5170  if MathTrace.get() > 0:
5171  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
5172  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
5173 
5174  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
5175  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
5176 
5177  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
5178  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
5179 
5180  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
5181  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
5182  ytemp = YIconv1 * (Ypower - CHAIOffset)
5183  y1 = int(c1 - ytemp)
5184 
5185  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
5186  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
5187  ytemp = YIconv2 * (Ypower - CHBIOffset)
5188  y1 = int(c2 - ytemp)
5189 
5190  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
5191  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
5192  ytemp = YIconv1 * (Yohms - CHAIOffset)
5193  y1 = int(c1 - ytemp)
5194 
5195  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
5196  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
5197  ytemp = YIconv2 * (Yohms - CHBIOffset)
5198  y1 = int(c2 - ytemp)
5199 
5200  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
5201  Ydif = (IBuffA[t] - IBuffB[t])# in mA
5202  ytemp = YIconv1 * (Ydif - CHAIOffset)
5203  y1 = int(c2 - ytemp)
5204 
5205  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
5206  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
5207  ytemp = YIconv2 * (Ydif - CHBIOffset)
5208  y1 = int(c2 - ytemp)
5209 
5210  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
5211  try:
5212  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
5213  except:
5214  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
5215 
5216  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
5217  try:
5218  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
5219  except:
5220  Y1 = (IBuffB[t] / 0.000001)
5221  ytemp = YIconv2 * (Y1 - CHBIOffset)
5222  y1 = int(c2 - ytemp)
5223 
5224  elif MathTrace.get() == 12: # plot from equation string
5225  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
5226  try:
5227  MathResult = eval(MathString)
5228  MathResult = MathResult - CHMOffset
5229  y1 = int(c1 - YconvM * MathResult)
5230  except:
5231  RUNstatus.set(0)
5232  x = Xlimit + 1 # exit loop
5233 
5234  if y1 < Ymin: # clip waveform if going off grid
5235  y1 = Ymin
5236  if y1 > Ymax:
5237  y1 = Ymax
5238  if ZOHold.get() == 1: # connet the dots with stair step
5239  Tmathline.append(int(x1))
5240  Tmathline.append(int(ypm))
5241  Tmathline.append(int(x1))
5242  Tmathline.append(int(y1))
5243  else: # connet the dots with single line
5244  Tmathline.append(int(x1))
5245  Tmathline.append(int(y1))
5246  ypm = y1
5247  if Show_MathX.get() > 0:
5248  try:
5249  MathResult = eval(MathXString)
5250  MathResult = MathResult - CHMXOffset
5251  y1 = int(c1 - XconvMxy * MathResult)
5252  except:
5253  RUNstatus.set(0)
5254  x = Xlimit + 1 # exit loop
5255 
5256  if y1 < Ymin: # clip waveform if going off grid
5257  y1 = Ymin
5258  if y1 > Ymax:
5259  y1 = Ymax
5260  if ZOHold.get() == 1: # connet the dots with stair step
5261  TMXline.append(int(x1))
5262  TMXline.append(int(ypmx))
5263  TMXline.append(int(x1))
5264  TMXline.append(int(y1))
5265  else: # connet the dots with single line
5266  TMXline.append(int(x1))
5267  TMXline.append(int(y1))
5268  ypmx = y1
5269  if Show_MathY.get() > 0:
5270  try:
5271  MathResult = eval(MathYString)
5272  MathResult = MathResult - CHMYOffset
5273  y1 = int(c1 - YconvMxy * MathResult)
5274  except:
5275  RUNstatus.set(0)
5276  x = Xlimit + 1 # exit loop
5277 
5278  if y1 < Ymin: # clip waveform if going off grid
5279  y1 = Ymin
5280  if y1 > Ymax:
5281  y1 = Ymax
5282  if ZOHold.get() == 1: # connet the dots with stair step
5283  TMYline.append(int(x1))
5284  TMYline.append(int(ypmy))
5285  TMYline.append(int(x1))
5286  TMYline.append(int(y1))
5287  else: # connet the dots with single line
5288  TMYline.append(int(x1))
5289  TMYline.append(int(y1))
5290  ypmy = y1
5291  # remember trace verticle pixel at X mouse location
5292  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
5293  Xfine = MouseX - X0L - x
5294  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
5295  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
5296  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
5297  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
5298  t = int(t + Tstep)
5299  x = x + Xstep
5300  xa = xa + Xstep
5301 
5302  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
5303  Xstep = 1
5304  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
5305  x1 = 0.0 # x position of trace line
5306  ylo = 0.0 # ymin position of trace 1 line
5307  yhi = 0.0 # ymax position of trace 1 line
5308 
5309  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
5310  if t > len(VBuffA)-1:
5311  t = 0
5312  if t < 0:
5313  t = 0
5314  x = 0 # Horizontal screen pixel
5315  ft = t # time point with fractions
5316  while (x <= GRW):
5317  if (t < TRACEsize):
5318  if (t >= len(VBuffA)):
5319  t = len(VBuffA)-2
5320  x = GRW
5321  x1 = x + X0L
5322  ylo = VBuffA[t] - CHAOffset
5323  ilo = IBuffA[t] - CHAIOffset
5324  yhi = ylo
5325  ihi = ilo
5326  n = t
5327  while n < (t + Tstep) and n < TRACEsize:
5328  if ( ShowC1_V.get() == 1 ):
5329  v = VBuffA[t] - CHAOffset
5330  if v < ylo:
5331  ylo = v
5332  if v > yhi:
5333  yhi = v
5334  if ( ShowC1_I.get() == 1 ):
5335  i = IBuffA[t] - CHAIOffset
5336  if i < ilo:
5337  ilo = i
5338  if i > ihi:
5339  ihi = i
5340  n = n + 1
5341  if ( ShowC1_V.get() == 1 ):
5342  ylo = int(c1 - Yconv1 * ylo)
5343  yhi = int(c1 - Yconv1 * yhi)
5344  if (ylo < Ymin):
5345  ylo = Ymin
5346  if (ylo > Ymax):
5347  ylo = Ymax
5348  if (yhi < Ymin):
5349  yhi = Ymin
5350  if (yhi > Ymax):
5351  yhi = Ymax
5352  T1Vline.append(int(x1))
5353  T1Vline.append(int(ylo))
5354  T1Vline.append(int(x1))
5355  T1Vline.append(int(yhi))
5356  ypv1 = ylo
5357  if ( ShowC1_I.get() == 1 ):
5358  ilo = int(c1 - YIconv1 * ilo)
5359  ihi = int(c1 - YIconv1 * ihi)
5360  if (ilo < Ymin):
5361  ilo = Ymin
5362  if (ilo > Ymax):
5363  ilo = Ymax
5364  if (ihi < Ymin):
5365  ihi = Ymin
5366  if (ihi > Ymax):
5367  ihi = Ymax
5368  T1Iline.append(int(x1))
5369  T1Iline.append(int(ilo))
5370  T1Iline.append(int(x1))
5371  T1Iline.append(int(ihi))
5372  ypi1 = ilo
5373  ylo = VBuffB[t] - CHBOffset
5374  ilo = IBuffB[t] - CHBIOffset
5375  yhi = ylo
5376  ihi = ilo
5377  n = t
5378  if MuxScreenStatus.get() == 0:
5379  while n < (t + Tstep) and n < TRACEsize:
5380  if ( ShowC2_V.get() == 1 ):
5381  v = VBuffB[t] - CHBOffset
5382  if v < ylo:
5383  ylo = v
5384  if v > yhi:
5385  yhi = v
5386  if ( ShowC2_I.get() == 1 ):
5387  i = IBuffB[t] - CHBIOffset
5388  if i < ilo:
5389  ilo = i
5390  if i > ihi:
5391  ihi = i
5392  n = n + 1
5393  if ( ShowC2_V.get() == 1 ):
5394  ylo = int(c2 - Yconv2 * ylo)
5395  yhi = int(c2 - Yconv2 * yhi)
5396  if (ylo < Ymin):
5397  ylo = Ymin
5398  if (ylo > Ymax):
5399  ylo = Ymax
5400 
5401  if (yhi < Ymin):
5402  yhi = Ymin
5403  if (yhi > Ymax):
5404  yhi = Ymax
5405  T2Vline.append(int(x1))
5406  T2Vline.append(int(ylo))
5407  T2Vline.append(int(x1))
5408  T2Vline.append(int(yhi))
5409  ypv2 = ylo
5410  if ( ShowC2_I.get() == 1 ):
5411  ilo = int(c2 - YIconv2 * ilo)
5412  ihi = int(c2 - YIconv2 * ihi)
5413  if (ilo < Ymin):
5414  ilo = Ymin
5415  if (ilo > Ymax):
5416  ilo = Ymax
5417  if (ihi < Ymin):
5418  ihi = Ymin
5419  if (ihi > Ymax):
5420  ihi = Ymax
5421  T2Iline.append(int(x1))
5422  T2Iline.append(int(ilo))
5423  T2Iline.append(int(x1))
5424  T2Iline.append(int(ihi))
5425  ypi2 = ilo
5426  else:
5427  if Show_CBA.get() == 1 and len(VBuffMA)>4:
5428  if t < len(VBuffMA):
5429  ylo = VBuffMA[t] - CHBAOffset
5430  yhi = ylo
5431  n = t
5432  while n < (t + Tstep) and n < len(VBuffMA):
5433  v = VBuffMA[t] - CHBAOffset
5434  if v < ylo:
5435  ylo = v
5436  if v > yhi:
5437  yhi = v
5438  n = n + 1
5439  ylo = int(c2 - YconvMA * ylo)
5440  yhi = int(c2 - YconvMA * yhi)
5441  if (ylo < Ymin):
5442  ylo = Ymin
5443  if (ylo > Ymax):
5444  ylo = Ymax
5445  if (yhi < Ymin):
5446  yhi = Ymin
5447  if (yhi > Ymax):
5448  yhi = Ymax
5449  TMAVline.append(int(x1))
5450  TMAVline.append(int(ylo))
5451  TMAVline.append(int(x1))
5452  TMAVline.append(int(yhi))
5453  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5454  MouseMuxA = ylo
5455  if Show_CBB.get() == 1 and len(VBuffMB)>4:
5456  if t < len(VBuffMB):
5457  ylo = VBuffMB[t] - CHBBOffset
5458  yhi = ylo
5459  n = t
5460  while n < (t + Tstep) and n < len(VBuffMB):
5461  v = VBuffMB[t] - CHBBOffset
5462  if v < ylo:
5463  ylo = v
5464  if v > yhi:
5465  yhi = v
5466  n = n + 1
5467  ylo = int(c2 - YconvMB * ylo)
5468  yhi = int(c2 - YconvMB * yhi)
5469  if (ylo < Ymin):
5470  ylo = Ymin
5471  if (ylo > Ymax):
5472  ylo = Ymax
5473  if (yhi < Ymin):
5474  yhi = Ymin
5475  if (yhi > Ymax):
5476  yhi = Ymax
5477  TMBVline.append(int(x1))
5478  TMBVline.append(int(ylo))
5479  TMBVline.append(int(x1))
5480  TMBVline.append(int(yhi))
5481  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5482  MouseMuxB = ylo
5483  if Show_CBC.get() == 1 and len(VBuffMC)>4:
5484  if t < len(VBuffMC):
5485  ylo = VBuffMC[t] - CHBCOffset
5486  yhi = ylo
5487  n = t
5488  while n < (t + Tstep) and n < len(VBuffMC):
5489  v = VBuffMC[t] - CHBCOffset
5490  if v < ylo:
5491  ylo = v
5492  if v > yhi:
5493  yhi = v
5494  n = n + 1
5495  ylo = int(c2 - YconvMC * ylo)
5496  yhi = int(c2 - YconvMC * yhi)
5497  if (ylo < Ymin):
5498  ylo = Ymin
5499  if (ylo > Ymax):
5500  ylo = Ymax
5501  if (yhi < Ymin):
5502  yhi = Ymin
5503  if (yhi > Ymax):
5504  yhi = Ymax
5505  TMCVline.append(int(x1))
5506  TMCVline.append(int(ylo))
5507  TMCVline.append(int(x1))
5508  TMCVline.append(int(yhi))
5509  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5510  MouseMuxC = ylo
5511  if Show_CBD.get() == 1 and len(VBuffMD)>4:
5512  if t < len(VBuffMD):
5513  ylo = VBuffMD[t] - CHBDOffset
5514  yhi = ylo
5515  n = t
5516  while n < (t + Tstep) and n < len(VBuffMD):
5517  v = VBuffMD[t] - CHBDOffset
5518  if v < ylo:
5519  ylo = v
5520  if v > yhi:
5521  yhi = v
5522  n = n + 1
5523  ylo = int(c2 - YconvMD * ylo)
5524  yhi = int(c2 - YconvMD * yhi)
5525  if (ylo < Ymin):
5526  ylo = Ymin
5527  if (ylo > Ymax):
5528  ylo = Ymax
5529  if (yhi < Ymin):
5530  yhi = Ymin
5531  if (yhi > Ymax):
5532  yhi = Ymax
5533  TMDVline.append(int(x1))
5534  TMDVline.append(int(ylo))
5535  TMDVline.append(int(x1))
5536  TMDVline.append(int(yhi))
5537  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5538  MouseMuxD = ylo
5539  if ( ShowC2_I.get() == 1 ):
5540  while n < (t + Tstep) and n < TRACEsize:
5541  i = IBuffB[t] - CHBIOffset
5542  if i < ilo:
5543  ilo = i
5544  if i > ihi:
5545  ihi = i
5546  n = n + 1
5547  ilo = int(c2 - YIconv2 * ilo)
5548  ihi = int(c2 - YIconv2 * ihi)
5549  if (ilo < Ymin):
5550  ilo = Ymin
5551  if (ilo > Ymax):
5552  ilo = Ymax
5553  if (ihi < Ymin):
5554  ihi = Ymin
5555  if (ihi > Ymax):
5556  ihi = Ymax
5557  T2Iline.append(int(x1))
5558  T2Iline.append(int(ilo))
5559  T2Iline.append(int(x1))
5560  T2Iline.append(int(ihi))
5561  if MathTrace.get() > 0:
5562  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
5563  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
5564 
5565  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
5566  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
5567 
5568  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
5569  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
5570 
5571  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
5572  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
5573  ytemp = YIconv1 * (Ypower - CHAIOffset)
5574  y1 = int(c1 - ytemp)
5575 
5576  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
5577  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
5578  ytemp = YIconv2 * (Ypower - CHBIOffset)
5579  y1 = int(c2 - ytemp)
5580 
5581  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
5582  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
5583  ytemp = YIconv1 * (Yohms- CHAIOffset)
5584  y1 = int(c1 - ytemp)
5585 
5586  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
5587  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
5588  ytemp = YIconv2 * (Yohms - CHBIOffset)
5589  y1 = int(c2 - ytemp)
5590 
5591  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
5592  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
5593  ytemp = YIconv1 * (Ydif - CHAIOffset)
5594  y1 = int(c2 - ytemp)
5595 
5596  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
5597  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
5598  ytemp = YIconv2 * (Ydif - CHBIOffset)
5599  y1 = int(c2 - ytemp)
5600 
5601  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
5602  try:
5603  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
5604  except:
5605  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
5606  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
5607  try:
5608  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
5609  except:
5610  Y1 = (IBuffB[t] / 0.000001)
5611  ytemp = YIconv2 * (Y1 - CHBIOffset)
5612  y1 = int(c2 - ytemp)
5613 
5614  elif MathTrace.get() == 12: # plot from equation string
5615  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
5616  try:
5617  MathResult = eval(MathString)
5618  MathResult = MathResult - CHMOffset
5619  y1 = int(c1 - YconvM * MathResult)
5620  except:
5621  RUNstatus.set(0)
5622  x = GRW + 1
5623 
5624  if (y1 < Ymin):
5625  y1 = Ymin
5626  if (y1 > Ymax):
5627  y1 = Ymax
5628  if (ZOHold.get() == 1):
5629  Tmathline.append(int(x1))
5630  Tmathline.append(int(ypm))
5631  Tmathline.append(int(x1))
5632  Tmathline.append(int(y1))
5633  else:
5634  Tmathline.append(int(x1))
5635  Tmathline.append(int(y1))
5636  ypm = y1
5637  if Show_MathX.get() > 0:
5638  try:
5639  MathResult = eval(MathXString)
5640  MathResult = MathResult - CHMXOffset
5641  y1 = int(c1 - XconvMxy * MathResult)
5642  except:
5643  RUNstatus.set(0)
5644  x = GRW + 1
5645 
5646  if y1 < Ymin: # clip waveform if going off grid
5647  y1 = Ymin
5648  if y1 > Ymax:
5649  y1 = Ymax
5650  if ZOHold.get() == 1: # connet the dots with stair step
5651  TMXline.append(int(x1))
5652  TMXline.append(int(ypmx))
5653  TMXline.append(int(x1))
5654  TMXline.append(int(y1))
5655  else: # connet the dots with single line
5656  TMXline.append(int(x1))
5657  TMXline.append(int(y1))
5658  ypmx = y1
5659  if Show_MathY.get() > 0:
5660  try:
5661  MathResult = eval(MathYString)
5662  MathResult = MathResult - CHMYOffset
5663  y1 = int(c1 - YconvMxy * MathResult)
5664  except:
5665  RUNstatus.set(0)
5666  x = GRW + 1
5667 
5668  if y1 < Ymin: # clip waveform if going off grid
5669  y1 = Ymin
5670  if y1 > Ymax:
5671  y1 = Ymax
5672  if ZOHold.get() == 1: # connet the dots with stair step
5673  TMYline.append(int(x1))
5674  TMYline.append(int(ypmy))
5675  TMYline.append(int(x1))
5676  TMYline.append(int(y1))
5677  else: # connet the dots with single line
5678  TMYline.append(int(x1))
5679  TMYline.append(int(y1))
5680  ypmy = y1
5681  ft = ft + Tstep
5682  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
5683  MouseCAV = ypv1
5684  MouseCAI = ypi1
5685  MouseCBV = ypv2
5686  MouseCBI = ypi2
5687  t = int(ft)
5688  if (t > len(VBuffA)):
5689  t = len(VBuffA)-2
5690  x = GRW
5691  x = x + Xstep
5692 
5693  # Make trigger triangle pointer
5694  Triggerline = [] # Trigger pointer
5695  Triggersymbol = [] # Trigger symbol
5696  if TgInput.get() > 0:
5697  if TgInput.get() == 1 : # triggering on CA-V
5698  x1 = X0L
5699  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) # / InGainA
5700  y1 = int(c1 - ytemp)
5701  elif TgInput.get() == 2: # triggering on CA-I
5702  x1 = X0L+GRW
5703  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
5704  elif TgInput.get() == 3: # triggering on CB-V
5705  x1 = X0L
5706  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) # / InGainB
5707  y1 = int(c2 - ytemp)
5708  elif TgInput.get() == 4: # triggering on CB-I
5709  x1 = X0L+GRW
5710  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
5711 
5712  if (y1 < Ymin):
5713  y1 = Ymin
5714  if (y1 > Ymax):
5715  y1 = Ymax
5716  Triggerline.append(int(x1-5))
5717  Triggerline.append(int(y1+5))
5718  Triggerline.append(int(x1+5))
5719  Triggerline.append(int(y1))
5720  Triggerline.append(int(x1-5))
5721  Triggerline.append(int(y1-5))
5722  Triggerline.append(int(x1-5))
5723  Triggerline.append(int(y1+5))
5724  x1 = X0L + (GRW/2)
5725  if TgEdge.get() == 0: # draw rising edge symbol
5726  y1 = -3
5727  y2 = -13
5728  else:
5729  y1 = -13
5730  y2 = -3
5731  Triggersymbol.append(int(x1-10))
5732  Triggersymbol.append(int(Ymin+y1))
5733  Triggersymbol.append(int(x1))
5734  Triggersymbol.append(int(Ymin+y1))
5735  Triggersymbol.append(int(x1))
5736  Triggersymbol.append(int(Ymin+y2))
5737  Triggersymbol.append(int(x1+10))
5738  Triggersymbol.append(int(Ymin+y2))
5739 
5741  global VBuffA, VBuffB, IBuffA, IBuffB
5742  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
5743  global TXYline, MathXString, MathYString, MathXAxis, MathYAxis
5744  global HoldOff, HoldOffentry
5745  global X0LXY, Y0TXY, GRWXY, GRHXY
5746  global YminXY, YmaxXY, XminXY, XmaxXY
5747  global SHOWsamples, ZOHold, AWGBMode
5748  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
5749  global TRACES, TRACESread, RUNstatus
5750  global Xsignal, Ysignal
5751  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
5752  global TMpdiv # Array with time / div values in ms
5753  global TMsb # Time per div spin box variable
5754  global TIMEdiv # current spin box value
5755  global SAMPLErate
5756  global SCstart, MathString
5757  global TRIGGERsample, TRACEsize, DX
5758  global TRIGGERlevel, TRIGGERentry, AutoLevel
5759  global InOffA, InGainA, InOffB, InGainB
5760  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5761  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5762  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
5763  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
5764  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
5765  global HozPoss, HozPossentry
5766 
5767  # Set the TRACEsize variable
5768  if len(VBuffA) < 100:
5769  return
5770  TRACEsize = SHOWsamples # Set the trace length
5771  SCstart = 0
5772  ylo = 0.0
5773  xlo = 0.0
5774  # get the vertical ranges
5775  try:
5776  CH1pdvRange = float(eval(CHAsbxy.get()))
5777  except:
5778  CHAsbxy.delete(0,END)
5779  CHAsbxy.insert(0, CH1vpdvRange)
5780  try:
5781  CH2pdvRange = float(eval(CHBsbxy.get()))
5782  except:
5783  CHBsbxy.delete(0,END)
5784  CHBsbxy.insert(0, CH2vpdvRange)
5785  try:
5786  CH1IpdvRange = float(eval(CHAIsbxy.get()))
5787  except:
5788  CHAIsbxy.delete(0,END)
5789  CHAIsbxy.insert(0, CH1IpdvRange)
5790  try:
5791  CH2IpdvRange = float(eval(CHBIsbxy.get()))
5792  except:
5793  CHBIsbxy.delete(0,END)
5794  CHBIsbxy.insert(0, CH2IpdvRange)
5795  # get the vertical offsets
5796  try:
5797  CHAOffset = float(eval(CHAVPosEntryxy.get()))
5798  except:
5799  CHAVPosEntryxy.delete(0,END)
5800  CHAVPosEntryxy.insert(0, CHAOffset)
5801  try:
5802  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
5803  except:
5804  CHAIPosEntryxy.delete(0,END)
5805  CHAIPosEntryxy.insert(0, CHAIOffset)
5806  try:
5807  CHBOffset = float(eval(CHBVPosEntryxy.get()))
5808  except:
5809  CHBVPosEntry.delete(0,END)
5810  CHBVPosEntry.insert(0, CHBOffset)
5811  try:
5812  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
5813  except:
5814  CHBIPosEntryxy.delete(0,END)
5815  CHBIPosEntryxy.insert(0, CHBIOffset)
5816  # prevent divide by zero error
5817  if CH1pdvRange < 0.001:
5818  CH1pdvRange = 0.001
5819  if CH2pdvRange < 0.001:
5820  CH2pdvRange = 0.001
5821  if CH1IpdvRange < 0.1:
5822  CH1IpdvRange = 0.1
5823  if CH2IpdvRange < 0.1:
5824  CH2IpdvRange = 0.1
5825  #
5826  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
5827  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
5828  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
5829  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
5830  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
5831  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
5832  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
5833  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
5834 
5835  if MathYAxis == "V-A":
5836  YconvMxy = Yconv1
5837  CHMYOffset = CHAOffset
5838  elif MathYAxis == "V-B":
5839  YconvMxy = Yconv2
5840  CHMYOffset = CHBOffset
5841  elif MathYAxis == "I-A":
5842  YconvMxy = YIconv1
5843  CHMYOffset = CHAIOffset
5844  elif MathYAxis == "I-B":
5845  YconvMxy = YIconv2
5846  CHMYOffset = CHBIOffset
5847  else:
5848  YconvMxy = Yconv1
5849  CHMYOffset = CHAOffset
5850  if MathXAxis == "V-A":
5851  XconvMxy = Xconv1
5852  CHMXOffset = CHAOffset
5853  elif MathXAxis == "V-B":
5854  XconvMxy = Xconv2
5855  CHMXOffset = CHBOffset
5856  elif MathYAxis == "I-A":
5857  XconvMxy = XIconv1
5858  CHMXOffset = CHAIOffset
5859  elif MathXAxis == "I-B":
5860  XconvMxy = XIconv2
5861  CHMXOffset = CHBIOffset
5862  else:
5863  XconvMxy = Xconv1
5864  CHMXOffset = CHAOffset
5865  # draw an X/Y plot
5866  TXYline = [] # XY Trace line
5867  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
5868  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
5869  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
5870  while (t < TRACEsize):
5871  if (Xsignal.get() == 3 and Ysignal.get() == 1): # mode CAV/CBV
5872  ylo = VBuffA[t] - CHAOffset
5873  xlo = VBuffB[t] - CHBOffset
5874  ylo = int(c1 - Yconv1 * ylo)
5875  xlo = int(c2 + Xconv2 * xlo)
5876  elif (Xsignal.get() == 1 and Ysignal.get() == 3): # mode CBV/CAV
5877  ylo = VBuffB[t] - CHBOffset
5878  xlo = VBuffA[t] - CHAOffset
5879  ylo = int(c1 - Yconv2 * ylo)
5880  xlo = int(c2 + Xconv1 * xlo)
5881  elif (Xsignal.get() == 5 and Ysignal.get() == 3): # mode CBV/Math
5882  if ( MathTrace.get() == 2): # plot difference of CA-V and CB-V
5883  ylo = VBuffB[t] - CHBOffset
5884  ylo = int(c1 - Yconv2 * ylo)
5885  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
5886  xlo = int(c2 + Xconv1 * xlo)
5887  elif (Xsignal.get() == 5 and Ysignal.get() == 4): # mode CBI/Math
5888  if ( MathTrace.get() == 2): # plot difference of CA-V and CB-V
5889  ylo = (IBuffB[t]) - CHBIOffset
5890  ylo = int(c1 - YIconv2 * ylo)
5891  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
5892  xlo = int(c2 + Xconv1 * xlo)
5893  elif (Xsignal.get() == 5 and Ysignal.get() == 2): # mode CAI/Math
5894  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5895  ylo = (IBuffA[t]) - CHAIOffset
5896  ylo = int(c1 - YIconv1 * ylo)
5897  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
5898  xlo = int(c2 + Xconv2 * xlo)
5899  elif (Xsignal.get() == 3 and Ysignal.get() == 5): # mode Math/CBV
5900  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
5901  ylo = VBuffA[t] - VBuffB[t] - CHAOffset
5902  ylo = int(c1 - Yconv1 * ylo)
5903  xlo = VBuffB[t] - CHBOffset
5904  xlo = int(c2 + Xconv2 * xlo)
5905  elif (Xsignal.get() == 5 and Ysignal.get() == 1): # mode CAV/Math
5906  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5907  ylo = VBuffA[t] - CHAOffset
5908  ylo = int(c1 - Yconv1 * ylo)
5909  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
5910  xlo = int(c2 + Xconv2 * xlo)
5911  elif (Xsignal.get() == 1 and Ysignal.get() == 5): # mode Math/CAV
5912  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5913  ylo = VBuffB[t] - VBuffA[t] - CHBOffset
5914  ylo = int(c1 - Yconv2 * ylo)
5915  xlo = VBuffA[t] - CHAOffset
5916  xlo = int(c2 + Xconv1 * xlo)
5917  elif (Xsignal.get() == 1 and Ysignal.get() == 2): # mode CAI/CAV
5918  ylo = (IBuffA[t]) - CHAIOffset
5919  xlo = VBuffA[t] - CHAOffset
5920  ylo = int(c1 - YIconv1 * ylo)
5921  xlo = int(c2 + Xconv1 * xlo)
5922  elif (Xsignal.get() == 3 and Ysignal.get() == 2): # mode CAI/CBV
5923  ylo = (IBuffA[t]) - CHAIOffset
5924  xlo = VBuffB[t] - CHBOffset
5925  ylo = int(c1 - YIconv1 * ylo)
5926  xlo = int(c2 + Xconv2 * xlo)
5927  elif (Xsignal.get() == 2 and Ysignal.get() == 1): # mode CAV/CAI
5928  ylo = VBuffA[t] - CHAOffset
5929  xlo = (IBuffA[t]) - CHAIOffset
5930  ylo = int(c1 - Yconv1 * ylo)
5931  xlo = int(c2 + XIconv1 * xlo)
5932  elif (Xsignal.get() == 2 and Ysignal.get() == 3): # mode CBV/CAI
5933  ylo = VBuffB[t] - CHBOffset
5934  xlo = (IBuffA[t]) - CHAIOffset
5935  ylo = int(c1 - Yconv2 * ylo)
5936  xlo = int(c2 + XIconv1 * xlo)
5937  elif (Xsignal.get() == 3 and Ysignal.get() == 4): # mode CBI/CBV
5938  ylo = (IBuffB[t]) - CHBIOffset
5939  xlo = VBuffB[t] - CHBOffset
5940  ylo = int(c1 - YIconv2 * ylo)
5941  xlo = int(c2 + Xconv2 * xlo)
5942  elif (Xsignal.get() == 4 and Ysignal.get() == 3): # mode CBV/CBI
5943  ylo = VBuffB[t] - CHBOffset
5944  xlo = (IBuffB[t]) - CHBIOffset
5945  ylo = int(c1 - Yconv2 * ylo)
5946  xlo = int(c2 + XIconv2 * xlo)
5947  elif (Xsignal.get() == 4 and Ysignal.get() == 2): # mode CAI/CBI
5948  ylo = (IBuffA[t]) - CHAIOffset
5949  xlo = (IBuffB[t]) - CHBIOffset
5950  ylo = int(c1 - YIconv1 * ylo)
5951  xlo = int(c2 + XIconv2 * xlo)
5952  elif (Xsignal.get() == 2 and Ysignal.get() == 4): # mode CBI/CAI
5953  ylo = (IBuffB[t]) - CHBIOffset
5954  xlo = (IBuffA[t]) - CHAIOffset
5955  ylo = int(c1 - YIconv2 * ylo)
5956  xlo = int(c2 + XIconv1 * xlo)
5957  elif (Xsignal.get() == 1 and Ysignal.get() == 4): # mode CBI/CAV
5958  ylo = (IBuffB[t]) - CHBIOffset
5959  xlo = VBuffA[t] - CHAOffset
5960  ylo = int(c1 - YIconv2 * ylo)
5961  xlo = int(c2 + Xconv1 * xlo)
5962  elif (Xsignal.get() == 5 and Ysignal.get() == 5): # mode MathYString/MathXString
5963  try:
5964  MathResult = eval(MathYString)
5965  MathResult = MathResult - CHMYOffset
5966  ylo = int(c1 - YconvMxy * MathResult)
5967  except:
5968  RUNstatus.set(0)
5969  try:
5970  MathResult = eval(MathXString)
5971  MathResult = MathResult - CHMXOffset
5972  xlo = int(c2 + XconvMxy * MathResult)
5973  except:
5974  RUNstatus.set(0)
5975  if ylo < YminXY: # clip waveform if going off grid
5976  ylo = YminXY
5977  if ylo > YmaxXY:
5978  ylo = YmaxXY
5979  if xlo < XminXY: # clip waveform if going off grid
5980  xlo = XminXY
5981  if xlo > XmaxXY:
5982  xlo = XmaxXY
5983  TXYline.append(int(xlo))
5984  TXYline.append(int(ylo))
5985  t = int(t + 1)
5986 
5988  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
5989  global TMXline, TMYline
5990  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
5991  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
5992  global VBuffA, VBuffB, IBuffA, IBuffB
5993  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus
5994  global TMAVline, TMBVline, TMCVline, TMDVline, TMCRline, TMBRline
5995  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
5996  global X0L # Left top X value
5997  global Y0T # Left top Y value
5998  global GRW # Screenwidth
5999  global GRH # Screenheight
6000  global FontSize, EnableHSsampling, ETSDisp, MinigenScreenStatus
6001  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
6002  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
6003  global ShowXCur, ShowYCur, TCursor, VCursor
6004  global SHOWsamples # Number of samples in data record
6005  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowRXY, Show_MathX, Show_MathY
6006  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
6007  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
6008  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
6009  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
6010  global CHAsb # V range spinbox Index for channel 1
6011  global CHBsb # V range spinbox Index for channel 2
6012  global CHAOffset # Position value for channel 1 V
6013  global CHBOffset # Position value for channel 2 V
6014  global CHAIsb # I range spinbox Index for channel 1
6015  global CHBIsb # I range spinbox Index for channel 2
6016  global CHAIOffset # Postion value for channel 1 I
6017  global CHBIOffset # position value for channel 2 I
6018  global TMpdiv # Array with time / div values in ms
6019  global TMsb # Time per div spin box variable
6020  global TIMEdiv, Mulx, DISsamples # current spin box value
6021  global SAMPLErate, contloop, discontloop, HtMulEntry
6022  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
6023  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
6024  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
6025  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
6026  global CANVASwidth, CANVASheight
6027  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
6028  global ScreenTrefresh, SmoothCurves, Is_Triggered
6029  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
6030  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
6031  global InOffA, InGainA, InOffB, InGainB
6032  global CurOffA, CurOffB, CurGainA, CurGainB
6033  # Analog Mux channel measurement variables
6034  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
6035  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
6036  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
6037  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
6038  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
6039  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
6040  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
6041  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
6042  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
6043  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
6044  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
6045  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
6046  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
6047  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6048  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6049  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
6050  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
6051  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
6052  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
6053  global D0, D1, D2, D3, D4, D5, D6, D7
6054  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
6055  global HozPoss, HozPossentry
6056  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
6057  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
6058  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
6059  #
6060  Ymin = Y0T # Minimum position of time grid (top)
6061  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
6062 
6063  # DISsamples = (10.0 * TIMEdiv) # grid width in time
6064  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
6065  # get the vertical ranges
6066  try:
6067  CH1pdvRange = float(eval(CHAsb.get()))
6068  except:
6069  CHAsb.delete(0,END)
6070  CHAsb.insert(0, CH1vpdvRange)
6071  try:
6072  CH2pdvRange = float(eval(CHBsb.get()))
6073  except:
6074  CHBsb.delete(0,END)
6075  CHBsb.insert(0, CH2vpdvRange)
6076  try:
6077  CH1IpdvRange = float(eval(CHAIsb.get()))
6078  except:
6079  CHAIsb.delete(0,END)
6080  CHAIsb.insert(0, CH1IpdvRange)
6081  try:
6082  CH2IpdvRange = float(eval(CHBIsb.get()))
6083  except:
6084  CHBIsb.delete(0,END)
6085  CHBIsb.insert(0, CH2IpdvRange)
6086  # get the vertical offsets
6087  try:
6088  CHAOffset = float(eval(CHAVPosEntry.get()))
6089  except:
6090  CHAVPosEntry.delete(0,END)
6091  CHAVPosEntry.insert(0, CHAOffset)
6092  try:
6093  CHAIOffset = float(eval(CHAIPosEntry.get()))
6094  except:
6095  CHAIPosEntry.delete(0,END)
6096  CHAIPosEntry.insert(0, CHAIOffset)
6097  try:
6098  CHBOffset = float(eval(CHBVPosEntry.get()))
6099  except:
6100  CHBVPosEntry.delete(0,END)
6101  CHBVPosEntry.insert(0, CHBOffset)
6102  try:
6103  CHBIOffset = float(eval(CHBIPosEntry.get()))
6104  except:
6105  CHBIPosEntry.delete(0,END)
6106  CHBIPosEntry.insert(0, CHBIOffset)
6107  try:
6108  HoldOff = float(eval(HoldOffentry.get()))
6109  if HoldOff < 0:
6110  HoldOff = 0
6111  except:
6112  HoldOffentry.delete(0,END)
6113  HoldOffentry.insert(0, HoldOff)
6114  if ETSDisp.get() > 0 or MinigenScreenStatus.get() > 0:
6115  try:
6116  Mulx = float(eval(HtMulEntry.get()))
6117  if Mulx < 1:
6118  Mulx = 1
6119  except:
6120  Mulx = 1
6121  if EnableHSsampling > 0:
6122  HtMulEntry.delete(0,END)
6123  HtMulEntry.insert(0, 1)
6124  else:
6125  Mulx = 1
6126  # slide trace left right by HozPoss
6127  try:
6128  HozPoss = float(eval(HozPossentry.get()))
6129  except:
6130  HozPossentry.delete(0,END)
6131  HozPossentry.insert(0, HozPoss)
6132  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6133  try:
6134  CHMApdvRange = float(eval(CHB_Asb.get()))
6135  except:
6136  CHB_Asb.delete(0,END)
6137  CHB_Asb.insert(0, CHMApdvRange)
6138  try:
6139  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6140  except:
6141  CHB_Bsb.delete(0,END)
6142  CHB_Bsb.insert(0, CHMBpdvRange)
6143  try:
6144  CHMCpdvRange = float(eval(CHB_Csb.get()))
6145  except:
6146  CHB_Csb.delete(0,END)
6147  CHB_Csb.insert(0, CHMCpdvRange)
6148  try:
6149  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6150  except:
6151  CHB_Dsb.delete(0,END)
6152  CHB_Dsb.insert(0, CHMDpdvRange)
6153  if CHMApdvRange < 0.001:
6154  CHMApdvRange = 0.001
6155  if CHMBpdvRange < 0.001:
6156  CHMBpdvRange = 0.001
6157  if CHMCpdvRange < 0.001:
6158  CHMCpdvRange = 0.001
6159  if CHMDpdvRange < 0.001:
6160  CHMDpdvRange = 0.001
6161  try:
6162  CHBAOffset = float(eval(CHB_APosEntry.get()))
6163  except:
6164  CHB_APosEntry.delete(0,END)
6165  CHB_APosEntry.insert(0, CHBAOffset)
6166  try:
6167  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6168  except:
6169  CHB_BPosEntry.delete(0,END)
6170  CHB_BPosEntry.insert(0, CHBBOffset)
6171  try:
6172  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6173  except:
6174  CHB_CPosEntry.delete(0,END)
6175  CHB_CPosEntry.insert(0, CHBCOffset)
6176  try:
6177  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6178  except:
6179  CHB_DPosEntry.delete(0,END)
6180  CHB_DPosEntry.insert(0, CHBDOffset)
6181  # prevent divide by zero error
6182  if CH1pdvRange < 0.001:
6183  CH1pdvRange = 0.001
6184  if CH2pdvRange < 0.001:
6185  CH2pdvRange = 0.001
6186  if CH1IpdvRange < 0.1:
6187  CH1IpdvRange = 0.1
6188  if CH2IpdvRange < 0.1:
6189  CH2IpdvRange = 0.1
6190  vt = HoldOff + HozPoss # invert sign and scale to mSec
6191  if ScreenTrefresh.get() == 0:
6192  # Delete all items on the screen
6193  ca.delete(ALL) # remove all items
6194  MarkerNum = 0
6195  # Draw horizontal grid lines
6196  i = 0
6197  x1 = X0L
6198  x2 = X0L + GRW
6199  mg_siz = GRW/10.0
6200  mg_inc = mg_siz/5.0
6201  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)
6202  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)
6203  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)
6204  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)
6205  # vertical scale text labels
6206  RightOffset = FontSize * 3
6207  LeftOffset = int(FontSize/2)
6208  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
6209  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
6210  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
6211  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
6212  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
6213  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
6214  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
6215  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
6216  #
6217  while (i < 11):
6218  y = Y0T + i * GRH/10.0
6219  Dline = [x1,y,x2,y]
6220  if i == 5:
6221  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
6222  k = 0
6223  while (k < 10):
6224  l = 1
6225  while (l < 5):
6226  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
6227  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6228  l = l + 1
6229  k = k + 1
6230  else:
6231  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6232 
6233  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
6234  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6235  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
6236  Vaxis_label = str(round(Vaxis_value,3 ))
6237  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
6238 
6239  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
6240  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6241  Iaxis_label = str(round(Iaxis_value, 3))
6242  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
6243 
6244  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
6245  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6246  Vaxis_label = str(round(Vaxis_value, 3))
6247  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
6248 
6249  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
6250  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6251  Iaxis_label = str(round(Iaxis_value, 3))
6252  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
6253  if MuxScreenStatus.get() == 1:
6254  if Show_CBA.get() == 1:
6255  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
6256  Vaxis_label = str(round(Vaxis_value, 3))
6257  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
6258  if Show_CBB.get() == 1:
6259  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
6260  Iaxis_label = str(round(Iaxis_value, 3))
6261  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
6262  if Show_CBC.get() == 1:
6263  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
6264  Iaxis_label = str(round(Iaxis_value, 3))
6265  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
6266  if Show_CBD.get() == 1:
6267  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
6268  Iaxis_label = str(round(Iaxis_value, 3))
6269  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
6270  i = i + 1
6271  # Draw vertical grid lines
6272  i = 0
6273  y1 = Y0T
6274  y2 = Y0T + GRH
6275  mg_siz = GRH/10.0
6276  mg_inc = mg_siz/5.0
6277  vx = TIMEdiv/Mulx
6278  vt = HoldOff/Mulx # invert sign and scale to mSec
6279  # vx = TIMEdiv
6280  while (i < 11):
6281  x = X0L + i * GRW/10.0
6282  Dline = [x,y1,x,y2]
6283  if (i == 5):
6284  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
6285  k = 0
6286  while (k < 10):
6287  l = 1
6288  while (l < 5):
6289  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
6290  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6291  l = l + 1
6292  k = k + 1
6293  #
6294  if vx >= 1000:
6295  axis_value = ((i * vx)+ vt) / 1000.0
6296  axis_label = ' {0:.1f} '.format(axis_value) + " S"
6297  if vx < 1000 and vx >= 1:
6298  axis_value = (i * vx) + vt
6299  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
6300  if vx < 1:
6301  axis_value = ((i * vx) + vt) * 1000.0
6302  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
6303  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
6304  else:
6305  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6306  if vx >= 1000:
6307  axis_value = ((i * vx)+ vt) / 1000.0
6308  axis_label = ' {0:.1f} '.format(axis_value) + " S"
6309  if vx < 1000 and vx >= 1:
6310  axis_value = (i * vx) + vt
6311  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
6312  if vx < 1:
6313  axis_value = ((i * vx) + vt) * 1000.0
6314  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
6315  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
6316 
6317  i = i + 1
6318  # Write the trigger line if available
6319  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
6320  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
6321  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
6322  if TgInput.get() == 1:
6323  TgLabel = "CA-V"
6324  if TgInput.get() == 2:
6325  TgLabel = "CA-I"
6326  if TgInput.get() == 3:
6327  TgLabel = "CB-V"
6328  if TgInput.get() == 4:
6329  TgLabel = "CB-I"
6330  if Is_Triggered == 1:
6331  TgLabel = TgLabel + " Triggered"
6332  else:
6333  TgLabel = TgLabel + " Not Triggered"
6334  if SingleShot.get() > 0:
6335  TgLabel = TgLabel + " Armed"
6336  x = X0L + (GRW/2) + 12
6337  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
6338  # Draw T - V Cursor lines if required
6339  if MarkerScale.get() == 0:
6340  Yconv1 = float(GRH/10.0) / CH1pdvRange
6341  Yoffset1 = CHAOffset
6342  COLORmarker = COLORtrace1
6343  Units = " V"
6344  if MarkerScale.get() == 1:
6345  MouseY = MouseCAV
6346  Yconv1 = float(GRH/10.0) / CH1pdvRange
6347  Yoffset1 = CHAOffset
6348  COLORmarker = COLORtrace1
6349  Units = " V"
6350  if MarkerScale.get() == 2:
6351  MouseY = MouseCBV
6352  Yconv1 = float(GRH/10.0) / CH2pdvRange
6353  Yoffset1 = CHBOffset
6354  COLORmarker = COLORtrace2
6355  Units = " V"
6356  if MarkerScale.get() == 3:
6357  MouseY = MouseCAI
6358  Yconv1 = float(GRH/10.0) / CH1IpdvRange
6359  Yoffset1 = CHAIOffset
6360  COLORmarker = COLORtrace3
6361  Units = " mA"
6362  if MarkerScale.get() == 4:
6363  MouseY = MouseCBI
6364  Yconv1 = float(GRH/10.0) / CH2IpdvRange
6365  Yoffset1 = CHBIOffset
6366  COLORmarker = COLORtrace4
6367  Units = " mA"
6368  # Analog Mux settings
6369  if MarkerScale.get() == 5:
6370  MouseY = MouseMuxA
6371  Yconv1 = float(GRH/10.0) / CHMApdvRange
6372  Yoffset1 = CHBAOffset
6373  COLORmarker = COLORtrace2
6374  Units = " V"
6375  if MarkerScale.get() == 6:
6376  MouseY = MouseMuxB
6377  Yconv1 = float(GRH/10.0) / CHMBpdvRange
6378  Yoffset1 = CHBBOffset
6379  COLORmarker = COLORtrace6
6380  Units = " V"
6381  if MarkerScale.get() == 7:
6382  MouseY = MouseMuxC
6383  Yconv1 = float(GRH/10.0) / CHMCpdvRange
6384  Yoffset1 = CHBCOffset
6385  COLORmarker = COLORtrace7
6386  Units = " V"
6387  if MarkerScale.get() == 8:
6388  MouseY = MouseMuxD
6389  Yconv1 = float(GRH/10.0) / CHMDpdvRange
6390  Yoffset1 = CHBDOffset
6391  COLORmarker = COLORtrace4
6392  Units = " V"
6393 #
6394  if ShowTCur.get() > 0:
6395  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
6396  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6397  Tpoint = ((TCursor-X0L) * Tstep) + vt
6398  Tpoint = Tpoint/Mulx
6399  if Tpoint >= 1000:
6400  axis_value = Tpoint / 1000.0
6401  V_label = ' {0:.2f} '.format(axis_value) + " S"
6402  if Tpoint < 1000 and Tpoint >= 1:
6403  axis_value = Tpoint
6404  V_label = ' {0:.2f} '.format(axis_value) + " mS"
6405  if Tpoint < 1:
6406  axis_value = Tpoint * 1000.0
6407  V_label = ' {0:.2f} '.format(axis_value) + " uS"
6408  ca.create_text(TCursor+1, VCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
6409  if ShowVCur.get() > 0:
6410  Dline = [X0L, VCursor, X0L+GRW, VCursor]
6411  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
6412  c1 = GRH / 2 + Y0T # fixed Y correction
6413  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
6414  V1String = ' {0:.3f} '.format(-yvolts)
6415  V_label = V1String + Units
6416  ca.create_text(TCursor+1, VCursor+5, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
6417  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
6418  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
6419  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
6420  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6421  Tpoint = ((MouseX-X0L) * Tstep) + vt
6422  Tpoint = Tpoint/Mulx
6423  if Tpoint >= 1000:
6424  axis_value = Tpoint / 1000.0
6425  V_label = ' {0:.2f} '.format(axis_value) + " S"
6426  if Tpoint < 1000 and Tpoint >= 1:
6427  axis_value = Tpoint
6428  V_label = ' {0:.2f} '.format(axis_value) + " mS"
6429  if Tpoint < 1:
6430  axis_value = Tpoint * 1000.0
6431  V_label = ' {0:.2f} '.format(axis_value) + " uS"
6432  ca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
6433  Dline = [X0L, MouseY, X0L+GRW, MouseY]
6434  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6435  c1 = GRH / 2 + Y0T # fixed Y correction
6436  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
6437  V1String = ' {0:.3f} '.format(-yvolts)
6438  V_label = V1String + Units
6439  ca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
6440 #
6441  if MeasGateStatus.get() == 1:
6442  LeftGate = X0L + MeasGateLeft / Tstep
6443  RightGate = X0L + MeasGateRight / Tstep
6444  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), fill=COLORtrace5)
6445  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), fill=COLORtrace7)
6446  #
6447  # TString = ' {0:.2f} '.format(Tpoint)
6448  DT = (MeasGateRight-MeasGateLeft)/Mulx
6449  if DT == 0.0:
6450  DT = 1.0
6451  if DT >= 1000:
6452  axis_value = DT / 1000.0
6453  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
6454  if DT < 1000 and DT >= 1:
6455  axis_value = DT
6456  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
6457  if DT < 1:
6458  axis_value = DT * 1000.0
6459  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
6460  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
6461  DFreq = ' {0:.3f} '.format(1.0/DT)
6462  V_label = " Delta T" + DeltaT
6463  #V_label = V_label + Units
6464  V_label = V_label + ", Freq " + DFreq + " KHz"
6465  # place in upper left unless specified otherwise
6466  x = X0L + 5
6467  y = Y0T + 7
6468  Justify = 'w'
6469  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
6470  x = X0L + GRW - 5
6471  y = Y0T + 7
6472  Justify = 'e'
6473  if MarkerLoc == 'LL' or MarkerLoc == 'll':
6474  x = X0L + 5
6475  y = Y0T + GRH + 7 - (MarkerNum*10)
6476  Justify = 'w'
6477  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
6478  x = X0L + GRW - 5
6479  y = Y0T + GRH + 7
6480  Justify = 'e'
6481  ca.create_text(x, y, text=V_label, fill=COLORtrace5, anchor=Justify, font=("arial", FontSize ))
6482  #
6483 #
6484  SmoothBool = SmoothCurves.get()
6485  # Write the traces if available
6486  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
6487  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
6488  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
6489  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
6490  if len(T2Vline) > 4: # Write the trace 2 if active
6491  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6492  if len(T2Iline) > 4:
6493  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6494  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
6495  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6496  if len(TMXline) > 4 : # Write X Math tace if active
6497  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6498  if len(TMYline) > 4 : # Write Y Math tace if active
6499  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6500  if MuxScreenStatus.get() == 1:
6501  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
6502  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6503  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
6504  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6505  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
6506  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6507  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
6508  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6509  if ShowRB_V.get() == 1 and len(TMBRline) > 4:
6510  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6511  if ShowRB_I.get() == 1 and len(TMCRline) > 4:
6512  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6513  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
6514  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6515  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
6516  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6517  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
6518  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6519  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
6520  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6521  if ShowMath.get() == 1 and len(TMRline) > 4:
6522  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6523 
6524  # General information on top of the grid
6525  # Sweep information
6526  if session.continuous:
6527  sttxt = "Running Continuous"
6528  else:
6529  sttxt = "Running Discontinuous"
6530  if TRACEmodeTime.get() == 1:
6531  sttxt = sttxt + " Averaging"
6532  if ManualTrigger.get() == 1:
6533  sttxt = "Manual Trigger"
6534  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
6535  sttxt = "Stopped"
6536  if ScreenTrefresh.get() == 1:
6537  sttxt = sttxt + " Persistance ON"
6538  # Delete text at bottom of screen
6539  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
6540  for n in de:
6541  ca.delete(n)
6542  # Delete text at top of screen
6543  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
6544  for n in de:
6545  ca.delete(n)
6546  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
6547  x = X0L+2
6548  y = 12
6549  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6550  # digital I/O indicators
6551  x2 = X0L + GRW
6552  BoxColor = "#808080" # gray
6553  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
6554  if D0.get() == 0 and D4.get() == 0:
6555  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
6556  if Dval[0] == 1:
6557  BoxColor = "#00ff00" # 100% green
6558  elif Dval[0] == 0:
6559  BoxColor = "#ff0000" # 100% red
6560  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
6561  else:
6562  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
6563  if D1.get() == 0 and D5.get() == 0:
6564  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
6565  if Dval[0] == 1:
6566  BoxColor = "#00ff00" # 100% green
6567  elif Dval[0] == 0:
6568  BoxColor = "#ff0000" # 100% red
6569  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
6570  else:
6571  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
6572  if D2.get() == 0 and D6.get() == 0:
6573  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
6574  if Dval[0] == 1:
6575  BoxColor = "#00ff00" # 100% green
6576  elif Dval[0] == 0:
6577  BoxColor = "#ff0000" # 100% red
6578  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
6579  else:
6580  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
6581  if D3.get() == 0 and D7.get() == 0:
6582  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
6583  if Dval[0] == 1:
6584  BoxColor = "#00ff00" # 100% green
6585  elif Dval[0] == 0:
6586  BoxColor = "#ff0000" # 100% red
6587  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
6588  else:
6589  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
6590  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
6591  # Time sweep information and view at information
6592  vx = TIMEdiv/Mulx
6593  if vx >= 1000:
6594  txt = ' {0:.2f} '.format(vx / 1000.0) + " S/div"
6595  if vx < 1000 and vx >= 1:
6596  txt = ' {0:.2f} '.format(vx) + " mS/div"
6597  if vx < 1:
6598  txt = ' {0:.2f} '.format(vx * 1000.0) + " uS/div"
6599 
6600  txt = txt + " "
6601  #
6602  txt = txt + "View at "
6603  if abs(vt) >= 1000:
6604  txt = txt + str(int(vt / 1000.0)) + " S "
6605  if abs(vt) < 1000 and abs(vt) >= 1:
6606  txt = txt + str(int(vt)) + " mS "
6607  if abs(vt) < 1:
6608  txt = txt + str(int(vt * 1000.0)) + " uS "
6609  # print period and frequency of displayed channels
6610  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
6611  if ETSDisp.get() > 0:
6612  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
6613  else:
6614  FindRisingEdge(VBuffA,VBuffB)
6615  if ShowC1_V.get() == 1:
6616  if MeasAHW.get() == 1:
6617  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
6618  if MeasALW.get() == 1:
6619  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
6620  if MeasADCy.get() == 1:
6621  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
6622  if MeasAPER.get() == 1:
6623  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
6624  if MeasAFREQ.get() == 1:
6625  txt = txt + " CA Freq = "
6626  ChaF = CHAfreq*Mulx
6627  if ChaF < 1000:
6628  V1String = ' {0:.1f} '.format(ChaF)
6629  txt = txt + str(V1String) + " Hz "
6630  if ChaF > 1000 and ChaF < 1000000:
6631  V1String = ' {0:.1f} '.format(ChaF/1000)
6632  txt = txt + str(V1String) + " KHz "
6633  if ChaF > 1000000:
6634  V1String = ' {0:.1f} '.format(ChaF/1000000)
6635  txt = txt + str(V1String) + " MHz "
6636  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
6637  if ShowC2_V.get() == 1:
6638  if MeasBHW.get() == 1:
6639  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
6640  if MeasBLW.get() == 1:
6641  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
6642  if MeasBDCy.get() == 1:
6643  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
6644  if MeasBPER.get() == 1:
6645  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
6646  if MeasBFREQ.get() == 1:
6647  txt = txt + " CB Freq = "
6648  ChaF = CHBfreq*Mulx
6649  if ChaF < 1000:
6650  V1String = ' {0:.1f} '.format(ChaF)
6651  txt = txt + str(V1String) + " Hz "
6652  if ChaF > 1000 and ChaF < 1000000:
6653  V1String = ' {0:.1f} '.format(ChaF/1000)
6654  txt = txt + str(V1String) + " KHz "
6655  if ChaF > 1000000:
6656  V1String = ' {0:.1f} '.format(ChaF/1000000)
6657  txt = txt + str(V1String) + " MHz "
6658  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
6659  if MuxScreenStatus.get() == 0:
6660  if MeasPhase.get() == 1:
6661  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
6662  if MeasDelay.get() == 1:
6663  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
6664 
6665  x = X0L
6666  y = Y0T+GRH+int(2.5 *FontSize) # 20
6667  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6668  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
6669  MakeHistogram()
6670  txt = " "
6671  if ShowC1_V.get() == 1:
6672  # Channel A information
6673  if CHA_RC_HP.get() == 1:
6674  txt = "CHA: HP "
6675  else:
6676  txt = "CHA: "
6677  txt = txt + str(CH1pdvRange) + " V/div"
6678  if MeasDCV1.get() == 1:
6679  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
6680  if MeasMaxV1.get() == 1:
6681  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
6682  if MeasTopV1.get() == 1:
6683  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
6684  if MeasMinV1.get() == 1:
6685  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
6686  if MeasBaseV1.get() == 1:
6687  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
6688  if MeasMidV1.get() == 1:
6689  MidV1 = (MaxV1+MinV1)/2.0
6690  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
6691  if MeasPPV1.get() == 1:
6692  PPV1 = MaxV1-MinV1
6693  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
6694  if MeasRMSV1.get() == 1:
6695  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
6696  if MeasRMSVA_B.get() == 1:
6697  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
6698  if MeasDiffAB.get() == 1:
6699  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
6700  if MeasUserA.get() == 1:
6701  try:
6702  TempValue = eval(UserAString)
6703  V1String = ' {0:.4f} '.format(TempValue)
6704  except:
6705  V1String = "####"
6706  txt = txt + UserALabel + " = " + V1String
6707  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
6708  txt = "CHA: "
6709  txt = txt + str(CH1IpdvRange) + " mA/div"
6710  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
6711  txt = txt + "CHA: "
6712  txt = txt + str(CH1IpdvRange) + " mA/div"
6713  if ShowC1_I.get() == 1:
6714  if MeasDCI1.get() == 1:
6715  V1String = ' {0:.2f} '.format(DCI1)
6716  txt = txt + " AvgI = " + V1String
6717  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
6718  try:
6719  Resvalue = (DCV1/DCI1)*1000
6720  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
6721  except:
6722  txt = txt + " Res = OverRange"
6723  if MeasMaxI1.get() == 1:
6724  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
6725  if MeasMinI1.get() == 1:
6726  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
6727  if MeasMidI1.get() == 1:
6728  MidI1 = (MaxI1+MinI1)/2.0
6729  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
6730  if MeasPPI1.get() == 1:
6731  PPI1 = MaxI1-MinI1
6732  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
6733  if MeasRMSI1.get() == 1:
6734  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
6735 
6736  x = X0L
6737  y = Y0T+GRH+(4*FontSize) # 32
6738  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6739  txt= " "
6740  # Channel B information
6741  if MuxScreenStatus.get() == 1:
6742  txt = "CHB-Mux: "
6743  if Show_CBA.get() > 0:
6744  FindRisingEdge(VBuffA,VBuffMA)
6745  elif Show_CBB.get() > 0:
6746  FindRisingEdge(VBuffA,VBuffMB)
6747  elif Show_CBC.get() > 0:
6748  FindRisingEdge(VBuffA,VBuffMC)
6749  elif Show_CBD.get() > 0:
6750  FindRisingEdge(VBuffA,VBuffMD)
6751  if MeasPhase.get() == 1:
6752  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
6753  if MeasDelay.get() == 1:
6754  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
6755  if MeasUserB.get() == 1:
6756  try:
6757  TempValue = eval(UserBString)
6758  V1String = ' {0:.4f} '.format(TempValue)
6759  except:
6760  V1String = "####"
6761  txt = txt + UserBLabel + " = " + V1String
6762  if ShowC2_V.get() == 1:
6763  if CHB_RC_HP.get() == 1:
6764  txt = "CHB: HP "
6765  else:
6766  txt = "CHB: "
6767  txt = txt + str(CH2pdvRange) + " V/div"
6768  if MeasDCV2.get() == 1:
6769  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
6770  if MeasMaxV2.get() == 1:
6771  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
6772  if MeasTopV2.get() == 1:
6773  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
6774  if MeasMinV2.get() == 1:
6775  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
6776  if MeasBaseV2.get() == 1:
6777  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
6778  if MeasMidV2.get() == 1:
6779  MidV2 = (MaxV2+MinV2)/2.0
6780  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
6781  if MeasPPV2.get() == 1:
6782  PPV2 = MaxV2-MinV2
6783  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
6784  if MeasRMSV2.get() == 1:
6785  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
6786  if MeasDiffBA.get() == 1:
6787  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
6788  if MeasUserB.get() == 1:
6789  try:
6790  TempValue = eval(UserBString)
6791  V1String = ' {0:.4f} '.format(TempValue)
6792  except:
6793  V1String = "####"
6794  txt = txt + UserBLabel + " = " + V1String
6795  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
6796  txt = "CHB: "
6797  txt = txt + str(CH2IpdvRange) + " mA/div"
6798  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
6799  txt = txt + "CHB: "
6800  txt = txt + str(CH2IpdvRange) + " mA/div"
6801  if ShowC2_I.get() == 1:
6802  if MeasDCI2.get() == 1:
6803  V1String = ' {0:.2f} '.format(DCI2)
6804  txt = txt + " AvgI = " + V1String
6805  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
6806  try:
6807  Resvalue = (DCV2/DCI2)*1000
6808  R1String = ' {0:.1f} '.format(Resvalue)
6809  txt = txt + " Res = " + R1String
6810  except:
6811  txt = txt + " Res = OverRange"
6812  if MeasMaxI2.get() == 1:
6813  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
6814  if MeasMinI2.get() == 1:
6815  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
6816  if MeasMidI2.get() == 1:
6817  MidI2 = (MaxI2+MinI2)/2.0
6818  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
6819  if MeasPPI2.get() == 1:
6820  PPI2 = MaxI2-MinI2
6821  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
6822  if MeasRMSI2.get() == 1:
6823  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
6824 
6825  x = X0L
6826  y = Y0T+GRH+int(5.5*FontSize) # 44
6827  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6828 
6830  global TXYline # active trave lines
6831  global Tmathline, TMRline, TXYRline
6832  global X0LXY # Left top X value
6833  global Y0TXY # Left top Y value
6834  global GRWXY # Screenwidth
6835  global GRHXY # Screenheight
6836  global FontSize
6837  global XYca, MouseX, MouseY, MouseWidget
6838  global ShowXCur, ShowYCur, XCursor, YCursor
6839  global SHOWsamples # Number of samples in data record
6840  global ShowRXY, ShowMath, MathUnits, MathXUnits, MathYUnits
6841  global Xsignal, Ysignal, MathXAxis, MathYAxis
6842  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
6843  global CHAsbxy # spinbox Index for channel 1 V
6844  global CHBsbxy # spinbox Index for channel 2 V
6845  global CHAOffset # Offset value for channel 1 V
6846  global CHBOffset # Offset value for channel 2 V
6847  global CHAIsbxy # spinbox Index for channel 1 I
6848  global CHBIsbxy # spinbox Index for channel 2 I
6849  global CHAIOffset # Offset value for channel 1 I
6850  global CHBIOffset # Offset value for channel 2 I
6851  global TMpdiv # Array with time / div values in ms
6852  global TMsb # Time per div spin box variable
6853  global TIMEdiv # current spin box value
6854  global SAMPLErate
6855  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
6856  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7 # The colors
6857  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
6858  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5
6859  global CANVASwidthXY, CANVASheightXY
6860  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
6861  global ScreenXYrefresh, SmoothCurves
6862  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
6863  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
6864  global SV1, SI1, SV2, SI2, CHABphase
6865  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
6866  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
6867  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
6868  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
6869  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
6870  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
6871  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
6872  global AWGAShape, AWGBShape
6873  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6874  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6875  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
6876  global DacScreenStatus, DigScreenStatus
6877  global D0, D1, D2, D3, D4, D5, D6, D7
6878  global DevID, devx, MarkerNum, MarkerScale
6879  global HozPoss, HozPossentry
6880  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
6881  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
6882  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
6883  #
6884  Ymin = Y0TXY # Minimum position of screen grid (top)
6885  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
6886  try:
6887  InOffA = float(eval(CHAVOffsetEntry.get()))
6888  except:
6889  CHAVOffsetEntry.delete(0,END)
6890  CHAVOffsetEntry.insert(0, InOffA)
6891  try:
6892  InGainA = float(eval(CHAVGainEntry.get()))
6893  except:
6894  CHAVGainEntry.delete(0,END)
6895  CHAVGainEntry.insert(0, InGainA)
6896  try:
6897  InOffB = float(eval(CHBVOffsetEntry.get()))
6898  except:
6899  CHBVOffsetEntry.delete(0,END)
6900  CHBVOffsetEntry.insert(0, InOffB)
6901  try:
6902  InGainB = float(eval(CHBVGainEntry.get()))
6903  except:
6904  CHBVGainEntry.delete(0,END)
6905  CHBVGainEntry.insert(0, InGainB)
6906 #
6907  try:
6908  CH1pdvRange = float(eval(CHAsbxy.get()))
6909  except:
6910  CHAsbxy.delete(0,END)
6911  CHAsbxy.insert(0, CH1vpdvRange)
6912  try:
6913  CH2pdvRange = float(eval(CHBsbxy.get()))
6914  except:
6915  CHBsbxy.delete(0,END)
6916  CHBsbxy.insert(0, CH2vpdvRange)
6917  try:
6918  CH1IpdvRange = float(eval(CHAIsbxy.get()))
6919  except:
6920  CHAIsbxy.delete(0,END)
6921  CHAIsbxy.insert(0, CH1IpdvRange)
6922  try:
6923  CH2IpdvRange = float(eval(CHBIsbxy.get()))
6924  except:
6925  CHBIsbxy.delete(0,END)
6926  CHBIsbxy.insert(0, CH2IpdvRange)
6927  # get the vertical offsets
6928  try:
6929  CHAOffset = float(eval(CHAVPosEntryxy.get()))
6930  except:
6931  CHAVPosEntryxy.delete(0,END)
6932  CHAVPosEntryxy.insert(0, CHAOffset)
6933  try:
6934  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
6935  except:
6936  CHAIPosEntryxy.delete(0,END)
6937  CHAIPosEntryxy.insert(0, CHAIOffset)
6938  try:
6939  CHBOffset = float(eval(CHBVPosEntryxy.get()))
6940  except:
6941  CHBVPosEntry.delete(0,END)
6942  CHBVPosEntry.insert(0, CHBOffset)
6943  try:
6944  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
6945  except:
6946  CHBIPosEntryxy.delete(0,END)
6947  CHBIPosEntryxy.insert(0, CHBIOffset)
6948  # prevent divide by zero error
6949  if CH1pdvRange < 0.001:
6950  CH1pdvRange = 0.001
6951  if CH2pdvRange < 0.001:
6952  CH2pdvRange = 0.001
6953  if CH1IpdvRange < 0.05:
6954  CH1IpdvRange = 0.05
6955  if CH2IpdvRange < 0.05:
6956  CH2IpdvRange = 0.05
6957  # If drawing histograms adjust offset based on range such that bottom grid is zero
6958  if Xsignal.get() == 6:
6959  CHAIOffset = 5 * CH1IpdvRange
6960  if Xsignal.get() == 7:
6961  CHBIOffset = 5 * CH2IpdvRange
6962  if ScreenXYrefresh.get() == 0:
6963  # Delete all items on the screen
6964  MarkerNum = 0
6965  XYca.delete(ALL) # remove all items
6966  # Draw horizontal grid lines
6967  i = 0
6968  x1 = X0LXY
6969  x2 = X0LXY + GRWXY
6970  mg_siz = GRWXY/10.0
6971  mg_inc = mg_siz/5.0
6972  while (i < 11):
6973  y = Y0TXY + i * GRHXY/10.0
6974  Dline = [x1,y,x2,y]
6975  if i == 5:
6976  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
6977  k = 0
6978  while (k < 10):
6979  l = 1
6980  while (l < 5):
6981  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
6982  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6983  l = l + 1
6984  k = k + 1
6985  else:
6986  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6987  if Ysignal.get() == 2 or Xsignal.get() == 6:
6988  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6989  Iaxis_label = str(round(Iaxis_value, 3))
6990  XYca.create_text(x1-3, y, text=Iaxis_label, fill=COLORtrace3, anchor="e", font=("arial", FontSize ))
6991  elif Ysignal.get() == 4 or Xsignal.get() == 7:
6992  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6993  Iaxis_label = str(round(Iaxis_value, 3))
6994  XYca.create_text(x1-3, y, text=Iaxis_label, fill=COLORtrace4, anchor="e", font=("arial", FontSize ))
6995  elif Ysignal.get() == 1:
6996  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6997  Vaxis_label = str(round(Vaxis_value, 3))
6998  XYca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
6999  elif Ysignal.get() == 3:
7000  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7001  Vaxis_label = str(round(Vaxis_value, 3))
7002  XYca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
7003  elif Ysignal.get() == 5:
7004  TempCOLOR = COLORtrace5
7005  if MathTrace.get() == 2:
7006  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7007  elif MathTrace.get() == 3:
7008  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7009  else:
7010  if MathYAxis == "V-A":
7011  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7012  TempCOLOR = COLORtrace1
7013  elif MathYAxis == "V-B":
7014  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7015  TempCOLOR = COLORtrace2
7016  elif MathYAxis == "I-A":
7017  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
7018  TempCOLOR = COLORtrace3
7019  elif MathYAxis == "I-B":
7020  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
7021  TempCOLOR = COLORtrace4
7022  else:
7023  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7024  Vaxis_label = str(round(Vaxis_value, 3))
7025  XYca.create_text(x1-3, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
7026  i = i + 1
7027  # Draw vertical grid lines
7028  i = 0
7029  y1 = Y0TXY
7030  y2 = Y0TXY + GRHXY
7031  mg_siz = GRHXY/10.0
7032  mg_inc = mg_siz/5.0
7033  #
7034  while (i < 11):
7035  x = X0LXY + i * GRWXY/10.0
7036  Dline = [x,y1,x,y2]
7037  if (i == 5):
7038  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
7039  k = 0
7040  while (k < 10):
7041  l = 1
7042  while (l < 5):
7043  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
7044  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7045  l = l + 1
7046  k = k + 1
7047  if Xsignal.get() == 1 or Xsignal.get() == 6: #
7048  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7049  Vaxis_label = str(round(Vaxis_value, 3))
7050  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
7051  elif Xsignal.get() == 3 or Xsignal.get() == 7:
7052  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7053  Vaxis_label = str(round(Vaxis_value, 3))
7054  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
7055  elif Xsignal.get() == 2:
7056  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7057  Iaxis_label = str(round(Iaxis_value, 3))
7058  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
7059  elif Xsignal.get() == 4:
7060  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7061  Iaxis_label = str(round(Iaxis_value, 3))
7062  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
7063  elif Xsignal.get() == 5:
7064  TempCOLOR = COLORtrace5
7065  if MathTrace.get() == 2:
7066  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7067  elif MathTrace.get() == 3:
7068  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7069  else:
7070  if MathXAxis == "V-A":
7071  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7072  TempCOLOR = COLORtrace1
7073  elif MathXAxis == "V-B":
7074  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7075  TempCOLOR = COLORtrace2
7076  elif MathXAxis == "I-A":
7077  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7078  TempCOLOR = COLORtrace3
7079  elif MathXAxis == "I-B":
7080  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7081  TempCOLOR = COLORtrace4
7082  else:
7083  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7084  TempCOLOR = COLORtrace5
7085  Vaxis_label = str(round(Vaxis_value, 3))
7086  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
7087  else:
7088  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7089  if Xsignal.get() == 1 or Xsignal.get() == 6:
7090  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7091  Vaxis_label = str(round(Vaxis_value, 3))
7092  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
7093  elif Xsignal.get() == 3 or Xsignal.get() == 7:
7094  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7095  Vaxis_label = str(round(Vaxis_value, 3))
7096  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
7097  elif Xsignal.get() == 2:
7098  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7099  Iaxis_label = str(round(Iaxis_value, 3))
7100  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
7101  elif Xsignal.get() == 4:
7102  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7103  Iaxis_label = str(round(Iaxis_value, 3))
7104  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
7105  elif Xsignal.get() == 5:
7106  TempCOLOR = COLORtrace5
7107  if MathTrace.get() == 2:
7108  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7109  elif MathTrace.get() == 3:
7110  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7111  else:
7112  if MathXAxis == "V-A":
7113  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7114  TempCOLOR = COLORtrace1
7115  elif MathXAxis == "V-B":
7116  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7117  TempCOLOR = COLORtrace2
7118  elif MathXAxis == "I-A":
7119  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7120  TempCOLOR = COLORtrace3
7121  elif MathXAxis == "I-B":
7122  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7123  TempCOLOR = COLORtrace4
7124  else:
7125  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7126  Vaxis_label = str(round(Vaxis_value, 3))
7127  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
7128  i = i + 1
7129 # Draw traces
7130  if len(TXYline) > 4: # Avoid writing lines with 1 coordinate
7131  if Xsignal.get() == 1:
7132  XYca.create_line(TXYline, fill=COLORtrace1, width=TRACEwidth.get())
7133  elif Xsignal.get() == 2:
7134  XYca.create_line(TXYline, fill=COLORtrace3, width=TRACEwidth.get())
7135  elif Xsignal.get() == 3:
7136  XYca.create_line(TXYline, fill=COLORtrace2, width=TRACEwidth.get())
7137  elif Xsignal.get() == 4:
7138  XYca.create_line(TXYline, fill=COLORtrace4, width=TRACEwidth.get())
7139  elif Xsignal.get() == 5 or Ysignal.get() == 5:
7140  XYca.create_line(TXYline, fill=COLORtrace5, width=TRACEwidth.get())
7141  if len(TXYRline) > 4 and ShowRXY.get() == 1:
7142  XYca.create_line(TXYRline, fill=COLORtraceR1, width=TRACEwidth.get())
7143 # Draw Histogram Traces
7144  if Xsignal.get() == 6:
7145  MakeHistogram()
7146  b = 0
7147  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7148  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
7149  y1 = Y0TXY + GRHXY
7150  # print Yconv1, y1
7151  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7152  while b < 4999: #
7153  if HistAsPercent == 1: # convert to percent of total sample count
7154  ylo = float(HBuffA[0][b]) / len(VBuffA)
7155  ylo = ylo * 100.0
7156  else:
7157  ylo = HBuffA[0][b] #
7158  ylo = int(y1 - (Yconv1 * ylo))
7159  if ylo > Ymax:
7160  ylo = Ymax
7161  if ylo < Ymin:
7162  ylo = Ymin
7163  xlo = HBuffA[1][b] - CHAOffset
7164  xlo = int(c2 + Xconv1 * xlo)
7165  Dline = [xlo,y1,xlo,ylo]
7166  XYca.create_line(Dline, fill=COLORtrace1)
7167  b = b + 1
7168  if Xsignal.get() == 7:
7169  MakeHistogram()
7170  b = 0
7171  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7172  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
7173  y1 = Y0TXY + GRHXY
7174  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7175  while b < 4999: #
7176  if HistAsPercent == 1: # convert to percent
7177  ylo = float(HBuffB[0][b]) / len(VBuffB)
7178  ylo = ylo * 100.0
7179  else:
7180  ylo = HBuffB[0][b]
7181  ylo = int(y1 - Yconv1 * ylo)
7182  if ylo > Ymax:
7183  ylo = Ymax
7184  if ylo < Ymin:
7185  ylo = Ymin
7186  xlo = HBuffB[1][b] - CHBOffset
7187  xlo = int(c2 + Xconv1 * xlo)
7188  Dline = [xlo,y1,xlo,ylo]
7189  XYca.create_line(Dline, fill=COLORtrace2)
7190  b = b + 1
7191 # Draw X - Y Cursor lines if required
7192  if Xsignal.get() == 1 or Xsignal.get() == 6:
7193  Xconv1 = float(GRWXY/10) / CH1pdvRange
7194  Xoffset1 = CHAOffset
7195  COLORXmarker = COLORtrace1
7196  X_label = " V"
7197  if Xsignal.get() == 2:
7198  Xconv1 = float(GRWXY/10) / CH1IpdvRange
7199  Xoffset1 = CHAIOffset
7200  COLORXmarker = COLORtrace3
7201  X_label = " mA"
7202  if Xsignal.get() == 3 or Xsignal.get() == 7:
7203  Xconv1 = float(GRWXY/10) / CH2pdvRange
7204  Xoffset1 = CHBOffset
7205  COLORXmarker = COLORtrace2
7206  X_label = " V"
7207  if Xsignal.get() == 4:
7208  Xconv1 = float(GRWXY/10) / CH2IpdvRange
7209  Xoffset1 = CHBIOffset
7210  COLORmarker = COLORtrace4
7211  X_label = " mA"
7212  if Xsignal.get() == 5:
7213  X_label = MathXUnits
7214  if MathXAxis == "V-A":
7215  Xconv1 = float(GRWXY/10) / CH1pdvRange
7216  Xoffset1 = CHAOffset
7217  COLORXmarker = COLORtrace1
7218  elif MathXAxis == "V-B":
7219  Xconv1 = float(GRWXY/10) / CH2pdvRange
7220  Xoffset1 = CHBOffset
7221  COLORXmarker = COLORtrace2
7222  elif MathXAxis == "I-A":
7223  Xconv1 = float(GRWXY/10) / CH1IpdvRange
7224  Xoffset1 = CHAIOffset
7225  COLORXmarker = COLORtrace3
7226  elif MathXAxis == "I-B":
7227  Xconv1 = float(GRWXY/10) / CH2IpdvRange
7228  Xoffset1 = CHBIOffset
7229  COLORXmarker = COLORtrace4
7230  else:
7231  Xconv1 = float(GRWXY/10) / CH1pdvRange
7232  Xoffset1 = CHAOffset
7233  COLORXmarker = COLORtrace1
7234 #
7235  if Ysignal.get() == 1 or Ysignal.get() == 6:
7236  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7237  Yoffset1 = CHAOffset
7238  COLORYmarker = COLORtrace1
7239  Y_label = " V"
7240  if Ysignal.get() == 2:
7241  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7242  Yoffset1 = CHAIOffset
7243  COLORYmarker = COLORtrace3
7244  Y_label = " mA"
7245  if Ysignal.get() == 3 or Ysignal.get() == 7:
7246  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
7247  Yoffset1 = CHBOffset
7248  COLORYmarker = COLORtrace2
7249  Y_label = " V"
7250  if Ysignal.get() == 4:
7251  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7252  Yoffset1 = CHBIOffset
7253  COLORYmarker = COLORtrace4
7254  Y_label = " mA"
7255  if Ysignal.get() == 5:
7256  Y_label = MathYUnits
7257  if MathYAxis == "V-A":
7258  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7259  Yoffset1 = CHAOffset
7260  COLORYmarker = COLORtrace1
7261  elif MathYAxis == "V-B":
7262  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
7263  Yoffset1 = CHBOffset
7264  COLORYmarker = COLORtrace2
7265  elif MathYAxis == "I-A":
7266  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7267  Yoffset1 = CHAIOffset
7268  COLORYmarker = COLORtrace3
7269  elif MathYAxis == "I-B":
7270  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7271  Yoffset1 = CHBIOffset
7272  COLORYmarker = COLORtrace4
7273  else:
7274  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7275  Yoffset1 = CHAOffset
7276  COLORYmarker = COLORtrace1
7277  if ShowXCur.get() > 0:
7278  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
7279  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
7280  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
7281  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
7282  XString = ' {0:.3f} '.format(xvolts)
7283  V_label = XString + X_label
7284  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
7285  if ShowYCur.get() > 0:
7286  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
7287  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
7288  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
7289  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
7290  V1String = ' {0:.3f} '.format(-yvolts)
7291  V_label = V1String + Y_label
7292  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
7293  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
7294  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
7295  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
7296  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
7297  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
7298  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
7299  XString = ' {0:.3f} '.format(xvolts)
7300  V_label = XString + X_label
7301  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
7302  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
7303  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
7304  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
7305  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
7306  V1String = ' {0:.3f} '.format(-yvolts)
7307  V_label = V1String + Y_label
7308  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
7309 #
7310 # General information on top of the grid
7311 # Sweep information
7312  sttxt = "Running"
7313  if TRACEmodeTime.get() == 1:
7314  sttxt = sttxt + " Averaging"
7315  if ManualTrigger.get() == 1:
7316  sttxt = "Manual Trigger"
7317  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
7318  sttxt = "Stopped"
7319  if ScreenXYrefresh.get() == 1:
7320  sttxt = sttxt + " Persistance ON"
7321  # Delete text at bottom of screen
7322  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
7323  for n in de:
7324  XYca.delete(n)
7325  # Delete text at top of screen
7326  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
7327  for n in de:
7328  XYca.delete(n)
7329  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7330  x = X0LXY
7331  y = 12
7332  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7333  # digital I/O indicators
7334  x2 = X0LXY + GRWXY
7335  BoxColor = "#808080" # gray
7336  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
7337  if D0.get() == 0 and D4.get() == 0:
7338  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
7339  if Dval[0] == 1:
7340  BoxColor = "#00ff00" # 100% green
7341  elif Dval[0] == 0:
7342  BoxColor = "#ff0000" # 100% red
7343  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
7344  else:
7345  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
7346  if D1.get() == 0 and D5.get() == 0:
7347  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
7348  if Dval[0] == 1:
7349  BoxColor = "#00ff00" # 100% green
7350  elif Dval[0] == 0:
7351  BoxColor = "#ff0000" # 100% red
7352  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
7353  else:
7354  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
7355  if D2.get() == 0 and D6.get() == 0:
7356  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
7357  if Dval[0] == 1:
7358  BoxColor = "#00ff00" # 100% green
7359  elif Dval[0] == 0:
7360  BoxColor = "#ff0000" # 100% red
7361  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
7362  else:
7363  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
7364  if D3.get() == 0 and D7.get() == 0:
7365  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
7366  if Dval[0] == 1:
7367  BoxColor = "#00ff00" # 100% green
7368  elif Dval[0] == 0:
7369  BoxColor = "#ff0000" # 100% red
7370  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
7371  else:
7372  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
7373  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
7374  # print period and frequency of displayed channels
7375  txt = " "
7376  if Xsignal.get() == 1 or Xsignal.get() == 3:
7377  FindRisingEdge(VBuffA, VBuffB)
7378  if Xsignal.get() == 1:
7379  if MeasAHW.get() == 1:
7380  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
7381  if MeasALW.get() == 1:
7382  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
7383  if MeasADCy.get() == 1:
7384  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
7385  if MeasAPER.get() == 1:
7386  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
7387  if MeasAFREQ.get() == 1:
7388  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
7389  if Xsignal.get() == 3:
7390  if MeasBHW.get() == 1:
7391  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
7392  if MeasBLW.get() == 1:
7393  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
7394  if MeasBDCy.get() == 1:
7395  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
7396  if MeasBPER.get() == 1:
7397  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
7398  if MeasBFREQ.get() == 1:
7399  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
7400  if MeasPhase.get() == 1:
7401  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
7402 
7403  x = X0LXY
7404  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
7405  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7406  txt = " "
7407  if Xsignal.get() == 1 or Ysignal.get() == 1 or Xsignal.get() == 6:
7408  # Channel A information
7409  txt = "CHA: "
7410  txt = txt + str(CH1pdvRange) + " V/div"
7411  if MeasDCV1.get() == 1:
7412  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
7413  if MeasMaxV1.get() == 1:
7414  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
7415  if MeasTopV1.get() == 1:
7416  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
7417  if MeasMinV1.get() == 1:
7418  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
7419  if MeasBaseV1.get() == 1:
7420  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
7421  if MeasMidV1.get() == 1:
7422  MidV1 = (MaxV1+MinV1)/2
7423  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
7424  if MeasPPV1.get() == 1:
7425  PPV1 = MaxV1-MinV1
7426  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
7427  if MeasRMSV1.get() == 1:
7428  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
7429  if MeasUserA.get() == 1:
7430  try:
7431  TempValue = eval(UserAString)
7432  V1String = ' {0:.4f} '.format(TempValue)
7433  except:
7434  V1String = "####"
7435  txt = txt + UserALabel + " = " + V1String
7436  if Xsignal.get() == 2:
7437  txt = "CHA: "
7438  txt = txt + str(CH1IpdvRange) + " mA/div"
7439  elif (Xsignal.get() == 2):
7440  txt = txt + "CHA: "
7441  txt = txt + str(CH1IpdvRange) + " mA/div"
7442  if Xsignal.get() == 2 or Ysignal.get() == 2:
7443  if MeasDCI1.get() == 1:
7444  V1String = ' {0:.2f} '.format(DCI1)
7445  txt = txt + " AvgI = " + V1String
7446  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
7447  try:
7448  Resvalue = (DCV1/DCI1)*1000
7449  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7450  except:
7451  txt = txt + " Res = OverRange"
7452  if MeasMaxI1.get() == 1:
7453  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
7454  if MeasMinI1.get() == 1:
7455  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
7456  if MeasMidI1.get() == 1:
7457  MidI1 = (MaxI1+MinI1)/2
7458  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
7459  if MeasPPI1.get() == 1:
7460  PPI1 = MaxI1-MinI1
7461  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
7462  if MeasRMSI1.get() == 1:
7463  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
7464 
7465  x = X0LXY
7466  y = Y0TXY+GRHXY+int(4*FontSize) # 32
7467  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7468  txt= " "
7469  # Channel B information
7470  if Xsignal.get() == 3 or Ysignal.get() == 3 or Xsignal.get() == 7:
7471  txt = "CHB: "
7472  txt = txt + str(CH2pdvRange) + " V/div"
7473  if MeasDCV2.get() == 1:
7474  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
7475  if MeasMaxV2.get() == 1:
7476  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
7477  if MeasTopV2.get() == 1:
7478  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
7479  if MeasMinV2.get() == 1:
7480  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
7481  if MeasBaseV2.get() == 1:
7482  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
7483  if MeasMidV2.get() == 1:
7484  MidV2 = (MaxV2+MinV2)/2
7485  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
7486  if MeasPPV2.get() == 1:
7487  PPV2 = MaxV2-MinV2
7488  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
7489  if MeasRMSV2.get() == 1:
7490  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
7491  if MeasUserB.get() == 1:
7492  try:
7493  TempValue = eval(UserBString)
7494  V1String = ' {0:.4f} '.format(TempValue)
7495  except:
7496  V1String = "####"
7497  txt = txt + UserBLabel + " = " + V1String
7498  if Xsignal.get() == 4:
7499  txt = "CHB: "
7500  txt = txt + str(CH2IpdvRange) + " mA/div"
7501  elif Xsignal.get() == 4:
7502  txt = txt + "CHB: "
7503  txt = txt + str(CH2IpdvRange) + " mA/div"
7504  if Xsignal.get() == 4 or Ysignal.get() == 4:
7505  if MeasDCI2.get() == 1:
7506  V1String = ' {0:.2f} '.format(DCI2)
7507  txt = txt + " AvgI = " + V1String
7508  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
7509  try:
7510  Resvalue = (DCV2/DCI2)*1000
7511  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7512  except:
7513  txt = txt + " Res = OverRange"
7514  if MeasMaxI2.get() == 1:
7515  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
7516  if MeasMinI2.get() == 1:
7517  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
7518  if MeasMidI2.get() == 1:
7519  MidI2 = (MaxI2+MinI2)/2
7520  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
7521  if MeasPPI2.get() == 1:
7522  PPI2 = MaxI2-MinI2
7523  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
7524  if MeasRMSI2.get() == 1:
7525  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
7526 
7527  x = X0LXY
7528  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
7529  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7530 #
7532  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7533 
7534  if MarkerScale.get() != 1:
7535  MarkerScale.set(1)
7536  CHAlab.config(style="Rtrace1.TButton")
7537  CHBlab.config(style="Strace2.TButton")
7538  CHAIlab.config(style="Strace3.TButton")
7539  CHBIlab.config(style="Strace4.TButton")
7540  else:
7541  MarkerScale.set(0)
7542 #
7544  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7545 
7546  if MarkerScale.get() != 3:
7547  MarkerScale.set(3)
7548  CHAlab.config(style="Strace1.TButton")
7549  CHBlab.config(style="Strace2.TButton")
7550  CHAIlab.config(style="Rtrace3.TButton")
7551  CHBIlab.config(style="Strace4.TButton")
7552  else:
7553  MarkerScale.set(0)
7554 
7556  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7557 
7558  if MarkerScale.get() != 2:
7559  MarkerScale.set(2)
7560  CHAlab.config(style="Strace1.TButton")
7561  CHBlab.config(style="Rtrace2.TButton")
7562  CHAIlab.config(style="Strace3.TButton")
7563  CHBIlab.config(style="Strace4.TButton")
7564  else:
7565  MarkerScale.set(0)
7566 
7568  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7569 
7570  if MarkerScale.get() != 3:
7571  MarkerScale.set(4)
7572  CHAlab.config(style="Strace1.TButton")
7573  CHBlab.config(style="Strace2.TButton")
7574  CHAIlab.config(style="Strace3.TButton")
7575  CHBIlab.config(style="Rtrace4.TButton")
7576  else:
7577  MarkerScale.set(0)
7578 #
7580  global MarkerXYScale, CHAxylab, CHBxylab
7581 
7582  MarkerXYScale.set(1)
7583  CHAxylab.config(style="Rtrace1.TButton")
7584  CHBxylab.config(style="Strace2.TButton")
7585 
7587  global MarkerXYScale, CHAxylab, CHBxylab
7588 
7589  MarkerXYScale.set(2)
7590  CHBxylab.config(style="Rtrace2.TButton")
7591  CHAxylab.config(style="Strace1.TButton")
7592 #
7594  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
7595 
7596  TCursor = event.x
7597  VCursor = event.y
7598  if RUNstatus.get() == 0:
7600  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
7601 
7603  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
7604  global MeasGateStatus, MeasGateLeft, MeasGateRight, TIMEdiv, GRW
7605 
7606  ShiftKeyDwn = event.state & 1
7607  if event.widget == ca:
7608  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
7609  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
7610  TCursor = TCursor + event.delta/100
7611  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
7612  VCursor = VCursor - event.delta/100
7613  else:
7614  if MeasGateStatus.get() == 1:
7615  Tstep = (TIMEdiv / GRW) / 10 # time in mS per pixel
7616  if ShiftKeyDwn == 0:
7617  MeasGateLeft = MeasGateLeft + (event.delta * Tstep) #+ HoldOff
7618  if ShiftKeyDwn == 1:
7619  MeasGateRight = MeasGateRight + (event.delta * Tstep) #+ HoldOff
7620  try:
7621  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
7622  except:
7623  donothing()
7624  if RUNstatus.get() == 0:
7626 
7627 def onCanvasUpArrow(event):
7628  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
7629 
7630  shift_key = event.state & 1
7631  if event.widget == ca:
7632  if ShowVCur.get() > 0 and shift_key == 0:
7633  VCursor = VCursor - 1
7634  elif ShowVCur.get() > 0 and shift_key == 1:
7635  VCursor = VCursor - 5
7636  if RUNstatus.get() == 0:
7638  try:
7639  if event.widget == XYca:
7640  if ShowYCur.get() > 0 and shift_key == 0:
7641  YCursor = YCursor - 1
7642  elif ShowYCur.get() > 0 and shift_key == 1:
7643  YCursor = YCursor - 5
7644  if RUNstatus.get() == 0:
7645  UpdateXYScreen()
7646  except:
7647  donothing()
7648  try:
7649  if event.widget == Freqca:
7650  if ShowdBCur.get() > 0 and shift_key == 0:
7651  dBCursor = dBCursor - 1
7652  elif ShowdBCur.get() > 0 and shift_key == 1:
7653  dBCursor = dBCursor - 5
7654  if RUNstatus.get() == 0:
7656  except:
7657  donothing()
7658  try:
7659  if event.widget == Bodeca:
7660  if ShowBdBCur.get() > 0 and shift_key == 0:
7661  BdBCursor = BdBCursor - 1
7662  elif ShowBdBCur.get() > 0 and shift_key == 1:
7663  BdBCursor = BdBCursor - 5
7664  if RUNstatus.get() == 0:
7666  except:
7667  donothing()
7668 
7670  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
7671 
7672  shift_key = event.state & 1
7673  if event.widget == ca:
7674  if ShowVCur.get() > 0 and shift_key == 0:
7675  VCursor = VCursor + 1
7676  elif ShowVCur.get() > 0 and shift_key == 1:
7677  VCursor = VCursor + 5
7678  if RUNstatus.get() == 0:
7680  try:
7681  if event.widget == XYca:
7682  if ShowYCur.get() > 0 and shift_key == 0:
7683  YCursor = YCursor + 1
7684  elif ShowYCur.get() > 0 and shift_key == 1:
7685  YCursor = YCursor + 5
7686  if RUNstatus.get() == 0:
7687  UpdateXYScreen()
7688  except:
7689  donothing()
7690  try:
7691  if event.widget == Freqca:
7692  if ShowdBCur.get() > 0 and shift_key == 0:
7693  dBCursor = dBCursor + 1
7694  elif ShowdBCur.get() > 0 and shift_key == 1:
7695  dBCursor = dBCursor + 5
7696  if RUNstatus.get() == 0:
7698  except:
7699  donothing()
7700  try:
7701  if event.widget == Bodeca:
7702  if ShowBdBCur.get() > 0 and shift_key == 0:
7703  BdBCursor = BdBCursor + 1
7704  elif ShowBdBCur.get() > 0 and shift_key == 1:
7705  BdBCursor = BdBCursor + 5
7706  if RUNstatus.get() == 0:
7708  except:
7709  donothing()
7710 
7712  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
7713 
7714  shift_key = event.state & 1
7715  if event.widget == ca:
7716  if ShowTCur.get() > 0 and shift_key == 0:
7717  TCursor = TCursor - 1
7718  elif ShowTCur.get() > 0 and shift_key == 1:
7719  TCursor = TCursor - 5
7720  if RUNstatus.get() == 0:
7722  try:
7723  if event.widget == XYca:
7724  if ShowXCur.get() > 0 and shift_key == 0:
7725  XCursor = XCursor - 1
7726  elif ShowXCur.get() > 0 and shift_key == 1:
7727  XCursor = XCursor - 5
7728  if RUNstatus.get() == 0:
7729  UpdateXYScreen()
7730  except:
7731  donothing()
7732  try:
7733  if event.widget == Freqca:
7734  if ShowFCur.get() > 0 and shift_key == 0:
7735  FCursor = FCursor - 1
7736  elif ShowFCur.get() > 0 and shift_key == 1:
7737  FCursor = FCursor - 5
7738  if RUNstatus.get() == 0:
7740  except:
7741  donothing()
7742  try:
7743  if event.widget == Bodeca:
7744  if ShowBPCur.get() > 0 and shift_key == 0:
7745  BPCursor = BPCursor - 1
7746  elif ShowBPCur.get() > 0 and shift_key == 1:
7747  BPCursor = BPCursor - 5
7748  if RUNstatus.get() == 0:
7750  except:
7751  donothing()
7752 
7754  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
7755 
7756  shift_key = event.state & 1
7757  if event.widget == ca:
7758  if ShowTCur.get() > 0 and shift_key == 0:
7759  TCursor = TCursor + 1
7760  elif ShowTCur.get() > 0 and shift_key == 1:
7761  TCursor = TCursor + 5
7762  if RUNstatus.get() == 0:
7764  try:
7765  if event.widget == XYca:
7766  if ShowXCur.get() > 0 and shift_key == 0:
7767  XCursor = XCursor + 1
7768  elif ShowXCur.get() > 0 and shift_key == 1:
7769  XCursor = XCursor + 5
7770  if RUNstatus.get() == 0:
7771  UpdateXYScreen()
7772  except:
7773  donothing()
7774  try:
7775  if event.widget == Freqca:
7776  if ShowFCur.get() > 0 and shift_key == 0:
7777  FCursor = FCursor + 1
7778  elif ShowFCur.get() > 0 and shift_key == 1:
7779  FCursor = FCursor + 5
7780  if RUNstatus.get() == 0:
7782  except:
7783  donothing()
7784  try:
7785  if event.widget == Bodeca:
7786  if ShowBPCur.get() > 0 and shift_key == 0:
7787  BPCursor = BPCursor + 1
7788  elif ShowBPCur.get() > 0 and shift_key == 1:
7789  BPCursor = BPCursor + 5
7790  if RUNstatus.get() == 0:
7792  except:
7793  donothing()
7794 
7795 def onCanvasSpaceBar(event):
7796  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
7797 
7798  if event.widget == ca:
7799  if RUNstatus.get() == 0:
7800  BStart()
7801  elif RUNstatus.get() > 0:
7802  BStop()
7803  try:
7804  if event.widget == XYca:
7805  if RUNstatus.get() == 0:
7806  BStart()
7807  elif RUNstatus.get() > 0:
7808  BStop()
7809  except:
7810  donothing()
7811  try:
7812  if event.widget == IAca:
7813  if RUNstatus.get() == 0:
7814  BStart()
7815  elif RUNstatus.get() > 0:
7816  BStop()
7817  except:
7818  donothing()
7819  try:
7820  if event.widget == Freqca:
7821  if RUNstatus.get() == 0:
7822  BStartSA()
7823  elif RUNstatus.get() > 0:
7824  BStopSA()
7825  except:
7826  donothing()
7827  try:
7828  if event.widget == Bodeca:
7829  if RUNstatus.get() == 0:
7830  BStartBP()
7831  elif RUNstatus.get() > 0:
7832  BStopBP()
7833  except:
7834  donothing()
7835 #
7837  global X0L # Left top X value
7838  global Y0T # Left top Y value
7839  global GRW # Screenwidth
7840  global GRH # Screenheight
7841  global FontSize
7842  global ca, MarkerLoc, Mulx
7843  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
7844  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
7845  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
7846  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
7847  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
7848  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
7849  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
7850  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
7851  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
7852  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
7853 
7854  try:
7855  HoldOff = float(eval(HoldOffentry.get()))
7856  if HoldOff < 0:
7857  HoldOff = 0
7858  except:
7859  HoldOffentry.delete(0,END)
7860  HoldOffentry.insert(0, HoldOff)
7861  # get time scale
7862  try:
7863  TIMEdiv = float(eval(TMsb.get()))
7864  except:
7865  TIMEdiv = 0.5
7866  TMsb.delete(0,"end")
7867  TMsb.insert(0,TIMEdiv)
7868  # prevent divide by zero error
7869  if TIMEdiv < 0.0002:
7870  TIMEdiv = 0.01
7871  # add markers only if stopped
7872  if (RUNstatus.get() == 0):
7873  MarkerNum = MarkerNum + 1
7874  # get the vertical ranges
7875  try:
7876  CH1pdvRange = float(eval(CHAsb.get()))
7877  except:
7878  CHAsb.delete(0,END)
7879  CHAsb.insert(0, CH1vpdvRange)
7880  try:
7881  CH2pdvRange = float(eval(CHBsb.get()))
7882  except:
7883  CHBsb.delete(0,END)
7884  CHBsb.insert(0, CH2vpdvRange)
7885  try:
7886  CH1IpdvRange = float(eval(CHAIsb.get()))
7887  except:
7888  CHAIsb.delete(0,END)
7889  CHAIsb.insert(0, CH1IpdvRange)
7890  try:
7891  CH2IpdvRange = float(eval(CHBIsb.get()))
7892  except:
7893  CHBIsb.delete(0,END)
7894  CHBIsb.insert(0, CH2IpdvRange)
7895  # get the vertical offsets
7896  try:
7897  CHAOffset = float(eval(CHAVPosEntry.get()))
7898  except:
7899  CHAVPosEntry.delete(0,END)
7900  CHAVPosEntry.insert(0, CHAOffset)
7901  try:
7902  CHAIOffset = float(eval(CHAIPosEntry.get()))
7903  except:
7904  CHAIPosEntry.delete(0,END)
7905  CHAIPosEntry.insert(0, CHAIOffset)
7906  try:
7907  CHBOffset = float(eval(CHBVPosEntry.get()))
7908  except:
7909  CHBVPosEntry.delete(0,END)
7910  CHBVPosEntry.insert(0, CHBOffset)
7911  try:
7912  CHBIOffset = float(eval(CHBIPosEntry.get()))
7913  except:
7914  CHBIPosEntry.delete(0,END)
7915  CHBIPosEntry.insert(0, CHBIOffset)
7916  # prevent divide by zero error
7917  if CH1pdvRange < 0.001:
7918  CH1pdvRange = 0.001
7919  if CH2pdvRange < 0.001:
7920  CH2pdvRange = 0.001
7921  if CH1IpdvRange < 1.0:
7922  CH1IpdvRange = 1.0
7923  if CH2IpdvRange < 1.0:
7924  CH2IpdvRange = 1.0
7925 #
7926  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
7927  try:
7928  CHMApdvRange = float(eval(CHB_Asb.get()))
7929  except:
7930  CHB_Asb.delete(0,END)
7931  CHB_Asb.insert(0, CHMApdvRange)
7932  try:
7933  CHMBpdvRange = float(eval(CHB_Bsb.get()))
7934  except:
7935  CHB_Bsb.delete(0,END)
7936  CHB_Bsb.insert(0, CHMBpdvRange)
7937  try:
7938  CHMCpdvRange = float(eval(CHB_Csb.get()))
7939  except:
7940  CHB_Csb.delete(0,END)
7941  CHB_Csb.insert(0, CHMCpdvRange)
7942  try:
7943  CHMDpdvRange = float(eval(CHB_Dsb.get()))
7944  except:
7945  CHB_Dsb.delete(0,END)
7946  CHB_Dsb.insert(0, CHMDpdvRange)
7947  YconvMA = float(GRH/10.0) / CHMApdvRange
7948  YconvMB = float(GRH/10.0) / CHMBpdvRange
7949  YconvMC = float(GRH/10.0) / CHMCpdvRange
7950  YconvMD = float(GRH/10.0) / CHMDpdvRange
7951  try:
7952  CHBAOffset = float(eval(CHB_APosEntry.get()))
7953  except:
7954  CHB_APosEntry.delete(0,END)
7955  CHB_APosEntry.insert(0, CHBAOffset)
7956  try:
7957  CHBBOffset = float(eval(CHB_BPosEntry.get()))
7958  except:
7959  CHB_BPosEntry.delete(0,END)
7960  CHB_BPosEntry.insert(0, CHBBOffset)
7961  try:
7962  CHBCOffset = float(eval(CHB_CPosEntry.get()))
7963  except:
7964  CHB_CPosEntry.delete(0,END)
7965  CHB_CPosEntry.insert(0, CHBCOffset)
7966  try:
7967  CHBDOffset = float(eval(CHB_DPosEntry.get()))
7968  except:
7969  CHB_DPosEntry.delete(0,END)
7970  CHB_DPosEntry.insert(0, CHBDOffset)
7971  Yoffset1 = CHAOffset
7972  if MarkerScale.get() == 1:
7973  Yconv1 = float(GRH/10.0) / CH1pdvRange
7974  Yoffset1 = CHAOffset
7975  COLORmarker = COLORtrace1
7976  Units = " V"
7977  elif MarkerScale.get() == 2:
7978  Yconv1 = float(GRH/10.0) / CH2pdvRange
7979  Yoffset1 = CHBOffset
7980  COLORmarker = COLORtrace2
7981  Units = " V"
7982  elif MarkerScale.get() == 3:
7983  Yconv1 = float(GRH/10.0) / CH1IpdvRange
7984  Yoffset1 = CHAIOffset
7985  COLORmarker = COLORtrace3
7986  Units = " mA"
7987  elif MarkerScale.get() == 4:
7988  Yconv1 = float(GRH/10.0) / CH2IpdvRange
7989  Yoffset1 = CHBIOffset
7990  COLORmarker = COLORtrace4
7991  Units = " mA"
7992  # Aanalog Mux settings
7993  elif MarkerScale.get() == 5:
7994  Yconv1 = float(GRH/10.0) / CHMApdvRange
7995  Yoffset1 = CHBAOffset
7996  COLORmarker = COLORtrace2
7997  Units = " V"
7998  elif MarkerScale.get() == 6:
7999  Yconv1 = float(GRH/10.0) / CHMBpdvRange
8000  Yoffset1 = CHBBOffset
8001  COLORmarker = COLORtrace6
8002  Units = " V"
8003  elif MarkerScale.get() == 7:
8004  Yconv1 = float(GRH/10.0) / CHMCpdvRange
8005  Yoffset1 = CHBCOffset
8006  COLORmarker = COLORtrace7
8007  Units = " V"
8008  elif MarkerScale.get() == 8:
8009  Yconv1 = float(GRH/10.0) / CHMDpdvRange
8010  Yoffset1 = CHBDOffset
8011  COLORmarker = COLORtrace4
8012  Units = " V"
8013  else:
8014  Yconv1 = float(GRH/10.0) / CH1pdvRange
8015  Yoffset1 = CHAOffset
8016  COLORmarker = COLORtrace1
8017  Units = " V"
8018  #
8019  c1 = GRH / 2.0 + Y0T # fixed correction channel A
8020  xc1 = GRW / 2.0 + X0L
8021  c2 = GRH / 2.0 + Y0T # fixed correction channel B
8022  # draw X at marker point and number
8023  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
8024  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
8025  # DISsamples = (10.0 * TIMEdiv) # grid width in time
8026  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
8027  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
8028  #
8029  Tpoint = Tpoint/Mulx
8030  if Tpoint >= 1000:
8031  axis_value = Tpoint / 1000.0
8032  TString = ' {0:.2f} '.format(axis_value) + " S "
8033  if Tpoint < 1000 and Tpoint >= 1:
8034  axis_value = Tpoint
8035  TString = ' {0:.2f} '.format(axis_value) + " mS "
8036  if Tpoint < 1:
8037  axis_value = Tpoint * 1000.0
8038  TString = ' {0:.2f} '.format(axis_value) + " uS "
8039  # TString = ' {0:.2f} '.format(Tpoint)
8040  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
8041  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
8042  V1String = ' {0:.3f} '.format(-yvolts)
8043  else:
8044  V1String = ' {0:.1f} '.format(-yvolts)
8045  V_label = str(MarkerNum) + " " + TString + V1String
8046  V_label = V_label + Units
8047  if MarkerNum > 1:
8048  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
8049  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
8050  else:
8051  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
8052  DT = (Tpoint-PrevT)
8053  if Tpoint >= 1000:
8054  axis_value = DT / 1000.0
8055  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
8056  if Tpoint < 1000 and Tpoint >= 1:
8057  axis_value = DT
8058  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
8059  if Tpoint < 1:
8060  axis_value = DT * 1000.0
8061  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
8062  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
8063  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
8064  V_label = V_label + " Delta " + DeltaT + DeltaV
8065  V_label = V_label + Units
8066  V_label = V_label + ", Freq " + DFreq + " KHz"
8067  # place in upper left unless specified otherwise
8068  x = X0L + 5
8069  y = Y0T + 3 + (MarkerNum*10)
8070  Justify = 'w'
8071  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
8072  x = X0L + GRW - 5
8073  y = Y0T + 3 + (MarkerNum*10)
8074  Justify = 'e'
8075  if MarkerLoc == 'LL' or MarkerLoc == 'll':
8076  x = X0L + 5
8077  y = Y0T + GRH + 3 - (MarkerNum*10)
8078  Justify = 'w'
8079  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
8080  x = X0L + GRW - 5
8081  y = Y0T + GRH + 3 - (MarkerNum*10)
8082  Justify = 'e'
8083  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
8084  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
8085  PrevV = yvolts
8086  PrevT = Tpoint
8087  else:
8088  if MeasGateStatus.get() == 1:
8089  #DISsamples = (10.0 * TIMEdiv) # grid width in time
8090  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
8091  if MeasGateNum == 0:
8092  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
8093  MeasGateNum = 1
8094  else:
8095  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
8096  MeasGateNum = 0
8097  LeftGate = X0L + MeasGateLeft / Tstep
8098  RightGate = X0L + MeasGateRight / Tstep
8099  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
8100  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
8101 
8102 #
8103 def onCanvasOne(event):
8104  global ShowC1_V
8105 
8106  if ShowC1_V.get() == 0:
8107  ShowC1_V.set(1)
8108  else:
8109  ShowC1_V.set(0)
8110 #
8111 def onCanvasTwo(event):
8112  global ShowC2_V
8113 
8114  if ShowC2_V.get() == 0:
8115  ShowC2_V.set(1)
8116  else:
8117  ShowC2_V.set(0)
8118 #
8119 def onCanvasThree(event):
8120  global ShowC1_I
8121 
8122  if ShowC1_I.get() == 0:
8123  ShowC1_I.set(1)
8124  else:
8125  ShowC1_I.set(0)
8126 #
8127 def onCanvasFour(event):
8128  global ShowC2_I
8129 
8130  if ShowC2_I.get() == 0:
8131  ShowC2_I.set(1)
8132  else:
8133  ShowC2_I.set(0)
8134 #
8135 def onCanvasFive(event):
8136  global MathTrace
8137 
8138  MathTrace.set(1)
8139 #
8140 def onCanvasSix(event):
8141  global MathTrace
8142 
8143  MathTrace.set(2)
8144 #
8145 def onCanvasSeven(event):
8146  global MathTrace
8147 
8148  MathTrace.set(3)
8149 #
8150 def onCanvasEight(event):
8151  global MathTrace
8152 
8153  MathTrace.set(10)
8154 #
8155 def onCanvasNine(event):
8156  global MathTrace
8157 
8158  MathTrace.set(12)
8159 #
8160 def onCanvasZero(event):
8161  global MathTrace
8162 
8163  MathTrace.set(0)
8164 #
8165 def onCanvasTrising(event):
8166  global TgEdge
8167 
8168  TgEdge.set(0)
8169 #
8170 def onCanvasTfalling(event):
8171  global TgEdge
8172 
8173  TgEdge.set(1)
8174 #
8175 def onCanvasSnap(event):
8176 
8177  BSnapShot()
8178 #
8179 def onCanvasAverage(event):
8180  global TRACEmodeTime
8181 
8182  if TRACEmodeTime.get() == 0:
8183  TRACEmodeTime.set(1)
8184  else:
8185  TRACEmodeTime.set(0)
8186 #
8187 def onCanvasShowTcur(event):
8188  global ShowTCur
8189 
8190  if ShowTCur.get() == 0:
8191  ShowTCur.set(1)
8192  else:
8193  ShowTCur.set(0)
8194 #
8195 def onCanvasShowVcur(event):
8196  global ShowVCur
8197 
8198  if ShowVCur.get() == 0:
8199  ShowVCur.set(1)
8200  else:
8201  ShowVCur.set(0)
8202 #
8204  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
8205 
8206  XCursor = event.x
8207  YCursor = event.y
8208  if RUNstatus.get() == 0:
8209  UpdateXYScreen()
8210  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
8211 #
8213  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
8214  if event.widget == XYca:
8215  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
8216  ShiftKeyDwn = event.state & 1
8217  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
8218  XCursor = XCursor + event.delta/100
8219  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
8220  YCursor = YCursor - event.delta/100
8221  if RUNstatus.get() == 0:
8222  UpdateXYScreen()
8223 #
8225  global X0LXY # Left top X value
8226  global Y0TXY # Left top Y value
8227  global GRWXY # Screenwidth
8228  global GRHXY # Screenheight
8229  global FontSize
8230  global XYca
8231  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
8232  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
8233  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
8234  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
8235  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
8236  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
8237  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
8238  # add markers only if stopped
8239  #
8240  if (RUNstatus.get() == 0):
8241  MarkerNum = MarkerNum + 1
8242  try:
8243  CH1pdvRange = float(eval(CHAsbxy.get()))
8244  except:
8245  CHAsbxy.delete(0,END)
8246  CHAsbxy.insert(0, CH1vpdvRange)
8247  try:
8248  CH2pdvRange = float(eval(CHBsbxy.get()))
8249  except:
8250  CHBsb.delete(0,END)
8251  CHBsb.insert(0, CH2vpdvRange)
8252  try:
8253  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8254  except:
8255  CHAIsbxy.delete(0,END)
8256  CHAIsbxy.insert(0, CH1IpdvRange)
8257  try:
8258  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8259  except:
8260  CHBIsbxy.delete(0,END)
8261  CHBIsbxy.insert(0, CH2IpdvRange)
8262  # get the vertical offsets
8263  try:
8264  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8265  except:
8266  CHAVPosEntryxy.delete(0,END)
8267  CHAVPosEntryxy.insert(0, CHAOffset)
8268  try:
8269  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8270  except:
8271  CHAIPosEntryxy.delete(0,END)
8272  CHAIPosEntryxy.insert(0, CHAIOffset)
8273  try:
8274  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8275  except:
8276  CHBVPosEntryxy.delete(0,END)
8277  CHBVPosEntryxy.insert(0, CHBOffset)
8278  try:
8279  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8280  except:
8281  CHBIPosEntryxy.delete(0,END)
8282  CHBIPosEntryxy.insert(0, CHBIOffset)
8283  # prevent divide by zero error
8284  if CH1pdvRange < 0.001:
8285  CH1pdvRange = 0.001
8286  if CH2pdvRange < 0.001:
8287  CH2pdvRange = 0.001
8288  if CH1IpdvRange < 1.0:
8289  CH1IpdvRange = 1.0
8290  if CH2IpdvRange < 1.0:
8291  CH2IpdvRange = 1.0
8292  try:
8293  HoldOff = float(eval(HoldOffentry.get()))
8294  if HoldOff < 0:
8295  HoldOff = 0
8296  except:
8297  HoldOffentry.delete(0,END)
8298  HoldOffentry.insert(0, HoldOff)
8299  #
8300  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
8301  Xconv1 = float(GRWXY/10) / CH1pdvRange
8302  Yconv2 = float(GRHXY/10) / CH2pdvRange
8303  Xconv2 = float(GRWXY/10) / CH2pdvRange
8304  # YIconv1 = float(GRH/10) / CH1IpdvRange
8305  # YIconv2 = float(GRH/10) / CH2IpdvRange
8306  COLORmarker = COLORtext
8307  Yoffset1 = CHAOffset
8308  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
8309  xc1 = GRWXY / 2 + X0LXY
8310  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
8311  # draw X at marker point and number
8312  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
8313  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
8314  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
8315  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
8316  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
8317  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
8318  VyString = ' {0:.3f} '.format(-yvolts)
8319  VxString = ' {0:.3f} '.format(-xvolts)
8320  V_label = str(MarkerNum) + " " + VxString + " V, " + VyString + " V"
8321  if MarkerNum > 1:
8322  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
8323  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
8324  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
8325  x = X0LXY + 5
8326  y = Y0TXY + 3 + (MarkerNum*10)
8327  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
8328  PrevY = yvolts
8329  PrevX = xvolts
8330  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
8331  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
8332  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
8333  VyString = ' {0:.3f} '.format(-yvolts)
8334  VxString = ' {0:.3f} '.format(-xvolts)
8335  V_label = str(MarkerNum) + " " + VxString + " V, " + VyString + " V"
8336  if MarkerNum > 1:
8337  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
8338  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
8339  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
8340  x = X0LXY + 5
8341  y = Y0TXY + 3 + (MarkerNum*10)
8342  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
8343  PrevY = yvolts
8344  PrevX = xvolts
8345 #
8346 def Wrap(InArray, WrFactor):
8347  # Build new array by skipping WrFactor samples and wrapping back around
8348  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
8349  # effectively multiplies the frequency content by WrFactor
8350  OutArray = []
8351  OutArray = numpy.array(OutArray)
8352  InArray = numpy.array(InArray)
8353  EndIndex = len(InArray)
8354  StartIndex = 0
8355  while StartIndex < WrFactor:
8356  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
8357  StartIndex = StartIndex + 1
8358  return OutArray
8359 #
8360 def UnWrap(InArray, WrFactor):
8361  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
8362  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
8363  # effectively divided the frequency content by WrFactor
8364  OutArray = []
8365  InArray = numpy.array(InArray)
8366  EndIndex = int(len(InArray)/WrFactor)
8367  StartIndex = 0
8368  while StartIndex < EndIndex:
8369  LoopIndex = 0
8370  while LoopIndex < WrFactor:
8371  OutArray.append(InArray[StartIndex+LoopIndex])
8372  LoopIndex = LoopIndex + 1
8373  StartIndex = StartIndex + 1
8374  OutArray = numpy.array(OutArray)
8375  return OutArray
8376 #
8377 def Write_WAV(data, repeat, filename):
8378  global SAMPLErate
8379  # write data array to mono .wav file 100KSPS
8380  # copy buffer repeat times in output file
8381  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
8382  wavfile = wave.open(filename, "w")
8383  nchannels = 1
8384  sampwidth = 2
8385  framerate = SAMPLErate
8386  amplitude = 32766
8387  nframes = len(data)
8388  comptype = "NONE"
8389  compname = "not compressed"
8390  wavfile.setparams((nchannels,
8391  sampwidth,
8392  framerate,
8393  nframes,
8394  comptype,
8395  compname))
8396  # Normalize data
8397  ArrN = numpy.array(data)
8398  ArrN /= numpy.max(numpy.abs(data))
8399  frames = []
8400  for s in ArrN:
8401  mul = int(s * amplitude)
8402  # print "s: %f mul: %d" % (s, mul)
8403  frames.append(struct.pack('h', mul))
8404  print( len(frames))
8405  frames = ''.join(frames)
8406  print( len(frames))
8407  for x in xrange(0, repeat):
8408  print( x )
8409  wavfile.writeframes(frames)
8410  wavfile.close()
8411 
8412 # =========== Awg functions ==================
8413 def BAWGAAmpl(temp):
8414  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8415  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8416 
8417  try:
8418  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
8419  except:
8420  AWGAAmplEntry.delete(0,"end")
8421  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8422  #
8423  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
8424  if AWGAMode.get() == 0: # Source Voltage measure current mode
8425  if AWGAAmplvalue > 5.00:
8426  AWGAAmplvalue = 5.00
8427  AWGAAmplEntry.delete(0,"end")
8428  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8429  if AWGAAmplvalue < 0.00:
8430  AWGAAmplvalue = 0.00
8431  AWGAAmplEntry.delete(0,"end")
8432  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8433  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
8434  if AWGAMode.get() == 0: # Source Voltage measure current mode
8435  if AWGAAmplvalue > (2.5 / AWGA_Ext_Gain.get()):
8436  AWGAAmplvalue = 2.5 / AWGA_Ext_Gain.get()
8437  AWGAAmplEntry.delete(0,"end")
8438  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8439  if AWGAAmplvalue < (-2.50 / AWGA_Ext_Gain.get()):
8440  AWGAAmplvalue = -2.50 / AWGA_Ext_Gain.get()
8441  AWGAAmplEntry.delete(0,"end")
8442  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8443  if AWGAMode.get() == 1: # Source current measure voltage mode
8444  if AWGAAmplvalue > 200.00:
8445  AWGAAmplvalue = 200.00
8446  AWGAAmplEntry.delete(0,"end")
8447  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8448  if AWGAAmplvalue < -200.00:
8449  AWGAAmplvalue = -200.00
8450  AWGAAmplEntry.delete(0,"end")
8451  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8452 #
8453 def BAWGAOffset(temp):
8454  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8455  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8456 
8457  try:
8458  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
8459  except:
8460  AWGAOffsetEntry.delete(0,"end")
8461  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8462  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
8463  if AWGAMode.get() == 0: # Source Voltage measure current mode
8464  if AWGAOffsetvalue > 5.00:
8465  AWGAOffsetvalue = 5.00
8466  AWGAOffsetEntry.delete(0,"end")
8467  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8468  if AWGAOffsetvalue < 0.00:
8469  AWGAOffsetvalue = 0.00
8470  AWGAOffsetEntry.delete(0,"end")
8471  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8472  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
8473  if AWGAOffsetvalue > (2.50-AWGA_Ext_Offset.get()):
8474  AWGAOffsetvalue = 2.50-AWGA_Ext_Offset.get()
8475  AWGAOffsetEntry.delete(0,"end")
8476  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8477  if AWGAOffsetvalue < (-2.50-AWGA_Ext_Offset.get()):
8478  AWGAOffsetvalue = -2.50-AWGA_Ext_Offset.get()
8479  AWGAOffsetEntry.delete(0,"end")
8480  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8481  if AWGAMode.get() == 1: # Source current measure voltage mode
8482  if AWGAOffsetvalue > 200.00:
8483  AWGAOffsetvalue = 200.00
8484  AWGAOffsetEntry.delete(0,"end")
8485  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8486  if AWGAOffsetvalue < -200.00:
8487  AWGAOffsetvalue = -200.00
8488  AWGAOffsetEntry.delete(0,"end")
8489  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8490 #
8491 def BAWGAFreq(temp):
8492  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X
8493  global BodeScreenStatus, BodeDisp
8494 
8495  try:
8496  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
8497  except:
8498  AWGAFreqEntry.delete(0,"end")
8499  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8500  if AWG_2X.get() == 1:
8501  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
8502  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
8503  AWGAFreqvalue = 90000
8504  AWGAFreqEntry.delete(0,"end")
8505  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8506  else:
8507  if AWGAFreqvalue > 50000: # max freq is 50KHz
8508  AWGAFreqvalue = 50000
8509  AWGAFreqEntry.delete(0,"end")
8510  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8511  else:
8512  if AWGAFreqvalue > 25000: # max freq is 25KHz
8513  AWGAFreqvalue = 25000
8514  AWGAFreqEntry.delete(0,"end")
8515  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8516  if AWGAFreqvalue < 0: # Set negative frequency entry to 0
8517  AWGAFreqvalue = 10
8518  AWGAFreqEntry.delete(0,"end")
8519  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8520  #UpdateAWGA()
8521 
8523  global AWGAPhaseDelay, phasealab, awgaph, awgadel
8524 
8525  if AWGAPhaseDelay.get() == 0:
8526  phasealab.configure(text="Deg")
8527  awgaph.configure(style="WPhase.TRadiobutton")
8528  awgadel.configure(style="GPhase.TRadiobutton")
8529  elif AWGAPhaseDelay.get() == 1:
8530  phasealab.configure(text="mSec")
8531  awgaph.configure(style="GPhase.TRadiobutton")
8532  awgadel.configure(style="WPhase.TRadiobutton")
8533 
8534 def BAWGAPhase(temp):
8535  global AWGAPhaseEntry, AWGAPhasevalue
8536 
8537  try:
8538  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
8539  except:
8540  AWGAPhaseEntry.delete(0,"end")
8541  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8542 
8543  if AWGAPhasevalue > 360: # max phase is 360 degrees
8544  AWGAPhasevalue = 360
8545  AWGAPhaseEntry.delete(0,"end")
8546  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8547  if AWGAPhasevalue < 0: # min phase is 0 degrees
8548  AWGAPhasevalue = 0
8549  AWGAPhaseEntry.delete(0,"end")
8550  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8551 
8552 def BAWGADutyCycle(temp):
8553  global AWGADutyCycleEntry, AWGADutyCyclevalue
8554 
8555  try:
8556  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
8557  except:
8558  AWGADutyCycleEntry.delete(0,"end")
8559  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
8560 
8561  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
8562  AWGADutyCyclevalue = 1
8563  AWGADutyCycleEntry.delete(0,"end")
8564  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
8565  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
8566  AWGADutyCyclevalue = 0
8567  AWGADutyCycleEntry.delete(0,"end")
8568  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
8569  #UpdateAWGA()
8570 
8572  global AWGAShape, AWGAWave, phasealab, duty1lab
8573 
8574  if AWGAShape.get() == 0:
8575  AWGAWave = 'dc'
8576  duty1lab.config(text="%")
8577  BAWGAPhaseDelay()
8578  if AWGAShape.get() == 1:
8579  AWGAWave = 'sine'
8580  duty1lab.config(text="%")
8581  BAWGAPhaseDelay()
8582  if AWGAShape.get() == 2:
8583  AWGAWave = 'triangle'
8584  duty1lab.config(text="%")
8585  BAWGAPhaseDelay()
8586  if AWGAShape.get() == 3:
8587  AWGAWave = 'sawtooth'
8588  duty1lab.config(text="%")
8589  BAWGAPhaseDelay()
8590  if AWGAShape.get() == 4:
8591  AWGAWave = 'square'
8592  duty1lab.config(text="%")
8593  BAWGAPhaseDelay()
8594  if AWGAShape.get() == 5:
8595  AWGAWave = 'stairstep'
8596  duty1lab.config(text="%")
8597  BAWGAPhaseDelay()
8598  if AWGAShape.get() > 5:
8599  AWGAWave = 'arbitrary'
8600  # UpdateAWGA()
8601 
8603  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X
8604 
8605  # Read values from CVS file
8606  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
8607  try:
8608  CSVFile = open(filename)
8609  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
8610  CSVFile.seek(0)
8611  #csv_f = csv.reader(CSVFile, dialect)
8612  csv_f = csv.reader(CSVFile, csv.excel)
8613  except:
8614  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
8615  # print csv_f.dialect
8616  AWGAwaveform = []
8617  ColumnNum = 0
8618  ColumnSel = 0
8619  RowNum = 0
8620  for row in csv_f:
8621  # print 'found row = ', row
8622  if len(row) > 1 and ColumnSel == 0:
8623  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
8624  ColumnNum = int(RequestColumn) - 1
8625  ColumnLen = str(len(row))
8626  ColumnSel = 1
8627  try:
8628  colnum = 0
8629  for col in row:
8630  if colnum == ColumnNum:
8631  AWGAwaveform.append(float(col))
8632  colnum += 1
8633  except:
8634  print( 'skipping non-numeric row', RowNum)
8635  RowNum += 1
8636  AWGAwaveform = numpy.array(AWGAwaveform)
8638  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8639  CSVFile.close()
8640  UpdateAwgCont()
8641 
8642 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
8644  global AWG_2X, AWGA2X, AWGAwaveform
8645 
8646  if AWG_2X.get() == 1:
8647  Tempwaveform = []
8648  AWGA2X = []
8649  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
8650  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
8651  AWGAwaveform = Tempwaveform
8652 #
8654  global AWGABurstFlag, AWGACycles, AWGABurstDelay
8655 
8656  if AWGABurstFlag.get() == 1:
8657  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
8658  if (AWGACyclesString == None): # If Cancel pressed, then None
8659  return
8660  AWGACycles = int(AWGACyclesString)
8661  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
8662  if (AWGADelayString == None): # If Cancel pressed, then None
8663  return
8664  AWGABurstDelay = float(AWGADelayString)
8665  ReMakeAWGwaves()
8666 #
8668  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
8669  global AWG_2X, AWGA2X
8670 
8671 # Read values from WAV file
8672  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
8673  try:
8674  spf = wave.open(filename,'r')
8675  except:
8676  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
8677  AWGAwaveform = []
8678  AWGBwaveform = []
8679  Length = spf.getnframes()
8680  if Length > 90000:
8681  Length = 90000
8682  # If Stereo put first channel in AWGA and second channel in AWGB
8683  if spf.getnchannels() == 2:
8684  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
8685  signal = spf.readframes(Length)
8686  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
8687  n = 0
8688  while n < Length*2:
8689  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
8690  n = n + 1
8691  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
8692  n = n + 1
8693  AWGAwaveform = numpy.array(AWGAwaveform)
8694  AWGBwaveform = numpy.array(AWGBwaveform)
8695  AWGALength.config(text = "L = " + str(len(AWGAwaveform))) # change displayed value
8696  AWGBLength.config(text = "L = " + str(len(AWGBwaveform))) # change displayed value
8697  AWGBShape.set(AWGAShape.get())
8698  else:
8699  #Extract Raw Audio from Wav File
8700  signal = spf.readframes(Length)
8701  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
8702  # offset and scale for 0 5 V range
8703  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
8704  AWGAwaveform = numpy.array(AWGAwaveform)
8706  AWGALength.config(text = "L = " + str(len(AWGAwaveform))) # change displayed value
8707  spf.close()
8708  UpdateAwgCont()
8709 
8711  global AWGAwaveform, AWGALength, awgwindow
8712 
8713  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
8714  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
8715 
8717  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
8718  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
8719  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
8720  global DFiltACoef, DFiltBCoef
8721  global AWG_2X, AWGA2X
8722 
8723  TempString = AWGAMathString
8724  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
8725  if (AWGAMathString == None): # If Cancel pressed, then None
8726  AWGAMathString = TempString
8727  return
8728  AWGAwaveform = eval(AWGAMathString)
8729  AWGAwaveform = numpy.array(AWGAwaveform)
8731  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8732  UpdateAwgCont()
8733 #
8735  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8736  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8737  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
8738  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8739 
8740  BAWGAAmpl(0)
8741  BAWGAOffset(0)
8742  BAWGAFreq(0)
8743  BAWGAPhase(0)
8744  BAWGADutyCycle(0)
8745 
8746  if AWGAFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
8747  AWGAShape.set(1)
8748  BAWGAShape()
8749  UpdateAwgCont()
8750  return
8751 
8752  if AWGAFreqvalue > 0.0:
8753  if AWG_2X.get() == 1:
8754  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8755  else:
8756  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8757  else:
8758  AWGAperiodvalue = 10.0
8759 
8760  if AWGAPhaseDelay.get() == 0:
8761  if AWGAPhasevalue > 0:
8762  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
8763  else:
8764  AWGAdelayvalue = 0.0
8765  elif AWGAPhaseDelay.get() == 1:
8766  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
8767  Cycles = int(32768/AWGAperiodvalue)
8768  if Cycles < 1:
8769  Cycles = 1
8770  RecLength = int(Cycles * AWGAperiodvalue)
8771  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8772  RecLength = RecLength + 1
8773  AWGAwaveform = []
8774  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
8775 
8776  if AWG_Amp_Mode.get() == 0:
8777  if AWGAMode.get() == 1: # convert to mA
8778  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8779  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8780  else:
8781  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8782  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8783  else:
8784  if AWGAMode.get() == 1: # convert to mA
8785  amplitude = AWGAAmplvalue/1000.0
8786  offset = AWGAOffsetvalue/1000.0
8787  else:
8788  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
8789  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
8790  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8791  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8792 #
8794  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8795  BAWGAPhaseDelay()
8796  duty1lab.config(text="%")
8797  UpdateAwgCont()
8798 #
8800  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8801  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8802  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
8803  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8804 
8805  BAWGAAmpl(0)
8806  BAWGAOffset(0)
8807  BAWGAFreq(0)
8808 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
8809  duty1lab.config(text = "M Index")
8810  phasealab.config(text = "M Freq")
8811 
8812  if AWGAFreqvalue > 0.0:
8813  if AWG_2X.get() == 1:
8814  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8815  else:
8816  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8817  else:
8818  AWGAperiodvalue = 10.0
8819 
8820  try:
8821  ModFreq = float(eval(AWGAPhaseEntry.get()))
8822  except:
8823  ModFreq = 10
8824  AWGAPhaseEntry.delete(0,"end")
8825  AWGAPhaseEntry.insert(0, ModFreq)
8826 
8827  if ModFreq < 10:
8828  ModFreq = 10
8829  AWGAPhaseEntry.delete(0,"end")
8830  AWGAPhaseEntry.insert(0, ModFreq)
8831 
8832  if AWG_2X.get() == 1:
8833  MODperiodvalue = (BaseSampleRate*2)/ModFreq
8834  else:
8835  MODperiodvalue = BaseSampleRate/ModFreq
8836 
8837  try:
8838  ModIndex = float(eval(AWGADutyCycleEntry.get()))
8839  except:
8840  ModIndex = 1.0
8841  AWGADutyCycleEntry.delete(0,"end")
8842  AWGADutyCycleEntry.insert(0, ModIndex)
8843 
8844  ModCycles = int(32768/MODperiodvalue) # find a whole number of cycles
8845  if ModCycles < 1:
8846  ModCycles = 1
8847  RecLength = int(ModCycles * MODperiodvalue)
8848  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8849  RecLength = RecLength + 1
8850  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
8851  AWGAwaveform = []
8852  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
8853  if AWG_Amp_Mode.get() == 0:
8854  if AWGAMode.get() == 1: # convert to mA
8855  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8856  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8857  else:
8858  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8859  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8860  else:
8861  if AWGAMode.get() == 1: # convert to mA
8862  amplitude = AWGAAmplvalue/1000.0
8863  offset = AWGAOffsetvalue/1000.0
8864  else:
8865  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
8866  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
8867  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8868  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8869 #
8870  SplitAWGAwaveform() # if needed
8871  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8872  UpdateAwgCont()
8873 #
8875  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8876  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8877  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
8878  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8879 
8880  BAWGAAmpl(0)
8881  BAWGAOffset(0)
8882  BAWGAFreq(0)
8883 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
8884  duty1lab.config(text = "M Index")
8885  phasealab.config(text = "M Freq")
8886 
8887  if AWGAFreqvalue > 0.0:
8888  if AWG_2X.get() == 1:
8889  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8890  else:
8891  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8892  else:
8893  AWGAperiodvalue = 10.0
8894 
8895  try:
8896  ModFreq = float(eval(AWGAPhaseEntry.get()))
8897  except:
8898  ModFreq = 10
8899  AWGAPhaseEntry.delete(0,"end")
8900  AWGAPhaseEntry.insert(0, ModFreq)
8901 
8902  if ModFreq < 10:
8903  ModFreq = 10
8904  AWGAPhaseEntry.delete(0,"end")
8905  AWGAPhaseEntry.insert(0, ModFreq)
8906 
8907  if AWG_2X.get() == 1:
8908  MODperiodvalue = (BaseSampleRate*2)/ModFreq
8909  else:
8910  MODperiodvalue = BaseSampleRate/ModFreq
8911 
8912  try:
8913  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
8914  except:
8915  ModIndex = 50.0
8916  AWGADutyCycleEntry.delete(0,"end")
8917  AWGADutyCycleEntry.insert(0, ModIndex)
8918 
8919  ModCycles = int(32768/MODperiodvalue) # find a whole number of cycles
8920  if ModCycles < 1:
8921  ModCycles = 1
8922  RecLength = int(ModCycles * MODperiodvalue)
8923  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8924  RecLength = RecLength + 1
8925  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
8926  AWGAwaveform = []
8927  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
8928  if AWG_Amp_Mode.get() == 0:
8929  if AWGAMode.get() == 1: # convert to mA
8930  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8931  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8932  else:
8933  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8934  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8935  else:
8936  if AWGAMode.get() == 1: # convert to mA
8937  amplitude = AWGAAmplvalue/1000.0
8938  offset = AWGAOffsetvalue/1000.0
8939  else:
8940  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
8941  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
8942  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8943  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8944 #
8945  SplitAWGAwaveform() # if needed
8946  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8947  UpdateAwgCont()
8948 #
8950  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
8951  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8952  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8953  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8954 
8955  BAWGAAmpl(0)
8956  BAWGAOffset(0)
8957  BAWGAFreq(0)
8958  BAWGAPhase(0)
8959  BAWGADutyCycle(0)
8960 
8961  if AWGAFreqvalue > 0.0:
8962  if AWG_2X.get() == 1:
8963  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
8964  else:
8965  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8966  else:
8967  AWGAperiodvalue = 0.0
8968  if AWG_Amp_Mode.get() == 1:
8969  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
8970  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
8971  else:
8972  MaxV = AWGAOffsetvalue
8973  MinV = AWGAAmplvalue
8974 
8975  PulseWidth = int(AWGADutyCyclevalue*100)
8976  PulseSamples = int(AWGAperiodvalue/PulseWidth)
8977  AWGAwaveform = []
8978  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
8979  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
8980  # print(v)
8981  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
8982  if j >= v:
8983  AWGAwaveform.append(MaxV) # j>=v?1:0
8984  else:
8985  AWGAwaveform.append(MinV) # j>=v?1:0
8987  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8988  duty1lab.config(text="PWidth")
8989  UpdateAwgCont()
8990 #
8992  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
8993  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8994  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8995  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
8996 
8997  BAWGAAmpl(0)
8998  BAWGAOffset(0)
8999  BAWGAFreq(0)
9000  BAWGADutyCycle(0)
9001 
9002  Max_term = int(AWGADutyCyclevalue*100)
9003  if AWG_2X.get() == 1:
9004  TempRate = (BaseSampleRate*2)
9005  else:
9006  TempRate = BaseSampleRate
9007  AWGAwaveform = []
9008  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, TempRate/AWGAFreqvalue)) # the fundamental
9009  k = 3
9010  while k <= Max_term:
9011  # Add odd harmonics up to max_term
9012  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, TempRate/AWGAFreqvalue)))
9013  AWGAwaveform = AWGAwaveform + Harmonic
9014  k = k + 2 # skip even numbers
9015  if AWG_Amp_Mode.get() == 0:
9016  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
9017  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
9018  else:
9019  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
9020  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
9021  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
9023  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9024  duty1lab.config(text="Harmonics")
9025  UpdateAwgCont()
9026 #
9028  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
9029  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
9030  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9031  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9032 
9033  BAWGAAmpl(0)
9034  BAWGAOffset(0)
9035  BAWGAFreq(0)
9036  BAWGAPhase(0)
9037  BAWGADutyCycle(0)
9038 
9039  if AWGAFreqvalue > 0.0:
9040  if AWG_2X.get() == 1:
9041  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9042  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9043  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9044  AWGAperiodvalue = AWGAperiodvalue + 1
9045  else:
9046  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9047  SamplesPermS = int(BaseSampleRate/1000) # 100
9048  else:
9049  AWGAperiodvalue = 0.0
9050  if AWG_Amp_Mode.get() == 1:
9051  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9052  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9053  else:
9054  MaxV = AWGAOffsetvalue
9055  MinV = AWGAAmplvalue
9056 
9057  if AWGAPhaseDelay.get() == 0:
9058  if AWGAPhasevalue > 0:
9059  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9060  else:
9061  AWGAdelayvalue = 0.0
9062  elif AWGAPhaseDelay.get() == 1:
9063  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
9064 
9065  Cycles = int(AWGADutyCyclevalue*100)
9066  NCycles = -1 * Cycles
9067  AWGAwaveform = []
9068  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, SAMPLErate/AWGAFreqvalue))
9069  amplitude = (MaxV-MinV) / 2.0
9070  offset = (MaxV+MinV) / 2.0
9071  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
9072  Cycles = int(37500/AWGAperiodvalue)
9073  if Cycles < 1:
9074  Cycles = 1
9075  if Cycles > 1:
9076  Extend = int((Cycles-1.0)*AWGAperiodvalue/2.0)
9077  AWGAwaveform = numpy.pad(AWGAwaveform, (Extend,Extend), 'wrap')
9078  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9080  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9081  #BAWGAPhaseDelay()
9082  duty1lab.config(text="Cycles")
9083  UpdateAwgCont()
9084 #
9086  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9087  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9088  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9089  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9090  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9091 
9092  BAWGAAmpl(0)
9093  BAWGAOffset(0)
9094  BAWGAFreq(0)
9095  BAWGAPhase(0)
9096  BAWGADutyCycle(0)
9097 
9098  if AWGAFreqvalue > 0.0:
9099  if AWG_2X.get() == 1:
9100  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9101  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9102  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9103  AWGAperiodvalue = AWGAperiodvalue + 1
9104  else:
9105  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9106  SamplesPermS = int(BaseSampleRate/1000) # 100
9107  else:
9108  AWGAperiodvalue = 0.0
9109  if AWG_Amp_Mode.get() == 1:
9110  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9111  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9112  else:
9113  MaxV = AWGAOffsetvalue
9114  MinV = AWGAAmplvalue
9115  AWGAwaveform = []
9116  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
9117  if SlopeValue <= 0:
9118  SlopeValue = 1
9119  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9120  if PulseWidth <=0:
9121  PulseWidth = 1
9122  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
9123  if Remainder <= 0:
9124  Remainder = 1
9125  PulseWidth = PulseWidth - SlopeValue
9126  if PulseWidth <=0:
9127  PulseWidth = 1
9128  StepAmp = (MaxV - MinV)/2
9129  StepOff = (MaxV + MinV)/2
9130  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
9131  MidArray = numpy.ones(PulseWidth) * MinV
9132  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
9133  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
9134  if AWGABurstFlag.get() == 1:
9135  TempOneCycle = AWGAwaveform
9136  for i in range(AWGACycles-1):
9137  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9138  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9139  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9141  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9142  duty1lab.config(text="%")
9143  phasealab.config(text = "Rise Time")
9144  UpdateAwgCont()
9145 #
9147  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9148  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9149  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9150  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9151  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9152 
9153  BAWGAAmpl(0)
9154  BAWGAOffset(0)
9155  BAWGAFreq(0)
9156  BAWGAPhase(0)
9157  BAWGADutyCycle(0)
9158 
9159  if AWGAFreqvalue > 0.0:
9160  if AWG_2X.get() == 1:
9161  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9162  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9163  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9164  AWGAperiodvalue = AWGAperiodvalue + 1
9165  else:
9166  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9167  SamplesPermS = int(BaseSampleRate/1000) # 100
9168  else:
9169  AWGAperiodvalue = 0.0
9170  if AWG_Amp_Mode.get() == 1:
9171  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9172  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9173  else:
9174  MaxV = AWGAOffsetvalue
9175  MinV = AWGAAmplvalue
9176  AWGAwaveform = []
9177  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9178  if SlopeValue <= 0:
9179  SlopeValue = 1
9180  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9181  if PulseWidth <=0:
9182  PulseWidth = 1
9183  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
9184  if Remainder <= 0:
9185  Remainder = 1
9186  PulseWidth = PulseWidth - SlopeValue
9187  if PulseWidth <=0:
9188  PulseWidth = 1
9189  StepValue = (MaxV - MinV) / SlopeValue
9190  SampleValue = MinV
9191  for i in range(SlopeValue):
9192  AWGAwaveform.append(SampleValue)
9193  SampleValue = SampleValue + StepValue
9194  for i in range(PulseWidth):
9195  AWGAwaveform.append(MaxV)
9196  for i in range(SlopeValue):
9197  AWGAwaveform.append(SampleValue)
9198  SampleValue = SampleValue - StepValue
9199  for i in range(Remainder):
9200  AWGAwaveform.append(MinV)
9201  if AWGABurstFlag.get() == 1:
9202  TempOneCycle = AWGAwaveform
9203  for i in range(AWGACycles-1):
9204  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9205  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9206  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9208  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9209  duty1lab.config(text="%")
9210  phasealab.config(text = "Rise Time")
9211  UpdateAwgCont()
9212 #
9214  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9215  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9216  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9217  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9218  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9219 
9220  BAWGAAmpl(0)
9221  BAWGAOffset(0)
9222  BAWGAFreq(0)
9223  BAWGAPhase(0)
9224 
9225  try:
9226  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
9227  except:
9228  AWGADutyCycleEntry.delete(0,"end")
9229  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
9230 
9231  if AWGAFreqvalue > 0.0:
9232  if AWG_2X.get() == 1:
9233  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9234  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9235  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9236  AWGAperiodvalue = AWGAperiodvalue + 1
9237  else:
9238  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9239  SamplesPermS = int(BaseSampleRate/1000) # 100
9240  else:
9241  AWGAperiodvalue = 0.0
9242  if AWG_Amp_Mode.get() == 1:
9243  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9244  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9245  else:
9246  MaxV = AWGAOffsetvalue
9247  MinV = AWGAAmplvalue
9248  AWGAwaveform = []
9249  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9250  if SlopeValue <= 0:
9251  SlopeValue = 1
9252  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
9253  if PulseWidth <=0:
9254  PulseWidth = 1
9255  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
9256  if Remainder <= 0:
9257  Remainder = 1
9258  PulseWidth = PulseWidth - SlopeValue
9259  if PulseWidth <=0:
9260  PulseWidth = 1
9261  StepValue = (MaxV - MinV) / SlopeValue
9262  SampleValue = MinV
9263  for i in range(SlopeValue):
9264  AWGAwaveform.append(SampleValue)
9265  SampleValue = SampleValue + StepValue
9266  for i in range(PulseWidth):
9267  AWGAwaveform.append(MaxV)
9268  for i in range(SlopeValue):
9269  AWGAwaveform.append(SampleValue)
9270  SampleValue = SampleValue - StepValue
9271  for i in range(Remainder):
9272  AWGAwaveform.append(MinV)
9273  if AWGABurstFlag.get() == 1:
9274  TempOneCycle = AWGAwaveform
9275  for i in range(AWGACycles-1):
9276  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9277  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9278  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9280  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9281  duty1lab.config(text="Width mS")
9282  phasealab.config(text = "Rise Time")
9283  UpdateAwgCont()
9284 #
9286  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9287  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9288  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9289  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9290  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9291 
9292  BAWGAAmpl(0)
9293  BAWGAOffset(0)
9294  BAWGAFreq(0)
9295  BAWGAPhase(0)
9296  BAWGADutyCycle(0)
9297 
9298  if AWGAFreqvalue > 0.0:
9299  if AWG_2X.get() == 1:
9300  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9301  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9302  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9303  AWGAperiodvalue = AWGAperiodvalue + 1
9304  else:
9305  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9306  SamplesPermS = int(BaseSampleRate/1000) # 100
9307  else:
9308  AWGAperiodvalue = 0.0
9309  if AWG_Amp_Mode.get() == 1:
9310  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9311  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9312  else:
9313  MaxV = AWGAOffsetvalue
9314  MinV = AWGAAmplvalue
9315  AWGAwaveform = []
9316  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9317  if SlopeValue <= 0:
9318  SlopeValue = 1
9319  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9320  if PulseWidth <=0:
9321  PulseWidth = 1
9322  Remainder = int(AWGAperiodvalue - PulseWidth)
9323  if Remainder <= 0:
9324  Remainder = 1
9325  PulseWidth = PulseWidth - SlopeValue
9326  if PulseWidth <=0:
9327  PulseWidth = 1
9328  StepValue = (MaxV - MinV) / SlopeValue
9329  SampleValue = MinV
9330  for i in range(SlopeValue):
9331  AWGAwaveform.append(SampleValue)
9332  SampleValue = SampleValue + StepValue
9333  for i in range(PulseWidth):
9334  AWGAwaveform.append(MaxV)
9335  for i in range(Remainder):
9336  AWGAwaveform.append(MinV)
9337  if AWGABurstFlag.get() == 1:
9338  TempOneCycle = AWGAwaveform
9339  for i in range(AWGACycles-1):
9340  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9341  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9342  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9344  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9345  duty1lab.config(text="%")
9346  phasealab.config(text = "Slope Time")
9347  UpdateAwgCont()
9348 #
9350  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
9351  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9352  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9353  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9354  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9355 
9356  BAWGAAmpl(0)
9357  BAWGAOffset(0)
9358  BAWGAFreq(0)
9359  BAWGAPhase(0)
9360  BAWGADutyCycle(0)
9361 
9362  if AWGAFreqvalue > 0.0:
9363  if AWG_2X.get() == 1:
9364  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9365  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9366  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9367  AWGAperiodvalue = AWGAperiodvalue + 1
9368  else:
9369  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
9370  SamplesPermS = int(BaseSampleRate/1000) # 100
9371  else:
9372  AWGAperiodvalue = 0.0
9373  if AWG_Amp_Mode.get() == 1:
9374  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9375  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9376  else:
9377  MaxV = AWGAOffsetvalue
9378  MinV = AWGAAmplvalue
9379  #
9380  if AWGAPhaseDelay.get() == 0:
9381  if AWGAPhasevalue > 0:
9382  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9383  else:
9384  AWGAdelayvalue = 0.0
9385  elif AWGAPhaseDelay.get() == 1:
9386  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
9387  #
9388  AWGAwaveform = []
9389  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9390  if PulseWidth <=0:
9391  PulseWidth = 1
9392  Remainder = int(AWGAperiodvalue - PulseWidth)
9393  if Remainder <= 0:
9394  Remainder = 1
9395  UpStepValue = (MaxV - MinV) / PulseWidth
9396  DownStepValue = (MaxV - MinV) / Remainder
9397  SampleValue = MinV
9398  for i in range(PulseWidth):
9399  AWGAwaveform.append(SampleValue)
9400  SampleValue = SampleValue + UpStepValue
9401  for i in range(Remainder):
9402  AWGAwaveform.append(SampleValue)
9403  SampleValue = SampleValue - DownStepValue
9404  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9405  if AWGABurstFlag.get() == 1:
9406  TempOneCycle = AWGAwaveform
9407  for i in range(AWGACycles-1):
9408  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9409  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9410  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
9412  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9413  BAWGAPhaseDelay()
9414  duty1lab.config(text = "Symmetry")
9415  UpdateAwgCont()
9416 #
9418  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9419  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
9420  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9421  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9422  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9423 
9424  BAWGAAmpl(0)
9425  BAWGAOffset(0)
9426  BAWGAFreq(0)
9427  BAWGAPhase(0)
9428  BAWGADutyCycle(0)
9429 
9430  if AWGAFreqvalue > 0.0:
9431  if AWG_2X.get() == 1:
9432  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9433  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9434  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9435  AWGAperiodvalue = AWGAperiodvalue + 1
9436  else:
9437  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9438  SamplesPermS = int(BaseSampleRate/1000) # 100
9439  else:
9440  AWGAperiodvalue = 0.0
9441  if AWG_Amp_Mode.get() == 1:
9442  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9443  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9444  else:
9445  MaxV = AWGAOffsetvalue
9446  MinV = AWGAAmplvalue
9447  AWGAwaveform = []
9448  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
9449  if AWGAPhaseDelay.get() == 0:
9450  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
9451  elif AWGAPhaseDelay.get() == 1:
9452  DelayValue = int(AWGAPhasevalue*SamplesPermS)
9453  for i in range(DelayValue-PulseWidth):
9454  AWGAwaveform.append((MinV+MaxV)/2.0)
9455  for i in range(PulseWidth):
9456  AWGAwaveform.append(MaxV)
9457  for i in range(PulseWidth):
9458  AWGAwaveform.append(MinV)
9459  DelayValue = int(AWGAperiodvalue-DelayValue)
9460  for i in range(DelayValue-PulseWidth):
9461  AWGAwaveform.append((MinV+MaxV)/2.0)
9462  if AWGABurstFlag.get() == 1:
9463  TempOneCycle = AWGAwaveform
9464  for i in range(AWGACycles-1):
9465  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9466  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9467  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
9469  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9470  UpdateAwgCont()
9471 
9473  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
9474  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9475  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9476  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9477  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9478 
9479  BAWGAAmpl(0)
9480  BAWGAOffset(0)
9481  BAWGAFreq(0)
9482 
9483  if AWGAFreqvalue > 0.0:
9484  if AWG_2X.get() == 1:
9485  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9486  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9487  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9488  AWGAperiodvalue = AWGAperiodvalue + 1
9489  else:
9490  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9491  SamplesPermS = int(BaseSampleRate/1000) # 100
9492  else:
9493  AWGAperiodvalue = 0.0
9494  if AWG_Amp_Mode.get() == 1:
9495  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9496  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9497  else:
9498  if AWGAAmplvalue > AWGAOffsetvalue:
9499  MinV = AWGAOffsetvalue
9500  MaxV = AWGAAmplvalue
9501  else:
9502  MaxV = AWGAOffsetvalue
9503  MinV = AWGAAmplvalue
9504  AWGAwaveform = []
9505  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
9506  Mid = (MaxV+MinV)/2.0
9507  if AWGABurstFlag.get() == 1:
9508  TempOneCycle = AWGAwaveform
9509  for i in range(AWGACycles-1):
9510  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9511  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9512  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
9514  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9515  UpdateAwgCont()
9516 
9518  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
9519  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9520  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9521  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9522  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9523 
9524  BAWGAAmpl(0)
9525  BAWGAOffset(0)
9526  BAWGAFreq(0)
9527 
9528  if AWGAFreqvalue > 0.0:
9529  if AWG_2X.get() == 1:
9530  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9531  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9532  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9533  AWGAperiodvalue = AWGAperiodvalue + 1
9534  else:
9535  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9536  SamplesPermS = int(BaseSampleRate/1000) # 100
9537  else:
9538  AWGAperiodvalue = 0.0
9539  if AWG_Amp_Mode.get() == 1:
9540  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9541  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9542  else:
9543  if AWGAAmplvalue > AWGAOffsetvalue:
9544  MinV = AWGAOffsetvalue
9545  MaxV = AWGAAmplvalue
9546  else:
9547  MaxV = AWGAOffsetvalue
9548  MinV = AWGAAmplvalue
9549  AWGAwaveform = []
9550  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
9551  Mid = (MaxV+MinV)/2.0
9552  if AWGABurstFlag.get() == 1:
9553  TempOneCycle = AWGAwaveform
9554  for i in range(AWGACycles-1):
9555  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9556  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9557  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
9559  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9560  UpdateAwgCont()
9561 
9563  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
9564  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9565 
9566  if AWGAMode.get() == 0: # Source Voltage measure current mode
9567  label_txt = "SVMI"
9568  elif AWGAMode.get() == 1: # Source current measure voltage mode
9569  label_txt = "SIMV"
9570  elif AWGAMode.get() == 2: # High impedance mode
9571  label_txt = "Hi-Z"
9572  if AWGAIOMode.get() > 0: # Split Input / Output mode
9573  if HWRevOne == "D":
9574  if AWGAMode.get() == 0:
9575  AWGAMode.set(1)
9576  CHA.set_mode('i') # channel must be in source current mode for rev D boards
9577  label_txt = "SIMV"
9578  label_txt = label_txt + " Split I/O"
9579  label_txt = label_txt + " Mode"
9580  AWGAModeLabel.config(text = label_txt ) # change displayed value
9581  ReMakeAWGwaves()
9582  #UpdateAwgCont()
9583 
9585  global AWGAAmplvalue, AWGAOffsetvalue
9586  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
9587  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
9588  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
9589  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9590  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
9591  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9592 
9593  BAWGAAmpl(0)
9594  BAWGAOffset(0)
9595  BAWGAFreq(0)
9596  BAWGAPhase(0)
9597  BAWGADutyCycle(0)
9598  BAWGAShape()
9599 
9600  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
9601  amp1lab.config(text = "Min Ch A" ) # change displayed value
9602  off1lab.config(text = "Max Ch A" ) # change displayed value
9603  else:
9604  amp1lab.config(text = "Amp Ch A" )
9605  off1lab.config(text = "Off Ch A" )
9606 
9607  if AWGAFreqvalue > 0.0:
9608  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
9609  else:
9610  AWGAperiodvalue = 0.0
9611 
9612  if AWGAPhaseDelay.get() == 0:
9613  if AWGAWave == 'square':
9614  AWGAPhasevalue = AWGAPhasevalue + 270.0
9615  if AWGAPhasevalue > 359:
9616  AWGAPhasevalue = AWGAPhasevalue - 360
9617  if AWGAPhasevalue > 0:
9618  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9619  else:
9620  AWGAdelayvalue = 0.0
9621  elif AWGAPhaseDelay.get() == 1:
9622  AWGAdelayvalue = AWGAPhasevalue * 100
9623 
9624  if AWGATerm.get() == 0: # Open termination
9625  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
9626  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
9627  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
9628  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
9629  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
9630  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
9631  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
9632  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
9633 
9634  if AWGAWave == 'dc':
9635  if AWG_2X.get() == 2:
9636  AWGAWave == 'arbitrary'
9637  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
9638  else:
9639  if AWGAMode.get() == 0: # Source Voltage measure current mode
9640  if AWGAIOMode.get() == 0:
9641  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
9642  else:
9643  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
9644  CHA.constant(AWGAOffsetvalue)
9645  #
9646  if AWGAMode.get() == 1: # Source current measure voltage mode
9647  if AWGAIOMode.get() == 0:
9648  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
9649  else:
9650  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
9651  CHA.constant(AWGAOffsetvalue/1000)
9652  #
9653  if AWGAMode.get() == 2: # High impedance mode
9654  if AWGAIOMode.get() == 0:
9655  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
9656  else:
9657  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
9658  #
9659  if AWGAIOMode.get() > 0: # Split Input / Output mode
9660  if HWRevOne == "D":
9661  AWGAMode.set(1)
9662  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
9663 #
9664  else:
9665  if AWGAMode.get() == 0: # Source Voltage measure current mode
9666  if AWGAIOMode.get() == 0:
9667  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
9668  else:
9669  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
9670  if AWGAMode.get() == 1: # Source current measure voltage mode
9671  if AWGAIOMode.get() == 0:
9672  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
9673  else:
9674  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
9675  AWGAOffsetvalue = AWGAOffsetvalue/1000
9676  AWGAAmplvalue = AWGAAmplvalue/1000
9677  if AWGAMode.get() == 2: # High impedance mode
9678  if AWGAIOMode.get() == 0:
9679  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
9680  else:
9681  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
9682  else:
9683  if AWG_Amp_Mode.get() == 1:
9684  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
9685  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
9686  else:
9687  MaxV = AWGAOffsetvalue
9688  MinV = AWGAAmplvalue
9689  try:
9690  if AWGAWave == 'sine':
9691  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9692  elif AWGAWave == 'triangle':
9693  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9694  elif AWGAWave == 'sawtooth':
9695  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9696  elif AWGAWave == 'square':
9697  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
9698  elif AWGAWave == 'stairstep':
9699  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9700  elif AWGAWave == 'arbitrary':
9701  if AWGSync.get() == 0:
9702  AWGARepeatFlag.set(1)
9703  if AWG_2X.get() == 2:
9704  AWGAWave == 'arbitrary'
9705  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
9706  else:
9707  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
9708  except:
9709  donothing()
9710  if AWGAIOMode.get() > 0: # Split Input / Output mode
9711  if HWRevOne == "D":
9712  AWGAMode.set(1)
9713  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
9714 # AWG B functions
9716  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
9717  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
9718  global BisCompA
9719 
9720  # if BisCompA.get() == 1:
9721  # sawp Min and Max values
9722  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
9723  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
9724  AWGBAmplEntry.delete(0,"end")
9725  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
9726  AWGBOffsetEntry.delete(0,"end")
9727  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
9728  # copy everything else
9729  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
9730  AWGBFreqEntry.delete(0,"end")
9731  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9732  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
9733  AWGBPhaseEntry.delete(0,"end")
9734  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9735  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
9736  AWGBDutyCycleEntry.delete(0,"end")
9737  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9738  AWGBShape.set(AWGAShape.get())
9739  #
9740 # ReMakeAWGwaves()
9741 # UpdateAwgCont()
9742 #
9744  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
9745 
9746  if AWGBBurstFlag.get() == 1:
9747  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
9748  if (AWGBCyclesString == None): # If Cancel pressed, then None
9749  return
9750  AWGBCycles = int(AWGBCyclesString)
9751  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
9752  if (AWGBDelayString == None): # If Cancel pressed, then None
9753  return
9754  AWGBBurstDelay = float(AWGBDelayString)
9755  ReMakeAWGwaves()
9756 #
9757 def BAWGBAmpl(temp):
9758  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9759  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9760 
9761  try:
9762  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
9763  except:
9764  AWGBAmplEntry.delete(0,"end")
9765  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9766  #
9767  if AWGBMode.get() == 0: # Source Voltage measure current mode
9768  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
9769  if AWGBAmplvalue > 5.00:
9770  AWGBAmplvalue = 5.00
9771  AWGBAmplEntry.delete(0,"end")
9772  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9773  if AWGBAmplvalue < 0.00:
9774  AWGBAmplvalue = 0.00
9775  AWGBAmplEntry.delete(0,"end")
9776  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9777  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
9778  if AWGBAmplvalue > (2.5 / AWGB_Ext_Gain.get()):
9779  AWGBAmplvalue = 2.5 / AWGB_Ext_Gain.get()
9780  AWGBAmplEntry.delete(0,"end")
9781  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9782  if AWGBAmplvalue < (-2.50 / AWGB_Ext_Gain.get()):
9783  AWGBAmplvalue = -2.50 / AWGB_Ext_Gain.get()
9784  AWGBAmplEntry.delete(0,"end")
9785  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9786  elif AWGBMode.get() == 1: # Source current measure voltage mode
9787  if AWGBAmplvalue > 200.00:
9788  AWGBAmplvalue = 200.00
9789  AWGBAmplEntry.delete(0,"end")
9790  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9791  if AWGBAmplvalue < -200.00:
9792  AWGBAmplvalue = -200.00
9793  AWGBAmplEntry.delete(0,"end")
9794  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9795 #
9796 def BAWGBOffset(temp):
9797  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9798  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
9799 
9800  try:
9801  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
9802  except:
9803  AWGBOffsetEntry.delete(0,"end")
9804  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9805  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
9806  if AWGBMode.get() == 0: # Source Voltage measure current mode
9807  if AWGBOffsetvalue > 5.00:
9808  AWGBOffsetvalue = 5.00
9809  AWGBOffsetEntry.delete(0,"end")
9810  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9811  if AWGBOffsetvalue < 0.00:
9812  AWGBOffsetvalue = 0.00
9813  AWGBOffsetEntry.delete(0,"end")
9814  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9815  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
9816  if AWGBOffsetvalue > (2.50-AWGB_Ext_Offset.get()):
9817  AWGBOffsetvalue = 2.50-AWGB_Ext_Offset.get()
9818  AWGBOffsetEntry.delete(0,"end")
9819  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9820  if AWGBOffsetvalue < (-2.50-AWGB_Ext_Offset.get()):
9821  AWGBOffsetvalue = -2.50-AWGB_Ext_Offset.get()
9822  AWGBOffsetEntry.delete(0,"end")
9823  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9824  if AWGBMode.get() == 1: # Source current measure voltage mode
9825  if AWGBOffsetvalue > 200.00:
9826  AWGBOffsetvalue = 200.00
9827  AWGBOffsetEntry.delete(0,"end")
9828  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9829  if AWGBOffsetvalue < -200.00:
9830  AWGBOffsetvalue = -200.00
9831  AWGBOffsetEntry.delete(0,"end")
9832  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9833 #
9834 def BAWGBFreq(temp):
9835  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
9836  global BodeScreenStatus, BodeDisp
9837 
9838  try:
9839  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
9840  except:
9841  AWGBFreqEntry.delete(0,"end")
9842  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9843  if AWG_2X.get() == 2:
9844  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
9845  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
9846  AWGBFreqvalue = 90000
9847  AWGBFreqEntry.delete(0,"end")
9848  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9849  else:
9850  if AWGBFreqvalue > 50000: # max freq is 50KHz
9851  AWGBFreqvalue = 50000
9852  AWGBFreqEntry.delete(0,"end")
9853  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9854  else:
9855  if AWGBFreqvalue > 25000: # max freq is 25KHz
9856  AWGBFreqvalue = 25000
9857  AWGBFreqEntry.delete(0,"end")
9858  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9859  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
9860  AWGBFreqvalue = 10
9861  AWGBFreqEntry.delete(0,"end")
9862  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9863  # UpdateAWGB()
9864 
9866  global AWGbPhaseDelay, phaseblab, awgbph, awgbdel
9867 
9868  if AWGBPhaseDelay.get() == 0:
9869  phaseblab.configure(text="Deg")
9870  awgbph.configure(style="WPhase.TRadiobutton")
9871  awgbdel.configure(style="GPhase.TRadiobutton")
9872  elif AWGBPhaseDelay.get() == 1:
9873  phaseblab.configure(text="mSec")
9874  awgbph.configure(style="GPhase.TRadiobutton")
9875  awgbdel.configure(style="WPhase.TRadiobutton")
9876 
9877 def BAWGBPhase(temp):
9878  global AWGBPhaseEntry, AWGBPhasevalue
9879 
9880  try:
9881  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
9882  except:
9883  AWGBPhaseEntry.delete(0,"end")
9884  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9885 
9886  if AWGBPhasevalue > 360: # max phase is 360 degrees
9887  AWGBPhasevalue = 360
9888  AWGBPhaseEntry.delete(0,"end")
9889  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9890  if AWGBPhasevalue < 0: # min phase is 0 degrees
9891  AWGBPhasevalue = 0
9892  AWGBPhaseEntry.delete(0,"end")
9893  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9894 
9895 def BAWGBDutyCycle(temp):
9896  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
9897 
9898  try:
9899  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
9900  except:
9901  AWGBDutyCycleEntry.delete(0,"end")
9902  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9903 
9904  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
9905  AWGBDutyCyclevalue = 1
9906  AWGBDutyCycleEntry.delete(0,"end")
9907  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
9908  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
9909  AWGBDutyCyclevalue = 0
9910  AWGBDutyCycleEntry.delete(0,"end")
9911  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9912  # UpdateAWGB()
9913 
9915  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
9916 
9917  if AWGBShape.get() == 0:
9918  AWGBWave = 'dc'
9919  duty2lab.config(text="%")
9920  BAWGBPhaseDelay()
9921  if AWGBShape.get() == 1:
9922  AWGBWave = 'sine'
9923  duty2lab.config(text="%")
9924  BAWGBPhaseDelay()
9925  if AWGBShape.get() == 2:
9926  AWGBWave = 'triangle'
9927  duty2lab.config(text="%")
9928  BAWGBPhaseDelay()
9929  if AWGBShape.get() == 3:
9930  AWGBWave = 'sawtooth'
9931  duty2lab.config(text="%")
9932  BAWGBPhaseDelay()
9933  if AWGBShape.get() == 4:
9934  AWGBWave = 'square'
9935  duty2lab.config(text="%")
9936  BAWGBPhaseDelay()
9937  if AWGBShape.get() == 5:
9938  AWGBWave = 'stairstep'
9939  duty2lab.config(text="%")
9940  BAWGBPhaseDelay()
9941  if AWGBShape.get() > 5:
9942  AWGBWave = 'arbitrary'
9943  if AWG_2X.get() == 1:
9944  CHB.mode = CHA.mode
9945  AWGBWave = 'arbitrary'
9946  # UpdateAWGB()
9947 
9949  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X
9950 
9951  # Read values from CVS file
9952  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
9953  try:
9954  CSVFile = open(filename)
9955  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
9956  CSVFile.seek(0)
9957  #csv_f = csv.reader(CSVFile, dialect)
9958  csv_f = csv.reader(CSVFile, csv.excel)
9959  except:
9960  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
9961  AWGBwaveform = []
9962  ColumnNum = 0
9963  ColumnSel = 0
9964  RowNum = 0
9965  for row in csv_f:
9966  if len(row) > 1 and ColumnSel == 0:
9967  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
9968  ColumnNum = int(RequestColumn) - 1
9969  ColumnLen = str(len(row))
9970  ColumnSel = 1
9971  try:
9972  colnum = 0
9973  for col in row:
9974  if colnum == ColumnNum:
9975  AWGBwaveform.append(float(col))
9976  colnum += 1
9977  except:
9978  print( 'skipping non-numeric row', RowNum)
9979  RowNum += 1
9980  AWGBwaveform = numpy.array(AWGBwaveform)
9982  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9983  CSVFile.close()
9984  UpdateAwgCont()
9985 
9986 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
9988  global AWG_2X, AWGB2X, AWGBwaveform
9989 
9990  if AWG_2X.get() == 2:
9991  Tempwaveform = []
9992  AWGB2X = []
9993  AWGB2X = AWGBwaveform[::2] # even numbered samples
9994  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
9995  AWGBwaveform = Tempwaveform
9996 #
9998  global AWGBwaveform, AWGBLength, awgwindow
9999  global AWG_2X, AWGA2X
10000 
10001 # Read values from WAV file
10002  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
10003  try:
10004  spf = wave.open(filename,'r')
10005  except:
10006  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10007  AWGBwaveform = []
10008  #If Stereo
10009  if spf.getnchannels() == 2:
10010  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
10011  return()
10012  #Extract Raw Audio from Wav File
10013  Length = spf.getnframes()
10014  if Length > 90000: # limit to first 90K samples
10015  Length = 90000
10016  signal = spf.readframes(Length)
10017  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
10018  # offset and scale for 0 5 V range
10019  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
10020  AWGBwaveform = numpy.array(AWGBwaveform)
10022  AWGBLength.config(text = "L = " + str(len(AWGBwaveform))) # change displayed value
10023  spf.close()
10024  UpdateAwgCont()
10025 
10027  global AWGBwaveform, AWGBLength, awgwindow
10028 
10029  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10030  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
10031 
10033  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10034  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
10035  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
10036  global DFiltACoef, DFiltBCoef
10037  global AWG_2X, AWGA2X
10038 
10039  TempString = AWGBMathString
10040  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
10041  if (AWGBMathString == None): # If Cancel pressed, then None
10042  AWGBMathString = TempString
10043  return
10044  AWGBwaveform = eval(AWGBMathString)
10045  AWGBwaveform = numpy.array(AWGBwaveform)
10047  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10048  UpdateAwgCont()
10049 #
10051  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
10052  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10053  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10054  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10055 
10056  Max_term = int(AWGBDutyCyclevalue*100)
10057 
10058  BAWGBAmpl(0)
10059  BAWGBOffset(0)
10060  BAWGBFreq(0)
10061  if AWG_2X.get() == 1:
10062  TempRate = (BaseSampleRate*2)
10063  else:
10064  TempRate = BaseSampleRate
10065  AWGBwaveform = []
10066  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, TempRate/AWGBFreqvalue)) # the fundamental
10067  k = 3
10068  while k <= Max_term:
10069  # Add odd harmonics up to max_term
10070  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, TempRate/AWGBFreqvalue)))
10071  AWGBwaveform = AWGBwaveform + Harmonic
10072  k = k + 2 # skip even numbers
10073  if AWG_Amp_Mode.get() == 0:
10074  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
10075  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
10076  else:
10077  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
10078  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
10079  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10081  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10082  duty2lab.config(text="Harmonics")
10083  UpdateAwgCont()
10084 #
10086  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
10087  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
10088  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
10089  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10090 
10091  BAWGBAmpl(0)
10092  BAWGBOffset(0)
10093  BAWGBFreq(0)
10094  BAWGBPhase(0)
10095  BAWGBDutyCycle(0)
10096 
10097  if AWGBFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
10098  AWGBShape.set(1)
10099  BAWGBShape()
10100  UpdateAwgCont()
10101  return
10102 
10103  if AWGBFreqvalue > 0.0:
10104  if AWG_2X.get() == 2:
10105  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10106  else:
10107  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10108  else:
10109  AWGBperiodvalue = 10.0
10110 
10111  if AWGBPhaseDelay.get() == 0:
10112  if AWGBPhasevalue > 0:
10113  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10114  else:
10115  AWGBdelayvalue = 0.0
10116  elif AWGBPhaseDelay.get() == 1:
10117  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
10118  Cycles = int(32768/AWGBperiodvalue)
10119  if Cycles < 1:
10120  Cycles = 1
10121  RecLength = int(Cycles * AWGBperiodvalue)
10122  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10123  RecLength = RecLength + 1
10124  AWGBwaveform = []
10125  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
10126 
10127  if AWG_Amp_Mode.get() == 0:
10128  if AWGBMode.get() == 1: # convert to mA
10129  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
10130  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
10131  else:
10132  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
10133  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
10134  else:
10135  if AWGBMode.get() == 1: # convert to mA
10136  amplitude = AWGBAmplvalue/1000.0
10137  offset = AWGBOffsetvalue/1000.0
10138  else:
10139  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
10140  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
10141  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10142  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10143  #
10144  if AWG_2X.get() == 2:
10145  Tempwaveform = []
10146  AWGB2X = []
10147  AWGB2X = AWGBwaveform[::2] # even numbered samples
10148  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
10149  AWGBwaveform = Tempwaveform
10150  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10151  BAWGBPhaseDelay()
10152  duty2lab.config(text="%")
10153  UpdateAwgCont()
10154 #
10156  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
10157  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10158  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10159  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10160 
10161  BAWGBAmpl(0)
10162  BAWGBOffset(0)
10163  BAWGBFreq(0)
10164  BAWGBPhase(0)
10165  BAWGBDutyCycle(0)
10166 
10167  if AWGBFreqvalue > 0.0:
10168  if AWG_2X.get() == 2:
10169  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10170  else:
10171  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10172  else:
10173  AWGBperiodvalue = 0.0
10174  if AWG_Amp_Mode.get() == 1:
10175  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10176  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10177  else:
10178  MaxV = AWGBOffsetvalue
10179  MinV = AWGBAmplvalue
10180 
10181  PulseWidth = int(AWGBDutyCyclevalue*100)
10182  PulseSamples = int(AWGBperiodvalue/PulseWidth)
10183  AWGBwaveform = []
10184  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
10185  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
10186  # print(v)
10187  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
10188  if j >= v:
10189  AWGBwaveform.append(MaxV) # j>=v?1:0
10190  else:
10191  AWGBwaveform.append(MinV) # j>=v?1:0
10193  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10194  duty2lab.config(text="PWidth")
10195  UpdateAwgCont()
10196 #
10198  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
10199  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
10200  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10201  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10202 
10203  BAWGBAmpl(0)
10204  BAWGBOffset(0)
10205  BAWGBFreq(0)
10206  BAWGBPhase(0)
10207  BAWGBDutyCycle(0)
10208 
10209  if AWGBFreqvalue > 0.0:
10210  if AWG_2X.get() == 1:
10211  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
10212  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10213  AWGBperiodvalue = AWGBperiodvalue + 1
10214  else:
10215  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10216  else:
10217  AWGBperiodvalue = 0.0
10218  if AWG_Amp_Mode.get() == 1:
10219  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10220  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10221  else:
10222  MaxV = AWGBOffsetvalue
10223  MinV = AWGBAmplvalue
10224 
10225  if AWGBPhaseDelay.get() == 0:
10226  if AWGBPhasevalue > 0:
10227  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10228  else:
10229  AWGBdelayvalue = 0.0
10230  elif AWGBPhaseDelay.get() == 1:
10231  AWGBdelayvalue = AWGBPhasevalue * SampleRate / 1000
10232 
10233  Cycles = int(AWGBDutyCyclevalue*100)
10234  NCycles = -1 * Cycles
10235  AWGBwaveform = []
10236  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, SAMPLErate/AWGBFreqvalue))
10237  amplitude = (MaxV-MinV) / 2.0
10238  offset = (MaxV+MinV) / 2.0
10239  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10240  Cycles = int(37500/AWGBperiodvalue)
10241  if Cycles < 1:
10242  Cycles = 1
10243  if Cycles > 1:
10244  Extend = int((Cycles-1.0)*AWGBperiodvalue/2.0)
10245  AWGBwaveform = numpy.pad(AWGBwaveform, (Extend,Extend), 'wrap')
10246  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10248  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10249  #BAWGAPhaseDelay()
10250  duty2lab.config(text="Cycles")
10251  UpdateAwgCont()
10252 #
10254  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10255  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10256  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10257  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10258  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10259  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10260 
10261  BAWGBAmpl(0)
10262  BAWGBOffset(0)
10263  BAWGBFreq(0)
10264  BAWGBPhase(0)
10265  BAWGBDutyCycle(0)
10266 
10267  if AWGBFreqvalue > 0.0:
10268  if AWG_2X.get() == 2:
10269  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10270  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10271  else:
10272  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10273  SamplesPermS = int(BaseSampleRate/1000) # 100
10274  else:
10275  AWGBperiodvalue = 0.0
10276  if AWG_Amp_Mode.get() == 1:
10277  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10278  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10279  else:
10280  MaxV = AWGBOffsetvalue
10281  MinV = AWGBAmplvalue
10282  AWGBwaveform = []
10283  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
10284  if SlopeValue <= 0:
10285  SlopeValue = 1
10286  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10287  if PulseWidth <=0:
10288  PulseWidth = 1
10289  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
10290  if Remainder <= 0:
10291  Remainder = 1
10292  PulseWidth = PulseWidth - SlopeValue
10293  if PulseWidth <=0:
10294  PulseWidth = 1
10295  StepAmp = (MaxV - MinV)/2
10296  StepOff = (MaxV + MinV)/2
10297  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
10298  MidArray = numpy.ones(PulseWidth) * MinV
10299  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
10300  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
10301  if AWGBBurstFlag.get() == 1:
10302  TempOneCycle = AWGBwaveform
10303  for i in range(AWGBCycles-1):
10304  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10305  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10306  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10308  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10309  duty2lab.config(text="%")
10310  phaseblab.config(text = "Rise Time")
10311  UpdateAwgCont()
10312 #
10314  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10315  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10316  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10317  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10318  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10319  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10320 
10321  BAWGBAmpl(0)
10322  BAWGBOffset(0)
10323  BAWGBFreq(0)
10324  BAWGBPhase(0)
10325  BAWGBDutyCycle(0)
10326 
10327  if AWGBFreqvalue > 0.0:
10328  if AWG_2X.get() == 2:
10329  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10330  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10331  else:
10332  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10333  SamplesPermS = int(BaseSampleRate/1000) # 100
10334  else:
10335  AWGBperiodvalue = 0.0
10336  if AWG_Amp_Mode.get() == 1:
10337  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10338  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10339  else:
10340  MaxV = AWGBOffsetvalue
10341  MinV = AWGBAmplvalue
10342  AWGBwaveform = []
10343  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
10344  if SlopeValue <= 0:
10345  SlopeValue = 1
10346  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10347  if PulseWidth <=0:
10348  PulseWidth = 1
10349  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
10350  if Remainder <= 0:
10351  Remainder = 1
10352  PulseWidth = PulseWidth - SlopeValue
10353  if PulseWidth <=0:
10354  PulseWidth = 1
10355  StepValue = (MaxV - MinV) / SlopeValue
10356  SampleValue = MinV
10357  for i in range(SlopeValue):
10358  AWGBwaveform.append(SampleValue)
10359  SampleValue = SampleValue + StepValue
10360  for i in range(PulseWidth):
10361  AWGBwaveform.append(MaxV)
10362  for i in range(SlopeValue):
10363  AWGBwaveform.append(SampleValue)
10364  SampleValue = SampleValue - StepValue
10365  for i in range(Remainder):
10366  AWGBwaveform.append(MinV)
10367  if AWGBBurstFlag.get() == 1:
10368  TempOneCycle = AWGBwaveform
10369  for i in range(AWGBCycles-1):
10370  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10371  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10372  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10374  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10375  duty2lab.config(text="%")
10376  phaseblab.config(text = "Rise Time")
10377  UpdateAwgCont()
10378 #
10380  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10381  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10382  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10383  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10384  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10385  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10386 
10387  BAWGBAmpl(0)
10388  BAWGBOffset(0)
10389  BAWGBFreq(0)
10390  BAWGBPhase(0)
10391 
10392  try:
10393  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
10394  except:
10395  AWGBDutyCycleEntry.delete(0,"end")
10396  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
10397 
10398  if AWGBFreqvalue > 0.0:
10399  if AWG_2X.get() == 2:
10400  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10401  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10402  else:
10403  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10404  SamplesPermS = int(BaseSampleRate/1000) # 100
10405  else:
10406  AWGBperiodvalue = 0.0
10407  if AWG_Amp_Mode.get() == 1:
10408  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10409  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10410  else:
10411  MaxV = AWGBOffsetvalue
10412  MinV = AWGBAmplvalue
10413  AWGBwaveform = []
10414  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
10415  if SlopeValue <= 0:
10416  SlopeValue = 1
10417  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
10418  if PulseWidth <=0:
10419  PulseWidth = 1
10420  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
10421  if Remainder <= 0:
10422  Remainder = 1
10423  PulseWidth = PulseWidth - SlopeValue
10424  if PulseWidth <=0:
10425  PulseWidth = 1
10426  StepValue = (MaxV - MinV) / SlopeValue
10427  SampleValue = MinV
10428  for i in range(SlopeValue):
10429  AWGBwaveform.append(SampleValue)
10430  SampleValue = SampleValue + StepValue
10431  for i in range(PulseWidth):
10432  AWGBwaveform.append(MaxV)
10433  for i in range(SlopeValue):
10434  AWGBwaveform.append(SampleValue)
10435  SampleValue = SampleValue - StepValue
10436  for i in range(Remainder):
10437  AWGBwaveform.append(MinV)
10438  if AWGBBurstFlag.get() == 1:
10439  TempOneCycle = AWGBwaveform
10440  for i in range(AWGBCycles-1):
10441  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10442  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10443  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10445  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10446  duty2lab.config(text="Width mS")
10447  phaseblab.config(text = "Rise Time")
10448  UpdateAwgCont()
10449 #
10451  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10452  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10453  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10454  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10455  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10456  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10457 
10458  BAWGBAmpl(0)
10459  BAWGBOffset(0)
10460  BAWGBFreq(0)
10461  BAWGBPhase(0)
10462  BAWGBDutyCycle(0)
10463 
10464  if AWGBFreqvalue > 0.0:
10465  if AWG_2X.get() == 2:
10466  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10467  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10468  else:
10469  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10470  SamplesPermS = int(BaseSampleRate/1000) # 100
10471  else:
10472  AWGBperiodvalue = 0.0
10473  if AWG_Amp_Mode.get() == 1:
10474  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10475  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10476  else:
10477  MaxV = AWGBOffsetvalue
10478  MinV = AWGBAmplvalue
10479  AWGBwaveform = []
10480  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
10481  if SlopeValue <= 0:
10482  SlopeValue = 1
10483  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10484  if PulseWidth <=0:
10485  PulseWidth = 1
10486  Remainder = int(AWGBperiodvalue - PulseWidth)
10487  if Remainder <= 0:
10488  Remainder = 1
10489  PulseWidth = PulseWidth - SlopeValue
10490  if PulseWidth <=0:
10491  PulseWidth = 1
10492  StepValue = (MaxV - MinV) / SlopeValue
10493  SampleValue = MinV
10494  for i in range(SlopeValue):
10495  AWGBwaveform.append(SampleValue)
10496  SampleValue = SampleValue + StepValue
10497  for i in range(PulseWidth):
10498  AWGBwaveform.append(MaxV)
10499  for i in range(Remainder):
10500  AWGBwaveform.append(MinV)
10501  if AWGBBurstFlag.get() == 1:
10502  TempOneCycle = AWGBwaveform
10503  for i in range(AWGBCycles-1):
10504  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10505  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10506  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10508  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10509  duty2lab.config(text="%")
10510  phaseblab.config(text = "Slope Time")
10511  UpdateAwgCont()
10512 #
10514  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10515  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10516  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10517  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10518  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10519  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10520 
10521  BAWGBAmpl(0)
10522  BAWGBOffset(0)
10523  BAWGBFreq(0)
10524  BAWGBPhase(0)
10525  BAWGBDutyCycle(0)
10526 
10527  if AWGBFreqvalue > 0.0:
10528  if AWG_2X.get() == 2:
10529  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10530  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10531  else:
10532  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10533  SamplesPermS = int(BaseSampleRate/1000) # 100
10534  else:
10535  AWGBperiodvalue = 0.0
10536  if AWG_Amp_Mode.get() == 1:
10537  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10538  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10539  else:
10540  MaxV = AWGBOffsetvalue
10541  MinV = AWGBAmplvalue
10542  #
10543  if AWGBPhaseDelay.get() == 0:
10544  if AWGBPhasevalue > 0:
10545  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10546  else:
10547  AWGBdelayvalue = 0.0
10548  elif AWGBPhaseDelay.get() == 1:
10549  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
10550  #
10551  AWGBwaveform = []
10552  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10553  if PulseWidth <=0:
10554  PulseWidth = 1
10555  Remainder = int(AWGBperiodvalue - PulseWidth)
10556  if Remainder <= 0:
10557  Remainder = 1
10558  UpStepValue = (MaxV - MinV) / PulseWidth
10559  DownStepValue = (MaxV - MinV) / Remainder
10560  SampleValue = MinV
10561  for i in range(PulseWidth):
10562  AWGBwaveform.append(SampleValue)
10563  SampleValue = SampleValue + UpStepValue
10564  for i in range(Remainder):
10565  AWGBwaveform.append(SampleValue)
10566  SampleValue = SampleValue - DownStepValue
10567  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10568  if AWGBBurstFlag.get() == 1:
10569  TempOneCycle = AWGBwaveform
10570  for i in range(AWGBCycles-1):
10571  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10572  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10573  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10575  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10576  BAWGBPhaseDelay()
10577  duty2lab.config(text = "Symmetry")
10578  UpdateAwgCont()
10579 #
10581  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10582  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10583  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10584  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10585  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10586  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10587 
10588  BAWGBAmpl(0)
10589  BAWGBOffset(0)
10590  BAWGBFreq(0)
10591  BAWGBPhase(0)
10592  BAWGBDutyCycle(0)
10593 
10594  if AWGBFreqvalue > 0.0:
10595  if AWG_2X.get() == 2:
10596  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10597  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10598  else:
10599  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10600  SamplesPermS = int(BaseSampleRate/1000) # 100
10601  else:
10602  AWGBperiodvalue = 0.0
10603  if AWG_Amp_Mode.get() == 1:
10604  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10605  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10606  else:
10607  MaxV = AWGBOffsetvalue
10608  MinV = AWGBAmplvalue
10609  AWGBwaveform = []
10610  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
10611  if AWGBPhaseDelay.get() == 0:
10612  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
10613  elif AWGBPhaseDelay.get() == 1:
10614  DelayValue = int(AWGBPhasevalue*SamplesPermS)
10615  for i in range(DelayValue-PulseWidth):
10616  AWGBwaveform.append((MinV+MaxV)/2)
10617  for i in range(PulseWidth):
10618  AWGBwaveform.append(MaxV)
10619  for i in range(PulseWidth):
10620  AWGBwaveform.append(MinV)
10621  DelayValue = int(AWGBperiodvalue-DelayValue)
10622  for i in range(DelayValue-PulseWidth):
10623  AWGBwaveform.append((MinV+MaxV)/2)
10624  if AWGBBurstFlag.get() == 1:
10625  TempOneCycle = AWGBwaveform
10626  for i in range(AWGBCycles-1):
10627  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10628  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10629  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10631  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10632  UpdateAwgCont()
10633 
10635  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
10636  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10637  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10638  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10639  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10640 
10641  BAWGBAmpl(0)
10642  BAWGBOffset(0)
10643  BAWGBFreq(0)
10644 
10645  if AWGBFreqvalue > 0.0:
10646  if AWG_2X.get() == 2:
10647  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10648  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10649  else:
10650  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10651  SamplesPermS = int(BaseSampleRate/1000) # 100
10652  else:
10653  AWGBperiodvalue = 0.0
10654 
10655  if AWGBAmplvalue > AWGBOffsetvalue:
10656  MinV = AWGBOffsetvalue
10657  MaxV = AWGBAmplvalue
10658  else:
10659  MaxV = AWGBOffsetvalue
10660  MinV = AWGBAmplvalue
10661  if AWG_Amp_Mode.get() == 1:
10662  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10663  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10664  AWGBwaveform = []
10665  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
10666  Mid = (MaxV+MinV)/2
10667  if AWGBBurstFlag.get() == 1:
10668  TempOneCycle = AWGBwaveform
10669  for i in range(AWGBCycles-1):
10670  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10671  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10672  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
10674  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10675  UpdateAwgCont()
10676 
10678  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
10679  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10680  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10681  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10682  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10683 
10684  BAWGBAmpl(0)
10685  BAWGBOffset(0)
10686  BAWGBFreq(0)
10687 
10688  if AWGBFreqvalue > 0.0:
10689  if AWG_2X.get() == 2:
10690  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10691  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10692  else:
10693  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10694  SamplesPermS = int(BaseSampleRate/1000) # 100
10695  else:
10696  AWGBperiodvalue = 0.0
10697  if AWGBAmplvalue > AWGBOffsetvalue:
10698  MinV = AWGBOffsetvalue
10699  MaxV = AWGBAmplvalue
10700  else:
10701  MaxV = AWGBOffsetvalue
10702  MinV = AWGBAmplvalue
10703  if AWG_Amp_Mode.get() == 1:
10704  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10705  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10706  AWGBwaveform = []
10707  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
10708  Mid = (MaxV+MinV)/2
10709  if AWGBBurstFlag.get() == 1:
10710  TempOneCycle = AWGBwaveform
10711  for i in range(AWGBCycles-1):
10712  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10713  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10714  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
10716  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10717  UpdateAwgCont()
10718 
10720  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
10721 
10722  if AWGBMode.get() == 0: # Source Voltage measure current mode
10723  label_txt = "SVMI"
10724  elif AWGBMode.get() == 1: # Source current measure voltage mode
10725  label_txt = "SIMV"
10726  elif AWGBMode.get() == 2: # High impedance mode
10727  label_txt = "Hi-Z"
10728  if AWGBIOMode.get() > 0: # Split Input / Output mode
10729  if HWRevOne == "D":
10730  if AWGBMode.get() == 0:
10731  AWGBMode.set(1)
10732  CHB.set_mode('i') # channel must be in source current mode for rev D boards
10733  label_txt = "SIMV"
10734  label_txt = label_txt + " Split I/O"
10735  label_txt = label_txt + " Mode"
10736  AWGBModeLabel.config(text = label_txt ) # change displayed value
10737  ReMakeAWGwaves()
10738  #UpdateAwgCont()
10739 
10741  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
10742  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
10743  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
10744  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
10745  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
10746  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10747  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag
10748  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10749 
10750  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
10751  amp2lab.config(text = "Min Ch B" ) # change displayed value
10752  off2lab.config(text = "Max Ch B" ) # change displayed value
10753  else:
10754  amp2lab.config(text = "Amp Ch B" )
10755  off2lab.config(text = "Off Ch B" )
10756 #
10757  if AWG_2X.get() == 1:
10758  AWGBWave = 'arbitrary'
10759  if AWGBFreqvalue > 0.0:
10760  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
10761  else:
10762  AWGBperiodvalue = 0.0
10763 #
10764  if AWGBPhaseDelay.get() == 0:
10765  if AWGBWave == 'square':
10766  AWGBPhasevalue = AWGBPhasevalue + 270.0
10767  if AWGBPhasevalue > 359:
10768  AWGBPhasevalue = AWGBPhasevalue - 360
10769  if AWGBPhasevalue > 0:
10770  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10771  else:
10772  AWGBdelayvalue = 0.0
10773  elif AWGBPhaseDelay.get() == 1:
10774  AWGBdelayvalue = AWGBPhasevalue * 100
10775 #
10776  if AWGBTerm.get() == 0: # Open termination
10777  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
10778  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
10779  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
10780  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
10781  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
10782  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
10783  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
10784  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
10785 
10786  if AWGBWave == 'dc':
10787  if AWG_2X.get() == 1:
10788  AWGBWave == 'arbitrary'
10789  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
10790  else:
10791  if AWGBMode.get() == 0: # Source Voltage measure current mode
10792  if AWGBIOMode.get() == 0:
10793  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
10794  else:
10795  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
10796  CHB.constant(AWGBOffsetvalue)
10797  if AWGBMode.get() == 1: # Source current measure Voltage mode
10798  if AWGBIOMode.get() == 0:
10799  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
10800  else:
10801  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
10802  CHB.constant(AWGBOffsetvalue/1000)
10803  if AWGBMode.get() == 2: # Hi impedance mode
10804  if AWGBIOMode.get() == 0:
10805  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
10806  else:
10807  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
10808 #
10809  if AWGBIOMode.get() > 0: # Split Input / Output mode
10810  if HWRevOne == "D":
10811  AWGBMode.set(1)
10812  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
10813 #
10814  else:
10815  if AWGBMode.get() == 0: # Source Voltage measure current mode
10816  if AWGBIOMode.get() == 0:
10817  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
10818  else:
10819  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
10820  if AWGBMode.get() == 1: # Source current measure Voltage mode
10821  if AWGBIOMode.get() == 0:
10822  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
10823  else:
10824  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
10825  AWGBOffsetvalue = AWGBOffsetvalue/1000
10826  AWGBAmplvalue = AWGBAmplvalue/1000
10827  if AWGBMode.get() == 2: # Hi impedance mode
10828  if AWGBIOMode.get() == 0:
10829  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
10830  else:
10831  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
10832  else:
10833  if AWG_Amp_Mode.get() == 1:
10834  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
10835  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
10836  else:
10837  MaxV = AWGBOffsetvalue
10838  MinV = AWGBAmplvalue
10839  try: # keep going even if low level library returns an error
10840  if AWGBWave == 'sine':
10841  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10842  elif AWGBWave == 'triangle':
10843  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10844  elif AWGBWave == 'sawtooth':
10845  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10846  elif AWGBWave == 'square':
10847  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
10848  elif AWGBWave == 'stairstep':
10849  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10850  elif AWGBWave == 'arbitrary':
10851  if AWGSync.get() == 0:
10852  AWGBRepeatFlag.set(1)
10853  if AWG_2X.get() == 1:
10854  AWGBWave == 'arbitrary'
10855  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
10856  else:
10857  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
10858  except:
10859  donothing()
10860  if AWGBIOMode.get() > 0: # Split Input / Output mode
10861  if HWRevOne == "D":
10862  AWGBMode.set(1)
10863  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
10864 #
10866  global session, CHA, CHB, AWGSync
10867  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
10868  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
10869  if session.continuous:
10870  session.end()
10871  BAWGEnab() # set-up new AWG settings
10872  time.sleep(0.01) # wait awhile here for some reason
10873  session.start(0)
10874 #
10876  UpdateAwgCont()
10877 
10878 def BAWGEnab():
10879  global AWGAMode, AWGBMode, AWGSync
10880  global CHA, CHB, discontloop, contloop, session
10881 
10882  # Stream = False
10883  # print "Updateing AWGs"
10884  BAWGAAmpl(0)
10885  BAWGAOffset(0)
10886  BAWGAFreq(0)
10887  BAWGAPhase(0)
10888  BAWGADutyCycle(0)
10889  BAWGAShape()
10890  BAWGBAmpl(0)
10891  BAWGBOffset(0)
10892  BAWGBFreq(0)
10893  BAWGBPhase(0)
10894  BAWGBDutyCycle(0)
10895  BAWGBShape()
10896  UpdateAWGA()
10897  UpdateAWGB()
10898 
10899 def BAWGSync():
10900  global RUNstatus, AWGSync, session, CHA, CHB
10901 
10902  if (RUNstatus.get() == 1): # do this only if running
10903  if AWGSync.get() == 0:
10904  #UpdateAwgCont()
10905  session.flush()
10906  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
10907  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
10908  BAWGEnab()
10909  session.start(0)
10910  time.sleep(0.02) # wait awhile here for some reason
10911  elif session.continuous:
10912  session.end()
10913  session.flush()
10914  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
10915  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
10916 
10917 # ======= Spectrum Analyzer functions ===========
10918 #
10920  global CANVASwidthF, CANVASheightF, freqwindow
10921  global COLORtext
10922  # ask for file name
10923  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
10924  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
10925  if MarkerNum > 0 or ColorMode.get() > 0:
10926  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
10927  else: # temp change text color to black
10928  COLORtext = "#000000"
10930  # save postscript file
10931  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
10932  #
10933  COLORtext = "#ffffff"
10935 #
10936 def Bnot():
10937  print( "Routine not made yet")
10938 
10940  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
10941  ShowC1_VdB.set(1)
10942  ShowC1_P.set(1)
10943  ShowC2_VdB.set(1)
10944  ShowC2_P.set(1)
10945 
10947  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
10948  ShowC1_VdB.set(0)
10949  ShowC1_P.set(0)
10950  ShowC2_VdB.set(0)
10951  ShowC2_P.set(0)
10952 
10954  global RUNstatus
10955  global FreqTraceMode
10956 
10957  FreqTraceMode.set(1)
10958  if RUNstatus.get() == 0: # Update if stopped
10960  if RUNstatus.get() == 2: # Restart if running
10961  RUNstatus.set(4)
10962 
10964  global RUNstatus
10965  global FreqTraceMode
10966 
10967  FreqTraceMode.set(2)
10968  if RUNstatus.get() == 0: # Update if stopped
10970  if RUNstatus.get() == 2: # Restart if running
10971  RUNstatus.set(4)
10972 
10974  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
10975 
10976  FreqTraceMode.set(3)
10977 
10978  if RUNstatus.get() == 0: # Update if stopped
10980  if RUNstatus.get() == 2: # Restart if running
10981  RUNstatus.set(4)
10982 
10984  global FreqTraceMode, TRACEresetFreq
10985 
10986  if FreqTraceMode.get()==3:
10987  TRACEresetFreq = True
10988 
10990  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
10991  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
10992  global T1Pline, T2Pline, T1PRline, T2PRline
10993  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
10994  global PeakxM, PeakyM, PeakMdb, PeakfreqM
10995  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
10996  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
10997  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
10998 
10999  if ShowC1_VdB.get() == 1:
11000  T1FRline = T1Fline
11001  PeakxRA = PeakxA
11002  PeakyRA = PeakyA
11003  PeakdbRA = PeakdbA
11004  PeakfreqRA = PeakfreqA
11005  if ShowC2_VdB.get() == 1:
11006  T2FRline = T2Fline
11007  PeakxRB = PeakxB
11008  PeakyRB = PeakyB
11009  PeakdbRB = PeakdbB
11010  PeakfreqRB = PeakfreqB
11011  if ShowC1_P.get() == 1:
11012  T1PRline = T1Pline
11013  if ShowC2_P.get() == 1:
11014  T2PRline = T2Pline
11015  if ShowMathSA.get() > 0:
11016  TFRMline = TFMline
11017  PeakxRM = PeakxM
11018  PeakyRM = PeakyM
11019  PeakRMdb = PeakMdb
11020  PeakfreqRM = PeakfreqM
11021 
11022  UpdateFreqTrace() # Always Update
11023 #
11025  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
11026  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
11027  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
11028  global TAPline, TBPline, TAPRline, TBPRline
11029  global TIARline, TIAXline, TIAMagline, TIAAngline
11030  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
11031  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
11032  global PeakxM, PeakyM, PeakMdb, PeakfreqM
11033  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
11034  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
11035  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
11036 
11037  if ShowCA_VdB.get() == 1:
11038  TAFRline = TAFline
11039  PeakxRA = PeakxA
11040  PeakyRA = PeakyA
11041  PeakdbRA = PeakdbA
11042  PeakfreqRA = PeakfreqA
11043  if ShowCB_VdB.get() == 1:
11044  TBFRline = TBFline
11045  PeakxRB = PeakxB
11046  PeakyRB = PeakyB
11047  PeakdbRB = PeakdbB
11048  PeakfreqRB = PeakfreqB
11049  if ShowCA_P.get() == 1:
11050  TAPRline = TAPline
11051  if ShowCB_P.get() == 1:
11052  TBPRline = TBPline
11053  if ShowMathBP.get() > 0:
11054  TBPRMline = TBPMline
11055  PeakxRM = PeakxM
11056  PeakyRM = PeakyM
11057  PeakRMdb = PeakMdb
11058  PeakfreqRM = PeakfreqM
11059  if Show_Rseries.get() > 0:
11060  RefIARline = TIARline
11061  if Show_Xseries.get() > 0:
11062  RefIAXline = TIAXline
11063  if Show_Magnitude.get() > 0:
11064  RefIAMagline = TIAMagline
11065  if Show_Angle.get() > 0:
11066  RefIAAngline = TIAAngline
11067  UpdateBodeTrace() # Always Update
11068 #
11069 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
11070  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
11071  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11072 
11073  # Set the TRACEsize variable
11074  if ShowCA_VdB.get() == 1:
11075  TRACEsize = len(FSweepAdB) # Set the trace length
11076  elif ShowCA_VdB.get() == 1:
11077  TRACEsize = len(FSweepBdB)
11078  if TRACEsize == 0: # If no trace, skip rest of this routine
11079  return()
11080 # ask if save as magnitude or dB
11081  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
11082 # Yes 1 = dB, No 0 = Mag
11083  # Make the file name and open it
11084  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
11085  filename = "Bode-" + tme
11086  filename = filename + ".csv"
11087  # open file to save data
11088  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
11089  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
11090  DataFile = open(filename,'a') # Open output file
11091  HeaderString = 'Frequency-#, '
11092  if ShowCA_VdB.get() == 1:
11093  if dB == 1:
11094  HeaderString = HeaderString + 'CA-dB, '
11095  if dB == 0:
11096  HeaderString = HeaderString + 'CA-Mag, '
11097  if ShowCB_VdB.get() == 1:
11098  if dB == 1:
11099  HeaderString = HeaderString + 'CB-dB, '
11100  if dB == 0:
11101  HeaderString = HeaderString + 'CB-Mag, '
11102  if ShowCA_P.get() == 1:
11103  HeaderString = HeaderString + 'Phase A-B, '
11104  if ShowCB_P.get() == 1:
11105  HeaderString = HeaderString + 'Phase B-A, '
11106  HeaderString = HeaderString + '\n'
11107  DataFile.write( HeaderString )
11108 
11109  n = 0
11110  while n < len(FSweepAdB):
11111  F = FBins[FStep[n]] # look up frequency bin in list of bins
11112  txt = str(F)
11113  if ShowCA_VdB.get() == 1:
11114  V = 10 * math.log10(float(FSweepAdB[n])) + 17 # Add 17 dB for max value of +10 dB
11115  if dB == 0:
11116  V = 10.0**(V/20.0)
11117  txt = txt + "," + str(V)
11118  if ShowCB_VdB.get() == 1:
11119  V = 10 * math.log10(float(FSweepBdB[n])) + 17 # Add 17 dB for max value of +10 dB
11120  if dB == 0:
11121  V = 10.0**(V/20.0)
11122  txt = txt + "," + str(V)
11123  if ShowCA_P.get() == 1:
11124  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
11125  if RelPhase > 180:
11126  RelPhase = RelPhase - 360
11127  elif RelPhase < -180:
11128  RelPhase = RelPhase + 360
11129  txt = txt + "," + str(RelPhase)
11130  if ShowCB_P.get() == 1:
11131  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
11132  if RelPhase > 180:
11133  RelPhase = RelPhase - 360
11134  elif RelPhase < -180:
11135  RelPhase = RelPhase + 360
11136  txt = txt + "," + str(RelPhase)
11137  txt = txt + "\n"
11138  DataFile.write(txt)
11139  n = n + 1
11140 
11141  DataFile.close() # Close the file
11142 
11144  global iawindow, FStep, FBins
11145  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
11146 
11147  if NetworkScreenStatus.get() > 0:
11148  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
11149  filename = "Impedance-" + tme
11150  filename = filename + ".csv"
11151  # open file to save data
11152  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
11153  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
11154  DataFile = open(filename,'a') # Open output file
11155  HeaderString = 'Frequency, Series R, Seriec X, Series Z, Series Angle'
11156  HeaderString = HeaderString + '\n'
11157  DataFile.write( HeaderString )
11158 
11159  n = 0
11160  while n < len(NSweepSeriesR):
11161  F = FBins[FStep[n]] # look up frequency bin in list of bins
11162  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
11163  txt = txt + "\n"
11164  DataFile.write(txt)
11165  n = n + 1
11166  DataFile.close() # Close the file
11167  else:
11168  return
11169 #
11170 def BStartSA():
11171  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
11172  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
11173  global Two_X_Sample, ADC_Mux_Mode
11174 
11175  #AWGSync.set(0) # always run in continuous mode
11176  if DevID == "No Device":
11177  showwarning("WARNING","No Device Plugged In!")
11178  elif FWRevOne == 0.0:
11179  showwarning("WARNING","Out of data Firmware!")
11180  else:
11181  if PowerStatus == 0:
11182  PowerStatus = 1
11183  PwrBt.config(style="Pwr.TButton",text="PWR-On")
11184  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
11185 
11186  if ShowC1_VdB.get() == 0 and ShowC2_VdB.get() == 0 and ShowMathSA.get() == 0 and ShowC1_P.get() == 0 and ShowC2_P.get() == 0:
11187  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
11188  return()
11189  try:
11190  StopFrequency = float(StopFreqEntry.get())
11191  except:
11192  StopFreqEntry.delete(0,"end")
11193  StopFreqEntry.insert(0,50000)
11194  StopFrequency = 50000
11195  if FWRevOne > 2.16:
11196  if StopFrequency >= 50000:
11197  Two_X_Sample.set(1)
11198  else:
11199  Two_X_Sample.set(0)
11200  ADC_Mux_Mode.set(0)
11201  SetADC_Mux()
11202  #
11203  BStart()
11204 #
11205  UpdateFreqAll() # Always Update
11206 
11207 def BStopSA():
11208  global RUNstatus, session, AWGSync
11209 
11210  if (RUNstatus.get() == 1):
11211  RUNstatus.set(0)
11212  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11213  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
11214  if AWGSync.get() == 0: # running in continuous mode
11215  CHA.constant(0.0)
11216  CHB.constant(0.0)
11217  # print "Stoping continuous mode"
11218  if session.continuous:
11219  # print "Stoping Is Continuous? ", session.continuous
11220  time.sleep(0.02)
11221  #print "Is Continuous? ", session.continuous
11222  else:
11223  contloop = 0
11224  discontloop = 1
11225  session.cancel()
11226  elif (RUNstatus.get() == 2):
11227  RUNstatus.set(3)
11228  elif (RUNstatus.get() == 3):
11229  RUNstatus.set(3)
11230  elif (RUNstatus.get() == 4):
11231  RUNstatus.set(3)
11232  UpdateFreqAll() # Always Update
11233 
11234 def Blevel1():
11235  global DBlevel
11236  global RUNstatus
11237 
11238  DBlevel.set(DBlevel.get() - 1)
11239 
11240  if RUNstatus.get() == 0: # Update if stopped
11241  UpdateFreqTrace()
11242 
11243 def Blevel2():
11244  global DBlevel
11245  global RUNstatus
11246 
11247  DBlevel.set(DBlevel.get() + 1)
11248 
11249  if RUNstatus.get() == 0: # Update if stopped
11250  UpdateFreqTrace()
11251 
11252 def Blevel3():
11253  global DBlevel
11254  global RUNstatus
11255 
11256  DBlevel.set(DBlevel.get() - 10)
11257 
11258  if RUNstatus.get() == 0: # Update if stopped
11259  UpdateFreqTrace()
11260 
11261 def Blevel4():
11262  global DBlevel
11263  global RUNstatus
11264 
11265  DBlevel.set(DBlevel.get() + 10)
11266 
11267  if RUNstatus.get() == 0: # Update if stopped
11268  UpdateFreqTrace()
11269 #
11271  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
11272  global SMPfftpwrTwo, SMPfft, FFTwindow
11273  global TRACEresetFreq
11274 
11275  if FFTwindow.get() != 8:
11276  if (SMPfftpwrTwo.get() > 6): # Min 64
11277  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
11278  TRACEresetFreq = True # Reset trace peak and trace average
11279  SMPfft = 2 ** int(SMPfftpwrTwo.get())
11280 
11281  if RUNstatus.get() == 0: # Update if stopped
11282  if SpectrumScreenStatus.get() > 0:
11284  if IAScreenStatus.get() > 0:
11285  UpdateIAScreen()
11286  if RUNstatus.get() == 2: # Restart if running
11287  RUNstatus.set(4)
11288 
11290  global RUNstatus
11291  global SMPfftpwrTwo, SMPfft, FFTwindow
11292  global TRACEresetFreq
11293 
11294  if FFTwindow.get() != 8:
11295  if (SMPfftpwrTwo.get() < 16): # Max 65536
11296  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
11297  TRACEresetFREQ = True # Reset trace peak and trace average
11298  SMPfft = 2 ** int(SMPfftpwrTwo.get())
11299 
11300  if RUNstatus.get() == 0: # Update if stopped
11301  if SpectrumScreenStatus.get() > 0:
11303  if IAScreenStatus.get() > 0:
11304  UpdateIAScreen()
11305  if RUNstatus.get() == 2: # Restart if running
11306  RUNstatus.set(4)
11307 
11308 def BDBdiv1():
11309  global DBdivindex
11310  global RUNstatus
11311 
11312  if (DBdivindex.get() >= 1):
11313  DBdivindex.set(DBdivindex.get() - 1)
11314 
11315  if RUNstatus.get() == 0: # Update if stopped
11316  UpdateFreqTrace()
11317 
11318 def BDBdiv2():
11319  global DBdivindex
11320  global DBdivlist
11321  global RUNstatus
11322 
11323  if (DBdivindex.get() < len(DBdivlist) - 1):
11324  DBdivindex.set(DBdivindex.get() + 1)
11325 
11326  if RUNstatus.get() == 0: # Update if stopped
11327  UpdateFreqTrace()
11328 #----- Bode Plot controls
11329 def BStartBP():
11330  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
11331  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
11332  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
11333  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
11334  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
11335  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
11336  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
11337  global BeginIndex, EndIndex
11338 
11339  if DevID == "No Device":
11340  showwarning("WARNING","No Device Plugged In!")
11341  elif FWRevOne == 0.0:
11342  showwarning("WARNING","Out of data Firmware!")
11343  else:
11344  if PowerStatus == 0:
11345  PowerStatus = 1
11346  PwrBt.config(style="Pwr.TButton",text="PWR-On")
11347  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
11348 
11349  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
11350  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
11351  return()
11352  #
11353  if ZEROstuffing.get() < 3:
11354  ZEROstuffing.set(3)
11355  CutDC.set(1) # set to remove DC
11356  try:
11357  EndFreq = float(StopBodeEntry.get())
11358  except:
11359  StopBodeEntry.delete(0,"end")
11360  StopBodeEntry.insert(0,10000)
11361  EndFreq = 10000
11362  if FWRevOne > 2.16:
11363  if EndFreq >= 20000:
11364  Two_X_Sample.set(1)
11365  FBins = numpy.linspace(0, 100000, num=16384)
11366  else:
11367  Two_X_Sample.set(0)
11368  FBins = numpy.linspace(0, 50000, num=16384)
11369  ADC_Mux_Mode.set(0)
11370  SetADC_Mux()
11371  try:
11372  BeginFreq = float(StartBodeEntry.get())
11373  except:
11374  StartBodeEntry.delete(0,"end")
11375  StartBodeEntry.insert(0,100)
11376  BeginFreq = 100
11377  #
11378  if FSweepMode.get() == 1:
11379  if AWGAMode.get() == 2:
11380  AWGAMode.set(0) # Set AWG A to SVMI
11381  AWGAShape.set(18) # Set Shape to Sine
11382  if Two_X_Sample.get() == 1:
11383  AWGBIOMode.set(1)
11384  AWGBMode.set(0)
11385  else:
11386  AWGBMode.set(2) # Set AWG B to Hi-Z
11387  AWG_2X.set(0)
11388  BAWG2X()
11389  Reset_Freq = AWGAFreqEntry.get()
11390  if FSweepMode.get() == 2:
11391  if AWGBMode.get() == 2:
11392  AWGBMode.set(0) # Set AWG B to SVMI
11393  AWGBShape.set(18) # Set Shape to Sine
11394  if Two_X_Sample.get() == 1:
11395  AWGAIOMode.set(1)
11396  AWGAMode.set(0)
11397  else:
11398  AWGAMode.set(2) # Set AWG A to Hi-Z
11399  AWG_2X.set(0)
11400  BAWG2X()
11401  Reset_Freq = AWGBFreqEntry.get()
11402  if FSweepMode.get() == 3: # using external Minigen
11403  AWGAMode.set(2) # Set AWG A to Hi-Z
11404  AWGBMode.set(2) # Set AWG B to Hi-Z
11405  try:
11406  NSteps.set(float(SweepStepBodeEntry.get()))
11407  except:
11408  SweepStepBodeEntry.delete(0,"end")
11409  SweepStepBodeEntry.insert(0, NSteps.get())
11410  #
11411  if FSweepMode.get() > 0:
11412  BAWGAModeLabel() # make sure AWG screen labels reflect any changes to the modes
11413  BAWGBModeLabel()
11414  LoopNum.set(1)
11415  NyquistFreq = SAMPLErate/2
11416  BeginIndex = int((BeginFreq/NyquistFreq)*16384)
11417  EndIndex = int((EndFreq/NyquistFreq)*16384)
11418  if NSteps.get() < 5:
11419  NSteps.set(5)
11420  if HScaleBP.get() == 1:
11421  LogFStop = math.log10(EndIndex)
11422  try:
11423  LogFStart = math.log10(BeginIndex)
11424  except:
11425  LogFStart = 1.0
11426  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
11427  else:
11428  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
11429  BStart()
11430  # UpdateBodeAll() # Always Update
11431 #
11432 def BStopBP():
11433  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
11434 
11435  if FSweepMode.get() == 1:
11436  AWGAFreqEntry.delete(0,"end")
11437  AWGAFreqEntry.insert(0, Reset_Freq)
11438  if FSweepMode.get() == 2:
11439  AWGBFreqEntry.delete(0,"end")
11440  AWGBFreqEntry.insert(0, Reset_Freq)
11441 #
11442  if (RUNstatus.get() == 1):
11443  RUNstatus.set(0)
11444  if AWGSync.get() == 0: # running in continuous mode
11445  session.cancel() # cancel continuous session mode while paused
11446  elif (RUNstatus.get() == 2):
11447  RUNstatus.set(3)
11448  elif (RUNstatus.get() == 3):
11449  RUNstatus.set(3)
11450  elif (RUNstatus.get() == 4):
11451  RUNstatus.set(3)
11452  UpdateBodeAll() # Always Update
11453 #
11455  global DBlevelBP
11456  global RUNstatus
11457 
11458  DBlevelBP.set(DBlevelBP.get() - 1)
11459 
11460  if RUNstatus.get() == 0: # Update if stopped
11461  UpdateBodeTrace()
11462 
11464  global DBlevelBP
11465  global RUNstatus
11466 
11467  DBlevelBP.set(DBlevelBP.get() + 1)
11468 
11469  if RUNstatus.get() == 0: # Update if stopped
11470  UpdateBodeTrace()
11471 
11473  global DBlevelBP
11474  global RUNstatus
11475 
11476  DBlevelBP.set(DBlevelBP.get() - 10)
11477 
11478  if RUNstatus.get() == 0: # Update if stopped
11479  UpdateBodeTrace()
11480 
11482  global DBlevelBP
11483  global RUNstatus
11484 
11485  DBlevelBP.set(DBlevelBP.get() + 10)
11486 
11487  if RUNstatus.get() == 0: # Update if stopped
11488  UpdateBodeTrace()
11489 
11491  global DBdivindexBP
11492  global RUNstatus
11493 
11494  if (DBdivindexBP.get() >= 1):
11495  DBdivindexBP.set(DBdivindexBP.get() - 1)
11496 
11497  if RUNstatus.get() == 0: # Update if stopped
11498  UpdateBodeTrace()
11499 
11501  global DBdivindexBP
11502  global DBdivlist
11503  global RUNstatus
11504 
11505  if (DBdivindexBP.get() < len(DBdivlist) - 1):
11506  DBdivindexBP.set(DBdivindexBP.get() + 1)
11507 
11508  if RUNstatus.get() == 0: # Update if stopped
11509  UpdateBodeTrace()
11510 #
11512  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11513  ShowCA_VdB.set(1)
11514  ShowCA_P.set(1)
11515  ShowCB_VdB.set(1)
11516  ShowCB_P.set(1)
11517 
11519  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11520  ShowCA_VdB.set(0)
11521  ShowCA_P.set(0)
11522  ShowCB_VdB.set(0)
11523  ShowCB_P.set(0)
11524 # Bode Plot refresh
11525 def UpdateBodeAll(): # Update Data, trace and screen
11526  global FFTBuffA, FFTBuffB
11527  global SMPfft
11528 
11529  # DoFFT() # Fast Fourier transformation
11530  MakeBodeTrace() # Update the traces
11531  UpdateBodeScreen() # Update the screen
11532 
11533 def UpdateBodeTrace(): # Update trace and screen
11534  MakeBodeTrace() # Update traces
11535  UpdateBodeScreen() # Update the screen
11536 
11537 def UpdateBodeScreen(): # Update screen with trace and text
11538  MakeBodeScreen() # Update the screen
11539 
11540 # ============================================ Freq Main routine ====================================================
11541 
11542 def UpdateFreqAll(): # Update Data, trace and screen
11543  global FFTBuffA, FFTBuffB
11544  global SMPfft
11545 
11546  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
11547  return
11548 
11549  # DoFFT() # Fast Fourier transformation
11550  MakeFreqTrace() # Update the traces
11551  UpdateFreqScreen() # Update the screen
11552 
11553 def UpdateFreqTrace(): # Update trace and screen
11554  MakeFreqTrace() # Update traces
11555  UpdateFreqScreen() # Update the screen
11556 
11557 def UpdateFreqScreen(): # Update screen with trace and text
11558  MakeFreqScreen() # Update the screen
11559 
11560 def DoFFT(): # Fast Fourier transformation
11561  global FFTBuffA, FFTBuffB
11562  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
11563  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
11564  global FFTmemoryB, FFTresultB
11565  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
11566  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
11567  global FFTwindowshape, FFTbandwidth
11568  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
11569  global SMPfft, LoopNum, IA_Ext_Conf
11570  global STARTsample, STOPsample
11571  global TRACEaverage, FreqTraceMode, FSweepMode
11572  global TRACEresetFreq, ZEROstuffing
11573  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
11574  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
11575 
11576  # T1 = time.time() # For time measurement of FFT routine
11577  REX = []
11578  PhaseA = []
11579  PhaseB = []
11580  # Convert list to numpy array REX for faster Numpy calculations
11581  # Take the first fft samples
11582  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
11583 
11584  # Set Analog level display value MAX value is 5 volts for ALM1000
11585  REX = REX / 5.0
11586 
11587  # Do the FFT window function
11588  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
11589 
11590  # Zero stuffing of array for better interpolation of peak level of signals
11591  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11592  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11593 
11594  # Save previous trace in memory for max or average trace
11595  FFTmemoryA = FFTresultA
11596  if FreqTraceMode.get() == 3:
11597  PhaseMemoryA = PhaseA
11598 
11599  # FFT with numpy
11600  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11601  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
11602  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11603  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
11604 
11605  le = int(len(ALL) / 2) # Only half is used, other half is mirror
11606  ALL = ALL[0:le] # So take only first half of the array
11607  PhaseA = PhaseA[0:le]
11608  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11609  Totalcorr = Totalcorr * Totalcorr # For POWER!
11610  FFTresultA = Totalcorr * ALL
11611 #
11612  REX = []
11613  # Convert list to numpy array REX for faster Numpy calculations
11614  # Take the first fft samples
11615  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
11616 
11617  # Set level display value MAX value is 5 volts for ALM1000
11618  REX = REX / 5.0
11619 
11620  # Do the FFT window function
11621  try:
11622  REX = REX * FFTwindowshape # The windowing shape function only over the samples
11623  except:
11624  return
11625  # Zero stuffing of array for better interpolation of peak level of signals
11626  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11627  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11628 
11629  # Save previous trace in memory for max or average trace
11630  FFTmemoryB = FFTresultB
11631  if FreqTraceMode.get() == 3:
11632  PhaseMemoryB = PhaseB
11633  # FFT with numpy
11634  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11635  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
11636  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11637  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
11638 
11639  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
11640  ALL = ALL[0:le] # So take only first half of the array
11641  PhaseB = PhaseB[0:le]
11642  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11643  Totalcorr = Totalcorr * Totalcorr # For POWER!
11644  FFTresultB = Totalcorr * ALL
11645 #
11646  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
11647  REX = []
11648  PhaseAB = []
11649  # Convert list to numpy array REX for faster Numpy calculations
11650  # Take the first fft samples
11651  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
11652 
11653  # Set level display value MAX value is 5 volts for ALM1000
11654  REX = REX / 5.0
11655 
11656  # Do the FFT window function
11657  REX = REX * FFTwindowshape # The windowing shape function only over the samples
11658 
11659  # Zero stuffing of array for better interpolation of peak level of signals
11660  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11661  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11662 
11663  # Save previous trace in memory for max or average trace
11664  # FFTmemoryB = FFTresultB
11665  # if FreqTraceMode.get() == 3:
11666  # PhaseMemoryB = PhaseB
11667  # FFT with numpy
11668  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11669  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
11670  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11671  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
11672 
11673  le = len(ALL) / 2 # Only half is used, other half is mirror
11674  ALL = ALL[:le] # So take only first half of the array
11675  PhaseAB = PhaseAB[:le]
11676  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11677  Totalcorr = Totalcorr * Totalcorr # For POWER!
11678  FFTresultAB = Totalcorr * ALL
11679 #
11680  TRACEsize = int(len(FFTresultB))
11681  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
11682  if SpectrumScreenStatus.get() > 0:
11683  try:
11684  StartFrequency = float(StartFreqEntry.get())
11685  except:
11686  StartFreqEntry.delete(0,"end")
11687  StartFreqEntry.insert(0,100)
11688  StartFrequency = 100
11689  STARTsample = StartFrequency / Fsample
11690  else:
11691  STARTsample = 0.0
11692  if LoopNum.get() == 1:
11693  PhaseMemoryB = PhaseB
11694  FSweepAdB = []
11695  FSweepBdB = []
11696  FSweepAPh = []
11697  FSweepBPh = []
11698  if NetworkScreenStatus.get() > 0:
11699  NSweepSeriesR = []
11700  NSweepSeriesX = []
11701  NSweepSeriesMag = [] # in ohms
11702  NSweepSeriesAng = [] # in degrees
11703  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
11704  if FSweepMode.get() == 1:
11705  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11706  if ptmax > STARTsample:
11707  STARTsample = ptmax
11708  i = 0
11709  while i < 6:
11710  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11711  i = i + 1
11712  if FSweepMode.get() == 2:
11713  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11714  if ptmax > STARTsample:
11715  STARTsample = ptmax
11716  i = 0
11717  while i < 6:
11718  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11719  i = i + 1
11720 
11721  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
11722  if FSweepMode.get() == 1:
11723  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11724  if ptmax > STARTsample:
11725  STARTsample = ptmax
11726  i = 0
11727  while i < 6:
11728  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11729  i = i + 1
11730  if FSweepMode.get() == 2:
11731  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11732  if ptmax > STARTsample:
11733  STARTsample = ptmax
11734  i = 0
11735  while i < 6:
11736  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11737  i = i + 1
11738  if len(FFTresultB) == len(FFTmemoryB):
11739  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
11740  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
11741  try:
11742  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
11743  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
11744  except:
11745  FFTmemoryB = FFTresultB
11746  PhaseMemoryB = PhaseB
11747 #
11748  TRACEsize = int(len(FFTresultA))
11749  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
11750  if SpectrumScreenStatus.get() > 0:
11751  STARTsample = StartFrequency / Fsample
11752  else:
11753  STARTsample = 0.0
11754  if LoopNum.get() == 1:
11755  PhaseMemoryA = PhaseA
11756  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
11757  if FSweepMode.get() == 1:
11758  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11759  if ptmax > STARTsample:
11760  STARTsample = ptmax
11761  i = 0
11762  while i < 6:
11763  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11764  i = i + 1
11765  if FSweepMode.get() == 2:
11766  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11767  if ptmax > STARTsample:
11768  STARTsample = ptmax
11769  i = 0
11770  while i < 6:
11771  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11772  i = i + 1
11773 
11774  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
11775  if FSweepMode.get() == 1:
11776  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11777  if ptmax > STARTsample:
11778  STARTsample = ptmax
11779  i = 0
11780  while i < 6:
11781  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11782  i = i + 1
11783  if FSweepMode.get() == 2:
11784  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11785  if ptmax > STARTsample:
11786  STARTsample = ptmax
11787  i = 0
11788  while i < 6:
11789  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11790  i = i + 1
11791 #
11792  if len(FFTresultA) == len(FFTmemoryA):
11793  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
11794  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
11795  try:
11796  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
11797  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
11798  except:
11799  FFTmemoryA = FFTresultA
11800  PhaseMemoryA = PhaseA
11801 #
11802  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
11803  FSweepAdB.append(numpy.amax(FFTresultA))
11804  FSweepBdB.append(numpy.amax(FFTresultB))
11805  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
11806  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
11807 
11808  TRACEresetFreq = False # Trace reset done
11809 
11810 def MakeFreqTrace(): # Update the grid and trace
11811  global FFTmemoryA, FFTresultA
11812  global FFTmemoryB, FFTresultB
11813  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
11814  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
11815  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
11816  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
11817  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
11818  global PeakfreqA, PeakfreqB, Two_X_Sample
11819  global DBdivindex # Index value
11820  global DBdivlist # dB per division list
11821  global DBlevel # Reference level
11822  global GRHF,GRWF # Screenheight, Screenwidth
11823  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
11824  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
11825  global STARTsample, STOPsample, LoopNum, FSweepMode
11826  global FreqTraceMode
11827  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline
11828  global Vdiv # Number of vertical divisions
11829  global X0LF, Y0TF # Left top X value, Left top Y value
11830 
11831  # Set the TRACEsize variable
11832  TRACEsize = 0
11833  try:
11834  StartFrequency = float(StartFreqEntry.get())
11835  except:
11836  StartFreqEntry.delete(0,"end")
11837  StartFreqEntry.insert(0,100)
11838  StartFrequency = 100
11839  try:
11840  StopFrequency = float(StopFreqEntry.get())
11841  except:
11842  StopFreqEntry.delete(0,"end")
11843  StopFreqEntry.insert(0,50000)
11844  StopFrequency = 50000
11845  if StartFrequency > StopFrequency :
11846  StopFreqEntry.delete(0,"end")
11847  StopFreqEntry.insert(0,50000)
11848  StopFrequency = 50000
11849  if StopFrequency < StartFrequency :
11850  StopFreqEntry.delete(0,"end")
11851  StopFreqEntry.insert(0,50000)
11852  StopFrequency = 50000
11853  try:
11854  Phasecenter = int(PhCenFreqEntry.get())
11855  RelPhaseCenter.set(Phasecenter)
11856  except:
11857  PhCenFreqEntry.delete(0,"end")
11858  PhCenFreqEntry.insert(0,0)
11859  RelPhaseCenter.set(0)
11860  Phasecenter = 0
11861  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
11862  TRACEsize = len(FFTresultA) # Set the trace length
11863  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
11864  TRACEsize = len(FFTresultB)
11865  if TRACEsize == 0: # If no trace, skip rest of this routine
11866  return()
11867  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
11868  PhaseA = PhaseMemoryA
11869  PhaseB = PhaseMemoryB
11870  # Vertical conversion factors (level dBs) and border limits
11871  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
11872  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
11873  Ymin = Y0TF # Minimum position of screen grid (top)
11874  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
11875  Yphconv = float(GRHF) / 360
11876  Yp = float(Y0TF) + Yphconv + 180
11877  # Horizontal conversion factors (frequency Hz) and border limits
11878  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
11879  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
11880  LogFStop = math.log10(StopFrequency)
11881  try:
11882  LogFStart = math.log10(StartFrequency)
11883  except:
11884  LogFStart = 0.0
11885  LogFpixel = (LogFStop - LogFStart) / GRWF
11886  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
11887  STARTsample = int(math.ceil(STARTsample)) # First within screen range
11888 
11889  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
11890  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
11891 
11892  MAXsample = TRACEsize # Just an out of range check
11893  if STARTsample > (MAXsample - 1):
11894  STARTsample = MAXsample - 1
11895 
11896  if STOPsample > MAXsample:
11897  STOPsample = MAXsample
11898 
11899  T1Fline = []
11900  T2Fline = []
11901  T1Pline = []
11902  T2Pline = []
11903  TFMline = []
11904  n = STARTsample
11905  PeakIndexA = PeakIndexB = n
11906  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
11907  while n <= STOPsample:
11908  F = n * Fsample
11909  if HScale.get() == 1:
11910  try:
11911  LogF = math.log10(F) # convet to log Freq
11912  x = X0LF + (LogF - LogFStart)/LogFpixel
11913  except:
11914  x = X0LF
11915  else:
11916  x = X0LF + (F - StartFrequency) / Fpixel
11917  if ShowC1_VdB.get() == 1:
11918  T1Fline.append(int(x + 0.5))
11919  try:
11920  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
11921  ya = Yc - Yconv * dbA # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11922  except:
11923  ya = Ymax
11924  if (ya < Ymin):
11925  ya = Ymin
11926  if (ya > Ymax):
11927  ya = Ymax
11928  if dbA > PeakdbA:
11929  PeakdbA = dbA
11930  PeakyA = int(ya + 0.5)
11931  PeakxA = int(x + 0.5)
11932  PeakfreqA = F
11933  PeakIndexA = n
11934  T1Fline.append(int(ya + 0.5))
11935  if ShowC2_VdB.get() == 1:
11936  T2Fline.append(int(x + 0.5))
11937  try:
11938  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11939  yb = Yc - Yconv * dbB
11940  except:
11941  yb = Ymax
11942  if (yb < Ymin):
11943  yb = Ymin
11944  if (yb > Ymax):
11945  yb = Ymax
11946  if dbB > PeakdbB:
11947  PeakdbB = dbB
11948  PeakyB = int(yb + 0.5)
11949  PeakxB = int(x + 0.5)
11950  PeakfreqB = F
11951  PeakIndexB = n
11952  T2Fline.append(int(yb + 0.5))
11953  if ShowC1_P.get() == 1:
11954  T1Pline.append(int(x + 0.5))
11955  if FSweepMode.get() > 0:
11956  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
11957  else:
11958  RelPhase = PhaseA[n]-PhaseB[n]
11959  RelPhase = RelPhase - Phasecenter
11960  if RelPhase > 180:
11961  RelPhase = RelPhase - 360
11962  elif RelPhase < -180:
11963  RelPhase = RelPhase + 360
11964  if Two_X_Sample.get() == 0:
11965  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
11966  RelPhase = RelPhase + PhErr - 12.0
11967  else:
11968  RelPhase = RelPhase - 9.0
11969  ya = Yp - Yphconv * RelPhase
11970  T1Pline.append(int(ya + 0.5))
11971  if ShowC2_P.get() == 1:
11972  T2Pline.append(int(x + 0.5))
11973  if FSweepMode.get() > 0:
11974  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
11975  else:
11976  RelPhase = PhaseB[n]-PhaseA[n]
11977  RelPhase = RelPhase - Phasecenter
11978  if RelPhase > 180:
11979  RelPhase = RelPhase - 360
11980  elif RelPhase < -180:
11981  RelPhase = RelPhase + 360
11982  if Two_X_Sample.get() == 0:
11983  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
11984  RelPhase = RelPhase - PhErr - 12.0
11985  else:
11986  RelPhase = RelPhase - 9.0
11987  ya = Yp - Yphconv * RelPhase
11988  T2Pline.append(int(ya + 0.5))
11989  if ShowMathSA.get() > 0:
11990  TFMline.append(int(x + 0.5))
11991  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
11992  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11993  if ShowMathSA.get() == 1:
11994  MdB = dbA - dbB
11995  elif ShowMathSA.get() == 2:
11996  MdB = dbB - dbA
11997  yb = Yc - Yconv * MdB
11998  if (yb < Ymin):
11999  yb = Ymin
12000  if (yb > Ymax):
12001  yb = Ymax
12002  if MdB > PeakMdb:
12003  PeakMdb = MdB
12004  PeakyM = int(yb + 0.5)
12005  PeakxM = int(x + 0.5)
12006  PeakfreqM = F
12007  TFMline.append(int(yb + 0.5))
12008  n = n + 1
12009 # make Bode Plot Traces
12010 def MakeBodeTrace(): # Update the grid and trace
12011  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
12012  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
12013  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12014  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12015  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
12016  global DBdivindexBP # Index value
12017  global DBdivlist # dB per division list
12018  global DBlevelBP # Reference level
12019  global GRHBP # Screenheight
12020  global GRWBP # Screenwidth
12021  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
12022  global StartBodeEntry, StopBodeEntry
12023  global STARTsample, STOPsample, LoopNum, FSweepMode
12024  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
12025  global TAFline, TBFline, TBPMline, TAPline, TBPline
12026  global Vdiv # Number of vertical divisions
12027  global X0LBP # Left top X value
12028  global Y0TBP # Left top Y value
12029  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
12030  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
12031  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
12032 
12033  # Set the TRACEsize variable
12034  TRACEsize = 0
12035  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
12036  TRACEsize = len(FStep) # Set the trace length
12037  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
12038  TRACEsize = len(FStep)
12039  if TRACEsize == 0: # If no trace, skip rest of this routine
12040  return()
12041  #
12042  try:
12043  EndFreq = float(StopBodeEntry.get())
12044  except:
12045  StopBodeEntry.delete(0,"end")
12046  StopBodeEntry.insert(0,10000)
12047  EndFreq = 10000
12048  try:
12049  BeginFreq = float(StartBodeEntry.get())
12050  except:
12051  StartBodeEntry.delete(0,"end")
12052  StartBodeEntry.insert(0,100)
12053  BeginFreq = 100
12054  try:
12055  Phasecenter = int(PhCenBodeEntry.get())
12056  RelPhaseCenter.set(Phasecenter)
12057  except:
12058  PhCenBodeEntry.delete(0,"end")
12059  PhCenBodeEntry.insert(0,0)
12060  RelPhaseCenter.set(0)
12061  Phasecenter = 0
12062  try:
12063  Impedcenter = int(ImCenBodeEntry.get())
12064  ImpedanceCenter.set(Impedcenter)
12065  except:
12066  ImCenBodeEntry.delete(0,"end")
12067  ImCenBodeEntry.insert(0,0)
12068  ImpedanceCenter.set(0)
12069  Impedcenter = 0
12070  #
12071  HalfSAMPLErate = SAMPLErate/2
12072  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
12073  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
12074  CurrentFreqX = X0LBP + 14
12075  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
12076  # Vertical conversion factors (level dBs) and border limits
12077  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
12078  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
12079  Ymin = Y0TBP # Minimum position of screen grid (top)
12080  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
12081  Yphconv = float(GRHBP) / 360 # degrees per pixel
12082  Yp = float(Y0TBP) + Yphconv + 180
12083  x1 = X0LBP + 14
12084  # Horizontal conversion factors (frequency Hz) and border limits
12085  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
12086  LogFStop = math.log10(EndFreq)
12087  try:
12088  LogFStart = math.log10(BeginFreq)
12089  except:
12090  LogFStart = 0.0
12091  LogFpixel = (LogFStop - LogFStart) / GRWBP
12092  TAFline = []
12093  TBFline = []
12094  TAPline = []
12095  TBPline = []
12096  TIARline = []
12097  TIAXline = []
12098  TIAMagline = []
12099  TIAAngline = []
12100  TBPMline = []
12101  PeakdbA = -200
12102  PeakdbB = -200
12103  PeakMdb = -200
12104  n = 0
12105  for n in range(len(FSweepAdB)): # while n < len(FStep):
12106  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
12107  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
12108  else:
12109  F = FBins[int(FStep[0])]
12110  if F >= BeginFreq and F <= EndFreq:
12111  if HScaleBP.get() == 1:
12112  try:
12113  LogF = math.log10(F) # convet to log Freq
12114  x = x1 + (LogF - LogFStart)/LogFpixel
12115  except:
12116  x = x1
12117  else:
12118  x = x1 + (F - BeginFreq) / Fpixel
12119  CurrentFreqX = x
12120  if ShowCA_VdB.get() == 1:
12121  TAFline.append(int(x + 0.5))
12122  try:
12123  dbA = (10 * math.log10(float(FSweepAdB[n])) + 17) # Convert power to DBs, except for log(0) error
12124  ya = Yc - Yconv * dbA # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12125  except:
12126  ya = Ymax
12127  if (ya < Ymin):
12128  ya = Ymin
12129  if (ya > Ymax):
12130  ya = Ymax
12131  if dbA > PeakdbA:
12132  PeakdbA = dbA
12133  PeakyA = int(ya + 0.5)
12134  PeakxA = int(x + 0.5)
12135  PeakfreqA = F
12136  TAFline.append(int(ya + 0.5))
12137  if ShowCB_VdB.get() == 1:
12138  TBFline.append(int(x + 0.5))
12139  try:
12140  dbB = (10 * math.log10(float(FSweepBdB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12141  yb = Yc - Yconv * dbB
12142  except:
12143  yb = Ymax
12144  if (yb < Ymin):
12145  yb = Ymin
12146  if (yb > Ymax):
12147  yb = Ymax
12148  if dbB > PeakdbB:
12149  PeakdbB = dbB
12150  PeakyB = int(yb + 0.5)
12151  PeakxB = int(x + 0.5)
12152  PeakfreqB = F
12153  TBFline.append(int(yb + 0.5))
12154  if ShowCA_P.get() == 1:
12155  TAPline.append(int(x + 0.5))
12156  RelPhase = FSweepAPh[n] - FSweepBPh[n]
12157  RelPhase = RelPhase - Phasecenter
12158  if RelPhase > 180:
12159  RelPhase = RelPhase - 360
12160  elif RelPhase < -180:
12161  RelPhase = RelPhase + 360
12162  if Two_X_Sample.get() == 0:
12163  PhErr = 0.0018 * F # calculate phase error due half sample period offset
12164  RelPhase = RelPhase + PhErr - PhaseOffset1x
12165  else:
12166  RelPhase = RelPhase - PhaseOffset2x
12167  ya = Yp - Yphconv * RelPhase
12168  TAPline.append(int(ya + 0.5))
12169  if ShowCB_P.get() == 1:
12170  TBPline.append(int(x + 0.5))
12171  RelPhase = FSweepBPh[n] - FSweepAPh[n]
12172  RelPhase = RelPhase - Phasecenter
12173  if RelPhase > 180:
12174  RelPhase = RelPhase - 360
12175  elif RelPhase < -180:
12176  RelPhase = RelPhase + 360
12177  if Two_X_Sample.get() == 0:
12178  PhErr = 0.0018 * F # calculate phase error due half sample period offset
12179  RelPhase = RelPhase - PhErr - PhaseOffset1x
12180  else:
12181  RelPhase = RelPhase - PhaseOffset2x
12182  ya = Yp - Yphconv * RelPhase
12183  TBPline.append(int(ya + 0.5))
12184  if ShowMathBP.get() > 0:
12185  TBPMline.append(int(x + 0.5))
12186  dbA = (10 * math.log10(float(FSweepAdB[n])) + 17) # Convert power to DBs, except for log(0) error
12187  dbB = (10 * math.log10(float(FSweepBdB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12188  if ShowMathBP.get() == 1:
12189  MdB = dbA - dbB
12190  elif ShowMathBP.get() == 2:
12191  MdB = dbB - dbA
12192  yb = Yc - Yconv * MdB
12193  if (yb < Ymin):
12194  yb = Ymin
12195  if (yb > Ymax):
12196  yb = Ymax
12197  if MdB > PeakMdb:
12198  PeakMdb = MdB
12199  PeakyM = int(yb + 0.5)
12200  PeakxM = int(x + 0.5)
12201  PeakfreqM = F
12202  TBPMline.append(int(yb + 0.5))
12203 # draw impedance trace if necessary
12204  if NetworkScreenStatus.get() > 0:
12205  ycenter = Y0TBP + (GRHBP/2)
12206  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
12207  n = 0
12208  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
12209  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
12210  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
12211  else:
12212  F = FBins[int(FStep[0])]
12213  if F >= BeginFreq and F <= EndFreq:
12214  if HScaleBP.get() == 1:
12215  try:
12216  LogF = math.log10(F) # convet to log Freq
12217  x = x1 + (LogF - LogFStart)/LogFpixel
12218  except:
12219  x = x1
12220  else:
12221  x = x1 + (F - BeginFreq) / Fpixel
12222  if Show_Rseries.get() == 1:
12223  TIARline.append(int(x + 0.5))
12224  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
12225  if (y1 < Ymin):
12226  y1 = Ymin
12227  if (y1 > Ymax):
12228  y1 = Ymax
12229  TIARline.append(y1)
12230  if Show_Xseries.get() == 1:
12231  TIAXline.append(int(x + 0.5))
12232  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
12233  if (y1 < Ymin):
12234  y1 = Ymin
12235  if (y1 > Ymax):
12236  y1 = Ymax
12237  TIAXline.append(y1)
12238  if Show_Magnitude.get() == 1:
12239  TIAMagline.append(int(x + 0.5))
12240  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
12241  if (y1 < Ymin):
12242  y1 = Ymin
12243  if (y1 > Ymax):
12244  y1 = Ymax
12245  TIAMagline.append(y1)
12246  if Show_Angle.get() == 1:
12247  TIAAngline.append(int(x + 0.5))
12248  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
12249  if (y1 < Ymin):
12250  y1 = Ymin
12251  if (y1 > Ymax):
12252  y1 = Ymax
12253  TIAAngline.append(y1)
12254 #
12255 def MakeBodeScreen(): # Update the screen with traces and text
12256  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
12257  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12258  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12259  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12260  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12261  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12262  global COLORgrid # The colors
12263  global COLORsignalband, COLORtext
12264  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
12265  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
12266  global DBdivindexBP # Index value
12267  global DBdivlist # dB per division list
12268  global DBlevelBP # Reference level
12269  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
12270  global X0LBP # Left top X value
12271  global Y0TBP # Left top Y value
12272  global GRWBP # Screenwidth
12273  global GRHBP # Screenheight
12274  global FontSize
12275  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
12276  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
12277  global SMPfft # number of FFT samples
12278  global StartBodeEntry, StopBodeEntry
12279  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
12280  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
12281  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
12282  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
12283  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
12284  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
12285  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
12286  global TAPRline, TBPRline
12287  global TRACEaverage # Number of traces for averageing
12288  global FreqTraceMode # 1 normal 2 max 3 average
12289  global Vdiv, ResScale # Number of vertical divisions
12290  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
12291  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
12292 
12293  # Delete all items on the screen
12294  MarkerFreqNum = 0
12295  Bodeca.delete(ALL) # remove all items
12296 
12297  try:
12298  EndFreq = float(StopBodeEntry.get())
12299  except:
12300  StopBodeEntry.delete(0,"end")
12301  StopBodeEntry.insert(0,10000)
12302  EndFreq = 10000
12303  try:
12304  BeginFreq = float(StartBodeEntry.get())
12305  except:
12306  StartBodeEntry.delete(0,"end")
12307  StartBodeEntry.insert(0,100)
12308  BeginFreq = 100
12309  try:
12310  Phasecenter = int(PhCenBodeEntry.get())
12311  RelPhaseCenter.set(Phasecenter)
12312  except:
12313  PhCenBodeEntry.delete(0,"end")
12314  PhCenBodeEntry.insert(0,0)
12315  RelPhaseCenter.set(0)
12316  Phasecenter = 0
12317  try:
12318  Impedcenter = int(ImCenBodeEntry.get())
12319  ImpedanceCenter.set(Impedcenter)
12320  except:
12321  ImCenBodeEntry.delete(0,"end")
12322  ImCenBodeEntry.insert(0,0)
12323  ImpedanceCenter.set(0)
12324  Impedcenter = 0
12325  #
12326  # Draw horizontal grid lines
12327  i = 0
12328  x1 = X0LBP + 14
12329  x2 = x1 + GRWBP
12330  while (i <= Vdiv.get()):
12331  y = Y0TBP + i * GRHBP/Vdiv.get()
12332  Dline = [x1,y,x2,y]
12333  if i == 0 or i == Vdiv.get():
12334  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12335  else:
12336  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12337  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
12338  Vaxis_label = str(Vaxis_value)
12339  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
12340  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
12341  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
12342  Vaxis_label = str(Vaxis_value)
12343  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
12344  if NetworkScreenStatus.get() > 0:
12345  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
12346  RperDiv = float(ResScale.get())
12347  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
12348  if Vaxis_value > 500 or Vaxis_value < -500:
12349  Vaxis_value = Vaxis_value/1000.0
12350  if Vaxis_value > 5 or Vaxis_value < -5:
12351  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
12352  else:
12353  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
12354  else:
12355  Vaxis_label = ' {0:.0f} '.format(Vaxis_value)
12356  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
12357  i = i + 1
12358  # Draw vertical grid lines
12359  i = 0
12360  y1 = Y0TBP
12361  y2 = Y0TBP + GRHBP
12362  if HScaleBP.get() == 1:
12363  F = 1.0
12364  LogFStop = math.log10(EndFreq)
12365  try:
12366  LogFStart = math.log10(BeginFreq)
12367  except:
12368  LogFStart = 0.0
12369  LogFpixel = (LogFStop - LogFStart) / GRWBP
12370  # draw left and right edges
12371  while F <= EndFreq:
12372  if F >= BeginFreq:
12373  try:
12374  LogF = math.log10(F) # convet to log Freq
12375  x = x1 + (LogF - LogFStart)/LogFpixel
12376  except:
12377  x = x1
12378  Dline = [x,y1,x,y2]
12379  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
12380  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12381  axis_label = str(F)
12382  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
12383  else:
12384  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12385 
12386  if F < 10:
12387  F = F + 1
12388  elif F < 100:
12389  F = F + 10
12390  elif F < 1000:
12391  F = F + 100
12392  elif F < 1000:
12393  F = F + 100
12394  elif F < 10000:
12395  F = F + 1000
12396  elif F < 100000:
12397  F = F + 10000
12398  elif F < 200000:
12399  F = F + 10000
12400  else:
12401  Freqdiv = (EndFreq - BeginFreq) / 10
12402  while (i < 11):
12403  x = x1 + i * GRWBP/10
12404  Dline = [x,y1,x,y2]
12405  if i == 0 or i == 10:
12406  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12407  else:
12408  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12409  axis_value = BeginFreq + (i * Freqdiv)
12410  axis_label = str(axis_value)
12411  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
12412  i = i + 1
12413  # Draw X - Y cursors if needed
12414  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
12415  LogFStop = math.log10(EndFreq)
12416  try:
12417  LogFStart = math.log10(BeginFreq)
12418  except:
12419  LogFStart = 0.0
12420  LogFpixel = (LogFStop - LogFStart) / GRWBP
12421  if ShowBPCur.get() > 0:
12422  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
12423  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
12424  # Horizontal conversion factors (frequency Hz) and border limits
12425  if HScaleBP.get() == 1:
12426  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
12427  else:
12428  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
12429  XFString = ' {0:.2f} '.format(xfreq)
12430  V_label = XFString + " Hz"
12431  Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
12432 #
12433  if ShowBdBCur.get() > 0:
12434  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
12435  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
12436  if ShowBdBCur.get() == 1:
12437  # Vertical conversion factors (level dBs) and border limits
12438  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
12439  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
12440  yvdB = ((Yc-BdBCursor)/Yconv)
12441  VdBString = ' {0:.1f} '.format(yvdB)
12442  V_label = VdBString + " dBV"
12443  else:
12444  # Vertical conversion factors (level degrees) and border limits
12445  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
12446  Yc = float(Y0TBP) # Yc is the 180 degree position
12447  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
12448  VdBString = ' {0:.1f} '.format(yvdB)
12449  V_label = VdBString + " Deg"
12450  Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
12451  #
12452  SmoothBool = SmoothCurvesBP.get()
12453  # Draw traces
12454  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
12455  # Write the trace CHA
12456  if OverRangeFlagA == 1:
12457  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12458  else:
12459  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12460  if ShowMarkerBP.get() == 1:
12461  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
12462  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
12463  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
12464  # Write the trace CHB
12465  if OverRangeFlagB == 1:
12466  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12467  else:
12468  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12469  if ShowMarkerBP.get() == 1:
12470  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
12471  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
12472  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
12473  # Write the phase trace A-B
12474  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12475  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
12476  # Write the phase trace A-B
12477  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12478  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
12479  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12480  if ShowMarkerBP.get() == 1:
12481  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
12482  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
12483  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
12484  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12485  if ShowMarkerBP.get() == 1:
12486  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
12487  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
12488  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
12489  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12490  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
12491  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12492  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
12493  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12494  if ShowMarkerBP.get() == 1:
12495  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
12496  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
12497  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
12498  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12499  if ShowMarkerBP.get() == 1:
12500  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
12501  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
12502  if Show_Rseries.get() == 1 and len(TIARline) > 4:
12503  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12504  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
12505  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12506  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
12507  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12508  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
12509  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12510  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
12511  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12512  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
12513  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12514  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
12515  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12516  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
12517  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12518 
12519  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
12520  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
12521  if HScaleBP.get() == 1:
12522  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
12523  else:
12524  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
12525  XFString = ' {0:.0f} '.format(xfreq)
12526  V_label = XFString + " Hz"
12527  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
12528  # General information on top of the grid
12529 
12530  txt = " Sample rate: " + str(SAMPLErate)
12531  txt = txt + " FFT samples: " + str(SMPfft)
12532 
12533  txt = txt + " " + FFTwindowname
12534 
12535  x = X0LBP
12536  y = 12
12537  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12538 
12539  # Start and stop frequency and dB/div and trace mode
12540  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
12541  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
12542  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
12543  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
12544 
12545  x = X0LBP
12546  y = Y0TBP+GRHBP+23
12547  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12548 
12549  if FreqTraceMode.get() == 1:
12550  txt ="Normal mode "
12551 
12552  if FreqTraceMode.get() == 2:
12553  txt = "Peak hold mode "
12554 
12555  if FreqTraceMode.get() == 3:
12556  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
12557 
12558  if ZEROstuffing.get() > 0:
12559  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
12560  # Runstatus and level information
12561  if (RUNstatus.get() == 0):
12562  txt = txt + " Stopped "
12563  else:
12564  if BodeDisp.get() == 1:
12565  txt = txt + " Running "
12566  else:
12567  txt = txt + " Display off "
12568  if FSweepMode.get() > 0:
12569  txt = txt + " Freq Step = " + str(LoopNum.get())
12570  x = X0LBP
12571  y = Y0TBP+GRHBP+34
12572  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12573 
12574 # Impedance analyzer routines -----
12575 def UpdateIAAll(): # Update Data, trace and screen
12576  global FFTBuffA, FFTBuffB
12577  global SMPfft
12578 
12579  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
12580  return
12581 
12582  MakeIATrace() # Update the traces
12583  UpdateIAScreen() # Update the screen
12584 
12585 def UpdateIATrace(): # Update trace and screen
12586  MakeIATrace() # Update traces
12587  UpdateIAScreen() # Update the screen
12588 
12589 def UpdateIAScreen(): # Update screen with trace and text
12590  MakeIAScreen() # Update the screen
12591  root.update() # Activate updated screens
12592 #
12594 
12595 # Input Variables
12596  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
12597  #(VZ/VA)from vector voltmeter
12598  # global VVangle # angle in degrees between VZ and VA
12599  global RsystemEntry # resistance of series resistor or power divider
12600 # Computed outputs
12601  # global VVangleCosine # cosine of vector voltmeter angle
12602  global ImpedanceMagnitude # in ohms
12603  global ImpedanceAngle # in degrees
12604  global ImpedanceRseries, ImpedanceXseries # in ohms
12605  global IA_Ext_Conf
12606 
12607  DEG2RAD = (math.pi / 180.0)
12608  SMALL = 1E-20
12609  try:
12610  ResValue = float(RsystemEntry.get())
12611  except:
12612  ResValue = 1000.0
12613 
12614  VA = math.pow(10,(PeakdbA/20))
12615  VB = math.pow(10,(PeakdbB/20))
12616  VVangleCosine = math.cos(math.radians(PeakRelPhase))
12617  if IA_Ext_Conf.get() == 1:
12618  VAB = math.pow(10,(PeakdbAB/20))
12619  VZ = VAB # VZ=VA-VB
12620  # VI = VB
12621  else:
12622  VZ = VB # VZ=VB
12623  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
12624  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
12625  Za = ResValue * VA / VI
12626  ImpedanceRseries = Za * costheta - ResValue
12627  ImpedanceMagnitude = ResValue * VZ / VI
12628  # don't try to take square root of a negative number)
12629  ImpedanceXseries = math.sqrt(abs(ImpedanceMagnitude**2 - ImpedanceRseries**2))
12630 
12631  if(PeakRelPhase < 0.0):
12632  ImpedanceXseries = -ImpedanceXseries
12633  if IA_Ext_Conf.get() == 1:
12634  ImpedanceRseries = -ImpedanceRseries
12635  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
12636 #
12637 def MakeIATrace(): # Update the grid and trace
12638  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
12639  global FFTmemoryB, FFTresultB
12640  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
12641  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
12642  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
12643  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
12644  global DBdivindex # Index value
12645  global DBdivlist # dB per division list
12646  global DBlevel # Reference level
12647  global GRHIA # Screenheight
12648  global GRWIA # Screenwidth
12649  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
12650  global STARTsample, STOPsample, LoopNum, FSweepMode
12651  global TRACEmode, Two_X_Sample, IA_Ext_Conf
12652  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
12653  global Vdiv # Number of vertical divisions
12654  global X0LIA # Left top X value
12655  global Y0TIA # Left top Y value
12656  global ImpedanceMagnitude # in ohms
12657  global ImpedanceAngle # in degrees
12658  global ImpedanceRseries, ImpedanceXseries # in ohms
12659 
12660  # Set the TRACEsize variable
12661  TRACEsize = len(FFTresultA) # Set the trace length
12662  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
12663  # Horizontal conversion factors (frequency Hz) and border limits
12664  STARTsample = 0 # First sample in FFTresult[] that is used
12665  STARTsample = int(math.ceil(STARTsample)) # First within screen range
12666  if Two_X_Sample.get() == 0:
12667  STOPsample = 45000 / Fsample # Last sample in FFTresult[] that is used
12668  else:
12669  STOPsample = 90000 / Fsample
12670  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
12671 #
12672  try:
12673  GainCorrection = float(eval(GainCorEntry.get()))
12674  except:
12675  GainCorEntry.delete(0,END)
12676  GainCorEntry.insert(0, GainCorrection)
12677 
12678  try:
12679  PhaseCorrection = float(eval(PhaseCorEntry.get()))
12680  except:
12681  PhaseCorEntry.delete(0,END)
12682  PhaseCorEntry.insert(0, PhaseCorrection)
12683 
12684  MAXsample = TRACEsize # Just an out of range check
12685  if STARTsample > (MAXsample - 1):
12686  STARTsample = MAXsample - 1
12687 
12688  if STOPsample > MAXsample:
12689  STOPsample = MAXsample
12690 
12691  n = STARTsample
12692  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
12693  PeakphaseA = PhaseA[n]
12694  PeakphaseB = PhaseB[n]
12695  #PeakphaseAB = PhaseAB[n]
12696  PeakSample = n
12697 
12698  PeakdbA = (10 * math.log10(float(FFTresultA[n])) + 17)
12699  PeakdbB = (10 * math.log10(float(FFTresultB[n])) + 17)
12700  PeakMdb = PeakdbA - PeakdbB
12701  if IA_Ext_Conf.get() == 1:
12702  PeakdbAB = (10 * math.log10(float(FFTresultAB[n])) + 17)
12703  while n <= STOPsample:
12704  F = n * Fsample
12705  try:
12706  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
12707  except:
12708  dbA = -200
12709  if dbA > PeakdbA:
12710  PeakdbA = dbA
12711  PeakfreqA = F
12712  PeakphaseA = PhaseA[n]
12713  PeakSample = n
12714 
12715  try:
12716  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12717  except:
12718  dbB = -200
12719  if dbB > PeakdbB:
12720  PeakdbB = dbB
12721  PeakfreqB = F
12722  PeakphaseB = PhaseB[n]
12723 
12724  if IA_Ext_Conf.get() == 1:
12725  try:
12726  dbAB = (10 * math.log10(float(FFTresultAB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12727  except:
12728  dbAB = -200
12729  if dbAB > PeakdbAB:
12730  PeakdbAB = dbAB
12731  PeakphaseAB = PhaseAB[n]
12732  RelPhase = PhaseA[n]-PhaseB[n]
12733  if RelPhase > 180:
12734  RelPhase = RelPhase - 360
12735  elif RelPhase < -180:
12736  RelPhase = RelPhase + 360
12737  if Two_X_Sample.get() == 0:
12738  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
12739  RelPhase = RelPhase + PhErr - 12.0
12740  else:
12741  RelPhase = RelPhase - 9.0
12742  n = n + 1
12743  if IA_Ext_Conf.get() == 1:
12744  PeakRelPhase = PeakphaseAB-PeakphaseA
12745  else:
12746  PeakRelPhase = PeakphaseB-PeakphaseA
12747 #
12748  if PeakRelPhase > 180:
12749  PeakRelPhase = PeakRelPhase - 360
12750  elif PeakRelPhase < -180:
12751  PeakRelPhase = PeakRelPhase + 360
12752  if Two_X_Sample.get() == 0:
12753  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
12754  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
12755  else:
12756  PeakRelPhase = PeakRelPhase + PhaseCorrection
12757  PeakdbB = PeakdbB + GainCorrection
12758  DoImpedance()
12759 
12761 def MakeIAScreen(): # Update the screen with traces and text
12762  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
12763  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12764  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
12765  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12766  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12767  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12768  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry
12769  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
12770  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
12771  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
12772  global ResScale, DisplaySeries # Ohms per div
12773  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
12774  global X0LIA # Left top X value
12775  global Y0TIA # Left top Y value
12776  global GRWIA # Screenwidth
12777  global GRHIA # Screenheight
12778  global FontSize
12779  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
12780  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
12781  global SMPfft # number of FFT samples
12782  global TRACEaverage # Number of traces for averageing
12783  global FreqTraceMode # 1 normal 2 max 3 average
12784  global Vdiv # Number of vertical divisions
12785  global ImpedanceMagnitude # in ohms
12786  global ImpedanceAngle # in degrees
12787  global ImpedanceRseries, ImpedanceXseries # in ohms
12788  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
12789 
12790  if LoopNum.get() > 1:
12791  if NetworkScreenStatus.get() > 0:
12792  NSweepSeriesR.append(ImpedanceRseries)
12793  NSweepSeriesX.append(ImpedanceXseries)
12794  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
12795  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
12796  # Delete all items on the screen
12797  IAca.delete(ALL) # remove all items
12798  SmoothBool = SmoothCurvesBP.get()
12799  # Draw circular grid lines
12800  i = 1
12801  xcenter = GRWIA/2
12802  ycenter = GRHIA/2
12803  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
12804  OhmsperPixel = float(ResScale.get())/Radius
12805  TRadius = Radius * Vdiv.get() # 5
12806  x1 = X0LIA
12807  x2 = X0LIA + GRWIA
12808  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
12809  while (i <= Vdiv.get()):
12810  x0 = xcenter - ( i * Radius )
12811  x1 = xcenter + ( i * Radius )
12812  y0 = ycenter - ( i * Radius )
12813  y1 = ycenter + ( i * Radius )
12814  ResTxt = float(ResScale.get()) * i
12815  IAca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
12816  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
12817  IAca.create_text(xright, y0, text=str(ResTxt), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
12818  #
12819  i = i + 1
12820  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
12821  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
12822  RAngle = math.radians(45)
12823  y = TRadius*math.sin(RAngle)
12824  x = TRadius*math.cos(RAngle)
12825  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
12826  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
12827  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
12828  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
12829  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
12830  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
12831 # Draw traces
12832  # Add saved line if there
12833  if IASweepSaved.get() > 0:
12834  if len(TIAMRline) > 4:
12835  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12836 #
12837  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
12838  if x1 > 1500:
12839  x1 = xright
12840  elif x1 < -500:
12841  x1 = xcenter - xright
12842  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, width=TRACEwidth.get())
12843  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
12844  if y1 > 1500:
12845  y1 = xright
12846  elif y1 < -500:
12847  y1 = ycenter - xright
12848  xmag = x1
12849  ymag = y1
12850  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, width=TRACEwidth.get())
12851  MagRadius = ImpedanceMagnitude / OhmsperPixel
12852  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
12853  if y1 > 1500:
12854  y1 = xright
12855  elif y1 < -500:
12856  y1 = ycenter - xright
12857  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
12858  if x1 > 1500:
12859  x1 = xright
12860  elif x1 < -500:
12861  x1 = xcenter - xright
12862  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, width=TRACEwidth.get())
12863 #
12864  TIAMline = []
12865  if len(NSweepSeriesMag) > 2:
12866  index = 0
12867  while index < len(NSweepSeriesMag):
12868  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
12869  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
12870  if y1 > 1500:
12871  y1 = xright
12872  elif y1 < -500:
12873  y1 = ycenter - xright
12874  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
12875  if x1 > 1500:
12876  x1 = xright
12877  elif x1 < -500:
12878  x1 = xcenter - xright
12879  TIAMline.append(x1)
12880  TIAMline.append(y1)
12881  index = index + 1
12882  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12883 # display warning if input out of range
12884  if OverRangeFlagA == 1:
12885  x = X0LIA+GRWIA+10
12886  y = Y0TIA+GRHIA-40
12887  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
12888  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
12889  if OverRangeFlagB == 1:
12890  x = X0LIA+GRWIA+10
12891  y = Y0TIA+GRHIA-10
12892  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
12893  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
12894  # General information on top of the grid
12895 
12896  txt = " Sample rate: " + str(SAMPLErate)
12897  txt = txt + " FFT samples: " + str(SMPfft)
12898 
12899  txt = txt + " " + FFTwindowname
12900 
12901  x = X0LIA
12902  y = 12
12903  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12904  #
12905  x = X0LIA + GRWIA + 4
12906  y = 24
12907  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
12908  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12909  y = y + 24
12910  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
12911  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12912  y = y + 24
12913  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
12914  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12915  y = y + 24
12916  txt = "Impedance Magnitude"
12917  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12918  y = y + 24
12919  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
12920  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12921  y = y + 24
12922  txt = "Impedance Angle"
12923  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12924  y = y + 24
12925  txt = ' {0:.1f} '.format(ImpedanceAngle)
12926  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12927  y = y + 24
12928  txt = "Impedance R series"
12929  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12930  y = y + 24
12931  txt = ' {0:.1f} '.format(ImpedanceRseries)
12932  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12933  y = y + 24
12934  txt = "Impedance X series"
12935  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12936  y = y + 24
12937  txt = ' {0:.1f} '.format(ImpedanceXseries)
12938  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12939 #
12940  if ImpedanceXseries < 0: # calculate series capacitance
12941  y = y + 24
12942  try:
12943  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
12944  except:
12945  Cseries = 0
12946  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
12947  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
12948  Cparallel = Cparallel * 1E6 # convert to micro Farads
12949  Rparallel = ImpedanceRseries * (1+Qseries**2)
12950  Cseries = Cseries * 1E6 # convert to micro Farads
12951  if DisplaySeries.get() == 0:
12952  txt = "Series Capacitance"
12953  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12954  y = y + 20
12955  if Cseries < 1:
12956  Cseries = Cseries * 1E3
12957  if Cseries < 1:
12958  Cseries = Cseries * 1E3
12959  txt = ' {0:.1f} '.format(Cseries) + "pF"
12960  else:
12961  txt = ' {0:.3f} '.format(Cseries) + "nF"
12962  else:
12963  txt = ' {0:.3f} '.format(Cseries) + "uF"
12964  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12965  else:
12966  txt = "Parallel"
12967  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12968  y = y + 20
12969  if Cparallel < 1:
12970  Cparallel = Cparallel * 1E3
12971  if Cparallel < 1:
12972  Cparallel = Cparallel * 1E3
12973  txt = "Capacitance " + ' {0:.1f} '.format(Cparallel) + "pF"
12974  else:
12975  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "nF"
12976  else:
12977  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
12978  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12979  y = y + 20
12980  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
12981  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12982  y = y + 20
12983  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
12984  txt = 'D = {0:.2f} '.format(dissp) + " %"
12985  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12986 
12987  elif ImpedanceXseries > 0: # calculate series inductance
12988  y = y + 24
12989  try:
12990  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
12991  except:
12992  Lseries = 0
12993  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
12994  if Qseries == 0.0: # Check if divide by zero
12995  Qseries = 0.00001
12996  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
12997  Lparallel = Lparallel * 1E3 # convert to millihenry
12998  Rparallel = ImpedanceRseries * (1+Qseries**2)
12999  Lseries = Lseries * 1E3 # in millihenry
13000  if DisplaySeries.get() == 0:
13001  txt = "Series Inductance"
13002  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13003  y = y + 22
13004  if Lseries < 1:
13005  Lseries = Lseries * 1E3
13006  txt = ' {0:.2f} '.format(Lseries) + "uH"
13007  else:
13008  txt = ' {0:.2f} '.format(Lseries) + "mH"
13009  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13010  else:
13011  txt = "Parallel"
13012  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13013  y = y + 20
13014  if Lparallel < 1:
13015  Lparallel = Lparallel * 1E3
13016  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "uH"
13017  else:
13018  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
13019  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13020  y = y + 20
13021  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
13022  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13023  y = y + 20
13024  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
13025  txt = 'Q = {0:.2f} '.format(qf)
13026  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
13027  # Start and stop frequency and trace mode
13028  if Two_X_Sample.get() == 0:
13029  txt = "0.0 to 45000 Hz"
13030  else:
13031  txt = "0.0 to 90000 Hz"
13032  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
13033 
13034  x = X0LIA
13035  y = Y0TIA+GRHIA-13
13036  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13037  txt = " "
13038  if FreqTraceMode.get() == 1:
13039  txt ="Normal mode "
13040 
13041  if FreqTraceMode.get() == 2:
13042  txt = "Peak hold mode "
13043 
13044  if FreqTraceMode.get() == 3:
13045  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
13046 
13047  if ZEROstuffing.get() > 0:
13048  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
13049  # Runstatus and level information
13050  if (RUNstatus.get() == 0):
13051  txt = txt + " Stopped "
13052  else:
13053  txt = txt + " Running "
13054  y = Y0TIA+GRHIA
13055  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13056 #
13057 def IACaresize(event):
13058  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
13059 
13060  CANVASwidthIA = event.width - 4
13061  CANVASheightIA = event.height - 4
13062  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
13063  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
13064  UpdateIAAll()
13065 #
13066 # ================ Make IA Window ==========================
13068  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
13069  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode
13070  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
13071  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev
13072  global NetworkScreenStatus, IASweepSaved
13073 
13074  if IAScreenStatus.get() == 0:
13075  IAScreenStatus.set(1)
13076  IADisp.set(1)
13077  IACheckBox()
13078  CutDC.set(1) # set to remove DC
13079  CANVASwidthIA = 170 + GRWIA + 2 * X0LIA # The canvas width
13080  CANVASheightIA = GRHIA + Y0TIA + 10 # The canvas height
13081  AWGAMode.set(0) # Set AWG A to SVMI
13082  AWGAShape.set(1) # Set Shape to Sine
13083  AWGBMode.set(2) # Set AWG B to Hi-Z
13084  AWGSync.set(1) # Set AWGs to run sync
13085  iawindow = Toplevel()
13086  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
13087  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
13088  frame2iar = Frame(iawindow, borderwidth=5, relief=RIDGE)
13089  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13090 
13091  frame2ia = Frame(iawindow, borderwidth=5, relief=RIDGE)
13092  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
13093 
13094  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
13095  IAca.bind("<Configure>", IACaresize)
13096  IAca.bind("<Return>", DoNothing)
13097  IAca.bind("<space>", onCanvasSpaceBar)
13098  IAca.pack(side=TOP, expand=YES, fill=BOTH)
13099 
13100  # menu buttons
13101  # right side drop down menu buttons
13102  dropmenu = Frame( frame2iar )
13103  dropmenu.pack(side=TOP)
13104  # File menu
13105  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
13106  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
13107  IAFilemenu["menu"] = IAFilemenu.menu
13108  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
13109  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
13110  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
13111  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
13112  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
13113  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
13114  IAFilemenu.menu.add_command(label="Help", command=BHelp)
13115  IAFilemenu.pack(side=LEFT, anchor=W)
13116  #
13117  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
13118  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
13119  IAOptionmenu["menu"] = IAOptionmenu.menu
13120  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
13121  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
13122  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
13123  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
13124  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
13125  if DeBugMode == 1:
13126  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
13127  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
13128  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
13129  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
13130  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
13131  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
13132  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
13133  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
13134  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
13135  IAOptionmenu.pack(side=LEFT, anchor=W)
13136  #
13137  rsemenu = Frame( frame2iar )
13138  rsemenu.pack(side=TOP)
13139  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
13140  rseb2.pack(side=RIGHT)
13141  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
13142  rseb3.pack(side=RIGHT)
13143  #
13144  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
13145  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
13146  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
13147  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
13148  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
13149  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
13150  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
13151  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
13152  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
13153  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
13154  IAFFTwindmenu.pack(side=TOP)
13155  #
13156  smpmenu = Frame( frame2iar )
13157  smpmenu.pack(side=TOP)
13158  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
13159  smpb1.pack(side=LEFT)
13160  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
13161  smpb2.pack(side=LEFT)
13162  # Temp set source resistance to 1000
13163  rsystem = Frame( frame2iar )
13164  rsystem.pack(side=TOP)
13165  rsystemlab = Label(rsystem, text="Ext Res")
13166  rsystemlab.pack(side=LEFT, anchor=W)
13167  RsystemEntry = Entry(rsystem, width=7)
13168  RsystemEntry.bind('<MouseWheel>', onTextScroll)
13169  RsystemEntry.bind('<Key>', onTextKey)
13170  RsystemEntry.pack(side=LEFT, anchor=W)
13171  RsystemEntry.delete(0,"end")
13172  RsystemEntry.insert(4,1000)
13173  # Res Sacle Spinbox
13174  ressb = Frame( frame2iar )
13175  ressb.pack(side=TOP)
13176  reslab = Label(ressb, text="Ohms/div ")
13177  reslab.pack(side=LEFT)
13178  ResScale = Spinbox(ressb, width=7, values=ResScalediv)
13179  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
13180  ResScale.pack(side=LEFT)
13181  ResScale.delete(0,"end")
13182  ResScale.insert(0,500)
13183  #
13184  GainCor = Frame( frame2iar )
13185  GainCor.pack(side=TOP)
13186  GainCorlab = Label(GainCor, text="Gain Cor dB")
13187  GainCorlab.pack(side=LEFT, anchor=W)
13188  GainCorEntry = Entry(GainCor, width=7)
13189  GainCorEntry.bind('<MouseWheel>', onTextScroll)
13190  GainCorEntry.bind('<Key>', onTextKey)
13191  GainCorEntry.pack(side=LEFT, anchor=W)
13192  GainCorEntry.delete(0,"end")
13193  GainCorEntry.insert(4,0.0)
13194  #
13195  PhaseCor = Frame( frame2iar )
13196  PhaseCor.pack(side=TOP)
13197  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
13198  PhaseCorlab.pack(side=LEFT, anchor=W)
13199  PhaseCorEntry = Entry(PhaseCor, width=7)
13200  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
13201  PhaseCorEntry.bind('<Key>', onTextKey)
13202  PhaseCorEntry.pack(side=LEFT, anchor=W)
13203  PhaseCorEntry.delete(0,"end")
13204  PhaseCorEntry.insert(4,0.0)
13205  #
13206  srclab = Label(frame2iar, text="Source")
13207  srclab.pack(side=TOP)
13208  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
13209  extsrc1.pack(side=TOP)
13210  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
13211  extsrc2.pack(side=TOP)
13212 
13213  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
13214  dismiss1button.pack(side=TOP)
13215  # add ADI logo
13216  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
13217  ADI1.pack(side=TOP)
13218 #
13220  global iawindow, IAScreenStatus, IAca, IADisp
13221 
13222  IAScreenStatus.set(0)
13223  IADisp.set(0)
13224  IACheckBox()
13225  iawindow.destroy()
13226 #
13228  global TIAMline, TIAMRline, IASweepSaved
13229 
13230  if IASweepSaved.get() > 0:
13231  TIAMRline = TIAMline
13232 #
13234  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
13235  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
13236  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
13237  global NetworkScreenStatus, NqPSweepSaved
13238 
13239  if NqPScreenStatus.get() == 0:
13240  NqPScreenStatus.set(1)
13241  NqPDisp.set(1)
13242  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
13243  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
13244  nqpwindow = Toplevel()
13245  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
13246  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
13247  #frame2iar = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13248  #frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13249 
13250  frame2nqp = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13251  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
13252 
13253  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
13254  NqPca.bind("<Configure>", NqPCaresize)
13255  NqPca.bind("<Return>", DoNothing)
13256  NqPca.bind("<space>", onCanvasSpaceBar)
13257  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
13258 #
13260  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
13261 
13262  NqPScreenStatus.set(0)
13263  NqPDisp.set(0)
13264  nqpwindow.destroy()
13265 #
13266 def NqPCaresize(event):
13267  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
13268 
13269  CANVASwidthNqP = event.width - 4
13270  CANVASheightNqP = event.height - 4
13271  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
13272  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
13273  UpdateNqPAll()
13274 
13277  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
13278  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
13279  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
13280  global Vdiv, FBins, FStep
13281  global FontSize
13282 
13283  # Delete all items on the canvas
13284  NqPca.delete(ALL) # remove all items
13285  SmoothBool = SmoothCurvesBP.get()
13286  # Draw circular grid lines
13287  i = 1
13288  xcenter = GRWNqP/2
13289  ycenter = GRHNqP/2
13290  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
13291  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
13292  TRadius = Radius * Vdiv.get() # 5
13293  x1 = X0LNqP
13294  x2 = X0LNqP + GRWNqP
13295  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
13296  while (i <= Vdiv.get()):
13297  x0 = xcenter - ( i * Radius )
13298  x1 = xcenter + ( i * Radius )
13299  y0 = ycenter - ( i * Radius )
13300  y1 = ycenter + ( i * Radius )
13301  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
13302  NqPca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
13303  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
13304  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13305  #
13306  i = i + 1
13307  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
13308  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
13309  RAngle = math.radians(45)
13310  y = TRadius*math.sin(RAngle)
13311  x = TRadius*math.cos(RAngle)
13312  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13313  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13314  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
13315  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13316  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
13317  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
13318  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
13319 # Draw traces
13320  NqPline = []
13321  if len(FSweepAdB) > 4:
13322  for index in range(len(FSweepAdB)): # while n < len(FStep):
13323  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
13324  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
13325  else:
13326  F = FBins[int(FStep[0])]
13327  # Mag value
13328  dbA = (10 * math.log10(float(FSweepAdB[index])) + 17) # Convert power to DBs, except for log(0) error
13329  dbB = (10 * math.log10(float(FSweepBdB[index])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13330  if ShowMathBP.get() == 1:
13331  MdB = dbA - dbB
13332  elif ShowMathBP.get() == 2:
13333  MdB = dbB - dbA
13334  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
13335  # Phase Value
13336  RelPhase = FSweepBPh[index] - FSweepAPh[index]
13337  if RelPhase > 180:
13338  RelPhase = RelPhase - 360
13339  elif RelPhase < -180:
13340  RelPhase = RelPhase + 360
13341  if Two_X_Sample.get() == 0:
13342  PhErr = 0.0018 * F # calculate phase error due half sample period offset
13343  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
13344  else:
13345  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
13346  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
13347  if y1 > 1500:
13348  y1 = xright
13349  elif y1 < -500:
13350  y1 = ycenter - xright
13351  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
13352  if x1 > 1500:
13353  x1 = xright
13354  elif x1 < -500:
13355  x1 = xcenter - xright
13356  NqPline.append(x1)
13357  NqPline.append(y1)
13358  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13359 #
13361  global NiCScreenStatus, NiCDisp
13362  global nicwindow, NiCca, logo, SWRev
13363  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
13364  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
13365  global NetworkScreenStatus, NiCSweepSaved
13366 
13367  if NiCScreenStatus.get() == 0:
13368  NiCScreenStatus.set(1)
13369  NiCDisp.set(1)
13370  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
13371  CANVASheightNic = GRHNiC + 60 # The canvas height
13372  nicwindow = Toplevel()
13373  nicwindow.title("Nichols Plot " + SWRev + RevDate)
13374  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
13375  #frame2iar = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13376  #frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13377 
13378  frame2nic = Frame(nicwindow, borderwidth=5, relief=RIDGE)
13379  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
13380 
13381  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
13382  NiCca.bind("<Configure>", NiCCaresize)
13383  NiCca.bind("<Return>", DoNothing)
13384  NiCca.bind("<space>", onCanvasSpaceBar)
13385  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
13386 #
13388  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
13389 
13390  NiCScreenStatus.set(0)
13391  NiCDisp.set(0)
13392  nicwindow.destroy()
13393 #
13394 def NiCCaresize(event):
13395  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
13396 
13397  CANVASwidthNic = event.width - 4
13398  CANVASheightNic = event.height - 4
13399  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
13400  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
13401  UpdateNiCAll()
13402 
13405  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
13406  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
13407  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
13408  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
13409  global FontSize
13410 
13411  Ymin = Y0TNiC # Minimum position of XY grid (top)
13412  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
13413  Xmin = X0LNiC # Minimum position of XY grid (left)
13414  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
13415  try:
13416  Phasecenter = int(PhCenBodeEntry.get())
13417  RelPhaseCenter.set(Phasecenter)
13418  except:
13419  PhCenBodeEntry.delete(0,"end")
13420  PhCenBodeEntry.insert(0,0)
13421  RelPhaseCenter.set(0)
13422  Phasecenter = 0
13423  # Delete all items on the screen
13424  MarkerNum = 0
13425  SmoothBool = SmoothCurvesBP.get()
13426  NiCca.delete(ALL) # remove all items
13427  # Draw horizontal grid lines Rel Gain Magnitude
13428  i = 0
13429  x1 = X0LNiC
13430  x2 = X0TNiC = X0LNiC + GRWNiC
13431  mg_siz = GRWNiC/10.0
13432  mg_inc = mg_siz/5.0
13433  DegPerDiv = 360 / 10
13434  while (i < Vdiv.get()+1):
13435  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
13436  y = Y0TNiC + i * GRHNiC/Vdiv.get()
13437  Dline = [x1,y,x2,y]
13438  if dBaxis_value == 0:
13439  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
13440  k = 0
13441  while (k < 10):
13442  l = 1
13443  while (l < 5): # add tick marks
13444  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
13445  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13446  l = l + 1
13447  k = k + 1
13448  else:
13449  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13450  dBaxis_label = str(dBaxis_value)
13451  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
13452 
13453  i = i + 1
13454  # Draw vertical grid lines (phase -180 to 180 10 div)
13455  i = 0
13456  y1 = Y0TNiC
13457  y2 = Y0TNiC + GRHNiC
13458  mg_siz = GRHNiC/10.0
13459  mg_inc = mg_siz/5.0
13460  #
13461  while (i < 11):
13462  x = X0LNiC + i * GRWNiC/10.0
13463  Dline = [x,y1,x,y2]
13464  axis_value = Phasecenter - 180 + (i * DegPerDiv)
13465  axis_label = str(axis_value)
13466  if ( axis_value == 0):
13467  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
13468  k = 0
13469  while (k < 10):
13470  l = 1
13471  while (l < 5): # add tick marks
13472  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
13473  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13474  l = l + 1
13475  k = k + 1
13476  else:
13477  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13478  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
13479  i = i + 1
13480  # Draw traces
13481  # Vertical conversion factors (level dBs) and border limits
13482  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13483  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
13484  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
13485  Xp = float(X0LNiC) + Xphconv * 180.0
13486  x1 = X0LNiC + 14
13487  # Horizontal conversion factors (phase deg) and border limits
13488  NiCline = []
13489  if len(FSweepAdB) > 4:
13490  index = 0
13491  for index in range(len(FSweepAdB)): # while n < len(FStep):
13492  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
13493  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
13494  else:
13495  F = FBins[int(FStep[0])]
13496  # Mag value
13497  dbA = (10 * math.log10(float(FSweepAdB[index])) + 17) # Convert power to DBs, except for log(0) error
13498  dbB = (10 * math.log10(float(FSweepBdB[index])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13499  if ShowMathBP.get() == 1:
13500  MdB = dbA - dbB
13501  elif ShowMathBP.get() == 2:
13502  MdB = dbB - dbA
13503  yb = Yc - Yconv * MdB
13504  if (yb < Ymin):
13505  yb = Ymin
13506  if (yb > Ymax):
13507  yb = Ymax
13508  # Phase Value
13509  RelPhase = FSweepBPh[index] - FSweepAPh[index]
13510  RelPhase = RelPhase - Phasecenter
13511  if RelPhase > 180:
13512  RelPhase = RelPhase - 360
13513  elif RelPhase < -180:
13514  RelPhase = RelPhase + 360
13515  if Two_X_Sample.get() == 0:
13516  PhErr = 0.0018 * F # calculate phase error due half sample period offset
13517  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
13518  else:
13519  RelPhase = RelPhase # - PhaseOffset2x
13520  xa = Xp + Xphconv * RelPhase
13521  if (xa < Xmin):
13522  xa = Ymin
13523  if (xa > Xmax):
13524  xa = Xmax
13525  NiCline.append(int(xa + 0.5))
13526  NiCline.append(int(yb + 0.5))
13527  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13528 #
13529 def UpdateNqPAll(): # Update Data, trace and screen
13530  global FFTBuffA, FFTBuffB
13531  global SMPfft
13532 
13533  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13534  return
13535  #MakeNqPTrace() # Update the traces
13536  UpdateNqPScreen() # Update the screen
13537 
13538 def UpdateNqPTrace(): # Update trace and screen
13539 
13540  #MakeNqPTrace() # Update traces
13541  UpdateNqPScreen() # Update the screen
13542 
13543 def UpdateNqPScreen(): # Update screen with trace and text
13544 
13545  MakeNqPScreen() # Update the screen
13546  root.update() # Activate updated screens
13547 #
13548 def UpdateNiCAll(): # Update Data, trace and screen
13549  global FFTBuffA, FFTBuffB
13550  global SMPfft
13551 
13552  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13553  return
13554  #MakeNiCTrace() # Update the traces
13555  UpdateNiCScreen() # Update the screen
13556 
13557 def UpdateNiCTrace(): # Update trace and screen
13558 
13559  #MakeNiCTrace() # Update traces
13560  UpdateNiCScreen() # Update the screen
13561 
13562 def UpdateNiCScreen(): # Update screen with trace and text
13563 
13564  MakeNiCScreen() # Update the screen
13565  root.update() # Activate updated screens
13566 #
13567 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
13568  global FFTmemoryA, FFTresultA
13569  global FFTmemoryB, FFTresultB
13570  global PhaseA, PhaseB, freqwindow
13571  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
13572 
13573  # Set the TRACEsize variable
13574  if ShowC1_VdB.get() == 1:
13575  TRACEsize = len(FFTresultA) # Set the trace length
13576  elif ShowC2_VdB.get() == 1:
13577  TRACEsize = len(FFTresultB)
13578  if TRACEsize == 0: # If no trace, skip rest of this routine
13579  return()
13580 # ask if save as magnitude or dB
13581  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
13582  # Make the file name and open it
13583  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13584  filename = "Spectrum-" + tme
13585  filename = filename + ".csv"
13586  # open file to save data
13587  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13588  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
13589  DataFile = open(filename,'a') # Open output file
13590  HeaderString = 'Frequency-#, '
13591  if ShowC1_VdB.get() == 1:
13592  if dB == 1:
13593  HeaderString = HeaderString + 'CA-dB, '
13594  if dB == 0:
13595  HeaderString = HeaderString + 'CA-Mag, '
13596  if ShowC2_VdB.get() == 1:
13597  if dB == 1:
13598  HeaderString = HeaderString + 'CB-dB, '
13599  if dB == 0:
13600  HeaderString = HeaderString + 'CB-Mag, '
13601  if ShowC1_P.get() == 1:
13602  HeaderString = HeaderString + 'Phase A-B, '
13603  if ShowC2_P.get() == 1:
13604  HeaderString = HeaderString + 'Phase B-A, '
13605  HeaderString = HeaderString + '\n'
13606  DataFile.write( HeaderString )
13607 
13608  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
13609 
13610  n = 0
13611  while n < TRACEsize:
13612  F = n * Fsample
13613  txt = str(F)
13614  if ShowC1_VdB.get() == 1:
13615  V = 10 * math.log10(float(FFTresultA[n])) + 17 # Add 17 dB for max value of +10 dB
13616  if dB == 0:
13617  V = 10.0**(V/20.0)
13618  txt = txt + "," + str(V)
13619  if ShowC2_VdB.get() == 1:
13620  V = 10 * math.log10(float(FFTresultB[n])) + 17 # Add 17 dB for max value of +10 dB
13621  if dB == 0:
13622  V = 10.0**(V/20.0)
13623  txt = txt + "," + str(V)
13624  if ShowC1_P.get() == 1:
13625  RelPhase = PhaseA[n]-PhaseB[n]
13626  if RelPhase > 180:
13627  RelPhase = RelPhase - 360
13628  elif RelPhase < -180:
13629  RelPhase = RelPhase + 360
13630  txt = txt + "," + str(RelPhase)
13631  if ShowC2_P.get() == 1:
13632  RelPhase = PhaseB[n]-PhaseA[n]
13633  if RelPhase > 180:
13634  RelPhase = RelPhase - 360
13635  elif RelPhase < -180:
13636  RelPhase = RelPhase + 360
13637  txt = txt + "," + str(RelPhase)
13638  txt = txt + "\n"
13639  DataFile.write(txt)
13640  n = n + 1
13641 
13642  DataFile.close() # Close the file
13643 
13645 def MakeFreqScreen(): # Update the screen with traces and text
13646  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
13647  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13648  global PeakxM, PeakyM, PeakMdb, PeakfreqM
13649  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
13650  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
13651  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
13652  global COLORgrid # The colors
13653  global COLORsignalband, COLORtext
13654  global COLORtrace1, COLORtrace2
13655  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
13656  global DBdivindex # Index value
13657  global DBdivlist # dB per division list
13658  global DBlevel # Reference level
13659  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
13660  global X0LF # Left top X value
13661  global Y0TF # Left top Y value
13662  global GRWF # Screenwidth
13663  global GRHF # Screenheight
13664  global FontSize
13665  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
13666  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
13667  global SMPfft # number of FFT samples
13668  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
13669  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
13670  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp
13671  global ShowFCur, ShowdBCur, FCursor, dBCursor
13672  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
13673  global T1PRline, T2PRline
13674  global TRACEaverage # Number of traces for averageing
13675  global FreqTraceMode # 1 normal 2 max 3 average
13676  global Vdiv # Number of vertical divisions
13677 
13678  # Delete all items on the screen
13679  MarkerFreqNum = 0
13680  Freqca.delete(ALL) # remove all items
13681  try:
13682  StartFrequency = float(StartFreqEntry.get())
13683  except:
13684  StartFreqEntry.delete(0,"end")
13685  StartFreqEntry.insert(0,100)
13686  StartFrequency = 100
13687  try:
13688  StopFrequency = float(StopFreqEntry.get())
13689  except:
13690  StopFreqEntry.delete(0,"end")
13691  StopFreqEntry.insert(0,10000)
13692  StopFrequency = 10000
13693  try:
13694  Phasecenter = int(PhCenFreqEntry.get())
13695  RelPhaseCenter.set(Phasecenter)
13696  except:
13697  PhCenFreqEntry.delete(0,"end")
13698  PhCenFreqEntry.insert(0,0)
13699  RelPhaseCenter.set(0)
13700  Phasecenter = 0
13701  # Draw horizontal grid lines
13702  i = 0
13703  x1 = X0LF
13704  x2 = X0LF + GRWF
13705  while (i <= Vdiv.get()):
13706  y = Y0TF + i * GRHF/Vdiv.get()
13707  Dline = [x1,y,x2,y]
13708  if i == 0 or i == Vdiv.get():
13709  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13710  else:
13711  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13712  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
13713  Vaxis_label = str(Vaxis_value)
13714  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
13715  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
13716  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
13717  Vaxis_value = Vaxis_value + Phasecenter
13718  Vaxis_label = str(Vaxis_value)
13719  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
13720  i = i + 1
13721  # Draw vertical grid lines
13722  i = 0
13723  y1 = Y0TF
13724  y2 = Y0TF + GRHF
13725  if HScale.get() == 1:
13726  F = 1.0
13727  LogFStop = math.log10(StopFrequency)
13728  try:
13729  LogFStart = math.log10(StartFrequency)
13730  except:
13731  LogFStart = 0.0
13732  LogFpixel = (LogFStop - LogFStart) / GRWF
13733  # draw left and right edges
13734  while F <= StopFrequency:
13735  if F >= StartFrequency:
13736  try:
13737  LogF = math.log10(F) # convet to log Freq
13738  x = X0LF + (LogF - LogFStart)/LogFpixel
13739  except:
13740  x = X0LF
13741  Dline = [x,y1,x,y2]
13742  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
13743  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13744  axis_label = str(F)
13745  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
13746  else:
13747  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13748 
13749  if F < 10:
13750  F = F + 1
13751  elif F < 100:
13752  F = F + 10
13753  elif F < 1000:
13754  F = F + 100
13755  elif F < 1000:
13756  F = F + 100
13757  elif F < 10000:
13758  F = F + 1000
13759  elif F < 100000:
13760  F = F + 10000
13761  elif F < 200000:
13762  F = F + 10000
13763  else:
13764  Freqdiv = (StopFrequency - StartFrequency) / 10
13765  while (i < 11):
13766  x = X0LF + i * GRWF/10.0
13767  Dline = [x,y1,x,y2]
13768  if i == 0 or i == 10:
13769  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13770  else:
13771  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13772  axis_value = (StartFrequency + (i * Freqdiv))
13773  axis_label = str(axis_value)
13774  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
13775  i = i + 1
13776  # Draw X - Y cursors if needed
13777  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13778  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13779  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13780  if ShowFCur.get() > 0:
13781  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
13782  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
13783  # Horizontal conversion factors (frequency Hz) and border limits
13784  if HScale.get() == 1:
13785  LogFStop = math.log10(StopFrequency)
13786  try:
13787  LogFStart = math.log10(StartFrequency)
13788  except:
13789  LogFStart = 0.0
13790  LogFpixel = (LogFStop - LogFStart) / GRWF
13791  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
13792  else:
13793  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13794  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
13795  XFString = ' {0:.2f} '.format(xfreq)
13796  V_label = XFString + " Hz"
13797  Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
13798 #
13799  if ShowdBCur.get() > 0:
13800  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
13801  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
13802  # Vertical conversion factors (level dBs) and border limits
13803  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13804  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13805  yvdB = ((Yc-dBCursor)/Yconv)
13806  VdBString = ' {0:.1f} '.format(yvdB)
13807  V_label = VdBString + " dBV"
13808  Freqca.create_text(FCursor+1, dBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
13809  #
13810  SmoothBool = SmoothCurvesSA.get()
13811  # Draw traces
13812  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
13813  # Write the trace CHA
13814  if OverRangeFlagA == 1:
13815  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13816  else:
13817  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13818  if ShowMarker.get() > 0:
13819  k = 1
13820  while k <= HarmonicMarkers.get():
13821  try:
13822  dbA = (10 * math.log10(float(FFTresultA[PeakIndexA*k])) + 17)
13823  FreqA = k*PeakIndexA*Fsample
13824  if ShowMarker.get() == 2 and k > 1:
13825  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
13826  else:
13827  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
13828  if HScale.get() == 1:
13829  try:
13830  LogF = math.log10(FreqA) # convet to log Freq
13831  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
13832  except:
13833  xA = X0LF
13834  else:
13835  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
13836  yA = Yc - Yconv * dbA
13837  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
13838  k = k + 1
13839  except:
13840  k = k + 1
13841  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
13842  # Write the trace CHB
13843  if OverRangeFlagB == 1:
13844  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13845  else:
13846  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13847  if ShowMarker.get() > 0:
13848  k = 1
13849  while k <= HarmonicMarkers.get():
13850  try:
13851  dbB = (10 * math.log10(float(FFTresultB[PeakIndexB*k])) + 17)
13852  FreqB = k*PeakIndexB*Fsample
13853  if ShowMarker.get() == 2 and k > 1:
13854  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
13855  else:
13856  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
13857  if HScale.get() == 1:
13858  try:
13859  LogF = math.log10(FreqB) # convet to log Freq
13860  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
13861  except:
13862  xB = X0LF
13863  else:
13864  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
13865  yB = Yc - Yconv * dbB
13866  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
13867  k = k + 1
13868  except:
13869  k = k + 1
13870  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
13871  # Write the phase trace A-B
13872  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13873  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
13874  # Write the phase trace A-B
13875  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13876  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
13877  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13878  if ShowMarker.get() == 1:
13879  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
13880  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
13881  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
13882  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13883  if ShowMarker.get() == 1:
13884  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
13885  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
13886  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
13887  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13888  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
13889  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13890  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
13891  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13892  if ShowMarker.get() ==1:
13893  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
13894  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
13895  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
13896  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13897  if ShowMarker.get() ==1:
13898  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
13899  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
13900  # General information on top of the grid
13901 
13902  txt = " Sample rate: " + str(SAMPLErate)
13903  txt = txt + " FFT samples: " + str(SMPfft)
13904 
13905  txt = txt + " " + FFTwindowname
13906 
13907  x = X0LF
13908  y = 12
13909  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13910 
13911  # Start and stop frequency and dB/div and trace mode
13912  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
13913  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
13914  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
13915  if FFTwindow.get() < 7:
13916  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
13917  else:
13918  txt = txt + " FFT Bandwidth = ???"
13919 
13920  x = X0LF
13921  y = Y0TF+GRHF+23
13922  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13923 
13924  if FreqTraceMode.get() == 1:
13925  txt ="Normal mode "
13926 
13927  if FreqTraceMode.get() == 2:
13928  txt = "Peak hold mode "
13929 
13930  if FreqTraceMode.get() == 3:
13931  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
13932 
13933  if ZEROstuffing.get() > 0:
13934  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
13935  # Runstatus and level information
13936  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
13937  txt = txt + " Stopped "
13938  elif SingleShotSA.get() == 1:
13939  txt = txt + " Single Shot Trace "
13940  else:
13941  if FreqDisp.get() == 1:
13942  txt = txt + " Running "
13943  else:
13944  txt = txt + " Display off "
13945  x = X0LF
13946  y = Y0TF+GRHF+34
13947  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13948 
13950  global SMPfft, FFTwindow
13951  global SMPfftpwrTwo, BodeDisp
13952  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
13953 
13954  # First some subroutines to set specific variables
13955  if BodeDisp.get() == 0:
13956  if FFTwindow.get() != 8:
13957  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
13958 
13960  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
13961  TRACEresetFreq = True # Clear the memory for averaging or peak
13962  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
13963  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
13964 
13965 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
13966  global FFTbandwidth # The FFT bandwidth
13967  global FFTwindow # Which FFT window number is selected
13968  global FFTwindowname # The name of the FFT window function
13969  global FFTwindowshape # The window shape
13970  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
13971  global SMPfft # Number of FFT samples
13972  global LastWindow, LastSMPfft
13973 
13974  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
13975  # recalculate window only if something changed
13976  return
13977  # FFTname and FFTbandwidth in milliHz
13978  FFTwindowname = "No such window"
13979  FFTbw = 0
13980 
13981  if FFTwindow.get() == 0:
13982  FFTwindowname = " Rectangular (no) window (B=1) "
13983  FFTbw = 1.0
13984 
13985  if FFTwindow.get() == 1:
13986  FFTwindowname = " Cosine window (B=1.24) "
13987  FFTbw = 1.24
13988 
13989  if FFTwindow.get() == 2:
13990  FFTwindowname = " Triangular window (B=1.33) "
13991  FFTbw = 1.33
13992 
13993  if FFTwindow.get() == 3:
13994  FFTwindowname = " Hann window (B=1.5) "
13995  FFTbw = 1.5
13996 
13997  if FFTwindow.get() == 4:
13998  FFTwindowname = " Blackman window (B=1.73) "
13999  FFTbw = 1.73
14000 
14001  if FFTwindow.get() == 5:
14002  FFTwindowname = " Nuttall window (B=2.02) "
14003  FFTbw = 2.02
14004 
14005  if FFTwindow.get() == 6:
14006  FFTwindowname = " Flat top window (B=3.77) "
14007  FFTbw = 3.77
14008 
14009  if FFTwindow.get() == 7:
14010  FFTwindowname = FFTUserWindowString
14011  FFTbw = 0.0
14012  try:
14013  FFTwindowshape = eval(FFTUserWindowString)
14014  except:
14015  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
14016  print( "Filling FFT window with Ones")
14017  elif FFTwindow.get() == 8: # window shape array read from csv file
14018  FFTwindowname = "Window Shape From file"
14019  FFTbw = 0.0
14020  else:
14021  FFTbandwidth = int(FFTbw * SAMPLErate / float(SMPfft))
14022  # Calculate the shape
14023  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
14024  n = 0
14025  while n < SMPfft:
14026  # Cosine window function - medium-dynamic range B=1.24
14027  if FFTwindow.get() == 1:
14028  w = math.sin(math.pi * n / (SMPfft - 1))
14029  FFTwindowshape[n] = w * 1.571
14030  # Triangular non-zero endpoints - medium-dynamic range B=1.33
14031  if FFTwindow.get() == 2:
14032  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
14033  FFTwindowshape[n] = w * 2.0
14034  # Hann window function - medium-dynamic range B=1.5
14035  if FFTwindow.get() == 3:
14036  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
14037  FFTwindowshape[n] = w * 2.000
14038  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
14039  if FFTwindow.get() == 4:
14040  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
14041  FFTwindowshape[n] = w * 2.381
14042  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
14043  if FFTwindow.get() == 5:
14044  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))
14045  FFTwindowshape[n] = w * 2.811
14046  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
14047  if FFTwindow.get() == 6:
14048  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))
14049  FFTwindowshape[n] = w * 1.000
14050  n = n + 1
14051  LastWindow = FFTwindow.get()
14052  LastSMPfft = SMPfft
14053 
14055  global FFTUserWindowString, freqwindow
14056 
14057  TempString = FFTUserWindowString
14058  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
14059  if (FFTUserWindowString == None): # If Cancel pressed, then None
14060  FFTUserWindowString = TempString
14061 
14063  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
14064 
14065  # Read values from CVS file
14066  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
14067  try:
14068  CSVFile = open(filename)
14069  csv_f = csv.reader(CSVFile)
14070  FFTwindowshape = []
14071  for row in csv_f:
14072  try:
14073  FFTwindowshape.append(float(row[0]))
14074  except:
14075  print( 'skipping non-numeric row')
14076  FFTwindowshape = numpy.array(FFTwindowshape)
14077  CSVFile.close()
14078  SMPfft = len(FFTwindowshape)
14079  LastSMPfft = SMPfft
14080  LastWindow = FFTwindow.get()
14081  print( SMPfft)
14082  except:
14083  showwarning("WARNING","No such file found or wrong format!")
14084 #
14086  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
14087 
14088  FCursor = event.x
14089  dBCursor = event.y
14090  if RUNstatus.get() == 0:
14092  Freqca.bind_all('<MouseWheel>', onCanvasFreqClickScroll)
14093 #
14095  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
14096  if event.widget == Freqca:
14097  ShiftKeyDwn = event.state & 1
14098  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
14099  FCursor = FCursor + event.delta/100
14100  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
14101  dBCursor = dBCursor - event.delta/100
14102  if RUNstatus.get() == 0:
14104 #
14106  global X0LF # Left top X value
14107  global Y0TF # Left top Y value
14108  global GRWF # Screenwidth
14109  global GRHF # Screenheight
14110  global FontSize
14111  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
14112  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
14113  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
14114  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
14115 
14116  if (RUNstatus.get() == 0):
14117  MarkerFreqNum = MarkerFreqNum + 1
14118  COLORmarker = COLORgrid
14119  if ShowC1_VdB.get() == 1:
14120  COLORmarker = COLORtrace1
14121  elif ShowC2_VdB.get() == 1:
14122  COLORmarker = COLORtrace2
14123  try:
14124  StartFrequency = float(StartFreqEntry.get())
14125  except:
14126  StartFreqEntry.delete(0,"end")
14127  StartFreqEntry.insert(0,100)
14128  StartFrequency = 100
14129  try:
14130  StopFrequency = float(StopFreqEntry.get())
14131  except:
14132  StopFreqEntry.delete(0,"end")
14133  StopFreqEntry.insert(0,100)
14134  StopFrequency = 100
14135  # draw X at marker point and number
14136  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
14137  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
14138  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
14139  # Vertical conversion factors (level dBs) and border limits
14140  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14141  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
14142  Yphconv = float(GRHF) / 360
14143  Yp = float(Y0TF) + Yphconv + 180
14144  # Horizontal conversion factors (frequency Hz) and border limits
14145  if HScale.get() == 1:
14146  LogFStop = math.log10(StopFrequency)
14147  try:
14148  LogFStart = math.log10(StartFrequency)
14149  except:
14150  LogFStart = 0.0
14151  LogFpixel = (LogFStop - LogFStart) / GRWF
14152  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
14153  else:
14154  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
14155  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
14156 
14157  yvdB = ((Yc-event.y)/Yconv)
14158  VdBString = ' {0:.1f} '.format(yvdB)
14159  XFString = ' {0:.2f} '.format(xfreq)
14160  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
14161  if MarkerFreqNum > 1:
14162  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
14163  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
14164  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
14165  x = X0LF + 5
14166  y = Y0TF + 3 + (MarkerFreqNum*10)
14167  Justify = 'w'
14168  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
14169  x = X0LF + GRWF - 5
14170  y = Y0TF + 3 + (MarkerFreqNum*10)
14171  Justify = 'e'
14172  if MarkerLoc == 'LL' or MarkerLoc == 'll':
14173  x = X0LF + 5
14174  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
14175  Justify = 'w'
14176  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
14177  x = X0LF + GRWF - 5
14178  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
14179  Justify = 'e'
14180  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
14181  PrevdBV = yvdB
14182  PrevF = xfreq
14183 #
14184 def onCanvasSAOne(event):
14185  global ShowC1_VdB
14186  if ShowC1_VdB.get() == 0:
14187  ShowC1_VdB.set(1)
14188  else:
14189  ShowC1_VdB.set(0)
14190 #
14191 def onCanvasSATwo(event):
14192  global ShowC2_VdB
14193  if ShowC2_VdB.get() == 0:
14194  ShowC2_VdB.set(1)
14195  else:
14196  ShowC2_VdB.set(0)
14197 #
14198 def onCanvasSAThree(event):
14199  global ShowC1_P
14200  if ShowC1_P.get() == 0:
14201  ShowC1_P.set(1)
14202  else:
14203  ShowC1_P.set(0)
14204 #
14205 def onCanvasSAFour(event):
14206  global ShowC2_P
14207  if ShowC2_P.get() == 0:
14208  ShowC2_P.set(1)
14209  else:
14210  ShowC2_P.set(0)
14211 #
14212 def onCanvasSAFive(event):
14213  global ShowMarker
14214  if ShowMarker.get() == 0:
14215  ShowMarker.set(1)
14216  else:
14217  ShowMarker.set(0)
14218 #
14219 def onCanvasSASix(event):
14220  global ShowRA_VdB
14221  if ShowRA_VdB.get() == 0:
14222  ShowRA_VdB.set(1)
14223  else:
14224  ShowRA_VdB.set(0)
14225 #
14226 def onCanvasSASeven(event):
14227  global ShowRB_VdB
14228  if ShowRB_VdB.get() == 0:
14229  ShowRB_VdB.set(1)
14230  else:
14231  ShowRB_VdB.set(0)
14232 #
14233 def onCanvasSAEight(event):
14234  global ShowMathSA
14235  ShowMathSA.set(2)
14236 #
14237 def onCanvasSANine(event):
14238  global ShowMathSA
14239  ShowMathSA.set(1)
14240 #
14241 def onCanvasSAZero(event):
14242  global ShowMathSA
14243  ShowMathSA.set(0)
14244 #
14245 def onCanvasSASnap(event):
14246  BSTOREtraceSA()
14247 #
14248 def onCanvasSANormal(event):
14249  BNormalmode()
14250 #
14251 def onCanvasSAPeak(event):
14252  BPeakholdmode()
14253 
14254 def onCanvasSAReset(event):
14255  BResetFreqAvg()
14256 #
14258  BAveragemode()
14259 #
14260 def onCanvasShowFcur(event):
14261  global ShowFCur
14262  if ShowFCur.get() == 0:
14263  ShowFCur.set(1)
14264  else:
14265  ShowFCur.set(0)
14266 #
14268  global ShowdBCur
14269  if ShowdBCur.get() == 1:
14270  ShowdBCur.set(0)
14271  else:
14272  ShowdBCur.set(1)
14273 #
14274 def onCanvasShowPcur(event):
14275  global ShowdBCur
14276  if ShowdBCur.get() == 2:
14277  ShowdBCur.set(0)
14278  else:
14279  ShowdBCur.set(2)
14280 #
14282  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
14283 
14284  BPCursor = event.x
14285  BdBCursor = event.y
14286  if RUNstatus.get() == 0:
14288  Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
14289 #
14291  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
14292 
14293  # print event.state
14294  shift_key = event.state & 1
14295  if ShowBPCur.get() > 0 and shift_key == 0:
14296  BPCursor = BPCursor + event.delta/100
14297  elif ShowBdBCur.get() > 0 or shift_key == 1:
14298  BdBCursor = BdBCursor - event.delta/100
14299  if RUNstatus.get() == 0:
14301 #
14303  global X0LBP # Left top X value
14304  global Y0TBP # Left top Y value
14305  global GRWBP # Screenwidth
14306  global GRHBP # Screenheight
14307  global FontSize
14308  global Bodeca, MarkerLoc, SAMPLErate
14309  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
14310  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
14311  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
14312 
14313  if (RUNstatus.get() == 0):
14314  MarkerFreqNum = MarkerFreqNum + 1
14315  COLORmarker = COLORtrace6 # COLORgrid
14316  if ShowCA_VdB.get() == 1:
14317  COLORmarker = COLORtrace1
14318  elif ShowCB_VdB.get() == 1:
14319  COLORmarker = COLORtrace2
14320  try:
14321  EndFreq = float(StopBodeEntry.get())
14322  except:
14323  StopBodeEntry.delete(0,"end")
14324  StopBodeEntry.insert(0,10000)
14325  EndFreq = 10000
14326  try:
14327  BeginFreq = float(StartBodeEntry.get())
14328  except:
14329  StartBodeEntry.delete(0,"end")
14330  StartBodeEntry.insert(0,100)
14331  BeginFreq = 100
14332  # draw X at marker point and number
14333  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
14334  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
14335  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
14336  # Vertical conversion factors (level dBs) and border limits
14337  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14338  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14339  Yphconv = float(GRHBP) / 360
14340  Yp = float(Y0TBP) + Yphconv + 180
14341  x1 = X0LBP + 14
14342  x2 = x1 + GRWBP
14343  # Horizontal conversion factors (frequency Hz) and border limits
14344  if HScaleBP.get() == 1:
14345  LogFStop = math.log10(EndFreq)
14346  try:
14347  LogFStart = math.log10(BeginFreq)
14348  except:
14349  LogFStart = 0.0
14350  LogFpixel = (LogFStop - LogFStart) / GRWBP
14351  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
14352  else:
14353  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14354  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
14355 
14356  yvdB = ((Yc-event.y)/Yconv)
14357  VdBString = ' {0:.1f} '.format(yvdB)
14358  XFString = ' {0:.2f} '.format(xfreq)
14359  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
14360  if MarkerFreqNum > 1:
14361  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
14362  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
14363  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
14364  x = x1 + 5
14365  y = Y0TBP + 3 + (MarkerFreqNum*10)
14366  Justify = 'w'
14367  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
14368  x = x2 - 5
14369  y = Y0TBP + 3 + (MarkerFreqNum*10)
14370  Justify = 'e'
14371  if MarkerLoc == 'LL' or MarkerLoc == 'll':
14372  x = x1 + 5
14373  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
14374  Justify = 'w'
14375  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
14376  x = x2 - 5
14377  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
14378  Justify = 'e'
14379  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
14380  PrevdBV = yvdB
14381  PrevF = xfreq
14382 #
14383 def onCanvasBdOne(event):
14384  global ShowCA_VdB
14385  if ShowCA_VdB.get() == 0:
14386  ShowCA_VdB.set(1)
14387  else:
14388  ShowCA_VdB.set(0)
14389 #
14390 def onCanvasBdTwo(event):
14391  global ShowCB_VdB
14392  if ShowCB_VdB.get() == 0:
14393  ShowCB_VdB.set(1)
14394  else:
14395  ShowCB_VdB.set(0)
14396 #
14397 def onCanvasBdThree(event):
14398  global ShowCA_P
14399  if ShowCA_P.get() == 0:
14400  ShowCA_P.set(1)
14401  else:
14402  ShowCA_P.set(0)
14403 #
14404 def onCanvasBdFour(event):
14405  global ShowCB_P
14406  if ShowCB_P.get() == 0:
14407  ShowCB_P.set(1)
14408  else:
14409  ShowCB_P.set(0)
14410 #
14411 def onCanvasBdFive(event):
14412  global ShowMarkerBP
14413  if ShowMarkerBP.get() == 0:
14414  ShowMarkerBP.set(1)
14415  else:
14416  ShowMarkerBP.set(0)
14417 #
14418 def onCanvasBdSix(event):
14419  global ShowRA_VdB
14420  if ShowRA_VdB.get() == 0:
14421  ShowRA_VdB.set(1)
14422  else:
14423  ShowRA_VdB.set(0)
14424 #
14425 def onCanvasBdSeven(event):
14426  global ShowRB_VdB
14427  if ShowRB_VdB.get() == 0:
14428  ShowRB_VdB.set(1)
14429  else:
14430  ShowRB_VdB.set(0)
14431 #
14432 def onCanvasBdEight(event):
14433  global ShowMathBP
14434  ShowMathBP.set(2)
14435 #
14436 def onCanvasBdNine(event):
14437  global ShowMathBP
14438  ShowMathBP.set(1)
14439 #
14440 def onCanvasBdZero(event):
14441  global ShowMathBP
14442  ShowMathBP.set(0)
14443 #
14444 def onCanvasBdSnap(event):
14445  BSTOREtraceBP()
14446 #
14448  global ShowBPCur
14449  if ShowBPCur.get() == 0:
14450  ShowBPCur.set(1)
14451  else:
14452  ShowBPCur.set(0)
14453 #
14455  global ShowBdBCur
14456  if ShowBdBCur.get() == 1:
14457  ShowBdBCur.set(0)
14458  else:
14459  ShowBdBCur.set(1)
14460 #
14462  global ShowBdBCur
14463  if ShowBdBCur.get() == 2:
14464  ShowBdBCur.set(0)
14465  else:
14466  ShowBdBCur.set(2)
14467 #
14468 def onAWGAscroll(event):
14469  global AWGAShape
14470 
14471  onTextScroll(event)
14472  time.sleep(0.05)
14473  ReMakeAWGwaves()
14474  time.sleep(0.05)
14475 #
14476 def onAWGBscroll(event):
14477  global AWGBShape
14478 
14479  onTextScroll(event)
14480  time.sleep(0.05)
14481  ReMakeAWGwaves()
14482  time.sleep(0.05)
14483 #
14484 def onTextScroll(event): # august 7
14485  button = event.widget
14486  cursor_position = button.index(INSERT) # get current cursor position
14487  Pos = cursor_position
14488  OldVal = button.get() # get current entry string
14489  OldValfl = float(OldVal) # and its value
14490  Len = len(OldVal)
14491  Dot = OldVal.find (".") # find decimal point position
14492  Decimals = Len - Dot - 1
14493  if Dot == -1 : # no point
14494  Decimals = 0
14495  Step = 10**(Len - Pos)
14496  elif Pos <= Dot : # no point left of position
14497  Step = 10**(Dot - Pos)
14498  else :
14499  Step = 10**(Dot - Pos + 1)
14500  if event.delta > 0: # increment value
14501  NewVal = OldValfl + Step
14502  else: # decrement value
14503  NewVal = OldValfl - Step
14504  FormatStr = "{0:." + str(Decimals) + "f}"
14505  NewStr = FormatStr.format(NewVal)
14506  NewDot = NewStr.find (".")
14507  NewPos = Pos + NewDot - Dot
14508  if Decimals == 0 :
14509  NewLen = len(NewStr)
14510  NewPos = Pos + NewLen - Len
14511  button.delete(0, END) # remove old entry
14512  button.insert(0, NewStr) # insert new entry
14513  button.icursor(NewPos) # resets the insertion cursor
14514 #
14515 def onAWGAkey(event):
14516  global AWGAShape
14517 
14518  onTextKey(event)
14519  ReMakeAWGwaves()
14520 #
14521 def onAWGBkey(event):
14522  global AWGBShape
14523 
14524  onTextKey(event)
14525  ReMakeAWGwaves()
14526 #
14527 def onTextKeyAWG(event):
14528  onTextKey(event)
14529  ReMakeAWGwaves()
14530 
14531 def onTextKey(event):
14532 
14533  button = event.widget
14534  cursor_position = button.index(INSERT) # get current cursor position
14535  NewPos = cursor_position -1
14536  OldVal = button.get() # get current entry string
14537  OldDigit = OldVal[NewPos]
14538  if platform.system() == "Windows":
14539  if event.keycode == 38: # increment digit for up arrow key
14540  NewDigit = int(OldDigit) + 1
14541  elif event.keycode == 40: # decrement digit for down arrow
14542  NewDigit = int(OldDigit) - 1
14543  else:
14544  return
14545  elif platform.system() == "Linux":
14546  if event.keycode == 111: # increment digit for up arrow key
14547  NewDigit = int(OldDigit) + 1
14548  elif event.keycode == 116: # decrement digit for down arrow
14549  NewDigit = int(OldDigit) - 1
14550  else:
14551  return
14552  if OldDigit == ".": # if cursor next to decimal point nop
14553  return
14554  if NewDigit > 9:
14555  NewDigit = 0
14556  button.delete(NewPos) # remove old digit
14557  button.insert(NewPos,NewDigit) # insert new digit
14558  NewPos = cursor_position-2
14559  if NewPos < 0:
14560  return
14561  CarryDigit = OldVal[NewPos]
14562  if CarryDigit == ".": # if carry is decimal point
14563  NewPos = cursor_position-3
14564  CarryDigit = OldVal[NewPos]
14565  NewDigit = int(CarryDigit) + 1
14566  if NewDigit > 9:
14567  NewDigit = 0
14568  button.delete(NewPos) # remove old digit
14569  button.insert(NewPos,NewDigit) # insert new digit
14570  elif NewDigit < 0:
14571  NewDigit = 9
14572  button.delete(NewPos) # remove old digit
14573  button.insert(NewPos,NewDigit) # insert new digit
14574  NewPos = cursor_position-2
14575  if NewPos < 0:
14576  return
14577  CarryDigit = OldVal[NewPos]
14578  if CarryDigit == ".": # if carry is decimal point
14579  NewPos = cursor_position-3
14580  CarryDigit = OldVal[NewPos]
14581  NewDigit = int(CarryDigit) - 1
14582  if NewDigit < 0:
14583  NewDigit = 9
14584  button.delete(NewPos) # remove old digit
14585  button.insert(NewPos,NewDigit) # insert new digit
14586  else:
14587  button.delete(NewPos) # remove old digit
14588  button.insert(NewPos,NewDigit) # insert new digit
14589 #
14590 def onSpinBoxScroll(event):
14591  spbox = event.widget
14592  if sys.version_info[0] == 3: # Spin Boxes do this automatically in Python 3 apparently
14593  return
14594  if event.delta > 0: # increment digit
14595  spbox.invoke('buttonup')
14596  else: # decrement digit
14597  spbox.invoke('buttondown')
14598 #
14599 # ================ Make awg sub window ==========================
14601  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
14602  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
14603  global AWGABurstFlag, AWGBBurstFlag
14604  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
14605  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
14606  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
14607  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
14608  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
14609  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
14610 
14611  if AWGScreenStatus.get() == 0:
14612  AWGScreenStatus.set(1)
14613 
14614  awgwindow = Toplevel()
14615  awgwindow.title("AWG Controls " + SWRev + RevDate)
14616  awgwindow.resizable(FALSE,FALSE)
14617  awgwindow.geometry('+0+100')
14618  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
14619  #
14620  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
14621  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
14622  #
14623  if AwgLayout == "Horz":
14624  frame2.pack(side=LEFT, expand=1, fill=X)
14625  frame3.pack(side=LEFT, expand=1, fill=X)
14626  else:
14627  frame2.pack(side=TOP, expand=1, fill=Y)
14628  frame3.pack(side=TOP, expand=1, fill=Y)
14629  # now AWG A
14630  # AWG enable sub frame
14631  AWGAMode = IntVar(0) # AWG A mode variable
14632  AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
14633  AWGATerm = IntVar(0) # AWG A termination variable
14634  AWGAShape = IntVar(0) # AWG A Wave shape variable
14635  AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
14636  AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
14637  AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
14638  AWGAMode.set(2)
14639  AWGSync = IntVar(0) # Sync start both AWG channels
14640  AWGSync.set(1)
14641  awg1eb = Frame( frame2 )
14642  awg1eb.pack(side=TOP)
14643  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
14644  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
14645  ModeAMenu["menu"] = ModeAMenu.menu
14646  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
14647  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
14648  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
14649  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
14650  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
14651  ModeAMenu.menu.add_separator()
14652  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
14653  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
14654  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
14655  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
14656  ModeAMenu.pack(side=LEFT, anchor=W)
14657  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W6.TButton")
14658  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
14659  ShapeAMenu["menu"] = ShapeAMenu.menu
14660  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
14661  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
14662  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
14663  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
14664  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
14665  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
14666  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
14667  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
14668  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
14669  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
14670  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
14671  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
14672  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
14673  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
14674  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
14675  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
14676  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
14677  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
14678  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
14679  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
14680  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
14681  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
14682  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
14683  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
14684  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
14685  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
14686  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
14687  ShapeAMenu.pack(side=LEFT, anchor=W)
14688  #
14689  AWGAModeLabel = Label(frame2, text="AWG A Mode")
14690  AWGAModeLabel.pack(side=TOP)
14691  #
14692  awg1ampl = Frame( frame2 )
14693  awg1ampl.pack(side=TOP)
14694  AWGAAmplEntry = Entry(awg1ampl, width=5)
14695  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
14696  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
14697  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
14698  AWGAAmplEntry.pack(side=LEFT, anchor=W)
14699  AWGAAmplEntry.delete(0,"end")
14700  AWGAAmplEntry.insert(0,0.0)
14701  amp1lab = Label(awg1ampl) #, text="Min Ch A")
14702  amp1lab.pack(side=LEFT, anchor=W)
14703  #
14704  awg1off = Frame( frame2 )
14705  awg1off.pack(side=TOP)
14706  AWGAOffsetEntry = Entry(awg1off, width=5)
14707  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
14708  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
14709  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
14710  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
14711  AWGAOffsetEntry.delete(0,"end")
14712  AWGAOffsetEntry.insert(0,0.0)
14713  off1lab = Label(awg1off) #, text="Max Ch A")
14714  off1lab.pack(side=LEFT, anchor=W)
14715  if AWG_Amp_Mode.get() == 0:
14716  amp1lab.config(text = "Min Ch A" ) # change displayed value
14717  off1lab.config(text = "Max Ch A" ) # change displayed value
14718  else:
14719  amp1lab.config(text = "Amp Ch A" )
14720  off1lab.config(text = "Off Ch A" )
14721  # AWG Frequency sub frame
14722  awg1freq = Frame( frame2 )
14723  awg1freq.pack(side=TOP)
14724  AWGAFreqEntry = Entry(awg1freq, width=7)
14725  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
14726  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
14727  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
14728  AWGAFreqEntry.pack(side=LEFT, anchor=W)
14729  AWGAFreqEntry.delete(0,"end")
14730  AWGAFreqEntry.insert(0,100.0)
14731  freq1lab = Label(awg1freq, text="Freq Ch A")
14732  freq1lab.pack(side=LEFT, anchor=W)
14733  # AWG Phase or delay select sub frame
14734  AWGAPhaseDelay = IntVar(0) #
14735  awgadelay = Frame( frame2 )
14736  awgadelay.pack(side=TOP)
14737  awgaph = Radiobutton(awgadelay, text="Phase", style="WPhase.TRadiobutton", variable=AWGAPhaseDelay, value=0, command=BAWGAPhaseDelay)
14738  awgaph.pack(side=LEFT, anchor=W)
14739  awgadel = Radiobutton(awgadelay, text="Delay", style="GPhase.TRadiobutton", variable=AWGAPhaseDelay, value=1, command=BAWGAPhaseDelay)
14740  awgadel.pack(side=LEFT, anchor=W)
14741  # AWG Phase entry sub frame
14742  awg1phase = Frame( frame2 )
14743  awg1phase.pack(side=TOP)
14744  AWGAPhaseEntry = Entry(awg1phase, width=5)
14745  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
14746  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
14747  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
14748  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
14749  AWGAPhaseEntry.delete(0,"end")
14750  AWGAPhaseEntry.insert(0,0)
14751  phasealab = Label(awg1phase, text="Deg")
14752  phasealab.pack(side=LEFT, anchor=W)
14753  # AWG duty cycle frame
14754  awg1dc = Frame( frame2 )
14755  awg1dc.pack(side=TOP)
14756  AWGADutyCycleEntry = Entry(awg1dc, width=5)
14757  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
14758  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
14759  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
14760  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
14761  AWGADutyCycleEntry.delete(0,"end")
14762  AWGADutyCycleEntry.insert(0,50)
14763  duty1lab = Label(awg1dc, text="%")
14764  duty1lab.pack(side=LEFT, anchor=W)
14765  #
14766  AWGALength = Label(frame2, text="Length")
14767  AWGALength.pack(side=TOP)
14768  #
14769  if FWRevOne > 2.16:
14770  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
14771  awg2x1.pack(side=TOP)
14772  awg2x2 = Radiobutton(frame2, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
14773  awg2x2.pack(side=TOP)
14774  awg2x3 = Radiobutton(frame2, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
14775  awg2x3.pack(side=TOP)
14776  else:
14777  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
14778  awgsync.pack(side=TOP)
14779  # now AWG B
14780  # AWG enable sub frame
14781  AWGBMode = IntVar(0) # AWG B mode variable
14782  AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
14783  AWGBTerm = IntVar(0) # AWG B termination variable
14784  AWGBShape = IntVar(0) # AWG B Wave shape variable
14785  AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
14786  AWGBMode.set(2)
14787  awg2eb = Frame( frame3 )
14788  awg2eb.pack(side=TOP)
14789  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
14790  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
14791  ModeBMenu["menu"] = ModeBMenu.menu
14792  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
14793  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
14794  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
14795  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
14796  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
14797  ModeBMenu.menu.add_separator()
14798  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
14799  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
14800  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
14801  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
14802  ModeBMenu.pack(side=LEFT, anchor=W)
14803  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W6.TButton")
14804  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
14805  ShapeBMenu["menu"] = ShapeBMenu.menu
14806  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
14807  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
14808  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
14809  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
14810  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
14811  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
14812  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
14813  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
14814  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
14815  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
14816  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
14817  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
14818  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
14819  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
14820  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
14821  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
14822  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
14823  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
14824  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
14825  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
14826  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
14827  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
14828  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
14829  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
14830  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
14831  ShapeBMenu.pack(side=LEFT, anchor=W)
14832  #
14833  AWGBModeLabel = Label(frame3, text="AWG A Mode")
14834  AWGBModeLabel.pack(side=TOP)
14835  #
14836  awg2ampl = Frame( frame3 )
14837  awg2ampl.pack(side=TOP)
14838  AWGBAmplEntry = Entry(awg2ampl, width=5)
14839  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
14840  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll) #
14841  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
14842  AWGBAmplEntry.pack(side=LEFT, anchor=W)
14843  AWGBAmplEntry.delete(0,"end")
14844  AWGBAmplEntry.insert(0,0.0)
14845  amp2lab = Label(awg2ampl) #, text="Min Ch B")
14846  amp2lab.pack(side=LEFT, anchor=W)
14847  #
14848  awg2off = Frame( frame3 )
14849  awg2off.pack(side=TOP)
14850  AWGBOffsetEntry = Entry(awg2off, width=5)
14851  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
14852  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
14853  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
14854  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
14855  AWGBOffsetEntry.delete(0,"end")
14856  AWGBOffsetEntry.insert(0,0.0)
14857  off2lab = Label(awg2off) #, text="Max Ch B")
14858  off2lab.pack(side=LEFT, anchor=W)
14859  if AWG_Amp_Mode.get() == 0:
14860  amp2lab.config(text = "Min Ch B" ) # change displayed value
14861  off2lab.config(text = "Max Ch B" ) # change displayed value
14862  else:
14863  amp2lab.config(text = "Amp Ch B" )
14864  off2lab.config(text = "Off Ch B" )
14865  # AWG Frequency sub frame
14866  awg2freq = Frame( frame3 )
14867  awg2freq.pack(side=TOP)
14868  AWGBFreqEntry = Entry(awg2freq, width=7)
14869  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
14870  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
14871  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
14872  AWGBFreqEntry.pack(side=LEFT, anchor=W)
14873  AWGBFreqEntry.delete(0,"end")
14874  AWGBFreqEntry.insert(0,100.0)
14875  freq2lab = Label(awg2freq, text="Freq Ch B")
14876  freq2lab.pack(side=LEFT, anchor=W)
14877  # AWG Phase or delay select sub frame
14878  AWGBPhaseDelay = IntVar(0) #
14879  awgbdelay = Frame( frame3 )
14880  awgbdelay.pack(side=TOP)
14881  awgbph = Radiobutton(awgbdelay, text="Phase", style="WPhase.TRadiobutton", variable=AWGBPhaseDelay, value=0, command=BAWGBPhaseDelay)
14882  awgbph.pack(side=LEFT, anchor=W)
14883  awgbdel = Radiobutton(awgbdelay, text="Delay", style="GPhase.TRadiobutton", variable=AWGBPhaseDelay, value=1, command=BAWGBPhaseDelay)
14884  awgbdel.pack(side=LEFT, anchor=W)
14885  # AWG Phase sub frame
14886  awg2phase = Frame( frame3 )
14887  awg2phase.pack(side=TOP)
14888  AWGBPhaseEntry = Entry(awg2phase, width=5)
14889  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
14890  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
14891  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
14892  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
14893  AWGBPhaseEntry.delete(0,"end")
14894  AWGBPhaseEntry.insert(0,0)
14895  phaseblab = Label(awg2phase, text="Deg")
14896  phaseblab.pack(side=LEFT, anchor=W)
14897  # AWG duty cycle frame
14898  awg2dc = Frame( frame3 )
14899  awg2dc.pack(side=TOP)
14900  AWGBDutyCycleEntry = Entry(awg2dc, width=5)
14901  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
14902  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
14903  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
14904  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
14905  AWGBDutyCycleEntry.delete(0,"end")
14906  AWGBDutyCycleEntry.insert(0,50)
14907  duty2lab = Label(awg2dc, text="%")
14908  duty2lab.pack(side=LEFT, anchor=W)
14909  #
14910  AWGBLength = Label(frame3, text="Length")
14911  AWGBLength.pack(side=TOP)
14912  #
14913  BisCompA = IntVar(0) # Sync start both AWG channels
14914  BisCompA.set(0)
14915  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
14916  bcompa.pack(side=TOP)
14917  if FWRevOne > 2.16:
14918  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
14919  awgsync.pack(side=TOP)
14920  #
14921  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
14922  dismissbutton.pack(side=TOP)
14923  else:
14924  awgwindow.deiconify()
14925 #
14926 def BAWG2X():
14927  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
14928 
14929  ReMakeAWGwaves()
14930  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
14931  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
14932  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
14933  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
14934  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
14935  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
14936  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
14937  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
14938  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
14939  BisCompA.set(0)
14940  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
14941  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
14942  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
14943  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
14944  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
14945  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
14946  BisCompA.set(0)
14947 #
14949  global awgwindow, AWGScreenStatus
14950 
14951  # AWGScreenStatus.set(0)
14952  awgwindow.iconify()
14953 #
14954 # ===== Channel B Mux Mode sub Window =======
14956  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
14957  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
14958  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
14959  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
14960  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev
14961  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg, DualMuxMode
14962 
14963  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
14964  MuxScreenStatus.set(1)
14965  #
14966  BAWGEnab() # update AWG settings
14967  #
14968  muxwindow = Toplevel()
14969  muxwindow.title("CH-B Mux " + SWRev + RevDate)
14970  muxwindow.resizable(FALSE,FALSE)
14971  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
14972  #
14973  frameM = LabelFrame(muxwindow, text="CH B Mux", style="A10B.TLabel") #, font="Arial 10 bold", borderwidth=5, relief=RIDGE)
14974  frameM.pack(side=LEFT, expand=1, fill=Y)
14975  #
14976  # Voltage channel CHB-A
14977  frameA = Frame(frameM)
14978  frameA.pack(side=TOP)
14979  cba = Checkbutton(frameA, text='CB-A', variable=Show_CBA, command=UpdateTimeTrace)
14980  cba.pack(side=LEFT, anchor=W)
14981  CHB_Asb = Spinbox(frameA, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14982  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
14983  CHB_Asb.pack(side=LEFT)
14984  CHB_Asb.delete(0,"end")
14985  CHB_Asb.insert(0,0.5)
14986  #
14987  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
14988  CHB_Alab.pack(side=LEFT)
14989  CHB_APosEntry = Entry(frameA, width=5)
14990  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
14991  CHB_APosEntry.bind('<Key>', onTextKey)
14992  CHB_APosEntry.pack(side=LEFT)
14993  CHB_APosEntry.delete(0,"end")
14994  CHB_APosEntry.insert(0,2.5)
14995  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
14996  CHB_Aofflab.pack(side=LEFT)
14997  # Voltage channel CHB-B
14998  frameB = Frame(frameM)
14999  frameB.pack(side=TOP)
15000  cbb = Checkbutton(frameB, text='CB-B', variable=Show_CBB, command=UpdateTimeTrace)
15001  cbb.pack(side=LEFT, anchor=W)
15002  CHB_Bsb = Spinbox(frameB, width=4, values=CHvpdiv, command=UpdateTimeTrace)
15003  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
15004  CHB_Bsb.pack(side=LEFT)
15005  CHB_Bsb.delete(0,"end")
15006  CHB_Bsb.insert(0,0.5)
15007  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
15008  CHB_Blab.pack(side=LEFT)
15009  CHB_BPosEntry = Entry(frameB, width=5)
15010  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
15011  CHB_BPosEntry.bind('<Key>', onTextKey)
15012  CHB_BPosEntry.pack(side=LEFT)
15013  CHB_BPosEntry.delete(0,"end")
15014  CHB_BPosEntry.insert(0,2.5)
15015  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
15016  CHB_Bofflab.pack(side=LEFT)
15017  # Voltage channel B-C
15018  frameC = Frame(frameM)
15019  frameC.pack(side=TOP)
15020  cbc = Checkbutton(frameC, text='CB-C', variable=Show_CBC, command=UpdateTimeTrace)
15021  cbc.pack(side=LEFT, anchor=W)
15022  CHB_Csb = Spinbox(frameC, width=4, values=CHvpdiv, command=UpdateTimeTrace)
15023  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
15024  CHB_Csb.pack(side=LEFT)
15025  CHB_Csb.delete(0,"end")
15026  CHB_Csb.insert(0,0.5)
15027  #
15028  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
15029  CHB_Clab.pack(side=LEFT)
15030  CHB_CPosEntry = Entry(frameC, width=5)
15031  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
15032  CHB_CPosEntry.bind('<Key>', onTextKey)
15033  CHB_CPosEntry.pack(side=LEFT)
15034  CHB_CPosEntry.delete(0,"end")
15035  CHB_CPosEntry.insert(0,2.5)
15036  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
15037  CHB_Cofflab.pack(side=LEFT)
15038  # Voltage channel B-D
15039  frameD = Frame(frameM)
15040  frameD.pack(side=TOP)
15041  cbd = Checkbutton(frameD, text='CB-D', variable=Show_CBD, command=UpdateTimeTrace)
15042  cbd.pack(side=LEFT, anchor=W)
15043  CHB_Dsb = Spinbox(frameD, width=4, values=CHvpdiv, command=UpdateTimeTrace)
15044  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
15045  CHB_Dsb.pack(side=LEFT)
15046  CHB_Dsb.delete(0,"end")
15047  CHB_Dsb.insert(0,0.5)
15048  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
15049  CHB_Dlab.pack(side=LEFT)
15050  CHB_DPosEntry = Entry(frameD, width=5)
15051  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
15052  CHB_DPosEntry.bind('<Key>', onTextKey)
15053  CHB_DPosEntry.pack(side=LEFT)
15054  CHB_DPosEntry.delete(0,"end")
15055  CHB_DPosEntry.insert(0,2.5)
15056  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
15057  CHB_Dofflab.pack(side=LEFT)
15058  frameE = Frame(frameM)
15059  frameE.pack(side=TOP)
15060  MuxEnb = IntVar(0)
15061  MuxSync = IntVar(0)
15062  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
15063  muxenab.pack(side=LEFT)
15064  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
15065  SyncButton.pack(side=LEFT)
15066  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
15067  dismissbutton.pack(side=LEFT)
15068  frameF = Frame(frameM)
15069  frameF.pack(side=TOP)
15070  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
15071  dmx.pack(side=LEFT)
15072  # Gray out main Channel B controls
15073  CHBlab.config(style="SGray.TButton")
15074  CHBofflab.config(style="SGray.TButton")
15075 #
15077  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
15078  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab
15079 
15080  if DualMuxMode.get() == 1:
15081  AWGAIOMode.set(1) # force awg A split I/O mode
15082  AWGBIOMode.set(1) # force awg A split I/O mode
15083  ShowC1_V.set(0) # force A voltage trace off
15084  CHB_Clab.config(text="CA-C V/Div")
15085  CHB_Dlab.config(text="CA-D V/Div")
15086  CHB_Cofflab.config(text="CA-C Pos")
15087  CHB_Dofflab.config(text="CA-D Pos")
15088  BAWGEnab() # update AWG settings
15089  # Gray out main Channel A controls
15090  CHAlab.config(style="SGray.TButton")
15091  CHAofflab.config(style="SGray.TButton")
15092  else:
15093  ShowC1_V.set(1) # force A voltage trace on
15094  CHB_Clab.config(text="CB-C V/Div")
15095  CHB_Dlab.config(text="CB-D V/Div")
15096  CHB_Cofflab.config(text="CB-C Pos")
15097  CHB_Dofflab.config(text="CB-D Pos")
15098  # Reset main Channel A control colors
15099  CHAlab.config(style="Rtrace1.TButton")
15100  CHAofflab.config(style="Rtrace1.TButton")
15101 #
15103  global MuxSync, hipulseimg, lowpulseimg, SyncButton
15104 
15105  if MuxSync.get() == 0:
15106  SyncButton.config(image=hipulseimg)
15107  else:
15108  SyncButton.config(image=lowpulseimg)
15109 
15111  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
15112 
15113  MuxScreenStatus.set(0)
15114  awgsync.config(state=NORMAL)
15115  # Reset main Channel B control colors
15116  CHBlab.config(style="Rtrace2.TButton")
15117  CHBofflab.config(style="Rtrace2.TButton")
15118  CHAlab.config(style="Rtrace1.TButton")
15119  CHAofflab.config(style="Rtrace1.TButton")
15120  muxwindow.destroy()
15121 #
15122 def BodeCaresize(event):
15123  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
15124 
15125  CANVASwidthBP = event.width - 4
15126  CANVASheightBP = event.height - 4
15127  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
15128  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
15129  UpdateBodeAll()
15130 #
15132  global FStepSync, DevOne
15133 
15134  if FStepSync.get() == 0:
15135  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
15136  elif FStepSync.get() == 1:
15137  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
15138  elif FStepSync.get() == 2:
15139  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
15140 #
15142  global FSweepSync, DevOne
15143 
15144  if FSweepSync.get() == 0:
15145  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
15146  elif FSweepSync.get() == 1:
15147  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
15148  elif FSweepSync.get() == 2:
15149  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
15150 #
15152  global BDSweepFile, FileSweepFreq, FileSweepAmpl
15153 
15154  if BDSweepFile.get() > 0:
15155  # Read values from CVS file
15156  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
15157  try:
15158  CSVFile = open(filename)
15159  csv_f = csv.reader(CSVFile)
15160  FileSweepFreq = []
15161  FileSweepAmpl = []
15162  for row in csv_f:
15163  try:
15164  FileSweepFreq.append(float(row[0]))
15165  FileSweepAmpl.append(float(row[1]))
15166  except:
15167  print( 'skipping non-numeric row')
15168  FileSweepFreq = numpy.array(FileSweepFreq)
15169  FileSweepAmpl = numpy.array(FileSweepAmpl)
15170  MaxAmpl = numpy.amax(FileSweepAmpl)
15171  NormAmpl = MaxAmpl
15172  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
15173  if (s == None): # If Cancel pressed, then None
15174  return()
15175  try: # Error if for example no numeric characters or OK pressed without input (s = "")
15176  v = int(s)
15177  except:
15178  s = "error"
15179 
15180  if s != "error":
15181  NormAmpl = MaxAmpl - v
15182  else:
15183  NormAmpl = MaxAmpl
15184  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
15185  CSVFile.close()
15186  StopBodeEntry.delete(0,"end")
15187  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
15188  StartBodeEntry.delete(0,"end")
15189  StartBodeEntry.insert(0,FileSweepFreq[0])
15190  SweepStepBodeEntry.delete(0,"end")
15191  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
15192  except:
15193  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
15194 #
15195 # ========== Make Bode Plot Window =============
15197  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
15198  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
15199  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
15200  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
15201  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
15202  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
15203  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
15204  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
15205  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
15206 
15207  if BodeScreenStatus.get() == 0:
15208  BodeScreenStatus.set(1)
15209  BodeDisp.set(1)
15210  BodeCheckBox()
15211  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
15212  CANVASheightBP = GRHBP + 80 # The ode canvas height
15213  CutDC.set(1) # set to remove DC
15214  AWGAMode.set(0) # Set AWG A to SVMI
15215  AWGAShape.set(1) # Set Shape to Sine
15216  AWGBMode.set(2) # Set AWG B to Hi-Z
15217  bodewindow = Toplevel()
15218  bodewindow.title("Bode Plotter " + SWRev + RevDate)
15219  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
15220  frame2bp = Frame(bodewindow, borderwidth=5, relief=RIDGE)
15221  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
15222 
15223  frame2b = Frame(bodewindow, borderwidth=5, relief=RIDGE)
15224  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
15225 
15226  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
15227  Bodeca.bind('<Configure>', BodeCaresize)
15228  Bodeca.bind('<1>', onCanvasBodeLeftClick)
15229  Bodeca.bind('<3>', onCanvasBodeRightClick)
15230  Bodeca.bind("<Up>", onCanvasUpArrow)
15231  Bodeca.bind("<Down>", onCanvasDownArrow)
15232  Bodeca.bind("<Left>", onCanvasLeftArrow)
15233  Bodeca.bind("<Right>", onCanvasRightArrow)
15234  Bodeca.bind("<space>", onCanvasSpaceBar)
15235  Bodeca.bind("1", onCanvasBdOne)
15236  Bodeca.bind("2", onCanvasBdTwo)
15237  Bodeca.bind("3", onCanvasBdThree)
15238  Bodeca.bind("4", onCanvasBdFour)
15239  Bodeca.bind("5", onCanvasBdFive)
15240  Bodeca.bind("6", onCanvasBdSix)
15241  Bodeca.bind("7", onCanvasBdSeven)
15242  Bodeca.bind("8", onCanvasBdEight)
15243  Bodeca.bind("9", onCanvasBdNine)
15244  Bodeca.bind("0", onCanvasBdZero)
15245  Bodeca.bind("f", onCanvasShowBPcur)
15246  Bodeca.bind("d", onCanvasShowBdBcur)
15247  Bodeca.bind("h", onCanvasShowPdBcur)
15248  Bodeca.bind("s", onCanvasBdSnap)
15249  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
15250 
15251  # right side drop down menu buttons
15252  dropmenu = Frame( frame2bp )
15253  dropmenu.pack(side=TOP)
15254  # File menu
15255  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15256  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
15257  BodeFilemenu["menu"] = BodeFilemenu.menu
15258  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
15259  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
15260  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
15261  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
15262  BodeFilemenu.pack(side=LEFT, anchor=W)
15263  #
15264  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15265  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
15266  BodeOptionmenu["menu"] = BodeOptionmenu.menu
15267  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15268  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
15269  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15270  BodeOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceBP)
15271  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
15272  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
15273  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
15274  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
15275  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
15276  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
15277  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
15278  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
15279  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
15280  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
15281  BodeOptionmenu.pack(side=LEFT, anchor=W)
15282  #
15283  RUNframe = Frame( frame2bp )
15284  RUNframe.pack(side=TOP)
15285  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
15286  rbode.pack(side=LEFT)
15287  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
15288  sbode.pack(side=LEFT)
15289  #
15290  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
15291  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
15292  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
15293  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15294  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15295  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15296  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15297  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15298  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15299  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15300  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
15301  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
15302  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
15303  BodeFFTwindmenu.pack(side=TOP)
15304  #
15305  tracemenu = Frame( frame2bp )
15306  tracemenu.pack(side=TOP)
15307  # Curves menu
15308  # Show channels menu
15309  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
15310  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
15311  BodeShowmenu["menu"] = BodeShowmenu.menu
15312  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
15313  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
15314  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
15315  BodeShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowCA_VdB, command=UpdateBodeAll)
15316  BodeShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowCB_VdB, command=UpdateBodeAll)
15317  BodeShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowCA_P, command=UpdateBodeAll)
15318  BodeShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowCB_P, command=UpdateBodeAll)
15319  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
15320  BodeShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathBP, value=0, command=UpdateBodeAll)
15321  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathBP, value=1, command=UpdateBodeAll)
15322  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathBP, value=2, command=UpdateBodeAll)
15323  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
15324  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
15325  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
15326  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
15327  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
15328  BodeShowmenu.menu.add_separator()
15329  BodeShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowCA_RdB, command=UpdateBodeAll)
15330  BodeShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowCB_RdB, command=UpdateBodeAll)
15331  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
15332  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
15333  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
15334  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
15335  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
15336  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
15337  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
15338  BodeShowmenu.pack(side=LEFT, anchor=W)
15339  #
15340  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
15341  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
15342  BodeMarkmenu["menu"] = BodeMarkmenu.menu
15343  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
15344  BodeMarkmenu.menu.add_checkbutton(label='Marker [5]', variable=ShowMarkerBP, command=UpdateBodeAll)
15345  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
15346  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
15347  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
15348  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowBdBCur, value=1)
15349  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowBdBCur, value=2)
15350  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowBPCur)
15351  BodeMarkmenu.pack(side=LEFT, anchor=W)
15352  #
15353  # Horz Scale
15354  HScaleBP = IntVar(0)
15355  HScaleBP.set(1)
15356  HzScale = Frame( frame2bp )
15357  HzScale.pack(side=TOP)
15358  rb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
15359  rb1.pack(side=LEFT)
15360  rb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
15361  rb2.pack(side=LEFT)
15362 
15363  DBrange = Frame( frame2bp )
15364  DBrange.pack(side=TOP)
15365  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
15366  bd3.pack(side=LEFT)
15367  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
15368  bd4.pack(side=LEFT)
15369 
15370  LVBrange = Frame( frame2bp )
15371  LVBrange.pack(side=TOP)
15372  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
15373  bd5.pack(side=LEFT)
15374  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
15375  bd6.pack(side=LEFT)
15376 
15377  LVSrange = Frame( frame2bp )
15378  LVSrange.pack(side=TOP)
15379  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
15380  bd7.pack(side=LEFT)
15381  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
15382  bd8.pack(side=LEFT)
15383 
15384  PhaseCenter = Frame( frame2bp )
15385  PhaseCenter.pack(side=TOP)
15386  PhCenlab = Label(PhaseCenter, text="Center Phase on")
15387  PhCenlab.pack(side=LEFT)
15388  PhCenBodeEntry = Entry(PhaseCenter, width=5)
15389  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
15390  PhCenBodeEntry.bind('<Key>', onTextKey)
15391  PhCenBodeEntry.pack(side=LEFT)
15392  PhCenBodeEntry.delete(0,"end")
15393  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
15394  #
15395  ImpedCenter = Frame( frame2bp )
15396  ImpedCenter.pack(side=TOP)
15397  ImCenlab = Label(ImpedCenter, text="Center Imped on")
15398  ImCenlab.pack(side=LEFT)
15399  ImCenBodeEntry = Entry(ImpedCenter, width=5)
15400  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
15401  ImCenBodeEntry.bind('<Key>', onTextKey)
15402  ImCenBodeEntry.pack(side=LEFT)
15403  ImCenBodeEntry.delete(0,"end")
15404  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
15405  # sweep generator mode menu buttons
15406  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
15407  FSweepmenu.pack(side=TOP)
15408 
15409  Frange1 = Frame( frame2bp )
15410  Frange1.pack(side=TOP)
15411  startfreqlab = Label(Frange1, text="Startfreq")
15412  startfreqlab.pack(side=LEFT)
15413  StartBodeEntry = Entry(Frange1, width=5)
15414  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
15415  StartBodeEntry.bind('<Key>', onTextKey)
15416  StartBodeEntry.pack(side=LEFT)
15417  StartBodeEntry.delete(0,"end")
15418  StartBodeEntry.insert(0,10)
15419 
15420  Frange2 = Frame( frame2bp )
15421  Frange2.pack(side=TOP)
15422  stopfreqlab = Label(Frange2, text="Stopfreq")
15423  stopfreqlab.pack(side=LEFT)
15424  StopBodeEntry = Entry(Frange2, width=5)
15425  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
15426  StopBodeEntry.bind('<Key>', onTextKey)
15427  StopBodeEntry.pack(side=LEFT)
15428  StopBodeEntry.delete(0,"end")
15429  StopBodeEntry.insert(0,10000)
15430 
15431  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
15432  sgrb1.pack(side=TOP)
15433  Frange4 = Frame( frame2bp )
15434  Frange4.pack(side=TOP)
15435  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
15436  sgrb2.pack(side=LEFT)
15437  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
15438  sgrb3.pack(side=LEFT)
15439  if MinigenScreenStatus.get() > 0:
15440  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
15441  sgrb1.pack(side=TOP)
15442  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
15443  ffcb.pack(side=TOP)
15444  Frange3 = Frame( frame2bp )
15445  Frange3.pack(side=TOP)
15446  sweepsteplab = Label(Frange3, text="Sweep Steps")
15447  sweepsteplab.pack(side=LEFT)
15448  SweepStepBodeEntry = Entry(Frange3, width=5)
15449  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
15450  SweepStepBodeEntry.bind('<Key>', onTextKey)
15451  SweepStepBodeEntry.pack(side=LEFT)
15452  SweepStepBodeEntry.delete(0,"end")
15453  SweepStepBodeEntry.insert(0,100)
15454 
15455  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
15456  sgrb5.pack(side=TOP)
15457  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
15458  sgrb6.pack(side=TOP)
15459  Plotsframe = Frame( frame2bp )
15460  Plotsframe.pack(side=TOP)
15461  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
15462  nyquistplotbutton.pack(side=LEFT)
15463  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
15464  nicholsplotbutton.pack(side=LEFT)
15465  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
15466  bodismiss1button.pack(side=TOP)
15467 
15468  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
15469  ADI2.pack(side=TOP)
15470  if ShowBallonHelp > 0:
15471  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
15472  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
15473  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
15474  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
15475  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
15476  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
15477  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
15478  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
15479  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
15480 #
15482  global bodewindow, BodeScreenStatus, ca, FSweepMode
15483 
15484  BodeScreenStatus.set(0)
15485  FSweepMode.set(0)
15486  BodeDisp.set(0)
15487  BodeCheckBox()
15488  bodewindow.destroy()
15489  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15490 #
15491 def FreqCaresize(event):
15492  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
15493 
15494  CANVASwidthF = event.width - 4
15495  CANVASheightF = event.height - 4
15496  GRWF = CANVASwidthF - (2 * X0LF) # new grid width
15497  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
15498  UpdateFreqAll()
15499 #
15500 # ================ Make spectrum sub window ==========================
15502  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
15503  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp
15504  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA
15505  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate
15506  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
15507  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
15508 
15509  if SpectrumScreenStatus.get() == 0:
15510  SpectrumScreenStatus.set(1)
15511  FreqDisp.set(1)
15512  FreqCheckBox()
15513  CANVASwidthF = GRWF + 2 * X0LF # The spectrum canvas width
15514  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
15515  freqwindow = Toplevel()
15516  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
15517  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
15518  frame2fr = Frame(freqwindow, borderwidth=5, relief=RIDGE)
15519  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
15520 
15521  frame2f = Frame(freqwindow, borderwidth=5, relief=RIDGE)
15522  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
15523 
15524  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
15525  Freqca.bind('<Configure>', FreqCaresize)
15526  Freqca.bind('<1>', onCanvasFreqLeftClick)
15527  Freqca.bind('<3>', onCanvasFreqRightClick)
15528  Freqca.bind("<Up>", onCanvasUpArrow)
15529  Freqca.bind("<Down>", onCanvasDownArrow)
15530  Freqca.bind("<Left>", onCanvasLeftArrow)
15531  Freqca.bind("<Right>", onCanvasRightArrow)
15532  Freqca.bind("<space>", onCanvasSpaceBar)
15533  Freqca.bind("1", onCanvasSAOne)
15534  Freqca.bind("2", onCanvasSATwo)
15535  Freqca.bind("3", onCanvasSAThree)
15536  Freqca.bind("4", onCanvasSAFour)
15537  Freqca.bind("5", onCanvasSAFive)
15538  Freqca.bind("6", onCanvasSASix)
15539  Freqca.bind("7", onCanvasSASeven)
15540  Freqca.bind("8", onCanvasSAEight)
15541  Freqca.bind("9", onCanvasSANine)
15542  Freqca.bind("0", onCanvasSAZero)
15543  Freqca.bind("a", onCanvasSAAverage)
15544  Freqca.bind("n", onCanvasSANormal)
15545  Freqca.bind("p", onCanvasSAPeak)
15546  Freqca.bind("r", onCanvasSAReset)
15547  Freqca.bind("f", onCanvasShowFcur)
15548  Freqca.bind("d", onCanvasShowdBcur)
15549  Freqca.bind("h", onCanvasShowPcur)
15550  Freqca.bind("s", onCanvasSASnap)
15551  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
15552  # right side drop down menu buttons
15553  dropmenu = Frame( frame2fr )
15554  dropmenu.pack(side=TOP)
15555  # File menu
15556  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15557  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
15558  SAFilemenu["menu"] = SAFilemenu.menu
15559  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
15560  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
15561  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
15562  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
15563  SAFilemenu.pack(side=LEFT, anchor=W)
15564  #
15565  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15566  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
15567  SAOptionmenu["menu"] = SAOptionmenu.menu
15568  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15569  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15570  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
15571  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15572  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
15573  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
15574  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
15575  SAOptionmenu.pack(side=LEFT, anchor=W)
15576  #
15577  RUNframe = Frame( frame2fr )
15578  RUNframe.pack(side=TOP)
15579  rb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
15580  rb.pack(side=LEFT)
15581  sb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
15582  sb.pack(side=LEFT)
15583  #
15584  Modeframe = Frame( frame2fr )
15585  Modeframe.pack(side=TOP)
15586  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
15587  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
15588  Modemenu["menu"] = Modemenu.menu
15589  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
15590  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
15591  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
15592  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
15593  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
15594  Modemenu.pack(side=LEFT)
15595  #
15596  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
15597  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
15598  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
15599  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15600  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15601  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15602  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15603  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15604  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15605  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15606  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
15607  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
15608  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
15609  SAFFTwindmenu.pack(side=LEFT)
15610  #
15611  SamplesMenu = Frame( frame2fr )
15612  SamplesMenu.pack(side=TOP)
15613  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
15614  bless.pack(side=LEFT)
15615  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
15616  bmore.pack(side=LEFT)
15617  #
15618  # Show channels menu
15619  ShowC1_VdB = IntVar(0) # curves to display variables
15620  ShowC1_P = IntVar(0)
15621  ShowC2_VdB = IntVar(0)
15622  ShowC2_P = IntVar(0)
15623  ShowMarker = IntVar(0)
15624  ShowRA_VdB = IntVar(0)
15625  ShowRA_P = IntVar(0)
15626  ShowRB_VdB = IntVar(0)
15627  ShowRB_P = IntVar(0)
15628  ShowMathSA = IntVar(0)
15629  ShowRMath = IntVar(0)
15630  #
15631  SAShowmenu = Menubutton(frame2fr, text="Curves", style="W7.TButton")
15632  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
15633  SAShowmenu["menu"] = SAShowmenu.menu
15634  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
15635  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
15636  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
15637  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
15638  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
15639  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
15640  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
15641  SAShowmenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
15642  SAShowmenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
15643  SAShowmenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
15644  SAShowmenu.menu.add_separator()
15645  SAShowmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
15646  SAShowmenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
15647  SAShowmenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
15648  SAShowmenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
15649  SAShowmenu.menu.add_separator()
15650  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
15651  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
15652  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
15653  SAShowmenu.menu.add_separator()
15654  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
15655  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
15656  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
15657  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
15658  SAShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMath, command=UpdateFreqAll)
15659  SAShowmenu.pack(side=TOP)
15660  # HScale
15661  Frange1 = Frame( frame2fr )
15662  Frange1.pack(side=TOP)
15663  startfreqlab = Label(Frange1, text="Startfreq")
15664  startfreqlab.pack(side=LEFT)
15665  StartFreqEntry = Entry(Frange1, width=5)
15666  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
15667  StartFreqEntry.bind('<Key>', onTextKey)
15668  StartFreqEntry.pack(side=LEFT)
15669  StartFreqEntry.delete(0,"end")
15670  StartFreqEntry.insert(0,10)
15671 
15672  Frange2 = Frame( frame2fr )
15673  Frange2.pack(side=TOP)
15674  stopfreqlab = Label(Frange2, text="Stopfreq")
15675  stopfreqlab.pack(side=LEFT)
15676  StopFreqEntry = Entry(Frange2, width=7)
15677  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
15678  StopFreqEntry.bind('<Key>', onTextKey)
15679  StopFreqEntry.pack(side=LEFT)
15680  StopFreqEntry.delete(0,"end")
15681  StopFreqEntry.insert(0,10000)
15682 
15683  HScale = IntVar(0)
15684  HzScale = Frame( frame2fr )
15685  HzScale.pack(side=TOP)
15686  rb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
15687  rb1.pack(side=LEFT)
15688  rb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
15689  rb2.pack(side=LEFT)
15690  #
15691  PhaseCenter = Frame( frame2fr )
15692  PhaseCenter.pack(side=TOP)
15693  PhCenlab = Label(PhaseCenter, text="Center Phase on")
15694  PhCenlab.pack(side=LEFT)
15695  PhCenFreqEntry = Entry(PhaseCenter, width=5)
15696  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
15697  PhCenFreqEntry.bind('<Key>', onTextKey)
15698  PhCenFreqEntry.pack(side=LEFT)
15699  PhCenFreqEntry.delete(0,"end")
15700  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
15701  #
15702  DBrange = Frame( frame2fr )
15703  DBrange.pack(side=TOP)
15704  b3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
15705  b3.pack(side=LEFT)
15706  b4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
15707  b4.pack(side=LEFT)
15708 
15709  LVBrange = Frame( frame2fr )
15710  LVBrange.pack(side=TOP)
15711  b5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
15712  b5.pack(side=LEFT)
15713  b6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
15714  b6.pack(side=LEFT)
15715 
15716  LVSrange = Frame( frame2fr )
15717  LVSrange.pack(side=TOP)
15718  b7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
15719  b7.pack(side=LEFT)
15720  b8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
15721  b8.pack(side=LEFT)
15722 
15723  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
15724  sadismiss1button.pack(side=TOP)
15725 
15726  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
15727  ADI2.pack(side=TOP)
15728  if ShowBallonHelp > 0:
15729  sb_tip = CreateToolTip(sb, 'Stop acquiring data')
15730  rb_tip = CreateToolTip(rb, 'Start acquiring data')
15731  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
15732  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
15733  b3_tip = CreateToolTip(b3, 'Increase number of dB/Div')
15734  b4_tip = CreateToolTip(b4, 'Decrease number of dB/Div')
15735  b5_tip = CreateToolTip(b5, 'Increase Ref Level by 10 dB')
15736  b6_tip = CreateToolTip(b6, 'Decrease Ref Level by 10 dB')
15737  b7_tip = CreateToolTip(b7, 'Increase Ref Level by 1 dB')
15738  b8_tip = CreateToolTip(b8, 'Decrease Ref Level by 1 dB')
15739  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
15740 
15742  global freqwindow, SpectrumScreenStatus, ca
15743 
15744  SpectrumScreenStatus.set(0)
15745  FreqDisp.set(0)
15746  FreqCheckBox()
15747  freqwindow.destroy()
15748  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15749 #
15750 def XYcaresize(event):
15751  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
15752  global YminXY, YmaxXY, XminXY, XmaxXY
15753 
15754  CANVASwidthXY = event.width - 4
15755  CANVASheightXY = event.height - 4
15756  GRWXY = CANVASwidthXY - int(2.25 * FontSize) - X0LXY # 18 new grid width
15757  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
15758  YminXY = Y0TXY # Minimum position of time grid (top)
15759  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
15760  XminXY = X0LXY # Minimum position of time grid (left)
15761  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
15762  UpdateXYAll()
15763 #
15764 # ================ Make XY Plot sub window ==========================
15766  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, Ysignal, ShowRXY
15767  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
15768  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
15769  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
15770  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
15771 
15772  if XYScreenStatus.get() == 0:
15773  XYScreenStatus.set(1)
15774  XYDisp.set(1)
15775  XYCheckBox()
15776  YminXY = Y0TXY # Minimum position of XY grid (top)
15777  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
15778  XminXY = X0LXY # Minimum position of XY grid (left)
15779  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
15780  CANVASwidthXY = GRWXY + 18 + X0LXY # The XY canvas width
15781  CANVASheightXY = GRHXY + 80 # The XY canvas height
15782  xywindow = Toplevel()
15783  xywindow.title("X-Y Plot " + SWRev + RevDate)
15784  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
15785  frame2xyr = Frame(xywindow, borderwidth=5, relief=RIDGE)
15786  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
15787 
15788  frame2xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15789  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
15790 
15791  frame3xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15792  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
15793 
15794  frame4xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15795  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
15796 
15797  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
15798  XYca.bind('<Configure>', XYcaresize)
15799  XYca.bind('<1>', onCanvasXYLeftClick)
15800  XYca.bind('<3>', onCanvasXYRightClick)
15801  XYca.bind("<Motion>",onCanvasMouse_xy)
15802  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
15803  XYca.bind("<Up>", onCanvasUpArrow)
15804  XYca.bind("<Down>", onCanvasDownArrow)
15805  XYca.bind("<Left>", onCanvasLeftArrow)
15806  XYca.bind("<Right>", onCanvasRightArrow)
15807  XYca.bind("<space>", onCanvasSpaceBar)
15808  XYca.bind("a", onCanvasAverage)
15809  XYca.pack(side=TOP, fill=BOTH, expand=YES)
15810  #
15811  RUNframe = Frame( frame2xyr )
15812  RUNframe.pack(side=TOP)
15813  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
15814  rbxy.pack(side=LEFT)
15815  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
15816  sbxy.pack(side=LEFT)
15817  # Open Math trace menu
15818  mathbt = Button(frame2xyr, text="Math", style="W5.TButton", command = NewEnterMathControls)
15819  mathbt.pack(side=TOP) #, anchor=W)
15820  # Disply mode menu
15821  # X - Y mode signal select
15822  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
15823  AxisLabX.pack(side=TOP)
15824  chaxmenu = Frame( frame2xyr )
15825  chaxmenu.pack(side=TOP)
15826  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
15827  rbx2.pack(side=LEFT, anchor=W)
15828  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
15829  rbx3.pack(side=LEFT, anchor=W)
15830  chbxmenu = Frame( frame2xyr )
15831  chbxmenu.pack(side=TOP)
15832  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
15833  rbx4.pack(side=LEFT, anchor=W)
15834  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
15835  rbx5.pack(side=LEFT, anchor=W)
15836  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
15837  rbx7.pack(side=TOP)
15838  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
15839  rbx8.pack(side=TOP)
15840  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
15841  rbx6.pack(side=TOP)
15842  #
15843  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
15844  AxisLabY.pack(side=TOP)
15845  chaymenu = Frame( frame2xyr )
15846  chaymenu.pack(side=TOP)
15847  rby2 = Radiobutton(chaymenu, text='CA-V', variable=Ysignal, value=1, command=UpdateXYTrace)
15848  rby2.pack(side=LEFT, anchor=W)
15849  rby3 = Radiobutton(chaymenu, text='CA-I', variable=Ysignal, value=2, command=UpdateXYTrace)
15850  rby3.pack(side=LEFT, anchor=W)
15851  chbymenu = Frame( frame2xyr )
15852  chbymenu.pack(side=TOP)
15853  rby4 = Radiobutton(chbymenu, text='CB-V', variable=Ysignal, value=3, command=UpdateXYTrace)
15854  rby4.pack(side=LEFT, anchor=W)
15855  rby5 = Radiobutton(chbymenu, text='CB-I', variable=Ysignal, value=4, command=UpdateXYTrace)
15856  rby5.pack(side=LEFT, anchor=W)
15857  rby6 = Radiobutton(frame2xyr, text='Math', variable=Ysignal, value=5, command=UpdateXYTrace)
15858  rby6.pack(side=TOP)
15859  # show cursor menu buttons
15860  cursormenu = Frame( frame2xyr )
15861  cursormenu.pack(side=TOP)
15862  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
15863  cb1.pack(side=LEFT, anchor=W)
15864  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
15865  cb2.pack(side=LEFT, anchor=W)
15866  cb3 = Checkbutton(frame2xyr, text='RX-Y', variable=ShowRXY, command=UpdateXYTrace)
15867  cb3.pack(side=TOP)
15868  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
15869  cb4.pack(side=TOP)
15870  #
15871  snapbutton = Button(frame2xyr, style="W11.TButton", text="SnapShot", command=BSnapShot)
15872  snapbutton.pack(side=TOP)
15873  savebutton = Button(frame2xyr, style="W11.TButton", text="Save Screen", command=BSaveScreenXY)
15874  savebutton.pack(side=TOP)
15875  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
15876  dismissxybutton.pack(side=TOP)
15877  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
15878  ADI1xy.pack(side=TOP)
15879 
15880  # Bottom Buttons
15881  MarkerXYScale = IntVar(0)
15882  MarkerXYScale.set(1)
15883  # Voltage channel A
15884  CHAsbxy = Spinbox(frame3xy, width=4, values=CHvpdiv)
15885  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15886  CHAsbxy.pack(side=LEFT)
15887  CHAsbxy.delete(0,"end")
15888  CHAsbxy.insert(0,0.5)
15889  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
15890  CHAxylab.pack(side=LEFT)
15891 
15892  CHAVPosEntryxy = Entry(frame3xy, width=5)
15893  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
15894  CHAVPosEntryxy.bind('<Key>', onTextKey)
15895  CHAVPosEntryxy.pack(side=LEFT)
15896  CHAVPosEntryxy.delete(0,"end")
15897  CHAVPosEntryxy.insert(0,2.5)
15898  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
15899  CHAofflabxy.pack(side=LEFT)
15900  # Current channel A
15901  CHAIsbxy = Spinbox(frame3xy, width=4, values=CHipdiv)
15902  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15903  CHAIsbxy.pack(side=LEFT)
15904  CHAIsbxy.delete(0,"end")
15905  CHAIsbxy.insert(0,50.0)
15906  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
15907  CHAIlabxy.pack(side=LEFT)
15908 
15909  CHAIPosEntryxy = Entry(frame3xy, width=5)
15910  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
15911  CHAIPosEntryxy.bind('<Key>', onTextKey)
15912  CHAIPosEntryxy.pack(side=LEFT)
15913  CHAIPosEntryxy.delete(0,"end")
15914  CHAIPosEntryxy.insert(0,0.0)
15915  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
15916  CHAIofflabxy.pack(side=LEFT)
15917  # Voltage channel B
15918  CHBsbxy = Spinbox(frame4xy, width=4, values=CHvpdiv)
15919  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15920  CHBsbxy.pack(side=LEFT)
15921  CHBsbxy.delete(0,"end")
15922  CHBsbxy.insert(0,0.5)
15923  #
15924  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
15925  CHBxylab.pack(side=LEFT)
15926 
15927  CHBVPosEntryxy = Entry(frame4xy, width=5)
15928  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
15929  CHBVPosEntryxy.bind('<Key>', onTextKey)
15930  CHBVPosEntryxy.pack(side=LEFT)
15931  CHBVPosEntryxy.delete(0,"end")
15932  CHBVPosEntryxy.insert(0,2.5)
15933  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
15934  CHBofflabxy.pack(side=LEFT)
15935  # Current channel B
15936  CHBIsbxy = Spinbox(frame4xy, width=4, values=CHipdiv) #
15937  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15938  CHBIsbxy.pack(side=LEFT)
15939  CHBIsbxy.delete(0,"end")
15940  CHBIsbxy.insert(0,50.0)
15941  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
15942  CHBIlabxy.pack(side=LEFT)
15943 
15944  CHBIPosEntryxy = Entry(frame4xy, width=5)
15945  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
15946  CHBIPosEntryxy.bind('<Key>', onTextKey)
15947  CHBIPosEntryxy.pack(side=LEFT)
15948  CHBIPosEntryxy.delete(0,"end")
15949  CHBIPosEntryxy.insert(0,0.0)
15950  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
15951  CHBIofflabxy.pack(side=LEFT)
15952  #
15953  if ShowBallonHelp > 0:
15954  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
15955  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
15956  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
15957  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
15958  math_tip = CreateToolTip(mathbt, 'Open Math window')
15959  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
15960  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
15961  snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
15962  savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
15963  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
15964  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
15965  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
15966  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
15967  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
15968  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
15969  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
15970 
15972  global xywindow, XYScreenStatus, ca, XYDisp
15973 
15974  XYScreenStatus.set(0)
15975  XYDisp.set(0)
15976  XYCheckBox()
15977  xywindow.destroy()
15978  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15979 #
15980 # Optional Calibration procedure routine
15981 #
15983  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
15984  global discontloop, contloop, session, AWGSync, SWRev
15985  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
15986  # setup cal results window
15987  if FWRevOne < 2.06: # Check firmware revision level > 2.06
15988  showwarning("WARNING","Out of date Firmware Revision!")
15989  return
15990  calwindow = Toplevel()
15991  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
15992  # display wigets
15993  prlab = Label(calwindow, text="Channel Gain / Offset calibration")
15994  prlab.grid(row=0, column=0, columnspan=2, sticky=W)
15995  labelA0 = Label(calwindow, style="A12B.TLabel")
15996  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
15997  labelA0.config(text = "CA gnd Volts")
15998  labelAMax = Label(calwindow, style="A12B.TLabel")
15999  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
16000  labelAMax.config(text = "CA 584 Volts")
16001  labelAMin = Label(calwindow, style="A12B.TLabel")
16002  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
16003  labelAMin.config(text = "CA 5V Src I ")
16004  labelB0 = Label(calwindow, style="A12B.TLabel")
16005  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
16006  labelB0.config(text = "CA gnd Volts")
16007  labelBMax = Label(calwindow, style="A12B.TLabel")
16008  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
16009  labelBMax.config(text = "CB 584 Volts")
16010  labelBMin = Label(calwindow, style="A12B.TLabel")
16011  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
16012  labelBMin.config(text = "CB 5V Src I ")
16013  labelAB = Label(calwindow, style="A12B.TLabel")
16014  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
16015  labelAB.config(text = "CA 0V Src I")
16016  labelBA = Label(calwindow, style="A12B.TLabel")
16017  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
16018  labelBA.config(text = "CA 0V Src I")
16019  labelSIA0 = Label(calwindow, style="A12B.TLabel")
16020  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
16021  labelSIA0.config(text = "CA 2.5 Src 0 I")
16022  labelSIA = Label(calwindow, style="A12B.TLabel")
16023  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
16024  labelSIA.config(text = "CA 50 Src 100 ")
16025  labelSIAN = Label(calwindow, style="A12B.TLabel")
16026  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
16027  labelSIAN.config(text = "CA 50 Src -45")
16028  labelSIB0 = Label(calwindow, style="A12B.TLabel")
16029  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
16030  labelSIB0.config(text = "CB 2.5 Src 0 I")
16031  labelSIB = Label(calwindow, style="A12B.TLabel")
16032  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
16033  labelSIB.config(text = "CB 50 Src 100 ")
16034  labelSIBN = Label(calwindow, style="A12B.TLabel")
16035  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
16036  labelSIBN.config(text = "CB 50 Src -45")
16037  # set to default mux and dac settings
16038  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
16039  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
16040  AWGSync.set(1)
16041  BAWGSync()
16042  if session.continuous:
16043  print( "ending session")
16044  session.end()
16045  # Setup ADALM1000
16046  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
16047  #print(devx.calibration)
16048  try:
16049  devx.write_calibration("calib_default.txt")
16050  #print "wrote calib_default.txt"
16051  except:
16052  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
16053  devx.write_calibration(filename)
16054  #print(devx.calibration)
16055  #
16056  devidstr = DevID[17:31]
16057  filename = "calib" + devidstr + ".txt"
16058  if os.path.isfile(filename):
16059  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
16060  devx.write_calibration(filename)
16061  #print "wrote old ", filename
16062  calwindow.destroy()
16063  return
16064  else:
16065  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
16066  donothing()
16067  else:
16068  calwindow.destroy()
16069  return
16070  #
16071  CalFile = open(filename, "w")
16072  #
16073  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
16074  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
16075  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
16076  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
16077  ADsignal1 = [] # Ain signal array channel
16078  ADsignal1 = devx.get_samples(1010)
16079  # Pause whie user connects external voltage reference AD584
16080  BadData = 1
16081  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
16082  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
16083  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16084  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16085  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
16086  try:
16087  AD584act = float(RequestVRef)*1.0
16088  except:
16089  AD584act = 3.3
16090  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
16091  while (BadData): # loop till good reading
16092  # Get A and B AD584 data
16093  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
16094  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
16095  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16096  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
16097  # get_samples returns a list of values for voltage [0] and current [1]
16098  for index in range(1000): # calculate average
16099  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16100  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16101 
16102  CHA584Raw = CHA584Raw / 1000.0 # calculate average
16103  CHB584Raw = CHB584Raw / 1000.0 # calculate average
16104  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
16105  labelAMax.config(text = VString) # change displayed value
16106  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
16107  labelBMax.config(text = VString) # change displayed value
16108  Lower = AD584act - 0.3
16109  Upper = AD584act + 0.3
16110  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
16111  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
16112  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
16113  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
16114  contloop = 0
16115  discontloop = 1
16116  calwindow.destroy()
16117  return
16118  else:
16119  BadData = 0
16120  #
16121  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
16122  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
16123  # Get A GND and B GND data
16124  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
16125  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
16126  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16127  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
16128  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
16129  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
16130  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16131  # get_samples returns a list of values for voltage [0] and current [1]
16132  for index in range(1000): # calculate average
16133  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16134  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16135  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16136  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16137 
16138  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
16139  CHAI0gRaw = CHAI0gRaw / 1000.0
16140  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
16141  CHBI0gRaw = CHBI0gRaw / 1000.0
16142  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
16143  labelA0.config(text = VString) # change displayed value
16144  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
16145  labelB0.config(text = VString) # change displayed value
16146  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
16147  # Get A and B data for internal 2.5 rail
16148  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
16149  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
16150  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
16151  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
16152  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16153  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16154  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16155  # get_samples returns a list of values for voltage [0] and current [1]
16156  for index in range(1000): # calculate average
16157  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16158  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16159  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16160  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16161 
16162  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
16163  CHAI02p5Raw = CHAI02p5Raw / 1000.0
16164  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
16165  CHBI02p5Raw = CHBI02p5Raw / 1000.0
16166  # Get A force 0V and B force 0V data
16167  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
16168  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
16169  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16170  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16171  CHA.mode = Mode.SVMI
16172  CHA.constant(0.0)
16173  CHB.mode = Mode.SVMI
16174  CHB.constant(0.0)
16175  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16176  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
16177  # get_samples returns a list of values for voltage [0] and current [1]
16178  for index in range(1000): # calculate average
16179  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16180  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16181  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16182  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16183 
16184  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
16185  CHAI0F0Raw = CHAI0F0Raw / 1000.0
16186  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
16187  CHBI0F0Raw = CHBI0F0Raw / 1000.0
16188  # Get A force 2.5V and B force 2.5V data
16189  CHA.mode = Mode.SVMI
16190  CHA.constant(4.5)
16191  CHB.mode = Mode.SVMI
16192  CHB.constant(4.5)
16193  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16194  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
16195  # get_samples returns a list of values for voltage [0] and current [1]
16196  for index in range(1000): # calculate average
16197  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16198  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16199  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16200  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16201 
16202  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
16203  CHAI0F25Raw = CHAI0F25Raw / 1000.0
16204  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
16205  CHBI0F25Raw = CHBI0F25Raw / 1000.0
16206  #
16207  # Get A and B measure current data for int 50 res to gnd at 5V
16208  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
16209  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
16210  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16211  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
16212  CHA.mode = Mode.SVMI
16213  CHA.constant(5.0)
16214  CHB.mode = Mode.SVMI
16215  CHB.constant(5.0)
16216  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16217  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
16218  for index in range(1000): # calculate average
16219  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16220  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16221  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16222  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16223 
16224  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
16225  CHAISr5vRaw = CHAISr5vRaw / 1000.0
16226  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
16227  CHBISr5vRaw = CHBISr5vRaw / 1000.0
16228  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
16229  labelAMin.config(text = VString) # change displayed value
16230  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
16231  labelBMin.config(text = VString) # change displayed value
16232  # Get A and B measure current data for int 50 res to 2.5 V at 0V
16233  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16234  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16235  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16236  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16237  CHA.mode = Mode.SVMI
16238  CHA.constant(0.001)
16239  CHB.mode = Mode.SVMI
16240  CHB.constant(0.001)
16241  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16242  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
16243  for index in range(1000): # calculate average
16244  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16245  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16246  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16247  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16248 
16249  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
16250  CHAISr0vRaw = CHAISr0vRaw / 1000.0
16251  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
16252  CHBISr0vRaw = CHBISr0vRaw / 1000.0
16253  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
16254  labelAB.config(text = VString) # change displayed value
16255  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
16256  labelBA.config(text = VString) # change displayed value
16257 
16258  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
16259  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16260  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16261  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16262  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16263  CHA.mode = Mode.SIMV
16264  CHA.constant(0.0)
16265  CHB.mode = Mode.SIMV
16266  CHB.constant(0.0)
16267  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16268  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
16269  for index in range(1000): # calculate average
16270  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16271  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16272  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16273  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16274 
16275  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
16276  CHAISr0iRaw = CHAISr0iRaw / 1000.0
16277  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
16278  CHBISr0iRaw = CHBISr0iRaw / 1000.0
16279  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
16280  labelSIA0.config(text = VString) # change displayed value
16281  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
16282  labelSIB0.config(text = VString) # change displayed value
16283  #
16284  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
16285  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16286  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16287  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16288  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16289  CHA.mode = Mode.SIMV
16290  CHA.constant(0.045)
16291  CHB.mode = Mode.SIMV
16292  CHB.constant(0.045)
16293  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16294  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
16295  for index in range(1000): # calculate average
16296  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16297  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16298  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16299  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16300 
16301  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
16302  CHAISr100Raw = CHAISr100Raw / 1000.0
16303  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
16304  CHBISr100Raw = CHBISr100Raw / 1000.0
16305  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
16306  labelSIA.config(text = VString) # change displayed value
16307  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
16308  labelSIB.config(text = VString) # change displayed value
16309  #
16310  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
16311  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16312  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16313  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16314  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16315  CHA.mode = Mode.SIMV
16316  CHA.constant(-0.045)
16317  CHB.mode = Mode.SIMV
16318  CHB.constant(-0.045)
16319  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16320  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
16321  for index in range(1000): # calculate average
16322  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16323  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16324  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16325  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16326 
16327  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
16328  CHAISrN45Raw = CHAISrN45Raw / 1000.0
16329  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
16330  CHBISrN45Raw = CHBISrN45Raw / 1000.0
16331  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
16332  labelSIAN.config(text = VString) # change displayed value
16333  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
16334  labelSIBN.config(text = VString) # change displayed value
16335  # return all switches to open
16336  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
16337  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
16338  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16339  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16340  # Caculate voltage gain errors
16341  #
16342  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
16343  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
16344  #
16345  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
16346  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
16347  #
16348  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
16349  # print "calculated fixed 2.5 from CHA ", CHA2p5
16350  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
16351  # print "calculated fixed 2.5 from CHB ", CHB2p5
16352  #
16353  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
16354  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
16355  #
16356  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
16357  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
16358  #
16359  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
16360  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
16361  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
16362  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
16363  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
16364  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
16365  #
16366  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
16367  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
16368  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
16369  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
16370  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
16371  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
16372  # Write cal factors to file
16373  #
16374  CalFile.write('# Channel A, measure V\n')
16375  CalFile.write('</>\n')
16376  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
16377  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
16378  CalFile.write('<>\n')
16379  CalFile.write('\n')
16380  #
16381  CalFile.write('# Channel A, measure I\n')
16382  CalFile.write('</>\n')
16383  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
16384  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
16385  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
16386  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
16387  CalFile.write('<>\n')
16388  CalFile.write('\n')
16389  #
16390  CalFile.write('# Channel A, source V\n')
16391  CalFile.write('</>\n')
16392  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
16393  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
16394  CalFile.write('<>\n')
16395  CalFile.write('\n')
16396  #
16397  CalFile.write('# Channel A, source I\n')
16398  CalFile.write('</>\n')
16399  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
16400  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
16401  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
16402  CalFile.write('<>\n')
16403  CalFile.write('\n')
16404  #
16405  CalFile.write('# Channel B, measure V\n')
16406  CalFile.write('</>\n')
16407  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
16408  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
16409  CalFile.write('<>\n')
16410  CalFile.write('\n')
16411  #
16412  CalFile.write('# Channel B, measure I\n')
16413  CalFile.write('</>\n')
16414  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
16415  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
16416  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
16417  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
16418  CalFile.write('<>\n')
16419  CalFile.write('\n')
16420  #
16421  CalFile.write('# Channel B, source V\n')
16422  CalFile.write('</>\n')
16423  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
16424  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
16425  CalFile.write('<>\n')
16426  CalFile.write('\n')
16427  #
16428  CalFile.write('# Channel B source I\n')
16429  CalFile.write('</>\n')
16430  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
16431  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
16432  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
16433  CalFile.write('<>\n')
16434  #
16435  CalFile.close()
16436  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
16437  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
16438  devx.write_calibration(filename)
16439  #print "wrote new " , filename
16440  #
16441  # session.end()
16442  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
16443  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
16444  contloop = 0
16445  discontloop = 1
16446  # session.cancel()
16447  calwindow.destroy()
16448 #
16450  global cal, DevID, devx
16451 
16452  devidstr = DevID[17:31]
16453  filename = "calib" + devidstr + "test.txt"
16454  if os.path.isfile(filename):
16455  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
16456  return
16457  else:
16458  if askyesno("Continue?", "Continure with save calibration file?"): #, parent=calwindow):
16459  donothing()
16460  else:
16461  calwindow.destroy()
16462  return
16463  #
16464  CalFile = open(filename, "w")
16465  #
16466  # Write cal factors to file
16467  # [0]
16468  CalFile.write('# Channel A, measure V\n')
16469  CalFile.write('</>\n')
16470  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
16471  CHAgp = (5.0/cal[0][1])+cal[0][0]
16472  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16473  CalFile.write('<>\n')
16474  CalFile.write('\n')
16475  # [1]
16476  CalFile.write('# Channel A, measure I\n')
16477  CalFile.write('</>\n')
16478  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
16479  CHAgp = (0.1/cal[0][1])+cal[1][0]
16480  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16481  CHAgn = (-0.1/cal[0][2])+cal[1][0]
16482  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
16483  CalFile.write('<>\n')
16484  CalFile.write('\n')
16485  # [2]
16486  CalFile.write('# Channel A, source V\n')
16487  CalFile.write('</>\n')
16488  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
16489  CHAgp = (5.0/cal[2][1])+cal[2][0]
16490  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16491  CalFile.write('<>\n')
16492  CalFile.write('\n')
16493  # [3]
16494  CalFile.write('# Channel A, source I\n')
16495  CalFile.write('</>\n')
16496  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
16497  CHAgp = (0.1/cal[3][1])+cal[3][0]
16498  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16499  CHAgn = (-0.1/cal[3][2])+cal[3][0]
16500  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16501  CalFile.write('<>\n')
16502  CalFile.write('\n')
16503  # [4]
16504  CalFile.write('# Channel B, measure V\n')
16505  CalFile.write('</>\n')
16506  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
16507  CHAgp = (5.0/cal[4][1])+cal[4][0]
16508  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16509  CalFile.write('<>\n')
16510  CalFile.write('\n')
16511  # [5]
16512  CalFile.write('# Channel B, measure I\n')
16513  CalFile.write('</>\n')
16514  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
16515  CHAgp = (0.1/cal[5][1])+cal[5][0]
16516  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16517  CHAgn = (-0.1/cal[5][2])+cal[5][0]
16518  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16519  CalFile.write('<>\n')
16520  CalFile.write('\n')
16521  # [6]
16522  CalFile.write('# Channel B, source V\n')
16523  CalFile.write('</>\n')
16524  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
16525  CHAgp = (5.0/cal[6][1])+cal[6][0]
16526  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16527  CalFile.write('<>\n')
16528  CalFile.write('\n')
16529  # [7]
16530  CalFile.write('# Channel B source I\n')
16531  CalFile.write('</>\n')
16532  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
16533  CHAgp = (0.1/cal[7][1])+cal[7][0]
16534  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16535  CHAgn = (-0.1/cal[7][2])+cal[7][0]
16536  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16537  CalFile.write('<>\n')
16538  #
16539  CalFile.close()
16540 
16542 def SPIShiftOut(DValue):
16543  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
16544 
16545  binstr = bin(DValue)
16546  binlen = len(binstr)
16547  datastr = binstr[2:binlen]
16548  datalen = len(datastr)
16549  if datalen < 16:
16550  datastr = str.rjust(datastr , 16 , '0')
16551  datalen = len(datastr)
16552  i = 1
16553  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
16554  while i < datalen+1:
16555  # sending 0x50 = set to 0, 0x51 = set to 1
16556  D1code = 0x50 + int(datastr[i-1])
16557  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
16558  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
16559  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
16560  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
16561  i = i + 1
16562  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
16563 #
16564 def SetAD9833(temp):
16565  global FminEntry, HtMulEntry, MinigenFout, MinigenMode, etssrlab, EnableMinigenMode # , Fclk, Fout
16566  global Two28, mclk, EnableHSsampling, MinigenScreenStatus, ETSts, Two_X_Sample
16567 
16568  #
16569  if MinigenScreenStatus.get() == 0:
16570  #SRstring = "ET Sample Rate = " + str(SAMPLErate*MulX)
16571  #etssrlab.config(text=SRstring)
16572  return
16573  #
16574  if EnableMinigenMode == 2:
16575  MinigenMode.set(40)
16576  #
16577  try:
16578  FminE = float(eval(FminEntry.get()))*1000
16579  except:
16580  if EnableHSsampling > 0:
16581  FminEntry.delete(0,END)
16582  FminEntry.insert(0, FminE/1000)
16583  if MulX == 1:
16584  Fmin = FminE
16585  else:
16586  Fmin = FminE - (FminE/MulX)
16587  #
16588  MinigenFout.delete(0,"end")
16589  MinigenFout.insert(0,Fmin)
16590  #
16591  BSendMG()
16592 
16594 def BSendMG():
16595  global MinigenFclk, MinigenFout, MinigenMode
16596  global Two28, SCLKPort, SDATAPort, SLATCHPort
16597 
16598  DValue = 8192 + MinigenMode.get()
16599  SPIShiftOut(DValue)
16600  try:
16601  fout = float(eval(MinigenFout.get()))
16602  except:
16603  MinigenFout.delete(0,"end")
16604  MinigenFout.insert(0,100)
16605  try:
16606  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
16607  except:
16608  MingenFclk.delete(0,"end")
16609  MinigenFclk.insert(0,16)
16610  Freg = int((fout*Two28)/mclk)
16611  Foutstr = bin(Freg)
16612  Foutlen = len(Foutstr)
16613  datastr = Foutstr[2:Foutlen]
16614  datalen = len(datastr)
16615  if datalen < 28:
16616  datastr = str.rjust(datastr , 28 , '0')
16617  datalen = len(datastr)
16618  Fmsb = '0b01' + datastr[0:14]
16619  Flsb = '0b01' + datastr[14:]
16620  FValue = int(eval(Flsb))
16621  SPIShiftOut(FValue)
16622  FValue = int(eval(Fmsb))
16623  SPIShiftOut(FValue)
16624 
16627  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
16628  global SCLKPort, SDATAPort, SLATCHPort
16629  global GenericSerialStatus
16630  global PIO_0, PIO_1, PIO_2, PIO_3
16631 
16632  if GenericSerialStatus.get() == 1:
16633  GenericSerialStatus.set(0)
16635  if MinigenScreenStatus.get() == 0:
16636  MinigenScreenStatus.set(1)
16637  minigenwindow = Toplevel()
16638  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
16639  minigenwindow.resizable(FALSE,FALSE)
16640  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
16641  #
16642  MinigenMode = IntVar(0)
16643  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
16644  mgb1.grid(row=1, column=0, sticky=W)
16645  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
16646  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
16647  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
16648  mgb3.grid(row=2, column=0, sticky=W)
16649  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
16650  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
16651  f0lab = Label(minigenwindow, text="Mclk in MHz")
16652  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
16653  MinigenFclk = Entry(minigenwindow, width=5)
16654  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
16655  MinigenFclk.delete(0,"end")
16656  MinigenFclk.insert(0,16)
16657  f1lab = Label(minigenwindow, text="Output Freq")
16658  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
16659  MinigenFout = Entry(minigenwindow, width=8)
16660  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
16661  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
16662  MinigenFout.delete(0,"end")
16663  MinigenFout.insert(0,100)
16664  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
16665  bsn1.grid(row=5, column=0, sticky=W, pady=4)
16666  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
16667  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
16668  #
16669  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
16670  label3.grid(row=6, column=0, sticky=W)
16671  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
16672  sclk1.grid(row=6, column=1, sticky=W)
16673  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
16674  sclk2.grid(row=6, column=2, sticky=W)
16675  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
16676  sclk3.grid(row=6, column=3, sticky=W)
16677  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
16678  sclk4.grid(row=6, column=4, sticky=W)
16679  #
16680  label4 = Label(minigenwindow,text="SData PI/O Port ")
16681  label4.grid(row=7, column=0, sticky=W)
16682  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
16683  sdat1.grid(row=7, column=1, sticky=W)
16684  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
16685  sdat2.grid(row=7, column=2, sticky=W)
16686  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
16687  sdat3.grid(row=7, column=3, sticky=W)
16688  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
16689  sdat4.grid(row=7, column=4, sticky=W)
16690  #
16691  label5 = Label(minigenwindow,text="FSync PI/O Port ")
16692  label5.grid(row=8, column=0, sticky=W)
16693  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
16694  slth1.grid(row=8, column=1, sticky=W)
16695  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
16696  slth2.grid(row=8, column=2, sticky=W)
16697  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
16698  slth3.grid(row=8, column=3, sticky=W)
16699  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
16700  slth4.grid(row=8, column=4, sticky=W)
16701  #
16702 
16705  global minigenwindow, MinigenScreenStatus
16706 
16707  MinigenScreenStatus.set(0)
16708  minigenwindow.destroy()
16709 #
16710 def onMiniGenScroll(event):
16711  global ETSStatus, ETSDisp
16712 
16713  onTextScroll(event)
16714  BSendMG()
16715 
16717 def DA1ShiftOut(D1Value, D2Value):
16718  global devx
16719  global PIO_0, PIO_1, PIO_2, PIO_3
16720 
16721  binstr = bin(D1Value)
16722  binlen = len(binstr)
16723  data1str = binstr[2:binlen]
16724  datalen = len(data1str)
16725  if datalen < 16:
16726  data1str = str.rjust(data1str , 16 , '0')
16727  datalen = len(data1str)
16728  #
16729  binstr = bin(D2Value)
16730  binlen = len(binstr)
16731  data2str = binstr[2:binlen]
16732  datalen = len(data2str)
16733  if datalen < 16:
16734  data2str = str.rjust(data2str , 16 , '0')
16735  datalen = len(data2str)
16736  # sync --> PIO 0
16737  # D0 --> PIO 1
16738  # D1 --> PIO 2
16739  # SCLK --> PIO 3
16740  i = 1
16741 #
16742  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
16743  while i < datalen+1:
16744  # sending 0x50 = set to 0, 0x51 = set to 1
16745  D1code = 0x50 + int(data1str[i-1])
16746  D2code = 0x50 + int(data2str[i-1])
16747  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
16748  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
16749  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
16750  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
16751  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
16752  i = i + 1
16753  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
16754  #
16755 def BSendDA1():
16756  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
16757 
16758  try:
16759  RefValue = float(eval(REFEntry.get()))
16760  except:
16761  RefValue = 3.3
16762  try:
16763  D1Value = float(eval(DAC1Entry.get()))
16764  except:
16765  D1Value = 0.0129
16766  D1Code = int((D1Value/RefValue)*255)
16767  if D1Code > 255:
16768  D1Code = 255
16769  D1Code = D1Code + 0x2000
16770  try:
16771  D2Value = float(eval(DAC2Entry.get()))
16772  except:
16773  D2Value = 0.0129
16774  D2Code = int((D2Value/RefValue)*255)
16775  if D2Code > 255:
16776  D2Code = 255
16777  D2Code = D2Code + 0x2400
16778  try:
16779  D3Value = float(eval(DAC3Entry.get()))
16780  except:
16781  D3Value = 0.0129
16782  D3Code = int((D3Value/RefValue)*255)
16783  if D3Code > 255:
16784  D3Code = 255
16785  D3Code = D3Code + 0x2000
16786  try:
16787  D4Value = float(eval(DAC4Entry.get()))
16788  except:
16789  D4Value = 0.0129
16790  D4Code = int((D4Value/RefValue)*255)
16791  if D4Code > 255:
16792  D4Code = 255
16793  D4Code = D4Code + 0x2400
16794  #
16795  DA1ShiftOut(D1Code, D3Code)
16796  DA1ShiftOut(D2Code, D4Code)
16797 
16800  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
16801  global REFEntry, RevDate, SWRev
16802 
16803  if DA1ScreenStatus.get() == 0:
16804  DA1ScreenStatus.set(1)
16805  da1window = Toplevel()
16806  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
16807  da1window.resizable(FALSE,FALSE)
16808  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
16809 #
16810  d1lab = Label(da1window, text="DAC A1 output")
16811  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
16812  DAC1Entry = Entry(da1window, width=5)
16813  DAC1Entry.grid(row=0, column=1, sticky=W)
16814  DAC1Entry.delete(0,"end")
16815  DAC1Entry.insert(0,0)
16816  d2lab = Label(da1window, text="DAC B1 output")
16817  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
16818  DAC2Entry = Entry(da1window, width=5)
16819  DAC2Entry.grid(row=1, column=1, sticky=W)
16820  DAC2Entry.delete(0,"end")
16821  DAC2Entry.insert(0,0)
16822 
16823  d3lab = Label(da1window, text="DAC A2 output")
16824  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
16825  DAC3Entry = Entry(da1window, width=5)
16826  DAC3Entry.grid(row=2, column=1, sticky=W)
16827  DAC3Entry.delete(0,"end")
16828  DAC3Entry.insert(0,0)
16829 
16830  d4lab = Label(da1window, text="DAC B2 output")
16831  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
16832  DAC4Entry = Entry(da1window, width=5)
16833  DAC4Entry.grid(row=3, column=1, sticky=W)
16834  DAC4Entry.delete(0,"end")
16835  DAC4Entry.insert(0,0)
16836 
16837  d5lab = Label(da1window, text="Reference V")
16838  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
16839  REFEntry = Entry(da1window, width=5)
16840  REFEntry.grid(row=4, column=1, sticky=W)
16841  REFEntry.delete(0,"end")
16842  REFEntry.insert(0,3.3)
16843 
16844  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
16845  bsn1.grid(row=5, column=0, sticky=W)
16846  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
16847  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
16848 
16851  global da1window, DA1ScreenStatus
16852 
16853  DA1ScreenStatus.set(0)
16854  da1window.destroy()
16855 
16856 def DigPotShiftOut(DValue):
16857  global devx, SingleDualPot
16858  global PIO_0, PIO_1, PIO_2, PIO_3
16859 
16860  binstr = bin(DValue)
16861  binlen = len(binstr)
16862  datastr = binstr[2:binlen]
16863  datalen = len(datastr)
16864  if SingleDualPot.get() == 0: # send 10 bits of data
16865  if datalen < 10:
16866  datastr = str.rjust(datastr , 10 , '0')
16867  datalen = len(datastr)
16868  if SingleDualPot.get() == 1: # send 8 bits of data
16869  if datalen < 8:
16870  datastr = str.rjust(datastr , 8 , '0')
16871  datalen = len(datastr)
16872  if SingleDualPot.get() == 2: # send 8 bits of data
16873  if datalen < 8:
16874  datastr = str.rjust(datastr , 8 , '0')
16875  datalen = len(datastr)
16876  i = 1
16877  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
16878  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
16879  while i < datalen+1:
16880  # CS --> PIO 0
16881  # D0 --> PIO 1
16882  # D1 --> PIO 2
16883  # SCLK --> PIO 3
16884  D1code = 0x50 + int(datastr[i-1])
16885  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
16886  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
16887  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
16888  i = i + 1
16889  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
16890  #
16891 def DigPotSend(Temp):
16892  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
16893  global SingleDualPot
16894 
16895  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
16896  NumTaps = 255
16897  if SingleDualPot.get() == 2:
16898  NumTaps = 63
16899  try:
16900  DValue1 = DigPot1.get()
16901  if DValue1 > NumTaps:
16902  DValue1 = NumTaps
16903  except:
16904  DValue1 = 0
16905  try:
16906  DValue2 = DigPot2.get()
16907  if DValue2 > NumTaps:
16908  DValue2 = NumTaps
16909  except:
16910  DValue2 = 0
16911  try:
16912  DValue3 = DigPot3.get()
16913  if DValue3 > NumTaps:
16914  DValue3 = NumTaps
16915  except:
16916  DValue3 = 0
16917  try:
16918  DValue4 = DigPot4.get()
16919  if DValue4 > NumTaps:
16920  DValue4 = NumTaps
16921  except:
16922  DValue4 = 0
16923  if SendPot1.get() > 0:
16924  DigPotShiftOut(DValue1)
16925  if SendPot2.get() > 0:
16926  DigPotShiftOut(DValue2+NumTaps+1)
16927  if SendPot3.get() > 0:
16928  DigPotShiftOut(DValue3+2*(NumTaps+1))
16929  if SendPot4.get() > 0:
16930  DigPotShiftOut(DValue4+3*(NumTaps+1))
16931 
16933  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
16934 
16935  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
16936  DPotlabel.config(text="Enter number from 0 to 255")
16937  DigPot1.config(from_=0, to=255, length=256)
16938  DigPot2.config(from_=0, to=255, length=256)
16939  DigPot3.config(from_=0, to=255, length=256)
16940  DigPot4.config(from_=0, to=255, length=256)
16941  if SingleDualPot.get() == 2:
16942  DPotlabel.config(text="Enter number from 0 to 63")
16943  DigPot1.config(from_=0, to=63, length=64)
16944  DigPot2.config(from_=0, to=63, length=64)
16945  DigPot3.config(from_=0, to=63, length=64)
16946  DigPot4.config(from_=0, to=63, length=64)
16947 
16950  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
16951  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
16952  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
16953 
16954  if DigPotScreenStatus.get() == 0:
16955  DigPotScreenStatus.set(1)
16956  digpotwindow = Toplevel()
16957  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
16958  digpotwindow.resizable(FALSE,FALSE)
16959  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
16960  #
16961  SendPot1 = IntVar(0)
16962  SendPot1.set(1)
16963  SendPot2 = IntVar(0)
16964  SendPot2.set(1)
16965  SendPot3 = IntVar(0)
16966  SendPot3.set(0)
16967  SendPot4 = IntVar(0)
16968  SendPot4.set(0)
16969  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
16970  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
16971 
16972  SingleDualPot = IntVar(0)
16973  SingleDualPot.set(0)
16974  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
16975  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
16976  CompMenu["menu"] = CompMenu.menu
16977  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
16978  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
16979  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
16980  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
16981  lab1 = Checkbutton(digpotwindow,text="Pot 1", pady=0, variable=SendPot1)
16982  lab1.grid(row=2, column=0, sticky=W)
16983  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16984  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
16985  lab2 = Checkbutton(digpotwindow,text="Pot 2", pady=0, variable=SendPot2)
16986  lab2.grid(row=4, column=0, sticky=W)
16987  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16988  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
16989  lab3 = Checkbutton(digpotwindow,text="Pot 3", pady=0, variable=SendPot3)
16990  lab3.grid(row=6, column=0, sticky=W)
16991  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16992  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
16993  lab4 = Checkbutton(digpotwindow,text="Pot 4", pady=0, variable=SendPot4)
16994  lab4.grid(row=8, column=0, sticky=W)
16995  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16996  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
16997  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
16998  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
16999 
17001  global digpotwindow, DigPotScreenStatus
17002 
17003  DigPotScreenStatus.set(0)
17004  digpotwindow.destroy()
17005 
17006 def BSendGS():
17007  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
17008  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
17009 
17010  if AD5626SerialStatus.get() == 0:
17011  try:
17012  DValue = int(eval(DataBitsEntry.get()))
17013  if DValue < 0:
17014  DValue = 0
17015  except:
17016  DValue = 0
17017  try:
17018  NumBits = int(NumBitsEntry.get())
17019  if NumBits < 1:
17020  NumBits = 1
17021  except:
17022  NumBits = 8
17023  else:
17024  try:
17025  DValue = int(eval(AD5626Entry.get())*1000)
17026  if DValue < 0:
17027  DValue = 0
17028  AD5626Entry.delete(0,"end")
17029  AD5626Entry.insert(0,'0.000')
17030  if DValue > 4095:
17031  DValue = 4095
17032  AD5626Entry.delete(0,"end")
17033  AD5626Entry.insert(0,DValue/1000.0)
17034  except:
17035  DValue = 0
17036  AD5626Entry.delete(0,"end")
17037  AD5626Entry.insert(0,'0.000')
17038  NumBits = 12
17039  # print DValue
17040  binstr = bin(DValue)
17041  binlen = len(binstr)
17042  datastr = binstr[2:binlen]
17043  datalen = len(datastr)
17044  if datalen < NumBits:
17045  datastr = str.rjust(datastr , NumBits , '0')
17046  datalen = len(datastr)
17047  if SLatchPhase.get() == 0:
17048  LatchInt = 0x50
17049  LatchEnd = 0x51
17050  else:
17051  LatchInt = 0x51
17052  LatchEnd = 0x50
17053  if AD5626SerialStatus.get() > 0:
17054  LatchInt = 0x51
17055  LatchEnd = 0x50
17056  if SClockPhase.get() == 0:
17057  ClockInt = 0x50
17058  ClockEnd = 0x51
17059  else:
17060  ClockInt = 0x51
17061  ClockEnd = 0x50
17062  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
17063  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
17064  i = 1
17065  while i < datalen+1:
17066  if SerDirection.get() == 1: # for MSB first
17067  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
17068  else:
17069  D1code = 0x50 + int(datastr[i-1]) # for LSB first
17070  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
17071  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
17072  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
17073  i = i + 1
17074  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
17075  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
17076  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
17077  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
17078 
17081  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
17082  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
17083  global PIO_0, PIO_1, PIO_2, PIO_3
17084 
17085  if GenericSerialStatus.get() == 1:
17086  GenericSerialStatus.set(0)
17088  if AD5626SerialStatus.get() == 0:
17089  AD5626SerialStatus.set(1)
17090  ad5626window = Toplevel()
17091  ad5626window.title("AD5626 Output " + SWRev + RevDate)
17092  ad5626window.resizable(FALSE,FALSE)
17093  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
17094 #
17095  SLatchPhase = IntVar(0)
17096  SLatchPhase.set(0)
17097  SClockPhase = IntVar(0)
17098  SClockPhase.set(1)
17099  SerDirection = IntVar(0)
17100  SerDirection.set(0)
17101  #
17102  label2 = Label(ad5626window,text="Enter Output Volts")
17103  label2.grid(row=1, column=0, columnspan=1, sticky=W)
17104  AD5626Entry = Entry(ad5626window, width=10)
17105  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
17106  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
17107  AD5626Entry.delete(0,"end")
17108  AD5626Entry.insert(0,'0.000')
17109  #
17110  label3 = Label(ad5626window,text="SCLK PI/O Port ")
17111  label3.grid(row=2, column=0, columnspan=1, sticky=W)
17112  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
17113  sclk1.grid(row=2, column=1, sticky=W)
17114  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
17115  sclk2.grid(row=2, column=2, sticky=W)
17116  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
17117  sclk3.grid(row=2, column=3, sticky=W)
17118  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
17119  sclk4.grid(row=2, column=4, sticky=W)
17120  #
17121  label4 = Label(ad5626window,text="SData PI/O Port ")
17122  label4.grid(row=3, column=0, columnspan=1, sticky=W)
17123  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
17124  sdat1.grid(row=3, column=1, sticky=W)
17125  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
17126  sdat2.grid(row=3, column=2, sticky=W)
17127  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
17128  sdat3.grid(row=3, column=3, sticky=W)
17129  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
17130  sdat4.grid(row=3, column=4, sticky=W)
17131  #
17132  label5 = Label(ad5626window,text="Latch PI/O Port ")
17133  label5.grid(row=4, column=0, columnspan=1, sticky=W)
17134  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
17135  slth1.grid(row=4, column=1, sticky=W)
17136  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
17137  slth2.grid(row=4, column=2, sticky=W)
17138  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
17139  slth3.grid(row=4, column=3, sticky=W)
17140  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
17141  slth4.grid(row=4, column=4, sticky=W)
17142  #
17143  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
17144  bsn1.grid(row=5, column=0, sticky=W)
17145  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
17146  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
17147 #
17148 def onAD5626Scroll(event):
17149  onTextScroll(event)
17150  BSendGS()
17151 
17153  global ad5626window, AD5626SerialStatus
17154 
17155  AD5626SerialStatus.set(0)
17156  ad5626window.destroy()
17157 
17159  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
17160  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
17161  global PIO_0, PIO_1, PIO_2, PIO_3
17162 
17163  if GenericSerialStatus.get() == 0:
17164  GenericSerialStatus.set(1)
17165  serialwindow = Toplevel()
17166  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
17167  serialwindow.resizable(FALSE,FALSE)
17168  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
17169  #
17170  SCLKPort = IntVar(0)
17171  SCLKPort.set(PIO_2)
17172  SDATAPort = IntVar(0)
17173  SDATAPort.set(PIO_1)
17174  SLATCHPort = IntVar(0)
17175  SLATCHPort.set(PIO_0)
17176  SLatchPhase = IntVar(0)
17177  SClockPhase = IntVar(0)
17178  SerDirection = IntVar(0)
17179  label = Label(serialwindow,text="Enter number of Bits")
17180  label.grid(row=1, column=0, columnspan=2, sticky=W)
17181  NumBitsEntry = Entry(serialwindow, width=3)
17182  NumBitsEntry.grid(row=1, column=2, sticky=W)
17183  NumBitsEntry.delete(0,"end")
17184  NumBitsEntry.insert(0,8)
17185  #
17186  label2 = Label(serialwindow,text="Enter Data Word")
17187  label2.grid(row=2, column=0, columnspan=1, sticky=W)
17188  DataBitsEntry = Entry(serialwindow, width=10)
17189  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
17190  DataBitsEntry.delete(0,"end")
17191  DataBitsEntry.insert(0,0)
17192  #
17193  label3 = Label(serialwindow,text="SCLK PI/O Port ")
17194  label3.grid(row=3, column=0, columnspan=1, sticky=W)
17195  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
17196  sclk1.grid(row=3, column=1, sticky=W)
17197  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
17198  sclk2.grid(row=3, column=2, sticky=W)
17199  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
17200  sclk3.grid(row=3, column=3, sticky=W)
17201  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
17202  sclk4.grid(row=3, column=4, sticky=W)
17203  #
17204  label4 = Label(serialwindow,text="SData PI/O Port ")
17205  label4.grid(row=4, column=0, columnspan=1, sticky=W)
17206  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
17207  sdat1.grid(row=4, column=1, sticky=W)
17208  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
17209  sdat2.grid(row=4, column=2, sticky=W)
17210  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
17211  sdat3.grid(row=4, column=3, sticky=W)
17212  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
17213  sdat4.grid(row=4, column=4, sticky=W)
17214  #
17215  label5 = Label(serialwindow,text="Latch PI/O Port ")
17216  label5.grid(row=5, column=0, columnspan=1, sticky=W)
17217  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
17218  slth1.grid(row=5, column=1, sticky=W)
17219  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
17220  slth2.grid(row=5, column=2, sticky=W)
17221  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
17222  slth3.grid(row=5, column=3, sticky=W)
17223  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
17224  slth4.grid(row=5, column=4, sticky=W)
17225  #
17226  label6 = Label(serialwindow,text="Latch Phase ")
17227  label6.grid(row=6, column=0, columnspan=1, sticky=W)
17228  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
17229  sph1.grid(row=6, column=1, sticky=W)
17230  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
17231  sph2.grid(row=6, column=2, sticky=W)
17232  #
17233  label7 = Label(serialwindow,text="Clock Phase ")
17234  label7.grid(row=7, column=0, columnspan=1, sticky=W)
17235  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
17236  sph7.grid(row=7, column=1, sticky=W)
17237  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
17238  sph8.grid(row=7, column=2, sticky=W)
17239  #
17240  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
17241  sdir1.grid(row=8, column=0, sticky=W)
17242  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
17243  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
17244 
17245  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
17246  bsn1.grid(row=9, column=0, sticky=W)
17247  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
17248  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
17249 
17251  global serialwindow, GenericSerialStatus
17252 
17253  GenericSerialStatus.set(0)
17254  serialwindow.destroy()
17255 
17258  global digfltwindow, DigFiltStatus, RevDate, SWRev
17259  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
17260  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
17261 
17262  if DigFiltStatus.get() == 0:
17263  DigFiltStatus.set(1)
17264  digfltwindow = Toplevel()
17265  digfltwindow.title("Digital Filter " + SWRev + RevDate)
17266  digfltwindow.resizable(FALSE,FALSE)
17267  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
17268  #
17269  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
17270  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
17271  frame2.pack(side=LEFT, expand=1, fill=X)
17272  frame3.pack(side=LEFT, expand=1, fill=X)
17273  #
17274  digfilta = Frame( frame2 )
17275  digfilta.pack(side=TOP)
17276  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
17277  #titlab.grid(row=0, column=0, sticky=W)
17278  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
17279  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
17280  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
17281  lab3.grid(row=1, column=0, sticky=W)
17282  BCALenEntry = Entry(digfilta, width=3)
17283  BCALenEntry.bind("<Return>", onRetDigFiltA)
17284  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
17285  # BCALenEntry.bind('<Key>', onTextKey)
17286  BCALenEntry.grid(row=1, column=1, sticky=W)
17287  BCALenEntry.delete(0,"end")
17288  BCALenEntry.insert(0,2)
17289  bcalab = Label(digfilta, text="Length")
17290  bcalab.grid(row=1, column=2, sticky=W)
17291  DifFiltALength = Label(digfilta, text="Length = 0 ")
17292  DifFiltALength.grid(row=2, column=0, sticky=W)
17293  DifFiltAFile = Label(digfilta, text="File Name, none ")
17294  DifFiltAFile.grid(row=3, column=0, sticky=W)
17295  cald = Button(digfilta, text='Load CH A Filter Coef', command=BLoadDFiltA)
17296  cald.grid(row=4, column=0, columnspan=2, sticky=W)
17297  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
17298  camath.grid(row=5, column=0, columnspan=2, sticky=W)
17299  #
17300  digfiltb = Frame( frame3 )
17301  digfiltb.pack(side=TOP)
17302  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
17303  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
17304  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
17305  lab4.grid(row=1, column=0, sticky=W)
17306  BCBLenEntry = Entry(digfiltb, width=3)
17307  BCBLenEntry.bind("<Return>", onRetDigFiltB)
17308  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
17309  # BCALenEntry.bind('<Key>', onTextKey)
17310  BCBLenEntry.grid(row=1, column=1, sticky=W)
17311  BCBLenEntry.delete(0,"end")
17312  BCBLenEntry.insert(0,2)
17313  bcblab = Label(digfiltb, text="Length")
17314  bcblab.grid(row=1, column=2, sticky=W)
17315  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
17316  DifFiltBLength.grid(row=2, column=0, sticky=W)
17317  DifFiltBFile = Label(digfiltb,text="File Name, none ")
17318  DifFiltBFile.grid(row=3, column=0, sticky=W)
17319  camath.grid(row=8, column=0, sticky=W)
17320  cbld = Button(digfiltb, text='Load CH B Filter Coef', command=BLoadDFiltB)
17321  cbld.grid(row=4, column=0, sticky=W)
17322  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
17323  cbmath.grid(row=5, column=0, sticky=W)
17324  dismissdfbutton = Button(digfiltb, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
17325  dismissdfbutton.grid(row=6, column=0, columnspan=1, sticky=W)
17326  #
17327 def onRetDigFiltA(event):
17328  BuildBoxCarA()
17329 
17330 def onDigFiltAScroll(event):
17331  onTextScroll(event)
17332  BuildBoxCarA()
17333 
17335  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
17336 
17337  if DigFiltABoxCar.get() == 0:
17338  return
17339 
17340  FLength = int(BCALenEntry.get())
17341  if FLength < 2:
17342  return
17343 
17344  DFiltACoef = [] # empty coef array
17345 
17346  for n in range(FLength):
17347  DFiltACoef.append(float(1.0/FLength))
17348 
17349  DFiltACoef = numpy.array(DFiltACoef)
17350  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17351 
17352 def onRetDigFiltB(event):
17353  BuildBoxCarB()
17354 
17355 def onDigFiltBScroll(event):
17356  onTextScroll(event)
17357  BuildBoxCarB()
17358 
17360  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
17361 
17362  if DigFiltBBoxCar.get() == 0:
17363  return
17364 
17365  FLength = int(BCBLenEntry.get())
17366  if FLength < 2:
17367  return
17368 
17369  DFiltBCoef = [] # empty coef array
17370 
17371  for n in range(FLength):
17372  DFiltBCoef.append(float(1.0/FLength))
17373 
17374  DFiltBCoef = numpy.array(DFiltBCoef)
17375  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17376 
17378  global digfltwindow, DigFiltStatus
17379 
17380  DigFiltStatus.set(0)
17381  digfltwindow.destroy()
17382 
17384  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
17385 
17386 # Read values from CVS file
17387  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
17388  try:
17389  CSVFile = open(filename)
17390  csv_f = csv.reader(CSVFile)
17391  except:
17392  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
17393  return
17394  DFiltACoef = []
17395 
17396  for row in csv_f:
17397  try:
17398  DFiltACoef.append(float(row[0]))
17399  except:
17400  print( 'skipping non-numeric row')
17401  DFiltACoef = numpy.array(DFiltACoef)
17402  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17403  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
17404  CSVFile.close()
17405 #
17407  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
17408 
17409  TempString = DigFilterAString
17410  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
17411  if (DigFilterAString == None): # If Cancel pressed, then None
17412  DigFilterAString = TempString
17413  return
17414  DFiltACoef = eval(DigFilterAString)
17415  DFiltACoef = numpy.array(DFiltACoef)
17416  coefsum = numpy.sum(DFiltACoef)
17417  DFiltACoef = DFiltACoef / coefsum
17418  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17419  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
17420 
17422  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
17423 
17424 # Read values from CVS file
17425  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
17426  try:
17427  CSVFile = open(filename)
17428  csv_f = csv.reader(CSVFile)
17429  except:
17430  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
17431  return
17432  DFiltBCoef = []
17433 
17434  for row in csv_f:
17435  try:
17436  DFiltBCoef.append(float(row[0]))
17437  except:
17438  print( 'skipping non-numeric row')
17439  DFiltBCoef = numpy.array(DFiltBCoef)
17440  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17441  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
17442  CSVFile.close()
17443 #
17445  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
17446 
17447  TempString = DigFilterBString
17448  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
17449  if (DigFilterBString == None): # If Cancel pressed, then None
17450  DigFilterBString = TempString
17451  return
17452  DFiltBCoef = eval(DigFilterBString)
17453  DFiltBCoef = numpy.array(DFiltBCoef)
17454  coefsum = numpy.sum(DFiltBCoef)
17455  DFiltBCoef = DFiltBCoef / coefsum
17456  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17457  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
17458 #
17460  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
17461 
17462  if CommandStatus.get() == 0:
17463  CommandStatus.set(1)
17464  commandwindow = Toplevel()
17465  commandwindow.title("Command Line " + SWRev + RevDate)
17466  commandwindow.resizable(FALSE,FALSE)
17467  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
17468  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
17469  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
17470  cl1 = Label(commandwindow,text="Last command:")
17471  cl1.grid(row=1, column=0, sticky=W)
17472  LastCommand = Label(commandwindow,text=" ")
17473  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
17474  ExecString = Entry(commandwindow, width=40)
17475  ExecString.bind("<Return>", RExecuteFromString)
17476  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
17477  ExecString.delete(0,"end")
17478  ExecString.insert(0,"global ; ")
17479  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
17480  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
17481  #
17482  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
17483  dismissclbutton.grid(row=4, column=1, sticky=W, pady=7)
17484 
17486  global commandwindow, CommandStatus
17487 
17488  CommandStatus.set(0)
17489  commandwindow.destroy()
17490 
17492 
17494 
17495 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
17496  global ExecString, LastCommand
17497 
17498  try:
17499  exec( ExecString.get() )
17500  LastCommand.config(text = ExecString.get() ) # change displayed last command
17501  except:
17502  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
17503  return()
17504 #
17505 def CAresize(event):
17506  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
17507 
17508  XOL = FontSize * 7
17509  CANVASwidth = event.width - 4
17510  CANVASheight = event.height - 4
17511  GRW = CANVASwidth - (2 * X0L) # new grid width
17512  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
17513  UpdateTimeAll()
17514 #
17516  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
17517  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
17518  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
17519  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
17520  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
17521  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
17522 
17523  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
17524  ChaValue1.config(text = ValueText)
17525  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
17526  ChaValue2.config(text = ValueText)
17527  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
17528  ChaValue3.config(text = ValueText)
17529  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
17530  ChaValue4.config(text = ValueText)
17531  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
17532  ChaValue5.config(text = ValueText)
17533  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
17534  ChaValue6.config(text = ValueText)
17535  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
17536  ChbValue1.config(text = ValueText)
17537  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
17538  ChbValue2.config(text = ValueText)
17539  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
17540  ChbValue3.config(text = ValueText)
17541  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
17542  ChbValue4.config(text = ValueText)
17543  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
17544  ChbValue5.config(text = ValueText)
17545  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
17546  ChbValue6.config(text = ValueText)
17547 #
17549  global measurewindow, MeasureStatus, RevDate, SWRev
17550  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
17551  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
17552  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
17553  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
17554  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
17555  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
17556 
17557  if MeasureStatus.get() == 0:
17558  MeasureStatus.set(1)
17559  measurewindow = Toplevel()
17560  measurewindow.title("Measurements " + SWRev + RevDate)
17561  measurewindow.resizable(FALSE,FALSE)
17562  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
17563  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
17564  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
17565  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
17566  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
17567  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17568  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
17569  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
17570  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
17571  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17572  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
17573  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
17574  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
17575  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17576  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
17577  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
17578  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
17579  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17580  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
17581  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
17582  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
17583  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17584  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
17585  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
17586  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
17587  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17588  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
17589  #
17590  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
17591  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
17592  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17593  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
17594  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
17595  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
17596  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17597  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
17598  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
17599  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
17600  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17601  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
17602  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
17603  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
17604  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17605  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
17606  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
17607  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
17608  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17609  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
17610  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
17611  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
17612  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17613  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
17614 #
17616  global measurewindow, MeasureStatus
17617 
17618  MeasureStatus.set(0)
17619  measurewindow.destroy()
17620 #
17622  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
17623  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
17624 
17625  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
17626  if BoardStatus.get() == 0:
17627  BoardStatus.set(1)
17628  boardwindow = Toplevel()
17629  boardwindow.title("Select Board " + RevDate)
17630  boardwindow.resizable(FALSE,FALSE)
17631  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
17632  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
17633  toplab.pack(side=TOP)
17634  for idx, devx in enumerate(session.devices):
17635  BrdText = "Board # " + str(idx)
17636  if idx == 0:
17637  devx.set_led(0b010) # LED.green
17638  FWRevOne = float(devx.fwver)
17639  HWRevOne = devx.hwver
17640  dev0 = devx #session.devices[0]
17641  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
17642  elif idx == 1:
17643  devx.set_led(0b100) # LED.blue,
17644  FWRevTwo = float(devx.fwver)
17645  HWRevTwo = devx.hwver
17646  dev1 = devx #session.devices[1]
17647  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
17648  elif idx == 2:
17649  devx.set_led(0b001) # LED.red,
17650  FWRevThree = float(devx.fwver)
17651  HWRevThree = devx.hwver
17652  dev2 = devx #session.devices[2]
17653  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
17654  else:
17655  dev3 = session.devices[3]
17656  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
17657  brd.pack(side=TOP)
17658  else:
17659  devx = session.devices[0]
17660  # devx.ignore_dataflow = True
17661  #devx.set_led(0b010) # LED.green
17662  try:
17663  FWRevOne = float(devx.fwver)
17664  HWRevOne = devx.hwver
17665  except:
17666  FWRevOne = "Before 2.06"
17667  HWRevOne = "?"
17668  dev0 = session.devices[0]
17669 #
17671  global boardwindow, BoardStatus
17672 
17673  BoardStatus.set(0)
17674  boardwindow.destroy()
17675 #
17677  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
17678  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
17679 
17680  if DevID == "No Device" or DevID == "m1k":
17681  #print("Request sample rate: " + str(SAMPLErate))
17682  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
17683  # session.add_all()
17684  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
17685  if not session.devices:
17686  print( 'No Device plugged IN!')
17687  DevID = "No Device"
17688  FWRevOne = 0.0
17689  bcon.configure(text="Recon", style="RConn.TButton")
17690  return
17691  session.configure(sample_rate=SAMPLErate)
17692  # print("Session sample rate: " + str(session.sample_rate))
17693  MakeBoardScreen()
17694  SelectBoard()
17695  bcon.configure(text="Conn", style="GConn.TButton")
17696  devx.set_adc_mux(0)
17697  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
17698  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
17699 
17703  session.start(0)
17704 #
17706  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
17707  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
17708  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
17709 
17710  if RUNstatus.get() == 1:
17711  BStop()
17712  print( "STOP")
17713 
17714  if BrdSel.get() == 0:
17715  try:
17716  session.remove(dev1)
17717  print( "Removing dev1")
17718  except:
17719  print( "Skipping dev1")
17720  try:
17721  session.remove(dev2)
17722  print( "Removing dev2")
17723  except:
17724  print( "Skipping dev2")
17725  session.add(dev0)
17726  devx = dev0
17727  #session.add(devx)
17728  if BrdSel.get() == 1:
17729  try:
17730  session.remove(dev0)
17731  print( "Removing dev0")
17732  except:
17733  print( "Skipping dev0")
17734  try:
17735  session.remove(dev2)
17736  print( "Removing dev2")
17737  except:
17738  print( "Skipping dev2")
17739  session.add(dev1)
17740  devx = dev1
17741  #session.add(devx)
17742  DevID = devx.serial
17743  print( DevID)
17744  FWRevOne = float(devx.fwver)
17745  HWRevOne = str(devx.hwver)
17746  print( FWRevOne, HWRevOne)
17747  # print("Session sample rate: " + str(session.sample_rate))
17748 
17749  if IgnoreFirmwareCheck == 0:
17750  if FWRevOne < 2.17:
17751  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
17752  UpdateFirmware()
17753  cal = devx.calibration
17754  CHA = devx.channels['A'] # Open CHA
17755  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
17756  CHB = devx.channels['B'] # Open CHB
17757  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
17758  #
17759  # if session.continuous == 0:
17760  #session.start(0)
17761 
17770  devx.set_adc_mux(0)
17771  if devx.hwver == "F":
17772  print( "Rev F Board I/O ports set")
17773  PIO_0 = 28
17774  PIO_1 = 29
17775  PIO_2 = 47
17776  PIO_3 = 3
17777  PIO_4 = 4
17778  PIO_5 = 5
17779  PIO_6 = 6
17780  PIO_7 = 7
17781  else:
17782  PIO_0 = 0
17783  PIO_1 = 1
17784  PIO_2 = 2
17785  PIO_3 = 3
17786  PIO_4 = 4
17787  PIO_5 = 5
17788  PIO_6 = 6
17789  PIO_7 = 7
17790 #
17791  SDATAPort.set(PIO_1)
17792  SCLKPort.set(PIO_2)
17793  SLATCHPort.set(PIO_0)
17794 
17796  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
17797  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
17798  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
17799 
17800  if SampleRateStatus.get() == 0:
17801  SampleRateStatus.set(1)
17802  SampleRatewindow = Toplevel()
17803  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
17804  SampleRatewindow.resizable(FALSE,FALSE)
17805  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
17806  frame1 = Frame(SampleRatewindow, borderwidth=5, relief=RIDGE)
17807  frame1.grid(row=0, column=0, sticky=W)
17808  #
17809  BaseRATE = Frame( frame1 )
17810  BaseRATE.grid(row=0, column=0, sticky=W)
17811  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
17812  baseratelab.pack(side=LEFT)
17813  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
17814  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
17815  BaseRatesb.bind("<Return>", onRetSrate)
17816  BaseRatesb.pack(side=LEFT)
17817  BaseRatesb.delete(0,"end")
17818  BaseRatesb.insert(0,BaseSampleRate)
17819  #
17820  nextrow = 2
17821  if FWRevOne > 2.16:
17822  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
17823  twoX.grid(row=1, column=0, sticky=W)
17824  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
17825  muxlab1.grid(row=2, column=0, sticky=W)
17826  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
17827  AltSweep.grid(row=3, column=0, sticky=W)
17828  chabuttons = Frame( frame1 )
17829  chabuttons.grid(row=4, column=0, sticky=W)
17830  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
17831  muxrb1.pack(side=LEFT)
17832  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
17833  muxrb2.pack(side=LEFT)
17834  chcbuttons = Frame( frame1 )
17835  chcbuttons.grid(row=5, column=0, sticky=W)
17836  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
17837  muxrb5.pack(side=LEFT)
17838  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
17839  muxrb6.pack(side=LEFT)
17840  nextrow = 6
17841  if DeBugMode == 1:
17842  chbbuttons = Frame( frame1 )
17843  chbbuttons.grid(row=nextrow, column=0, sticky=W)
17844  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
17845  muxrb3.pack(side=LEFT)
17846  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
17847  muxrb4.pack(side=LEFT)
17848  nextrow = nextrow + 1
17849  #
17850  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
17851  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
17852 #
17854  global SampleRatewindow, SampleRateStatus
17855 
17856  SampleRateStatus.set(0)
17857  SampleRatewindow.destroy()
17858 #
17859 #
17860 def onSrateScroll(event):
17861 
17862  #onTextScroll
17863  onSpinBoxScroll(event)
17864  SetSampleRate()
17865 #
17866 def onRetSrate(event):
17867 
17868  SetSampleRate()
17869 #
17871  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
17872  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
17873 
17874  #
17875  WasRunning = 0
17876  if (RUNstatus.get() == 1):
17877  WasRunning = 1
17878  BStop() # Force Stop loop if running
17879  try:
17880  NewRate = int(BaseRatesb.get())
17881  if NewRate <= 100000: # rate has to be less than or equal to 100,000
17882  BaseSampleRate = NewRate
17883  else:
17884  BaseSampleRate = 100000
17885  BaseRatesb.delete(0,"end")
17886  BaseRatesb.insert(0,BaseSampleRate)
17887  SAMPLErate = BaseSampleRate # Scope sample rate
17888  except:
17889  donothing()
17890  session.configure(sample_rate=BaseSampleRate)
17891  BaseSampleRate = session.sample_rate
17892  #print("Session sample rate: " + str(session.sample_rate), BaseSampleRate)
17893  SAMPLErate = BaseSampleRate # Scope sample rate
17894  #print("Session sample rate: " + str(session.sample_rate), SAMPLErate)
17895  AWGSAMPLErate = BaseSampleRate
17896  if ETSStatus.get() > 0:
17897  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
17898  rtsrlab.config(text=SRstring)
17899  ETSUpdate()
17900  BaseRatesb.delete(0,"end")
17901  BaseRatesb.insert(0,BaseSampleRate)
17902  ReMakeAWGwaves() # remake AWG waveforms for new rate
17903  if (WasRunning == 1):
17904  WasRunning = 0
17905  BStart() # restart loop if was running
17906 #
17907 def onStopfreqScroll(event):
17908  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
17909 
17910  onTextScroll(event)
17911  try:
17912  StopFrequency = float(StopFreqEntry.get())
17913  except:
17914  StopFreqEntry.delete(0,"end")
17915  StopFreqEntry.insert(0,50000)
17916  StopFrequency = 50000
17917  if FWRevOne > 2.16:
17918  if StopFrequency >= 50000:
17919  Two_X_Sample.set(1)
17920  ADC_Mux_Mode.set(0)
17921  SetADC_Mux()
17922  else:
17923  Two_X_Sample.set(0)
17924  ADC_Mux_Mode.set(0)
17925  SetADC_Mux()
17926 #
17927 def onStopBodeScroll(event):
17928  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
17929 
17930  onTextScroll(event)
17931  try:
17932  StopFrequency = float(StopBodeEntry.get())
17933  except:
17934  StopBodeEntry.delete(0,"end")
17935  StopBodeEntry.insert(0,20000)
17936  StopFrequency = 20000
17937  if FWRevOne > 2.16:
17938  if StopFrequency >= 20000:
17939  Two_X_Sample.set(1)
17940  ADC_Mux_Mode.set(0)
17941  SetADC_Mux()
17942  else:
17943  Two_X_Sample.set(0)
17944  ADC_Mux_Mode.set(0)
17945  SetADC_Mux()
17946 #
17948  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
17949  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
17950 
17951  if Two_X_Sample.get() == 1:
17952  if ADC_Mux_Mode.get() == 0: # VA and VB
17953  devx.set_adc_mux(1)
17954  elif ADC_Mux_Mode.get() == 1: # IA and IB
17955  devx.set_adc_mux(2)
17956  elif ADC_Mux_Mode.get() == 2: # VA and IB
17957  # cycle trhough default mux values as starting point
17958  devx.set_adc_mux(2)
17959  # now set new mux values
17960  devx.set_adc_mux(7)
17961  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
17962  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
17963  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
17964  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
17965  time.sleep(0.1)
17966  elif ADC_Mux_Mode.get() == 3: # VB and IA
17967  # cycle trhough default mux values as starting point
17968  # now set new mux values
17969  devx.set_adc_mux(7)
17970  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
17971  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
17972  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
17973  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
17974  time.sleep(0.1)
17975  elif ADC_Mux_Mode.get() == 4: # VA and IA
17976  # now set new mux values
17977  devx.set_adc_mux(4)
17978  elif ADC_Mux_Mode.get() == 5: # VB and IB
17979  # now set new mux values
17980  devx.set_adc_mux(5)
17981  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
17982  else:
17983  devx.set_adc_mux(0)
17984  SAMPLErate = BaseSampleRate
17985 #
17987  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
17988 
17989  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17990  ADC_Mux_Mode.set(0) # All four traces
17991  Alternate_Sweep_Mode.set(1)
17992  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
17993  ADC_Mux_Mode.set(0) # three traces
17994  Alternate_Sweep_Mode.set(1)
17995  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
17996  ADC_Mux_Mode.set(0) # three traces
17997  Alternate_Sweep_Mode.set(1)
17998  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17999  ADC_Mux_Mode.set(0) # three traces
18000  Alternate_Sweep_Mode.set(1)
18001  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
18002  ADC_Mux_Mode.set(0) # three traces
18003  Alternate_Sweep_Mode.set(1)
18004  #
18005  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
18006  ADC_Mux_Mode.set(1) # IA and IB
18007  Alternate_Sweep_Mode.set(0)
18008  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
18009  ADC_Mux_Mode.set(1) # just IA
18010  Alternate_Sweep_Mode.set(0)
18011  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
18012  ADC_Mux_Mode.set(1) # just IB
18013  Alternate_Sweep_Mode.set(0)
18014  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
18015  ADC_Mux_Mode.set(4) # VA and IA
18016  Alternate_Sweep_Mode.set(0)
18017  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
18018  ADC_Mux_Mode.set(5) # VB and IB
18019  Alternate_Sweep_Mode.set(0)
18020  else:
18021  ADC_Mux_Mode.set(0)
18022  Alternate_Sweep_Mode.set(0)
18023  SetADC_Mux()
18024  UpdateTimeTrace()
18025 #
18027  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
18028  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
18029 
18030  RUNstatus.set(0)
18031  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
18032  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
18033  print( filename)
18034  #print DevID
18035  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
18036  try:
18037  print( "Cancel current session.")
18038  session.cancel()
18039  print( session.cancelled)
18040  session.end()
18041  print( "Waiting 5...")
18042  time.sleep(5)
18043  print( "Put board in Samba mode and flash firmware.")
18044  session.flash_firmware(filename)
18045  except:
18046  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
18047 
18055  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
18056  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
18057  Bcloseexit()
18058 
18068  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
18069  global CHATestVEntry, CHATestREntry, SWRev, AWGSync, OnBoardRes
18070 
18071  if OhmStatus.get() == 0:
18072  AWGSync.set(1)
18073  OhmStatus.set(1)
18074  OhmDisp.set(1)
18075  OhmCheckBox()
18076  ohmwindow = Toplevel()
18077  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
18078  ohmwindow.resizable(FALSE,FALSE)
18079  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
18080  frame1 = Frame(ohmwindow, borderwidth=5, relief=RIDGE)
18081  frame1.grid(row=0, column=0, sticky=W)
18082  #
18083  buttons = Frame( frame1 )
18084  buttons.grid(row=0, column=0, sticky=W)
18085  rb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
18086  rb2.pack(side=LEFT)
18087  rb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
18088  rb1.pack(side=LEFT)
18089  #
18090  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
18091  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
18092  OhmA0.config(text = "0.000 Ohms")
18093 
18094  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
18095  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
18096  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
18097  #
18098  TestVA = Frame( frame1 )
18099  TestVA.grid(row=3, column=0, sticky=W)
18100  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
18101  chatestvlab.pack(side=LEFT)
18102  CHATestVEntry = Entry(TestVA, width=6) #
18103  CHATestVEntry.pack(side=LEFT)
18104  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
18105  CHATestVEntry.delete(0,"end")
18106  CHATestVEntry.insert(0,5.0)
18107  #
18108  RMode = IntVar(0)
18109  RMode.set(1)
18110  TestMode = Frame( frame1 )
18111  TestMode.grid(row=4, column=0, sticky=W)
18112  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
18113  modelab.pack(side=LEFT)
18114  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
18115  rm3.pack(side=LEFT)
18116  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
18117  rm4.pack(side=LEFT)
18118  #
18119  TestRA = Frame( frame1 )
18120  TestRA.grid(row=5, column=0, sticky=W)
18121  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
18122  chatestrlab.pack(side=LEFT)
18123  CHATestREntry = Entry(TestRA, width=6) #
18124  CHATestREntry.pack(side=LEFT)
18125  CHATestREntry.bind('<MouseWheel>', onTextScroll)
18126  CHATestREntry.delete(0,"end")
18127  CHATestREntry.insert(0,OnBoardRes)
18128  #
18129  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
18130  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
18131 #
18133  global ohmwindow, OhmStatus, OhmDisp
18134 
18135  OhmStatus.set(0)
18136  OhmDisp.set(0)
18137  OhmCheckBox()
18138  ohmwindow.destroy()
18139 #
18141  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
18142  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
18143  global MinigenScreenStatus, DeBugMode
18144 
18145  #
18146  if ETSStatus.get() == 0:
18147  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
18148  ETSStatus.set(1)
18149  ETSDisp.set(0)
18150  etswindow = Toplevel()
18151  etswindow.title("ETS Controls " + SWRev + RevDate)
18152  etswindow.resizable(FALSE,FALSE)
18153  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
18154  frame1 = Frame(etswindow, borderwidth=5, relief=RIDGE)
18155  frame1.grid(row=0, column=0, sticky=W)
18156  # Sampling controls Widgets
18157  SRstring = "RT Sample Rate = " + str(SAMPLErate)
18158  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
18159  rtsrlab.grid(row=1, column=0, sticky=W)
18160  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
18161  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
18162  etssrlab.grid(row=2, column=0, sticky=W)
18163  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
18164  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
18165  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
18166  enb1.grid(row=4, column=0, sticky=W)
18167  #
18168  Divx = Frame( frame1 )
18169  Divx.grid(row=5, column=0, sticky=W)
18170  DivXEntry = Entry(Divx, width=6)
18171  DivXEntry.bind('<MouseWheel>', ETSscroll)
18172  DivXEntry.pack(side=RIGHT)
18173  DivXEntry.delete(0,"end")
18174  DivXEntry.insert(0,2)
18175  divxlab = Label( Divx, text = "Divide Factor")
18176  divxlab.pack(side=RIGHT)
18177  GridRow = 5
18178  #
18179  if DeBugMode > 0:
18180  FOffEntry = Label(frame1, text="Samples")
18181  FOffEntry.grid(row=GridRow+1, column=0, sticky=W)
18182  MulXEntry = Label( frame1, text = "Rec Len Mul")
18183  MulXEntry.grid(row=GridRow+2, column=0, sticky=W)
18184  GridRow = GridRow + 2
18185  #
18186  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
18187  eqivsamplerate.grid(row=GridRow+1, column=0, sticky=W)
18188  #
18189  FConv = Frame( frame1 )
18190  FConv.grid(row=GridRow+2, column=0, sticky=W)
18191  FMulXEntry = Entry(FConv, width=3)
18192  FMulXEntry.bind('<MouseWheel>', ETSscroll)
18193  FMulXEntry.pack(side=RIGHT)
18194  FMulXEntry.delete(0,"end")
18195  FMulXEntry.insert(0,1)
18196  fminlab = Label( FConv, text = "Freq Multiplier")
18197  fminlab.pack(side=RIGHT)
18198  #
18199  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
18200  FminDisp.grid(row=GridRow+3, column=0, sticky=W)
18201  #
18202  if MinigenScreenStatus.get() > 0:
18203  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
18204  mgloadbutton.grid(row=GridRow+4, column=0, sticky=W)
18205  GridRow = GridRow + 1
18206  #
18207  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
18208  dirlab.grid(row=GridRow+5, column=0, sticky=W)
18209  DataMode = Frame( frame1 )
18210  DataMode.grid(row=GridRow+6, column=0, sticky=W)
18211  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
18212  dm3.pack(side=LEFT)
18213  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
18214  dm4.pack(side=LEFT)
18215  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
18216  tclab.grid(row=GridRow+7, column=0, sticky=W)
18217  TSMode = Frame( frame1 )
18218  TSMode.grid(row=GridRow+8, column=0, sticky=W)
18219  ETSts = Entry(TSMode, width=6)
18220  ETSts.bind('<MouseWheel>', ETSscroll)
18221  ETSts.pack(side=RIGHT)
18222  ETSts.delete(0,"end")
18223  ETSts.insert(0,1)
18224  ETStslab = Label( TSMode, text = "Factor")
18225  ETStslab.pack(side=RIGHT)
18226  #
18227  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
18228  etsdismissclbutton.grid(row=GridRow+9, column=0, sticky=W, pady=7)
18229  ETSDisp.set(0)
18230  ETSCheckBox()
18231 #
18233  global etswindow, ETSStatus, ETSDisp
18234 
18235  ETSStatus.set(0)
18236  ETSDisp.set(0)
18237  ETSCheckBox()
18238  etswindow.destroy()
18239 #
18240 def MGLoad():
18241  global MinigenFout, Fmin, ETSDir
18242 
18243  MinigenFout.delete(0,"end")
18244  if ETSDir.get() == 0:
18245  MinigenFout.insert(0,Fmin+20)
18246  else:
18247  MinigenFout.insert(0,Fmin-20)
18248  BSendMG()
18249 #
18250 def ETSscroll(event):
18251  onTextScroll(event)
18252  ETSUpdate()
18253 #
18254 def onFminScroll(event):
18255  onTextScroll(event)
18256  ETSUpdate()
18257  SetETSComp()
18258  SetAD9833(event)
18259 
18260 def onMulXScroll(event):
18261  global Two_X_Sample, HtMulEntry, ETSts, etssrlab, SAMPLErate
18262 
18263  onTextScroll(event)
18264  # ETSUpdate()
18265  try:
18266  TscaleX = float(HtMulEntry.get())
18267  except:
18268  HtMulEntry.delete(0,END)
18269  HtMulEntry.insert(0, 1)
18270  if Two_X_Sample.get() == 0:
18271  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
18272  else:
18273  ToffsetX = 0
18274  ETSts.delete(0,"end")
18275  ETSts.insert(0,ToffsetX)
18276  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
18277  etssrlab.config(text=SRstring)
18278  #
18279  SetETSComp()
18280  SetAD9833(event)
18281 #
18283  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
18284  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
18285  global FminEntry, HtMulEntry, Two_X_Sample, DeBugMode
18286 
18287  if TIMEdiv > 0.2:
18288  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
18289  else:
18290  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
18291  if (MaxETSrecord*100) > MaxSamples:
18292  MaxETSrecord = MaxSamples / 100
18293  try:
18294  DivX = float(eval(DivXEntry.get()))
18295  if DivX < 2:
18296  DivX = 2
18297  if DivX > 75:
18298  DivX = 75
18299  DivXEntry.delete(0,END)
18300  DivXEntry.insert(0, DivX)
18301  except:
18302  DivXEntry.delete(0,END)
18303  DivXEntry.insert(0, DivX)
18304  #
18305  FOff = 25
18306  MulX = (DivX*SAMPLErate)/(100*FOff)
18307  while MulX > MaxETSrecord:
18308  FOff = FOff + 5
18309  MulX = (DivX*SAMPLErate)/(100*FOff)
18310  FOff = 0 - FOff
18311  if DeBugMode > 0:
18312  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
18313  MulXEntry.config(text = SRstring) # change displayed value
18314  SRstring = "Offset = " + str(FOff) + " samples"
18315  FOffEntry.config(text = SRstring) # change displayed value
18316  baseFreq = SAMPLErate/DivX
18317  try:
18318  FMul = float(eval(FMulXEntry.get()))
18319  if FMul < 1:
18320  FMul = 1
18321  FMulXEntry.delete(0,END)
18322  FMulXEntry.insert(0, int(FMul))
18323  if FMul > 75:
18324  FMul = 75
18325  FMulXEntry.delete(0,END)
18326  FMulXEntry.insert(0, int(FMul))
18327  except:
18328  FMulXEntry.delete(0,END)
18329  FMulXEntry.insert(0, int(FMul))
18330  FreqMin = baseFreq * FMul
18331  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
18332  FminDisp.config(text = SRstring) # change displayed value
18333  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
18334  eqivsamplerate.config(text = SRstring) # change displayed value
18335  # calculate time scale multiplication factor
18336  try:
18337  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
18338  except:
18339  FminEntry.delete(0,END)
18340  FminEntry.insert(0, 25)
18341  #
18342  try: # catch for divide by zero
18343  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
18344  except:
18345  TscaleX = 1
18346 
18347  if TscaleX > 0:
18348  ETSDir.set(0) # set sample direction to forward if positive
18349  else:
18350  ETSDir.set(1) # set sample direction to reverse if negative
18351  TscaleX = abs(TscaleX)
18352  if Two_X_Sample.get() == 0:
18353  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
18354  else:
18355  ToffsetX = 0
18356  ETSts.delete(0,"end")
18357  ETSts.insert(0,ToffsetX)
18358 
18359  HtMulEntry.delete(0,END)
18360  HtMulEntry.insert(0, TscaleX)
18361  SRstring = "RT Sample Rate = " + str(SAMPLErate)
18362  rtsrlab.config(text=SRstring)
18363  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
18364  etssrlab.config(text=SRstring)
18365 #
18366 def Settingsscroll(event):
18367  onTextScroll(event)
18368  SettingsUpdate()
18369 #
18371  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
18372  global Settingswindow, SettingsStatus, SettingsDisp, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
18373  global AWG_Amp_Mode, SWRev, EnableHSsampling, Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
18374  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry, TrgLPFEntry, Trigger_LPF_length
18375  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
18376  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
18377  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
18378  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
18379 
18380  if SettingsStatus.get() == 0:
18381  Settingswindow = Toplevel()
18382  Settingswindow.title("Settings " + SWRev + RevDate)
18383  Settingswindow.resizable(FALSE,FALSE)
18384  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
18385  frame1 = Frame(Settingswindow, borderwidth=5, relief=RIDGE)
18386  frame1.grid(row=0, column=0, sticky=W)
18387  #
18388  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
18389  zstlab.grid(row=0, column=0, sticky=W)
18390  zstMode = Frame( frame1 )
18391  zstMode.grid(row=0, column=1, sticky=W)
18392  ZSTuff = Entry(zstMode, width=4)
18393  ZSTuff.bind('<MouseWheel>', Settingsscroll)
18394  ZSTuff.bind('<Key>', onTextKey)
18395  ZSTuff.pack(side=RIGHT)
18396  ZSTuff.delete(0,"end")
18397  ZSTuff.insert(0,ZEROstuffing.get())
18398  #
18399  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
18400  Avglab.grid(row=1, column=0, sticky=W)
18401  AvgMode = Frame( frame1 )
18402  AvgMode.grid(row=1, column=1, sticky=W)
18403  TAvg = Entry(AvgMode, width=4)
18404  TAvg.bind('<MouseWheel>', Settingsscroll)
18405  TAvg.bind('<Key>', onTextKey)
18406  TAvg.pack(side=RIGHT)
18407  TAvg.delete(0,"end")
18408  TAvg.insert(0,TRACEaverage.get())
18409  #
18410  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
18411  HarMlab.grid(row=2, column=0, sticky=W)
18412  HarMMode = Frame( frame1 )
18413  HarMMode.grid(row=2, column=1, sticky=W)
18414  HarMon = Entry(HarMMode, width=4)
18415  HarMon.bind('<MouseWheel>', Settingsscroll)
18416  HarMon.bind('<Key>', onTextKey)
18417  HarMon.pack(side=RIGHT)
18418  HarMon.delete(0,"end")
18419  HarMon.insert(0,HarmonicMarkers.get())
18420  #
18421  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
18422  Vdivlab.grid(row=3, column=0, sticky=W)
18423  VdivMode = Frame( frame1 )
18424  VdivMode.grid(row=3, column=1, sticky=W)
18425  VDivE = Entry(VdivMode, width=4)
18426  VDivE.bind('<MouseWheel>', Settingsscroll)
18427  VDivE.bind('<Key>', onTextKey)
18428  VDivE.pack(side=RIGHT)
18429  VDivE.delete(0,"end")
18430  VDivE.insert(0,Vdiv.get())
18431  #
18432  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
18433  Twdthlab.grid(row=4, column=0, sticky=W)
18434  TwdthMode = Frame( frame1 )
18435  TwdthMode.grid(row=4, column=1, sticky=W)
18436  TwdthE = Entry(TwdthMode, width=4)
18437  TwdthE.bind('<MouseWheel>', Settingsscroll)
18438  TwdthE.bind('<Key>', onTextKey)
18439  TwdthE.pack(side=RIGHT)
18440  TwdthE.delete(0,"end")
18441  TwdthE.insert(0,TRACEwidth.get())
18442  #
18443  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
18444  Gwdthlab.grid(row=5, column=0, sticky=W)
18445  GwdthMode = Frame( frame1 )
18446  GwdthMode.grid(row=5, column=1, sticky=W)
18447  GwdthE = Entry(GwdthMode, width=4)
18448  GwdthE.bind('<MouseWheel>', Settingsscroll)
18449  GwdthE.bind('<Key>', onTextKey)
18450  GwdthE.pack(side=RIGHT)
18451  GwdthE.delete(0,"end")
18452  GwdthE.insert(0,GridWidth.get())
18453  #
18454  trglpflab = Label(frame1, text="Trigger LPF Length", style= "A10B.TLabel")
18455  trglpflab.grid(row=6, column=0, sticky=W)
18456  TrgLPFMode = Frame( frame1 )
18457  TrgLPFMode.grid(row=6, column=1, sticky=W)
18458  TrgLPFEntry = Entry(TrgLPFMode, width=4)
18459  TrgLPFEntry.bind('<MouseWheel>', Settingsscroll)
18460  TrgLPFEntry.bind('<Key>', onTextKey)
18461  TrgLPFEntry.pack(side=RIGHT)
18462  TrgLPFEntry.delete(0,"end")
18463  TrgLPFEntry.insert(0,Trigger_LPF_length.get())
18464  #
18465  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
18466  AwgAmplrb1.grid(row=7, column=0, sticky=W)
18467  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
18468  AwgAmplrb2.grid(row=7, column=1, sticky=W)
18469  #
18470  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
18471  cha_Rcomplab.grid(row=8, column=0, sticky=W)
18472  cha_RcomplabMode = Frame( frame1 )
18473  cha_RcomplabMode.grid(row=8, column=1, sticky=W)
18474  cha_TC1Entry = Entry(cha_RcomplabMode, width=5)
18475  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
18476  cha_TC1Entry.bind('<Key>', onTextKey)
18477  cha_TC1Entry.pack(side=LEFT)
18478  cha_TC1Entry.delete(0,"end")
18479  cha_TC1Entry.insert(0,CHA_TC1.get())
18480  cha_A1Entry = Entry(cha_RcomplabMode, width=5)
18481  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
18482  cha_A1Entry.bind('<Key>', onTextKey)
18483  cha_A1Entry.pack(side=LEFT)
18484  cha_A1Entry.delete(0,"end")
18485  cha_A1Entry.insert(0,CHA_A1.get())
18486  #
18487  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
18488  cha_Ccomplab.grid(row=9, column=0, sticky=W)
18489  cha_CcomplabMode = Frame( frame1 )
18490  cha_CcomplabMode.grid(row=9, column=1, sticky=W)
18491  cha_TC2Entry = Entry(cha_CcomplabMode, width=5)
18492  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
18493  cha_TC2Entry.bind('<Key>', onTextKey)
18494  cha_TC2Entry.pack(side=LEFT)
18495  cha_TC2Entry.delete(0,"end")
18496  cha_TC2Entry.insert(0,CHA_TC2.get())
18497  cha_A2Entry = Entry(cha_CcomplabMode, width=5)
18498  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
18499  cha_A2Entry.bind('<Key>', onTextKey)
18500  cha_A2Entry.pack(side=LEFT)
18501  cha_A2Entry.delete(0,"end")
18502  cha_A2Entry.insert(0,CHA_A2.get())
18503  #
18504  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
18505  chb_Rcomplab.grid(row=10, column=0, sticky=W)
18506  chb_RcomplabMode = Frame( frame1 )
18507  chb_RcomplabMode.grid(row=10, column=1, sticky=W)
18508  chb_TC1Entry = Entry(chb_RcomplabMode, width=5)
18509  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
18510  chb_TC1Entry.bind('<Key>', onTextKey)
18511  chb_TC1Entry.pack(side=LEFT)
18512  chb_TC1Entry.delete(0,"end")
18513  chb_TC1Entry.insert(0,CHB_TC1.get())
18514  chb_A1Entry = Entry(chb_RcomplabMode, width=5)
18515  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
18516  chb_A1Entry.bind('<Key>', onTextKey)
18517  chb_A1Entry.pack(side=LEFT)
18518  chb_A1Entry.delete(0,"end")
18519  chb_A1Entry.insert(0,CHB_A1.get())
18520  #
18521  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
18522  chb_Ccomplab.grid(row=11, column=0, sticky=W)
18523  chb_CcomplabMode = Frame( frame1 )
18524  chb_CcomplabMode.grid(row=11, column=1, sticky=W)
18525  chb_TC2Entry = Entry(chb_CcomplabMode, width=5)
18526  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
18527  chb_TC2Entry.bind('<Key>', onTextKey)
18528  chb_TC2Entry.pack(side=LEFT)
18529  chb_TC2Entry.delete(0,"end")
18530  chb_TC2Entry.insert(0,CHB_TC2.get())
18531  chb_A2Entry = Entry(chb_CcomplabMode, width=5)
18532  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
18533  chb_A2Entry.bind('<Key>', onTextKey)
18534  chb_A2Entry.pack(side=LEFT)
18535  chb_A2Entry.delete(0,"end")
18536  chb_A2Entry.insert(0,CHB_A2.get())
18537  #
18538  if EnableHSsampling > 0:
18539  hs_ckb1 = Checkbutton(frame1, text="Auto Set ETS Comp", variable=Auto_ETS_Comp, command=SetETSComp)
18540  hs_ckb1.grid(row=12, column=0, sticky=W)
18541  hs1_Complab = Label(frame1, text="ETS Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
18542  hs1_Complab.grid(row=13, column=0, sticky=W)
18543  hs1_ComplabMode = Frame( frame1 )
18544  hs1_ComplabMode.grid(row=13, column=1, sticky=W)
18545  ets_TC1Entry = Entry(hs1_ComplabMode, width=5)
18546  ets_TC1Entry.bind('<MouseWheel>', Settingsscroll)
18547  ets_TC1Entry.bind('<Key>', onTextKey)
18548  ets_TC1Entry.pack(side=LEFT)
18549  ets_TC1Entry.delete(0,"end")
18550  ets_TC1Entry.insert(0,ETS_TC1.get())
18551  ets_A1Entry = Entry(hs1_ComplabMode, width=5)
18552  ets_A1Entry.bind('<MouseWheel>', Settingsscroll)
18553  ets_A1Entry.bind('<Key>', onTextKey)
18554  ets_A1Entry.pack(side=LEFT)
18555  ets_A1Entry.delete(0,"end")
18556  ets_A1Entry.insert(0,ETS_A1.get())
18557  #
18558  hs2_Complab = Label(frame1, text="ETS Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
18559  hs2_Complab.grid(row=14, column=0, sticky=W)
18560  hs2_ComplabMode = Frame( frame1 )
18561  hs2_ComplabMode.grid(row=14, column=1, sticky=W)
18562  ets_TC2Entry = Entry(hs2_ComplabMode, width=5)
18563  ets_TC2Entry.bind('<MouseWheel>', Settingsscroll)
18564  ets_TC2Entry.bind('<Key>', onTextKey)
18565  ets_TC2Entry.pack(side=LEFT)
18566  ets_TC2Entry.delete(0,"end")
18567  ets_TC2Entry.insert(0,ETS_TC2.get())
18568  ets_A2Entry = Entry(hs2_ComplabMode, width=5)
18569  ets_A2Entry.bind('<MouseWheel>', Settingsscroll)
18570  ets_A2Entry.bind('<Key>', onTextKey)
18571  ets_A2Entry.pack(side=LEFT)
18572  ets_A2Entry.delete(0,"end")
18573  ets_A2Entry.insert(0,ETS_A2.get())
18574  #
18575  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
18576  Settingsdismissbutton.grid(row=15, column=0, sticky=W, pady=7)
18577  else:
18578  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
18579  Settingsdismissbutton.grid(row=12, column=0, sticky=W, pady=7)
18580 #
18582  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
18583  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
18584  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
18585  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
18586  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
18587  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
18588 
18589  if Auto_ETS_Comp.get() == 1:
18590  try:
18591  MulX = float(HtMulEntry.get())
18592  #
18593  Value = float(ets_TC1Entry.get()) * MulX
18594  cha_TC1Entry.delete(0,"end")
18595  cha_TC1Entry.insert(0, Value)
18596  cha_A1Entry.delete(0,"end")
18597  cha_A1Entry.insert(0, ets_A1Entry.get())
18598  chb_TC1Entry.delete(0,"end")
18599  chb_TC1Entry.insert(0, Value)
18600  chb_A1Entry.delete(0,"end")
18601  chb_A1Entry.insert(0, ets_A1Entry.get())
18602  #
18603  Value = float(ets_TC2Entry.get()) * MulX
18604  cha_TC2Entry.delete(0,"end")
18605  cha_TC2Entry.insert(0, Value)
18606  cha_A2Entry.delete(0,"end")
18607  cha_A2Entry.insert(0, ets_A2Entry.get())
18608  chb_TC2Entry.delete(0,"end")
18609  chb_TC2Entry.insert(0, Value)
18610  chb_A2Entry.delete(0,"end")
18611  chb_A2Entry.insert(0, ets_A2Entry.get())
18612  except:
18613  MulX = 1.0
18614 
18616 
18617  UpdateAWGA()
18618  UpdateAWGB()
18619  ReMakeAWGwaves()
18620 
18622  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
18623  global Settingswindow, SettingsStatus, SettingsDisp, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
18624  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
18625  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, TrgLPFEntry, Trigger_LPF_length
18626  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
18627  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
18628 
18629  try:
18630  GW = int(eval(GwdthE.get()))
18631  if GW < 1:
18632  GW = 1
18633  GwdthE.delete(0,END)
18634  GwdthE.insert(0, int(GW))
18635  if GW > 5:
18636  GW = 5
18637  GwdthE.delete(0,END)
18638  GwdthE.insert(0, int(GW))
18639  except:
18640  GwdthE.delete(0,END)
18641  GwdthE.insert(0, GridWidth.get())
18642  GridWidth.set(GW)
18643  #
18644  try:
18645  T_length = int(eval(TrgLPFEntry.get()))
18646  if T_length < 1:
18647  T_length = 1
18648  TrgLPFEntry.delete(0,END)
18649  TrgLPFEntry.insert(0, int(GW))
18650  if T_length > 100:
18651  T_length = 100
18652  TrgLPFEntry.delete(0,END)
18653  TrgLPFEntry.insert(0, int(GW))
18654  except:
18655  TrgLPFEntry.delete(0,END)
18656  TrgLPFEntry.insert(0, Trigger_LPF_length.get())
18657  Trigger_LPF_length.set(T_length)
18658  #
18659  try:
18660  TW = int(eval(TwdthE.get()))
18661  if TW < 1:
18662  TW = 1
18663  TwdthE.delete(0,END)
18664  TwdthE.insert(0, int(TW))
18665  if TW > 5:
18666  TW = 5
18667  TwdthE.delete(0,END)
18668  TwdthE.insert(0, int(TW))
18669  except:
18670  TwdthE.delete(0,END)
18671  TwdthE.insert(0, TRACEwidth.get())
18672  TRACEwidth.set(TW)
18673  # Number of average sweeps for average mode
18674  try:
18675  TA = int(eval(TAvg.get()))
18676  if TA < 1:
18677  TA = 1
18678  TAvg.delete(0,END)
18679  TAvg.insert(0, int(TA))
18680  if TA > 16:
18681  TA = 16
18682  TAvg.delete(0,END)
18683  TAvg.insert(0, int(TA))
18684  except:
18685  TAvg.delete(0,END)
18686  TAvg.insert(0, TRACEaverage.get())
18687  TRACEaverage.set(TA)
18688  # Number of vertical divisions for spectrum / Bode
18689  try:
18690  VDv = int(eval(VDivE.get()))
18691  if VDv < 1:
18692  VDv = 1
18693  VDivE.delete(0,END)
18694  VDivE.insert(0, int(VDv))
18695  if VDv > 16:
18696  VDv = 16
18697  VDivE.delete(0,END)
18698  VDivE.insert(0, int(VDv))
18699  except:
18700  VDivE.delete(0,END)
18701  VDivE.insert(0, Vdiv.get())
18702  Vdiv.set(VDv)
18703  # number of Harmonic Markers in SA
18704  try:
18705  HM = int(eval(HarMon.get()))
18706  if HM < 1:
18707  HM = 1
18708  HarMon.delete(0,END)
18709  HarMon.insert(0, int(HM))
18710  if HM > 9:
18711  HM =9
18712  HarMon.delete(0,END)
18713  HarMon.insert(0, int(HM))
18714  except:
18715  HarMon.delete(0,END)
18716  HarMon.insert(0, HarmonicMarkers.get())
18717  HarmonicMarkers.set(HM)
18718  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
18719  try:
18720  ZST = int(eval(ZSTuff.get()))
18721  if ZST < 1:
18722  ZST = 1
18723  ZSTuff.delete(0,END)
18724  ZSTuff.insert(0, int(ZST))
18725  if ZST > 5:
18726  ZST = 5
18727  ZSTuff.delete(0,END)
18728  ZSTuff.insert(0, int(ZST))
18729  except:
18730  ZSTuff.delete(0,END)
18731  ZSTuff.insert(0, ZEROstuffing.get())
18732  ZEROstuffing.set(ZST)
18733 #
18734  try:
18735  TC1A = float(cha_TC1Entry.get())
18736  CHA_TC1.set(TC1A)
18737  if TC1A < 0:
18738  TC1A = 0
18739  cha_TC1Entry.delete(0,END)
18740  cha_TC1Entry.insert(0, TC1A)
18741  except:
18742  cha_TC1Entry.delete(0,END)
18743  cha_TC1Entry.insert(0, CHA_TC1.get())
18744  try:
18745  TC2A = float(cha_TC2Entry.get())
18746  CHA_TC2.set(TC2A)
18747  if TC2A < 0:
18748  TC2A = 0
18749  cha_TC2Entry.delete(0,END)
18750  cha_TC2Entry.insert(0, TC2A)
18751  except:
18752  cha_TC2Entry.delete(0,END)
18753  cha_TC2Entry.insert(0, CHA_TC2.get())
18754  #
18755  try:
18756  Gain1A = float(cha_A1Entry.get())
18757  CHA_A1.set(Gain1A)
18758  except:
18759  cha_A1Entry.delete(0,END)
18760  cha_A1Entry.insert(0, CHA_A1.get())
18761  try:
18762  Gain2A = float(cha_A2Entry.get())
18763  CHA_A2.set(Gain2A)
18764  except:
18765  cha_A2Entry.delete(0,END)
18766  cha_A2Entry.insert(0, CHA_A2.get())
18767  #
18768  try:
18769  TC1B = float(chb_TC1Entry.get())
18770  CHB_TC1.set(TC1B)
18771  if TC1B < 0:
18772  TC1B = 0
18773  chb_TC1Entry.delete(0, END)
18774  chb_TC1Entry.insert(0, TC1B)
18775  except:
18776  chb_TC1Entry.delete(0,END)
18777  chb_TC1Entry.insert(0, CHB_TC1.get())
18778  try:
18779  TC2B = float(chb_TC2Entry.get())
18780  CHB_TC2.set(TC2B)
18781  if TC2B < 0:
18782  TC2B = 0
18783  chb_TC2Entry.delete(0, END)
18784  chb_TC2Entry.insert(0, TC2B)
18785  except:
18786  chb_TC2Entry.delete(0,END)
18787  chb_TC2Entry.insert(0, CHB_TC2.get())
18788  #
18789  try:
18790  Gain1B = float(chb_A1Entry.get())
18791  CHB_A1.set(Gain1B)
18792  except:
18793  chb_A1Entry.delete(0,END)
18794  chb_A1Entry.insert(0, CHB_A1.get())
18795  try:
18796  Gain2B = float(chb_A2Entry.get())
18797  CHB_A2.set(Gain2B)
18798  except:
18799  chb_A2Entry.delete(0,END)
18800  chb_A2Entry.insert(0, CHB_A2.get())
18801  # set ETS base comp
18802  #
18803  SetETSComp()
18804 #
18806  global Settingswindow, SettingsStatus, SettingsDisp
18807 
18808  SettingsStatus.set(0)
18809  SettingsUpdate()
18810  # SettingsDisp.set(0)
18811  Settingswindow.destroy()
18812 #
18813 def onCanvasMouse_xy(event):
18814  global MouseX, MouseY, MouseWidget
18815 
18816  MouseWidget = event.widget
18817  MouseX, MouseY = event.x, event.y
18818 #
18819 def BSetFmin():
18820  global FminEntry, CHAfreq
18821 
18822  if CHAfreq > 0:
18823  String = '{0:.3f}'.format(CHAfreq/1000)
18824  FminEntry.delete(0,"end")
18825  FminEntry.insert(0,String)
18826 #
18827 # ================ Make main Screen ==========================
18828 TgInput = IntVar(0) # Trigger Input variable
18829 SingleShot = IntVar(0) # variable for single shot triger
18830 ManualTrigger = IntVar(0) # variable for Manual trigger
18831 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
18832 ShowC1_V = IntVar(0) # curves to display variables
18833 TgEdge = IntVar(0) # Trigger edge variable
18834 # Show channels variables
18835 ShowC1_V = IntVar(0) # curves to display variables
18836 ShowC1_I = IntVar(0)
18837 ShowC2_V = IntVar(0)
18838 ShowC2_I = IntVar(0)
18839 ShowAV_I = IntVar(0)
18840 ShowBV_I = IntVar(0)
18841 ShowRA_V = IntVar(0)
18842 ShowRA_I = IntVar(0)
18843 ShowRB_V = IntVar(0)
18844 ShowRB_I = IntVar(0)
18845 ShowMath = IntVar(0)
18846 Show_MathX = IntVar(0)
18847 Show_MathY = IntVar(0)
18848 AutoCenterA = IntVar(0)
18849 AutoCenterB = IntVar(0)
18850 SmoothCurves = IntVar(0)
18851 ZOHold = IntVar(0)
18852 TRACEmodeTime = IntVar(0)
18853 TRACEmodeTime.set(0)
18854 ColorMode = IntVar(0)
18855 DecimateOption = IntVar(0)
18856 MathTrace = IntVar(0)
18857 # define vertical measurment variables
18858 MeasDCV1 = IntVar(0)
18859 MeasMinV1 = IntVar(0)
18860 MeasMaxV1 = IntVar(0)
18861 MeasMidV1 = IntVar(0)
18862 MeasPPV1 = IntVar(0)
18863 MeasRMSV1 = IntVar(0)
18864 MeasRMSVA_B = IntVar(0)
18865 MeasDCI1 = IntVar(0)
18866 MeasMinI1 = IntVar(0)
18867 MeasMaxI1 = IntVar(0)
18868 MeasMidI1 = IntVar(0)
18869 MeasPPI1 = IntVar(0)
18870 MeasRMSI1 = IntVar(0)
18871 MeasDiffAB = IntVar(0)
18872 MeasDCV2 = IntVar(0)
18873 MeasMinV2 = IntVar(0)
18874 MeasMaxV2 = IntVar(0)
18875 MeasMidV2 = IntVar(0)
18876 MeasPPV2 = IntVar(0)
18877 MeasRMSV2 = IntVar(0)
18878 MeasDCI2 = IntVar(0)
18879 MeasMinI2 = IntVar(0)
18880 MeasMaxI2 = IntVar(0)
18881 MeasMidI2 = IntVar(0)
18882 MeasPPI2 = IntVar(0)
18883 MeasRMSI2 = IntVar(0)
18884 MeasDiffBA = IntVar(0)
18885 MeasUserA = IntVar(0)
18886 MeasAHW = IntVar(0)
18887 MeasALW = IntVar(0)
18888 MeasADCy = IntVar(0)
18889 MeasAPER = IntVar(0)
18890 MeasAFREQ = IntVar(0)
18891 MeasBHW = IntVar(0)
18892 MeasBLW = IntVar(0)
18893 MeasBDCy = IntVar(0)
18894 MeasBPER = IntVar(0)
18895 MeasBFREQ = IntVar(0)
18896 MeasPhase = IntVar(0)
18897 MeasTopV1 = IntVar(0)
18898 MeasBaseV1 = IntVar(0)
18899 MeasTopV2 = IntVar(0)
18900 MeasBaseV2 = IntVar(0)
18901 MeasUserB = IntVar(0)
18902 MeasDelay = IntVar(0)
18903 TimeDisp = IntVar(0)
18904 TimeDisp.set(1)
18905 XYDisp = IntVar(0)
18906 FreqDisp = IntVar(0)
18907 BodeDisp = IntVar(0)
18908 IADisp = IntVar(0)
18909 OhmDisp = IntVar(0)
18910 BodeScreenStatus = IntVar(0)
18911 BodeScreenStatus.set(0)
18912 DigScreenStatus = IntVar(0)
18913 DigScreenStatus.set(0)
18914 DacScreenStatus = IntVar(0)
18915 DacScreenStatus.set(0)
18916 MuxScreenStatus = IntVar(0)
18917 MuxScreenStatus.set(0)
18918 DualMuxMode = IntVar(0)
18919 MinigenScreenStatus = IntVar(0)
18920 MinigenScreenStatus.set(0)
18921 DA1ScreenStatus = IntVar(0)
18922 DA1ScreenStatus.set(0)
18923 DigPotScreenStatus = IntVar(0)
18924 DigPotScreenStatus.set(0)
18925 GenericSerialStatus = IntVar(0)
18926 GenericSerialStatus.set(0)
18927 AD5626SerialStatus = IntVar(0)
18928 AD5626SerialStatus.set(0)
18929 DigFiltStatus = IntVar(0)
18930 DigFiltStatus.set(0)
18931 CommandStatus = IntVar(0)
18932 CommandStatus.set(0)
18933 MeasureStatus = IntVar(0)
18934 MeasureStatus.set(0)
18935 MarkerScale = IntVar(0)
18936 MarkerScale.set(1)
18937 SettingsStatus = IntVar(0)
18938 CHA_RC_HP = IntVar(0)
18939 CHB_RC_HP = IntVar(0)
18940 CHAI_RC_HP = IntVar(0)
18941 CHBI_RC_HP = IntVar(0)
18942 #
18943 frame2r = Frame(root, borderwidth=5, relief=RIDGE)
18944 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
18945 
18946 frame1 = Frame(root, borderwidth=5, relief=RIDGE)
18947 frame1.pack(side=TOP, fill=BOTH, expand=NO)
18948 
18949 frame2 = Frame(root, borderwidth=5, relief=RIDGE)
18950 frame2.pack(side=TOP, fill=BOTH, expand=YES)
18951 
18952 frame3 = Frame(root, borderwidth=5, relief=RIDGE)
18953 frame3.pack(side=TOP, fill=BOTH, expand=NO)
18954 # define custom buttons
18955 root.style.configure("W3.TButton", width=3, relief=RAISED)
18956 root.style.configure("W4.TButton", width=4, relief=RAISED)
18957 root.style.configure("W5.TButton", width=5, relief=RAISED)
18958 root.style.configure("W6.TButton", width=6, relief=RAISED)
18959 root.style.configure("W7.TButton", width=7, relief=RAISED)
18960 root.style.configure("W8.TButton", width=8, relief=RAISED)
18961 root.style.configure("W9.TButton", width=9, relief=RAISED)
18962 root.style.configure("W10.TButton", width=10, relief=RAISED)
18963 root.style.configure("W11.TButton", width=11, relief=RAISED)
18964 root.style.configure("W16.TButton", width=16, relief=RAISED)
18965 root.style.configure("W17.TButton", width=17, relief=RAISED)
18966 root.style.configure("Stop.TButton", background="red", width=4, relief=RAISED)
18967 root.style.configure("Run.TButton", background="green", width=4, relief=RAISED)
18968 root.style.configure("Pwr.TButton", background="green", width=7, relief=RAISED)
18969 root.style.configure("PwrOff.TButton", background="red", width=7, relief=RAISED)
18970 root.style.configure("RConn.TButton", background="red", width=5, relief=RAISED)
18971 root.style.configure("GConn.TButton", background="green", width=5, relief=RAISED)
18972 root.style.configure("Rtrace1.TButton", background=COLORtrace1, width=7, relief=RAISED)
18973 root.style.configure("Strace1.TButton", background=COLORtrace1, width=7, relief=SUNKEN)
18974 root.style.configure("Rtrace2.TButton", background=COLORtrace2, width=7, relief=RAISED)
18975 root.style.configure("Strace2.TButton", background=COLORtrace2, width=7, relief=SUNKEN)
18976 root.style.configure("Rtrace3.TButton", background=COLORtrace3, width=7, relief=RAISED)
18977 root.style.configure("Strace3.TButton", background=COLORtrace3, width=7, relief=SUNKEN)
18978 root.style.configure("Rtrace4.TButton", background=COLORtrace4, width=7, relief=RAISED)
18979 root.style.configure("Strace4.TButton", background=COLORtrace4, width=7, relief=SUNKEN)
18980 root.style.configure("Rtrace6.TButton", background=COLORtrace6, width=7, relief=RAISED)
18981 root.style.configure("Strace6.TButton", background=COLORtrace6, width=7, relief=SUNKEN)
18982 root.style.configure("Rtrace7.TButton", background=COLORtrace7, width=7, relief=RAISED)
18983 root.style.configure("Strace7.TButton", background=COLORtrace7, width=7, relief=SUNKEN)
18984 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
18985 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
18986 root.style.configure("A10R1.TLabelframe.Label", foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
18987 root.style.configure("A10R1.TLabelframe", borderwidth=5, relief=RIDGE)
18988 root.style.configure("A10R2.TLabelframe.Label", foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
18989 root.style.configure("A10R2.TLabelframe", borderwidth=5, relief=RIDGE)
18990 root.style.configure("A10B.TLabel", foreground=COLORcanvas, font="Arial 10 bold") # Black text
18991 root.style.configure("A10R.TLabel", foreground="red", font="Arial 10 bold") # Red text
18992 root.style.configure("A10G.TLabel", foreground="green", font="Arial 10 bold") # Red text
18993 root.style.configure("A12B.TLabel", foreground=COLORcanvas, font="Arial 12 bold") # Black text
18994 root.style.configure("A16B.TLabel", foreground=COLORcanvas, font="Arial 16 bold") # Black text
18995 root.style.configure("Stop.TRadiobutton", background="red")
18996 root.style.configure("Run.TRadiobutton", background="green")
18997 root.style.configure("Disab.TCheckbutton", indicatorcolor="red")
18998 root.style.configure("Enab.TCheckbutton", indicatorcolor="green")
18999 root.style.configure("WPhase.TRadiobutton", width=5, background="white", indicatorcolor=("red", "green"))
19000 root.style.configure("GPhase.TRadiobutton", width=5, background="gray", indicatorcolor=("red", "green"))
19001 # create a pulldown menu
19002 # Trigger signals
19003 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
19004 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
19005 Triggermenu["menu"] = Triggermenu.menu
19006 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
19007 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
19008 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
19009 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
19010 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
19011 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
19012 Triggermenu.menu.add_checkbutton(label='Low Pass Filter', variable=LPFTrigger)
19013 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
19014 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
19015 Triggermenu.pack(side=LEFT)
19016 #
19017 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
19018 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
19019 Edgemenu["menu"] = Edgemenu.menu
19020 Edgemenu.menu.add_radiobutton(label='Rising [+]', variable=TgEdge, value=0)
19021 Edgemenu.menu.add_radiobutton(label='Falling [-]', variable=TgEdge, value=1)
19022 Edgemenu.pack(side=LEFT)
19023 #
19024 tlab = Label(frame1, text="Trig Level")
19025 tlab.pack(side=LEFT)
19026 TRIGGERentry = Entry(frame1, width=5)
19027 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
19028 TRIGGERentry.bind("<Return>", BTriglevel)
19029 TRIGGERentry.bind('<Key>', onTextKey)
19030 TRIGGERentry.pack(side=LEFT)
19031 TRIGGERentry.delete(0,"end")
19032 TRIGGERentry.insert(0,0.0)
19033 #
19034 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
19035 tgb.pack(side=LEFT)
19036 #
19037 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
19038 hldlab.pack(side=LEFT)
19039 HoldOffentry = Entry(frame1, width=4)
19040 HoldOffentry.bind('<MouseWheel>', onTextScroll)
19041 HoldOffentry.bind("<Return>", BHoldOff)
19042 HoldOffentry.bind('<Key>', onTextKey)
19043 HoldOffentry.pack(side=LEFT)
19044 HoldOffentry.delete(0,"end")
19045 HoldOffentry.insert(0,0.0)
19046 #
19047 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
19048 hozlab.pack(side=LEFT)
19049 HozPossentry = Entry(frame1, width=4)
19050 HozPossentry.bind('<MouseWheel>', onTextScroll)
19051 HozPossentry.bind("<Return>", BHozPoss)
19052 HozPossentry.bind('<Key>', onTextKey)
19053 HozPossentry.pack(side=LEFT)
19054 HozPossentry.delete(0,"end")
19055 HozPossentry.insert(0,0.0)
19056 #
19057 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
19058 bexit.pack(side=RIGHT)
19059 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
19060 bstop.pack(side=RIGHT)
19061 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
19062 brun.pack(side=RIGHT)
19063 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
19064 PwrBt.pack(side=RIGHT)
19065 # Curves Menu , background="#A0A0A0"
19066 Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
19067 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
19068 Showmenu["menu"] = Showmenu.menu
19069 Showmenu.menu.add_command(label="-Show-", foreground="blue", command=donothing)
19070 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
19071 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
19072 Showmenu.menu.add_checkbutton(label='CA-V [1]', background=COLORtrace1, variable=ShowC1_V, command=TraceSelectADC_Mux)
19073 Showmenu.menu.add_checkbutton(label='CA-I [3]', background=COLORtrace3, variable=ShowC1_I, command=TraceSelectADC_Mux)
19074 Showmenu.menu.add_checkbutton(label='CB-V [2]', background=COLORtrace2, variable=ShowC2_V, command=TraceSelectADC_Mux)
19075 Showmenu.menu.add_checkbutton(label='CB-I [4]', background=COLORtrace4,variable=ShowC2_I, command=TraceSelectADC_Mux)
19076 Showmenu.menu.add_checkbutton(label='Math-X', background=COLORtrace6, variable=Show_MathX, command=UpdateTimeTrace)
19077 Showmenu.menu.add_checkbutton(label='Math-Y', background=COLORtrace7, variable=Show_MathY, command=UpdateTimeTrace)
19078 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
19079 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
19080 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
19081 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
19082 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
19083 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
19084 if EnableHSsampling > 0:
19085  Showmenu.menu.add_checkbutton(label='Comp CA-I', variable=CHAI_RC_HP)
19086  Showmenu.menu.add_checkbutton(label='Comp CB-I', variable=CHBI_RC_HP)
19087 Showmenu.menu.add_separator()
19088 Showmenu.menu.add_checkbutton(label='RA-V', background=COLORtraceR1, variable=ShowRA_V, command=UpdateTimeTrace)
19089 Showmenu.menu.add_checkbutton(label='RA-I', background=COLORtraceR3, variable=ShowRA_I, command=UpdateTimeTrace)
19090 Showmenu.menu.add_checkbutton(label='RB-V', background=COLORtraceR2, variable=ShowRB_V, command=UpdateTimeTrace)
19091 Showmenu.menu.add_checkbutton(label='RB-I', background=COLORtraceR4, variable=ShowRB_I, command=UpdateTimeTrace)
19092 Showmenu.menu.add_checkbutton(label='RMath', background=COLORtraceR5, variable=ShowMath, command=UpdateTimeTrace)
19093 Showmenu.menu.add_separator()
19094 Showmenu.menu.add_checkbutton(label='T Cursor [t]', variable=ShowTCur, command=UpdateTimeTrace)
19095 Showmenu.menu.add_checkbutton(label='V Cursor [v]', variable=ShowVCur, command=UpdateTimeTrace)
19096 Showmenu.pack(side=RIGHT)
19097 #
19098 if ShowBallonHelp > 0:
19099  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
19100  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
19101  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
19102  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
19103  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
19104  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
19105  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
19106  brun_tip = CreateToolTip(brun, 'Start acquiring data')
19107  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
19108  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
19109 
19110 # Sampling controls Widgets
19111 if EnableHSsampling > 0:
19112  fminlab2 = Label(frame1, text="KHz")
19113  fminlab2.pack(side=RIGHT)
19114  FminEntry = Entry(frame1, width=6)
19115  FminEntry.bind('<MouseWheel>', onFminScroll)
19116  FminEntry.bind("<Return>", SetAD9833)
19117  FminEntry.pack(side=RIGHT)
19118  FminEntry.delete(0,"end")
19119  FminEntry.insert(0,25)
19120  fminlab = Button(frame1, text="Fmin", style="W5.TButton", command=BSetFmin)
19121  fminlab.pack(side=RIGHT)
19122  #
19123  HtMulEntry = Entry(frame1, width=4)
19124  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
19125  HtMulEntry.bind("<Return>", SetAD9833)
19126  HtMulEntry.pack(side=RIGHT)
19127  HtMulEntry.delete(0,"end")
19128  HtMulEntry.insert(0,1)
19129  mulxlab = Label( frame1, text = "Mul X")
19130  mulxlab.pack(side=RIGHT)
19131 #
19132 # Time per Div
19133 TMsb = Spinbox(frame1, width=5, values= TMpdiv, command=BTime)
19134 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
19135 TMsb.pack(side=RIGHT)
19136 TMsb.delete(0,"end")
19137 TMsb.insert(0,0.5)
19138 TMlab = Label(frame1, text="Time mS/Div")
19139 TMlab.pack(side=RIGHT)
19140 #
19141 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
19142 # add mouse left and right button click to canvas
19143 ca.bind('<Configure>', CAresize)
19144 ca.bind('<1>', onCanvasClickLeft)
19145 ca.bind('<3>', onCanvasClickRight)
19146 ca.bind("<Motion>",onCanvasMouse_xy)
19147 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
19148 ca.bind("<Down>", onCanvasDownArrow)
19149 ca.bind("<Left>", onCanvasLeftArrow)
19150 ca.bind("<Right>", onCanvasRightArrow)
19151 ca.bind("<space>", onCanvasSpaceBar)
19152 ca.bind("1", onCanvasOne)
19153 ca.bind("2", onCanvasTwo)
19154 ca.bind("3", onCanvasThree)
19155 ca.bind("4", onCanvasFour)
19156 ca.bind("5", onCanvasFive)
19157 ca.bind("6", onCanvasSix)
19158 ca.bind("7", onCanvasSeven)
19159 ca.bind("8", onCanvasEight)
19160 ca.bind("9", onCanvasNine)
19161 ca.bind("0", onCanvasZero)
19162 ca.bind("a", onCanvasAverage)
19163 ca.bind("t", onCanvasShowTcur)
19164 ca.bind("v", onCanvasShowVcur)
19165 ca.bind("s", onCanvasSnap)
19166 ca.bind("+", onCanvasTrising)
19167 ca.bind("-", onCanvasTfalling)
19168 ca.bind('<MouseWheel>', onCanvasClickScroll)
19169 ca.pack(side=TOP, fill=BOTH, expand=YES)
19170 MouseWidget = ca
19171 # right side menu buttons
19172 dropmenu = Frame( frame2r )
19173 dropmenu.pack(side=TOP)
19174 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
19175 bcon.pack(side=LEFT, anchor=W)
19176 # File menu
19177 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
19178 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
19179 Filemenu["menu"] = Filemenu.menu
19180 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
19181 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
19182 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
19183 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
19184 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
19185 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
19186 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
19187 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
19188 Filemenu.menu.add_command(label="Help", command=BHelp)
19189 Filemenu.menu.add_command(label="About", command=BAbout)
19190 Filemenu.pack(side=LEFT, anchor=W)
19191 # Options Menu
19192 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
19193 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
19194 Optionmenu["menu"] = Optionmenu.menu
19195 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
19196 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
19197 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
19198 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
19199 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
19200 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
19201 Optionmenu.menu.add_checkbutton(label='Trace Avg [a]', variable=TRACEmodeTime)
19202 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
19203 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
19204 Optionmenu.menu.add_command(label="SnapShot [s]", command=BSnapShot)
19205 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
19206 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
19207 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
19208 if AllowFlashFirmware == 1:
19209  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
19210  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
19211 Optionmenu.pack(side=LEFT, anchor=W)
19212 #
19213 dropmenu2 = Frame( frame2r )
19214 dropmenu2.pack(side=TOP)
19215 # Open Math trace menu
19216 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
19217 mathbt.pack(side=RIGHT, anchor=W)
19218 # Measurments menu
19219 measlab = Label(dropmenu2, text="Meas")
19220 measlab.pack(side=LEFT, anchor=W)
19221 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
19222 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
19223 MeasmenuA["menu"] = MeasmenuA.menu
19224 MeasmenuA.menu.add_command(label="-CA-V-", foreground="blue", command=donothing)
19225 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
19226 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
19227 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
19228 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
19229 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
19230 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
19231 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
19232 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
19233 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
19234 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
19235 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
19236 #MeasmenuA.menu.add_separator()
19237 MeasmenuA.menu.add_command(label="-CA-I-", foreground="blue", command=donothing)
19238 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
19239 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
19240 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
19241 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
19242 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
19243 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
19244 #MeasmenuA.menu.add_separator()
19245 MeasmenuA.menu.add_command(label="-CA-Time-", foreground="blue", command=donothing)
19246 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
19247 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
19248 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
19249 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
19250 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
19251 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
19252 #
19253 MeasmenuA.pack(side=LEFT)
19254 #
19255 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
19256 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
19257 MeasmenuB["menu"] = MeasmenuB.menu
19258 MeasmenuB.menu.add_command(label="-CB-V-", foreground="blue", command=donothing)
19259 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
19260 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
19261 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
19262 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
19263 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
19264 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
19265 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
19266 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
19267 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
19268 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
19269 #MeasmenuB.menu.add_separator()
19270 MeasmenuB.menu.add_command(label="-CB-I-", foreground="blue", command=donothing)
19271 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
19272 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
19273 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
19274 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
19275 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
19276 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
19277 #MeasmenuB.menu.add_separator()
19278 MeasmenuB.menu.add_command(label="-CB-Time-", foreground="blue", command=donothing)
19279 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
19280 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
19281 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
19282 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
19283 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
19284 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
19285 MeasmenuB.pack(side=LEFT)
19286 #
19287 BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
19288 BuildAWGScreen.pack(side=TOP)
19289 # Mode selector
19290 timebtn = Frame( frame2r )
19291 timebtn.pack(side=TOP)
19292 ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
19293 ckb1.pack(side=LEFT)
19294 timelab = Label(timebtn, text="Time Plot")
19295 timelab.pack(side=LEFT)
19296 xybtn = Frame( frame2r )
19297 xybtn.pack(side=TOP)
19298 ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
19299 ckb2.pack(side=LEFT)
19300 BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
19301 BuildXYScreen.pack(side=TOP)
19302 #
19303 freqbtn = Frame( frame2r )
19304 freqbtn.pack(side=TOP)
19305 ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
19306 ckb3.pack(side=LEFT)
19307 BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
19308 BuildSpectrumScreen.pack(side=LEFT)
19309 #
19310 bodebtn = Frame( frame2r )
19311 bodebtn.pack(side=TOP)
19312 ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
19313 ckb5.pack(side=LEFT)
19314 BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
19315 BuildBodeScreen.pack(side=LEFT)
19316 #
19317 impdbtn = Frame( frame2r )
19318 impdbtn.pack(side=TOP)
19319 ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
19320 ckb4.pack(side=LEFT)
19321 BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
19322 BuildIAScreen.pack(side=LEFT)
19323 #
19324 dcohmbtn = Frame( frame2r )
19325 dcohmbtn.pack(side=TOP)
19326 ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
19327 ckb6.pack(side=LEFT)
19328 BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
19329 BuildOhmScreen.pack(side=LEFT)
19330 if ShowBallonHelp > 0:
19331  math_tip = CreateToolTip(mathbt, 'Open Math window')
19332  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
19333  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
19334  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open spectrum analyzer window')
19335  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
19336  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance analyzer window')
19337  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
19338 # Digital Input / Output Option screens
19339 DigScreenStatus = IntVar(0)
19340 DigScreenStatus.set(0)
19341 BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
19342 BuildDigScreen.pack(side=TOP)
19343 #
19344 # Optional plugin tools
19345 if EnablePIODACMode > 0:
19346  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
19347  BuildDacScreen.pack(side=TOP)
19348 if EnableMuxMode > 0:
19349  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
19350  BuildMuxScreen.pack(side=TOP)
19351 if EnableMinigenMode > 0:
19352  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
19353  BuildMinigenScreen.pack(side=TOP)
19354 if EnablePmodDA1Mode > 0:
19355  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
19356  BuildDA1Screen.pack(side=TOP)
19357 if EnableDigPotMode >0:
19358  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
19359  BuildDigPotScreen.pack(side=TOP)
19360 if EnableGenericSerialMode >0:
19361  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
19362  GenericSerialScreen.pack(side=TOP)
19363 if EnableAD5626SerialMode >0:
19364  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
19365  AD5626SerialScreen.pack(side=TOP)
19366 if EnableDigitalFilter >0:
19367  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
19368  DigFiltScreen.pack(side=TOP)
19369 if EnableCommandInterface > 0:
19370  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
19371  CommandLineScreen.pack(side=TOP)
19372 if EnableMeasureScreen > 0:
19373  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
19374  MeasureScreen.pack(side=TOP)
19375 if EnableETSScreen > 0:
19376  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
19377  ETSScreen.pack(side=TOP)
19378 # input probe wigets
19379 prlab = Label(frame2r, text="Adjust Gain / Offset")
19380 prlab.pack(side=TOP)
19381 # Input Probes sub frame
19382 ProbeA = Frame( frame2r )
19383 ProbeA.pack(side=TOP)
19384 gain1lab = Label(ProbeA, text="CA-V")
19385 gain1lab.pack(side=LEFT)
19386 CHAVGainEntry = Entry(ProbeA, width=5)
19387 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
19388 CHAVGainEntry.bind('<Key>', onTextKey)
19389 CHAVGainEntry.pack(side=LEFT)
19390 CHAVGainEntry.delete(0,"end")
19391 CHAVGainEntry.insert(0,1.0)
19392 CHAVOffsetEntry = Entry(ProbeA, width=5)
19393 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
19394 CHAVOffsetEntry.bind('<Key>', onTextKey)
19395 CHAVOffsetEntry.pack(side=LEFT)
19396 CHAVOffsetEntry.delete(0,"end")
19397 CHAVOffsetEntry.insert(0,0.0)
19398 #
19399 ProbeB = Frame( frame2r )
19400 ProbeB.pack(side=TOP)
19401 gain2lab = Label(ProbeB, text="CB-V")
19402 gain2lab.pack(side=LEFT)
19403 CHBVGainEntry = Entry(ProbeB, width=5)
19404 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
19405 CHBVGainEntry.bind('<Key>', onTextKey)
19406 CHBVGainEntry.pack(side=LEFT)
19407 CHBVGainEntry.delete(0,"end")
19408 CHBVGainEntry.insert(0,1.0)
19409 CHBVOffsetEntry = Entry(ProbeB, width=5)
19410 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
19411 CHBVOffsetEntry.bind('<Key>', onTextKey)
19412 CHBVOffsetEntry.pack(side=LEFT)
19413 CHBVOffsetEntry.delete(0,"end")
19414 CHBVOffsetEntry.insert(0,0.0)
19415 #
19416 ProbeAI = Frame( frame2r )
19417 ProbeAI.pack(side=TOP)
19418 gainailab = Label(ProbeAI, text="CA-I")
19419 gainailab.pack(side=LEFT)
19420 CHAIGainEntry = Entry(ProbeAI, width=5)
19421 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
19422 CHAIGainEntry.bind('<Key>', onTextKey)
19423 CHAIGainEntry.pack(side=LEFT)
19424 CHAIGainEntry.delete(0,"end")
19425 CHAIGainEntry.insert(0,1.0)
19426 CHAIOffsetEntry = Entry(ProbeAI, width=5)
19427 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
19428 CHAIOffsetEntry.bind('<Key>', onTextKey)
19429 CHAIOffsetEntry.pack(side=LEFT)
19430 CHAIOffsetEntry.delete(0,"end")
19431 CHAIOffsetEntry.insert(0,0.0)
19432 #
19433 ProbeBI = Frame( frame2r )
19434 ProbeBI.pack(side=TOP)
19435 gainbilab = Label(ProbeBI, text="CB-I")
19436 gainbilab.pack(side=LEFT)
19437 CHBIGainEntry = Entry(ProbeBI, width=5)
19438 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
19439 CHBIGainEntry.bind('<Key>', onTextKey)
19440 CHBIGainEntry.pack(side=LEFT)
19441 CHBIGainEntry.delete(0,"end")
19442 CHBIGainEntry.insert(0,1.0)
19443 CHBIOffsetEntry = Entry(ProbeBI, width=5)
19444 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
19445 CHBIOffsetEntry.bind('<Key>', onTextKey)
19446 CHBIOffsetEntry.pack(side=LEFT)
19447 CHBIOffsetEntry.delete(0,"end")
19448 CHBIOffsetEntry.insert(0,0.0)
19449 # add ADI logo Don't mess with this bit map data!
19450 ADIlogo = """
19451 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
19452 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
19453 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
19454 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
19455 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
19456 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
19457 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
19458 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
19459 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
19460 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
19461 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
19462 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
19463 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
19464 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
19465 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
19466 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
19467 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
19468 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
19469 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
19470 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
19471 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
19472 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
19473 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
19474 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
19475 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
19476 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
19477 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
19478 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
19479 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
19480 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
19481 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
19482 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
19483 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
19484 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
19485 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
19486 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
19487 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
19488 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
19489 """
19490 logo = PhotoImage(data=ADIlogo)
19491 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
19492 ADI1.pack(side=TOP)
19493 
19494 # Bottom Buttons
19495 # Voltage channel A
19496 CHAsb = Spinbox(frame3, width=4, values=CHvpdiv, command=BCHAlevel)
19497 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
19498 CHAsb.pack(side=LEFT)
19499 CHAsb.delete(0,"end")
19500 CHAsb.insert(0,0.5)
19501 #
19502 CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
19503 CHAlab.pack(side=LEFT)
19504 
19505 CHAVPosEntry = Entry(frame3, width=5)
19506 CHAVPosEntry.bind("<Return>", BOffsetA)
19507 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)
19508 CHAVPosEntry.bind('<Key>', onTextKey)
19509 CHAVPosEntry.pack(side=LEFT)
19510 CHAVPosEntry.delete(0,"end")
19511 CHAVPosEntry.insert(0,2.5)
19512 CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
19513 CHAofflab.pack(side=LEFT)
19514 # Current channel A
19515 CHAIsb = Spinbox(frame3, width=4, values=CHipdiv, command=BCHAIlevel)
19516 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
19517 CHAIsb.pack(side=LEFT)
19518 CHAIsb.delete(0,"end")
19519 CHAIsb.insert(0,50.0)
19520 CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
19521 CHAIlab.pack(side=LEFT)
19522 
19523 CHAIPosEntry = Entry(frame3, width=5)
19524 CHAIPosEntry.bind("<Return>", BIOffsetA)
19525 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)
19526 CHAIPosEntry.bind('<Key>', onTextKey)
19527 CHAIPosEntry.pack(side=LEFT)
19528 CHAIPosEntry.delete(0,"end")
19529 CHAIPosEntry.insert(0,0.0)
19530 CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
19531 CHAIofflab.pack(side=LEFT)
19532 # Voltage channel B
19533 CHBsb = Spinbox(frame3, width=4, values=CHvpdiv, command=BCHBlevel)
19534 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
19535 CHBsb.pack(side=LEFT)
19536 CHBsb.delete(0,"end")
19537 CHBsb.insert(0,0.5)
19538 #
19539 CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
19540 CHBlab.pack(side=LEFT)
19541 
19542 CHBVPosEntry = Entry(frame3, width=5)
19543 CHBVPosEntry.bind("<Return>", BOffsetB)
19544 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)
19545 CHBVPosEntry.bind('<Key>', onTextKey)
19546 CHBVPosEntry.pack(side=LEFT)
19547 CHBVPosEntry.delete(0,"end")
19548 CHBVPosEntry.insert(0,2.5)
19549 CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
19550 CHBofflab.pack(side=LEFT)
19551 # Current channel B
19552 CHBIsb = Spinbox(frame3, width=4, values=CHipdiv, command=BCHBIlevel)
19553 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
19554 CHBIsb.pack(side=LEFT)
19555 CHBIsb.delete(0,"end")
19556 CHBIsb.insert(0,50.0)
19557 CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
19558 CHBIlab.pack(side=LEFT)
19559 
19560 CHBIPosEntry = Entry(frame3, width=5)
19561 CHBIPosEntry.bind("<Return>", BIOffsetB)
19562 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)
19563 CHBIPosEntry.bind('<Key>', onTextKey)
19564 CHBIPosEntry.pack(side=LEFT)
19565 CHBIPosEntry.delete(0,"end")
19566 CHBIPosEntry.insert(0,0.0)
19567 CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
19568 CHBIofflab.pack(side=LEFT)
19569 #
19570 if ShowBallonHelp > 0:
19571  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
19572  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
19573  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
19574  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
19575  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
19576  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
19577  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
19578  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
19579 #
19580 root.geometry('+300+0')
19581 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
19582 #===== Initalize device ======
19583 if not numpy_found:
19584  root.update()
19585  showwarning("WARNING","Numpy not found!")
19586  root.destroy()
19587  exit()
19588 #
19589 BrdSel = IntVar(0)
19590 BoardStatus = IntVar(0)
19591 if pysmu_found:
19592  ConnectDevice()
19593  #session.hotplug_attach(ConnectDevice)
19594  #session.hotplug_detach(ConnectDevice)
19595  MakeAWGWindow() # always build AWG window
19596  BLoadConfig("alice-last-config.cfg") # load configuration from last session
19597 # ================ Call main routine ===============================
19598  root.update() # Activate updated screens
19599 #
19600 
19601 # Start sampling
19602  Analog_In()
19603 else:
19604  root.update()
19605  showwarning("WARNING","Pysmu not found!")
19606  root.destroy()
19607  exit()
19608 
alice-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-desktop-1.3-old.pyw:15741
alice-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-desktop-1.3-old.pyw:2021
alice-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-desktop-1.3-old.pyw:2054
alice-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-desktop-1.3-old.pyw:1964
alice-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-desktop-1.3-old.pyw:15076
alice-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-desktop-1.3-old.pyw:14955
alice-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-desktop-1.3-old.pyw:17670
alice-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-desktop-1.3-old.pyw:1448
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-old.pyw:2117
alice-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-desktop-1.3-old.pyw:17485
alice-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-desktop-1.3-old.pyw:17860
alice-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-desktop-1.3-old.pyw:15141
alice-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-desktop-1.3-old.pyw:2416
alice-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-desktop-1.3-old.pyw:11289
alice-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-desktop-1.3-old.pyw:8135
alice-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-desktop-1.3-old.pyw:4686
alice-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-desktop-1.3-old.pyw:1269
alice-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-desktop-1.3-old.pyw:13645
alice-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-desktop-1.3-old.pyw:2399
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-old.pyw:17705
alice-desktop-1.sel
def sel()
Definition: alice-desktop-1.3-old.pyw:4415
alice-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-desktop-1.3-old.pyw:9584
alice-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-desktop-1.3-old.pyw:16710
alice-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-desktop-1.3-old.pyw:2166
alice-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-desktop-1.3-old.pyw:12589
alice-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-desktop-1.3-old.pyw:10032
alice-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-desktop-1.3-old.pyw:10875
alice-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-desktop-1.3-old.pyw:18615
alice-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-desktop-1.3-old.pyw:17866
alice-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-desktop-1.3-old.pyw:10155
alice-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-desktop-1.3-old.pyw:5740
alice-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-desktop-1.3-old.pyw:8145
alice-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-desktop-1.3-old.pyw:2035
alice-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-desktop-1.3-old.pyw:12593
alice-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-desktop-1.3-old.pyw:17495
alice-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-desktop-1.3-old.pyw:13567
alice-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-desktop-1.3-old.pyw:10450
alice-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-desktop-1.3-old.pyw:9948
alice-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-desktop-1.3-old.pyw:18232
alice-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-desktop-1.3-old.pyw:8187
alice-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-desktop-1.3-old.pyw:2274
alice-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-desktop-1.3-old.pyw:12575
alice-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-desktop-1.3-old.pyw:18250
alice-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-desktop-1.3-old.pyw:9472
alice-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-desktop-1.3-old.pyw:2567
alice-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-desktop-1.3-old.pyw:12637
alice-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-desktop-1.3-old.pyw:11308
alice-desktop-1.BStopSA
def BStopSA()
Definition: alice-desktop-1.3-old.pyw:11207
alice-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-desktop-1.3-old.pyw:8179
alice-desktop-1.Analog_Fast_time
def Analog_Fast_time()
routine for time scales faster than 500 mSec/Div
Definition: alice-desktop-1.3-old.pyw:3119
alice-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-desktop-1.3-old.pyw:10953
alice-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-desktop-1.3-old.pyw:2578
alice-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-desktop-1.3-old.pyw:17421
alice-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-desktop-1.3-old.pyw:14062
alice-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-desktop-1.3-old.pyw:1804
alice-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-desktop-1.3-old.pyw:15971
alice-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-desktop-1.3-old.pyw:13548
alice-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-desktop-1.3-old.pyw:13529
alice-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-desktop-1.3-old.pyw:11024
alice-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-desktop-1.3-old.pyw:2073
alice-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-desktop-1.3-old.pyw:7579
alice-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-desktop-1.3-old.pyw:18260
alice-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-desktop-1.3-old.pyw:2505
alice-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-desktop-1.3-old.pyw:8799
alice-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-old.pyw:1539
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-old.pyw:2982
alice-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-desktop-1.3-old.pyw:13067
alice-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-desktop-1.3-old.pyw:8224
alice-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-desktop-1.3-old.pyw:11542
alice-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-desktop-1.3-old.pyw:14454
alice-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-desktop-1.3-old.pyw:17491
alice-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-desktop-1.3-old.pyw:14105
alice-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-desktop-1.3-old.pyw:2280
alice-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-desktop-1.3-old.pyw:1281
alice-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-desktop-1.3-old.pyw:13259
alice-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-desktop-1.3-old.pyw:16932
alice-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-desktop-1.3-old.pyw:14302
alice-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-desktop-1.3-old.pyw:9562
alice-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-desktop-1.3-old.pyw:10253
alice-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-desktop-1.3-old.pyw:13219
alice-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-desktop-1.3-old.pyw:14926
alice-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-desktop-1.3-old.pyw:18813
alice-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-desktop-1.3-old.pyw:11810
alice-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-desktop-1.3-old.pyw:14521
alice-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-desktop-1.3-old.pyw:9085
alice-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-desktop-1.3-old.pyw:14274
alice-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-desktop-1.3-old.pyw:8667
alice-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-desktop-1.3-old.pyw:8119
alice-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-desktop-1.3-old.pyw:13543
alice-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-desktop-1.3-old.pyw:9213
alice-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-desktop-1.3-old.pyw:17080
alice-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-desktop-1.3-old.pyw:14241
alice-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-desktop-1.3-old.pyw:9027
alice-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-desktop-1.3-old.pyw:18132
alice-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-desktop-1.3-old.pyw:15151
alice-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-desktop-1.3-old.pyw:8212
alice-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-desktop-1.3-old.pyw:10379
alice-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-desktop-1.3-old.pyw:2148
alice-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-desktop-1.3-old.pyw:2028
alice-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-desktop-1.3-old.pyw:2220
alice-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-desktop-1.3-old.pyw:8653
alice-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-desktop-1.3-old.pyw:14251
alice-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Move Time curcors right 1 or 5.
Definition: alice-desktop-1.3-old.pyw:7753
alice-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-desktop-1.3-old.pyw:14447
alice-desktop-1.CreateToolTip.tw
tw
Definition: alice-desktop-1.3-old.pyw:702
alice-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-desktop-1.3-old.pyw:14198
alice-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-desktop-1.3-old.pyw:13404
alice-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-desktop-1.3-old.pyw:17000
alice-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-desktop-1.3-old.pyw:4279
alice-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-desktop-1.3-old.pyw:8160
alice-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-desktop-1.3-old.pyw:10946
alice-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-desktop-1.3-old.pyw:8534
alice-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-desktop-1.3-old.pyw:9865
alice-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-desktop-1.3-old.pyw:4681
alice-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-desktop-1.3-old.pyw:1556
alice-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-desktop-1.3-old.pyw:2596
alice-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-desktop-1.3-old.pyw:2304
alice-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-desktop-1.3-old.pyw:1957
alice-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-desktop-1.3-old.pyw:2556
alice-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-desktop-1.3-old.pyw:17947
alice-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-desktop-1.3-old.pyw:1292
alice-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-desktop-1.3-old.pyw:14440
alice-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-desktop-1.3-old.pyw:1287
alice-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-desktop-1.3-old.pyw:17334
alice-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-desktop-1.3-old.pyw:8111
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-old.pyw:1625
alice-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-desktop-1.3-old.pyw:2262
font
alice-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-desktop-1.3-old.pyw:10634
alice-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-desktop-1.3-old.pyw:1368
alice-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-desktop-1.3-old.pyw:10580
alice-desktop-1.SetETSComp
def SetETSComp()
Definition: alice-desktop-1.3-old.pyw:18581
alice-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-desktop-1.3-old.pyw:18140
alice-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-desktop-1.3-old.pyw:7555
alice-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-desktop-1.3-old.pyw:9997
alice-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-desktop-1.3-old.pyw:13949
alice-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-desktop-1.3-old.pyw:9895
alice-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-desktop-1.3-old.pyw:8453
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-old.pyw:3738
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-old.pyw:3720
alice-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-desktop-1.3-old.pyw:17515
alice-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-desktop-1.3-old.pyw:7593
alice-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-desktop-1.3-old.pyw:14237
alice-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-desktop-1.3-old.pyw:14425
alice-desktop-1.sel1
def sel1(temp)
Definition: alice-desktop-1.3-old.pyw:4555
alice-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-desktop-1.3-old.pyw:9914
alice-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-desktop-1.3-old.pyw:17444
alice-desktop-1.CreateToolTip.widget
widget
Definition: alice-desktop-1.3-old.pyw:696
alice-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-desktop-1.3-old.pyw:2381
alice-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-desktop-1.3-old.pyw:17795
alice-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-desktop-1.3-old.pyw:1591
alice-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-desktop-1.3-old.pyw:17158
alice-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-desktop-1.3-old.pyw:17330
alice-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-desktop-1.3-old.pyw:2244
alice-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-desktop-1.3-old.pyw:10865
alice-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-desktop-1.3-old.pyw:14245
alice-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-desktop-1.3-old.pyw:2057
alice-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-desktop-1.3-old.pyw:17352
alice-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-desktop-1.3-old.pyw:16856
alice-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-desktop-1.3-old.pyw:13276
alice-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-desktop-1.3-old.pyw:2286
alice-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-desktop-1.3-old.pyw:11472
alice-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-desktop-1.3-old.pyw:1649
alice-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-desktop-1.3-old.pyw:9285
alice-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-desktop-1.3-old.pyw:4516
alice-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-desktop-1.3-old.pyw:14383
alice-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-desktop-1.3-old.pyw:8360
alice-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-desktop-1.3-old.pyw:694
alice-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-desktop-1.3-old.pyw:13227
alice-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-desktop-1.3-old.pyw:16755
alice-desktop-1.SyncImage
def SyncImage()
Definition: alice-desktop-1.3-old.pyw:15102
alice-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-desktop-1.3-old.pyw:8716
alice-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-desktop-1.3-old.pyw:2079
alice-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-desktop-1.3-old.pyw:14432
alice-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-desktop-1.3-old.pyw:14191
alice-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-desktop-1.3-old.pyw:2105
alice-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-desktop-1.3-old.pyw:2065
alice-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-desktop-1.3-old.pyw:13562
alice-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-desktop-1.3-old.pyw:15501
alice-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-desktop-1.3-old.pyw:10719
alice-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-desktop-1.3-old.pyw:4453
alice-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-desktop-1.3-old.pyw:9715
alice-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-desktop-1.3-old.pyw:14444
alice-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Move Time curcors left 1 or 5.
Definition: alice-desktop-1.3-old.pyw:7711
alice-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-desktop-1.3-old.pyw:1275
alice-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-desktop-1.3-old.pyw:10740
alice-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-desktop-1.3-old.pyw:2196
alice-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-desktop-1.3-old.pyw:15982
alice-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-desktop-1.3-old.pyw:13360
alice-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-desktop-1.3-old.pyw:14390
alice-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-desktop-1.3-old.pyw:8710
alice-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-desktop-1.3-old.pyw:14260
alice-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-desktop-1.3-old.pyw:17359
alice-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-desktop-1.3-old.pyw:14411
alice-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-desktop-1.3-old.pyw:8127
alice-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-desktop-1.3-old.pyw:10313
alice-desktop-1.CreateToolTip.id
id
Definition: alice-desktop-1.3-old.pyw:701
alice-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-desktop-1.3-old.pyw:17548
alice-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-desktop-1.3-old.pyw:10983
alice-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-desktop-1.3-old.pyw:2525
alice-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-desktop-1.3-old.pyw:14590
alice-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-desktop-1.3-old.pyw:8140
alice-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-desktop-1.3-old.pyw:11481
alice-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-desktop-1.3-old.pyw:9877
alice-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-desktop-1.3-old.pyw:17406
alice-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-desktop-1.3-old.pyw:17853
alice-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-desktop-1.3-old.pyw:14461
alice-desktop-1.BStartSA
def BStartSA()
Definition: alice-desktop-1.3-old.pyw:11170
alice-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-desktop-1.3-old.pyw:10989
alice-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-desktop-1.3-old.pyw:8491
alice-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-desktop-1.3-old.pyw:14436
alice-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-desktop-1.3-old.pyw:17615
alice-desktop-1.Blevel3
def Blevel3()
Definition: alice-desktop-1.3-old.pyw:11252
alice-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-desktop-1.3-old.pyw:11463
alice-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-desktop-1.3-old.pyw:1436
alice-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-desktop-1.3-old.pyw:14212
alice-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-desktop-1.3-old.pyw:745
alice-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-desktop-1.3-old.pyw:12010
alice-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-desktop-1.3-old.pyw:16704
alice-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-desktop-1.3-old.pyw:14418
alice-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-desktop-1.3-old.pyw:18067
alice-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-desktop-1.3-old.pyw:14515
alice-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-desktop-1.3-old.pyw:6829
alice-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-desktop-1.3-old.pyw:8155
alice-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-desktop-1.3-old.pyw:17355
alice-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-desktop-1.3-old.pyw:2643
alice-desktop-1.BStepSync
def BStepSync()
Definition: alice-desktop-1.3-old.pyw:15131
alice-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3-old.pyw:1679
alice-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-desktop-1.3-old.pyw:10513
alice-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-desktop-1.3-old.pyw:11533
alice-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-desktop-1.3-old.pyw:7836
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-old.pyw:2921
alice-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-desktop-1.3-old.pyw:18026
alice-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-desktop-1.3-old.pyw:16626
alice-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-desktop-1.3-old.pyw:13538
alice-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-desktop-1.3-old.pyw:16542
alice-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-desktop-1.3-old.pyw:4079
alice-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-desktop-1.3-old.pyw:4654
alice-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-desktop-1.3-old.pyw:16891
alice-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-desktop-1.3-old.pyw:2603
alice-desktop-1.CAresize
def CAresize(event)
Definition: alice-desktop-1.3-old.pyw:17505
alice-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-desktop-1.3-old.pyw:8203
alice-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-desktop-1.3-old.pyw:1983
alice-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-desktop-1.3-old.pyw:16717
alice-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-desktop-1.3-old.pyw:12255
alice-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-desktop-1.3-old.pyw:8175
alice-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-desktop-1.3-old.pyw:715
alice-desktop-1.sel0
def sel0(temp)
Definition: alice-desktop-1.3-old.pyw:4522
alice-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-desktop-1.3-old.pyw:2268
alice-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-desktop-1.3-old.pyw:10677
alice-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-desktop-1.3-old.pyw:14290
alice-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-desktop-1.3-old.pyw:14219
alice-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-desktop-1.3-old.pyw:17927
alice-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-desktop-1.3-old.pyw:10050
alice-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-desktop-1.3-old.pyw:9146
alice-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-desktop-1.3-old.pyw:11454
alice-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-desktop-1.3-old.pyw:18282
alice-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-desktop-1.3-old.pyw:11553
alice-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-desktop-1.3-old.pyw:2190
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-old.pyw:3758
alice-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-desktop-1.3-old.pyw:14397
alice-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-desktop-1.3-old.pyw:13266
alice-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-desktop-1.3-old.pyw:11318
alice-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-desktop-1.3-old.pyw:16449
alice-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-desktop-1.3-old.pyw:14600
alice-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-desktop-1.3-old.pyw:8643
alice-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-desktop-1.3-old.pyw:9834
alice-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-desktop-1.3-old.pyw:14404
alice-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-desktop-1.3-old.pyw:4676
alice-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-desktop-1.3-old.pyw:13394
alice-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-desktop-1.3-old.pyw:704
alice-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-desktop-1.3-old.pyw:9796
alice-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-desktop-1.3-old.pyw:2130
alice-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-desktop-1.3-old.pyw:4120
alice-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-desktop-1.3-old.pyw:17870
alice-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-desktop-1.3-old.pyw:14233
alice-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-desktop-1.3-old.pyw:11557
alice-desktop-1.DoFFT
def DoFFT()
Definition: alice-desktop-1.3-old.pyw:11560
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-old.pyw:7602
alice-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-desktop-1.3-old.pyw:693
alice-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-desktop-1.3-old.pyw:10899
alice-desktop-1.sel3
def sel3(temp)
Definition: alice-desktop-1.3-old.pyw:4621
alice-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-desktop-1.3-old.pyw:2618
alice-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-desktop-1.3-old.pyw:2184
alice-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-desktop-1.3-old.pyw:13057
alice-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-desktop-1.3-old.pyw:8346
alice-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-desktop-1.3-old.pyw:2208
alice-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-desktop-1.3-old.pyw:15196
alice-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-desktop-1.3-old.pyw:1569
alice-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-desktop-1.3-old.pyw:11511
alice-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-desktop-1.3-old.pyw:17152
alice-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-desktop-1.3-old.pyw:15481
alice-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-desktop-1.3-old.pyw:8413
alice-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-desktop-1.3-old.pyw:4691
alice-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-desktop-1.3-old.pyw:10973
alice-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-desktop-1.3-old.pyw:18621
alice-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-desktop-1.3-old.pyw:12585
alice-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-desktop-1.3-old.pyw:14948
alice-desktop-1.CreateToolTip.text
text
Definition: alice-desktop-1.3-old.pyw:697
alice-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-desktop-1.3-old.pyw:15750
alice-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-desktop-1.3-old.pyw:13557
alice-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-desktop-1.3-old.pyw:8522
alice-desktop-1.MGLoad
def MGLoad()
Definition: alice-desktop-1.3-old.pyw:18240
alice-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-desktop-1.3-old.pyw:10963
alice-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-desktop-1.3-old.pyw:17377
alice-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-desktop-1.3-old.pyw:8103
alice-desktop-1.Blevel1
def Blevel1()
Definition: alice-desktop-1.3-old.pyw:11234
alice-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-desktop-1.3-old.pyw:4706
alice-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-desktop-1.3-old.pyw:695
alice-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-desktop-1.3-old.pyw:9417
alice-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-desktop-1.3-old.pyw:9987
alice-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-desktop-1.3-old.pyw:2298
messagebox
alice-desktop-1.Blevel2
def Blevel2()
Definition: alice-desktop-1.3-old.pyw:11243
alice-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-desktop-1.3-old.pyw:2625
alice-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-desktop-1.3-old.pyw:17148
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-old.pyw:3772
alice-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-desktop-1.3-old.pyw:17257
alice-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-desktop-1.3-old.pyw:10197
alice-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-desktop-1.3-old.pyw:17383
alice-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-desktop-1.3-old.pyw:4290
alice-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Move Vertical cursors down 1 or 5.
Definition: alice-desktop-1.3-old.pyw:7669
alice-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-desktop-1.3-old.pyw:707
alice-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Pause / start on space bar.
Definition: alice-desktop-1.3-old.pyw:7795
alice-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-desktop-1.3-old.pyw:13233
alice-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-desktop-1.3-old.pyw:17327
alice-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-desktop-1.3-old.pyw:7543
alice-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-desktop-1.3-old.pyw:4128
alice-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-desktop-1.3-old.pyw:17621
alice-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-desktop-1.3-old.pyw:8874
alice-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-desktop-1.3-old.pyw:8949
alice-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-desktop-1.3-old.pyw:16564
alice-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-desktop-1.3-old.pyw:15110
alice-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-desktop-1.3-old.pyw:14267
alice-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-desktop-1.3-old.pyw:9743
alice-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-desktop-1.3-old.pyw:2292
alice-desktop-1.BSendGS
def BSendGS()
Definition: alice-desktop-1.3-old.pyw:17006
alice-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-desktop-1.3-old.pyw:14531
alice-desktop-1.Bnot
def Bnot()
Definition: alice-desktop-1.3-old.pyw:10936
alice-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-desktop-1.3-old.pyw:2042
alice-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-desktop-1.3-old.pyw:8165
alice-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-desktop-1.3-old.pyw:1442
alice-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-desktop-1.3-old.pyw:14476
alice-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-desktop-1.3-old.pyw:17986
alice-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-desktop-1.3-old.pyw:8170
alice-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-desktop-1.3-old.pyw:13965
alice-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-desktop-1.3-old.pyw:2632
alice-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-desktop-1.3-old.pyw:9517
alice-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-desktop-1.3-old.pyw:12761
alice-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-desktop-1.3-old.pyw:14484
alice-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-desktop-1.3-old.pyw:8991
alice-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-desktop-1.3-old.pyw:8602
alice-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-old.pyw:1503
alice-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-desktop-1.3-old.pyw:11537
alice-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-desktop-1.3-old.pyw:8552
alice-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-desktop-1.3-old.pyw:17459
alice-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-desktop-1.3-old.pyw:1630
alice-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digitla I/O screen.
Definition: alice-desktop-1.3-old.pyw:4409
alice-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-desktop-1.3-old.pyw:2535
alice-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-desktop-1.3-old.pyw:14054
alice-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-desktop-1.3-old.pyw:8377
alice-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-desktop-1.3-old.pyw:2232
alice-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-desktop-1.3-old.pyw:2202
alice-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-old.pyw:1484
alice-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-desktop-1.3-old.pyw:2589
alice-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-desktop-1.3-old.pyw:2463
alice-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-desktop-1.3-old.pyw:721
alice-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-desktop-1.3-old.pyw:11490
alice-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-desktop-1.3-old.pyw:2610
alice-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-desktop-1.3-old.pyw:15765
alice-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-desktop-1.3-old.pyw:1430
alice-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-desktop-1.3-old.pyw:10919
alice-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-desktop-1.3-old.pyw:10939
alice-desktop-1.donothing
def donothing()
Nop.
Definition: alice-desktop-1.3-old.pyw:2051
alice-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-desktop-1.3-old.pyw:8195
alice-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-desktop-1.3-old.pyw:2002
alice-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-desktop-1.3-old.pyw:14226
alice-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-desktop-1.3-old.pyw:5987
alice-desktop-1.BStopBP
def BStopBP()
Definition: alice-desktop-1.3-old.pyw:11432
alice-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-desktop-1.3-old.pyw:18366
alice-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-desktop-1.3-old.pyw:14254
alice-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-desktop-1.3-old.pyw:11143
alice-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-desktop-1.3-old.pyw:4696
alice-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-desktop-1.3-old.pyw:11500
alice-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-desktop-1.3-old.pyw:11518
alice-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-desktop-1.3-old.pyw:2328
alice-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-desktop-1.3-old.pyw:2256
alice-desktop-1.sel2
def sel2(temp)
Definition: alice-desktop-1.3-old.pyw:4588
alice-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-desktop-1.3-old.pyw:18805
alice-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-desktop-1.3-old.pyw:15122
alice-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-desktop-1.3-old.pyw:14468
alice-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-desktop-1.3-old.pyw:15491
alice-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-desktop-1.3-old.pyw:2799
ttk
alice-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-desktop-1.3-old.pyw:10085
alice-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-desktop-1.3-old.pyw:2139
alice-desktop-1.BSetFmin
def BSetFmin()
Definition: alice-desktop-1.3-old.pyw:18819
alice-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-desktop-1.3-old.pyw:691
alice-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-desktop-1.3-old.pyw:16949
alice-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-desktop-1.3-old.pyw:11270
alice-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3-old.pyw:1751
alice-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-desktop-1.3-old.pyw:7586
alice-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-desktop-1.3-old.pyw:8571
alice-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-desktop-1.3-old.pyw:17676
alice-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-desktop-1.3-old.pyw:17250
alice-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-desktop-1.3-old.pyw:10878
alice-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-desktop-1.3-old.pyw:16799
alice-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-desktop-1.3-old.pyw:711
alice-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-desktop-1.3-old.pyw:14527
alice-desktop-1.BStartBP
def BStartBP()
Definition: alice-desktop-1.3-old.pyw:11329
alice-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-desktop-1.3-old.pyw:17907
alice-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-desktop-1.3-old.pyw:11069
alice-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-desktop-1.3-old.pyw:7531
alice-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-old.pyw:1522
alice-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-desktop-1.3-old.pyw:14205
alice-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-desktop-1.3-old.pyw:18370
alice-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-desktop-1.3-old.pyw:1770
alice-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-desktop-1.3-old.pyw:4701
alice-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-desktop-1.3-old.pyw:14281
alice-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-desktop-1.3-old.pyw:16594
alice-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Move Vertical cursors up 1 or 5.
Definition: alice-desktop-1.3-old.pyw:7627
alice-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-desktop-1.3-old.pyw:10026
alice-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-desktop-1.3-old.pyw:11525
alice-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-desktop-1.3-old.pyw:1787
alice-desktop-1.Blevel4
def Blevel4()
Definition: alice-desktop-1.3-old.pyw:11261
alice-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-desktop-1.3-old.pyw:2545
alice-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-desktop-1.3-old.pyw:13387
alice-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-desktop-1.3-old.pyw:2477
alice-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-desktop-1.3-old.pyw:14257
alice-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-desktop-1.3-old.pyw:8734
alice-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-desktop-1.3-old.pyw:14248
alice-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-desktop-1.3-old.pyw:2515
alice-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-desktop-1.3-old.pyw:14094
alice-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-desktop-1.3-old.pyw:736
alice-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-desktop-1.3-old.pyw:2430
alice-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-desktop-1.3-old.pyw:16850
alice-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-desktop-1.3-old.pyw:8150
alice-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-desktop-1.3-old.pyw:14085
alice-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-desktop-1.3-old.pyw:14184
alice-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-desktop-1.3-old.pyw:9757
alice-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-desktop-1.3-old.pyw:7567
alice-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-desktop-1.3-old.pyw:9349
alice-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-desktop-1.3-old.pyw:1455
alice-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-desktop-1.3-old.pyw:18254