ALICE 1.3  1.0
Develpoer documentation
alice-desktop-1.3.1.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 urllib2
24 import struct
25 import subprocess
26 from time import gmtime, strftime
27 import tkFont
28 from Tkinter import *
29 from ttk import *
30 from tkFileDialog import askopenfilename
31 from tkFileDialog import asksaveasfilename
32 from tkSimpleDialog import askstring
33 from tkMessageBox import *
34 import webbrowser
35 try:
36  from pysmu import *
37  pysmu_found = True
38 except:
39  pysmu_found = False
40 #
41 # check which operating system
42 import platform
43 #
44 RevDate = "(2 March 2020)"
45 SWRev = "1.3 "
46 Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.1/alice-desktop-1.3-setup.exe'
47 # samll bit map of ADI logo for window icon
48 TBicon = """
49 R0lGODlhIAAgAHAAACH5BAEAAAIALAAAAAAgACAAgQAAAP///wAAAAAAAAJJhI+py+0PYwtBWkDp
50 hTnv2XlfEobjUZZnmn4se72vJMtcbYN4ruz44uORgiodsfI4Im++2M5VW81OmBbVULxiRVrUsgsO
51 i8fUAgA7
52 """
53 
54 root=Tk()
55 root.title("ALICE DeskTop " + SWRev + RevDate + ": ALM1000 Oscilloscope")
56 img = PhotoImage(data=TBicon)
57 root.call('wm', 'iconphoto', root._w, '-default', img)
58 
59 GRW = 720 # Width of the time grid 720 default
60 GRH = 390 # Height of the time grid 390 default
61 X0L = 55 # Left top X value of time grid
62 Y0T = 25 # Left top Y value of time grid
63 #
64 GRWF = 720 # Width of the spectrum grid 720 default
65 GRHF = 390 # Height of the spectrum grid 390 default
66 X0LF = 37 # Left top X value of spectrum grid
67 Y0TF = 25 # Left top Y value of spectrum grid
68 #
69 GRWBP = 720 # Width of the Bode Plot grid 720 default
70 GRHBP = 390 # Height of the Bode Plot grid 390 default
71 X0LBP = 37 # Left top X value of Bode Plot grid
72 Y0TBP = 25 # Left top Y value of Bode Plot grid
73 #
74 GRWXY = 420 # Width of the XY grid 420 default
75 GRHXY = 390 # Height of the XY grid 390 default
76 X0LXY = 37 # Left top X value of XY grid
77 Y0TXY = 25 # Left top Y value of XY grid
78 #
79 GRWIA = 400 # Width of the grid 400 default
80 GRHIA = 400 # Height of the grid 400 default
81 X0LIA = 37 # Left top X value of grid
82 Y0TIA = 25 # Left top Y value of grid
83 #
84 GRWNqP = 400 # Width of the Nyquist plot grid 400 default
85 GRHNqP = 400 # Height of the grid 400 default
86 X0LNqP = 25 # Left top X value of grid
87 Y0TNqP = 25 # Left top Y value of grid
88 #
89 GRWNiC = 400 # Width of the Nichols plot grid 400 default
90 GRHNiC = 400 # Height of the grid 400 default
91 X0LNiC = 25 # Left top X value of grid
92 Y0TNiC = 25 # Left top Y value of grid
93 #
94 FontSize = 8
95 MouseX = MouseY = -10
96 MouseCAV = MouseCAI = MouseCBV = MouseCBI = MouseMuxA = MouseMuxB = MouseMuxC = MouseMuxD = -10
97 
98 COLORframes = "#000080" # Color = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
99 COLORcanvas = "#000000" # 100% black
100 COLORgrid = "#808080" # 50% Gray
101 COLORzeroline = "#0000ff" # 100% blue
102 COLORtrace1 = "#00ff00" # 100% green
103 COLORtrace2 = "#ff8000" # 100% orange
104 COLORtrace3 = "#00ffff" # 100% cyan
105 COLORtrace4 = "#ffff00" # 100% yellow
106 COLORtrace5 = "#ff00ff" # 100% magenta
107 COLORtrace6 = "#C80000" # 90% red
108 COLORtrace7 = "#8080ff" # 100% purple
109 COLORtraceR1 = "#008000" # 50% green
110 COLORtraceR2 = "#905000" # 50% orange
111 COLORtraceR3 = "#008080" # 50% cyan
112 COLORtraceR4 = "#808000" # 50% yellow
113 COLORtraceR5 = "#800080" # 50% magenta
114 COLORtraceR6 = "#800000" # 80% red
115 COLORtraceR7 = "#4040a0" # 80% purple
116 COLORtext = "#ffffff" # 100% white
117 COLORtrigger = "#ff0000" # 100% red
118 COLORsignalband = "#ff0000" # 100% red
119 
120 OnBoardRes = 50.83
121 AD584act = 2.5
122 # Set sample buffer size
123 HoldOff = 0.0
124 LShift = 0
125 BaseSampleRate = 100000
126 AWGSAMPLErate = BaseSampleRate # Sample rate of the AWG channels
127 SAMPLErate = BaseSampleRate # Scope sample rate can be decimated
128 MinSamples = 2000
129 MaxSamples = 200000
130 # set initial trigger conditions
131 TRIGGERlevel = 2.5 # Triggerlevel in volts
132 
133 MathString = "VBuffA[t] + VBuffB[t]"
134 MathUnits = " V"
135 MathXString = "VBuffA[t]"
136 MathXUnits = " V"
137 MathYString = "VBuffB[t]"
138 MathYUnits = " V"
139 UserAString = "MaxV1-VATop"
140 UserALabel = "OverShoot"
141 UserBString = "MinV2-VBBase"
142 UserBLabel = "UnderShoot"
143 MathAxis = "V-A"
144 MathXAxis = "V-A"
145 MathYAxis = "V-B"
146 AWGAMathString = "(VBuffA + VBuffB)/2"
147 AWGBMathString = "(VBuffA + VBuffB)/2"
148 FFTUserWindowString = "numpy.kaiser(SMPfft, 14) * 3"
149 DigFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
150 DigFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
151 ChaMeasString1 = "DCV1"
152 ChaMeasString2 = "DCI1"
153 ChaMeasString3 = "SV1"
154 ChaMeasString4 = "MaxV1-MinV1"
155 ChaMeasString5 = "MaxI1-MinI1"
156 ChaMeasString6 = "math.sqrt(SV1**2 - DCV1**2)"
157 ChbMeasString1 = "DCV2"
158 ChbMeasString2 = "DCI2"
159 ChbMeasString3 = "SV2"
160 ChbMeasString4 = "MaxV2-MinV2"
161 ChbMeasString5 = "MaxI2-MinI2"
162 ChbMeasString6 = "math.sqrt(SV2**2 - DCV2**2)"
163 ChaLableSrring1 = "CHA-DCV "
164 ChaLableSrring2 = "CHA-DCI "
165 ChaLableSrring3 = "CHA-TRMS "
166 ChaLableSrring4 = "CHA-VP-P "
167 ChaLableSrring5 = "CHA-IP-P "
168 ChaLableSrring6 = "CHA-ACRMS "
169 ChbLableSrring1 = "CHB-DCV "
170 ChbLableSrring2 = "CHB-DCI "
171 ChbLableSrring3 = "CHB-TRMS "
172 ChbLableSrring4 = "CHB-VP-P "
173 ChbLableSrring5 = "CHB-IP-P "
174 ChbLableSrring6 = "CHB-ACRMS "
175 
176 GridWidth = IntVar(0)
177 GridWidth.set(1)
178 TRACEwidth = IntVar(0)
179 TRACEwidth.set(1)
180 TRACEaverage = IntVar(0) # Number of average sweeps for average mode
181 TRACEaverage.set(8)
182 Vdiv = IntVar(0)
183 Vdiv.set(10) # Number of vertical divisions for spectrum / Bode
184 HarmonicMarkers = IntVar(0)
185 HarmonicMarkers.set(3)
186 AWG_Amp_Mode = IntVar(0)
187 AWG_Amp_Mode.set(0) # 0 = Min/Max mode, 1 = Amp/Offset
188 AWG_2X = IntVar(0) # selection variable to set AWG DAC channes for 2X samplerate modes
189 Two_X_Sample = IntVar(0) # selection variable to set ADC channes for 2X samplerate mode
190 Two_X_Sample.set(0)
191 ADC_Mux_Mode = IntVar(0) # selection variable to set ADC CHA for voltagr or current 2X samplerate mode
192 ADC_Mux_Mode.set(0)
193 Last_ADC_Mux_Mode = 0
194 Alternate_Sweep_Mode = IntVar(0) # alternate sweeps when in 2X samplerate mode
195 Alternate_Sweep_Mode.set(0)
196 #
197 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
198 ZEROstuffing.set(1)
199 FFTwindow = IntVar(0) # FFT window function variable
200 FFTwindow.set(5) # FFTwindow 0=None (rectangular B=1), 1=Cosine (B=1.24), 2=Triangular non-zero endpoints (B=1.33),
201  # 3=Hann (B=1.5), 4=Blackman (B=1.73), 5=Nuttall (B=2.02), 6=Flat top (B=3.77)
202 RelPhaseCorrection = 15 # Relative Phase error seems to be a random number each time board is powered up
203 RelPhaseCenter = IntVar(0)
204 RelPhaseCenter.set(0) # Center line value for phase plots
205 ImpedanceCenter = IntVar(0)
206 ImpedanceCenter.set(0) # Center line value for impedance plots
207 MultipleBoards = IntVar(0)
208 MultipleBoards.set(0) # Turn on access for multiple m1k boards
209 IgnoreFirmwareCheck = 0
210 EnableCommandInterface = 0
211 EnableMuxMode = 1
212 EnablePIODACMode = 1
213 EnableMinigenMode = 0
214 EnablePmodDA1Mode = 0
215 EnableDigPotMode = 0
216 EnableGenericSerialMode = 0
217 EnableAD5626SerialMode = 0
218 EnableDigitalFilter = 0
219 EnableMeasureScreen = 0
220 EnableETSScreen = 0
221 EnableHSsampling = 0
222 AllowFlashFirmware = 0
223 DeBugMode = 0
224 # ADC Mux defaults
225 v1_adc_conf = 0x20F1
226 i1_adc_conf = 0x20F7
227 v2_adc_conf = 0x20F7
228 i2_adc_conf = 0x20F1
229 #
230 MouseFocus = 1
231 HistAsPercent = 0
232 ShowBallonHelp = 0
233 contloop = 0
234 discontloop = 0
235 AwgLayout = "Horz"
236 Style_String = 'alt'
237 MarkerLoc = 'UL' # can be UL, UR, LL or LR
238 CHA_TC1 = DoubleVar(0)
239 CHA_TC1.set(1)
240 CHA_TC2 = DoubleVar(0)
241 CHA_TC2.set(1)
242 CHB_TC1 = DoubleVar(0)
243 CHB_TC1.set(1)
244 CHB_TC2 = DoubleVar(0)
245 CHB_TC2.set(1)
246 CHA_A1 = DoubleVar(0)
247 CHA_A1.set(1)
248 CHA_A2 = DoubleVar(0)
249 CHA_A2.set(1)
250 CHB_A1 = DoubleVar(0)
251 CHB_A1.set(1)
252 CHB_A2 = DoubleVar(0)
253 CHB_A2.set(1)
254 PhaseOffset1x = 37
255 PhaseOffset2x = 37
256 # Check if there is an alice_init.ini file to read in
257 try:
258  InitFile = open("alice_init.ini")
259  for line in InitFile:
260  try:
261  exec( line.rstrip() )
262  except:
263  print("Skiping " + line.rstrip())
264  InitFile.close()
265 except:
266  print( "No Init File Read")
267 #
268 X0L = FontSize * 7
269 XOLF = XOLBP = XOLXY = XOLIA = int(FontSize * 4.625)
270 XOLNqP = XOLNiC = int(FontSize * 3.125)
271 root.style = Style()
272 #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
273 try:
274  root.style.theme_use(Style_String)
275 except:
276  root.style.theme_use('default')
277 if MouseFocus == 1:
278  root.tk_focusFollowsMouse()
279 #
280 DevID = "m1k"
281 #
282 default_font = tkFont.nametofont("TkDefaultFont")
283 default_font.configure(size=FontSize)
284 
285 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)
286 
287 CHipdiv = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
288 
289 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)
290 ResScalediv = (1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000)
291 SampRateList = (1024, 2048, 4096, 8192, 16384, 32765, 64000, 96385, 96774, 97166, 97561, 97959, 98361, 98765, 99174, 99585, 100000)
292 
293 AWGAAmplvalue = 0.0
294 AWGAOffsetvalue = 0.0
295 AWGAFreqvalue = 0.0
296 AWGAPhasevalue = 0
297 AWGAdelayvalue = 0
298 AWGADutyCyclevalue = 50
299 AWGAWave = 'dc'
300 AWGBAmplvalue = 0.0
301 AWGBOffsetvalue = 0.0
302 AWGBFreqvalue = 0.0
303 AWGBPhasevalue = 0
304 AWGBdelayvalue = 0
305 AWGBDutyCyclevalue = 50
306 AWGBWave = 'dc'
307 AWGACycles = 1
308 AWGBCycles = 1
309 AWGABurstDelay = 0
310 AWGBBurstDelay = 0
311 Reset_Freq = 300
312 MeasGateLeft = 0.0
313 MeasGateRight = 0.0 # in mSec
314 MeasGateNum = 0
315 MeasGateStatus = IntVar(0)
316 MeasGateStatus.set(0)
317 #
318 DCV1 = DCV2 = MinV1 = MaxV1 = MinV2 = MaxV2 = MidV1 = PPV1 = MidV2 = PPV2 = SV1 = SI1 = 0
319 
320 DCVMuxA = MinVMuxA = MaxVMuxA = MidVMuxA = PPVMuxA = SVMuxA = 0
321 DCVMuxB = MinVMuxB = MaxVMuxB = MidVMuxB = PPVMuxB = SVMuxB = 0
322 DCVMuxC = MinVMuxC = MaxVMuxC = MidVMuxC = PPVMuxC = SVMuxC = 0
323 DCVMuxD = MinVMuxD = MaxVMuxD = MidVMuxD = PPVMuxD = SVMuxD = 0
324 DCI1 = DCI2 = MinI1 = MaxI1 = MinI2 = MaxI2 = MidI1 = PPI1 = MidI2 = PPI2 = SV2 = SI2 = 0
325 CHAperiod = CHAfreq = CHBperiod = CHBfreq = 0
326 # Calibration coefficients
327 CHAVGain = CHBVGain = 1.0
328 CHAVOffset = CHBVOffset = 0.0
329 # Initialisation of general variables
330 CHAOffset = CHBOffset = CHBAOffset = CHBBOffset = CHBCOffset = CHBDOffset = 2.5
331 CHAIOffset = CHBIOffset = InOffA = InGainA = InOffB = InGainB = 0.0
332 # Other global variables required in various routines
333 CANVASwidth = GRW + 2 * X0L # The canvas width
334 CANVASheight = GRH + Y0T + (FontSize * 7) # The canvas height
335 
336 ADsignal1 = [] # Ain signal array channel A and B
337 VBuffA = []
338 VBuffB = []
339 IBuffA = []
340 IBuffB = []
341 MBuff = []
342 MBuffX = []
343 MBuffY = []
344 VBuffMA = []
345 VBuffMB = []
346 VBuffMC = []
347 VBuffMD = []
348 VmemoryMuxA = []
349 VmemoryMuxB = []
350 VmemoryMuxC = []
351 VmemoryMuxD = []
352 #
353 DFiltACoef = [1]
354 DFiltBCoef = [1]
355 DigFiltA = IntVar(0)
356 DigFiltA.set(0)
357 DigFiltABoxCar = IntVar(0)
358 DigFiltBBoxCar = IntVar(0)
359 DigFiltB = IntVar(0)
360 DigFiltB.set(0)
361 DigBuffA = IntVar(0)
362 DigBuffB = IntVar(0)
363 DigBuffA.set(0)
364 DigBuffB.set(0)
365 VFilterA = {}
366 VFilterB = {}
367 SampleRateStatus = IntVar(0)
368 ETSStatus = IntVar(0)
369 ETSDisp = IntVar(0)
370 ETSDir = IntVar(0)
371 #
372 AWGAwaveform = []
373 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
374 AWGBwaveform = []
375 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
376 VmemoryA = numpy.ones(1) # The memory for averaging
377 VmemoryB = numpy.ones(1)
378 ImemoryA = numpy.ones(1) # The memory for averaging
379 ImemoryB = numpy.ones(1)
380 TRACEresetTime = True # True for first new trace, false for averageing
381 TRACEresetFreq = True # True for first new trace, false for averageing
382 AWGScreenStatus = IntVar(0)
383 
384 T1Vline = [] # Voltage Trace line channel A
385 T2Vline = [] # Voltage Trace line channel B
386 T1Iline = [] # Current Trace line channel A
387 T2Iline = [] # Current Trace line channel B
388 TMAVline = [] # Voltage Trace line MUX channel A
389 TMBVline = [] # Voltage Trace line MUX channel B
390 TMCVline = [] # Voltage Trace line MUX channel C
391 TMDVline = [] # Voltage Trace line MUX channel D
392 TMBRline = [] # V reference Trace line MUX channel B
393 TMCRline = [] # V reference line MUX channel C
394 TXYline = [] # XY Trace line
395 TXYRline = [] # XY reference trace line
396 Tmathline = [] # Math trace line
397 TMXline = [] # X math Trace line
398 TMYline = [] # Y math Trace line
399 T1VRline = [] # V reference Trace line channel A
400 T2VRline = [] # V reference Trace line channel B
401 T1IRline = [] # I reference Trace line channel A
402 T2IRline = [] # I reference Trace line channel B
403 TMRline = [] # Math reference Trace line
404 Triggerline = [] # Triggerline
405 Triggersymbol = [] # Trigger symbol
406 #
407 SHOWsamples = 4000 # Number of samples on the screen
408 SCstart = 0 # Start sample of the trace
409 HozPoss = 0.0
410 Is_Triggered = 0
411 #
412 TRACES = 1 # Number of traces 1 or 2
413 TRACESread = 0 # Number of traces that have been read from ALM
414 ScreenTrefresh = IntVar(0)
415 ScreenXYrefresh = IntVar(0)
416 #
417 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
418 ZEROstuffing.set(1)
419 NSteps = IntVar(0) # number of frequency sweep steps
420 NSteps.set(128)
421 LoopNum = IntVar(0)
422 LoopNum.set(1)
423 LastWindow = -1
424 LastSMPfft = 0
425 CurrentFreqX = X0LBP + 14
426 FBins = numpy.linspace(0, 50000, num=16384)
427 FStep = numpy.linspace(0, 16384, num=NSteps.get())
428 FSweepMode = IntVar(0)
429 FSweepCont = IntVar(0)
430 FStepSync = IntVar(0)
431 FSweepSync = IntVar(0)
432 ShowCA_VdB = IntVar(0) # curves to display variables
433 ShowCA_P = IntVar(0)
434 ShowCB_VdB = IntVar(0)
435 ShowCB_P = IntVar(0)
436 ShowMarkerBP = IntVar(0)
437 ShowCA_RdB = IntVar(0)
438 ShowCA_RP = IntVar(0)
439 ShowCB_RdB = IntVar(0)
440 ShowCB_RP = IntVar(0)
441 ShowMathBP = IntVar(0)
442 ShowRMathBP = IntVar(0)
443 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
444 FSweepAdB = []
445 FSweepBdB = []
446 FSweepAPh = []
447 FSweepBPh = []
448 NSweepSeriesR = []
449 NSweepSeriesX = []
450 NSweepSeriesMag = [] # in ohms
451 NSweepSeriesAng = [] # in degrees
452 NetworkScreenStatus = IntVar(0)
453 BDSweepFile = IntVar(0)
454 FileSweepFreq = []
455 FileSweepAmpl = []
456 #
457 MarkerNum = MarkerFreqNum = 0
458 ShowTCur = IntVar(0)
459 ShowVCur = IntVar(0)
460 TCursor = VCursor = 0
461 ShowXCur = IntVar(0)
462 ShowYCur = IntVar(0)
463 XCursor = YCursor = 0
464 ShowFCur = IntVar(0)
465 ShowdBCur = IntVar(0)
466 FCursor = dBCursor = 0
467 ShowBPCur = IntVar(0)
468 ShowBdBCur = IntVar(0)
469 BPCursor = BdBCursor = 0
470 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
471 PowerStatus = 1
472 TRIGGERsample = 0 # AD sample trigger point
473 DX = 0 # interpolated trigger point
474 
475 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
476 DBdivindex = IntVar(0) # 10 dB/div as initial value
477 DBdivindex.set(4)
478 DBlevel = IntVar(0) # Reference level
479 DBlevel.set(0)
480 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
481 DBdivindexBP.set(4)
482 DBlevelBP = IntVar(0) # Reference level
483 DBlevelBP.set(0)
484 hldn = 0
485 SpectrumScreenStatus = IntVar(0)
486 SmoothCurvesSA = IntVar(0)
487 SmoothCurvesBP = IntVar(0)
488 CutDC = IntVar(0)
489 IAScreenStatus = IntVar(0)
490 NqPScreenStatus = IntVar(0)
491 NqPDisp = IntVar(0)
492 NiCScreenStatus = IntVar(0)
493 NiCDisp = IntVar(0)
494 ImpedanceMagnitude = 0.0 # in ohms
495 ImpedanceAngle = 0.0 # in degrees
496 ImpedanceRseries = 0.0 # in ohms
497 ImpedanceXseries = 0.0 # in ohms
498 Show_Rseries = IntVar(0)
499 Show_Xseries = IntVar(0)
500 Show_Magnitude = IntVar(0)
501 Show_Angle = IntVar(0)
502 Show_RseriesRef = IntVar(0)
503 Show_XseriesRef = IntVar(0)
504 Show_MagnitudeRef = IntVar(0)
505 Show_AngleRef = IntVar(0)
506 
507 TIARline = []
508 TIAXline = []
509 TIAMagline = []
510 TIAAngline = []
511 TIAMline = []
512 TIAMRline = []
513 RefIARline = []
514 RefIAXline = []
515 RefIAMagline = []
516 RefIAAngline = []
517 IASource = IntVar(0)
518 
519 DisplaySeries = IntVar(0)
520 IA_Ext_Conf = IntVar(0)
521 IASweepSaved = IntVar(0)
522 OverRangeFlagA = 0
523 OverRangeFlagB = 0
524 PeakdbA = 10
525 PeakdbB = 10
526 PeakRelPhase = 0.0
527 PeakfreqA = 100
528 PeakfreqB = 1000
529 OhmStatus = IntVar(0)
530 OhmRunStatus = IntVar(0)
531 FFTbandwidth = 0 # The FFT bandwidth
532 FFTBuffA = [] # Clear the FFTBuff array for trace A
533 FFTBuffB = [] # Clear the FFTBuff array for trace B
534 FFTresultA = [] # FFT result CHA
535 PhaseA = []
536 FFTresultB = [] # FFT result CHB
537 PhaseB = []
538 FFTresultAB = []
539 FFTwindowname = "--" # The FFT window name
540 FFTmemoryA = numpy.ones(1) # The memory for averaging
541 PhaseMemoryA = numpy.ones(1)
542 FFTmemoryB = numpy.ones(1) # The memory for averaging
543 PhaseMemoryB = numpy.ones(1)
544 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
545 SMPfftpwrTwo.set(11)
546 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
547 Two28 = 268435456
548 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
549 
550 T1Fline = [] # Frequency Trace line channel A
551 T2Fline = [] # Frequency Trace line channel B
552 T1Pline = [] # Phase angle Trace line channel A - B
553 T2Pline = [] # Phase angle Trace line channel B - A
554 T1FRline = [] # F reference Trace line channel A
555 T2FRline = [] # F reference Trace line channel B
556 T1PRline = [] # Phase reference Trace line channel A - B
557 T2PRline = [] # Phase reference Trace line channel B - A
558 TFMline = [] # Frequency Math Trace
559 TFRMline = [] # Frequency reference Math Trace
560 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
561 FreqTraceMode.set(1)
562 
563 TAFline = [] # Bode Freq Trace line channel A
564 TBFline = [] # Bode Freq Trace line channel B
565 TAPline = [] # Bode Phase angle Trace line channel A - B
566 TBPline = [] # Bode Phase angle Trace line channel B - A
567 TAFRline = [] # Bode F reference Trace line channel A
568 TBFRline = [] # Bode F reference Trace line channel B
569 TAPRline = [] # Bode Phase reference Trace line channel A - B
570 TBPRline = [] # Bode Phase reference Trace line channel B - A
571 TBPMline = [] # Bode Frequency Math Trace
572 TBPRMline = [] # Bode Frequency reference Math Trace
573 #
574 MinSamplesSA = 64
575 MaxSamplesSA = 65536
576 #
577 MathScreenStatus = IntVar(0)
578 #
579 XYScreenStatus = IntVar(0)
580 Xsignal = IntVar(0) # Signal for X axis variable
581 Xsignal.set(1)
582 Ysignal = IntVar(0) # Signal for X axis variable
583 Ysignal.set(3)
584 ShowRXY = IntVar(0) # show reference XY trace
585 # show Analog Input Mux Variables
586 Show_CBA = IntVar(0)
587 Show_CBB = IntVar(0)
588 Show_CBC = IntVar(0)
589 Show_CBD = IntVar(0)
590 D0 = IntVar(0)
591 D1 = IntVar(0)
592 D2 = IntVar(0)
593 D3 = IntVar(0)
594 D4 = IntVar(0)
595 D5 = IntVar(0)
596 D6 = IntVar(0)
597 D7 = IntVar(0)
598 PIO_0 = 28
599 PIO_1 = 29
600 PIO_2 = 47
601 PIO_3 = 3
602 PIO_4 = 4
603 PIO_5 = 5
604 PIO_6 = 6
605 PIO_7 = 7
606 #
607 SCLKPort = IntVar(0)
608 SDATAPort = IntVar(0)
609 SLATCHPort = IntVar(0)
610 
611 
612 hipulse = """
613 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
614 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
615 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
616 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
617 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
618 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
619 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
620 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
621 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
622 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
623 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
624 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
625 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
626 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
627 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
628 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
629 """
630 hipulseimg = PhotoImage(data=hipulse)
631 
632 lowpulse = """
633 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
634 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
635 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
636 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
637 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
638 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
639 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
640 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
641 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
642 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
643 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
644 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
645 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
646 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
647 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
648 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
649 """
650 lowpulseimg = PhotoImage(data=lowpulse)
651 
652 class CreateToolTip(object):
653 
654  def __init__(self, widget, text='widget info'):
655  self.waittime = 500 #miliseconds
656  self.wraplength = 100 #pixels
657  self.widget = widget
658  self.text = text
659  self.widget.bind("<Enter>", self.enter)
660  self.widget.bind("<Leave>", self.leave)
661  self.widget.bind("<ButtonPress>", self.leave)
662  self.id = None
663  self.tw = None
664 
665  def enter(self, event=None):
666  self.schedule()
667 
668  def leave(self, event=None):
669  self.unschedule()
670  self.hidetip()
671 
672  def schedule(self):
673  self.unschedule()
674  self.id = self.widget.after(self.waittime, self.showtip)
675 
676  def unschedule(self):
677  id = self.id
678  self.id = None
679  if id:
680  self.widget.after_cancel(id)
681 
682  def showtip(self, event=None):
683  x = y = 0
684  x, y, cx, cy = self.widget.bbox("insert")
685  x += self.widget.winfo_rootx() + 25
686  y += self.widget.winfo_rooty() + 20
687  # creates a toplevel window
688  self.tw = Toplevel(self.widget)
689  # Leaves only the label and removes the app window
690  self.tw.wm_overrideredirect(True)
691  self.tw.wm_geometry("+%d+%d" % (x, y))
692  label = Label(self.tw, text=self.text, justify='left',
693  background="#ffffe0", relief='solid', borderwidth=1,
694  wraplength = self.wraplength)
695  label.pack(ipadx=1)
696 
697  def hidetip(self):
698  tw = self.tw
699  self.tw= None
700  if tw:
701  tw.destroy()
702 #
703 # =========== Start widgets routines =============================
704 
706 def BSaveConfig(filename):
707  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
708  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
709  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
710  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
711  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
712  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
713  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
714  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
715  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
716  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
717  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
718  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
719  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
720  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
721  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
722  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
723  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
724  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
725  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
726  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
727  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
728  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
729  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
730  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
731  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
732  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
733  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
734  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
735  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
736  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode
737  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
738  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
739  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
740  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
741  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
742  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
743  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
744  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
745  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
746  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
747  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
748  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
749  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
750  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
751  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
752  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
753  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
754  global AWGABurstFlag, AWGACycles, AWGABurstDelay
755  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
756  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
757 
758  # open Config file for Write
759  ConfgFile = open(filename, "w")
760  # Save Window placements
761  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
762  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
763  ConfgFile.write('global GRW; GRW = ' + str(GRW) + '\n')
764  ConfgFile.write('global GRH; GRH = ' + str(GRH) + '\n')
765  # Windows configuration
766  ConfgFile.write('global MathString; MathString = "' + MathString + '"\n')
767  ConfgFile.write('global MathUnits; MathUnits = "' + MathUnits + '"\n')
768  ConfgFile.write('global MathAxis; MathAxis = "' + MathAxis + '"\n')
769  ConfgFile.write('global MathXString; MathXString = "' + MathXString + '"\n')
770  ConfgFile.write('global MathXUnits; MathXUnits = "' + MathXUnits + '"\n')
771  ConfgFile.write('global MathXAxis; MathXAxis = "' + MathXAxis + '"\n')
772  ConfgFile.write('global MathYString; MathYString = "' + MathYString + '"\n')
773  ConfgFile.write('global MathYUnits; MathYUnits = "' + MathYUnits + '"\n')
774  ConfgFile.write('global MathYAxis; MathYAxis = "' + MathYAxis + '"\n')
775  if MathScreenStatus.get() > 0:
776  ConfgFile.write('NewEnterMathControls()\n')
777  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
778  else:
779  ConfgFile.write('DestroyMathScreen()\n')
780  if XYScreenStatus.get() > 0:
781  ConfgFile.write('global GRWXY; GRWXY = ' + str(GRWXY) + '\n')
782  ConfgFile.write('global GRHXY; GRHXY = ' + str(GRHXY) + '\n')
783  ConfgFile.write('MakeXYWindow()\n')
784  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
785  ConfgFile.write('CHAsbxy.delete(0,END)\n')
786  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
787  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
788  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
789  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
790  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
791  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
792  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
793  ConfgFile.write('CHBsbxy.delete(0,END)\n')
794  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
795  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
796  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
797  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
798  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
799  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
800  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
801  else:
802  ConfgFile.write('DestroyXYScreen()\n')
803  if IAScreenStatus.get() > 0:
804  ConfgFile.write('global GRWIA; GRWIA = ' + str(GRWIA) + '\n')
805  ConfgFile.write('global GRHIA; GRHIA = ' + str(GRHIA) + '\n')
806  ConfgFile.write('MakeIAWindow()\n')
807  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
808  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
809  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
810  ConfgFile.write('RsystemEntry.delete(0,END)\n')
811  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
812  ConfgFile.write('ResScale.delete(0,END)\n')
813  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
814  ConfgFile.write('GainCorEntry.delete(0,END)\n')
815  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
816  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
817  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
818  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
819  else:
820  ConfgFile.write('DestroyIAScreen()\n')
821  if SpectrumScreenStatus.get() > 0:
822  ConfgFile.write('global GRWF; GRWF = ' + str(GRWF) + '\n')
823  ConfgFile.write('global GRHF; GRHF = ' + str(GRHF) + '\n')
824  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
825  ConfgFile.write('MakeSpectrumWindow()\n')
826  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
827  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
828  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
829  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
830  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
831  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
832  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
833  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
834  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
835  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
836  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
837  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
838  else:
839  ConfgFile.write('DestroySpectrumScreen()\n')
840  if DacScreenStatus.get() > 0:
841  ConfgFile.write('MakeDacScreen()\n')
842  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
843  else:
844  ConfgFile.write('DestroyDacScreen()\n')
845  if DigScreenStatus.get() > 0:
846  ConfgFile.write('MakeDigScreen()\n')
847  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
848  else:
849  ConfgFile.write('DestroyDigScreen()\n')
850  if EnableHSsampling > 0:
851  ConfgFile.write('FminEntry.delete(0,"end")\n')
852  ConfgFile.write('FminEntry.insert(0, ' + FminEntry.get() + ')\n')
853  ConfgFile.write('HtMulEntry.delete(0,"end")\n')
854  ConfgFile.write('HtMulEntry.insert(0, ' + HtMulEntry.get() + ')\n')
855  if MinigenScreenStatus.get() == 1:
856  ConfgFile.write('MakeMinigenWindow()\n')
857  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
858  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
859  ConfgFile.write('MinigenFout.delete(0,END)\n')
860  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
861  ConfgFile.write('MinigenFclk.delete(0,END)\n')
862  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
863  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
864  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
865  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
866  else:
867  ConfgFile.write('DestroyMinigenScreen()\n')
868  if MuxScreenStatus.get() == 1:
869  ConfgFile.write('MakeMuxModeWindow()\n')
870  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
871  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
872  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
873  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
874  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
875  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
876  ConfgFile.write('CHB_Asb.delete(0,END)\n')
877  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
878  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
879  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
880  ConfgFile.write('CHB_Csb.delete(0,END)\n')
881  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
882  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
883  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
884  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
885  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
886  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
887  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
888  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
889  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
890  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
891  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
892  else:
893  ConfgFile.write('DestroyMuxScreen()\n')
894  if BodeScreenStatus.get() == 1:
895  ConfgFile.write('global GRWBP; GRWBP = ' + str(GRWBP) + '\n')
896  ConfgFile.write('global GRHBP; GRHBP = ' + str(GRHBP) + '\n')
897  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
898  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
899  ConfgFile.write('MakeBodeWindow()\n')
900  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
901  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
902  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
903  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
904  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
905  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
906  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
907  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
908  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
909  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
910  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
911  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
912  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
913  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
914  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
915  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
916  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
917  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
918  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
919  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
920  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
921  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
922  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
923  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
924  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
925  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
926  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
927  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
928  else:
929  ConfgFile.write('DestroyBodeScreen()\n')
930  if MeasureStatus.get() == 1:
931  # Save strings
932  ConfgFile.write('global ChaLableSrring1; ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
933  ConfgFile.write('global ChaLableSrring2; ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
934  ConfgFile.write('global ChaLableSrring3; ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
935  ConfgFile.write('global ChaLableSrring4; ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
936  ConfgFile.write('global ChaLableSrring5; ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
937  ConfgFile.write('global ChaLableSrring6; ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
938  ConfgFile.write('global ChbLableSrring1; ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
939  ConfgFile.write('global ChbLableSrring2; ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
940  ConfgFile.write('global ChbLableSrring3; ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
941  ConfgFile.write('global ChbLableSrring4; ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
942  ConfgFile.write('global ChbLableSrring5; ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
943  ConfgFile.write('global ChbLableSrring6; ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
944  ConfgFile.write('global ChaMeasString1; ChaMeasString1 = "' + ChaMeasString1 + '"\n')
945  ConfgFile.write('global ChaMeasString2; ChaMeasString2 = "' + ChaMeasString2 + '"\n')
946  ConfgFile.write('global ChaMeasString3; ChaMeasString3 = "' + ChaMeasString3 + '"\n')
947  ConfgFile.write('global ChaMeasString4; ChaMeasString4 = "' + ChaMeasString4 + '"\n')
948  ConfgFile.write('global ChaMeasString5; ChaMeasString5 = "' + ChaMeasString5 + '"\n')
949  ConfgFile.write('global ChaMeasString6; ChaMeasString6 = "' + ChaMeasString6 + '"\n')
950  ConfgFile.write('global ChbMeasString1; ChbMeasString1 = "' + ChbMeasString1 + '"\n')
951  ConfgFile.write('global ChbMeasString2; ChbMeasString2 = "' + ChbMeasString2 + '"\n')
952  ConfgFile.write('global ChbMeasString3; ChbMeasString3 = "' + ChbMeasString3 + '"\n')
953  ConfgFile.write('global ChbMeasString4; ChbMeasString4 = "' + ChbMeasString4 + '"\n')
954  ConfgFile.write('global ChbMeasString5; ChbMeasString5 = "' + ChbMeasString5 + '"\n')
955  ConfgFile.write('global ChbMeasString6; ChbMeasString6 = "' + ChbMeasString6 + '"\n')
956  ConfgFile.write('MakeMeasureScreen()\n')
957  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
958  else:
959  ConfgFile.write('DestroyMeasuewScreen()\n')
960  if ETSStatus.get() == 1: #
961  ConfgFile.write('MakeETSWindow()\n')
962  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
963  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
964  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
965  ConfgFile.write('FMulXEntry.delete(0,END)\n')
966  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
967  ConfgFile.write('DivXEntry.delete(0,END)\n')
968  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
969  ConfgFile.write('ETSts.delete(0,END)\n')
970  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
971  else:
972  ConfgFile.write('DestroyETSScreen()\n')
973  #
974  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
975  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
976  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
977  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
978  ConfgFile.write('HozPossentry.delete(0,"end")\n')
979  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
980  ConfgFile.write('TMsb.delete(0,END)\n')
981  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
982  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
983  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
984  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
985  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
986  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
987  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
988  ConfgFile.write('Ysignal.set(' + str(Ysignal.get()) + ')\n')
989  #
990  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
991  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
992  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
993  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
994  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
995  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
996  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
997  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
998  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
999  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
1000  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
1001  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
1002  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
1003  #
1004  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
1005  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
1006  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
1007  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1008  ConfgFile.write('CHAsb.delete(0,END)\n')
1009  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1010  ConfgFile.write('CHAIsb.delete(0,END)\n')
1011  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1012  #
1013  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1014  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1015  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1016  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1017  ConfgFile.write('CHBsb.delete(0,END)\n')
1018  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1019  ConfgFile.write('CHBIsb.delete(0,END)\n')
1020  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1021  # AWG stuff
1022  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1023  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1024  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1025  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1026  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1027  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1028  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1029  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1030  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1031  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1032  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1033  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1034  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1035  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1036  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1037  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1038  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1039  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1040  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1041  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1042  #
1043  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1044  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1045  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1046  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1047  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1048  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1049  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1050  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1051  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1052  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1053  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1054  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1055  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1056  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1057  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1058  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1059  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1060  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1061  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1062  #
1063  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1064  #
1065  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1066  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1067  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1068  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1069  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1070  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1071  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1072  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1073  #
1074  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1075  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1076  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1077  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1078  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1079  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1080  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1081  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1082  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1083  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1084  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1085  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1086  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1087  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1088  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1089  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1090  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1091  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1092  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1093  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1094  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1095  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1096  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1097  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1098  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1099  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1100  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1101  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1102  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1103  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1104  #
1105  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1106  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1107  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1108  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1109  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1110  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1111  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1112  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1113  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1114  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1115  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1116  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1117  #
1118  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1119  #
1120  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1121  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1122  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1123  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1124  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1125  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1126  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1127  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1128  # Save strings
1129  ConfgFile.write('global UserAString; UserAString = "' + UserAString + '"\n')
1130  ConfgFile.write('global UserALabel; UserALabel = "' + UserALabel + '"\n')
1131  ConfgFile.write('global UserBString; UserBString = "' + UserBString + '"\n')
1132  ConfgFile.write('global UserBLabel; UserBLabel = "' + UserBLabel + '"\n')
1133  ConfgFile.write('global AWGAMathString; AWGAMathString = "' + AWGAMathString + '"\n')
1134  ConfgFile.write('global AWGBMathString; AWGBMathString = "' + AWGBMathString + '"\n')
1135  ConfgFile.write('global FFTUserWindowString; FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1136  ConfgFile.write('global DigFilterAString; DigFilterAString = "' + DigFilterAString + '"\n')
1137  ConfgFile.write('global DigFilterBString; DigFilterBString = "' + DigFilterBString + '"\n')
1138  # save channel AC frequency compensation settings
1139  try:
1140  CHA_TC1.set(float(cha_TC1Entry.get()))
1141  CHA_TC2.set(float(cha_TC2Entry.get()))
1142  CHB_TC1.set(float(chb_TC1Entry.get()))
1143  CHB_TC2.set(float(chb_TC2Entry.get()))
1144  CHA_A1.set(float(cha_A1Entry.get()))
1145  CHA_A2.set(float(cha_A2Entry.get()))
1146  CHB_A1.set(float(chb_A1Entry.get()))
1147  CHB_A2.set(float(chb_A2Entry.get()))
1148  except:
1149  donothing()
1150  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1151  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1152  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1153  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1154  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1155  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1156  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1157  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1158  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1159  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1160  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1161  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1162  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1163  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1164  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1165  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1166  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1167  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1168  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1169  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1170  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1171  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1172  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1173  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1174  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1175  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1176 
1177  # extra Spectrum stuff
1178  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1179  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1180  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1181  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1182  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1183  #
1184  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1185  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1186  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1187  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1188  #
1189  ConfgFile.close()
1190 
1192  global iawindow
1193 
1194  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1195  BSaveConfig(filename)
1196 
1198  global freqwindow
1199 
1200  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1201  BSaveConfig(filename)
1202 
1204  global bodewindow
1205 
1206  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1207  BSaveConfig(filename)
1208 
1210  global root
1211  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1212  BSaveConfig(filename)
1213 
1214 def BLoadConfig(filename):
1215  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1216  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1217  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
1218  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1219  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1220  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1221  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1222  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1223  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1224  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1225  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1226  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1227  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1228  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1229  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1230  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1231  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1232  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1233  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1234  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1235  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1236  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1237  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1238  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1239  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1240  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1241  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1242  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
1243  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1244  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1245  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1246  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1247  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1248  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1249  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1250  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1251  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1252  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1253  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1254  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1255  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1256  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1257  global AWGABurstFlag, AWGACycles, AWGABurstDelay
1258  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
1259  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1260 
1261  # Read configuration values from file
1262  try:
1263  ConfgFile = open(filename)
1264  for line in ConfgFile:
1265  try:
1266  exec( line.rstrip() )
1267  except:
1268  print( "Skipping " + line.rstrip())
1269  ConfgFile.close()
1270  if DevID != "No Device":
1271  BAWGAModeLabel()
1272  BAWGBModeLabel()
1273  BAWGAPhaseDelay()
1274  BAWGBPhaseDelay()
1275  TimeCheckBox()
1276  XYCheckBox()
1277  FreqCheckBox()
1278  BodeCheckBox()
1279  IACheckBox()
1280  OhmCheckBox()
1281 #
1282  time.sleep(0.05)
1283  ReMakeAWGwaves()
1284  BTime()
1285  except:
1286  print( "Config File Not Found.")
1287 
1288 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1289  global AWGAShape, AWGBShape, BisCompA
1290 
1291  if AWGAShape.get()==9:
1292  AWGAMakeImpulse()
1293  elif AWGAShape.get()==11:
1295  elif AWGAShape.get()==15:
1296  AWGAMakeSSQ()
1297  elif AWGAShape.get()==16:
1298  AWGAMakeRamp()
1299  elif AWGAShape.get()==17:
1300  AWGAMakePWMSine()
1301  elif AWGAShape.get()==18:
1303  elif AWGAShape.get()==12:
1305  elif AWGAShape.get()==14:
1306  AWGAMakeFourier()
1307  elif AWGAShape.get()==19:
1308  AWGAMakeSinc()
1309  elif AWGAShape.get()==20:
1310  AWGAMakePulse()
1311  elif AWGAShape.get()==21:
1312  AWGAMakeFMSine()
1313  elif AWGAShape.get()==22:
1314  AWGAMakeAMSine()
1315  elif AWGAShape.get()==7:
1316  AWGAMakeUUNoise()
1317  elif AWGAShape.get()==8:
1318  AWGAMakeUGNoise()
1319 #
1320  if BisCompA.get() == 1:
1321  SetBCompA()
1322  if AWGBShape.get()==9:
1323  AWGBMakeImpulse()
1324  elif AWGBShape.get()==11:
1326  elif AWGBShape.get()==15:
1327  AWGBMakeSSQ()
1328  elif AWGBShape.get()==16:
1329  AWGBMakeRamp()
1330  elif AWGBShape.get()==17:
1331  AWGBMakePWMSine()
1332  elif AWGBShape.get()==18:
1334  elif AWGBShape.get()==12:
1336  elif AWGBShape.get()==14:
1337  AWGBMakeFourier()
1338  elif AWGBShape.get()==19:
1339  AWGBMakeSinc()
1340  elif AWGBShape.get()==20:
1341  AWGBMakePulse()
1342  elif AWGBShape.get()==7:
1343  AWGBMakeUUNoise()
1344  elif AWGBShape.get()==8:
1345  AWGBMakeUGNoise()
1346  else:
1347  UpdateAwgCont()
1348  time.sleep(0.05)
1349 
1351  global iawindow
1352 
1353  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1354  BLoadConfig(filename)
1355 
1357  global freqwindow
1358 
1359  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1360  BLoadConfig(filename)
1361 
1363  global bodewindow
1364 
1365  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1366  BLoadConfig(filename)
1367 
1369  global root
1370 
1371  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1372  BLoadConfig(filename)
1373  UpdateTimeTrace()
1374 
1375 def BgColor():
1376  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus
1377  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
1378 
1379  if ColorMode.get() > 0:
1380  COLORtext = "#000000" # 100% black
1381  COLORtrace4 = "#a0a000" # 50% yellow
1382  COLORtraceR4 = "#606000" # 25% yellow
1383  COLORcanvas = "#ffffff" # 100% white
1384  else:
1385  COLORcanvas = "#000000" # 100% black
1386  COLORtrace4 = "#ffff00" # 100% yellow
1387  COLORtraceR4 = "#808000" # 50% yellow
1388  COLORtext = "#ffffff" # 100% white
1389  ca.config(background=COLORcanvas)
1391  if SpectrumScreenStatus.get() > 0:
1392  Freqca.config(background=COLORcanvas)
1394  if XYScreenStatus.get() > 0:
1395  XYca.config(background=COLORcanvas)
1396  UpdateXYScreen()
1397  if IAScreenStatus.get() > 0:
1398  IAca.config(background=COLORcanvas)
1399  UpdateIAScreen()
1400  if BodeScreenStatus.get() > 0:
1401  Bodeca.config(background=COLORcanvas)
1403 
1405  global CANVASwidth, CANVASheight
1406  global COLORtext, MarkerNum, ColorMode
1407  # ask for file name
1408  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
1409  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
1410  if MarkerNum > 0 or ColorMode.get() > 0:
1411  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
1412  else: # temp chnage text corlor to black
1413  COLORtext = "#000000"
1415  # first save postscript file
1416  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
1417  # now convert to bit map
1418  # img = Image.open("screen_shot.eps")
1419  # img.save("screen_shot.gif", "gif")
1420  COLORtext = "#ffffff"
1422 
1424  global CANVASwidthXY, CANVASheightXY, xywindow
1425  global COLORtext, MarkerNum, ColorMode, XYca
1426  # ask for file name
1427  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
1428  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
1429  if MarkerNum > 0 or ColorMode.get() > 0:
1430  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
1431  else: # temp chnage text corlor to black
1432  COLORtext = "#000000"
1433  UpdateXYScreen()
1434  # first save postscript file
1435  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
1436  # now convert to bit map
1437  # img = Image.open("screen_shot.eps")
1438  # img.save("screen_shot.gif", "gif")
1439  COLORtext = "#ffffff"
1440  UpdateXYScreen()
1441 
1443  global CANVASwidthIA, CANVASheightIA
1444  global COLORtext, IAca, ColorMode, iawindow
1445  # ask for file name
1446  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
1447  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
1448  if ColorMode.get() > 0:
1449  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
1450  else: # temp change text color to black for Black BG
1451  COLORtext = "#000000"
1452  UpdateIAScreen()
1453  # save postscript file
1454  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
1455  #
1456  COLORtext = "#ffffff"
1457  UpdateIAScreen()
1458 
1460  global CANVASwidthBP, CANVASheightBP
1461  global COLORtext, Bodeca, bodewindow
1462  # ask for file name
1463  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
1464  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
1465  if MarkerNum > 0 or ColorMode.get() > 0:
1466  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
1467  else: # temp change text color to black
1468  COLORtext = "#000000"
1470  # save postscript file
1471  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
1472  #
1473  COLORtext = "#ffffff"
1475 
1477  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
1478 
1479  # open file to save data
1480  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
1481  DataFile = open(filename, 'w')
1482  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
1483  for index in range(len(VBuffA)):
1484  TimePnt = float((index+0.0)/SAMPLErate)
1485  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
1486  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
1487  DataFile.close()
1488 
1490  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
1491 
1492  # ask user for channel to save
1493  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I or CB-I\n\nChannel:\n", initialvalue="CA-V")
1494  if (Channel == None): # If Cancel pressed, then None
1495  return
1496  # open file to save data
1497  filename = asksaveasfilename(defaultextension = ".txt", filetypes=[("Text Columns", "*.txt")])
1498  DataFile = open(filename, 'w')
1499  for index in range(len(VBuffA)):
1500  TimePnt = float((index+0.0)/SAMPLErate)
1501  if Channel == "CA-V":
1502  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
1503  elif Channel == "CA-I":
1504  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
1505  elif Channel == "CB-V":
1506  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
1507  elif Channel == "CB-I":
1508  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
1509  DataFile.close()
1510 
1512  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
1513 
1514  # Read values from CVS file
1515  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
1516  try:
1517  CSVFile = open(filename)
1518  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
1519  CSVFile.seek(0)
1520  csv_f = csv.reader(CSVFile, dialect)
1521  VBuffA = []
1522  VBuffB = []
1523  IBuffA = []
1524  IBuffB = []
1525  SHOWsamples = 0
1526  for row in csv_f:
1527  try:
1528  VBuffA.append(float(row[1]))
1529  IBuffA.append(float(row[2]))
1530  VBuffB.append(float(row[3]))
1531  IBuffB.append(float(row[4]))
1532  SHOWsamples = SHOWsamples + 1
1533  except:
1534  print( 'skipping non-numeric row')
1535  VBuffA = numpy.array(VBuffA)
1536  IBuffA = numpy.array(IBuffA)
1537  VBuffB = numpy.array(VBuffB)
1538  IBuffB = numpy.array(IBuffB)
1539  CSVFile.close()
1540  UpdateTimeTrace()
1541  except:
1542  showwarning("WARNING","No such file found or wrong format!")
1543 
1545 def BHelp():
1546 
1547  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
1548  webbrowser.open(url,new=2)
1549 
1550 def BAbout():
1551  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
1552 
1553  try:
1554  u = urllib2.urlopen(Version_url)
1555  meta = u.info()
1556  time_string = str(meta.getheaders("Last-Modified"))
1557  except:
1558  time_string = "Unavailable"
1559  print(time_string)
1560  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
1561  "Latest Version: " + time_string[7:18] + "\n" +
1562  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
1563  "Firmware Rev " + str(FWRevOne) + "\n" +
1564  "Board Serial Number " + DevID + "\n" +
1565  "Software is provided as is without any Warranty")
1566 
1568  global T1Vline, T2Vline, T1Iline, T2Iline
1569  global TXYline, Tmathline, TMRline, TXYRline
1570  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
1571  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
1572  global MuxScreenStatus, TMCRline, TMBRline, TMAVline, TMBVline, TMCVline, TMDVline
1573  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
1574 
1575  if ShowC1_V.get() == 1:
1576  T1VRline = T1Vline # V reference Trace line channel A
1577  if ShowC2_V.get() == 1:
1578  T2VRline = T2Vline # V reference Trace line channel B
1579  if ShowC1_I.get() == 1:
1580  T1IRline = T1Iline # I reference Trace line channel A
1581  if ShowC2_I.get() == 1:
1582  T2IRline = T2Iline # I reference Trace line channel B
1583  if MathTrace.get() > 0:
1584  TMRline = Tmathline # Math reference Trace line
1585  if MuxScreenStatus.get() > 0:
1586  if Show_CBA.get() > 0:
1587  T2VRline = TMAVline # V reference Trace line Mux channel A
1588  if Show_CBB.get() > 0:
1589  TMBRline = TMBVline # V reference Trace line Mux channel B
1590  if Show_CBC.get() > 0:
1591  TMCRline = TMCVline # V reference Trace line Mux channel C
1592  if Show_CBD.get() > 0:
1593  T2IRline = TMDVline # V reference Trace line Mux channel D
1594  if len(TXYline) > 4:
1595  TXYRline = TXYline # XY reference trace line
1596 
1597 def BSaveCal():
1598  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1599  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1600  global DevID
1601  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1602  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
1603  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1604  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1605 
1606  devidstr = DevID[17:31]
1607  filename = devidstr + "_O.cal"
1608  CalFile = open(filename, "w")
1609  #
1610  CalFile.write('CHAVGainEntry.delete(0,END)\n')
1611  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1612  CalFile.write('CHBVGainEntry.delete(0,END)\n')
1613  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1614  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
1615  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1616  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
1617  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1618  #
1619  CalFile.write('CHAIGainEntry.delete(0,END)\n')
1620  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1621  CalFile.write('CHBIGainEntry.delete(0,END)\n')
1622  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1623  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
1624  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1625  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
1626  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1627  #
1628  # save channel AC frequency compensation settings
1629  try:
1630  CHA_TC1.set(float(cha_TC1Entry.get()))
1631  CHA_TC2.set(float(cha_TC2Entry.get()))
1632  CHB_TC1.set(float(chb_TC1Entry.get()))
1633  CHB_TC2.set(float(chb_TC2Entry.get()))
1634  CHA_A1.set(float(cha_A1Entry.get()))
1635  CHA_A2.set(float(cha_A2Entry.get()))
1636  CHB_A1.set(float(chb_A1Entry.get()))
1637  CHB_A2.set(float(chb_A2Entry.get()))
1638  except:
1639  donothing()
1640  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1641  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1642  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1643  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1644  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1645  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1646  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1647  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1648  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1649  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1650  CalFile.write('cha_TC1Entry.delete(0,END)\n')
1651  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1652  CalFile.write('cha_TC2Entry.delete(0,END)\n')
1653  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1654  CalFile.write('chb_TC1Entry.delete(0,END)\n')
1655  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1656  CalFile.write('chb_TC2Entry.delete(0,END)\n')
1657  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1658  CalFile.write('cha_A1Entry.delete(0,END)\n')
1659  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1660  CalFile.write('cha_A2Entry.delete(0,END)\n')
1661  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1662  CalFile.write('chb_A1Entry.delete(0,END)\n')
1663  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1664  CalFile.write('chb_A2Entry.delete(0,END)\n')
1665  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1666 
1667  CalFile.close()
1668 
1669 def BLoadCal():
1670  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1671  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1672  global DevID
1673  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1674  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
1675  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1676  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1677 
1678  devidstr = DevID[17:31]
1679  filename = devidstr + "_O.cal"
1680  try:
1681  CalFile = open(filename)
1682  for line in CalFile:
1683  exec( line.rstrip() )
1684  CalFile.close()
1685  except:
1686  print( "Cal file for this device not found")
1687 
1689  global UserAString, UserALabel, MeasUserA
1690 
1691  TempString = UserALabel
1692  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
1693  if (UserALabel == None): # If Cancel pressed, then None
1694  MeasUserA.set(0)
1695  UserALabel = TempString
1696  return
1697  TempString = UserAString
1698  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
1699  if (UserAString == None): # If Cancel pressed, then None
1700  MeasUserA.set(0)
1701  UserAString = TempString
1702  return
1703  MeasUserA.set(1)
1704 
1706  global UserBString, UserBLabel, MeasUserB
1707 
1708  TempString = UserBLabel
1709  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
1710  if (UserBLabel == None): # If Cancel pressed, then None
1711  MeasUserB.set(0)
1712  UserBLabel = TempString
1713  return
1714  TempString = UserBString
1715  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
1716  if (UserBString == None): # If Cancel pressed, then None
1717  MeasUserB.set(0)
1718  UserBString = TempString
1719  return
1720  MeasUserB.set(1)
1721 
1723  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
1724  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
1725  global MathAxis, MathXAxis, MathYAxis, MathTrace
1726  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
1727  global formlab, xformlab, yformlab
1728 
1729  if MathScreenStatus.get() == 0:
1730  MathScreenStatus.set(1)
1731  #
1732  MathWindow = Toplevel()
1733  MathWindow.title("Math Formula " + SWRev + RevDate)
1734  MathWindow.resizable(FALSE,FALSE)
1735  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
1736  frame1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10R1.TLabelframe")
1737  frame2 = LabelFrame(MathWindow, text="Math Trace", style="A10R1.TLabelframe")
1738  frame3 = LabelFrame(MathWindow, text="X Math Trace", style="A10R1.TLabelframe")
1739  frame4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10R1.TLabelframe")
1740  # frame1.grid(row=0, column=0, sticky=W)
1741  #
1742  frame1.grid(row = 0, column=0, rowspan=3, sticky=W)
1743  frame2.grid(row = 0, column=1, sticky=W)
1744  frame3.grid(row = 1, column=1, sticky=W)
1745  frame4.grid(row = 2, column=1, sticky=W)
1746  #
1747  # Built in functions
1748  #
1749  rb1 = Radiobutton(frame1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
1750  rb1.grid(row=0, column=0, sticky=W)
1751  rb2 = Radiobutton(frame1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
1752  rb2.grid(row=1, column=0, sticky=W)
1753  rb3 = Radiobutton(frame1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
1754  rb3.grid(row=2, column=0, sticky=W)
1755  rb4 = Radiobutton(frame1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
1756  rb4.grid(row=3, column=0, sticky=W)
1757  rb5 = Radiobutton(frame1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
1758  rb5.grid(row=4, column=0, sticky=W)
1759  rb6 = Radiobutton(frame1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
1760  rb6.grid(row=5, column=0, sticky=W)
1761  rb7 = Radiobutton(frame1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
1762  rb7.grid(row=6, column=0, sticky=W)
1763  rb8 = Radiobutton(frame1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
1764  rb8.grid(row=7, column=0, sticky=W)
1765  rb9 = Radiobutton(frame1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
1766  rb9.grid(row=8, column=0, sticky=W)
1767  rb10 = Radiobutton(frame1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
1768  rb10.grid(row=9, column=0, sticky=W)
1769  rb11 = Radiobutton(frame1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
1770  rb11.grid(row=10, column=0, sticky=W)
1771  rb12 = Radiobutton(frame1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
1772  rb12.grid(row=11, column=0, sticky=W)
1773  rb13 = Radiobutton(frame1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
1774  rb13.grid(row=12, column=0, sticky=W)
1775  #
1776  # Math trace formula sub frame2
1777  #
1778  sframe2a = Frame( frame2 )
1779  sframe2a.pack(side=TOP)
1780  formlab = Label(sframe2a, text="Formula ", style= "A10B.TLabel")
1781  formlab.grid(row=0, column=0, sticky=W)
1782  formlab.pack(side=LEFT)
1783  formentry = Entry(sframe2a, width=23)
1784  formentry.grid(row=0, column=1, sticky=W)
1785  formentry.pack(side=LEFT)
1786  formentry.delete(0,"end")
1787  formentry.insert(0,MathString)
1788  sframe2b = Frame( frame2 )
1789  sframe2b.pack(side=TOP)
1790  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
1791  unitslab.grid(row=0, column=0, sticky=W)
1792  unitslab.pack(side=LEFT)
1793  unitsentry = Entry(sframe2b, width=6)
1794  unitsentry.grid(row=0, column=1, sticky=W)
1795  unitsentry.pack(side=LEFT)
1796  unitsentry.delete(0,"end")
1797  unitsentry.insert(0,MathUnits)
1798  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
1799  checkbt.grid(row=0, column=2, sticky=W)
1800  checkbt.pack(side=LEFT)
1801  sframe2c = Frame( frame2 )
1802  sframe2c.pack(side=TOP)
1803  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
1804  axislab.grid(row=0, column=0, sticky=W)
1805  axislab.pack(side=LEFT)
1806  axisentry = Entry(sframe2c, width=3)
1807  axisentry.grid(row=0, column=1, sticky=W)
1808  axisentry.pack(side=LEFT)
1809  axisentry.delete(0,"end")
1810  axisentry.insert(0,MathAxis)
1811  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
1812  applybt.grid(row=0, column=2, sticky=W)
1813  applybt.pack(side=LEFT)
1814  #
1815  # X Math trace formula sub frame3
1816  #
1817  sframe3a = Frame( frame3 )
1818  sframe3a.pack(side=TOP)
1819  xformlab = Label(sframe3a, text=" X Formula ", style= "A10B.TLabel")
1820  xformlab.grid(row=0, column=0, sticky=W)
1821  xformlab.pack(side=LEFT)
1822  xformentry = Entry(sframe3a, width=20)
1823  xformentry.grid(row=0, column=1, sticky=W)
1824  xformentry.pack(side=LEFT)
1825  xformentry.delete(0,"end")
1826  xformentry.insert(0, MathXString)
1827  sframe3b = Frame( frame3 )
1828  sframe3b.pack(side=TOP)
1829  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
1830  xunitslab.grid(row=0, column=0, sticky=W)
1831  xunitslab.pack(side=LEFT)
1832  xunitsentry = Entry(sframe3b, width=6)
1833  xunitsentry.grid(row=0, column=1, sticky=W)
1834  xunitsentry.pack(side=LEFT)
1835  xunitsentry.delete(0,"end")
1836  xunitsentry.insert(0, MathXUnits)
1837  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
1838  xcheckbt.grid(row=0, column=2, sticky=W)
1839  xcheckbt.pack(side=LEFT)
1840  sframe3c = Frame( frame3 )
1841  sframe3c.pack(side=TOP)
1842  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
1843  xaxislab.grid(row=0, column=0, sticky=W)
1844  xaxislab.pack(side=LEFT)
1845  xaxisentry = Entry(sframe3c, width=3)
1846  xaxisentry.grid(row=0, column=1, sticky=W)
1847  xaxisentry.pack(side=LEFT)
1848  xaxisentry.delete(0,"end")
1849  xaxisentry.insert(0, MathXAxis)
1850  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
1851  xapplybt.grid(row=0, column=3, sticky=W)
1852  xapplybt.pack(side=LEFT)
1853  #
1854  # Math trace formula sub frame4
1855  #
1856  sframe4a = Frame( frame4 )
1857  sframe4a.pack(side=TOP)
1858  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
1859  yformlab.grid(row=0, column=0, sticky=W)
1860  yformlab.pack(side=LEFT)
1861  yformentry = Entry(sframe4a, width=20)
1862  yformentry.grid(row=0, column=1, sticky=W)
1863  yformentry.pack(side=LEFT)
1864  yformentry.delete(0,"end")
1865  yformentry.insert(0,MathYString)
1866  sframe4b = Frame( frame4 )
1867  sframe4b.pack(side=TOP)
1868  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
1869  yunitslab.grid(row=0, column=0, sticky=W)
1870  yunitslab.pack(side=LEFT)
1871  yunitsentry = Entry(sframe4b, width=6)
1872  yunitsentry.grid(row=0, column=1, sticky=W)
1873  yunitsentry.pack(side=LEFT)
1874  yunitsentry.delete(0,"end")
1875  yunitsentry.insert(0,MathYUnits)
1876  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
1877  ycheckbt.grid(row=0, column=2, sticky=W)
1878  ycheckbt.pack(side=LEFT)
1879  sframe4c = Frame( frame4 )
1880  sframe4c.pack(side=TOP)
1881  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
1882  yaxislab.grid(row=0, column=0, sticky=W)
1883  yaxislab.pack(side=LEFT)
1884  yaxisentry = Entry(sframe4c, width=3)
1885  yaxisentry.grid(row=0, column=1, sticky=W)
1886  yaxisentry.pack(side=LEFT)
1887  yaxisentry.delete(0,"end")
1888  yaxisentry.insert(0,MathYAxis)
1889  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
1890  yapplybt.grid(row=0, column=3, sticky=W)
1891  yapplybt.pack(side=LEFT)
1892 
1893  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
1894  dismissbutton.grid(row=3, column=0, sticky=W)
1895 
1896  if RUNstatus.get() > 0:
1897  UpdateTimeTrace()
1898 
1900  global MathScreenStatus, MathWindow
1901 
1902  if MathScreenStatus.get() == 1:
1903  MathScreenStatus.set(0)
1904  MathWindow.destroy()
1905 
1907  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
1908  global VBuffA, VBuffB, IBuffA, IBuffB
1909  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
1910  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
1911  global FFTBuffA, FFTBuffB, FFTwindowshape
1912  global AWGAwaveform, AWGBwaveform
1913  global Show_MathX, Show_MathY
1914  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
1915  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
1916 
1917  t = 0
1918  TempString = formentry.get()
1919  try:
1920  MathResult = eval(TempString)
1921  formlab.configure(text="Formula ", style= "A10G.TLabel")
1922  except:
1923  formlab.configure(text="Formula ", style= "A10R.TLabel")
1924 
1926  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
1927  global VBuffA, VBuffB, IBuffA, IBuffB
1928  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
1929  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
1930  global FFTBuffA, FFTBuffB, FFTwindowshape
1931  global AWGAwaveform, AWGBwaveform
1932  global Show_MathX, Show_MathY
1933  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
1934  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
1935 
1936  t = 0
1937  TempString = xformentry.get()
1938  try:
1939  MathResult = eval(TempString)
1940  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
1941  except:
1942  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
1943 
1945  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
1946  global VBuffA, VBuffB, IBuffA, IBuffB
1947  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
1948  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
1949  global FFTBuffA, FFTBuffB, FFTwindowshape
1950  global AWGAwaveform, AWGBwaveform
1951  global Show_MathX, Show_MathY
1952  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
1953  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
1954 
1955  t = 0
1956  TempString = yformentry.get()
1957  try:
1958  MathResult = eval(TempString)
1959  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
1960  except:
1961  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
1962 
1964  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
1965 
1966  MathString = formentry.get()
1967  MathUnits = unitsentry.get()
1968  MathAxis = axisentry.get()
1969 
1971  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
1972 
1973  MathXString = xformentry.get()
1974  MathXUnits = xunitsentry.get()
1975  MathXAxis = xaxisentry.get()
1976 
1978  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
1979 
1980  MathYString = yformentry.get()
1981  MathYUnits = yunitsentry.get()
1982  MathYAxis = yaxisentry.get()
1983 
1985  global MarkerLoc
1986 
1987  TempString = MarkerLoc
1988  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
1989  if (MarkerLoc == None): # If Cancel pressed, then None
1990  MarkerLoc = TempString
1991  UpdateTimeTrace()
1992 
1994  global RUNstatus
1995 
1996 def DoNothing(event):
1997  global RUNstatus
1998 
2000  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
2001  ShowC1_V.set(1)
2002  ShowC1_I.set(1)
2003  ShowC2_V.set(1)
2004  ShowC2_I.set(1)
2005  UpdateTimeTrace()
2006 
2008  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
2009  ShowC1_V.set(0)
2010  ShowC1_I.set(0)
2011  ShowC2_V.set(0)
2012  ShowC2_I.set(0)
2013  UpdateTimeTrace()
2014 
2016  global TgEdge
2017 
2018 # TRIGCOND trigcondRisingPositive = 0
2019 # TRIGCOND trigcondFallingNegative = 1
2020 
2022  global TgInput, TRIGGERlevel, TRIGGERentry
2023  global MaxV1, MinV1, MaxV2, MinV2
2024  global MaxI1, MinI1, MaxI2, MinI2
2025  # set new trigger level to mid point of waveform
2026  MidV1 = (MaxV1+MinV1)/2
2027  MidV2 = (MaxV2+MinV2)/2
2028  MidI1 = (MaxI1+MinI1)/2
2029  MidI2 = (MaxI2+MinI2)/2
2030  if (TgInput.get() == 0):
2031  DCString = "0.0"
2032  elif (TgInput.get() == 1 ):
2033  DCString = ' {0:.2f} '.format(MidV1)
2034  elif (TgInput.get() == 2 ):
2035  DCString = ' {0:.2f} '.format(MidI1)
2036  elif (TgInput.get() == 3 ):
2037  DCString = ' {0:.2f} '.format(MidV2)
2038  elif (TgInput.get() == 4 ):
2039  DCString = ' {0:.2f} '.format(MidI2)
2040 
2041  TRIGGERlevel = eval(DCString)
2042  TRIGGERentry.delete(0,END)
2043  TRIGGERentry.insert(4, DCString)
2044 
2045  UpdateTimeTrace() # Always Update
2046 
2048  global TgInput
2049 
2050 # if (TgInput.get() == 0):
2051  # no trigger
2052 # elif (TgInput.get() == 1):
2053  # trigger source set to detector of analog in channels
2054  # auto trigger timeout value
2055 # elif (TgInput.get() == 2):
2056  # trigger source set to detector of analog in channels
2057  # 0 disables auto trigger
2058 
2059 def BTriglevel(event):
2060  global TRIGGERlevel, TRIGGERentry
2061 
2062  # evalute entry string to a numerical value
2063  try:
2064  TRIGGERlevel = float(eval(TRIGGERentry.get()))
2065  except:
2066  TRIGGERentry.delete(0,END)
2067  TRIGGERentry.insert(0, TRIGGERlevel)
2068  # set new trigger level
2069 
2070  UpdateTimeTrace() # Always Update
2071 
2072 def BHoldOff(event):
2073  global HoldOff, HoldOffentry
2074 
2075  try:
2076  HoldOff = float(eval(HoldOffentry.get()))
2077  except:
2078  HoldOffentry.delete(0,END)
2079  HoldOffentry.insert(0, HoldOff)
2080 # Set Horx possition from entry widget
2081 def BHozPoss(event):
2082  global HozPoss, HozPossentry
2083 
2084  try:
2085  HozPoss = float(eval(HozPossentry.get()))
2086  except:
2087  HozPossentry.delete(0,END)
2088  HozPossentry.insert(0, HozPoss)
2089 #
2091  global HozPossentry, TgInput, TMsb
2092 
2093  # get time scale
2094  try:
2095  TIMEdiv = float(eval(TMsb.get()))
2096  except:
2097  TIMEdiv = 0.5
2098  TMsb.delete(0,"end")
2099  TMsb.insert(0,TIMEdiv)
2100  # prevent divide by zero error
2101  if TIMEdiv < 0.0002:
2102  TIMEdiv = 0.01
2103  if TgInput.get() > 0:
2104  HozPoss = -5 * TIMEdiv
2105  HozPossentry.delete(0,END)
2106  HozPossentry.insert(0, HozPoss)
2107 #
2109  global HoldOffentry, HoldOff, TgInput, TMsb
2110 
2111 # get time scale
2112  try:
2113  TIMEdiv = float(eval(TMsb.get()))
2114  except:
2115  TIMEdiv = 0.5
2116  TMsb.delete(0,"end")
2117  TMsb.insert(0,TIMEdiv)
2118  # prevent divide by zero error
2119  if TIMEdiv < 0.0002:
2120  TIMEdiv = 0.01
2121  if TgInput.get() == 0:
2122  HoldOff = HoldOff + TIMEdiv
2123  HoldOffentry.delete(0,END)
2124  HoldOffentry.insert(0, HoldOff)
2125 
2127  global CHB_APosEntry, DCVMuxA
2128 
2129  CHB_APosEntry.delete(0,"end")
2130  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
2131 #
2133  global CHB_BPosEntry, DCVMuxB
2134 
2135  CHB_BPosEntry.delete(0,"end")
2136  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
2137 #
2139  global CHB_CPosEntry, DCVMuxC
2140 
2141  CHB_CPosEntry.delete(0,"end")
2142  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
2143 #
2145  global CHD_BPosEntry, DCVMuxD
2146 
2147  CHB_DPosEntry.delete(0,"end")
2148  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
2149 #
2151  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2152 
2153  if MarkerScale.get() != 1:
2154  MarkerScale.set(5)
2155  CHB_Alab.config(style="Rtrace2.TButton")
2156  CHB_Blab.config(style="Strace6.TButton")
2157  CHB_Clab.config(style="Strace7.TButton")
2158  CHB_Dlab.config(style="Strace4.TButton")
2159  else:
2160  MarkerScale.set(0)
2161 #
2163  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2164 
2165  if MarkerScale.get() != 1:
2166  MarkerScale.set(6)
2167  CHB_Alab.config(style="Strace2.TButton")
2168  CHB_Blab.config(style="Rtrace6.TButton")
2169  CHB_Clab.config(style="Strace7.TButton")
2170  CHB_Dlab.config(style="Strace4.TButton")
2171  else:
2172  MarkerScale.set(0)
2173 #
2175  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2176 
2177  if MarkerScale.get() != 1:
2178  MarkerScale.set(7)
2179  CHB_Alab.config(style="Strace2.TButton")
2180  CHB_Blab.config(style="Strace6.TButton")
2181  CHB_Clab.config(style="Rtrace7.TButton")
2182  CHB_Dlab.config(style="Strace4.TButton")
2183  else:
2184  MarkerScale.set(0)
2185 #
2187  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2188 
2189  if MarkerScale.get() != 1:
2190  MarkerScale.set(8)
2191  CHB_Alab.config(style="Strace2.TButton")
2192  CHB_Blab.config(style="Strace6.TButton")
2193  CHB_Clab.config(style="Strace7.TButton")
2194  CHB_Dlab.config(style="Rtrace4.TButton")
2195  else:
2196  MarkerScale.set(0)
2197 #
2199  global CHAVPosEntry, DCV1
2200 
2201  CHAVPosEntry.delete(0,"end")
2202  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
2203 #
2205  global CHBVPosEntry, DCV2
2206 
2207  CHBVPosEntry.delete(0,"end")
2208  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
2209 #
2211  global CHAIPosEntry, DCI1
2212 
2213  CHAIPosEntry.delete(0,"end")
2214  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
2215 #
2217  global CHBIPosEntry, DCI2
2218 
2219  CHBIPosEntry.delete(0,"end")
2220  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
2221 #
2223  global CHAVPosEntryxy, DCV1
2224 
2225  CHAVPosEntryxy.delete(0,"end")
2226  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
2227 #
2229  global CHBVPosEntryxy, DCV2
2230 
2231  CHBVPosEntryxy.delete(0,"end")
2232  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
2233 #
2235  global CHAIPosEntryxy, DCI1
2236 
2237  CHAIPosEntryxy.delete(0,"end")
2238  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
2239 #
2241  global CHBIPosEntryxy, DCI2
2242 
2243  CHBIPosEntryxy.delete(0,"end")
2244  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
2245 
2247  global RUNstatus, session, CHA, CHB, devx, AWG_2X
2248 
2249  RUNstatus.set(0)
2250  BSaveConfig("alice-last-config.cfg")
2251  # Put channels in Hi-Z and exit
2252  try:
2253  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2254  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2255  devx.set_adc_mux(0) # set ADC mux conf to default
2256  AWG_2X.set(0)
2257  BAWG2X()
2258  CHA.constant(0.0)
2259  CHB.constant(0.0)
2260  if session.continuous:
2261  session.end()
2262  except:
2263  donothing()
2264 
2265  root.destroy()
2266  exit()
2267 
2268 def BStart():
2269  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
2270  global contloop, discontloop, TIMEdiv, First_Slow_sweep
2271 
2272  if DevID == "No Device":
2273  showwarning("WARNING","No Device Plugged In!")
2274  elif FWRevOne == 0.0:
2275  showwarning("WARNING","Out of data Firmware!")
2276  else:
2277  if PowerStatus == 0:
2278  PowerStatus = 1
2279  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2280  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2281  if (RUNstatus.get() == 0):
2282  RUNstatus.set(1)
2283  if AWGSync.get() == 0:
2284  session.flush()
2285  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2286  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2287  BAWGEnab()
2288  if not session.continuous:
2289  session.start(0)
2290  time.sleep(0.02) # wait awhile here for some reason
2291  elif session.continuous:
2292  session.end()
2293  session.flush()
2294  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2295  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2296 
2308  BAWGEnab()
2309  else:
2310  contloop = 0
2311  discontloop = 1
2312  if session.continuous:
2313  session.end() # end continuous session mode
2314 
2315  # UpdateTimeScreen() # Always Update
2316  if TIMEdiv >= 100:
2317  First_Slow_sweep = 0
2318  else:
2319  First_Slow_sweep = 1
2320 #$ Start running Ohmmeter tool
2322  global session, AWGSync
2323 
2324  AWGSync.set(1)
2325  if AWGSync.get() == 0:
2326  session.flush()
2327  if not session.continuous:
2328  session.start(0)
2329  time.sleep(0.02) # wait awhile here for some reason
2330  elif session.continuous:
2331  session.end()
2332  session.flush()
2333  else:
2334  contloop = 0
2335  discontloop = 1
2336  if session.continuous:
2337  session.end() # end continuous session mode
2338 
2339 def BStartIA():
2340  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne
2341 
2342  try:
2343  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
2344  except:
2345  AWGAFreqEntry.delete(0,"end")
2346  AWGAFreqEntry.insert(0, AWGAFreqvalue)
2347  if FWRevOne > 2.16:
2348  if AWGAFreqvalue > 20000.0:
2349  Two_X_Sample.set(1)
2350  else:
2351  Two_X_Sample.set(0)
2352  SetADC_Mux()
2353  IASourceSet()
2354  BStart()
2355 
2357  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode
2358 
2359  if IASource.get() == 1:
2360  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
2361  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
2362  AWGAMode.set(2) # Set AWG A to Hi-Z
2363  else:
2364  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
2365  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
2366  AWGAMode.set(0) # Set AWG A to SVMI
2367  if AWGBIOMode.get() == 0: # if not in split I/O mode
2368  AWGBMode.set(2) # Set AWG B to Hi-Z
2369 
2370 def BStop():
2371  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
2372  global CHA, CHB, contloop, discontloop
2373 
2374  if (RUNstatus.get() == 1):
2375  RUNstatus.set(0)
2376  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2377  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2378  if AWGSync.get() == 0: # running in continuous mode
2379  CHA.constant(0.0)
2380  CHB.constant(0.0)
2381  # print "Stoping continuous mode"
2382  # session.cancel() # cancel continuous session mode while paused
2383  if session.continuous:
2384  #print "Is Continuous? ", session.continuous
2385  session.end()
2386  #time.sleep(0.02)
2387  #print "Is Continuous? ", session.continuous
2388  else:
2389  contloop = 0
2390  discontloop = 1
2391  session.cancel()
2392  elif (RUNstatus.get() == 2):
2393  RUNstatus.set(3)
2394  elif (RUNstatus.get() == 3):
2395  RUNstatus.set(3)
2396  elif (RUNstatus.get() == 4):
2397  RUNstatus.set(3)
2398  if TimeDisp.get() > 0:
2399  UpdateTimeScreen() # Always Update screens as necessary
2400  if XYDisp.get() > 0:
2401  UpdateXYScreen()
2402  if FreqDisp.get() > 0:
2404  if IADisp.get() > 0:
2405  UpdateIAScreen()
2406 
2407 def BPower():
2408  global RUNstatus, PowerStatus, devx, PwrBt
2409 
2410  if (RUNstatus.get() == 1):
2411  BStop()
2412  if PowerStatus == 1:
2413  PowerStatus = 0
2414  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
2415  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
2416  else:
2417  PowerStatus = 1
2418  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2419  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2420 
2421 def BTime():
2422  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne
2423 
2424  try: # get time scale in mSec/div
2425  TIMEdiv = float(eval(TMsb.get()))
2426  if TIMEdiv < 0.0002:
2427  TIMEdiv = 0.01
2428  TMsb.delete(0,"end")
2429  TMsb.insert(0,TIMEdiv)
2430  except:
2431  TIMEdiv = 0.5
2432  TMsb.delete(0,"end")
2433  TMsb.insert(0,TIMEdiv)
2434  # Switch to 2X sampleling if time scale small enough and not runing ETS
2435  if ETSDisp.get() == 0:
2436  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
2437  if FWRevOne > 2.16:
2438  if Samples_per_div < 20.0:
2439  Two_X_Sample.set(1)
2440  else:
2441  Two_X_Sample.set(0)
2442  SetADC_Mux()
2443  #
2444  if RUNstatus.get() == 2: # Restart if running
2445  RUNstatus.set(4)
2446 
2447  UpdateTimeTrace() # Always Update
2448 
2450  global CHAsb
2451 
2452  try:
2453  CH1vpdvLevel = float(eval(CHAsb.get()))
2454  except:
2455  CHAsb.delete(0,END)
2456  CHAsb.insert(0, CH1vpdvLevel)
2457  UpdateTimeTrace() # Always Update
2458 
2460  global CHAIsb
2461 
2462  try:
2463  CH1ipdvLevel = float(eval(CHAIsb.get()))
2464  except:
2465  CHAIsb.delete(0,END)
2466  CHAIsb.insert(0, CH1ipdvLevel)
2467  UpdateTimeTrace() # Always Update
2468 
2470  global CHBsb
2471 
2472  try:
2473  CH2vpdvLevel = float(eval(CHBsb.get()))
2474  except:
2475  CHBsb.delete(0,END)
2476  CHBsb.insert(0, CH2vpdvLevel)
2477  UpdateTimeTrace() # Always Update
2478 
2480  global CHBIsb
2481 
2482  try:
2483  CH2ipdvLevel = float(eval(CHBIsb.get()))
2484  except:
2485  CHBIsb.delete(0,END)
2486  CHBIsb.insert(0, CH2ipdvLevel)
2487  UpdateTimeTrace() # Always Update
2488 
2489 def BOffsetA(event):
2490  global CHAOffset, CHAVPosEntry
2491 
2492  try:
2493  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
2494  except:
2495  CHAVPosEntry.delete(0,END)
2496  CHAVPosEntry.insert(0, CHAOffset)
2497  # set new offset level
2498  UpdateTimeTrace() # Always Update
2499 
2500 def BIOffsetA(event):
2501  global CHAIOffset, CHAIPosEntry
2502 
2503  try:
2504  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
2505  except:
2506  CHAIPosEntry.delete(0,END)
2507  CHAIPosEntry.insert(0, CHAIOffset)
2508  # set new offset level
2509  UpdateTimeTrace() # Always Update
2510 
2511 def BOffsetB(event):
2512  global CHBOffset, CHBVPosEntry
2513 
2514  try:
2515  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
2516  except:
2517  CHBVPosEntry.delete(0,END)
2518  CHBVPosEntry.insert(0, CHBOffset)
2519  # set new offset level
2520  UpdateTimeTrace() # Always Update
2521 
2522 def BIOffsetB(event):
2523  global CHBIOffset, CHBIPosEntry
2524 
2525  try:
2526  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
2527  except:
2528  CHBIPosEntry.delete(0,END)
2529  CHBIPosEntry.insert(0, CHBIOffset)
2530  # set new offset level
2531  UpdateTimeTrace() # Always Update
2532 
2534  global TimeDisp, ckb1
2535  if TimeDisp.get() == 1:
2536  ckb1.config(style="Enab.TCheckbutton")
2537  else:
2538  ckb1.config(style="Disab.TCheckbutton")
2539 #
2541  global XYDisp, ckb2
2542  if XYDisp.get() == 1:
2543  ckb2.config(style="Enab.TCheckbutton")
2544  else:
2545  ckb2.config(style="Disab.TCheckbutton")
2546 #
2548  global FreqDisp, ckb3
2549  if FreqDisp.get() == 1:
2550  ckb3.config(style="Enab.TCheckbutton")
2551  else:
2552  ckb3.config(style="Disab.TCheckbutton")
2553 #
2555  global BodeDisp, ckb5, AWGSync
2556  if BodeDisp.get() == 1:
2557  AWGSync.set(1)
2558  ckb5.config(style="Enab.TCheckbutton")
2559  else:
2560  ckb5.config(style="Disab.TCheckbutton")
2561 #
2563  global IADisp, ckb4
2564  if IADisp.get() == 1:
2565  ckb4.config(style="Enab.TCheckbutton")
2566  else:
2567  ckb4.config(style="Disab.TCheckbutton")
2568 #
2570  global OhmDisp, ckb6
2571  if OhmDisp.get() == 1:
2572  ckb6.config(style="Enab.TCheckbutton")
2573  else:
2574  ckb6.config(style="Disab.TCheckbutton")
2575 #
2577  global ETSDisp, enb1
2578  if ETSDisp.get() == 1:
2579  enb1.config(style="Enab.TCheckbutton")
2580  else:
2581  try:
2582  enb1.config(style="Disab.TCheckbutton")
2583  except:
2584  donothing()
2585 # ========================= Main routine ====================================
2586 
2588  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
2589  global IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
2590  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
2591  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
2592  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
2593  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
2594  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2595  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2596  global SV1, SI1, SV2, SI2, SVA_B
2597  global FregPoint, FBins, FStep
2598  # Analog Mux channel measurement variables
2599  global TRACEresetTime, TRACEmodeTime
2600  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
2601  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
2602  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
2603  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
2604  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
2605  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
2606 
2607  while (True): # Main loop
2608  # RUNstatus = 1 : Open Acquisition
2609  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
2610  if TimeDisp.get() > 0 or XYDisp.get() > 0:
2611  if MuxScreenStatus.get() == 0:
2612  MuxChan = -1
2613  Analog_Time_In()
2614  else:
2615  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
2616  AWGAIOMode.set(1)
2617  AWGBIOMode.set(1)
2618  ShowC1_V.set(0) # force A voltage trace off
2619  ShowC2_V.set(0) # force B voltage trace off
2620  if HWRevOne == "D" :
2621  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
2622  AWGBMode.set(2)
2623  if AWGBIOMode.get() == 0: # if not in split I/O mode
2624  ShowC2_I.set(0) # no need to show CH-B current
2625  if MuxEnb.get() == 1:
2626  PIO2 = 0x51
2627  else:
2628  PIO2 = 0x50
2629  if MuxSync.get() == 0:
2630  PIO3 = 0x51
2631  PIO3x = 0x50
2632  else:
2633  PIO3 = 0x50
2634  PIO3x = 0x51
2635  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
2636  TRACEresetTime = True # Clear the memory for averaging
2637  elif TRACEmodeTime.get() == 1:
2638  if TRACEresetTime == True:
2639  TRACEresetTime = False
2640  # Save previous trace in memory for average trace
2641  VmemoryMuxA = VBuffMA
2642  VmemoryMuxB = VBuffMB
2643  VmemoryMuxC = VBuffMC
2644  ImemoryMuxD = VBuffMD
2645  if Show_CBA.get() == 1:
2646  MuxChan = 0
2647  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2648  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2649  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
2650  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
2651  time.sleep(0.002)
2652  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2653  Analog_Time_In()
2654  # Average mode 1, add difference / TRACEaverage to arrayif :
2655  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2656  try:
2657  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
2658  except:
2659  # buffer size mismatch so reset memory buffers
2660  VmemoryMuxA = VBuffMA
2661  if Show_CBB.get() == 1:
2662  MuxChan = 1
2663  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2664  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2665  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2666  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2667  time.sleep(0.002)
2668  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
2669  Analog_Time_In()
2670  # Average mode 1, add difference / TRACEaverage to arrayif :
2671  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2672  try:
2673  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
2674  except:
2675  # buffer size mismatch so reset memory buffers
2676  VmemoryMuxB = VBuffMB
2677  if Show_CBC.get() == 1:
2678  MuxChan = 2
2679  if DualMuxMode.get() == 1:
2680  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2681  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2682  else:
2683  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2684  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
2685  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2686  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2687  time.sleep(0.002)
2688  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2689  Analog_Time_In()
2690  # Average mode 1, add difference / TRACEaverage to arrayif :
2691  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2692  try:
2693  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
2694  except:
2695  # buffer size mismatch so reset memory buffers
2696  VmemoryMuxC = VBuffMC
2697  if Show_CBD.get() == 1:
2698  MuxChan = 3
2699  if DualMuxMode.get() == 1:
2700  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2701  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2702  else:
2703  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2704  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
2705  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2706  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 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  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
2714  except:
2715  # buffer size mismatch so reset memory buffers
2716  VmemoryMuxD = VBuffMD
2717  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:
2718  Analog_Time_In()
2719  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
2720  if IADisp.get() > 0 or BodeDisp.get() > 0:
2721  CutDC.set(1) # remove DC portion of waveform
2722  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
2723  if BodeDisp.get() > 0:
2724  if LoopNum.get() <= len(FStep):
2725  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
2726  if FregPoint < 100.0:
2727  SMPfft = 16384
2728  elif FregPoint < 500.0:
2729  SMPfft = 8192
2730  elif FregPoint < 2000.0:
2731  SMPfft = 4096
2732  else:
2733  SMPfft = 2048
2734  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
2735  SMPfft = SMPfft * 2
2736 
2737  Analog_Freq_In()
2738  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
2739  Ohm_Analog_In()
2740  root.update_idletasks()
2741  root.update()
2742 
2744  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
2745  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
2746 
2747 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
2748  try:
2749  InOffA = float(eval(CHAVOffsetEntry.get()))
2750  except:
2751  CHAVOffsetEntry.delete(0,END)
2752  CHAVOffsetEntry.insert(0, InOffA)
2753  try:
2754  InGainA = float(eval(CHAVGainEntry.get()))
2755  except:
2756  CHAVGainEntry.delete(0,END)
2757  CHAVGainEntry.insert(0, InGainA)
2758  try:
2759  InOffB = float(eval(CHBVOffsetEntry.get()))
2760  except:
2761  CHBVOffsetEntry.delete(0,END)
2762  CHBVOffsetEntry.insert(0, InOffB)
2763  try:
2764  InGainB = float(eval(CHBVGainEntry.get()))
2765  except:
2766  CHBVGainEntry.delete(0,END)
2767  CHBVGainEntry.insert(0, InGainB)
2768  try:
2769  CurOffA = float(CHAIOffsetEntry.get())
2770  except:
2771  CurOffA = 0.0
2772  try:
2773  CurOffB = float(CHBIOffsetEntry.get())
2774  except:
2775  CurOffB = 0.0
2776  try:
2777  CurGainA = float(CHAIGainEntry.get())
2778  except:
2779  CurGainA = 1.0
2780  try:
2781  CurGainB = float(CHBIGainEntry.get())
2782  except:
2783  CurGainB = 1.0
2784  try:
2785  chatestv = float(eval(CHATestVEntry.get()))
2786  if chatestv > 5.0:
2787  chatestv = 5.0
2788  CHATestVEntry.delete(0,END)
2789  CHATestVEntry.insert(0, chatestv)
2790  except:
2791  CHATestVEntry.delete(0,END)
2792  CHATestVEntry.insert(0, chatestv)
2793  try:
2794  chatestr = float(eval(CHATestREntry.get()))
2795  except:
2796  CHATestREntry.delete(0,END)
2797  CHATestREntry.insert(0, chatestr)
2798  #
2799  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
2800  RIN = 1000000 # nominal ALM1000 input resistance is 1 Mohm
2801  # set A and B channels
2802  AWGAMode.set(0) # Set AWG A to SVMI
2803  AWGAShape.set(0) # DC
2804  AWGBMode.set(2) # Set AWG B to Hi-Z
2805  AWGAOffsetEntry.delete(0,"end")
2806  AWGAOffsetEntry.insert(0, chatestv)
2807  if RMode.get() == 0:
2808  AWGBTerm.set(0)
2809  else:
2810  AWGBTerm.set(1)
2811  #
2812  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
2813  if discontloop > 0:
2814  session.flush()
2815  else:
2816  discontloop = 1
2817  time.sleep(0.01)
2818  BAWGEnab()
2819  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
2820  # time.sleep(1000.0/SHOWsamples)
2821  else: # running in continuous mode
2822  if session.continuous:
2823  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
2824  #
2825  # get_samples returns a list of values for voltage [0] and current [1]
2826  for index in range(200): # calculate average
2827  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
2828  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
2829  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
2830  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
2831 
2832  DCVA0 = DCVA0 / 200.0 # calculate average
2833  DCVB0 = DCVB0 / 200.0 # calculate average
2834  DCIA0 = DCIA0 / 200.0 # calculate average
2835  DCIB0 = DCIB0 / 200.0 # calculate average
2836  DCVA0 = (DCVA0 - InOffA) * InGainA
2837  DCVB0 = (DCVB0 - InOffB) * InGainB
2838  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
2839  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
2840  if RMode.get() == 0: # external resistor
2841  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
2842  DCR = (DCM * RIN) / (RIN - DCM) # correct for channel B input resistance
2843  else: # use internal 50 ohm resistor
2844  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
2845  if DCR < 1000:
2846  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
2847  else:
2848  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
2849  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
2850  OhmA0.config(text = OhmString) # change displayed value
2851  OhmA1.config(text = IAString) # change displayed value
2852 #
2853  time.sleep(0.1)
2854  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
2855 
2858  global TIMEdiv, TMsb
2859  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
2860  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
2861  global InOffA, InGainA, InOffB, InGainB
2862  global CurOffA, CurOffB, CurGainA, CurGainB
2863 
2864  # get time scale
2865  try:
2866  TIMEdiv = eval(TMsb.get())
2867  except:
2868  TIMEdiv = 0.5
2869  TMsb.delete(0,"end")
2870  TMsb.insert(0,TIMEdiv)
2871  if TIMEdiv < 0.0002:
2872  TIMEdiv = 0.01
2873  #
2874 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
2875  try:
2876  InOffA = float(eval(CHAVOffsetEntry.get()))
2877  except:
2878  CHAVOffsetEntry.delete(0,END)
2879  CHAVOffsetEntry.insert(0, InOffA)
2880  try:
2881  InGainA = float(eval(CHAVGainEntry.get()))
2882  except:
2883  CHAVGainEntry.delete(0,END)
2884  CHAVGainEntry.insert(0, InGainA)
2885  try:
2886  InOffB = float(eval(CHBVOffsetEntry.get()))
2887  except:
2888  CHBVOffsetEntry.delete(0,END)
2889  CHBVOffsetEntry.insert(0, InOffB)
2890  try:
2891  InGainB = float(eval(CHBVGainEntry.get()))
2892  except:
2893  CHBVGainEntry.delete(0,END)
2894  CHBVGainEntry.insert(0, InGainB)
2895  try:
2896  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
2897  except:
2898  CurOffA = 0.0
2899  try:
2900  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
2901  except:
2902  CurOffB = 0.0
2903  try:
2904  CurGainA = float(CHAIGainEntry.get())
2905  except:
2906  CurGainA = 1.0
2907  try:
2908  CurGainB = float(CHBIGainEntry.get())
2909  except:
2910  CurGainB = 1.0
2911 # Dedecide which Fast or Slow sweep routine to call
2912  if TIMEdiv > 500: # in mSec
2914  else:
2916 
2919  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
2920  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2921  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
2922  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
2923  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
2924  global CHA, CHB, session, devx, discontloop, contloop
2925  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, ShiftPointer
2926  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
2927  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered
2928  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
2929  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
2930  global SCREENrefresh, DCrefresh
2931  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2932  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2933  global SV1, SI1, SV2, SI2, SVA_B
2934  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2935  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
2936  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2937  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
2938  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
2939  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2940  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2941  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2942  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2943  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
2944  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
2945  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
2946  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
2947  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
2948  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
2949  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
2950  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
2951  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
2952  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
2953  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
2954  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
2955 
2956  # Starting acquisition
2957  DCVA0 = DCVB0 = DCIA0 = DCIB0= 0.0 # initalize measurment variable
2958  #
2959  NumSamples = 1 # int(SAMPLErate/TIMEdiv)
2960  if First_Slow_sweep == 0:
2961  BufferLen = TIMEdiv*12.0
2962  VBuffA = numpy.ones(BufferLen)
2963  VBuffB = numpy.ones(BufferLen)
2964  IBuffA = numpy.ones(BufferLen)
2965  IBuffB = numpy.ones(BufferLen)
2966  First_Slow_sweep = 1
2967  #
2968  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
2969  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
2970  if discontloop > 0:
2971  session.flush()
2972  else:
2973  discontloop = 1
2974  BAWGEnab()
2975  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
2976  # waite to finish then return to open termination
2977  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
2978  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
2979  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
2980  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
2981 
2982  else: # running in continuous mode
2983  if session.continuous:
2984  if MuxScreenStatus.get() > 0:
2985  devx.flush(-1, True)
2986  DummySamples = NumSamples*2
2987  if DummySamples < 10000:
2988  DummySamples = 10000
2989  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
2990  ADsignal1 = devx.read(NumSamples, -1, True) # get samples for both channel A and B
2991  #
2992  else:
2993  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
2994 
2995  # get_samples returns a list of values for voltage [0] and current [1]
2996  for index in range(NumSamples): # calculate average
2997  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
2998  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
2999  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
3000  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
3001  DCVA0 = DCVA0/(NumSamples) # calculate V average
3002  DCVB0 = DCVB0/(NumSamples) # calculate V average
3003  DCVA0 = (DCVA0 - InOffA) * InGainA
3004  DCVB0 = (DCVB0 - InOffB) * InGainB
3005  DCIA0 = DCIA0/(NumSamples) # calculate I average
3006  DCIB0 = DCIB0/(NumSamples) # calculate I average
3007  DCIA0 = DCIA0 * 1000 # convert to mA
3008  DCIB0 = DCIB0 * 1000 # convert to mA
3009  DCIA0 = (DCIA0 - CurOffA) * CurGainA
3010  DCIB0 = (DCIB0 - CurOffB) * CurGainB
3011 # Shift in next new sample
3012  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
3013  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
3014  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
3015  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
3016 # Calculate measurement values
3017  DCV1 = numpy.mean(VBuffA)
3018  DCV2 = numpy.mean(VBuffB)
3019  DCI1 = numpy.mean(IBuffA)
3020  DCI2 = numpy.mean(IBuffB)
3021 # find min and max values
3022  MinV1 = numpy.amin(VBuffA)
3023  MaxV1 = numpy.amax(VBuffA)
3024  MinV2 = numpy.amin(VBuffB)
3025  MaxV2 = numpy.amax(VBuffB)
3026  MinI1 = numpy.amin(IBuffA)
3027  MaxI1 = numpy.amax(IBuffA)
3028  MinI2 = numpy.amin(IBuffB)
3029  MaxI2 = numpy.amax(IBuffB)
3030 # RMS value = square root of average of the data record squared
3031  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA)))
3032  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA)))
3033  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB)))
3034  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB)))
3035  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA-VBuffB)))
3036 #
3037  if TimeDisp.get() > 0:
3038  UpdateTimeAll() # Update Data, trace and time screen
3039  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3040  UpdateXYAll() # Update Data, trace and XY screen
3041  if MeasureStatus.get() > 0:
3043  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
3044  if RUNstatus.get() == 3:
3045  RUNstatus.set(0)
3046  if RUNstatus.get() == 4:
3047  RUNstatus.set(1)
3048  if TimeDisp.get() > 0:
3050  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3051  UpdateXYScreen()
3052  # update screens
3053 
3056  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
3057  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, MBuff, MBuffX, MBuffY
3058  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
3059  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
3060  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
3061  global CHA, CHB, session, devx, discontloop, contloop
3062  global TRACES, TRACESread, TRACEsize
3063  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
3064  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered
3065  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
3066  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
3067  global SCREENrefresh, DCrefresh
3068  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3069  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3070  global SV1, SI1, SV2, SI2, SVA_B
3071  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3072  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
3073  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
3074  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
3075  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
3076  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3077  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3078  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3079  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3080  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
3081  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
3082  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
3083  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
3084  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
3085  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
3086  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3087  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3088  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3089  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3090  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3091  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3092 
3093  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3094  TRACEresetTime = True # Clear the memory for averaging
3095  elif TRACEmodeTime.get() == 1:
3096  if TRACEresetTime == True:
3097  TRACEresetTime = False
3098  # Save previous trace in memory for average trace
3099  VmemoryA = VBuffA
3100  VmemoryB = VBuffB
3101  ImemoryA = IBuffA
3102  ImemoryB = IBuffB
3103 
3104  try:
3105  HoldOff = float(eval(HoldOffentry.get()))
3106  if HoldOff < 0:
3107  HoldOff = 0
3108  HoldOffentry.delete(0,END)
3109  HoldOffentry.insert(0, HoldOff)
3110  except:
3111  HoldOffentry.delete(0,END)
3112  HoldOffentry.insert(0, HoldOff)
3113 #
3114  try:
3115  HozPoss = float(eval(HozPossentry.get()))
3116  except:
3117  HozPossentry.delete(0,END)
3118  HozPossentry.insert(0, HozPoss)
3119 
3120  hldn = int(HoldOff * SAMPLErate/1000 )
3121  hozpos = int(HozPoss * SAMPLErate/1000 )
3122  if hozpos < 0:
3123  hozpos = 0
3124  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
3125  onescreen = int(twoscreens/2)
3126  if hldn+hozpos > MaxSamples-twoscreens:
3127  hldn = MaxSamples-twoscreens-hozpos
3128  HoldOffentry.delete(0,END)
3129  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
3130  if ETSDisp.get() > 0:
3131  if TIMEdiv > 0.2:
3132  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
3133  else:
3134  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
3135  if (MaxETSrecord*100) > MaxSamples:
3136  MaxETSrecord = MaxSamples / 100
3137  try:
3138  DivX = float(eval(DivXEntry.get()))
3139  if DivX < 2:
3140  DivX = 2
3141  if DivX > 75:
3142  DivX = 75
3143  DivXEntry.delete(0,END)
3144  DivXEntry.insert(0, DivX)
3145  except:
3146  DivXEntry.delete(0,END)
3147  DivXEntry.insert(0, DivX)
3148  FOff = 25
3149  MulX = (DivX*SAMPLErate)/(100*FOff)
3150  while MulX > MaxETSrecord:
3151  FOff = FOff + 5
3152  MulX = (DivX*SAMPLErate)/(100*FOff)
3153  FOff = 0 - FOff
3154  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
3155  MulXEntry.config(text = SRstring) # change displayed value
3156  SRstring = "Offset = " + str(FOff) + " samples"
3157  FOffEntry.config(text = SRstring) # change displayed value
3158  SHOWsamples = int(MulX * 100)
3159  else:
3160  SHOWsamples = twoscreens + hldn + hozpos
3161  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
3162  SHOWsamples = MaxSamples
3163  if SHOWsamples < MinSamples: # or a Min of 1000 samples
3164  SHOWsamples = MinSamples
3165  if hozpos >= 0:
3166  TRIGGERsample = hldn
3167  else:
3168  TRIGGERsample = abs(hozpos)
3169  TRIGGERsample = TRIGGERsample + hozpos #
3170 # Starting acquisition
3171  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3172  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3173  if discontloop > 0:
3174  session.flush()
3175  else:
3176  discontloop = 1
3177  time.sleep(0.01)
3178  BAWGEnab()
3179  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3180  # waite to finish then return to open termination
3181  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3182  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3183  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3184  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3185  else: # running in continuous mode
3186  if session.continuous:
3187  if MuxScreenStatus.get() > 0:
3188  devx.flush(-1, True)
3189  DummySamples = SHOWsamples*2
3190  if DummySamples < 20000:
3191  DummySamples = 20000
3192  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
3193  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
3194  #
3195  else:
3196  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
3197  # waite to finish then return to open termination
3198  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3199  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3200  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3201  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3202  #
3203  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
3204  if ADC_Mux_Mode.get() == 0: # VA and VB
3205  VBuffA = [] # Clear the V Buff array for trace A
3206  VBuffB = [] # Clear the V Buff array for trace B
3207  elif ADC_Mux_Mode.get() == 1: # IA and IB
3208  IBuffA = [] # Clear the I Buff array for trace A
3209  IBuffB = [] # Clear the I Buff array for trace B
3210  elif ADC_Mux_Mode.get() == 4: # VA and IA
3211  VBuffA = [] # Clear the V Buff array for trace A
3212  IBuffA = [] # Clear the I Buff array for trace A
3213  elif ADC_Mux_Mode.get() == 5: # VB and IB
3214  VBuffB = [] # Clear the V Buff array for trace B
3215  IBuffB = [] # Clear the I Buff array for trace B
3216  else:
3217  VBuffA = [] # Clear the V Buff array for trace A
3218  IBuffA = [] # Clear the I Buff array for trace A
3219  VBuffB = [] # Clear the V Buff array for trace B
3220  IBuffB = [] # Clear the I Buff array for trace B
3221  increment = 1
3222  # SAMPLErate = 200000 #AWGSAMPLErate
3223  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
3224  increment = 2
3225  SAMPLErate = int(AWGSAMPLErate/increment)
3226  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
3227  increment = 4
3228  SAMPLErate = int(AWGSAMPLErate/increment)
3229  index = 0
3230  if SHOWsamples != len(ADsignal1):
3231  SHOWsamples = len(ADsignal1)
3232  while index < SHOWsamples: # build arrays and decimate if needed
3233  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
3234  if ADC_Mux_Mode.get() == 0: # VA and VB
3235  VBuffA.append(ADsignal1[index][0][0])
3236  VBuffA.append(ADsignal1[index][1][1])
3237  VBuffB.append(ADsignal1[index][0][1])
3238  VBuffB.append(ADsignal1[index][1][0])
3239  if Alternate_Sweep_Mode.get() == 0:
3240  IBuffA.append(0.0) # fill as a place holder
3241  IBuffA.append(0.0) # fill as a place holder
3242  IBuffB.append(0.0) # fill as a place holder
3243  IBuffB.append(0.0) # fill as a place holder
3244  elif ADC_Mux_Mode.get() == 1: # IA and IB
3245  IBuffA.append(ADsignal1[index][0][1])
3246  IBuffA.append(ADsignal1[index][1][0])
3247  IBuffB.append(ADsignal1[index][0][0])
3248  IBuffB.append(ADsignal1[index][1][1])
3249  if Alternate_Sweep_Mode.get() == 0:
3250  VBuffA.append(0.0) # fill as a place holder
3251  VBuffA.append(0.0) # fill as a place holder
3252  VBuffB.append(0.0) # fill as a place holder
3253  VBuffB.append(0.0) # fill as a place holder
3254  elif ADC_Mux_Mode.get() == 2: # VA and IB
3255  VBuffA.append((ADsignal1[index][0][1])/1024.0)
3256  VBuffA.append((ADsignal1[index][1][0])/1024.0)
3257  #
3258  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
3259  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
3260  #
3261  if Alternate_Sweep_Mode.get() == 0:
3262  VBuffB.append(0.0) # fill as a place holder
3263  VBuffB.append(0.0) # fill as a place holder
3264  IBuffA.append(0.0) # fill as a place holder
3265  IBuffA.append(0.0) # fill as a place holder
3266  elif ADC_Mux_Mode.get() == 3: # VB and IA
3267  VBuffB.append((ADsignal1[index][0][0])/1024.0)
3268  VBuffB.append((ADsignal1[index][1][1])/1024.0)
3269  #
3270  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
3271  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
3272  #
3273  if Alternate_Sweep_Mode.get() == 0:
3274  VBuffA.append(0.0) # fill as a place holder
3275  VBuffA.append(0.0) # fill as a place holder
3276  IBuffB.append(0.0) # fill as a place holder
3277  IBuffB.append(0.0) # fill as a place holder
3278  elif ADC_Mux_Mode.get() == 4: # VA and IA
3279  VBuffA.append(ADsignal1[index][0][0])
3280  VBuffA.append(ADsignal1[index][1][1])
3281  IBuffA.append(ADsignal1[index][0][1])
3282  IBuffA.append(ADsignal1[index][1][0])
3283  if Alternate_Sweep_Mode.get() == 0:
3284  VBuffB.append(0.0) # fill as a place holder
3285  VBuffB.append(0.0) # fill as a place holder
3286  IBuffB.append(0.0) # fill as a place holder
3287  IBuffB.append(0.0) # fill as a place holder
3288  elif ADC_Mux_Mode.get() == 5: # VB and IB
3289  VBuffB.append(ADsignal1[index][0][1])
3290  VBuffB.append(ADsignal1[index][1][0])
3291  IBuffB.append(ADsignal1[index][0][0])
3292  IBuffB.append(ADsignal1[index][1][1])
3293  if Alternate_Sweep_Mode.get() == 0:
3294  VBuffA.append(0.0) # fill as a place holder
3295  VBuffA.append(0.0) # fill as a place holder
3296  IBuffA.append(0.0) # fill as a place holder
3297  IBuffA.append(0.0) # fill as a place holder
3298  else:
3299  VBuffA.append(ADsignal1[index][0][0])
3300  IBuffA.append(ADsignal1[index][0][1])
3301  VBuffB.append(ADsignal1[index][1][0])
3302  IBuffB.append(ADsignal1[index][1][1])
3303  index = index + increment
3304 #
3305  SHOWsamples = len(VBuffA)
3306  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
3307  if ADC_Mux_Mode.get() == 0: # VA and VB
3308  VBuffA = numpy.array(VBuffA)
3309  VBuffB = numpy.array(VBuffB)
3310  VBuffA = (VBuffA - InOffA) * InGainA
3311  VBuffB = (VBuffB - InOffB) * InGainB
3312  ADC_Mux_Mode.set(1) # switch mode
3313  Last_ADC_Mux_Mode = 0
3314  elif ADC_Mux_Mode.get() == 1: # IA and IB
3315  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3316  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3317  IBuffA = (IBuffA - CurOffA) * CurGainA
3318  IBuffB = (IBuffB - CurOffB) * CurGainB
3319  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
3320  elif ADC_Mux_Mode.get() == 4: # VA and IA
3321  VBuffA = numpy.array(VBuffA)
3322  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3323  IBuffA = (IBuffA - CurOffA) * CurGainA
3324  VBuffA = (VBuffA - InOffA) * InGainA
3325  ADC_Mux_Mode.set(1) # switch mode
3326  Last_ADC_Mux_Mode = 4
3327  elif ADC_Mux_Mode.get() == 5: # VB and IB
3328  VBuffB = numpy.array(VBuffB)
3329  VBuffB = (VBuffB - InOffB) * InGainB
3330  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3331  IBuffB = (IBuffB - CurOffB) * CurGainB
3332  ADC_Mux_Mode.set(1) # switch mode
3333  Last_ADC_Mux_Mode = 5
3334  SetADC_Mux()
3335  #
3336  else:
3337  VBuffA = numpy.array(VBuffA)
3338  VBuffB = numpy.array(VBuffB)
3339  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3340  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3341  VBuffA = (VBuffA - InOffA) * InGainA
3342  VBuffB = (VBuffB - InOffB) * InGainB
3343  IBuffA = (IBuffA - CurOffA) * CurGainA
3344  IBuffB = (IBuffB - CurOffB) * CurGainB
3345  TRACESread = 2
3346 # temp ETS calculations
3347  if ETSDisp.get() > 0:
3348  baseFreq = SAMPLErate/DivX
3349  #
3350  VAets = []
3351  VBets = []
3352  IAets = []
3353  IBets = []
3354  index = 0
3355  try:
3356  FMul = float(eval(FminEntry.get()))
3357  if FMul < 1:
3358  FMul = 1
3359  FMulXEntry.delete(0,END)
3360  FMulXEntry.insert(0, int(FMul))
3361  if FMul > 75:
3362  FMul = 75
3363  FMulXEntry.delete(0,END)
3364  FMulXEntry.insert(0, int(FMul))
3365  except:
3366  FMulXEntry.delete(0,END)
3367  FMulXEntry.insert(0, int(FMul))
3368  Fmin = baseFreq * FMul
3369  FminE = float(SAMPLErate + FOff)
3370  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
3371  # length of record set my Multiplcation factor
3372  tot_cycles = int((MulX*100)/Samples_Cycle)
3373  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
3374  if tot_cycles > SHOWsamples:
3375  tot_cycles = SHOWsamples-1
3376  # now sort RT data into ETS sample buffers
3377  while index < SHOWsamples:
3378  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
3379  IndexValue = int(tot_cycles * Dpart)
3380  if IndexValue > SHOWsamples:
3381  IndexValue = SHOWsamples-1
3382  if IndexValue > tot_cycles:
3383  IndexValue = tot_cycles
3384  if ETSDir.get() == 0:
3385  VAets.append(VBuffA[IndexValue])
3386  VBets.append(VBuffB[IndexValue])
3387  IAets.append(IBuffA[IndexValue])
3388  IBets.append(IBuffB[IndexValue])
3389  else:
3390  VAets.append(VBuffA[tot_cycles-IndexValue])
3391  VBets.append(VBuffB[tot_cycles-IndexValue])
3392  IAets.append(IBuffA[tot_cycles-IndexValue])
3393  IBets.append(IBuffB[tot_cycles-IndexValue])
3394  index = index + 1
3395  SHiftFact = 5
3396  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
3397  VBuffA = VAets
3398  VBuffB = VBets
3399  IBuffA = IAets
3400  IBuffB = IBets
3401  VBuffA = numpy.array(VBuffA)
3402  VBuffB = numpy.array(VBuffB)
3403  IBuffA = numpy.array(IBuffA)
3404  IBuffB = numpy.array(IBuffB)
3405  try:
3406  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
3407  except:
3408  TimeCorrection = SHiftFact
3409  if ETSDir.get() == 0:
3410  VBuffB = numpy.roll(VBuffB, TimeCorrection)
3411  IBuffB = numpy.roll(IBuffB, TimeCorrection)
3412  else:
3413  VBuffB = numpy.roll(VBuffB, TimeCorrection)
3414  IBuffB = numpy.roll(IBuffB, TimeCorrection)
3415  SHOWsamples = twoscreens + hldn + hozpos
3416 # Check if Input channel RC high pass compensation checked
3417  if CHA_RC_HP.get() == 1:
3418  try:
3419  TC1A = float(cha_TC1Entry.get())
3420  if TC1A < 0:
3421  TC1A = 0
3422  cha_TC1Entry.delete(0,END)
3423  cha_TC1Entry.insert(0, TC1A)
3424  except:
3425  TC1A = CHA_TC1.get()
3426  try:
3427  TC2A = float(cha_TC2Entry.get())
3428  if TC2A < 0:
3429  TC2A = 0
3430  cha_TC2Entry.delete(0,END)
3431  cha_TC2Entry.insert(0, TC2A)
3432  except:
3433  TC2A = CHA_TC2.get()
3434  #
3435  try:
3436  Gain1A = float(cha_A1Entry.get())
3437  except:
3438  Gain1A = CHA_A1.get()
3439  try:
3440  Gain2A = float(cha_A2Entry.get())
3441  except:
3442  Gain2A = CHA_A2.get()
3443  #
3444  if len(VBuffA) > 4:
3445  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
3446  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
3447  if CHB_RC_HP.get() == 1:
3448  try:
3449  TC1B = float(chb_TC1Entry.get())
3450  if TC1B < 0:
3451  TC1B = 0
3452  chb_TC1Entry.delete(0, END)
3453  chb_TC1Entry.insert(0, TC1B)
3454  except:
3455  TC1B = CHB_TC1.get()
3456  try:
3457  TC2B = float(chb_TC2Entry.get())
3458  if TC2B < 0:
3459  TC2B = 0
3460  chb_TC2Entry.delete(0, END)
3461  chb_TC2Entry.insert(0, TC2B)
3462  except:
3463  TC2B = CHB_TC2.get()
3464  #
3465  try:
3466  Gain1B = float(chb_A1Entry.get())
3467  except:
3468  Gain1B = CHB_A1.get()
3469  try:
3470  Gain2B = float(chb_A2Entry.get())
3471  except:
3472  Gain2B = CHB_A2.get()
3473  #
3474  if len(VBuffB) > 4:
3475  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
3476  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
3477 # check if digital filter box checked
3478  if DigFiltA.get() == 1:
3479  if len(DFiltACoef) > 1:
3480  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
3481  if DigFiltB.get() == 1:
3482  if len(DFiltBCoef) > 1:
3483  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
3484 # Find trigger sample point if necessary
3485  LShift = 0
3486  if TgInput.get() == 1:
3487  FindTriggerSample(VBuffA)
3488  if TgInput.get() == 2:
3489  FindTriggerSample(IBuffA)
3490  if TgInput.get() == 3:
3491  FindTriggerSample(VBuffB)
3492  if TgInput.get() == 4:
3493  FindTriggerSample(IBuffB)
3494  if TgInput.get() > 4: # trigger on math trace
3495  CalcMathBuff()
3496  if TgInput.get() == 5:
3497  FindTriggerSample(MBuff)
3498  if TgInput.get() == 6:
3499  FindTriggerSample(MBuffX)
3500  if TgInput.get() == 7:
3501  FindTriggerSample(MBuffY)
3502  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
3503  # Average mode 1, add difference / TRACEaverage to array
3504  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
3505  LShift = 0 - TRIGGERsample
3506  VBuffA = numpy.roll(VBuffA, LShift)
3507  VBuffB = numpy.roll(VBuffB, LShift)
3508  IBuffA = numpy.roll(IBuffA, LShift)
3509  IBuffB = numpy.roll(IBuffB, LShift)
3510  if TgInput.get() > 4: # Change when Make Time Trace is updated to use Math Buffers
3511  if TgInput.get() == 5:
3512  MBuff = numpy.roll(MBuff, LShift)
3513  if TgInput.get() == 6:
3514  MBuffX = numpy.roll(MBuffX, LShift)
3515  if TgInput.get() == 7:
3516  MBuffY = numpy.roll(MBuffY, LShift)
3517  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
3518  try:
3519  if DualMuxMode.get() == 0 and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
3520  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
3521  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
3522  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
3523  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
3524  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
3525  except:
3526  # buffer size mismatch so reset memory buffers
3527  VmemoryA = VBuffA
3528  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
3529  VmemoryB = VBuffB
3530  ImemoryA = IBuffA
3531  ImemoryB = IBuffB
3532  if TgInput.get() == 1:
3533  ReInterploateTrigger(VBuffA)
3534  if TgInput.get() == 2:
3535  ReInterploateTrigger(IBuffA)
3536  if TgInput.get() == 3:
3537  ReInterploateTrigger(VBuffB)
3538  if TgInput.get() == 4:
3539  ReInterploateTrigger(IBuffB)
3540 # DC value = average of the data record
3541  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
3542  Endsample = hldn+onescreen # average over only one screen's worth of samples
3543  else:
3544  Endsample = SHOWsamples - 10 # average over all samples
3545  if MeasGateStatus.get() == 1:
3546  if (MeasGateRight-MeasGateLeft) > 0:
3547  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
3548  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
3549  DCV1 = numpy.mean(VBuffA[hldn:Endsample])
3550  DCV2 = numpy.mean(VBuffB[hldn:Endsample])
3551  # convert current values to mA
3552  DCI1 = numpy.mean(IBuffA[hldn:Endsample])
3553  DCI2 = numpy.mean(IBuffB[hldn:Endsample])
3554 # find min and max values
3555  MinV1 = numpy.amin(VBuffA[hldn:Endsample])
3556  MaxV1 = numpy.amax(VBuffA[hldn:Endsample])
3557  MinV2 = numpy.amin(VBuffB[hldn:Endsample])
3558  MaxV2 = numpy.amax(VBuffB[hldn:Endsample])
3559  MinI1 = numpy.amin(IBuffA[hldn:Endsample])
3560  MaxI1 = numpy.amax(IBuffA[hldn:Endsample])
3561  MinI2 = numpy.amin(IBuffB[hldn:Endsample])
3562  MaxI2 = numpy.amax(IBuffB[hldn:Endsample])
3563 # RMS value = square root of average of the data record squared
3564  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample])))
3565  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[hldn:Endsample])))
3566  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[hldn:Endsample])))
3567  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[hldn:Endsample])))
3568  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample]-VBuffB[hldn:Endsample])))
3569 # Transfer to mux buffers as necessary
3570  if TgInput.get() > 0 and MuxChan > -1 and TRACEmodeTime.get() != 1:
3571  # if triggering left shift all arrays such that trigger point is at index 0
3572  LShift = 0 - TRIGGERsample
3573  VBuffA = numpy.roll(VBuffA, LShift)
3574  VBuffB = numpy.roll(VBuffB, LShift)
3575  IBuffA = numpy.roll(IBuffA, LShift)
3576  IBuffB = numpy.roll(IBuffB, LShift)
3577  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
3578  if MuxChan > -1:
3579  Dval0 = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
3580  Dval1 = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
3581  if Show_CBA.get() == 1 and Dval0[0] == 0 and Dval1[0] == 0:
3582  DCVMuxA = DCV2
3583  MinVMuxA = MinV2
3584  MaxVMuxA = MaxV2
3585  MidVMuxA = (MaxV2+MinV2)/2.0
3586  PPVMuxA = MaxV2-MinV2
3587  SVMuxA = SV2
3588  VBuffMA = VBuffB
3589  if Show_CBB.get() == 1 and Dval0[0] == 1 and Dval1[0] == 0:
3590  DCVMuxB = DCV2
3591  MinVMuxB = MinV2
3592  MaxVMuxB = MaxV2
3593  MidVMuxB = (MaxV2+MinV2)/2.0
3594  PPVMuxB = MaxV2-MinV2
3595  SVMuxB = SV2
3596  VBuffMB = VBuffB
3597  if Show_CBC.get() == 1 and Dval0[0] == 0 and Dval1[0] == 1:
3598  if DualMuxMode.get() == 1:
3599  DCVMuxC = DCV1
3600  MinVMuxC = MinV1
3601  MaxVMuxC = MaxV1
3602  MidVMuxC = (MaxV1+MinV1)/2.0
3603  PPVMuxC = MaxV1-MinV1
3604  SVMuxC = SV1
3605  VBuffMC = VBuffA
3606  else:
3607  DCVMuxC = DCV2
3608  MinVMuxC = MinV2
3609  MaxVMuxC = MaxV2
3610  MidVMuxC = (MaxV2+MinV2)/2.0
3611  PPVMuxC = MaxV2-MinV2
3612  SVMuxC = SV2
3613  VBuffMC = VBuffB
3614  if Show_CBD.get() == 1 and Dval0[0] == 1 and Dval1[0] == 1:
3615  if DualMuxMode.get() == 1:
3616  DCVMuxD = DCV1
3617  MinVMuxD = MinV1
3618  MaxVMuxD = MaxV1
3619  MidVMuxD = (MaxV1+MinV1)/2.0
3620  PPVMuxD = MaxV1-MinV1
3621  SVMuxD = SV1
3622  VBuffMD = VBuffA
3623  else:
3624  DCVMuxD = DCV2
3625  MinVMuxD = MinV2
3626  MaxVMuxD = MaxV2
3627  MidVMuxD = (MaxV2+MinV2)/2.0
3628  PPVMuxD = MaxV2-MinV2
3629  SVMuxD = SV2
3630  VBuffMD = VBuffB
3631 #
3632  if TimeDisp.get() > 0:
3633  UpdateTimeAll() # Update Data, trace and time screen
3634  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3635  UpdateXYAll() # Update Data, trace and XY screen
3636  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
3637  BStop() #
3638  SingleShot.set(0)
3639  if ManualTrigger.get() == 1: # Manual trigger is on
3640  BStop() #
3641  if MeasureStatus.get() > 0:
3643  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
3644  if RUNstatus.get() == 3:
3645  RUNstatus.set(0)
3646  if RUNstatus.get() == 4:
3647  RUNstatus.set(1)
3648  if TimeDisp.get() > 0:
3650  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3651  UpdateXYScreen()
3652  # update screens
3653 #
3654 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
3655 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
3656 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
3657 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
3658 
3659 
3661 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
3662  global SAMPLErate
3663 
3664  OutBuff = []
3665  n = len(InBuff)
3666  Delta = 1.0/SAMPLErate
3667  TC = TC1 * 1.0E-6
3668  Alpha = TC / (TC + Delta)
3669  OutBuff.append(InBuff[1]-InBuff[0]) # set inital sample to derivative (difference of first two samples)
3670  i = 1
3671  while i < n:
3672  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
3673  i += 1
3674  OutBuff = numpy.array(OutBuff)
3675  OutBuff = InBuff + (OutBuff * Gain)
3676  return OutBuff
3677 
3679 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
3680  global SAMPLErate
3681 
3682  OutBuff = []
3683  n = len(InBuff)
3684  Delta = 1.0/SAMPLErate
3685  TC = TC1 * 1.0E-6
3686  Alpha = Delta / (TC + Delta)
3687  i = 1
3688  OutBuff.append(Alpha*InBuff[0])
3689  while i < n:
3690  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
3691  i += 1
3692  OutBuff = numpy.array(OutBuff)
3693  OutBuff = (OutBuff * Gain)
3694  return OutBuff
3695 
3699 def shift_buffer(arr, num, fill_value=numpy.nan):
3700  result = numpy.empty_like(arr)
3701  if num > 0:
3702  result[:num] = fill_value
3703  result[num:] = arr[:-num]
3704  elif num < 0:
3705  result[num:] = fill_value
3706  result[:num] = arr[-num:]
3707  else:
3708  result[:] = arr
3709  return result
3710 
3711 
3714  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
3715  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
3716  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
3717  global NSteps, LoopNum, FSweepMode, FStep, FBins
3718  global StartFreqEntry, StopFreqEntry, HoldOffentry
3719  global session, CHA, CHB, devx, MaxSamples, discontloop
3720  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
3721  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
3722  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
3723  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
3724  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
3725  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3726  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
3727  global BDSweepFile, FileSweepFreq, FileSweepAmpl
3728  global PIO_0, PIO_1, PIO_2, PIO_3
3729  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3730  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3731  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3732  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3733  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
3734 
3735  HalfSAMPLErate = SAMPLErate/2
3736  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3737  try:
3738  InOffA = float(eval(CHAVOffsetEntry.get()))
3739  except:
3740  CHAVOffsetEntry.delete(0,END)
3741  CHAVOffsetEntry.insert(0, InOffA)
3742  try:
3743  InGainA = float(eval(CHAVGainEntry.get()))
3744  except:
3745  CHAVGainEntry.delete(0,END)
3746  CHAVGainEntry.insert(0, InGainA)
3747  try:
3748  InOffB = float(eval(CHBVOffsetEntry.get()))
3749  except:
3750  CHBVOffsetEntry.delete(0,END)
3751  CHBVOffsetEntry.insert(0, InOffB)
3752  try:
3753  InGainB = float(eval(CHBVGainEntry.get()))
3754  except:
3755  CHBVGainEntry.delete(0,END)
3756  CHBVGainEntry.insert(0, InGainB)
3757  try:
3758  HoldOff = float(eval(HoldOffentry.get()))
3759  if HoldOff < 0:
3760  HoldOff = 0
3761  HoldOffentry.delete(0,END)
3762  HoldOffentry.insert(0, HoldOff)
3763  except:
3764  HoldOffentry.delete(0,END)
3765  HoldOffentry.insert(0, HoldOff)
3766  #
3767  INITIALIZEstart()
3768  # Starting acquisition This is a HACK to get around non-continous AWG mode!
3769  # restart AWGs if indicated
3770  if BodeDisp.get() == 0: # make new noise waveforms each sweep
3771  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
3772  AWGAMakeUUNoise()
3773  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
3774  AWGAMakeUGNoise()
3775  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
3776  AWGBMakeUUNoise()
3777  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
3778  AWGBMakeUGNoise()
3779  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
3780  if BDSweepFile.get() == 0:
3781  if LoopNum.get() <= len(FStep):
3782  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
3783  else:
3784  FregPoint = FBins[FStep[0]]
3785  else:
3786  if LoopNum.get() <= len(FileSweepFreq): #
3787  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
3788  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
3789  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
3790  else:
3791  FregPoint = FBins[FileSweepFreq[0]]
3792  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
3793  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
3794  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
3795  if FSweepMode.get() == 1: # set new CH-A amplitude
3796  AWGAAmplEntry.delete(0,END)
3797  AWGAAmplEntry.insert(4, VMin)
3798  AWGAOffsetEntry.delete(0,END)
3799  AWGAOffsetEntry.insert(4, VMax)
3800  if FSweepMode.get() == 2: # set new CH-B amplitude
3801  AWGBAmplEntry.delete(0,END)
3802  AWGBAmplEntry.insert(4, VMin)
3803  AWGBOffsetEntry.delete(0,END)
3804  AWGBOffsetEntry.insert(4, VMax)
3805  if FSweepMode.get() == 1: # set new CH-A frequency
3806  AWGAFreqEntry.delete(0,END)
3807  AWGAFreqEntry.insert(4, FregPoint)
3809  if FSweepMode.get() == 2: # set new CH-B frequency
3810  AWGBFreqEntry.delete(0,END)
3811  AWGBFreqEntry.insert(4, FregPoint)
3813  if FSweepMode.get() == 3: # set new MiniGen frequency
3814  MinigenFout.delete(0,END)
3815  MinigenFout.insert(4, FregPoint)
3816  BSendMG()
3817  if AWGSync.get() > 0:
3818  if IAScreenStatus.get() > 0 and IASource.get() == 0:
3819  if Two_X_Sample.get() == 1:
3820  AWGBIOMode.set(1)
3821  AWGBMode.set(0)
3822  else:
3823  AWGBMode.set(2)
3824  # BAWGEnab()
3825 #
3826  hldn = int(HoldOff * 100 )
3827  if hldn > MaxSamples-SMPfft:
3828  hldn = MaxSamples-SMPfft
3829  HoldOffentry.delete(0,END)
3830  HoldOffentry.insert(0, hldn/100)
3831  if hldn < 128:
3832  hldn = 128
3833  SHOWsamples = SMPfft + hldn # get holf off extra samples
3834  if BodeDisp.get() > 0: # check if doing Bode Plot
3835  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
3836  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3837  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3838  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3839  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
3840  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3841  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3842  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3843  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
3844  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3845  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3846  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3847  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
3848  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3849  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3850  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3851  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3852  if IAScreenStatus.get() > 0 and IASource.get() == 0:
3853  if Two_X_Sample.get() == 1:
3854  AWGBIOMode.set(1)
3855  AWGBMode.set(0)
3856  else:
3857  AWGBMode.set(2)
3858  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3859  if discontloop > 0:
3860  session.flush()
3861  else:
3862  discontloop = 1
3863  BAWGEnab()
3864  try:
3865  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3866  except:
3867  donothing()
3868  # waite to finish then return to open termination
3869  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3870  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3871  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3872  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3873  else: # running in continuous mode
3874  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
3875  #
3876  else:
3877  if session.continuous:
3878  ADsignal1 = devx.read(SHOWsamples, -1, True)
3879  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3880  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3881  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3882  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3883  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3884  FFTBuffA = [] # Clear the FFTBuff array for trace A
3885  FFTBuffB = [] # Clear the FFTBuff array for trace B
3886  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
3887  index = hldn # skip first hldn samples
3888  if SHOWsamples != len(ADsignal1):
3889  SHOWsamples = len(ADsignal1)
3890  while index < SHOWsamples:
3891  if Two_X_Sample.get() == 1:
3892  if ADC_Mux_Mode.get() == 0: # VA and VB
3893  FFTBuffA.append(ADsignal1[index][0][0])
3894  FFTBuffA.append(ADsignal1[index][1][1])
3895  FFTBuffB.append(ADsignal1[index][0][1])
3896  FFTBuffB.append(ADsignal1[index][1][0])
3897  else:
3898  VAdata = ADsignal1[index][0][0]
3899  FFTBuffA.append(VAdata)
3900  VBdata = ADsignal1[index][1][0]
3901  FFTBuffB.append(VBdata)
3902  if VAdata > 5.0 or VAdata < 0.0:
3903  OverRangeFlagA = 1
3904 
3905  if VBdata > 5.0 or VBdata < 0.0:
3906  OverRangeFlagB = 1
3907  index = index + 1
3908 
3909  FFTBuffA = numpy.array(FFTBuffA)
3910  FFTBuffB = numpy.array(FFTBuffB)
3911  FFTBuffA = (FFTBuffA - InOffA) * InGainA
3912  FFTBuffB = (FFTBuffB - InOffB) * InGainB
3913  DCA = numpy.average(FFTBuffA)
3914  DCB = numpy.average(FFTBuffB)
3915  if CutDC.get() == 1:
3916  FFTBuffA = FFTBuffA - DCA
3917  FFTBuffB = FFTBuffB - DCB
3918 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3919  if CHA_RC_HP.get() == 1:
3920  try:
3921  TC1A = float(cha_TC1Entry.get())
3922  if TC1A < 0:
3923  TC1A = 0
3924  cha_TC1Entry.delete(0,END)
3925  cha_TC1Entry.insert(0, TC1A)
3926  except:
3927  TC1A = CHA_TC1.get()
3928  try:
3929  TC2A = float(cha_TC2Entry.get())
3930  if TC2A < 0:
3931  TC2A = 0
3932  cha_TC2Entry.delete(0,END)
3933  cha_TC2Entry.insert(0, TC2A)
3934  except:
3935  TC2A = CHA_TC2.get()
3936  #
3937  try:
3938  Gain1A = float(cha_A1Entry.get())
3939  except:
3940  Gain1A = CHA_A1.get()
3941  try:
3942  Gain2A = float(cha_A2Entry.get())
3943  except:
3944  Gain2A = CHA_A2.get()
3945  #
3946  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
3947  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
3948  if CHB_RC_HP.get() == 1:
3949  try:
3950  TC1B = float(chb_TC1Entry.get())
3951  if TC1B < 0:
3952  TC1B = 0
3953  chb_TC1Entry.delete(0, END)
3954  chb_TC1Entry.insert(0, TC1B)
3955  except:
3956  TC1B = CHB_TC1.get()
3957  try:
3958  TC2B = float(chb_TC2Entry.get())
3959  if TC2B < 0:
3960  TC2B = 0
3961  chb_TC2Entry.delete(0, END)
3962  chb_TC2Entry.insert(0, TC2B)
3963  except:
3964  TC2B = CHB_TC2.get()
3965  #
3966  try:
3967  Gain1B = float(chb_A1Entry.get())
3968  except:
3969  Gain1B = CHB_A1.get()
3970  try:
3971  Gain2B = float(chb_A2Entry.get())
3972  except:
3973  Gain2B = CHB_A2.get()
3974  #
3975  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
3976  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
3977 # check if digital filter box checked
3978  if DigFiltA.get() == 1:
3979  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
3980  if DigFiltB.get() == 1:
3981  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
3982  DoFFT()
3983  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
3984  UpdateFreqAll() # Update spectrum Data, trace and screen
3985  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
3986  UpdateIAAll()
3987  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
3988  UpdateBodeAll()
3989  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
3990  UpdateNqPAll()
3991  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
3992  UpdateNiCAll()
3993  if SingleShotSA.get() == 1: # Single shot sweep is on
3994  RUNstatus.set(0)
3995 # RUNstatus = 3: Stop
3996 # RUNstatus = 4: Stop and restart
3997  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
3998  if RUNstatus.get() == 3:
3999  RUNstatus.set(0) # Status is stopped
4000  if RUNstatus.get() == 4:
4001  RUNstatus.set(1) # Status is (re)start
4002  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
4003  UpdateFreqScreen() # Freq UpdateScreen() call
4004  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
4005  UpdateIAScreen()
4006  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
4007  LoopNum.set(LoopNum.get() + 1)
4008  if LoopNum.get() > NSteps.get():
4009  if FSweepMode.get() == 1:
4010  AWGAFreqEntry.delete(0,"end")
4011  AWGAFreqEntry.insert(0, Reset_Freq)
4012  if FSweepMode.get() == 2:
4013  AWGBFreqEntry.delete(0,"end")
4014  AWGBFreqEntry.insert(0, Reset_Freq)
4015 #
4016  LoopNum.set(1)
4017  if FSweepCont.get() == 0:
4018  RUNstatus.set(0)
4019 
4021  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
4022  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
4023  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
4024  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4025  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4026  global VABase, VATop, VBBase, VBTop
4027 
4028  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
4029  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
4030  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
4031  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
4032  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
4033  LowerPeak = 0
4034  UpperPeak = 0
4035  b = 0
4036  while (b < 4999):
4037  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
4038  LowerPeak = b
4039  VABase = HBuffA[1][b]
4040  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
4041  UpperPeak = b
4042  VATop = HBuffA[1][b]
4043  b = b + 1
4044  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
4045  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
4046  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
4047  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
4048  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
4049  LowerPeak = 0
4050  UpperPeak = 0
4051  b = 0
4052  while (b < 4999):
4053  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
4054  LowerPeak = b
4055  VBBase = HBuffB[1][b]
4056  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
4057  UpperPeak = b
4058  VBTop = HBuffB[1][b]
4059  b = b + 1
4060 
4062  global HistAsPercent
4063 
4064  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
4065  HistAsPercent = 1
4066  else:
4067  HistAsPercent = 0
4068 
4069 def FindRisingEdge(Trace1, Trace2):
4070  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
4071  # global VBuffA, VBuffB
4072  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
4073  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
4074  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
4075 
4076  anr1 = bnr1 = 0
4077  anf1 = bnf1 = 1
4078  anr2 = bnr2 = 2
4079  hldn = int(HoldOff * SAMPLErate/1000)
4080  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
4081  Trace1 = numpy.roll(Trace1, -LShift)
4082  Trace2 = numpy.roll(Trace2, -LShift)
4083  else:
4084  Trace1 = numpy.roll(Trace1, -hldn)
4085  Trace2 = numpy.roll(Trace2, -hldn)
4086  try:
4087  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
4088  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
4089  except:
4090  MidV1 = (MinV1+MaxV1)/2
4091  MidV2 = (MinV2+MaxV2)/2
4092 # search Trace 1
4093  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
4094  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
4095  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
4096  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
4097 
4098  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
4099  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
4100  if len(Arising) > 0 or len(Afalling) > 0:
4101  if Arising[0] > 0:
4102  try:
4103  anr1 = AIrising[0]
4104  except:
4105  anr1 = 0
4106  try:
4107  anr2 = AIrising[1]
4108  except:
4109  anr2 = SHOWsamples
4110  try:
4111  if AIfalling[0] < AIrising[0]:
4112  anf1 = AIfalling[1]
4113  else:
4114  anf1 = AIfalling[0]
4115  except:
4116  anf1 = 1
4117  else:
4118  try:
4119  anr1 = AIrising[1]
4120  except:
4121  anr1 = 0
4122  try:
4123  anr2 = AIrising[2]
4124  except:
4125  anr2 = SHOWsamples
4126  try:
4127  if AIfalling[1] < AIrising[1]:
4128  anf1 = AIfalling[2]
4129  else:
4130  anf1 = AIfalling[1]
4131  except:
4132  anf1 = 1
4133 # search Trace 2
4134  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
4135  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
4136  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
4137  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
4138 
4139  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
4140  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
4141  if len(Brising) > 0 or len(Bfalling) > 0:
4142  if Brising[0] > 0:
4143  try:
4144  bnr1 = BIrising[0]
4145  except:
4146  bnr1 = 0
4147  try:
4148  bnr2 = BIrising[1]
4149  except:
4150  bnr2 = SHOWsamples
4151  try:
4152  if BIfalling[0] < BIrising[0]:
4153  bnf1 = BIfalling[1]
4154  else:
4155  bnf1 = BIfalling[0]
4156  except:
4157  bnf1 = 1
4158  else:
4159  try:
4160  bnr1 = BIrising[1]
4161  except:
4162  bnr1 = 0
4163  try:
4164  bnr2 = BIrising[2]
4165  except:
4166  bnr2 = SHOWsamples
4167  try:
4168  if BIfalling[1] < BIrising[1]:
4169  bnf1 = BIfalling[2]
4170  else:
4171  bnf1 = BIfalling[1]
4172  except:
4173  bnf1 = 1
4174  #
4175  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
4176  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
4177  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
4178  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
4179  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
4180  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
4181 #
4182  if bnr1 > anr1:
4183  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
4184  else:
4185  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
4186  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
4187  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
4188  try:
4189  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
4190  except:
4191  CHABphase = 0.0
4192  if CHABphase < 0.0:
4193  CHABphase = CHABphase + 360.0
4194 
4196  global DX, TRIGGERsample, TRIGGERlevel
4197 
4198  DX = 0
4199  n = TRIGGERsample
4200  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
4201  if DY != 0.0:
4202  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
4203  else:
4204  DX = 0
4205 
4206 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
4207  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
4208  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
4209 
4210  # Set the TRACEsize variable
4211  TRACEsize = SHOWsamples # Set the trace length
4212  DX = 0
4213  Is_Triggered = 0
4214  if len(TrgBuff) == 0:
4215  return
4216  try:
4217  TrgMin = numpy.amin(TrgBuff)
4218  except:
4219  TrgMin = 0.0
4220  try:
4221  TrgMax = numpy.amax(TrgBuff)
4222  except:
4223  TrgMax = 0.0
4224 # Find trigger sample
4225  try:
4226  if AutoLevel.get() == 1:
4227  TRIGGERlevel = (TrgMin + TrgMax)/2
4228  TRIGGERentry.delete(0,"end")
4229  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
4230  else:
4231  TRIGGERlevel = eval(TRIGGERentry.get())
4232  except:
4233  TRIGGERentry.delete(0,END)
4234  TRIGGERentry.insert(0, TRIGGERlevel)
4235 # Start from first sample after HoldOff
4236  try:
4237  HoldOff = float(eval(HoldOffentry.get()))
4238  if HoldOff < 0:
4239  HoldOff = 0
4240  HoldOffentry.delete(0,END)
4241  HoldOffentry.insert(0, HoldOff)
4242  except:
4243  HoldOffentry.delete(0,END)
4244  HoldOffentry.insert(0, HoldOff)
4245 # slide trace left right by HozPoss
4246  try:
4247  HozPoss = float(eval(HozPossentry.get()))
4248  except:
4249  HozPossentry.delete(0,END)
4250  HozPossentry.insert(0, HozPoss)
4251 
4252  hldn = int(HoldOff * SAMPLErate/1000)
4253  hozpos = int(HozPoss * SAMPLErate/1000)
4254  if hozpos >= 0:
4255  TRIGGERsample = hldn
4256  else:
4257  TRIGGERsample = abs(hozpos)
4258 #
4259  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
4260  DX = 0
4261  n = TRIGGERsample
4262  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
4263  if TRIGGERlevel2 < TrgMin:
4264  TRIGGERlevel2 = TrgMin
4265  if TRIGGERlevel2 > TrgMax:
4266  TRIGGERlevel2 = TrgMax
4267  ChInput = TrgBuff[int(n)]
4268  Prev = ChInput
4269  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
4270  n = n + 1
4271  ChInput = TrgBuff[int(n)]
4272  while (ChInput <= TRIGGERlevel) and n < Nmax:
4273  Prev = ChInput
4274  n = n + 1
4275  ChInput = TrgBuff[int(n)]
4276  DY = ChInput - Prev
4277  if DY != 0.0:
4278  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
4279  else:
4280  DX = 0
4281  if TgEdge.get() == 1:
4282  TRIGGERlevel2 = 1.01 * TRIGGERlevel
4283  if TRIGGERlevel2 < TrgMin:
4284  TRIGGERlevel2 = TrgMin
4285  if TRIGGERlevel2 > TrgMax:
4286  TRIGGERlevel2 = TrgMax
4287  ChInput = TrgBuff[int(n)]
4288  Prev = ChInput
4289  while (ChInput <= TRIGGERlevel2) and n < Nmax:
4290  n = n + 1
4291  ChInput = TrgBuff[int(n)]
4292  while (ChInput >= TRIGGERlevel) and n < Nmax:
4293  Prev = ChInput
4294  n = n + 1
4295  ChInput = TrgBuff[int(n)]
4296  DY = Prev - ChInput
4297  try:
4298  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
4299  except:
4300  DX = 0
4301 
4302 # check to insure trigger point is in bounds
4303  if n < Nmax:
4304  TRIGGERsample = n - 1
4305  Is_Triggered = 1
4306  elif n > Nmax: # Didn't find edge in first 2/3 of data set
4307  TRIGGERsample = 1 + hldn # reset to begining
4308  Is_Triggered = 0
4309  if DX > 1:
4310  DX = 1 # never more than 100% of a sample period
4311  elif DX < 0:
4312  DX = 0 # never less than 0% of a sample period
4313  if math.isnan(DX):
4314  DX = 0
4315  TRIGGERsample = TRIGGERsample + hozpos
4316 
4318  global win2, DigScreenStatus
4319 
4320  DigScreenStatus.set(0)
4321  win2.destroy()
4322 
4323 def sel():
4324  global devx, DevID
4325  global D0, D1, D2, D3, D4, D5, D6, D7
4326  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4327  # sending 0x50 = set to 0, 0x51 = set to 1
4328  if D0.get() > 0:
4329  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
4330  else:
4331  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
4332  if D1.get() > 0:
4333  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
4334  else:
4335  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
4336  if D2.get() > 0:
4337  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
4338  else:
4339  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
4340  if D3.get() > 0:
4341  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
4342  else:
4343  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
4344  if D4.get() > 0:
4345  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
4346  else:
4347  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
4348  if D5.get() > 0:
4349  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
4350  else:
4351  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
4352  if D6.get() > 0:
4353  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
4354  else:
4355  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
4356  if D7.get() > 0:
4357  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
4358  else:
4359  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
4360 
4362  global D0, D1, D2, D3, D4, D5, D6, D7
4363  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4364  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
4365  # setup Dig output window
4366  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
4367  DigScreenStatus.set(1)
4368  win2 = Toplevel()
4369  win2.title("Dig Out")
4370  win2.resizable(FALSE,FALSE)
4371  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
4372  rb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
4373  rb1.grid(row=2, column=0, sticky=W)
4374  rb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
4375  rb0z.grid(row=2, column=1, sticky=W)
4376  rb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
4377  rb2.grid(row=2, column=2, sticky=W)
4378  rb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
4379  rb3.grid(row=3, column=0, sticky=W)
4380  rb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
4381  rb3z.grid(row=3, column=1, sticky=W)
4382  rb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
4383  rb4.grid(row=3, column=2, sticky=W)
4384  rb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
4385  rb5.grid(row=4, column=0, sticky=W)
4386  rb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
4387  rb5z.grid(row=4, column=1, sticky=W)
4388  rb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
4389  rb6.grid(row=4, column=2, sticky=W)
4390  rb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
4391  rb7.grid(row=5, column=0, sticky=W)
4392  rb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
4393  rb7z.grid(row=5, column=1, sticky=W)
4394  rb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
4395  rb8.grid(row=5, column=2, sticky=W)
4396  rb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
4397  rb9.grid(row=6, column=0, sticky=W)
4398  rb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
4399  rb9z.grid(row=6, column=1, sticky=W)
4400  rb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
4401  rb10.grid(row=6, column=2, sticky=W)
4402  rb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
4403  rb11.grid(row=7, column=0, sticky=W)
4404  rb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
4405  rb11z.grid(row=7, column=1, sticky=W)
4406  rb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
4407  rb12.grid(row=7, column=2, sticky=W)
4408  rb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
4409  rb13.grid(row=8, column=0, sticky=W)
4410  rb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
4411  rb13z.grid(row=8, column=1, sticky=W)
4412  rb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
4413  rb13.grid(row=8, column=2, sticky=W)
4414  rb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
4415  rb14.grid(row=9, column=0, sticky=W)
4416  rb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
4417  rb14z.grid(row=9, column=1, sticky=W)
4418  rb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
4419  rb15.grid(row=9, column=2, sticky=W)
4420 
4421  dismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
4422  dismissbutton.grid(row=10, column=0, sticky=W)
4423 
4425  global win1, DacScreenStatus
4426 
4427  DacScreenStatus.set(0)
4428  win1.destroy()
4429 
4430 def sel0(temp):
4431  global devx, DevID
4432  global PIO_0, PIO_4
4433  global DAC0
4434  # sending 0x50 = set to 0, 0x51 = set to 1
4435  if DAC0.get() == 1:
4436  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4437  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
4438  elif DAC0.get() == 4:
4439  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4440  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
4441  elif DAC0.get() == 2:
4442  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4443  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4444  elif DAC0.get() == 3:
4445  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
4446  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
4447  elif DAC0.get() == 5:
4448  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
4449  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4450  elif DAC0.get() == 7:
4451  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
4452  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
4453  elif DAC0.get() == 8:
4454  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
4455  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4456  elif DAC0.get() == 6:
4457  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
4458  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
4459  elif DAC0.get() == 9:
4460  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
4461  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
4462 
4463 def sel1(temp):
4464  global devx, DevID
4465  global PIO_1, PIO_5
4466  global DAC1
4467  # sending 0x50 = set to 0, 0x51 = set to 1
4468  if DAC1.get() == 1:
4469  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4470  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
4471  elif DAC1.get() == 4:
4472  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4473  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
4474  elif DAC1.get() == 2:
4475  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4476  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4477  elif DAC1.get() == 3:
4478  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4479  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
4480  elif DAC1.get() == 5:
4481  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4482  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4483  elif DAC1.get() == 7:
4484  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4485  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
4486  elif DAC1.get() == 8:
4487  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
4488  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4489  elif DAC1.get() == 6:
4490  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
4491  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
4492  elif DAC1.get() == 9:
4493  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
4494  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
4495 
4496 def sel2(temp):
4497  global devx, DevID
4498  global PIO_2, PIO_6
4499  global DAC2
4500  # sending 0x50 = set to 0, 0x51 = set to 1
4501  if DAC2.get() == 1:
4502  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4503  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
4504  elif DAC2.get() == 4:
4505  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4506  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
4507  elif DAC2.get() == 2:
4508  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4509  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4510  elif DAC2.get() == 3:
4511  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4512  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
4513  elif DAC2.get() == 5:
4514  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4515  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4516  elif DAC2.get() == 7:
4517  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4518  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
4519  elif DAC2.get() == 8:
4520  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
4521  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4522  elif DAC2.get() == 6:
4523  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
4524  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
4525  elif DAC2.get() == 9:
4526  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
4527  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
4528 
4529 def sel3(temp):
4530  global devx, DevID
4531  global PIO_3, PIO_7
4532  global DAC3
4533  # sending 0x50 = set to 0, 0x51 = set to 1
4534  if DAC3.get() == 1:
4535  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4536  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
4537  elif DAC3.get() == 4:
4538  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4539  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
4540  elif DAC3.get() == 2:
4541  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4542  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4543  elif DAC3.get() == 3:
4544  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4545  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
4546  elif DAC3.get() == 5:
4547  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4548  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4549  elif DAC3.get() == 7:
4550  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4551  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
4552  elif DAC3.get() == 8:
4553  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
4554  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4555  elif DAC3.get() == 6:
4556  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
4557  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
4558  elif DAC3.get() == 9:
4559  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
4560  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
4561 
4563  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
4564  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
4565  # setup Dig output window
4566  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
4567  DacScreenStatus.set(1)
4568  win1 = Toplevel()
4569  win1.title("DAC Out "+ SWRev + RevDate)
4570  win1.resizable(FALSE,FALSE)
4571  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
4572  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
4573  DAC0.grid(row=0, column=0, sticky=W)
4574  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
4575  DAC1.grid(row=0, column=1, sticky=W)
4576  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
4577  DAC2.grid(row=0, column=2, sticky=W)
4578  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
4579  DAC3.grid(row=0, column=3, sticky=W)
4580 
4581  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
4582  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
4583 
4585 
4586  MakeTimeTrace() # Update the traces
4587  UpdateTimeScreen() # Update the screen
4588 
4590 
4591  MakeTimeTrace() # Update traces
4592  UpdateTimeScreen() # Update the screen
4593 
4595 
4596  MakeTimeScreen() # Update the screen
4597  root.update() # Activate updated screens
4598 
4600 
4601  MakeXYTrace() # Update the traces
4602  UpdateXYScreen() # Update the screen
4603 
4605 
4606  MakeXYTrace() # Update traces
4607  UpdateXYScreen() # Update the screen
4608 
4610 
4611  MakeXYScreen() # Update the screen
4612  root.update() # Activate updated screens
4613 
4615  global MBuff, MBuffX, MBuffY, VBuffA, VBuffB, IBuffA, IBuffB
4616  global MathTrace, Show_MathX, Show_MathY, CHAOffset, CHBOffset, CHAIOffset, CHBIOffset
4617  global CHMOffset, CHMXOffset, CHMYOffset, MathString, MathStringX, MathStringY
4618 
4619  if MathTrace.get() > 0:
4620  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
4621  MBuff = (VBuffA + VBuffB) - CHAOffset
4622 
4623  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
4624  MBuff = (VBuffA - VBuffB) - CHAOffset
4625 
4626  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
4627  MBuff = (VBuffB - VBuffA) - CHBOffset
4628 
4629  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
4630  MBuff = (VBuffA * IBuffA) - CHAIOffset # mAmps * Volts = mWatts
4631 
4632  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
4633  MBuff = (VBuffB * IBuffB) - CHBIOffset # mAmps * Volts = mWatts
4634 
4635  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
4636  MBuff = ((VBuffA / (IBuffA / 1000.0)) - CHAIOffset) # Volts / Amps = ohms
4637 
4638  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
4639  MBuff = ((VBuffB / (IBuffB / 1000.0)) - CHBIOffset) # Volts / Amps = ohms
4640 
4641  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
4642  MBuff = (IBuffA - IBuffB) - CHAIOffset# in mA
4643 
4644  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
4645  MBuff = (IBuffB - IBuffA) - CHBIOffset # in mA
4646 
4647  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
4648  try:
4649  MBuff = (VBuffB / VBuffA) - CHBOffset # voltage gain A to B
4650  except:
4651  MBuff = (VBuffB / 0.000001) - CHBOffset
4652 
4653  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
4654  try:
4655  MBuff = (IBuffB / IBuffA) # current gain A to B
4656  except:
4657  MBuff = (IBuffB / 0.000001) - CHBIOffset
4658 
4659  elif MathTrace.get() == 12: # plot from equation string
4660  # Example --- MathString = "(VBuffA+ VBuffB - CHAOffset)"
4661  try:
4662  MBuff = eval(MathString)
4663  MBuff = MBuff - CHMOffset
4664  except:
4665  RUNstatus.set(0) # exit loop
4666  if Show_MathX.get() > 0:
4667  try:
4668  MBuffX = eval(MathXString)
4669  MBuffX = MBuffX - CHMXOffset
4670  except:
4671  RUNstatus.set(0) # exit loop
4672  if Show_MathY.get() > 0:
4673  try:
4674  MBuffY = eval(MathYString)
4675  MBuffY = MBuffY - CHMYOffset
4676  except:
4677  RUNstatus.set(0) # exit loop
4678 
4680  global VBuffA, VBuffB, IBuffA, IBuffB
4681  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus
4682  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4683  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4684  global FFTBuffA, FFTBuffB, FFTwindowshape
4685  global AWGAwaveform, AWGBwaveform
4686  global T1Vline, T2Vline, T1Iline, T2Iline
4687  global TMAVline, TMBVline, TMCVline, TMDVline
4688  global Tmathline, TMXline, TMYline
4689  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
4690  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
4691  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
4692  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
4693  global SHOWsamples, ZOHold, AWGBMode
4694  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
4695  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4696  global Show_MathX, Show_MathY
4697  global TRACES, TRACESread, RUNstatus
4698  global AutoCenterA, AutoCenterB
4699  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
4700  global TMpdiv # Array with time / div values in ms
4701  global TMsb # Time per div spin box variable
4702  global TIMEdiv # current spin box value
4703  global SAMPLErate, SCstart, Two_X_Sample
4704  global TRIGGERsample, TRACEsize, DX
4705  global TRIGGERlevel, TRIGGERentry, AutoLevel
4706  global InOffA, InGainA, InOffB, InGainB
4707  global CurOffA, CurOffB, CurGainA, CurGainB
4708  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4709  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4710  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4711  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
4712  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4713  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
4714  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
4715  global HozPoss, HozPossentry
4716 
4717  # Set the TRACEsize variable
4718  if len(VBuffA) < 100:
4719  return
4720  TRACEsize = SHOWsamples # Set the trace length
4721  SCstart = 0
4722  ylo = 0.0
4723  xlo = 0.0
4724  Ymin = Y0T # Minimum position of time grid (top)
4725  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
4726  Xmin = X0L # Minimum position of time grid (left)
4727  Xmax = X0L + GRW # Maximum position of time grid (right)
4728 
4729  # prevent divide by zero error
4730  if TIMEdiv < 0.0002:
4731  TIMEdiv = 0.01
4732  # Check for Auto Centering
4733  if AutoCenterA.get() > 0:
4734  CHAOffset = DCV1
4735  CHAVPosEntry.delete(0,END)
4736  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
4737  if AutoCenterB.get() > 0:
4738  CHBOffset = DCV2
4739  CHBVPosEntry.delete(0,END)
4740  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
4741  # get the vertical ranges
4742  try:
4743  CH1pdvRange = float(eval(CHAsb.get()))
4744  except:
4745  CHAsb.delete(0,END)
4746  CHAsb.insert(0, CH1vpdvRange)
4747  try:
4748  CH2pdvRange = float(eval(CHBsb.get()))
4749  except:
4750  CHBsb.delete(0,END)
4751  CHBsb.insert(0, CH2vpdvRange)
4752  try:
4753  CH1IpdvRange = float(eval(CHAIsb.get()))
4754  except:
4755  CHAIsb.delete(0,END)
4756  CHAIsb.insert(0, CH1IpdvRange)
4757  try:
4758  CH2IpdvRange = float(eval(CHBIsb.get()))
4759  except:
4760  CHBIsb.delete(0,END)
4761  CHBIsb.insert(0, CH2IpdvRange)
4762  # get the vertical offsets
4763  try:
4764  CHAOffset = float(eval(CHAVPosEntry.get()))
4765  except:
4766  CHAVPosEntry.delete(0,END)
4767  CHAVPosEntry.insert(0, CHAOffset)
4768  try:
4769  CHAIOffset = float(eval(CHAIPosEntry.get()))
4770  except:
4771  CHAIPosEntry.delete(0,END)
4772  CHAIPosEntry.insert(0, CHAIOffset)
4773  try:
4774  CHBOffset = float(eval(CHBVPosEntry.get()))
4775  except:
4776  CHBVPosEntry.delete(0,END)
4777  CHBVPosEntry.insert(0, CHBOffset)
4778  try:
4779  CHBIOffset = float(eval(CHBIPosEntry.get()))
4780  except:
4781  CHBIPosEntry.delete(0,END)
4782  CHBIPosEntry.insert(0, CHBIOffset)
4783  # prevent divide by zero error
4784  if CH1pdvRange < 0.001:
4785  CH1pdvRange = 0.001
4786  if CH2pdvRange < 0.001:
4787  CH2pdvRange = 0.001
4788  if CH1IpdvRange < 0.1:
4789  CH1IpdvRange = 0.1
4790  if CH2IpdvRange < 0.1:
4791  CH2IpdvRange = 0.1
4792 #
4793  try:
4794  HoldOff = float(eval(HoldOffentry.get()))
4795  if HoldOff < 0:
4796  HoldOff = 0
4797  HoldOffentry.delete(0,END)
4798  HoldOffentry.insert(0, HoldOff)
4799  except:
4800  HoldOffentry.delete(0,END)
4801  HoldOffentry.insert(0, HoldOff)
4802 #
4803  try:
4804  HozPoss = float(eval(HozPossentry.get()))
4805  except:
4806  HozPossentry.delete(0,END)
4807  HozPossentry.insert(0, HozPoss)
4808 #
4809  hldn = int(HoldOff * SAMPLErate/1000 )
4810  hozpos = int(HozPoss * SAMPLErate/1000 )
4811  if hozpos < 0:
4812  hozpos = 0
4813  # drawing the traces
4814  if TRACEsize == 0: # If no trace, skip rest of this routine
4815  T1Vline = [] # Trace line channel A V
4816  T2Vline = [] # Trace line channel B V
4817  T1Iline = []
4818  T2Iline = []
4819  TMAVline = [] # V Trace line Mux channel A
4820  TMBVline = [] # V Trace line Mux channel B
4821  TMCVline = [] # V Trace line Mux channel C
4822  TMDVline = [] # V Trace line Mux channel D
4823  Tmathline = [] # math trce line
4824  return()
4825 
4826  # set and/or corrected for in range
4827  if TgInput.get() > 0:
4828  SCmin = int(-1 * TRIGGERsample)
4829  SCmax = int(TRACEsize - TRIGGERsample - 0)
4830  else:
4831  SCmin = 0 # hldn
4832  SCmax = TRACEsize - 1
4833  if SCstart < SCmin: # No reading before start of array
4834  SCstart = SCmin
4835  if SCstart > SCmax: # No reading after end of array
4836  SCstart = SCmax
4837 
4838  # Make Trace lines etc.
4839 
4840  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
4841  Yconv2 = float(GRH/10.0) / CH2pdvRange
4842  YIconv1 = float(GRH/10.0) / CH1IpdvRange
4843  YIconv2 = float(GRH/10.0) / CH2IpdvRange
4844  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
4845  Xconv2 = float(GRW/10.0) / CH2pdvRange
4846  XIconv1 = float(GRW/10.0) / CH1IpdvRange
4847  XIconv2 = float(GRW/10.0) / CH2IpdvRange
4848  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
4849  try:
4850  CHMApdvRange = float(eval(CHB_Asb.get()))
4851  except:
4852  CHB_Asb.delete(0,END)
4853  CHB_Asb.insert(0, CHMApdvRange)
4854  try:
4855  CHMBpdvRange = float(eval(CHB_Bsb.get()))
4856  except:
4857  CHB_Bsb.delete(0,END)
4858  CHB_Bsb.insert(0, CHMBpdvRange)
4859  try:
4860  CHMCpdvRange = float(eval(CHB_Csb.get()))
4861  except:
4862  CHB_Csb.delete(0,END)
4863  CHB_Csb.insert(0, CHMCpdvRange)
4864  try:
4865  CHMDpdvRange = float(eval(CHB_Dsb.get()))
4866  except:
4867  CHB_Dsb.delete(0,END)
4868  CHB_Dsb.insert(0, CHMDpdvRange)
4869  YconvMA = float(GRH/10.0) / CHMApdvRange
4870  YconvMB = float(GRH/10.0) / CHMBpdvRange
4871  YconvMC = float(GRH/10.0) / CHMCpdvRange
4872  YconvMD = float(GRH/10.0) / CHMDpdvRange
4873  try:
4874  CHBAOffset = float(eval(CHB_APosEntry.get()))
4875  except:
4876  CHB_APosEntry.delete(0,END)
4877  CHB_APosEntry.insert(0, CHBAOffset)
4878  try:
4879  CHBBOffset = float(eval(CHB_BPosEntry.get()))
4880  except:
4881  CHB_BPosEntry.delete(0,END)
4882  CHB_BPosEntry.insert(0, CHBBOffset)
4883  try:
4884  CHBCOffset = float(eval(CHB_CPosEntry.get()))
4885  except:
4886  CHB_CPosEntry.delete(0,END)
4887  CHB_CPosEntry.insert(0, CHBCOffset)
4888  try:
4889  CHBDOffset = float(eval(CHB_DPosEntry.get()))
4890  except:
4891  CHB_DPosEntry.delete(0,END)
4892  CHB_DPosEntry.insert(0, CHBDOffset)
4893  if MathAxis == "V-A":
4894  YconvM = Yconv1
4895  CHMOffset = CHAOffset
4896  elif MathAxis == "V-B":
4897  YconvM = Yconv2
4898  CHMOffset = CHBOffset
4899  elif MathAxis == "I-A":
4900  YconvM = YIconv1
4901  CHMOffset = CHAIOffset
4902  elif MathAxis == "I-B":
4903  YconvM = YIconv2
4904  CHMOffset = CHBIOffset
4905  else:
4906  YconvM = Yconv1
4907  CHMOffset = CHAOffset
4908 # include ploting X and Y math formulas vs time
4909  if MathYAxis == "V-A":
4910  YconvMxy = Yconv1
4911  CHMYOffset = CHAOffset
4912  elif MathYAxis == "V-B":
4913  YconvMxy = Yconv2
4914  CHMYOffset = CHBOffset
4915  elif MathYAxis == "I-A":
4916  YconvMxy = YIconv1
4917  CHMYOffset = CHAIOffset
4918  elif MathYAxis == "I-B":
4919  YconvMxy = YIconv2
4920  CHMYOffset = CHBIOffset
4921  else:
4922  YconvMxy = Yconv1
4923  CHMYOffset = CHAOffset
4924 #
4925  if MathXAxis == "V-A":
4926  XconvMxy = Yconv1
4927  CHMXOffset = CHAOffset
4928  elif MathXAxis == "V-B":
4929  XconvMxy = Yconv2
4930  CHMXOffset = CHBOffset
4931  elif MathXAxis == "I-A":
4932  XconvMxy = YIconv1
4933  CHMXOffset = CHAIOffset
4934  elif MathXAxis == "I-B":
4935  XconvMxy = YIconv2
4936  CHMXOffset = CHBIOffset
4937  else:
4938  XconvMxy = Yconv1
4939  CHMXOffset = CHAOffset
4940 #
4941  c1 = GRH / 2.0 + Y0T # fixed correction channel A
4942  c2 = GRH / 2.0 + Y0T # fixed correction channel B
4943 
4944  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
4945  T1Vline = [] # V Trace line channel A
4946  T2Vline = [] # V Trace line channel B
4947  T1Iline = [] # I Trace line channel A
4948  T2Iline = [] # I Trace line channel B
4949  TMAVline = [] # V Trace line Mux channel A
4950  TMBVline = [] # V Trace line Mux channel B
4951  TMCVline = [] # V Trace line Mux channel C
4952  TMDVline = [] # V Trace line Mux channel D
4953  Tmathline = [] # math trce line
4954  TMXline = [] # X math Trace line
4955  TMYline = [] # Y math Trace line
4956  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
4957  return
4958  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
4959  if t < 0:
4960  t = 0
4961  x = 0 # Horizontal screen pixel
4962 #
4963  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
4964  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
4965  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
4966  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
4967  DvY1 = DvY2 = DiY1 = DiY2 = 0
4968 #
4969  if (DISsamples <= GRW):
4970  Xstep = GRW / DISsamples
4971  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
4972  xa = int((Xstep/-2.5) - (Xstep*DX))
4973  else:
4974  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
4975  x = 0 - int(Xstep*DX)
4976  Tstep = 1
4977  x1 = 0 # x position of trace line
4978  xa1 = 0
4979  y1 = 0.0 # y position of trace line
4980  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
4981  ytemp = IBuffA[t]
4982  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
4983  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
4984  if MuxScreenStatus.get() == 1:
4985  if len(VBuffMA) > 4:
4986  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
4987  if len(VBuffMB) > 4:
4988  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
4989  if len(VBuffMC) > 4:
4990  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
4991  if len(VBuffMD) > 4:
4992  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
4993  ytemp = IBuffB[t]
4994  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
4995  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
4996  if TgInput.get() == 0:
4997  Xlimit = GRW
4998  else:
4999  Xlimit = GRW+Xstep
5000  while x <= Xlimit:
5001  if t < TRACEsize:
5002  xa1 = xa + X0L
5003  x1 = x + X0L
5004  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
5005  ytemp = IBuffA[t]
5006  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
5007 
5008  if y1 < Ymin: # clip waveform if going off grid
5009  y1 = Ymin
5010  if y1 > Ymax:
5011  y1 = Ymax
5012  if yi1 < Ymin:
5013  yi1 = Ymin
5014  if yi1 > Ymax:
5015  yi1 = Ymax
5016  if ShowC1_V.get() == 1 :
5017  if ZOHold.get() == 1:
5018  T1Vline.append(int(xa1))
5019  T1Vline.append(int(ypv1))
5020  T1Vline.append(int(xa1))
5021  T1Vline.append(int(y1))
5022  else:
5023  T1Vline.append(int(xa1))
5024  T1Vline.append(int(y1))
5025  DvY1 = ypv1 - y1
5026  ypv1 = y1
5027  if ShowC1_I.get() == 1:
5028  if ZOHold.get() == 1:
5029  T1Iline.append(int(xa1))
5030  T1Iline.append(int(ypi1))
5031  T1Iline.append(int(xa1))
5032  T1Iline.append(int(yi1))
5033  else:
5034  T1Iline.append(int(xa1))
5035  T1Iline.append(int(yi1))
5036  DiY1 = ypi1 - yi1
5037  ypi1 = yi1
5038  if ShowC2_V.get() == 1:
5039  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
5040  if y1 < Ymin: # clip waveform if going off grid
5041  y1 = Ymin
5042  if y1 > Ymax:
5043  y1 = Ymax
5044  if ZOHold.get() == 1:
5045  T2Vline.append(int(x1))
5046  T2Vline.append(int(ypv2))
5047  T2Vline.append(int(x1))
5048  T2Vline.append(int(y1))
5049  else:
5050  T2Vline.append(int(x1))
5051  T2Vline.append(int(y1))
5052  DvY2 = ypv2 - y1
5053  ypv2 = y1
5054  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
5055  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
5056  if y1 < Ymin: # clip waveform if going off grid
5057  y1 = Ymin
5058  if y1 > Ymax:
5059  y1 = Ymax
5060  if ZOHold.get() == 1:
5061  TMAVline.append(int(x1))
5062  TMAVline.append(int(ypvma))
5063  TMAVline.append(int(x1))
5064  TMAVline.append(int(y1))
5065  else:
5066  TMAVline.append(int(x1))
5067  TMAVline.append(int(y1))
5068  ypvma = y1
5069  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5070  Xfine = MouseX - X0L - x
5071  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
5072  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
5073  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
5074  if y1 < Ymin: # clip waveform if going off grid
5075  y1 = Ymin
5076  if y1 > Ymax:
5077  y1 = Ymax
5078  if ZOHold.get() == 1:
5079  TMBVline.append(int(x1))
5080  TMBVline.append(int(ypvmb))
5081  TMBVline.append(int(x1))
5082  TMBVline.append(int(y1))
5083  else:
5084  TMBVline.append(int(x1))
5085  TMBVline.append(int(y1))
5086  ypvmb = y1
5087  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5088  Xfine = MouseX - X0L - x
5089  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
5090  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
5091  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
5092  if y1 < Ymin: # clip waveform if going off grid
5093  y1 = Ymin
5094  if y1 > Ymax:
5095  y1 = Ymax
5096  if ZOHold.get() == 1:
5097  TMCVline.append(int(x1))
5098  TMCVline.append(int(ypvmc))
5099  TMCVline.append(int(x1))
5100  TMCVline.append(int(y1))
5101  else:
5102  TMCVline.append(int(x1))
5103  TMCVline.append(int(y1))
5104  ypvmc = y1
5105  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5106  Xfine = MouseX - X0L - x
5107  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
5108  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
5109  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
5110  if y1 < Ymin: # clip waveform if going off grid
5111  y1 = Ymin
5112  if y1 > Ymax:
5113  y1 = Ymax
5114  if ZOHold.get() == 1:
5115  TMDVline.append(int(x1))
5116  TMDVline.append(int(ypvmd))
5117  TMDVline.append(int(x1))
5118  TMDVline.append(int(y1))
5119  else:
5120  TMDVline.append(int(x1))
5121  TMDVline.append(int(y1))
5122  ypvmd = y1
5123  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5124  Xfine = MouseX - X0L - x
5125  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
5126  if ShowC2_I.get() == 1:
5127  ytemp = IBuffB[t]
5128  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
5129  if yi1 < Ymin:
5130  yi1 = Ymin
5131  if yi1 > Ymax:
5132  yi1 = Ymax
5133  if (ZOHold.get() == 1):
5134  T2Iline.append(int(x1))
5135  T2Iline.append(int(ypi2))
5136  T2Iline.append(int(x1))
5137  T2Iline.append(int(yi1))
5138  else:
5139  T2Iline.append(int(x1))
5140  T2Iline.append(int(yi1))
5141  DiY2 = ypi2 - yi1
5142  ypi2 = yi1
5143  if MathTrace.get() > 0:
5144  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
5145  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
5146 
5147  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
5148  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
5149 
5150  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
5151  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
5152 
5153  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
5154  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
5155  ytemp = YIconv1 * (Ypower - CHAIOffset)
5156  y1 = int(c1 - ytemp)
5157 
5158  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
5159  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
5160  ytemp = YIconv2 * (Ypower - CHBIOffset)
5161  y1 = int(c2 - ytemp)
5162 
5163  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
5164  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
5165  ytemp = YIconv1 * (Yohms - CHAIOffset)
5166  y1 = int(c1 - ytemp)
5167 
5168  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
5169  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
5170  ytemp = YIconv2 * (Yohms - CHBIOffset)
5171  y1 = int(c2 - ytemp)
5172 
5173  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
5174  Ydif = (IBuffA[t] - IBuffB[t])# in mA
5175  ytemp = YIconv1 * (Ydif - CHAIOffset)
5176  y1 = int(c2 - ytemp)
5177 
5178  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
5179  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
5180  ytemp = YIconv2 * (Ydif - CHBIOffset)
5181  y1 = int(c2 - ytemp)
5182 
5183  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
5184  try:
5185  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
5186  except:
5187  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
5188 
5189  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
5190  try:
5191  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
5192  except:
5193  Y1 = (IBuffB[t] / 0.000001)
5194  ytemp = YIconv2 * (Y1 - CHBIOffset)
5195  y1 = int(c2 - ytemp)
5196 
5197  elif MathTrace.get() == 12: # plot from equation string
5198  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
5199  try:
5200  MathResult = eval(MathString)
5201  MathResult = MathResult - CHMOffset
5202  y1 = int(c1 - YconvM * MathResult)
5203  except:
5204  RUNstatus.set(0)
5205  x = Xlimit + 1 # exit loop
5206 
5207  if y1 < Ymin: # clip waveform if going off grid
5208  y1 = Ymin
5209  if y1 > Ymax:
5210  y1 = Ymax
5211  if ZOHold.get() == 1: # connet the dots with stair step
5212  Tmathline.append(int(x1))
5213  Tmathline.append(int(ypm))
5214  Tmathline.append(int(x1))
5215  Tmathline.append(int(y1))
5216  else: # connet the dots with single line
5217  Tmathline.append(int(x1))
5218  Tmathline.append(int(y1))
5219  ypm = y1
5220  if Show_MathX.get() > 0:
5221  try:
5222  MathResult = eval(MathXString)
5223  MathResult = MathResult - CHMXOffset
5224  y1 = int(c1 - XconvMxy * MathResult)
5225  except:
5226  RUNstatus.set(0)
5227  x = Xlimit + 1 # exit loop
5228 
5229  if y1 < Ymin: # clip waveform if going off grid
5230  y1 = Ymin
5231  if y1 > Ymax:
5232  y1 = Ymax
5233  if ZOHold.get() == 1: # connet the dots with stair step
5234  TMXline.append(int(x1))
5235  TMXline.append(int(ypmx))
5236  TMXline.append(int(x1))
5237  TMXline.append(int(y1))
5238  else: # connet the dots with single line
5239  TMXline.append(int(x1))
5240  TMXline.append(int(y1))
5241  ypmx = y1
5242  if Show_MathY.get() > 0:
5243  try:
5244  MathResult = eval(MathYString)
5245  MathResult = MathResult - CHMYOffset
5246  y1 = int(c1 - YconvMxy * MathResult)
5247  except:
5248  RUNstatus.set(0)
5249  x = Xlimit + 1 # exit loop
5250 
5251  if y1 < Ymin: # clip waveform if going off grid
5252  y1 = Ymin
5253  if y1 > Ymax:
5254  y1 = Ymax
5255  if ZOHold.get() == 1: # connet the dots with stair step
5256  TMYline.append(int(x1))
5257  TMYline.append(int(ypmy))
5258  TMYline.append(int(x1))
5259  TMYline.append(int(y1))
5260  else: # connet the dots with single line
5261  TMYline.append(int(x1))
5262  TMYline.append(int(y1))
5263  ypmy = y1
5264  # remember trace verticle pixel at X mouse location
5265  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
5266  Xfine = MouseX - X0L - x
5267  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
5268  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
5269  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
5270  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
5271  t = int(t + Tstep)
5272  x = x + Xstep
5273  xa = xa + Xstep
5274 
5275  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
5276  Xstep = 1
5277  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
5278  x1 = 0.0 # x position of trace line
5279  ylo = 0.0 # ymin position of trace 1 line
5280  yhi = 0.0 # ymax position of trace 1 line
5281 
5282  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
5283  if t > len(VBuffA)-1:
5284  t = 0
5285  if t < 0:
5286  t = 0
5287  x = 0 # Horizontal screen pixel
5288  ft = t # time point with fractions
5289  while (x <= GRW):
5290  if (t < TRACEsize):
5291  if (t >= len(VBuffA)):
5292  t = len(VBuffA)-2
5293  x = GRW
5294  x1 = x + X0L
5295  ylo = VBuffA[t] - CHAOffset
5296  ilo = IBuffA[t] - CHAIOffset
5297  yhi = ylo
5298  ihi = ilo
5299  n = t
5300  while n < (t + Tstep) and n < TRACEsize:
5301  if ( ShowC1_V.get() == 1 ):
5302  v = VBuffA[t] - CHAOffset
5303  if v < ylo:
5304  ylo = v
5305  if v > yhi:
5306  yhi = v
5307  if ( ShowC1_I.get() == 1 ):
5308  i = IBuffA[t] - CHAIOffset
5309  if i < ilo:
5310  ilo = i
5311  if i > ihi:
5312  ihi = i
5313  n = n + 1
5314  if ( ShowC1_V.get() == 1 ):
5315  ylo = int(c1 - Yconv1 * ylo)
5316  yhi = int(c1 - Yconv1 * yhi)
5317  if (ylo < Ymin):
5318  ylo = Ymin
5319  if (ylo > Ymax):
5320  ylo = Ymax
5321  if (yhi < Ymin):
5322  yhi = Ymin
5323  if (yhi > Ymax):
5324  yhi = Ymax
5325  T1Vline.append(int(x1))
5326  T1Vline.append(int(ylo))
5327  T1Vline.append(int(x1))
5328  T1Vline.append(int(yhi))
5329  ypv1 = ylo
5330  if ( ShowC1_I.get() == 1 ):
5331  ilo = int(c1 - YIconv1 * ilo)
5332  ihi = int(c1 - YIconv1 * ihi)
5333  if (ilo < Ymin):
5334  ilo = Ymin
5335  if (ilo > Ymax):
5336  ilo = Ymax
5337  if (ihi < Ymin):
5338  ihi = Ymin
5339  if (ihi > Ymax):
5340  ihi = Ymax
5341  T1Iline.append(int(x1))
5342  T1Iline.append(int(ilo))
5343  T1Iline.append(int(x1))
5344  T1Iline.append(int(ihi))
5345  ypi1 = ilo
5346  ylo = VBuffB[t] - CHBOffset
5347  ilo = IBuffB[t] - CHBIOffset
5348  yhi = ylo
5349  ihi = ilo
5350  n = t
5351  if MuxScreenStatus.get() == 0:
5352  while n < (t + Tstep) and n < TRACEsize:
5353  if ( ShowC2_V.get() == 1 ):
5354  v = VBuffB[t] - CHBOffset
5355  if v < ylo:
5356  ylo = v
5357  if v > yhi:
5358  yhi = v
5359  if ( ShowC2_I.get() == 1 ):
5360  i = IBuffB[t] - CHBIOffset
5361  if i < ilo:
5362  ilo = i
5363  if i > ihi:
5364  ihi = i
5365  n = n + 1
5366  if ( ShowC2_V.get() == 1 ):
5367  ylo = int(c2 - Yconv2 * ylo)
5368  yhi = int(c2 - Yconv2 * yhi)
5369  if (ylo < Ymin):
5370  ylo = Ymin
5371  if (ylo > Ymax):
5372  ylo = Ymax
5373 
5374  if (yhi < Ymin):
5375  yhi = Ymin
5376  if (yhi > Ymax):
5377  yhi = Ymax
5378  T2Vline.append(int(x1))
5379  T2Vline.append(int(ylo))
5380  T2Vline.append(int(x1))
5381  T2Vline.append(int(yhi))
5382  ypv2 = ylo
5383  if ( ShowC2_I.get() == 1 ):
5384  ilo = int(c2 - YIconv2 * ilo)
5385  ihi = int(c2 - YIconv2 * ihi)
5386  if (ilo < Ymin):
5387  ilo = Ymin
5388  if (ilo > Ymax):
5389  ilo = Ymax
5390  if (ihi < Ymin):
5391  ihi = Ymin
5392  if (ihi > Ymax):
5393  ihi = Ymax
5394  T2Iline.append(int(x1))
5395  T2Iline.append(int(ilo))
5396  T2Iline.append(int(x1))
5397  T2Iline.append(int(ihi))
5398  ypi2 = ilo
5399  else:
5400  if Show_CBA.get() == 1 and len(VBuffMA)>4:
5401  if t < len(VBuffMA):
5402  ylo = VBuffMA[t] - CHBAOffset
5403  yhi = ylo
5404  n = t
5405  while n < (t + Tstep) and n < len(VBuffMA):
5406  v = VBuffMA[t] - CHBAOffset
5407  if v < ylo:
5408  ylo = v
5409  if v > yhi:
5410  yhi = v
5411  n = n + 1
5412  ylo = int(c2 - YconvMA * ylo)
5413  yhi = int(c2 - YconvMA * yhi)
5414  if (ylo < Ymin):
5415  ylo = Ymin
5416  if (ylo > Ymax):
5417  ylo = Ymax
5418  if (yhi < Ymin):
5419  yhi = Ymin
5420  if (yhi > Ymax):
5421  yhi = Ymax
5422  TMAVline.append(int(x1))
5423  TMAVline.append(int(ylo))
5424  TMAVline.append(int(x1))
5425  TMAVline.append(int(yhi))
5426  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5427  MouseMuxA = ylo
5428  if Show_CBB.get() == 1 and len(VBuffMB)>4:
5429  if t < len(VBuffMB):
5430  ylo = VBuffMB[t] - CHBBOffset
5431  yhi = ylo
5432  n = t
5433  while n < (t + Tstep) and n < len(VBuffMB):
5434  v = VBuffMB[t] - CHBBOffset
5435  if v < ylo:
5436  ylo = v
5437  if v > yhi:
5438  yhi = v
5439  n = n + 1
5440  ylo = int(c2 - YconvMB * ylo)
5441  yhi = int(c2 - YconvMB * yhi)
5442  if (ylo < Ymin):
5443  ylo = Ymin
5444  if (ylo > Ymax):
5445  ylo = Ymax
5446  if (yhi < Ymin):
5447  yhi = Ymin
5448  if (yhi > Ymax):
5449  yhi = Ymax
5450  TMBVline.append(int(x1))
5451  TMBVline.append(int(ylo))
5452  TMBVline.append(int(x1))
5453  TMBVline.append(int(yhi))
5454  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5455  MouseMuxB = ylo
5456  if Show_CBC.get() == 1 and len(VBuffMC)>4:
5457  if t < len(VBuffMC):
5458  ylo = VBuffMC[t] - CHBCOffset
5459  yhi = ylo
5460  n = t
5461  while n < (t + Tstep) and n < len(VBuffMC):
5462  v = VBuffMC[t] - CHBCOffset
5463  if v < ylo:
5464  ylo = v
5465  if v > yhi:
5466  yhi = v
5467  n = n + 1
5468  ylo = int(c2 - YconvMC * ylo)
5469  yhi = int(c2 - YconvMC * yhi)
5470  if (ylo < Ymin):
5471  ylo = Ymin
5472  if (ylo > Ymax):
5473  ylo = Ymax
5474  if (yhi < Ymin):
5475  yhi = Ymin
5476  if (yhi > Ymax):
5477  yhi = Ymax
5478  TMCVline.append(int(x1))
5479  TMCVline.append(int(ylo))
5480  TMCVline.append(int(x1))
5481  TMCVline.append(int(yhi))
5482  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5483  MouseMuxC = ylo
5484  if Show_CBD.get() == 1 and len(VBuffMD)>4:
5485  if t < len(VBuffMD):
5486  ylo = VBuffMD[t] - CHBDOffset
5487  yhi = ylo
5488  n = t
5489  while n < (t + Tstep) and n < len(VBuffMD):
5490  v = VBuffMD[t] - CHBDOffset
5491  if v < ylo:
5492  ylo = v
5493  if v > yhi:
5494  yhi = v
5495  n = n + 1
5496  ylo = int(c2 - YconvMD * ylo)
5497  yhi = int(c2 - YconvMD * yhi)
5498  if (ylo < Ymin):
5499  ylo = Ymin
5500  if (ylo > Ymax):
5501  ylo = Ymax
5502  if (yhi < Ymin):
5503  yhi = Ymin
5504  if (yhi > Ymax):
5505  yhi = Ymax
5506  TMDVline.append(int(x1))
5507  TMDVline.append(int(ylo))
5508  TMDVline.append(int(x1))
5509  TMDVline.append(int(yhi))
5510  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5511  MouseMuxD = ylo
5512  if ( ShowC2_I.get() == 1 ):
5513  while n < (t + Tstep) and n < TRACEsize:
5514  i = IBuffB[t] - CHBIOffset
5515  if i < ilo:
5516  ilo = i
5517  if i > ihi:
5518  ihi = i
5519  n = n + 1
5520  ilo = int(c2 - YIconv2 * ilo)
5521  ihi = int(c2 - YIconv2 * ihi)
5522  if (ilo < Ymin):
5523  ilo = Ymin
5524  if (ilo > Ymax):
5525  ilo = Ymax
5526  if (ihi < Ymin):
5527  ihi = Ymin
5528  if (ihi > Ymax):
5529  ihi = Ymax
5530  T2Iline.append(int(x1))
5531  T2Iline.append(int(ilo))
5532  T2Iline.append(int(x1))
5533  T2Iline.append(int(ihi))
5534  if MathTrace.get() > 0:
5535  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
5536  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
5537 
5538  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
5539  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
5540 
5541  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
5542  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
5543 
5544  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
5545  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
5546  ytemp = YIconv1 * (Ypower - CHAIOffset)
5547  y1 = int(c1 - ytemp)
5548 
5549  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
5550  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
5551  ytemp = YIconv2 * (Ypower - CHBIOffset)
5552  y1 = int(c2 - ytemp)
5553 
5554  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
5555  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
5556  ytemp = YIconv1 * (Yohms- CHAIOffset)
5557  y1 = int(c1 - ytemp)
5558 
5559  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
5560  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
5561  ytemp = YIconv2 * (Yohms - CHBIOffset)
5562  y1 = int(c2 - ytemp)
5563 
5564  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
5565  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
5566  ytemp = YIconv1 * (Ydif - CHAIOffset)
5567  y1 = int(c2 - ytemp)
5568 
5569  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
5570  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
5571  ytemp = YIconv2 * (Ydif - CHBIOffset)
5572  y1 = int(c2 - ytemp)
5573 
5574  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
5575  try:
5576  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
5577  except:
5578  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
5579  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
5580  try:
5581  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
5582  except:
5583  Y1 = (IBuffB[t] / 0.000001)
5584  ytemp = YIconv2 * (Y1 - CHBIOffset)
5585  y1 = int(c2 - ytemp)
5586 
5587  elif MathTrace.get() == 12: # plot from equation string
5588  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
5589  try:
5590  MathResult = eval(MathString)
5591  MathResult = MathResult - CHMOffset
5592  y1 = int(c1 - YconvM * MathResult)
5593  except:
5594  RUNstatus.set(0)
5595  x = GRW + 1
5596 
5597  if (y1 < Ymin):
5598  y1 = Ymin
5599  if (y1 > Ymax):
5600  y1 = Ymax
5601  if (ZOHold.get() == 1):
5602  Tmathline.append(int(x1))
5603  Tmathline.append(int(ypm))
5604  Tmathline.append(int(x1))
5605  Tmathline.append(int(y1))
5606  else:
5607  Tmathline.append(int(x1))
5608  Tmathline.append(int(y1))
5609  ypm = y1
5610  if Show_MathX.get() > 0:
5611  try:
5612  MathResult = eval(MathXString)
5613  MathResult = MathResult - CHMXOffset
5614  y1 = int(c1 - XconvMxy * MathResult)
5615  except:
5616  RUNstatus.set(0)
5617  x = GRW + 1
5618 
5619  if y1 < Ymin: # clip waveform if going off grid
5620  y1 = Ymin
5621  if y1 > Ymax:
5622  y1 = Ymax
5623  if ZOHold.get() == 1: # connet the dots with stair step
5624  TMXline.append(int(x1))
5625  TMXline.append(int(ypmx))
5626  TMXline.append(int(x1))
5627  TMXline.append(int(y1))
5628  else: # connet the dots with single line
5629  TMXline.append(int(x1))
5630  TMXline.append(int(y1))
5631  ypmx = y1
5632  if Show_MathY.get() > 0:
5633  try:
5634  MathResult = eval(MathYString)
5635  MathResult = MathResult - CHMYOffset
5636  y1 = int(c1 - YconvMxy * MathResult)
5637  except:
5638  RUNstatus.set(0)
5639  x = GRW + 1
5640 
5641  if y1 < Ymin: # clip waveform if going off grid
5642  y1 = Ymin
5643  if y1 > Ymax:
5644  y1 = Ymax
5645  if ZOHold.get() == 1: # connet the dots with stair step
5646  TMYline.append(int(x1))
5647  TMYline.append(int(ypmy))
5648  TMYline.append(int(x1))
5649  TMYline.append(int(y1))
5650  else: # connet the dots with single line
5651  TMYline.append(int(x1))
5652  TMYline.append(int(y1))
5653  ypmy = y1
5654  ft = ft + Tstep
5655  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
5656  MouseCAV = ypv1
5657  MouseCAI = ypi1
5658  MouseCBV = ypv2
5659  MouseCBI = ypi2
5660  t = int(ft)
5661  if (t > len(VBuffA)):
5662  t = len(VBuffA)-2
5663  x = GRW
5664  x = x + Xstep
5665 
5666  # Make trigger triangle pointer
5667  Triggerline = [] # Trigger pointer
5668  Triggersymbol = [] # Trigger symbol
5669  if TgInput.get() > 0:
5670  if TgInput.get() == 1 : # triggering on CA-V
5671  x1 = X0L
5672  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) # / InGainA
5673  y1 = int(c1 - ytemp)
5674  elif TgInput.get() == 2: # triggering on CA-I
5675  x1 = X0L+GRW
5676  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
5677  elif TgInput.get() == 3: # triggering on CB-V
5678  x1 = X0L
5679  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) # / InGainB
5680  y1 = int(c2 - ytemp)
5681  elif TgInput.get() == 4: # triggering on CB-I
5682  x1 = X0L+GRW
5683  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
5684 
5685  if (y1 < Ymin):
5686  y1 = Ymin
5687  if (y1 > Ymax):
5688  y1 = Ymax
5689  Triggerline.append(int(x1-5))
5690  Triggerline.append(int(y1+5))
5691  Triggerline.append(int(x1+5))
5692  Triggerline.append(int(y1))
5693  Triggerline.append(int(x1-5))
5694  Triggerline.append(int(y1-5))
5695  Triggerline.append(int(x1-5))
5696  Triggerline.append(int(y1+5))
5697  x1 = X0L + (GRW/2)
5698  if TgEdge.get() == 0: # draw rising edge symbol
5699  y1 = -3
5700  y2 = -13
5701  else:
5702  y1 = -13
5703  y2 = -3
5704  Triggersymbol.append(int(x1-10))
5705  Triggersymbol.append(int(Ymin+y1))
5706  Triggersymbol.append(int(x1))
5707  Triggersymbol.append(int(Ymin+y1))
5708  Triggersymbol.append(int(x1))
5709  Triggersymbol.append(int(Ymin+y2))
5710  Triggersymbol.append(int(x1+10))
5711  Triggersymbol.append(int(Ymin+y2))
5712 
5714  global VBuffA, VBuffB, IBuffA, IBuffB
5715  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
5716  global TXYline, MathXString, MathYString, MathXAxis, MathYAxis
5717  global HoldOff, HoldOffentry
5718  global X0LXY, Y0TXY, GRWXY, GRHXY
5719  global YminXY, YmaxXY, XminXY, XmaxXY
5720  global SHOWsamples, ZOHold, AWGBMode
5721  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
5722  global TRACES, TRACESread, RUNstatus
5723  global Xsignal, Ysignal
5724  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
5725  global TMpdiv # Array with time / div values in ms
5726  global TMsb # Time per div spin box variable
5727  global TIMEdiv # current spin box value
5728  global SAMPLErate
5729  global SCstart, MathString
5730  global TRIGGERsample, TRACEsize, DX
5731  global TRIGGERlevel, TRIGGERentry, AutoLevel
5732  global InOffA, InGainA, InOffB, InGainB
5733  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5734  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5735  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
5736  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
5737  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
5738  global HozPoss, HozPossentry
5739 
5740  # Set the TRACEsize variable
5741  if len(VBuffA) < 100:
5742  return
5743  TRACEsize = SHOWsamples # Set the trace length
5744  SCstart = 0
5745  ylo = 0.0
5746  xlo = 0.0
5747  # get the vertical ranges
5748  try:
5749  CH1pdvRange = float(eval(CHAsbxy.get()))
5750  except:
5751  CHAsbxy.delete(0,END)
5752  CHAsbxy.insert(0, CH1vpdvRange)
5753  try:
5754  CH2pdvRange = float(eval(CHBsbxy.get()))
5755  except:
5756  CHBsbxy.delete(0,END)
5757  CHBsbxy.insert(0, CH2vpdvRange)
5758  try:
5759  CH1IpdvRange = float(eval(CHAIsbxy.get()))
5760  except:
5761  CHAIsbxy.delete(0,END)
5762  CHAIsbxy.insert(0, CH1IpdvRange)
5763  try:
5764  CH2IpdvRange = float(eval(CHBIsbxy.get()))
5765  except:
5766  CHBIsbxy.delete(0,END)
5767  CHBIsbxy.insert(0, CH2IpdvRange)
5768  # get the vertical offsets
5769  try:
5770  CHAOffset = float(eval(CHAVPosEntryxy.get()))
5771  except:
5772  CHAVPosEntryxy.delete(0,END)
5773  CHAVPosEntryxy.insert(0, CHAOffset)
5774  try:
5775  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
5776  except:
5777  CHAIPosEntryxy.delete(0,END)
5778  CHAIPosEntryxy.insert(0, CHAIOffset)
5779  try:
5780  CHBOffset = float(eval(CHBVPosEntryxy.get()))
5781  except:
5782  CHBVPosEntry.delete(0,END)
5783  CHBVPosEntry.insert(0, CHBOffset)
5784  try:
5785  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
5786  except:
5787  CHBIPosEntryxy.delete(0,END)
5788  CHBIPosEntryxy.insert(0, CHBIOffset)
5789  # prevent divide by zero error
5790  if CH1pdvRange < 0.001:
5791  CH1pdvRange = 0.001
5792  if CH2pdvRange < 0.001:
5793  CH2pdvRange = 0.001
5794  if CH1IpdvRange < 0.1:
5795  CH1IpdvRange = 0.1
5796  if CH2IpdvRange < 0.1:
5797  CH2IpdvRange = 0.1
5798  #
5799  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
5800  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
5801  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
5802  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
5803  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
5804  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
5805  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
5806  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
5807 
5808  if MathYAxis == "V-A":
5809  YconvMxy = Yconv1
5810  CHMYOffset = CHAOffset
5811  elif MathYAxis == "V-B":
5812  YconvMxy = Yconv2
5813  CHMYOffset = CHBOffset
5814  elif MathYAxis == "I-A":
5815  YconvMxy = YIconv1
5816  CHMYOffset = CHAIOffset
5817  elif MathYAxis == "I-B":
5818  YconvMxy = YIconv2
5819  CHMYOffset = CHBIOffset
5820  else:
5821  YconvMxy = Yconv1
5822  CHMYOffset = CHAOffset
5823  if MathXAxis == "V-A":
5824  XconvMxy = Xconv1
5825  CHMXOffset = CHAOffset
5826  elif MathXAxis == "V-B":
5827  XconvMxy = Xconv2
5828  CHMXOffset = CHBOffset
5829  elif MathYAxis == "I-A":
5830  XconvMxy = XIconv1
5831  CHMXOffset = CHAIOffset
5832  elif MathXAxis == "I-B":
5833  XconvMxy = XIconv2
5834  CHMXOffset = CHBIOffset
5835  else:
5836  XconvMxy = Xconv1
5837  CHMXOffset = CHAOffset
5838  # draw an X/Y plot
5839  TXYline = [] # XY Trace line
5840  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
5841  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
5842  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
5843  while (t < TRACEsize):
5844  if (Xsignal.get() == 3 and Ysignal.get() == 1): # mode CAV/CBV
5845  ylo = VBuffA[t] - CHAOffset
5846  xlo = VBuffB[t] - CHBOffset
5847  ylo = int(c1 - Yconv1 * ylo)
5848  xlo = int(c2 + Xconv2 * xlo)
5849  elif (Xsignal.get() == 1 and Ysignal.get() == 3): # mode CBV/CAV
5850  ylo = VBuffB[t] - CHBOffset
5851  xlo = VBuffA[t] - CHAOffset
5852  ylo = int(c1 - Yconv2 * ylo)
5853  xlo = int(c2 + Xconv1 * xlo)
5854  elif (Xsignal.get() == 5 and Ysignal.get() == 3): # mode CBV/Math
5855  if ( MathTrace.get() == 2): # plot difference of CA-V and CB-V
5856  ylo = VBuffB[t] - CHBOffset
5857  ylo = int(c1 - Yconv2 * ylo)
5858  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
5859  xlo = int(c2 + Xconv1 * xlo)
5860  elif (Xsignal.get() == 5 and Ysignal.get() == 4): # mode CBI/Math
5861  if ( MathTrace.get() == 2): # plot difference of CA-V and CB-V
5862  ylo = (IBuffB[t]) - CHBIOffset
5863  ylo = int(c1 - YIconv2 * ylo)
5864  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
5865  xlo = int(c2 + Xconv1 * xlo)
5866  elif (Xsignal.get() == 5 and Ysignal.get() == 2): # mode CAI/Math
5867  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5868  ylo = (IBuffA[t]) - CHAIOffset
5869  ylo = int(c1 - YIconv1 * ylo)
5870  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
5871  xlo = int(c2 + Xconv2 * xlo)
5872  elif (Xsignal.get() == 3 and Ysignal.get() == 5): # mode Math/CBV
5873  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
5874  ylo = VBuffA[t] - VBuffB[t] - CHAOffset
5875  ylo = int(c1 - Yconv1 * ylo)
5876  xlo = VBuffB[t] - CHBOffset
5877  xlo = int(c2 + Xconv2 * xlo)
5878  elif (Xsignal.get() == 5 and Ysignal.get() == 1): # mode CAV/Math
5879  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5880  ylo = VBuffA[t] - CHAOffset
5881  ylo = int(c1 - Yconv1 * ylo)
5882  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
5883  xlo = int(c2 + Xconv2 * xlo)
5884  elif (Xsignal.get() == 1 and Ysignal.get() == 5): # mode Math/CAV
5885  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5886  ylo = VBuffB[t] - VBuffA[t] - CHBOffset
5887  ylo = int(c1 - Yconv2 * ylo)
5888  xlo = VBuffA[t] - CHAOffset
5889  xlo = int(c2 + Xconv1 * xlo)
5890  elif (Xsignal.get() == 1 and Ysignal.get() == 2): # mode CAI/CAV
5891  ylo = (IBuffA[t]) - CHAIOffset
5892  xlo = VBuffA[t] - CHAOffset
5893  ylo = int(c1 - YIconv1 * ylo)
5894  xlo = int(c2 + Xconv1 * xlo)
5895  elif (Xsignal.get() == 3 and Ysignal.get() == 2): # mode CAI/CBV
5896  ylo = (IBuffA[t]) - CHAIOffset
5897  xlo = VBuffB[t] - CHBOffset
5898  ylo = int(c1 - YIconv1 * ylo)
5899  xlo = int(c2 + Xconv2 * xlo)
5900  elif (Xsignal.get() == 2 and Ysignal.get() == 1): # mode CAV/CAI
5901  ylo = VBuffA[t] - CHAOffset
5902  xlo = (IBuffA[t]) - CHAIOffset
5903  ylo = int(c1 - Yconv1 * ylo)
5904  xlo = int(c2 + XIconv1 * xlo)
5905  elif (Xsignal.get() == 2 and Ysignal.get() == 3): # mode CBV/CAI
5906  ylo = VBuffB[t] - CHBOffset
5907  xlo = (IBuffA[t]) - CHAIOffset
5908  ylo = int(c1 - Yconv2 * ylo)
5909  xlo = int(c2 + XIconv1 * xlo)
5910  elif (Xsignal.get() == 3 and Ysignal.get() == 4): # mode CBI/CBV
5911  ylo = (IBuffB[t]) - CHBIOffset
5912  xlo = VBuffB[t] - CHBOffset
5913  ylo = int(c1 - YIconv2 * ylo)
5914  xlo = int(c2 + Xconv2 * xlo)
5915  elif (Xsignal.get() == 4 and Ysignal.get() == 3): # mode CBV/CBI
5916  ylo = VBuffB[t] - CHBOffset
5917  xlo = (IBuffB[t]) - CHBIOffset
5918  ylo = int(c1 - Yconv2 * ylo)
5919  xlo = int(c2 + XIconv2 * xlo)
5920  elif (Xsignal.get() == 4 and Ysignal.get() == 2): # mode CAI/CBI
5921  ylo = (IBuffA[t]) - CHAIOffset
5922  xlo = (IBuffB[t]) - CHBIOffset
5923  ylo = int(c1 - YIconv1 * ylo)
5924  xlo = int(c2 + XIconv2 * xlo)
5925  elif (Xsignal.get() == 2 and Ysignal.get() == 4): # mode CBI/CAI
5926  ylo = (IBuffB[t]) - CHBIOffset
5927  xlo = (IBuffA[t]) - CHAIOffset
5928  ylo = int(c1 - YIconv2 * ylo)
5929  xlo = int(c2 + XIconv1 * xlo)
5930  elif (Xsignal.get() == 1 and Ysignal.get() == 4): # mode CBI/CAV
5931  ylo = (IBuffB[t]) - CHBIOffset
5932  xlo = VBuffA[t] - CHAOffset
5933  ylo = int(c1 - YIconv2 * ylo)
5934  xlo = int(c2 + Xconv1 * xlo)
5935  elif (Xsignal.get() == 5 and Ysignal.get() == 5): # mode MathYString/MathXString
5936  try:
5937  MathResult = eval(MathYString)
5938  MathResult = MathResult - CHMYOffset
5939  ylo = int(c1 - YconvMxy * MathResult)
5940  except:
5941  RUNstatus.set(0)
5942  try:
5943  MathResult = eval(MathXString)
5944  MathResult = MathResult - CHMXOffset
5945  xlo = int(c2 + XconvMxy * MathResult)
5946  except:
5947  RUNstatus.set(0)
5948  if ylo < YminXY: # clip waveform if going off grid
5949  ylo = YminXY
5950  if ylo > YmaxXY:
5951  ylo = YmaxXY
5952  if xlo < XminXY: # clip waveform if going off grid
5953  xlo = XminXY
5954  if xlo > XmaxXY:
5955  xlo = XmaxXY
5956  TXYline.append(int(xlo))
5957  TXYline.append(int(ylo))
5958  t = int(t + 1)
5959 
5961  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
5962  global TMXline, TMYline
5963  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
5964  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
5965  global VBuffA, VBuffB, IBuffA, IBuffB
5966  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus
5967  global TMAVline, TMBVline, TMCVline, TMDVline, TMCRline, TMBRline
5968  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
5969  global X0L # Left top X value
5970  global Y0T # Left top Y value
5971  global GRW # Screenwidth
5972  global GRH # Screenheight
5973  global FontSize, EnableHSsampling, ETSDisp, MinigenScreenStatus
5974  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
5975  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
5976  global ShowXCur, ShowYCur, TCursor, VCursor
5977  global SHOWsamples # Number of samples in data record
5978  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowRXY, Show_MathX, Show_MathY
5979  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
5980  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
5981  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
5982  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
5983  global CHAsb # V range spinbox Index for channel 1
5984  global CHBsb # V range spinbox Index for channel 2
5985  global CHAOffset # Position value for channel 1 V
5986  global CHBOffset # Position value for channel 2 V
5987  global CHAIsb # I range spinbox Index for channel 1
5988  global CHBIsb # I range spinbox Index for channel 2
5989  global CHAIOffset # Postion value for channel 1 I
5990  global CHBIOffset # position value for channel 2 I
5991  global TMpdiv # Array with time / div values in ms
5992  global TMsb # Time per div spin box variable
5993  global TIMEdiv, Mulx # current spin box value
5994  global SAMPLErate, contloop, discontloop, HtMulEntry
5995  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
5996  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
5997  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
5998  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
5999  global CANVASwidth, CANVASheight
6000  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
6001  global ScreenTrefresh, SmoothCurves, Is_Triggered
6002  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
6003  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
6004  global InOffA, InGainA, InOffB, InGainB
6005  global CurOffA, CurOffB, CurGainA, CurGainB
6006  # Analog Mux channel measurement variables
6007  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
6008  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
6009  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
6010  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
6011  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
6012  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
6013  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
6014  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
6015  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
6016  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
6017  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
6018  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
6019  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
6020  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6021  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6022  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
6023  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
6024  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
6025  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
6026  global D0, D1, D2, D3, D4, D5, D6, D7
6027  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
6028  global HozPoss, HozPossentry
6029  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
6030  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
6031  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
6032  #
6033  Ymin = Y0T # Minimum position of time grid (top)
6034  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
6035 
6036  DISsamples = (10.0 * TIMEdiv) # grid width in time
6037  Tstep = DISsamples / GRW # time in mS per pixel
6038  # get the vertical ranges
6039  try:
6040  CH1pdvRange = float(eval(CHAsb.get()))
6041  except:
6042  CHAsb.delete(0,END)
6043  CHAsb.insert(0, CH1vpdvRange)
6044  try:
6045  CH2pdvRange = float(eval(CHBsb.get()))
6046  except:
6047  CHBsb.delete(0,END)
6048  CHBsb.insert(0, CH2vpdvRange)
6049  try:
6050  CH1IpdvRange = float(eval(CHAIsb.get()))
6051  except:
6052  CHAIsb.delete(0,END)
6053  CHAIsb.insert(0, CH1IpdvRange)
6054  try:
6055  CH2IpdvRange = float(eval(CHBIsb.get()))
6056  except:
6057  CHBIsb.delete(0,END)
6058  CHBIsb.insert(0, CH2IpdvRange)
6059  # get the vertical offsets
6060  try:
6061  CHAOffset = float(eval(CHAVPosEntry.get()))
6062  except:
6063  CHAVPosEntry.delete(0,END)
6064  CHAVPosEntry.insert(0, CHAOffset)
6065  try:
6066  CHAIOffset = float(eval(CHAIPosEntry.get()))
6067  except:
6068  CHAIPosEntry.delete(0,END)
6069  CHAIPosEntry.insert(0, CHAIOffset)
6070  try:
6071  CHBOffset = float(eval(CHBVPosEntry.get()))
6072  except:
6073  CHBVPosEntry.delete(0,END)
6074  CHBVPosEntry.insert(0, CHBOffset)
6075  try:
6076  CHBIOffset = float(eval(CHBIPosEntry.get()))
6077  except:
6078  CHBIPosEntry.delete(0,END)
6079  CHBIPosEntry.insert(0, CHBIOffset)
6080  try:
6081  HoldOff = float(eval(HoldOffentry.get()))
6082  if HoldOff < 0:
6083  HoldOff = 0
6084  except:
6085  HoldOffentry.delete(0,END)
6086  HoldOffentry.insert(0, HoldOff)
6087  if ETSDisp.get() > 0 or MinigenScreenStatus.get() > 0:
6088  try:
6089  Mulx = float(eval(HtMulEntry.get()))
6090  if Mulx < 1:
6091  Mulx = 1
6092  except:
6093  Mulx = 1
6094  if EnableHSsampling > 0:
6095  HtMulEntry.delete(0,END)
6096  HtMulEntry.insert(0, 1)
6097  else:
6098  Mulx = 1
6099  # slide trace left right by HozPoss
6100  try:
6101  HozPoss = float(eval(HozPossentry.get()))
6102  except:
6103  HozPossentry.delete(0,END)
6104  HozPossentry.insert(0, HozPoss)
6105  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6106  try:
6107  CHMApdvRange = float(eval(CHB_Asb.get()))
6108  except:
6109  CHB_Asb.delete(0,END)
6110  CHB_Asb.insert(0, CHMApdvRange)
6111  try:
6112  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6113  except:
6114  CHB_Bsb.delete(0,END)
6115  CHB_Bsb.insert(0, CHMBpdvRange)
6116  try:
6117  CHMCpdvRange = float(eval(CHB_Csb.get()))
6118  except:
6119  CHB_Csb.delete(0,END)
6120  CHB_Csb.insert(0, CHMCpdvRange)
6121  try:
6122  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6123  except:
6124  CHB_Dsb.delete(0,END)
6125  CHB_Dsb.insert(0, CHMDpdvRange)
6126  if CHMApdvRange < 0.001:
6127  CHMApdvRange = 0.001
6128  if CHMBpdvRange < 0.001:
6129  CHMBpdvRange = 0.001
6130  if CHMCpdvRange < 0.001:
6131  CHMCpdvRange = 0.001
6132  if CHMDpdvRange < 0.001:
6133  CHMDpdvRange = 0.001
6134  try:
6135  CHBAOffset = float(eval(CHB_APosEntry.get()))
6136  except:
6137  CHB_APosEntry.delete(0,END)
6138  CHB_APosEntry.insert(0, CHBAOffset)
6139  try:
6140  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6141  except:
6142  CHB_BPosEntry.delete(0,END)
6143  CHB_BPosEntry.insert(0, CHBBOffset)
6144  try:
6145  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6146  except:
6147  CHB_CPosEntry.delete(0,END)
6148  CHB_CPosEntry.insert(0, CHBCOffset)
6149  try:
6150  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6151  except:
6152  CHB_DPosEntry.delete(0,END)
6153  CHB_DPosEntry.insert(0, CHBDOffset)
6154  # prevent divide by zero error
6155  if CH1pdvRange < 0.001:
6156  CH1pdvRange = 0.001
6157  if CH2pdvRange < 0.001:
6158  CH2pdvRange = 0.001
6159  if CH1IpdvRange < 0.1:
6160  CH1IpdvRange = 0.1
6161  if CH2IpdvRange < 0.1:
6162  CH2IpdvRange = 0.1
6163  vt = HoldOff + HozPoss # invert sign and scale to mSec
6164  if ScreenTrefresh.get() == 0:
6165  # Delete all items on the screen
6166  ca.delete(ALL) # remove all items
6167  MarkerNum = 0
6168  # Draw horizontal grid lines
6169  i = 0
6170  x1 = X0L
6171  x2 = X0L + GRW
6172  mg_siz = GRW/10.0
6173  mg_inc = mg_siz/5.0
6174  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)
6175  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)
6176  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)
6177  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)
6178  # vertical scale text labels
6179  RightOffset = FontSize * 3
6180  LeftOffset = int(FontSize/2)
6181  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
6182  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
6183  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
6184  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
6185  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
6186  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
6187  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
6188  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
6189  #
6190  while (i < 11):
6191  y = Y0T + i * GRH/10.0
6192  Dline = [x1,y,x2,y]
6193  if i == 5:
6194  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
6195  k = 0
6196  while (k < 10):
6197  l = 1
6198  while (l < 5):
6199  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
6200  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6201  l = l + 1
6202  k = k + 1
6203  else:
6204  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6205 
6206  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
6207  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6208  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
6209  Vaxis_label = str(round(Vaxis_value,3 ))
6210  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
6211 
6212  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
6213  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6214  Iaxis_label = str(round(Iaxis_value, 3))
6215  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
6216 
6217  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
6218  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6219  Vaxis_label = str(round(Vaxis_value, 3))
6220  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
6221 
6222  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
6223  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6224  Iaxis_label = str(round(Iaxis_value, 3))
6225  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
6226  if MuxScreenStatus.get() == 1:
6227  if Show_CBA.get() == 1:
6228  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
6229  Vaxis_label = str(round(Vaxis_value, 3))
6230  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
6231  if Show_CBB.get() == 1:
6232  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
6233  Iaxis_label = str(round(Iaxis_value, 3))
6234  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
6235  if Show_CBC.get() == 1:
6236  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
6237  Iaxis_label = str(round(Iaxis_value, 3))
6238  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
6239  if Show_CBD.get() == 1:
6240  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
6241  Iaxis_label = str(round(Iaxis_value, 3))
6242  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
6243  i = i + 1
6244  # Draw vertical grid lines
6245  i = 0
6246  y1 = Y0T
6247  y2 = Y0T + GRH
6248  mg_siz = GRH/10.0
6249  mg_inc = mg_siz/5.0
6250  vx = TIMEdiv/Mulx
6251  vt = HoldOff/Mulx # invert sign and scale to mSec
6252  # vx = TIMEdiv
6253  while (i < 11):
6254  x = X0L + i * GRW/10.0
6255  Dline = [x,y1,x,y2]
6256  if (i == 5):
6257  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
6258  k = 0
6259  while (k < 10):
6260  l = 1
6261  while (l < 5):
6262  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
6263  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6264  l = l + 1
6265  k = k + 1
6266  #
6267  if vx >= 1000:
6268  axis_value = ((i * vx)+ vt) / 1000.0
6269  axis_label = ' {0:.1f} '.format(axis_value) + " S"
6270  if vx < 1000 and vx >= 1:
6271  axis_value = (i * vx) + vt
6272  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
6273  if vx < 1:
6274  axis_value = ((i * vx) + vt) * 1000.0
6275  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
6276  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
6277  else:
6278  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6279  if vx >= 1000:
6280  axis_value = ((i * vx)+ vt) / 1000.0
6281  axis_label = ' {0:.1f} '.format(axis_value) + " S"
6282  if vx < 1000 and vx >= 1:
6283  axis_value = (i * vx) + vt
6284  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
6285  if vx < 1:
6286  axis_value = ((i * vx) + vt) * 1000.0
6287  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
6288  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
6289 
6290  i = i + 1
6291  # Write the trigger line if available
6292  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
6293  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
6294  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
6295  if TgInput.get() == 1:
6296  TgLabel = "CA-V"
6297  if TgInput.get() == 2:
6298  TgLabel = "CA-I"
6299  if TgInput.get() == 3:
6300  TgLabel = "CB-V"
6301  if TgInput.get() == 4:
6302  TgLabel = "CB-I"
6303  if TgInput.get() == 5:
6304  TgLabel = "Math"
6305  if TgInput.get() == 6:
6306  TgLabel = "MathX"
6307  if TgInput.get() == 7:
6308  TgLabel = "MathY"
6309  if Is_Triggered == 1:
6310  TgLabel = TgLabel + " Triggered"
6311  else:
6312  TgLabel = TgLabel + " Not Triggered"
6313  if SingleShot.get() > 0:
6314  TgLabel = TgLabel + " Armed"
6315  x = X0L + (GRW/2) + 12
6316  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
6317  # Draw T - V Cursor lines if required
6318  if MarkerScale.get() == 0:
6319  Yconv1 = float(GRH/10.0) / CH1pdvRange
6320  Yoffset1 = CHAOffset
6321  COLORmarker = COLORtrace1
6322  Units = " V"
6323  if MarkerScale.get() == 1:
6324  MouseY = MouseCAV
6325  Yconv1 = float(GRH/10.0) / CH1pdvRange
6326  Yoffset1 = CHAOffset
6327  COLORmarker = COLORtrace1
6328  Units = " V"
6329  if MarkerScale.get() == 2:
6330  MouseY = MouseCBV
6331  Yconv1 = float(GRH/10.0) / CH2pdvRange
6332  Yoffset1 = CHBOffset
6333  COLORmarker = COLORtrace2
6334  Units = " V"
6335  if MarkerScale.get() == 3:
6336  MouseY = MouseCAI
6337  Yconv1 = float(GRH/10.0) / CH1IpdvRange
6338  Yoffset1 = CHAIOffset
6339  COLORmarker = COLORtrace3
6340  Units = " mA"
6341  if MarkerScale.get() == 4:
6342  MouseY = MouseCBI
6343  Yconv1 = float(GRH/10.0) / CH2IpdvRange
6344  Yoffset1 = CHBIOffset
6345  COLORmarker = COLORtrace4
6346  Units = " mA"
6347  # Analog Mux settings
6348  if MarkerScale.get() == 5:
6349  MouseY = MouseMuxA
6350  Yconv1 = float(GRH/10.0) / CHMApdvRange
6351  Yoffset1 = CHBAOffset
6352  COLORmarker = COLORtrace2
6353  Units = " V"
6354  if MarkerScale.get() == 6:
6355  MouseY = MouseMuxB
6356  Yconv1 = float(GRH/10.0) / CHMBpdvRange
6357  Yoffset1 = CHBBOffset
6358  COLORmarker = COLORtrace6
6359  Units = " V"
6360  if MarkerScale.get() == 7:
6361  MouseY = MouseMuxC
6362  Yconv1 = float(GRH/10.0) / CHMCpdvRange
6363  Yoffset1 = CHBCOffset
6364  COLORmarker = COLORtrace7
6365  Units = " V"
6366  if MarkerScale.get() == 8:
6367  MouseY = MouseMuxD
6368  Yconv1 = float(GRH/10.0) / CHMDpdvRange
6369  Yoffset1 = CHBDOffset
6370  COLORmarker = COLORtrace4
6371  Units = " V"
6372 #
6373  if ShowTCur.get() > 0:
6374  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
6375  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6376  Tpoint = ((TCursor-X0L) * Tstep) + vt
6377  Tpoint = Tpoint/Mulx
6378  if Tpoint >= 1000:
6379  axis_value = Tpoint / 1000.0
6380  V_label = ' {0:.2f} '.format(axis_value) + " S"
6381  if Tpoint < 1000 and Tpoint >= 1:
6382  axis_value = Tpoint
6383  V_label = ' {0:.2f} '.format(axis_value) + " mS"
6384  if Tpoint < 1:
6385  axis_value = Tpoint * 1000.0
6386  V_label = ' {0:.2f} '.format(axis_value) + " uS"
6387  ca.create_text(TCursor+1, VCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
6388  if ShowVCur.get() > 0:
6389  Dline = [X0L, VCursor, X0L+GRW, VCursor]
6390  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
6391  c1 = GRH / 2 + Y0T # fixed Y correction
6392  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
6393  V1String = ' {0:.3f} '.format(-yvolts)
6394  V_label = V1String + Units
6395  ca.create_text(TCursor+1, VCursor+5, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
6396  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
6397  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
6398  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
6399  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6400  Tpoint = ((MouseX-X0L) * Tstep) + vt
6401  Tpoint = Tpoint/Mulx
6402  if Tpoint >= 1000:
6403  axis_value = Tpoint / 1000.0
6404  V_label = ' {0:.2f} '.format(axis_value) + " S"
6405  if Tpoint < 1000 and Tpoint >= 1:
6406  axis_value = Tpoint
6407  V_label = ' {0:.2f} '.format(axis_value) + " mS"
6408  if Tpoint < 1:
6409  axis_value = Tpoint * 1000.0
6410  V_label = ' {0:.2f} '.format(axis_value) + " uS"
6411  ca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
6412  Dline = [X0L, MouseY, X0L+GRW, MouseY]
6413  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6414  c1 = GRH / 2 + Y0T # fixed Y correction
6415  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
6416  V1String = ' {0:.3f} '.format(-yvolts)
6417  V_label = V1String + Units
6418  ca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
6419 #
6420  if MeasGateStatus.get() == 1:
6421  LeftGate = X0L + MeasGateLeft / Tstep
6422  RightGate = X0L + MeasGateRight / Tstep
6423  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), fill=COLORtrace5)
6424  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), fill=COLORtrace7)
6425 #
6426  SmoothBool = SmoothCurves.get()
6427  # Write the traces if available
6428  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
6429  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
6430  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
6431  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
6432  if len(T2Vline) > 4: # Write the trace 2 if active
6433  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6434  if len(T2Iline) > 4:
6435  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6436  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
6437  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6438  if len(TMXline) > 4 : # Write X Math tace if active
6439  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6440  if len(TMYline) > 4 : # Write Y Math tace if active
6441  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6442  if MuxScreenStatus.get() == 1:
6443  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
6444  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6445  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
6446  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6447  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
6448  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6449  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
6450  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6451  if ShowRB_V.get() == 1 and len(TMBRline) > 4:
6452  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6453  if ShowRB_I.get() == 1 and len(TMCRline) > 4:
6454  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6455  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
6456  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6457  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
6458  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6459  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
6460  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6461  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
6462  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6463  if ShowMath.get() == 1 and len(TMRline) > 4:
6464  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6465 
6466  # General information on top of the grid
6467  # Sweep information
6468  if session.continuous:
6469  sttxt = "Running Continuous"
6470  else:
6471  sttxt = "Running Discontinuous"
6472  if TRACEmodeTime.get() == 1:
6473  sttxt = sttxt + " Averaging"
6474  if ManualTrigger.get() == 1:
6475  sttxt = "Manual Trigger"
6476  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
6477  sttxt = "Stopped"
6478  if ScreenTrefresh.get() == 1:
6479  sttxt = sttxt + " Persistance ON"
6480  # Delete text at bottom of screen
6481  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
6482  for n in de:
6483  ca.delete(n)
6484  # Delete text at top of screen
6485  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
6486  for n in de:
6487  ca.delete(n)
6488  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
6489  x = X0L+2
6490  y = 12
6491  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6492  # digital I/O indicators
6493  x2 = X0L + GRW
6494  BoxColor = "#808080" # gray
6495  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
6496  if D0.get() == 0 and D4.get() == 0:
6497  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
6498  if Dval[0] == 1:
6499  BoxColor = "#00ff00" # 100% green
6500  elif Dval[0] == 0:
6501  BoxColor = "#ff0000" # 100% red
6502  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
6503  else:
6504  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
6505  if D1.get() == 0 and D5.get() == 0:
6506  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
6507  if Dval[0] == 1:
6508  BoxColor = "#00ff00" # 100% green
6509  elif Dval[0] == 0:
6510  BoxColor = "#ff0000" # 100% red
6511  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
6512  else:
6513  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
6514  if D2.get() == 0 and D6.get() == 0:
6515  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
6516  if Dval[0] == 1:
6517  BoxColor = "#00ff00" # 100% green
6518  elif Dval[0] == 0:
6519  BoxColor = "#ff0000" # 100% red
6520  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
6521  else:
6522  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
6523  if D3.get() == 0 and D7.get() == 0:
6524  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
6525  if Dval[0] == 1:
6526  BoxColor = "#00ff00" # 100% green
6527  elif Dval[0] == 0:
6528  BoxColor = "#ff0000" # 100% red
6529  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
6530  else:
6531  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
6532  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
6533  # Time sweep information and view at information
6534  vx = TIMEdiv/Mulx
6535  if vx >= 1000:
6536  txt = ' {0:.2f} '.format(vx / 1000.0) + " S/div"
6537  if vx < 1000 and vx >= 1:
6538  txt = ' {0:.2f} '.format(vx) + " mS/div"
6539  if vx < 1:
6540  txt = ' {0:.2f} '.format(vx * 1000.0) + " uS/div"
6541 
6542  txt = txt + " "
6543  #
6544  txt = txt + "View at "
6545  if abs(vt) >= 1000:
6546  txt = txt + str(int(vt / 1000.0)) + " S "
6547  if abs(vt) < 1000 and abs(vt) >= 1:
6548  txt = txt + str(int(vt)) + " mS "
6549  if abs(vt) < 1:
6550  txt = txt + str(int(vt * 1000.0)) + " uS "
6551  # print period and frequency of displayed channels
6552  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
6553  FindRisingEdge(VBuffA,VBuffB)
6554  if ShowC1_V.get() == 1:
6555  if MeasAHW.get() == 1:
6556  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
6557  if MeasALW.get() == 1:
6558  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
6559  if MeasADCy.get() == 1:
6560  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
6561  if MeasAPER.get() == 1:
6562  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
6563  if MeasAFREQ.get() == 1:
6564  txt = txt + " CA Freq = "
6565  ChaF = CHAfreq*Mulx
6566  if ChaF < 1000:
6567  V1String = ' {0:.1f} '.format(ChaF)
6568  txt = txt + str(V1String) + " Hz "
6569  if ChaF > 1000 and ChaF < 1000000:
6570  V1String = ' {0:.1f} '.format(ChaF/1000)
6571  txt = txt + str(V1String) + " KHz "
6572  if ChaF > 1000000:
6573  V1String = ' {0:.1f} '.format(ChaF/1000000)
6574  txt = txt + str(V1String) + " MHz "
6575  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
6576  if ShowC2_V.get() == 1:
6577  if MeasBHW.get() == 1:
6578  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
6579  if MeasBLW.get() == 1:
6580  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
6581  if MeasBDCy.get() == 1:
6582  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
6583  if MeasBPER.get() == 1:
6584  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
6585  if MeasBFREQ.get() == 1:
6586  txt = txt + " CB Freq = "
6587  ChaF = CHBfreq*Mulx
6588  if ChaF < 1000:
6589  V1String = ' {0:.1f} '.format(ChaF)
6590  txt = txt + str(V1String) + " Hz "
6591  if ChaF > 1000 and ChaF < 1000000:
6592  V1String = ' {0:.1f} '.format(ChaF/1000)
6593  txt = txt + str(V1String) + " KHz "
6594  if ChaF > 1000000:
6595  V1String = ' {0:.1f} '.format(ChaF/1000000)
6596  txt = txt + str(V1String) + " MHz "
6597  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
6598  if MuxScreenStatus.get() == 0:
6599  if MeasPhase.get() == 1:
6600  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
6601  if MeasDelay.get() == 1:
6602  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
6603 
6604  x = X0L
6605  y = Y0T+GRH+int(2.5 *FontSize) # 20
6606  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6607  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
6608  MakeHistogram()
6609  txt = " "
6610  if ShowC1_V.get() == 1:
6611  # Channel A information
6612  if CHA_RC_HP.get() == 1:
6613  txt = "CHA: HP "
6614  else:
6615  txt = "CHA: "
6616  txt = txt + str(CH1pdvRange) + " V/div"
6617  if MeasDCV1.get() == 1:
6618  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
6619  if MeasMaxV1.get() == 1:
6620  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
6621  if MeasTopV1.get() == 1:
6622  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
6623  if MeasMinV1.get() == 1:
6624  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
6625  if MeasBaseV1.get() == 1:
6626  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
6627  if MeasMidV1.get() == 1:
6628  MidV1 = (MaxV1+MinV1)/2.0
6629  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
6630  if MeasPPV1.get() == 1:
6631  PPV1 = MaxV1-MinV1
6632  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
6633  if MeasRMSV1.get() == 1:
6634  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
6635  if MeasRMSVA_B.get() == 1:
6636  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
6637  if MeasDiffAB.get() == 1:
6638  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
6639  if MeasUserA.get() == 1:
6640  try:
6641  TempValue = eval(UserAString)
6642  V1String = ' {0:.4f} '.format(TempValue)
6643  except:
6644  V1String = "####"
6645  txt = txt + UserALabel + " = " + V1String
6646  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
6647  txt = "CHA: "
6648  txt = txt + str(CH1IpdvRange) + " mA/div"
6649  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
6650  txt = txt + "CHA: "
6651  txt = txt + str(CH1IpdvRange) + " mA/div"
6652  if ShowC1_I.get() == 1:
6653  if MeasDCI1.get() == 1:
6654  V1String = ' {0:.2f} '.format(DCI1)
6655  txt = txt + " AvgI = " + V1String
6656  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
6657  try:
6658  Resvalue = (DCV1/DCI1)*1000
6659  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
6660  except:
6661  txt = txt + " Res = OverRange"
6662  if MeasMaxI1.get() == 1:
6663  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
6664  if MeasMinI1.get() == 1:
6665  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
6666  if MeasMidI1.get() == 1:
6667  MidI1 = (MaxI1+MinI1)/2.0
6668  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
6669  if MeasPPI1.get() == 1:
6670  PPI1 = MaxI1-MinI1
6671  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
6672  if MeasRMSI1.get() == 1:
6673  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
6674 
6675  x = X0L
6676  y = Y0T+GRH+(4*FontSize) # 32
6677  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6678  txt= " "
6679  # Channel B information
6680  if MuxScreenStatus.get() == 1:
6681  txt = "CHB-Mux: "
6682  if Show_CBA.get() > 0:
6683  FindRisingEdge(VBuffA,VBuffMA)
6684  elif Show_CBB.get() > 0:
6685  FindRisingEdge(VBuffA,VBuffMB)
6686  elif Show_CBC.get() > 0:
6687  FindRisingEdge(VBuffA,VBuffMC)
6688  elif Show_CBD.get() > 0:
6689  FindRisingEdge(VBuffA,VBuffMD)
6690  if MeasPhase.get() == 1:
6691  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
6692  if MeasDelay.get() == 1:
6693  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
6694  if MeasUserB.get() == 1:
6695  try:
6696  TempValue = eval(UserBString)
6697  V1String = ' {0:.4f} '.format(TempValue)
6698  except:
6699  V1String = "####"
6700  txt = txt + UserBLabel + " = " + V1String
6701  if ShowC2_V.get() == 1:
6702  if CHB_RC_HP.get() == 1:
6703  txt = "CHB: HP "
6704  else:
6705  txt = "CHB: "
6706  txt = txt + str(CH2pdvRange) + " V/div"
6707  if MeasDCV2.get() == 1:
6708  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
6709  if MeasMaxV2.get() == 1:
6710  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
6711  if MeasTopV2.get() == 1:
6712  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
6713  if MeasMinV2.get() == 1:
6714  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
6715  if MeasBaseV2.get() == 1:
6716  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
6717  if MeasMidV2.get() == 1:
6718  MidV2 = (MaxV2+MinV2)/2.0
6719  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
6720  if MeasPPV2.get() == 1:
6721  PPV2 = MaxV2-MinV2
6722  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
6723  if MeasRMSV2.get() == 1:
6724  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
6725  if MeasDiffBA.get() == 1:
6726  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
6727  if MeasUserB.get() == 1:
6728  try:
6729  TempValue = eval(UserBString)
6730  V1String = ' {0:.4f} '.format(TempValue)
6731  except:
6732  V1String = "####"
6733  txt = txt + UserBLabel + " = " + V1String
6734  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
6735  txt = "CHB: "
6736  txt = txt + str(CH2IpdvRange) + " mA/div"
6737  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
6738  txt = txt + "CHB: "
6739  txt = txt + str(CH2IpdvRange) + " mA/div"
6740  if ShowC2_I.get() == 1:
6741  if MeasDCI2.get() == 1:
6742  V1String = ' {0:.2f} '.format(DCI2)
6743  txt = txt + " AvgI = " + V1String
6744  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
6745  try:
6746  Resvalue = (DCV2/DCI2)*1000
6747  R1String = ' {0:.1f} '.format(Resvalue)
6748  txt = txt + " Res = " + R1String
6749  except:
6750  txt = txt + " Res = OverRange"
6751  if MeasMaxI2.get() == 1:
6752  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
6753  if MeasMinI2.get() == 1:
6754  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
6755  if MeasMidI2.get() == 1:
6756  MidI2 = (MaxI2+MinI2)/2.0
6757  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
6758  if MeasPPI2.get() == 1:
6759  PPI2 = MaxI2-MinI2
6760  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
6761  if MeasRMSI2.get() == 1:
6762  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
6763 
6764  x = X0L
6765  y = Y0T+GRH+int(5.5*FontSize) # 44
6766  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6767 
6769  global TXYline # active trave lines
6770  global Tmathline, TMRline, TXYRline
6771  global X0LXY # Left top X value
6772  global Y0TXY # Left top Y value
6773  global GRWXY # Screenwidth
6774  global GRHXY # Screenheight
6775  global FontSize
6776  global XYca, MouseX, MouseY, MouseWidget
6777  global ShowXCur, ShowYCur, XCursor, YCursor
6778  global SHOWsamples # Number of samples in data record
6779  global ShowRXY, ShowMath, MathUnits, MathXUnits, MathYUnits
6780  global Xsignal, Ysignal, MathXAxis, MathYAxis
6781  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
6782  global CHAsbxy # spinbox Index for channel 1 V
6783  global CHBsbxy # spinbox Index for channel 2 V
6784  global CHAOffset # Offset value for channel 1 V
6785  global CHBOffset # Offset value for channel 2 V
6786  global CHAIsbxy # spinbox Index for channel 1 I
6787  global CHBIsbxy # spinbox Index for channel 2 I
6788  global CHAIOffset # Offset value for channel 1 I
6789  global CHBIOffset # Offset value for channel 2 I
6790  global TMpdiv # Array with time / div values in ms
6791  global TMsb # Time per div spin box variable
6792  global TIMEdiv # current spin box value
6793  global SAMPLErate
6794  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
6795  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7 # The colors
6796  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
6797  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5
6798  global CANVASwidthXY, CANVASheightXY
6799  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
6800  global ScreenXYrefresh, SmoothCurves
6801  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
6802  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
6803  global SV1, SI1, SV2, SI2, CHABphase
6804  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
6805  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
6806  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
6807  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
6808  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
6809  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
6810  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
6811  global AWGAShape, AWGBShape
6812  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6813  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6814  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
6815  global DacScreenStatus, DigScreenStatus
6816  global D0, D1, D2, D3, D4, D5, D6, D7
6817  global DevID, devx, MarkerNum, MarkerScale
6818  global HozPoss, HozPossentry
6819  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
6820  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
6821  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
6822  #
6823  Ymin = Y0TXY # Minimum position of screen grid (top)
6824  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
6825  try:
6826  InOffA = float(eval(CHAVOffsetEntry.get()))
6827  except:
6828  CHAVOffsetEntry.delete(0,END)
6829  CHAVOffsetEntry.insert(0, InOffA)
6830  try:
6831  InGainA = float(eval(CHAVGainEntry.get()))
6832  except:
6833  CHAVGainEntry.delete(0,END)
6834  CHAVGainEntry.insert(0, InGainA)
6835  try:
6836  InOffB = float(eval(CHBVOffsetEntry.get()))
6837  except:
6838  CHBVOffsetEntry.delete(0,END)
6839  CHBVOffsetEntry.insert(0, InOffB)
6840  try:
6841  InGainB = float(eval(CHBVGainEntry.get()))
6842  except:
6843  CHBVGainEntry.delete(0,END)
6844  CHBVGainEntry.insert(0, InGainB)
6845 #
6846  try:
6847  CH1pdvRange = float(eval(CHAsbxy.get()))
6848  except:
6849  CHAsbxy.delete(0,END)
6850  CHAsbxy.insert(0, CH1vpdvRange)
6851  try:
6852  CH2pdvRange = float(eval(CHBsbxy.get()))
6853  except:
6854  CHBsbxy.delete(0,END)
6855  CHBsbxy.insert(0, CH2vpdvRange)
6856  try:
6857  CH1IpdvRange = float(eval(CHAIsbxy.get()))
6858  except:
6859  CHAIsbxy.delete(0,END)
6860  CHAIsbxy.insert(0, CH1IpdvRange)
6861  try:
6862  CH2IpdvRange = float(eval(CHBIsbxy.get()))
6863  except:
6864  CHBIsbxy.delete(0,END)
6865  CHBIsbxy.insert(0, CH2IpdvRange)
6866  # get the vertical offsets
6867  try:
6868  CHAOffset = float(eval(CHAVPosEntryxy.get()))
6869  except:
6870  CHAVPosEntryxy.delete(0,END)
6871  CHAVPosEntryxy.insert(0, CHAOffset)
6872  try:
6873  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
6874  except:
6875  CHAIPosEntryxy.delete(0,END)
6876  CHAIPosEntryxy.insert(0, CHAIOffset)
6877  try:
6878  CHBOffset = float(eval(CHBVPosEntryxy.get()))
6879  except:
6880  CHBVPosEntry.delete(0,END)
6881  CHBVPosEntry.insert(0, CHBOffset)
6882  try:
6883  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
6884  except:
6885  CHBIPosEntryxy.delete(0,END)
6886  CHBIPosEntryxy.insert(0, CHBIOffset)
6887  # prevent divide by zero error
6888  if CH1pdvRange < 0.001:
6889  CH1pdvRange = 0.001
6890  if CH2pdvRange < 0.001:
6891  CH2pdvRange = 0.001
6892  if CH1IpdvRange < 0.05:
6893  CH1IpdvRange = 0.05
6894  if CH2IpdvRange < 0.05:
6895  CH2IpdvRange = 0.05
6896  # If drawing histograms adjust offset based on range such that bottom grid is zero
6897  if Xsignal.get() == 6:
6898  CHAIOffset = 5 * CH1IpdvRange
6899  if Xsignal.get() == 7:
6900  CHBIOffset = 5 * CH2IpdvRange
6901  if ScreenXYrefresh.get() == 0:
6902  # Delete all items on the screen
6903  MarkerNum = 0
6904  XYca.delete(ALL) # remove all items
6905  # Draw horizontal grid lines
6906  i = 0
6907  x1 = X0LXY
6908  x2 = X0LXY + GRWXY
6909  mg_siz = GRWXY/10.0
6910  mg_inc = mg_siz/5.0
6911  while (i < 11):
6912  y = Y0TXY + i * GRHXY/10.0
6913  Dline = [x1,y,x2,y]
6914  if i == 5:
6915  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
6916  k = 0
6917  while (k < 10):
6918  l = 1
6919  while (l < 5):
6920  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
6921  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6922  l = l + 1
6923  k = k + 1
6924  else:
6925  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6926  if Ysignal.get() == 2 or Xsignal.get() == 6:
6927  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6928  Iaxis_label = str(round(Iaxis_value, 3))
6929  XYca.create_text(x1-3, y, text=Iaxis_label, fill=COLORtrace3, anchor="e", font=("arial", FontSize ))
6930  elif Ysignal.get() == 4 or Xsignal.get() == 7:
6931  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6932  Iaxis_label = str(round(Iaxis_value, 3))
6933  XYca.create_text(x1-3, y, text=Iaxis_label, fill=COLORtrace4, anchor="e", font=("arial", FontSize ))
6934  elif Ysignal.get() == 1:
6935  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6936  Vaxis_label = str(round(Vaxis_value, 3))
6937  XYca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
6938  elif Ysignal.get() == 3:
6939  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6940  Vaxis_label = str(round(Vaxis_value, 3))
6941  XYca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
6942  elif Ysignal.get() == 5:
6943  TempCOLOR = COLORtrace5
6944  if MathTrace.get() == 2:
6945  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6946  elif MathTrace.get() == 3:
6947  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6948  else:
6949  if MathYAxis == "V-A":
6950  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6951  TempCOLOR = COLORtrace1
6952  elif MathYAxis == "V-B":
6953  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6954  TempCOLOR = COLORtrace2
6955  elif MathYAxis == "I-A":
6956  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6957  TempCOLOR = COLORtrace3
6958  elif MathYAxis == "I-B":
6959  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6960  TempCOLOR = COLORtrace4
6961  else:
6962  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6963  Vaxis_label = str(round(Vaxis_value, 3))
6964  XYca.create_text(x1-3, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
6965  i = i + 1
6966  # Draw vertical grid lines
6967  i = 0
6968  y1 = Y0TXY
6969  y2 = Y0TXY + GRHXY
6970  mg_siz = GRHXY/10.0
6971  mg_inc = mg_siz/5.0
6972  #
6973  while (i < 11):
6974  x = X0LXY + i * GRWXY/10.0
6975  Dline = [x,y1,x,y2]
6976  if (i == 5):
6977  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
6978  k = 0
6979  while (k < 10):
6980  l = 1
6981  while (l < 5):
6982  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
6983  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6984  l = l + 1
6985  k = k + 1
6986  if Xsignal.get() == 1 or Xsignal.get() == 6: #
6987  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
6988  Vaxis_label = str(round(Vaxis_value, 3))
6989  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
6990  elif Xsignal.get() == 3 or Xsignal.get() == 7:
6991  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
6992  Vaxis_label = str(round(Vaxis_value, 3))
6993  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
6994  elif Xsignal.get() == 2:
6995  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
6996  Iaxis_label = str(round(Iaxis_value, 3))
6997  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
6998  elif Xsignal.get() == 4:
6999  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7000  Iaxis_label = str(round(Iaxis_value, 3))
7001  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
7002  elif Xsignal.get() == 5:
7003  TempCOLOR = COLORtrace5
7004  if MathTrace.get() == 2:
7005  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7006  elif MathTrace.get() == 3:
7007  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7008  else:
7009  if MathXAxis == "V-A":
7010  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7011  TempCOLOR = COLORtrace1
7012  elif MathXAxis == "V-B":
7013  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7014  TempCOLOR = COLORtrace2
7015  elif MathXAxis == "I-A":
7016  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7017  TempCOLOR = COLORtrace3
7018  elif MathXAxis == "I-B":
7019  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7020  TempCOLOR = COLORtrace4
7021  else:
7022  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7023  TempCOLOR = COLORtrace5
7024  Vaxis_label = str(round(Vaxis_value, 3))
7025  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
7026  else:
7027  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7028  if Xsignal.get() == 1 or Xsignal.get() == 6:
7029  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7030  Vaxis_label = str(round(Vaxis_value, 3))
7031  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
7032  elif Xsignal.get() == 3 or Xsignal.get() == 7:
7033  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7034  Vaxis_label = str(round(Vaxis_value, 3))
7035  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
7036  elif Xsignal.get() == 2:
7037  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7038  Iaxis_label = str(round(Iaxis_value, 3))
7039  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
7040  elif Xsignal.get() == 4:
7041  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7042  Iaxis_label = str(round(Iaxis_value, 3))
7043  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
7044  elif Xsignal.get() == 5:
7045  TempCOLOR = COLORtrace5
7046  if MathTrace.get() == 2:
7047  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7048  elif MathTrace.get() == 3:
7049  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7050  else:
7051  if MathXAxis == "V-A":
7052  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7053  TempCOLOR = COLORtrace1
7054  elif MathXAxis == "V-B":
7055  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7056  TempCOLOR = COLORtrace2
7057  elif MathXAxis == "I-A":
7058  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7059  TempCOLOR = COLORtrace3
7060  elif MathXAxis == "I-B":
7061  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7062  TempCOLOR = COLORtrace4
7063  else:
7064  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7065  Vaxis_label = str(round(Vaxis_value, 3))
7066  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
7067  i = i + 1
7068 # Draw traces
7069  if len(TXYline) > 4: # Avoid writing lines with 1 coordinate
7070  if Xsignal.get() == 1:
7071  XYca.create_line(TXYline, fill=COLORtrace1, width=TRACEwidth.get())
7072  elif Xsignal.get() == 2:
7073  XYca.create_line(TXYline, fill=COLORtrace3, width=TRACEwidth.get())
7074  elif Xsignal.get() == 3:
7075  XYca.create_line(TXYline, fill=COLORtrace2, width=TRACEwidth.get())
7076  elif Xsignal.get() == 4:
7077  XYca.create_line(TXYline, fill=COLORtrace4, width=TRACEwidth.get())
7078  elif Xsignal.get() == 5 or Ysignal.get() == 5:
7079  XYca.create_line(TXYline, fill=COLORtrace5, width=TRACEwidth.get())
7080  if len(TXYRline) > 4 and ShowRXY.get() == 1:
7081  XYca.create_line(TXYRline, fill=COLORtraceR1, width=TRACEwidth.get())
7082 # Draw Histogram Traces
7083  if Xsignal.get() == 6:
7084  MakeHistogram()
7085  b = 0
7086  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7087  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
7088  y1 = Y0TXY + GRHXY
7089  # print Yconv1, y1
7090  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7091  while b < 4999: #
7092  if HistAsPercent == 1: # convert to percent of total sample count
7093  ylo = float(HBuffA[0][b]) / len(VBuffA)
7094  ylo = ylo * 100.0
7095  else:
7096  ylo = HBuffA[0][b] #
7097  ylo = int(y1 - (Yconv1 * ylo))
7098  if ylo > Ymax:
7099  ylo = Ymax
7100  if ylo < Ymin:
7101  ylo = Ymin
7102  xlo = HBuffA[1][b] - CHAOffset
7103  xlo = int(c2 + Xconv1 * xlo)
7104  Dline = [xlo,y1,xlo,ylo]
7105  XYca.create_line(Dline, fill=COLORtrace1)
7106  b = b + 1
7107  if Xsignal.get() == 7:
7108  MakeHistogram()
7109  b = 0
7110  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7111  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
7112  y1 = Y0TXY + GRHXY
7113  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7114  while b < 4999: #
7115  if HistAsPercent == 1: # convert to percent
7116  ylo = float(HBuffB[0][b]) / len(VBuffB)
7117  ylo = ylo * 100.0
7118  else:
7119  ylo = HBuffB[0][b]
7120  ylo = int(y1 - Yconv1 * ylo)
7121  if ylo > Ymax:
7122  ylo = Ymax
7123  if ylo < Ymin:
7124  ylo = Ymin
7125  xlo = HBuffB[1][b] - CHBOffset
7126  xlo = int(c2 + Xconv1 * xlo)
7127  Dline = [xlo,y1,xlo,ylo]
7128  XYca.create_line(Dline, fill=COLORtrace2)
7129  b = b + 1
7130 # Draw X - Y Cursor lines if required
7131  if Xsignal.get() == 1 or Xsignal.get() == 6:
7132  Xconv1 = float(GRWXY/10) / CH1pdvRange
7133  Xoffset1 = CHAOffset
7134  COLORXmarker = COLORtrace1
7135  X_label = " V"
7136  if Xsignal.get() == 2:
7137  Xconv1 = float(GRWXY/10) / CH1IpdvRange
7138  Xoffset1 = CHAIOffset
7139  COLORXmarker = COLORtrace3
7140  X_label = " mA"
7141  if Xsignal.get() == 3 or Xsignal.get() == 7:
7142  Xconv1 = float(GRWXY/10) / CH2pdvRange
7143  Xoffset1 = CHBOffset
7144  COLORXmarker = COLORtrace2
7145  X_label = " V"
7146  if Xsignal.get() == 4:
7147  Xconv1 = float(GRWXY/10) / CH2IpdvRange
7148  Xoffset1 = CHBIOffset
7149  COLORmarker = COLORtrace4
7150  X_label = " mA"
7151  if Xsignal.get() == 5:
7152  X_label = MathXUnits
7153  if MathXAxis == "V-A":
7154  Xconv1 = float(GRWXY/10) / CH1pdvRange
7155  Xoffset1 = CHAOffset
7156  COLORXmarker = COLORtrace1
7157  elif MathXAxis == "V-B":
7158  Xconv1 = float(GRWXY/10) / CH2pdvRange
7159  Xoffset1 = CHBOffset
7160  COLORXmarker = COLORtrace2
7161  elif MathXAxis == "I-A":
7162  Xconv1 = float(GRWXY/10) / CH1IpdvRange
7163  Xoffset1 = CHAIOffset
7164  COLORXmarker = COLORtrace3
7165  elif MathXAxis == "I-B":
7166  Xconv1 = float(GRWXY/10) / CH2IpdvRange
7167  Xoffset1 = CHBIOffset
7168  COLORXmarker = COLORtrace4
7169  else:
7170  Xconv1 = float(GRWXY/10) / CH1pdvRange
7171  Xoffset1 = CHAOffset
7172  COLORXmarker = COLORtrace1
7173 #
7174  if Ysignal.get() == 1 or Ysignal.get() == 6:
7175  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7176  Yoffset1 = CHAOffset
7177  COLORYmarker = COLORtrace1
7178  Y_label = " V"
7179  if Ysignal.get() == 2:
7180  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7181  Yoffset1 = CHAIOffset
7182  COLORYmarker = COLORtrace3
7183  Y_label = " mA"
7184  if Ysignal.get() == 3 or Ysignal.get() == 7:
7185  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
7186  Yoffset1 = CHBOffset
7187  COLORYmarker = COLORtrace2
7188  Y_label = " V"
7189  if Ysignal.get() == 4:
7190  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7191  Yoffset1 = CHBIOffset
7192  COLORYmarker = COLORtrace4
7193  Y_label = " mA"
7194  if Ysignal.get() == 5:
7195  Y_label = MathYUnits
7196  if MathYAxis == "V-A":
7197  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7198  Yoffset1 = CHAOffset
7199  COLORYmarker = COLORtrace1
7200  elif MathYAxis == "V-B":
7201  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
7202  Yoffset1 = CHBOffset
7203  COLORYmarker = COLORtrace2
7204  elif MathYAxis == "I-A":
7205  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7206  Yoffset1 = CHAIOffset
7207  COLORYmarker = COLORtrace3
7208  elif MathYAxis == "I-B":
7209  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7210  Yoffset1 = CHBIOffset
7211  COLORYmarker = COLORtrace4
7212  else:
7213  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7214  Yoffset1 = CHAOffset
7215  COLORYmarker = COLORtrace1
7216  if ShowXCur.get() > 0:
7217  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
7218  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
7219  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
7220  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
7221  XString = ' {0:.3f} '.format(xvolts)
7222  V_label = XString + X_label
7223  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
7224  if ShowYCur.get() > 0:
7225  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
7226  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
7227  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
7228  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
7229  V1String = ' {0:.3f} '.format(-yvolts)
7230  V_label = V1String + Y_label
7231  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
7232  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
7233  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
7234  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
7235  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
7236  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
7237  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
7238  XString = ' {0:.3f} '.format(xvolts)
7239  V_label = XString + X_label
7240  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
7241  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
7242  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
7243  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
7244  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
7245  V1String = ' {0:.3f} '.format(-yvolts)
7246  V_label = V1String + Y_label
7247  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
7248 #
7249 # General information on top of the grid
7250 # Sweep information
7251  sttxt = "Running"
7252  if TRACEmodeTime.get() == 1:
7253  sttxt = sttxt + " Averaging"
7254  if ManualTrigger.get() == 1:
7255  sttxt = "Manual Trigger"
7256  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
7257  sttxt = "Stopped"
7258  if ScreenXYrefresh.get() == 1:
7259  sttxt = sttxt + " Persistance ON"
7260  # Delete text at bottom of screen
7261  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
7262  for n in de:
7263  XYca.delete(n)
7264  # Delete text at top of screen
7265  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
7266  for n in de:
7267  XYca.delete(n)
7268  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7269  x = X0LXY
7270  y = 12
7271  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7272  # digital I/O indicators
7273  x2 = X0LXY + GRWXY
7274  BoxColor = "#808080" # gray
7275  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
7276  if D0.get() == 0 and D4.get() == 0:
7277  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
7278  if Dval[0] == 1:
7279  BoxColor = "#00ff00" # 100% green
7280  elif Dval[0] == 0:
7281  BoxColor = "#ff0000" # 100% red
7282  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
7283  else:
7284  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
7285  if D1.get() == 0 and D5.get() == 0:
7286  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
7287  if Dval[0] == 1:
7288  BoxColor = "#00ff00" # 100% green
7289  elif Dval[0] == 0:
7290  BoxColor = "#ff0000" # 100% red
7291  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
7292  else:
7293  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
7294  if D2.get() == 0 and D6.get() == 0:
7295  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
7296  if Dval[0] == 1:
7297  BoxColor = "#00ff00" # 100% green
7298  elif Dval[0] == 0:
7299  BoxColor = "#ff0000" # 100% red
7300  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
7301  else:
7302  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
7303  if D3.get() == 0 and D7.get() == 0:
7304  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
7305  if Dval[0] == 1:
7306  BoxColor = "#00ff00" # 100% green
7307  elif Dval[0] == 0:
7308  BoxColor = "#ff0000" # 100% red
7309  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
7310  else:
7311  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
7312  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
7313  # print period and frequency of displayed channels
7314  txt = " "
7315  if Xsignal.get() == 1 or Xsignal.get() == 3:
7316  FindRisingEdge(VBuffA, VBuffB)
7317  if Xsignal.get() == 1:
7318  if MeasAHW.get() == 1:
7319  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
7320  if MeasALW.get() == 1:
7321  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
7322  if MeasADCy.get() == 1:
7323  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
7324  if MeasAPER.get() == 1:
7325  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
7326  if MeasAFREQ.get() == 1:
7327  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
7328  if Xsignal.get() == 3:
7329  if MeasBHW.get() == 1:
7330  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
7331  if MeasBLW.get() == 1:
7332  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
7333  if MeasBDCy.get() == 1:
7334  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
7335  if MeasBPER.get() == 1:
7336  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
7337  if MeasBFREQ.get() == 1:
7338  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
7339  if MeasPhase.get() == 1:
7340  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
7341 
7342  x = X0LXY
7343  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
7344  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7345  txt = " "
7346  if Xsignal.get() == 1 or Ysignal.get() == 1 or Xsignal.get() == 6:
7347  # Channel A information
7348  txt = "CHA: "
7349  txt = txt + str(CH1pdvRange) + " V/div"
7350  if MeasDCV1.get() == 1:
7351  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
7352  if MeasMaxV1.get() == 1:
7353  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
7354  if MeasTopV1.get() == 1:
7355  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
7356  if MeasMinV1.get() == 1:
7357  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
7358  if MeasBaseV1.get() == 1:
7359  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
7360  if MeasMidV1.get() == 1:
7361  MidV1 = (MaxV1+MinV1)/2
7362  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
7363  if MeasPPV1.get() == 1:
7364  PPV1 = MaxV1-MinV1
7365  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
7366  if MeasRMSV1.get() == 1:
7367  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
7368  if MeasUserA.get() == 1:
7369  try:
7370  TempValue = eval(UserAString)
7371  V1String = ' {0:.4f} '.format(TempValue)
7372  except:
7373  V1String = "####"
7374  txt = txt + UserALabel + " = " + V1String
7375  if Xsignal.get() == 2:
7376  txt = "CHA: "
7377  txt = txt + str(CH1IpdvRange) + " mA/div"
7378  elif (Xsignal.get() == 2):
7379  txt = txt + "CHA: "
7380  txt = txt + str(CH1IpdvRange) + " mA/div"
7381  if Xsignal.get() == 2 or Ysignal.get() == 2:
7382  if MeasDCI1.get() == 1:
7383  V1String = ' {0:.2f} '.format(DCI1)
7384  txt = txt + " AvgI = " + V1String
7385  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
7386  try:
7387  Resvalue = (DCV1/DCI1)*1000
7388  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7389  except:
7390  txt = txt + " Res = OverRange"
7391  if MeasMaxI1.get() == 1:
7392  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
7393  if MeasMinI1.get() == 1:
7394  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
7395  if MeasMidI1.get() == 1:
7396  MidI1 = (MaxI1+MinI1)/2
7397  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
7398  if MeasPPI1.get() == 1:
7399  PPI1 = MaxI1-MinI1
7400  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
7401  if MeasRMSI1.get() == 1:
7402  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
7403 
7404  x = X0LXY
7405  y = Y0TXY+GRHXY+int(4*FontSize) # 32
7406  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7407  txt= " "
7408  # Channel B information
7409  if Xsignal.get() == 3 or Ysignal.get() == 3 or Xsignal.get() == 7:
7410  txt = "CHB: "
7411  txt = txt + str(CH2pdvRange) + " V/div"
7412  if MeasDCV2.get() == 1:
7413  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
7414  if MeasMaxV2.get() == 1:
7415  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
7416  if MeasTopV2.get() == 1:
7417  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
7418  if MeasMinV2.get() == 1:
7419  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
7420  if MeasBaseV2.get() == 1:
7421  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
7422  if MeasMidV2.get() == 1:
7423  MidV2 = (MaxV2+MinV2)/2
7424  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
7425  if MeasPPV2.get() == 1:
7426  PPV2 = MaxV2-MinV2
7427  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
7428  if MeasRMSV2.get() == 1:
7429  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
7430  if MeasUserB.get() == 1:
7431  try:
7432  TempValue = eval(UserBString)
7433  V1String = ' {0:.4f} '.format(TempValue)
7434  except:
7435  V1String = "####"
7436  txt = txt + UserBLabel + " = " + V1String
7437  if Xsignal.get() == 4:
7438  txt = "CHB: "
7439  txt = txt + str(CH2IpdvRange) + " mA/div"
7440  elif Xsignal.get() == 4:
7441  txt = txt + "CHB: "
7442  txt = txt + str(CH2IpdvRange) + " mA/div"
7443  if Xsignal.get() == 4 or Ysignal.get() == 4:
7444  if MeasDCI2.get() == 1:
7445  V1String = ' {0:.2f} '.format(DCI2)
7446  txt = txt + " AvgI = " + V1String
7447  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
7448  try:
7449  Resvalue = (DCV2/DCI2)*1000
7450  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7451  except:
7452  txt = txt + " Res = OverRange"
7453  if MeasMaxI2.get() == 1:
7454  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
7455  if MeasMinI2.get() == 1:
7456  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
7457  if MeasMidI2.get() == 1:
7458  MidI2 = (MaxI2+MinI2)/2
7459  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
7460  if MeasPPI2.get() == 1:
7461  PPI2 = MaxI2-MinI2
7462  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
7463  if MeasRMSI2.get() == 1:
7464  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
7465 
7466  x = X0LXY
7467  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
7468  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7469 #
7471  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7472 
7473  if MarkerScale.get() != 1:
7474  MarkerScale.set(1)
7475  CHAlab.config(style="Rtrace1.TButton")
7476  CHBlab.config(style="Strace2.TButton")
7477  CHAIlab.config(style="Strace3.TButton")
7478  CHBIlab.config(style="Strace4.TButton")
7479  else:
7480  MarkerScale.set(0)
7481 #
7483  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7484 
7485  if MarkerScale.get() != 3:
7486  MarkerScale.set(3)
7487  CHAlab.config(style="Strace1.TButton")
7488  CHBlab.config(style="Strace2.TButton")
7489  CHAIlab.config(style="Rtrace3.TButton")
7490  CHBIlab.config(style="Strace4.TButton")
7491  else:
7492  MarkerScale.set(0)
7493 
7495  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7496 
7497  if MarkerScale.get() != 2:
7498  MarkerScale.set(2)
7499  CHAlab.config(style="Strace1.TButton")
7500  CHBlab.config(style="Rtrace2.TButton")
7501  CHAIlab.config(style="Strace3.TButton")
7502  CHBIlab.config(style="Strace4.TButton")
7503  else:
7504  MarkerScale.set(0)
7505 
7507  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7508 
7509  if MarkerScale.get() != 3:
7510  MarkerScale.set(4)
7511  CHAlab.config(style="Strace1.TButton")
7512  CHBlab.config(style="Strace2.TButton")
7513  CHAIlab.config(style="Strace3.TButton")
7514  CHBIlab.config(style="Rtrace4.TButton")
7515  else:
7516  MarkerScale.set(0)
7517 #
7519  global MarkerXYScale, CHAxylab, CHBxylab
7520 
7521  MarkerXYScale.set(1)
7522  CHAxylab.config(style="Rtrace1.TButton")
7523  CHBxylab.config(style="Strace2.TButton")
7524 
7526  global MarkerXYScale, CHAxylab, CHBxylab
7527 
7528  MarkerXYScale.set(2)
7529  CHBxylab.config(style="Rtrace2.TButton")
7530  CHAxylab.config(style="Strace1.TButton")
7531 #
7533  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
7534 
7535  TCursor = event.x
7536  VCursor = event.y
7537  if RUNstatus.get() == 0:
7539  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
7540 #
7542  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
7543  if event.widget == ca:
7544  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
7545  ShiftKeyDwn = event.state & 1
7546  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
7547  TCursor = TCursor + event.delta/100
7548  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
7549  VCursor = VCursor - event.delta/100
7550  else:
7551  try:
7552  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
7553  except:
7554  donothing()
7555  if RUNstatus.get() == 0:
7557 #
7558 def onCanvasUpArrow(event):
7559  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
7560 
7561  shift_key = event.state & 1
7562  if event.widget == ca:
7563  if ShowVCur.get() > 0 and shift_key == 0:
7564  VCursor = VCursor - 1
7565  elif ShowVCur.get() > 0 and shift_key == 1:
7566  VCursor = VCursor - 5
7567  if RUNstatus.get() == 0:
7569  try:
7570  if event.widget == XYca:
7571  if ShowYCur.get() > 0 and shift_key == 0:
7572  YCursor = YCursor - 1
7573  elif ShowYCur.get() > 0 and shift_key == 1:
7574  YCursor = YCursor - 5
7575  if RUNstatus.get() == 0:
7576  UpdateXYScreen()
7577  except:
7578  donothing()
7579  try:
7580  if event.widget == Freqca:
7581  if ShowdBCur.get() > 0 and shift_key == 0:
7582  dBCursor = dBCursor - 1
7583  elif ShowdBCur.get() > 0 and shift_key == 1:
7584  dBCursor = dBCursor - 5
7585  if RUNstatus.get() == 0:
7587  except:
7588  donothing()
7589  try:
7590  if event.widget == Bodeca:
7591  if ShowBdBCur.get() > 0 and shift_key == 0:
7592  BdBCursor = BdBCursor - 1
7593  elif ShowBdBCur.get() > 0 and shift_key == 1:
7594  BdBCursor = BdBCursor - 5
7595  if RUNstatus.get() == 0:
7597  except:
7598  donothing()
7599 #
7601  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
7602 
7603  shift_key = event.state & 1
7604  if event.widget == ca:
7605  if ShowVCur.get() > 0 and shift_key == 0:
7606  VCursor = VCursor + 1
7607  elif ShowVCur.get() > 0 and shift_key == 1:
7608  VCursor = VCursor + 5
7609  if RUNstatus.get() == 0:
7611  try:
7612  if event.widget == XYca:
7613  if ShowYCur.get() > 0 and shift_key == 0:
7614  YCursor = YCursor + 1
7615  elif ShowYCur.get() > 0 and shift_key == 1:
7616  YCursor = YCursor + 5
7617  if RUNstatus.get() == 0:
7618  UpdateXYScreen()
7619  except:
7620  donothing()
7621  try:
7622  if event.widget == Freqca:
7623  if ShowdBCur.get() > 0 and shift_key == 0:
7624  dBCursor = dBCursor + 1
7625  elif ShowdBCur.get() > 0 and shift_key == 1:
7626  dBCursor = dBCursor + 5
7627  if RUNstatus.get() == 0:
7629  except:
7630  donothing()
7631  try:
7632  if event.widget == Bodeca:
7633  if ShowBdBCur.get() > 0 and shift_key == 0:
7634  BdBCursor = BdBCursor + 1
7635  elif ShowBdBCur.get() > 0 and shift_key == 1:
7636  BdBCursor = BdBCursor + 5
7637  if RUNstatus.get() == 0:
7639  except:
7640  donothing()
7641 #
7643  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
7644 
7645  shift_key = event.state & 1
7646  if event.widget == ca:
7647  if ShowTCur.get() > 0 and shift_key == 0:
7648  TCursor = TCursor - 1
7649  elif ShowTCur.get() > 0 and shift_key == 1:
7650  TCursor = TCursor - 5
7651  if RUNstatus.get() == 0:
7653  try:
7654  if event.widget == XYca:
7655  if ShowXCur.get() > 0 and shift_key == 0:
7656  XCursor = XCursor - 1
7657  elif ShowXCur.get() > 0 and shift_key == 1:
7658  XCursor = XCursor - 5
7659  if RUNstatus.get() == 0:
7660  UpdateXYScreen()
7661  except:
7662  donothing()
7663  try:
7664  if event.widget == Freqca:
7665  if ShowFCur.get() > 0 and shift_key == 0:
7666  FCursor = FCursor - 1
7667  elif ShowFCur.get() > 0 and shift_key == 1:
7668  FCursor = FCursor - 5
7669  if RUNstatus.get() == 0:
7671  except:
7672  donothing()
7673  try:
7674  if event.widget == Bodeca:
7675  if ShowBPCur.get() > 0 and shift_key == 0:
7676  BPCursor = BPCursor - 1
7677  elif ShowBPCur.get() > 0 and shift_key == 1:
7678  BPCursor = BPCursor - 5
7679  if RUNstatus.get() == 0:
7681  except:
7682  donothing()
7683 #
7685  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
7686 
7687  shift_key = event.state & 1
7688  if event.widget == ca:
7689  if ShowTCur.get() > 0 and shift_key == 0:
7690  TCursor = TCursor + 1
7691  elif ShowTCur.get() > 0 and shift_key == 1:
7692  TCursor = TCursor + 5
7693  if RUNstatus.get() == 0:
7695  try:
7696  if event.widget == XYca:
7697  if ShowXCur.get() > 0 and shift_key == 0:
7698  XCursor = XCursor + 1
7699  elif ShowXCur.get() > 0 and shift_key == 1:
7700  XCursor = XCursor + 5
7701  if RUNstatus.get() == 0:
7702  UpdateXYScreen()
7703  except:
7704  donothing()
7705  try:
7706  if event.widget == Freqca:
7707  if ShowFCur.get() > 0 and shift_key == 0:
7708  FCursor = FCursor + 1
7709  elif ShowFCur.get() > 0 and shift_key == 1:
7710  FCursor = FCursor + 5
7711  if RUNstatus.get() == 0:
7713  except:
7714  donothing()
7715  try:
7716  if event.widget == Bodeca:
7717  if ShowBPCur.get() > 0 and shift_key == 0:
7718  BPCursor = BPCursor + 1
7719  elif ShowBPCur.get() > 0 and shift_key == 1:
7720  BPCursor = BPCursor + 5
7721  if RUNstatus.get() == 0:
7723  except:
7724  donothing()
7725 #
7726 def onCanvasSpaceBar(event):
7727  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
7728 
7729  if event.widget == ca:
7730  if RUNstatus.get() == 0:
7731  BStart()
7732  elif RUNstatus.get() > 0:
7733  BStop()
7734  try:
7735  if event.widget == XYca:
7736  if RUNstatus.get() == 0:
7737  BStart()
7738  elif RUNstatus.get() > 0:
7739  BStop()
7740  except:
7741  donothing()
7742  try:
7743  if event.widget == IAca:
7744  if RUNstatus.get() == 0:
7745  BStart()
7746  elif RUNstatus.get() > 0:
7747  BStop()
7748  except:
7749  donothing()
7750  try:
7751  if event.widget == Freqca:
7752  if RUNstatus.get() == 0:
7753  BStartSA()
7754  elif RUNstatus.get() > 0:
7755  BStopSA()
7756  except:
7757  donothing()
7758  try:
7759  if event.widget == Bodeca:
7760  if RUNstatus.get() == 0:
7761  BStartBP()
7762  elif RUNstatus.get() > 0:
7763  BStopBP()
7764  except:
7765  donothing()
7766 #
7768  global X0L # Left top X value
7769  global Y0T # Left top Y value
7770  global GRW # Screenwidth
7771  global GRH # Screenheight
7772  global FontSize
7773  global ca, MarkerLoc, Mulx
7774  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
7775  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
7776  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
7777  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
7778  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
7779  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
7780  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
7781  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
7782  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
7783  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
7784 
7785  try:
7786  HoldOff = float(eval(HoldOffentry.get()))
7787  if HoldOff < 0:
7788  HoldOff = 0
7789  except:
7790  HoldOffentry.delete(0,END)
7791  HoldOffentry.insert(0, HoldOff)
7792  # get time scale
7793  try:
7794  TIMEdiv = float(eval(TMsb.get()))
7795  except:
7796  TIMEdiv = 0.5
7797  TMsb.delete(0,"end")
7798  TMsb.insert(0,TIMEdiv)
7799  # prevent divide by zero error
7800  if TIMEdiv < 0.0002:
7801  TIMEdiv = 0.01
7802  # add markers only if stopped
7803  if (RUNstatus.get() == 0):
7804  MarkerNum = MarkerNum + 1
7805  # get the vertical ranges
7806  try:
7807  CH1pdvRange = float(eval(CHAsb.get()))
7808  except:
7809  CHAsb.delete(0,END)
7810  CHAsb.insert(0, CH1vpdvRange)
7811  try:
7812  CH2pdvRange = float(eval(CHBsb.get()))
7813  except:
7814  CHBsb.delete(0,END)
7815  CHBsb.insert(0, CH2vpdvRange)
7816  try:
7817  CH1IpdvRange = float(eval(CHAIsb.get()))
7818  except:
7819  CHAIsb.delete(0,END)
7820  CHAIsb.insert(0, CH1IpdvRange)
7821  try:
7822  CH2IpdvRange = float(eval(CHBIsb.get()))
7823  except:
7824  CHBIsb.delete(0,END)
7825  CHBIsb.insert(0, CH2IpdvRange)
7826  # get the vertical offsets
7827  try:
7828  CHAOffset = float(eval(CHAVPosEntry.get()))
7829  except:
7830  CHAVPosEntry.delete(0,END)
7831  CHAVPosEntry.insert(0, CHAOffset)
7832  try:
7833  CHAIOffset = float(eval(CHAIPosEntry.get()))
7834  except:
7835  CHAIPosEntry.delete(0,END)
7836  CHAIPosEntry.insert(0, CHAIOffset)
7837  try:
7838  CHBOffset = float(eval(CHBVPosEntry.get()))
7839  except:
7840  CHBVPosEntry.delete(0,END)
7841  CHBVPosEntry.insert(0, CHBOffset)
7842  try:
7843  CHBIOffset = float(eval(CHBIPosEntry.get()))
7844  except:
7845  CHBIPosEntry.delete(0,END)
7846  CHBIPosEntry.insert(0, CHBIOffset)
7847  # prevent divide by zero error
7848  if CH1pdvRange < 0.001:
7849  CH1pdvRange = 0.001
7850  if CH2pdvRange < 0.001:
7851  CH2pdvRange = 0.001
7852  if CH1IpdvRange < 1.0:
7853  CH1IpdvRange = 1.0
7854  if CH2IpdvRange < 1.0:
7855  CH2IpdvRange = 1.0
7856 #
7857  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
7858  try:
7859  CHMApdvRange = float(eval(CHB_Asb.get()))
7860  except:
7861  CHB_Asb.delete(0,END)
7862  CHB_Asb.insert(0, CHMApdvRange)
7863  try:
7864  CHMBpdvRange = float(eval(CHB_Bsb.get()))
7865  except:
7866  CHB_Bsb.delete(0,END)
7867  CHB_Bsb.insert(0, CHMBpdvRange)
7868  try:
7869  CHMCpdvRange = float(eval(CHB_Csb.get()))
7870  except:
7871  CHB_Csb.delete(0,END)
7872  CHB_Csb.insert(0, CHMCpdvRange)
7873  try:
7874  CHMDpdvRange = float(eval(CHB_Dsb.get()))
7875  except:
7876  CHB_Dsb.delete(0,END)
7877  CHB_Dsb.insert(0, CHMDpdvRange)
7878  YconvMA = float(GRH/10.0) / CHMApdvRange
7879  YconvMB = float(GRH/10.0) / CHMBpdvRange
7880  YconvMC = float(GRH/10.0) / CHMCpdvRange
7881  YconvMD = float(GRH/10.0) / CHMDpdvRange
7882  try:
7883  CHBAOffset = float(eval(CHB_APosEntry.get()))
7884  except:
7885  CHB_APosEntry.delete(0,END)
7886  CHB_APosEntry.insert(0, CHBAOffset)
7887  try:
7888  CHBBOffset = float(eval(CHB_BPosEntry.get()))
7889  except:
7890  CHB_BPosEntry.delete(0,END)
7891  CHB_BPosEntry.insert(0, CHBBOffset)
7892  try:
7893  CHBCOffset = float(eval(CHB_CPosEntry.get()))
7894  except:
7895  CHB_CPosEntry.delete(0,END)
7896  CHB_CPosEntry.insert(0, CHBCOffset)
7897  try:
7898  CHBDOffset = float(eval(CHB_DPosEntry.get()))
7899  except:
7900  CHB_DPosEntry.delete(0,END)
7901  CHB_DPosEntry.insert(0, CHBDOffset)
7902  Yoffset1 = CHAOffset
7903  if MarkerScale.get() == 1:
7904  Yconv1 = float(GRH/10.0) / CH1pdvRange
7905  Yoffset1 = CHAOffset
7906  COLORmarker = COLORtrace1
7907  Units = " V"
7908  elif MarkerScale.get() == 2:
7909  Yconv1 = float(GRH/10.0) / CH2pdvRange
7910  Yoffset1 = CHBOffset
7911  COLORmarker = COLORtrace2
7912  Units = " V"
7913  elif MarkerScale.get() == 3:
7914  Yconv1 = float(GRH/10.0) / CH1IpdvRange
7915  Yoffset1 = CHAIOffset
7916  COLORmarker = COLORtrace3
7917  Units = " mA"
7918  elif MarkerScale.get() == 4:
7919  Yconv1 = float(GRH/10.0) / CH2IpdvRange
7920  Yoffset1 = CHBIOffset
7921  COLORmarker = COLORtrace4
7922  Units = " mA"
7923  # Aanalog Mux settings
7924  elif MarkerScale.get() == 5:
7925  Yconv1 = float(GRH/10.0) / CHMApdvRange
7926  Yoffset1 = CHBAOffset
7927  COLORmarker = COLORtrace2
7928  Units = " V"
7929  elif MarkerScale.get() == 6:
7930  Yconv1 = float(GRH/10.0) / CHMBpdvRange
7931  Yoffset1 = CHBBOffset
7932  COLORmarker = COLORtrace6
7933  Units = " V"
7934  elif MarkerScale.get() == 7:
7935  Yconv1 = float(GRH/10.0) / CHMCpdvRange
7936  Yoffset1 = CHBCOffset
7937  COLORmarker = COLORtrace7
7938  Units = " V"
7939  elif MarkerScale.get() == 8:
7940  Yconv1 = float(GRH/10.0) / CHMDpdvRange
7941  Yoffset1 = CHBDOffset
7942  COLORmarker = COLORtrace4
7943  Units = " V"
7944  else:
7945  Yconv1 = float(GRH/10.0) / CH1pdvRange
7946  Yoffset1 = CHAOffset
7947  COLORmarker = COLORtrace1
7948  Units = " V"
7949  #
7950  c1 = GRH / 2.0 + Y0T # fixed correction channel A
7951  xc1 = GRW / 2.0 + X0L
7952  c2 = GRH / 2.0 + Y0T # fixed correction channel B
7953  # draw X at marker point and number
7954  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
7955  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
7956  DISsamples = (10.0 * TIMEdiv) # grid width in time
7957  Tstep = DISsamples / GRW # time in mS per pixel
7958  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
7959  #
7960  Tpoint = Tpoint/Mulx
7961  if Tpoint >= 1000:
7962  axis_value = Tpoint / 1000.0
7963  TString = ' {0:.2f} '.format(axis_value) + " S "
7964  if Tpoint < 1000 and Tpoint >= 1:
7965  axis_value = Tpoint
7966  TString = ' {0:.2f} '.format(axis_value) + " mS "
7967  if Tpoint < 1:
7968  axis_value = Tpoint * 1000.0
7969  TString = ' {0:.2f} '.format(axis_value) + " uS "
7970  # TString = ' {0:.2f} '.format(Tpoint)
7971  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
7972  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
7973  V1String = ' {0:.3f} '.format(-yvolts)
7974  else:
7975  V1String = ' {0:.1f} '.format(-yvolts)
7976  V_label = str(MarkerNum) + " " + TString + V1String
7977  V_label = V_label + Units
7978  if MarkerNum > 1:
7979  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
7980  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
7981  else:
7982  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
7983  DT = (Tpoint-PrevT)
7984  if Tpoint >= 1000:
7985  axis_value = DT / 1000.0
7986  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
7987  if Tpoint < 1000 and Tpoint >= 1:
7988  axis_value = DT
7989  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
7990  if Tpoint < 1:
7991  axis_value = DT * 1000.0
7992  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
7993  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
7994  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
7995  V_label = V_label + " Delta " + DeltaT + DeltaV
7996  V_label = V_label + Units
7997  V_label = V_label + ", Freq " + DFreq + " KHz"
7998  # place in upper left unless specified otherwise
7999  x = X0L + 5
8000  y = Y0T + 3 + (MarkerNum*10)
8001  Justify = 'w'
8002  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
8003  x = X0L + GRW - 5
8004  y = Y0T + 3 + (MarkerNum*10)
8005  Justify = 'e'
8006  if MarkerLoc == 'LL' or MarkerLoc == 'll':
8007  x = X0L + 5
8008  y = Y0T + GRH + 3 - (MarkerNum*10)
8009  Justify = 'w'
8010  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
8011  x = X0L + GRW - 5
8012  y = Y0T + GRH + 3 - (MarkerNum*10)
8013  Justify = 'e'
8014  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
8015  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
8016  PrevV = yvolts
8017  PrevT = Tpoint
8018  else:
8019  if MeasGateStatus.get() == 1:
8020  DISsamples = (10.0 * TIMEdiv) # grid width in time
8021  Tstep = DISsamples / GRW # time in mS per pixel
8022  if MeasGateNum == 0:
8023  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
8024  MeasGateNum = 1
8025  else:
8026  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
8027  MeasGateNum = 0
8028  LeftGate = X0L + MeasGateLeft / Tstep
8029  RightGate = X0L + MeasGateRight / Tstep
8030  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
8031  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
8032 
8033 #
8034 def onCanvasOne(event):
8035  global ShowC1_V
8036 
8037  if ShowC1_V.get() == 0:
8038  ShowC1_V.set(1)
8039  else:
8040  ShowC1_V.set(0)
8041 #
8042 def onCanvasTwo(event):
8043  global ShowC2_V
8044 
8045  if ShowC2_V.get() == 0:
8046  ShowC2_V.set(1)
8047  else:
8048  ShowC2_V.set(0)
8049 #
8050 def onCanvasThree(event):
8051  global ShowC1_I
8052 
8053  if ShowC1_I.get() == 0:
8054  ShowC1_I.set(1)
8055  else:
8056  ShowC1_I.set(0)
8057 #
8058 def onCanvasFour(event):
8059  global ShowC2_I
8060 
8061  if ShowC2_I.get() == 0:
8062  ShowC2_I.set(1)
8063  else:
8064  ShowC2_I.set(0)
8065 #
8066 def onCanvasFive(event):
8067  global MathTrace
8068 
8069  MathTrace.set(1)
8070 #
8071 def onCanvasSix(event):
8072  global MathTrace
8073 
8074  MathTrace.set(2)
8075 #
8076 def onCanvasSeven(event):
8077  global MathTrace
8078 
8079  MathTrace.set(3)
8080 #
8081 def onCanvasEight(event):
8082  global MathTrace
8083 
8084  MathTrace.set(10)
8085 #
8086 def onCanvasNine(event):
8087  global MathTrace
8088 
8089  MathTrace.set(12)
8090 #
8091 def onCanvasZero(event):
8092  global MathTrace
8093 
8094  MathTrace.set(0)
8095 #
8096 def onCanvasTrising(event):
8097  global TgEdge
8098 
8099  TgEdge.set(0)
8100 #
8101 def onCanvasTfalling(event):
8102  global TgEdge
8103 
8104  TgEdge.set(1)
8105 #
8106 def onCanvasSnap(event):
8107 
8108  BSnapShot()
8109 #
8110 def onCanvasAverage(event):
8111  global TRACEmodeTime
8112 
8113  if TRACEmodeTime.get() == 0:
8114  TRACEmodeTime.set(1)
8115  else:
8116  TRACEmodeTime.set(0)
8117 #
8118 def onCanvasShowTcur(event):
8119  global ShowTCur
8120 
8121  if ShowTCur.get() == 0:
8122  ShowTCur.set(1)
8123  else:
8124  ShowTCur.set(0)
8125 #
8126 def onCanvasShowVcur(event):
8127  global ShowVCur
8128 
8129  if ShowVCur.get() == 0:
8130  ShowVCur.set(1)
8131  else:
8132  ShowVCur.set(0)
8133 #
8135  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
8136 
8137  XCursor = event.x
8138  YCursor = event.y
8139  if RUNstatus.get() == 0:
8140  UpdateXYScreen()
8141  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
8142 #
8144  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
8145  if event.widget == XYca:
8146  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
8147  ShiftKeyDwn = event.state & 1
8148  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
8149  XCursor = XCursor + event.delta/100
8150  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
8151  YCursor = YCursor - event.delta/100
8152  if RUNstatus.get() == 0:
8153  UpdateXYScreen()
8154 #
8156  global X0LXY # Left top X value
8157  global Y0TXY # Left top Y value
8158  global GRWXY # Screenwidth
8159  global GRHXY # Screenheight
8160  global FontSize
8161  global XYca
8162  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
8163  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
8164  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
8165  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
8166  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
8167  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
8168  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
8169  # add markers only if stopped
8170  #
8171  if (RUNstatus.get() == 0):
8172  MarkerNum = MarkerNum + 1
8173  try:
8174  CH1pdvRange = float(eval(CHAsbxy.get()))
8175  except:
8176  CHAsbxy.delete(0,END)
8177  CHAsbxy.insert(0, CH1vpdvRange)
8178  try:
8179  CH2pdvRange = float(eval(CHBsbxy.get()))
8180  except:
8181  CHBsb.delete(0,END)
8182  CHBsb.insert(0, CH2vpdvRange)
8183  try:
8184  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8185  except:
8186  CHAIsbxy.delete(0,END)
8187  CHAIsbxy.insert(0, CH1IpdvRange)
8188  try:
8189  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8190  except:
8191  CHBIsbxy.delete(0,END)
8192  CHBIsbxy.insert(0, CH2IpdvRange)
8193  # get the vertical offsets
8194  try:
8195  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8196  except:
8197  CHAVPosEntryxy.delete(0,END)
8198  CHAVPosEntryxy.insert(0, CHAOffset)
8199  try:
8200  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8201  except:
8202  CHAIPosEntryxy.delete(0,END)
8203  CHAIPosEntryxy.insert(0, CHAIOffset)
8204  try:
8205  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8206  except:
8207  CHBVPosEntryxy.delete(0,END)
8208  CHBVPosEntryxy.insert(0, CHBOffset)
8209  try:
8210  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8211  except:
8212  CHBIPosEntryxy.delete(0,END)
8213  CHBIPosEntryxy.insert(0, CHBIOffset)
8214  # prevent divide by zero error
8215  if CH1pdvRange < 0.001:
8216  CH1pdvRange = 0.001
8217  if CH2pdvRange < 0.001:
8218  CH2pdvRange = 0.001
8219  if CH1IpdvRange < 1.0:
8220  CH1IpdvRange = 1.0
8221  if CH2IpdvRange < 1.0:
8222  CH2IpdvRange = 1.0
8223  try:
8224  HoldOff = float(eval(HoldOffentry.get()))
8225  if HoldOff < 0:
8226  HoldOff = 0
8227  except:
8228  HoldOffentry.delete(0,END)
8229  HoldOffentry.insert(0, HoldOff)
8230  #
8231  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
8232  Xconv1 = float(GRWXY/10) / CH1pdvRange
8233  Yconv2 = float(GRHXY/10) / CH2pdvRange
8234  Xconv2 = float(GRWXY/10) / CH2pdvRange
8235  # YIconv1 = float(GRH/10) / CH1IpdvRange
8236  # YIconv2 = float(GRH/10) / CH2IpdvRange
8237  COLORmarker = COLORtext
8238  Yoffset1 = CHAOffset
8239  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
8240  xc1 = GRWXY / 2 + X0LXY
8241  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
8242  # draw X at marker point and number
8243  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
8244  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
8245  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
8246  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
8247  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
8248  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
8249  VyString = ' {0:.3f} '.format(-yvolts)
8250  VxString = ' {0:.3f} '.format(-xvolts)
8251  V_label = str(MarkerNum) + " " + VxString + " V, " + VyString + " V"
8252  if MarkerNum > 1:
8253  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
8254  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
8255  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
8256  x = X0LXY + 5
8257  y = Y0TXY + 3 + (MarkerNum*10)
8258  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
8259  PrevY = yvolts
8260  PrevX = xvolts
8261  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
8262  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
8263  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
8264  VyString = ' {0:.3f} '.format(-yvolts)
8265  VxString = ' {0:.3f} '.format(-xvolts)
8266  V_label = str(MarkerNum) + " " + VxString + " V, " + VyString + " V"
8267  if MarkerNum > 1:
8268  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
8269  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
8270  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
8271  x = X0LXY + 5
8272  y = Y0TXY + 3 + (MarkerNum*10)
8273  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
8274  PrevY = yvolts
8275  PrevX = xvolts
8276 #
8277 def Wrap(InArray, WrFactor):
8278  # Build new array by skipping WrFactor samples and wrapping back around
8279  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
8280  # effectively multiplies the frequency content by WrFactor
8281  OutArray = []
8282  OutArray = numpy.array(OutArray)
8283  InArray = numpy.array(InArray)
8284  EndIndex = len(InArray)
8285  StartIndex = 0
8286  while StartIndex < WrFactor:
8287  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
8288  StartIndex = StartIndex + 1
8289  return OutArray
8290 #
8291 def UnWrap(InArray, WrFactor):
8292  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
8293  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
8294  # effectively divided the frequency content by WrFactor
8295  OutArray = []
8296  InArray = numpy.array(InArray)
8297  EndIndex = int(len(InArray)/WrFactor)
8298  StartIndex = 0
8299  while StartIndex < EndIndex:
8300  LoopIndex = 0
8301  while LoopIndex < WrFactor:
8302  OutArray.append(InArray[StartIndex+LoopIndex])
8303  LoopIndex = LoopIndex + 1
8304  StartIndex = StartIndex + 1
8305  OutArray = numpy.array(OutArray)
8306  return OutArray
8307 #
8308 def Write_WAV(data, repeat, filename):
8309  global SAMPLErate
8310  # write data array to mono .wav file 100KSPS
8311  # copy buffer repeat times in output file
8312  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
8313  wavfile = wave.open(filename, "w")
8314  nchannels = 1
8315  sampwidth = 2
8316  framerate = SAMPLErate
8317  amplitude = 32766
8318  nframes = len(data)
8319  comptype = "NONE"
8320  compname = "not compressed"
8321  wavfile.setparams((nchannels,
8322  sampwidth,
8323  framerate,
8324  nframes,
8325  comptype,
8326  compname))
8327  # Normalize data
8328  ArrN = numpy.array(data)
8329  ArrN /= numpy.max(numpy.abs(data))
8330  frames = []
8331  for s in ArrN:
8332  mul = int(s * amplitude)
8333  # print "s: %f mul: %d" % (s, mul)
8334  frames.append(struct.pack('h', mul))
8335  print( len(frames))
8336  frames = ''.join(frames)
8337  print( len(frames))
8338  for x in xrange(0, repeat):
8339  print( x )
8340  wavfile.writeframes(frames)
8341  wavfile.close()
8342 
8343 # =========== Awg functions ==================
8344 def BAWGAAmpl(temp):
8345  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8346 
8347  try:
8348  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
8349  except:
8350  AWGAAmplEntry.delete(0,"end")
8351  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8352  #
8353  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
8354  if AWGAMode.get() == 0: # Source Voltage measure current mode
8355  if AWGAAmplvalue > 5.00:
8356  AWGAAmplvalue = 5.00
8357  AWGAAmplEntry.delete(0,"end")
8358  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8359  if AWGAAmplvalue < 0.00:
8360  AWGAAmplvalue = 0.00
8361  AWGAAmplEntry.delete(0,"end")
8362  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8363  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
8364  if AWGAMode.get() == 0: # Source Voltage measure current mode
8365  if AWGAAmplvalue > 2.5:
8366  AWGAAmplvalue = 2.5
8367  AWGAAmplEntry.delete(0,"end")
8368  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8369  if AWGAAmplvalue < -2.50:
8370  AWGAAmplvalue = -2.50
8371  AWGAAmplEntry.delete(0,"end")
8372  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8373  if AWGAMode.get() == 1: # Source current measure voltage mode
8374  if AWGAAmplvalue > 200.00:
8375  AWGAAmplvalue = 200.00
8376  AWGAAmplEntry.delete(0,"end")
8377  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8378  if AWGAAmplvalue < -200.00:
8379  AWGAAmplvalue = -200.00
8380  AWGAAmplEntry.delete(0,"end")
8381  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8382 #
8383 def BAWGAOffset(temp):
8384  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8385 
8386  try:
8387  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
8388  except:
8389  AWGAOffsetEntry.delete(0,"end")
8390  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8391  if AWGAMode.get() == 0: # Source Voltage measure current mode
8392  if AWGAOffsetvalue > 5.00:
8393  AWGAOffsetvalue = 5.00
8394  AWGAOffsetEntry.delete(0,"end")
8395  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8396  if AWGAOffsetvalue < 0.00:
8397  AWGAOffsetvalue = 0.00
8398  AWGAOffsetEntry.delete(0,"end")
8399  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8400  if AWGAMode.get() == 1: # Source current measure voltage mode
8401  if AWGAOffsetvalue > 200.00:
8402  AWGAOffsetvalue = 200.00
8403  AWGAOffsetEntry.delete(0,"end")
8404  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8405  if AWGAOffsetvalue < -200.00:
8406  AWGAOffsetvalue = -200.00
8407  AWGAOffsetEntry.delete(0,"end")
8408  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8409 #
8410 def BAWGAFreq(temp):
8411  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X
8412  global BodeScreenStatus, BodeDisp
8413 
8414  try:
8415  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
8416  except:
8417  AWGAFreqEntry.delete(0,"end")
8418  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8419  if AWG_2X.get() == 1:
8420  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
8421  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
8422  AWGAFreqvalue = 90000
8423  AWGAFreqEntry.delete(0,"end")
8424  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8425  else:
8426  if AWGAFreqvalue > 50000: # max freq is 50KHz
8427  AWGAFreqvalue = 50000
8428  AWGAFreqEntry.delete(0,"end")
8429  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8430  else:
8431  if AWGAFreqvalue > 25000: # max freq is 25KHz
8432  AWGAFreqvalue = 25000
8433  AWGAFreqEntry.delete(0,"end")
8434  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8435  if AWGAFreqvalue < 0: # Set negative frequency entry to 0
8436  AWGAFreqvalue = 10
8437  AWGAFreqEntry.delete(0,"end")
8438  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8439  #UpdateAWGA()
8440 
8442  global AWGAPhaseDelay, phasealab, awgaph, awgadel
8443 
8444  if AWGAPhaseDelay.get() == 0:
8445  phasealab.configure(text="Deg")
8446  awgaph.configure(style="WPhase.TRadiobutton")
8447  awgadel.configure(style="GPhase.TRadiobutton")
8448  elif AWGAPhaseDelay.get() == 1:
8449  phasealab.configure(text="mSec")
8450  awgaph.configure(style="GPhase.TRadiobutton")
8451  awgadel.configure(style="WPhase.TRadiobutton")
8452 
8453 def BAWGAPhase(temp):
8454  global AWGAPhaseEntry, AWGAPhasevalue
8455 
8456  try:
8457  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
8458  except:
8459  AWGAPhaseEntry.delete(0,"end")
8460  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8461 
8462  if AWGAPhasevalue > 360: # max phase is 360 degrees
8463  AWGAPhasevalue = 360
8464  AWGAPhaseEntry.delete(0,"end")
8465  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8466  if AWGAPhasevalue < 0: # min phase is 0 degrees
8467  AWGAPhasevalue = 0
8468  AWGAPhaseEntry.delete(0,"end")
8469  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8470 
8471 def BAWGADutyCycle(temp):
8472  global AWGADutyCycleEntry, AWGADutyCyclevalue
8473 
8474  try:
8475  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
8476  except:
8477  AWGADutyCycleEntry.delete(0,"end")
8478  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
8479 
8480  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
8481  AWGADutyCyclevalue = 1
8482  AWGADutyCycleEntry.delete(0,"end")
8483  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
8484  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
8485  AWGADutyCyclevalue = 0
8486  AWGADutyCycleEntry.delete(0,"end")
8487  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
8488  #UpdateAWGA()
8489 
8491  global AWGAShape, AWGAWave, phasealab, duty1lab
8492 
8493  if AWGAShape.get() == 0:
8494  AWGAWave = 'dc'
8495  duty1lab.config(text="%")
8496  BAWGAPhaseDelay()
8497  if AWGAShape.get() == 1:
8498  AWGAWave = 'sine'
8499  duty1lab.config(text="%")
8500  BAWGAPhaseDelay()
8501  if AWGAShape.get() == 2:
8502  AWGAWave = 'triangle'
8503  duty1lab.config(text="%")
8504  BAWGAPhaseDelay()
8505  if AWGAShape.get() == 3:
8506  AWGAWave = 'sawtooth'
8507  duty1lab.config(text="%")
8508  BAWGAPhaseDelay()
8509  if AWGAShape.get() == 4:
8510  AWGAWave = 'square'
8511  duty1lab.config(text="%")
8512  BAWGAPhaseDelay()
8513  if AWGAShape.get() == 5:
8514  AWGAWave = 'stairstep'
8515  duty1lab.config(text="%")
8516  BAWGAPhaseDelay()
8517  if AWGAShape.get() > 5:
8518  AWGAWave = 'arbitrary'
8519  # UpdateAWGA()
8520 
8522  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X
8523 
8524  # Read values from CVS file
8525  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
8526  try:
8527  CSVFile = open(filename)
8528  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
8529  CSVFile.seek(0)
8530  #csv_f = csv.reader(CSVFile, dialect)
8531  csv_f = csv.reader(CSVFile, csv.excel)
8532  except:
8533  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
8534  # print csv_f.dialect
8535  AWGAwaveform = []
8536  ColumnNum = 0
8537  ColumnSel = 0
8538  RowNum = 0
8539  for row in csv_f:
8540  # print 'found row = ', row
8541  if len(row) > 1 and ColumnSel == 0:
8542  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
8543  ColumnNum = int(RequestColumn) - 1
8544  ColumnLen = str(len(row))
8545  ColumnSel = 1
8546  try:
8547  colnum = 0
8548  for col in row:
8549  if colnum == ColumnNum:
8550  AWGAwaveform.append(float(col))
8551  colnum += 1
8552  except:
8553  print( 'skipping non-numeric row', RowNum)
8554  RowNum += 1
8555  AWGAwaveform = numpy.array(AWGAwaveform)
8557  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8558  CSVFile.close()
8559  UpdateAwgCont()
8560 
8561 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
8563  global AWG_2X, AWGA2X, AWGAwaveform
8564 
8565  if AWG_2X.get() == 1:
8566  Tempwaveform = []
8567  AWGA2X = []
8568  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
8569  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
8570  AWGAwaveform = Tempwaveform
8571 #
8573  global AWGABurstFlag, AWGACycles, AWGABurstDelay
8574 
8575  if AWGABurstFlag.get() == 1:
8576  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
8577  if (AWGACyclesString == None): # If Cancel pressed, then None
8578  return
8579  AWGACycles = int(AWGACyclesString)
8580  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
8581  if (AWGADelayString == None): # If Cancel pressed, then None
8582  return
8583  AWGABurstDelay = float(AWGADelayString)
8584  ReMakeAWGwaves()
8585 #
8587  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
8588  global AWG_2X, AWGA2X
8589 
8590 # Read values from WAV file
8591  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
8592  try:
8593  spf = wave.open(filename,'r')
8594  except:
8595  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
8596  AWGAwaveform = []
8597  AWGBwaveform = []
8598  Length = spf.getnframes()
8599  if Length > 90000:
8600  Length = 90000
8601  # If Stereo put first channel in AWGA and second channel in AWGB
8602  if spf.getnchannels() == 2:
8603  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
8604  signal = spf.readframes(Length)
8605  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
8606  n = 0
8607  while n < Length*2:
8608  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
8609  n = n + 1
8610  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
8611  n = n + 1
8612  AWGAwaveform = numpy.array(AWGAwaveform)
8613  AWGBwaveform = numpy.array(AWGBwaveform)
8614  AWGALength.config(text = "L = " + str(len(AWGAwaveform))) # change displayed value
8615  AWGBLength.config(text = "L = " + str(len(AWGBwaveform))) # change displayed value
8616  AWGBShape.set(AWGAShape.get())
8617  else:
8618  #Extract Raw Audio from Wav File
8619  signal = spf.readframes(Length)
8620  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
8621  # offset and scale for 0 5 V range
8622  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
8623  AWGAwaveform = numpy.array(AWGAwaveform)
8625  AWGALength.config(text = "L = " + str(len(AWGAwaveform))) # change displayed value
8626  spf.close()
8627  UpdateAwgCont()
8628 
8630  global AWGAwaveform, AWGALength, awgwindow
8631 
8632  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
8633  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
8634 
8636  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
8637  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
8638  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
8639  global DFiltACoef, DFiltBCoef
8640  global AWG_2X, AWGA2X
8641 
8642  TempString = AWGAMathString
8643  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
8644  if (AWGAMathString == None): # If Cancel pressed, then None
8645  AWGAMathString = TempString
8646  return
8647  AWGAwaveform = eval(AWGAMathString)
8648  AWGAwaveform = numpy.array(AWGAwaveform)
8650  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8651  UpdateAwgCont()
8652 #
8654  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8655  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8656  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab
8657 
8658  BAWGAAmpl(0)
8659  BAWGAOffset(0)
8660  BAWGAFreq(0)
8661  BAWGAPhase(0)
8662  BAWGADutyCycle(0)
8663 
8664  if AWGAFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
8665  AWGAShape.set(1)
8666  BAWGAShape()
8667  UpdateAwgCont()
8668  return
8669 
8670  if AWGAFreqvalue > 0.0:
8671  if AWG_2X.get() == 1:
8672  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8673  else:
8674  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8675  else:
8676  AWGAperiodvalue = 10.0
8677 
8678  if AWGAPhaseDelay.get() == 0:
8679  if AWGAPhasevalue > 0:
8680  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
8681  else:
8682  AWGAdelayvalue = 0.0
8683  elif AWGAPhaseDelay.get() == 1:
8684  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
8685  Cycles = int(32768/AWGAperiodvalue)
8686  if Cycles < 1:
8687  Cycles = 1
8688  RecLength = int(Cycles * AWGAperiodvalue)
8689  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8690  RecLength = RecLength + 1
8691  AWGAwaveform = []
8692  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
8693  if AWGAMode.get() == 1: # convert to mA
8694  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8695  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8696  else:
8697  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8698  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8699  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8700  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8701 #
8703  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8704  BAWGAPhaseDelay()
8705  duty1lab.config(text="%")
8706  phasealab.config(text="Delay")
8707  UpdateAwgCont()
8708 #
8710  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8711  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8712  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab
8713 
8714  BAWGAAmpl(0)
8715  BAWGAOffset(0)
8716  BAWGAFreq(0)
8717 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
8718  duty1lab.config(text = "M Index")
8719  phasealab.config(text = "M Freq")
8720 
8721  if AWGAFreqvalue > 0.0:
8722  if AWG_2X.get() == 1:
8723  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8724  else:
8725  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8726  else:
8727  AWGAperiodvalue = 10.0
8728 
8729  try:
8730  ModFreq = float(eval(AWGAPhaseEntry.get()))
8731  except:
8732  ModFreq = 10
8733  AWGAPhaseEntry.delete(0,"end")
8734  AWGAPhaseEntry.insert(0, ModFreq)
8735 
8736  if ModFreq < 10:
8737  ModFreq = 10
8738  AWGAPhaseEntry.delete(0,"end")
8739  AWGAPhaseEntry.insert(0, ModFreq)
8740 
8741  if AWG_2X.get() == 1:
8742  MODperiodvalue = (BaseSampleRate*2)/ModFreq
8743  else:
8744  MODperiodvalue = BaseSampleRate/ModFreq
8745 
8746  try:
8747  ModIndex = float(eval(AWGADutyCycleEntry.get()))
8748  except:
8749  ModIndex = 1.0
8750  AWGADutyCycleEntry.delete(0,"end")
8751  AWGADutyCycleEntry.insert(0, ModIndex)
8752 
8753  ModCycles = int(32768/MODperiodvalue) # find a whole number of cycles
8754  if ModCycles < 1:
8755  ModCycles = 1
8756  RecLength = int(ModCycles * MODperiodvalue)
8757  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8758  RecLength = RecLength + 1
8759  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
8760  AWGAwaveform = []
8761  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
8762  if AWGAMode.get() == 1: # convert to mA
8763  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8764  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8765  else:
8766  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8767  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8768  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8769  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8770 #
8771  SplitAWGAwaveform() # if needed
8772  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8773  UpdateAwgCont()
8774 #
8776  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8777  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8778  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab
8779 
8780  BAWGAAmpl(0)
8781  BAWGAOffset(0)
8782  BAWGAFreq(0)
8783 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
8784  duty1lab.config(text = "M Index")
8785  phasealab.config(text = "M Freq")
8786 
8787  if AWGAFreqvalue > 0.0:
8788  if AWG_2X.get() == 1:
8789  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8790  else:
8791  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8792  else:
8793  AWGAperiodvalue = 10.0
8794 
8795  try:
8796  ModFreq = float(eval(AWGAPhaseEntry.get()))
8797  except:
8798  ModFreq = 10
8799  AWGAPhaseEntry.delete(0,"end")
8800  AWGAPhaseEntry.insert(0, ModFreq)
8801 
8802  if ModFreq < 10:
8803  ModFreq = 10
8804  AWGAPhaseEntry.delete(0,"end")
8805  AWGAPhaseEntry.insert(0, ModFreq)
8806 
8807  if AWG_2X.get() == 1:
8808  MODperiodvalue = (BaseSampleRate*2)/ModFreq
8809  else:
8810  MODperiodvalue = BaseSampleRate/ModFreq
8811 
8812  try:
8813  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
8814  except:
8815  ModIndex = 50.0
8816  AWGADutyCycleEntry.delete(0,"end")
8817  AWGADutyCycleEntry.insert(0, ModIndex)
8818 
8819  ModCycles = int(32768/MODperiodvalue) # find a whole number of cycles
8820  if ModCycles < 1:
8821  ModCycles = 1
8822  RecLength = int(ModCycles * MODperiodvalue)
8823  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8824  RecLength = RecLength + 1
8825  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
8826  AWGAwaveform = []
8827  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
8828  if AWGAMode.get() == 1: # convert to mA
8829  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8830  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8831  else:
8832  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8833  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8834  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8835  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8836 #
8837  SplitAWGAwaveform() # if needed
8838  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8839  UpdateAwgCont()
8840 #
8842  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
8843  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8844  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8845 
8846  BAWGAAmpl(0)
8847  BAWGAOffset(0)
8848  BAWGAFreq(0)
8849  BAWGAPhase(0)
8850  BAWGADutyCycle(0)
8851 
8852  if AWGAFreqvalue > 0.0:
8853  if AWG_2X.get() == 1:
8854  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
8855  else:
8856  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8857  else:
8858  AWGAperiodvalue = 0.0
8859  if AWG_Amp_Mode.get() == 1:
8860  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
8861  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
8862  else:
8863  MaxV = AWGAOffsetvalue
8864  MinV = AWGAAmplvalue
8865 
8866  PulseWidth = int(AWGADutyCyclevalue*100)
8867  PulseSamples = int(AWGAperiodvalue/PulseWidth)
8868  AWGAwaveform = []
8869  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
8870  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
8871  # print(v)
8872  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
8873  if j >= v:
8874  AWGAwaveform.append(MaxV) # j>=v?1:0
8875  else:
8876  AWGAwaveform.append(MinV) # j>=v?1:0
8878  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8879  duty1lab.config(text="PWidth")
8880  UpdateAwgCont()
8881 #
8883  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
8884  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8885  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8886 
8887  BAWGAAmpl(0)
8888  BAWGAOffset(0)
8889  BAWGAFreq(0)
8890  BAWGADutyCycle(0)
8891 
8892  Max_term = int(AWGADutyCyclevalue*100)
8893  if AWG_2X.get() == 1:
8894  TempRate = (BaseSampleRate*2)
8895  else:
8896  TempRate = BaseSampleRate
8897  AWGAwaveform = []
8898  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, TempRate/AWGAFreqvalue)) # the fundamental
8899  k = 3
8900  while k <= Max_term:
8901  # Add odd harmonics up to max_term
8902  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, TempRate/AWGAFreqvalue)))
8903  AWGAwaveform = AWGAwaveform + Harmonic
8904  k = k + 2 # skip even numbers
8905  if AWG_Amp_Mode.get() == 0:
8906  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
8907  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
8908  else:
8909  amplitude = AWGAAmplvalue
8910  offset = AWGAOffsetvalue
8911  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8913  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8914  duty1lab.config(text="Harmonics")
8915  UpdateAwgCont()
8916 #
8918  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8919  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
8920  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8921 
8922  BAWGAAmpl(0)
8923  BAWGAOffset(0)
8924  BAWGAFreq(0)
8925  BAWGAPhase(0)
8926  BAWGADutyCycle(0)
8927 
8928  if AWGAFreqvalue > 0.0:
8929  if AWG_2X.get() == 1:
8930  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
8931  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
8932  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8933  AWGAperiodvalue = AWGAperiodvalue + 1
8934  else:
8935  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8936  SamplesPermS = int(BaseSampleRate/1000) # 100
8937  else:
8938  AWGAperiodvalue = 0.0
8939  if AWG_Amp_Mode.get() == 1:
8940  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
8941  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
8942  else:
8943  MaxV = AWGAOffsetvalue
8944  MinV = AWGAAmplvalue
8945 
8946  if AWGAPhaseDelay.get() == 0:
8947  if AWGAPhasevalue > 0:
8948  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
8949  else:
8950  AWGAdelayvalue = 0.0
8951  elif AWGAPhaseDelay.get() == 1:
8952  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
8953 
8954  Cycles = int(AWGADutyCyclevalue*100)
8955  NCycles = -1 * Cycles
8956  AWGAwaveform = []
8957  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, SAMPLErate/AWGAFreqvalue))
8958  amplitude = (MaxV-MinV) / 2.0
8959  offset = (MaxV+MinV) / 2.0
8960  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8961  Cycles = int(37500/AWGAperiodvalue)
8962  if Cycles < 1:
8963  Cycles = 1
8964  if Cycles > 1:
8965  Extend = int((Cycles-1.0)*AWGAperiodvalue/2.0)
8966  AWGAwaveform = numpy.pad(AWGAwaveform, (Extend,Extend), 'wrap')
8967  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8969  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8970  #BAWGAPhaseDelay()
8971  duty1lab.config(text="Cycles")
8972  UpdateAwgCont()
8973 #
8975  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
8976  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8977  global AWGABurstFlag, AWGACycles, AWGABurstDelay
8978  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8979 
8980  BAWGAAmpl(0)
8981  BAWGAOffset(0)
8982  BAWGAFreq(0)
8983  BAWGAPhase(0)
8984  BAWGADutyCycle(0)
8985 
8986  if AWGAFreqvalue > 0.0:
8987  if AWG_2X.get() == 1:
8988  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
8989  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
8990  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8991  AWGAperiodvalue = AWGAperiodvalue + 1
8992  else:
8993  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8994  SamplesPermS = int(BaseSampleRate/1000) # 100
8995  else:
8996  AWGAperiodvalue = 0.0
8997  if AWG_Amp_Mode.get() == 1:
8998  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
8999  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9000  else:
9001  MaxV = AWGAOffsetvalue
9002  MinV = AWGAAmplvalue
9003  AWGAwaveform = []
9004  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
9005  if SlopeValue <= 0:
9006  SlopeValue = 1
9007  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9008  if PulseWidth <=0:
9009  PulseWidth = 1
9010  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
9011  if Remainder <= 0:
9012  Remainder = 1
9013  PulseWidth = PulseWidth - SlopeValue
9014  if PulseWidth <=0:
9015  PulseWidth = 1
9016  StepAmp = (MaxV - MinV)/2
9017  StepOff = (MaxV + MinV)/2
9018  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
9019  MidArray = numpy.ones(PulseWidth) * MinV
9020  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
9021  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
9022  if AWGABurstFlag.get() == 1:
9023  TempOneCycle = AWGAwaveform
9024  for i in range(AWGACycles-1):
9025  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9026  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9027  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9029  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9030  duty1lab.config(text="%")
9031  phasealab.config(text = "Rise Time")
9032  UpdateAwgCont()
9033 #
9035  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9036  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9037  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9038  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9039 
9040  BAWGAAmpl(0)
9041  BAWGAOffset(0)
9042  BAWGAFreq(0)
9043  BAWGAPhase(0)
9044  BAWGADutyCycle(0)
9045 
9046  if AWGAFreqvalue > 0.0:
9047  if AWG_2X.get() == 1:
9048  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9049  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9050  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9051  AWGAperiodvalue = AWGAperiodvalue + 1
9052  else:
9053  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9054  SamplesPermS = int(BaseSampleRate/1000) # 100
9055  else:
9056  AWGAperiodvalue = 0.0
9057  if AWG_Amp_Mode.get() == 1:
9058  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9059  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9060  else:
9061  MaxV = AWGAOffsetvalue
9062  MinV = AWGAAmplvalue
9063  AWGAwaveform = []
9064  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9065  if SlopeValue <= 0:
9066  SlopeValue = 1
9067  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9068  if PulseWidth <=0:
9069  PulseWidth = 1
9070  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
9071  if Remainder <= 0:
9072  Remainder = 1
9073  PulseWidth = PulseWidth - SlopeValue
9074  if PulseWidth <=0:
9075  PulseWidth = 1
9076  StepValue = (MaxV - MinV) / SlopeValue
9077  SampleValue = MinV
9078  for i in range(SlopeValue):
9079  AWGAwaveform.append(SampleValue)
9080  SampleValue = SampleValue + StepValue
9081  for i in range(PulseWidth):
9082  AWGAwaveform.append(MaxV)
9083  for i in range(SlopeValue):
9084  AWGAwaveform.append(SampleValue)
9085  SampleValue = SampleValue - StepValue
9086  for i in range(Remainder):
9087  AWGAwaveform.append(MinV)
9088  if AWGABurstFlag.get() == 1:
9089  TempOneCycle = AWGAwaveform
9090  for i in range(AWGACycles-1):
9091  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9092  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9093  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9095  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9096  duty1lab.config(text="%")
9097  phasealab.config(text = "Rise Time")
9098  UpdateAwgCont()
9099 #
9101  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9102  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9103  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9104  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9105 
9106  BAWGAAmpl(0)
9107  BAWGAOffset(0)
9108  BAWGAFreq(0)
9109  BAWGAPhase(0)
9110 
9111  try:
9112  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
9113  except:
9114  AWGADutyCycleEntry.delete(0,"end")
9115  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
9116 
9117  if AWGAFreqvalue > 0.0:
9118  if AWG_2X.get() == 1:
9119  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9120  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9121  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9122  AWGAperiodvalue = AWGAperiodvalue + 1
9123  else:
9124  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9125  SamplesPermS = int(BaseSampleRate/1000) # 100
9126  else:
9127  AWGAperiodvalue = 0.0
9128  if AWG_Amp_Mode.get() == 1:
9129  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9130  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9131  else:
9132  MaxV = AWGAOffsetvalue
9133  MinV = AWGAAmplvalue
9134  AWGAwaveform = []
9135  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9136  if SlopeValue <= 0:
9137  SlopeValue = 1
9138  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
9139  if PulseWidth <=0:
9140  PulseWidth = 1
9141  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
9142  if Remainder <= 0:
9143  Remainder = 1
9144  PulseWidth = PulseWidth - SlopeValue
9145  if PulseWidth <=0:
9146  PulseWidth = 1
9147  StepValue = (MaxV - MinV) / SlopeValue
9148  SampleValue = MinV
9149  for i in range(SlopeValue):
9150  AWGAwaveform.append(SampleValue)
9151  SampleValue = SampleValue + StepValue
9152  for i in range(PulseWidth):
9153  AWGAwaveform.append(MaxV)
9154  for i in range(SlopeValue):
9155  AWGAwaveform.append(SampleValue)
9156  SampleValue = SampleValue - StepValue
9157  for i in range(Remainder):
9158  AWGAwaveform.append(MinV)
9159  if AWGABurstFlag.get() == 1:
9160  TempOneCycle = AWGAwaveform
9161  for i in range(AWGACycles-1):
9162  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9163  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9164  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9166  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9167  duty1lab.config(text="Width mS")
9168  phasealab.config(text = "Rise Time")
9169  UpdateAwgCont()
9170 #
9172  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9173  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9174  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9175  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9176 
9177  BAWGAAmpl(0)
9178  BAWGAOffset(0)
9179  BAWGAFreq(0)
9180  BAWGAPhase(0)
9181  BAWGADutyCycle(0)
9182 
9183  if AWGAFreqvalue > 0.0:
9184  if AWG_2X.get() == 1:
9185  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9186  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9187  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9188  AWGAperiodvalue = AWGAperiodvalue + 1
9189  else:
9190  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9191  SamplesPermS = int(BaseSampleRate/1000) # 100
9192  else:
9193  AWGAperiodvalue = 0.0
9194  if AWG_Amp_Mode.get() == 1:
9195  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9196  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9197  else:
9198  MaxV = AWGAOffsetvalue
9199  MinV = AWGAAmplvalue
9200  AWGAwaveform = []
9201  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9202  if SlopeValue <= 0:
9203  SlopeValue = 1
9204  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9205  if PulseWidth <=0:
9206  PulseWidth = 1
9207  Remainder = int(AWGAperiodvalue - PulseWidth)
9208  if Remainder <= 0:
9209  Remainder = 1
9210  PulseWidth = PulseWidth - SlopeValue
9211  if PulseWidth <=0:
9212  PulseWidth = 1
9213  StepValue = (MaxV - MinV) / SlopeValue
9214  SampleValue = MinV
9215  for i in range(SlopeValue):
9216  AWGAwaveform.append(SampleValue)
9217  SampleValue = SampleValue + StepValue
9218  for i in range(PulseWidth):
9219  AWGAwaveform.append(MaxV)
9220  for i in range(Remainder):
9221  AWGAwaveform.append(MinV)
9222  if AWGABurstFlag.get() == 1:
9223  TempOneCycle = AWGAwaveform
9224  for i in range(AWGACycles-1):
9225  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9226  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9227  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9229  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9230  duty1lab.config(text="%")
9231  phasealab.config(text = "Slope Time")
9232  UpdateAwgCont()
9233 #
9235  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
9236  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9237  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9238  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9239 
9240  BAWGAAmpl(0)
9241  BAWGAOffset(0)
9242  BAWGAFreq(0)
9243  BAWGAPhase(0)
9244  BAWGADutyCycle(0)
9245 
9246  if AWGAFreqvalue > 0.0:
9247  if AWG_2X.get() == 1:
9248  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9249  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9250  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9251  AWGAperiodvalue = AWGAperiodvalue + 1
9252  else:
9253  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
9254  SamplesPermS = int(BaseSampleRate/1000) # 100
9255  else:
9256  AWGAperiodvalue = 0.0
9257  if AWG_Amp_Mode.get() == 1:
9258  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9259  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9260  else:
9261  MaxV = AWGAOffsetvalue
9262  MinV = AWGAAmplvalue
9263  #
9264  if AWGAPhaseDelay.get() == 0:
9265  if AWGAPhasevalue > 0:
9266  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9267  else:
9268  AWGAdelayvalue = 0.0
9269  elif AWGAPhaseDelay.get() == 1:
9270  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
9271  #
9272  AWGAwaveform = []
9273  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9274  if PulseWidth <=0:
9275  PulseWidth = 1
9276  Remainder = int(AWGAperiodvalue - PulseWidth)
9277  if Remainder <= 0:
9278  Remainder = 1
9279  UpStepValue = (MaxV - MinV) / PulseWidth
9280  DownStepValue = (MaxV - MinV) / Remainder
9281  SampleValue = MinV
9282  for i in range(PulseWidth):
9283  AWGAwaveform.append(SampleValue)
9284  SampleValue = SampleValue + UpStepValue
9285  for i in range(Remainder):
9286  AWGAwaveform.append(SampleValue)
9287  SampleValue = SampleValue - DownStepValue
9288  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9289  if AWGABurstFlag.get() == 1:
9290  TempOneCycle = AWGAwaveform
9291  for i in range(AWGACycles-1):
9292  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9293  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9294  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
9296  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9297  BAWGAPhaseDelay()
9298  duty1lab.config(text = "Symmetry")
9299  UpdateAwgCont()
9300 #
9302  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9303  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
9304  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9305  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9306 
9307  BAWGAAmpl(0)
9308  BAWGAOffset(0)
9309  BAWGAFreq(0)
9310  BAWGAPhase(0)
9311  BAWGADutyCycle(0)
9312 
9313  if AWGAFreqvalue > 0.0:
9314  if AWG_2X.get() == 1:
9315  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9316  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9317  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9318  AWGAperiodvalue = AWGAperiodvalue + 1
9319  else:
9320  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9321  SamplesPermS = int(BaseSampleRate/1000) # 100
9322  else:
9323  AWGAperiodvalue = 0.0
9324  if AWG_Amp_Mode.get() == 1:
9325  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9326  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9327  else:
9328  MaxV = AWGAOffsetvalue
9329  MinV = AWGAAmplvalue
9330  AWGAwaveform = []
9331  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
9332  if AWGAPhaseDelay.get() == 0:
9333  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
9334  elif AWGAPhaseDelay.get() == 1:
9335  DelayValue = int(AWGAPhasevalue*SamplesPermS)
9336  for i in range(DelayValue-PulseWidth):
9337  AWGAwaveform.append((MinV+MaxV)/2.0)
9338  for i in range(PulseWidth):
9339  AWGAwaveform.append(MaxV)
9340  for i in range(PulseWidth):
9341  AWGAwaveform.append(MinV)
9342  DelayValue = int(AWGAperiodvalue-DelayValue)
9343  for i in range(DelayValue-PulseWidth):
9344  AWGAwaveform.append((MinV+MaxV)/2.0)
9345  if AWGABurstFlag.get() == 1:
9346  TempOneCycle = AWGAwaveform
9347  for i in range(AWGACycles-1):
9348  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9349  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9350  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
9352  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9353  UpdateAwgCont()
9354 
9356  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
9357  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9358  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9359  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9360 
9361  BAWGAAmpl(0)
9362  BAWGAOffset(0)
9363  BAWGAFreq(0)
9364 
9365  if AWGAFreqvalue > 0.0:
9366  if AWG_2X.get() == 1:
9367  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9368  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9369  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9370  AWGAperiodvalue = AWGAperiodvalue + 1
9371  else:
9372  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9373  SamplesPermS = int(BaseSampleRate/1000) # 100
9374  else:
9375  AWGAperiodvalue = 0.0
9376  if AWG_Amp_Mode.get() == 1:
9377  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9378  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9379  else:
9380  if AWGAAmplvalue > AWGAOffsetvalue:
9381  MinV = AWGAOffsetvalue
9382  MaxV = AWGAAmplvalue
9383  else:
9384  MaxV = AWGAOffsetvalue
9385  MinV = AWGAAmplvalue
9386  AWGAwaveform = []
9387  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
9388  Mid = (MaxV+MinV)/2.0
9389  if AWGABurstFlag.get() == 1:
9390  TempOneCycle = AWGAwaveform
9391  for i in range(AWGACycles-1):
9392  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9393  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9394  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
9396  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9397  UpdateAwgCont()
9398 
9400  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
9401  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9402  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9403  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9404 
9405  BAWGAAmpl(0)
9406  BAWGAOffset(0)
9407  BAWGAFreq(0)
9408 
9409  if AWGAFreqvalue > 0.0:
9410  if AWG_2X.get() == 1:
9411  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9412  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9413  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9414  AWGAperiodvalue = AWGAperiodvalue + 1
9415  else:
9416  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9417  SamplesPermS = int(BaseSampleRate/1000) # 100
9418  else:
9419  AWGAperiodvalue = 0.0
9420  if AWG_Amp_Mode.get() == 1:
9421  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9422  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9423  else:
9424  if AWGAAmplvalue > AWGAOffsetvalue:
9425  MinV = AWGAOffsetvalue
9426  MaxV = AWGAAmplvalue
9427  else:
9428  MaxV = AWGAOffsetvalue
9429  MinV = AWGAAmplvalue
9430  AWGAwaveform = []
9431  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
9432  Mid = (MaxV+MinV)/2.0
9433  if AWGABurstFlag.get() == 1:
9434  TempOneCycle = AWGAwaveform
9435  for i in range(AWGACycles-1):
9436  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9437  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9438  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
9440  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9441  UpdateAwgCont()
9442 
9444  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
9445  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9446 
9447  if AWGAMode.get() == 0: # Source Voltage measure current mode
9448  label_txt = "SVMI"
9449  elif AWGAMode.get() == 1: # Source current measure voltage mode
9450  label_txt = "SIMV"
9451  elif AWGAMode.get() == 2: # High impedance mode
9452  label_txt = "Hi-Z"
9453  if AWGAIOMode.get() > 0: # Split Input / Output mode
9454  if HWRevOne == "D":
9455  if AWGAMode.get() == 0:
9456  AWGAMode.set(1)
9457  CHA.set_mode('i') # channel must be in source current mode for rev D boards
9458  label_txt = "SIMV"
9459  label_txt = label_txt + " Split I/O"
9460  label_txt = label_txt + " Mode"
9461  AWGAModeLabel.config(text = label_txt ) # change displayed value
9462  ReMakeAWGwaves()
9463  #UpdateAwgCont()
9464 
9466  global AWGAAmplvalue, AWGAOffsetvalue
9467  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
9468  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
9469  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
9470  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9471  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
9472 
9473  BAWGAAmpl(0)
9474  BAWGAOffset(0)
9475  BAWGAFreq(0)
9476  BAWGAPhase(0)
9477  BAWGADutyCycle(0)
9478  BAWGAShape()
9479 
9480  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
9481  amp1lab.config(text = "Min Ch A" ) # change displayed value
9482  off1lab.config(text = "Max Ch A" ) # change displayed value
9483  else:
9484  amp1lab.config(text = "Amp Ch A" )
9485  off1lab.config(text = "Off Ch A" )
9486 
9487  if AWGAFreqvalue > 0.0:
9488  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
9489  else:
9490  AWGAperiodvalue = 0.0
9491 
9492  if AWGAPhaseDelay.get() == 0:
9493  if AWGAWave == 'square':
9494  AWGAPhasevalue = AWGAPhasevalue + 270.0
9495  if AWGAPhasevalue > 359:
9496  AWGAPhasevalue = AWGAPhasevalue - 360
9497  if AWGAPhasevalue > 0:
9498  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9499  else:
9500  AWGAdelayvalue = 0.0
9501  elif AWGAPhaseDelay.get() == 1:
9502  AWGAdelayvalue = AWGAPhasevalue * 100
9503 
9504  if AWGATerm.get() == 0: # Open termination
9505  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
9506  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
9507  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
9508  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
9509  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
9510  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
9511  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
9512  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
9513 
9514  if AWGAWave == 'dc':
9515  if AWG_2X.get() == 2:
9516  AWGAWave == 'arbitrary'
9517  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
9518  else:
9519  if AWGAMode.get() == 0: # Source Voltage measure current mode
9520  if AWGAIOMode.get() == 0:
9521  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
9522  else:
9523  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
9524  CHA.constant(AWGAOffsetvalue)
9525  #
9526  if AWGAMode.get() == 1: # Source current measure voltage mode
9527  if AWGAIOMode.get() == 0:
9528  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
9529  else:
9530  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
9531  CHA.constant(AWGAOffsetvalue/1000)
9532  #
9533  if AWGAMode.get() == 2: # High impedance mode
9534  if AWGAIOMode.get() == 0:
9535  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
9536  else:
9537  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
9538  #
9539  if AWGAIOMode.get() > 0: # Split Input / Output mode
9540  if HWRevOne == "D":
9541  AWGAMode.set(1)
9542  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
9543 #
9544  else:
9545  if AWGAMode.get() == 0: # Source Voltage measure current mode
9546  if AWGAIOMode.get() == 0:
9547  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
9548  else:
9549  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
9550  if AWGAMode.get() == 1: # Source current measure voltage mode
9551  if AWGAIOMode.get() == 0:
9552  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
9553  else:
9554  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
9555  AWGAOffsetvalue = AWGAOffsetvalue/1000
9556  AWGAAmplvalue = AWGAAmplvalue/1000
9557  if AWGAMode.get() == 2: # High impedance mode
9558  if AWGAIOMode.get() == 0:
9559  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
9560  else:
9561  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
9562  else:
9563  if AWG_Amp_Mode.get() == 1:
9564  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9565  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9566  else:
9567  MaxV = AWGAOffsetvalue
9568  MinV = AWGAAmplvalue
9569  try:
9570  if AWGAWave == 'sine':
9571  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9572  elif AWGAWave == 'triangle':
9573  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9574  elif AWGAWave == 'sawtooth':
9575  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9576  elif AWGAWave == 'square':
9577  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
9578  elif AWGAWave == 'stairstep':
9579  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9580  elif AWGAWave == 'arbitrary':
9581  if AWGSync.get() == 0:
9582  AWGARepeatFlag.set(1)
9583  if AWG_2X.get() == 2:
9584  AWGAWave == 'arbitrary'
9585  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
9586  else:
9587  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
9588  except:
9589  donothing()
9590  if AWGAIOMode.get() > 0: # Split Input / Output mode
9591  if HWRevOne == "D":
9592  AWGAMode.set(1)
9593  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
9594 # AWG B functions
9596  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
9597  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
9598  global BisCompA
9599 
9600  # if BisCompA.get() == 1:
9601  # sawp Min and Max values
9602  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
9603  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
9604  AWGBAmplEntry.delete(0,"end")
9605  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
9606  AWGBOffsetEntry.delete(0,"end")
9607  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
9608  # copy everything else
9609  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
9610  AWGBFreqEntry.delete(0,"end")
9611  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9612  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
9613  AWGBPhaseEntry.delete(0,"end")
9614  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9615  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
9616  AWGBDutyCycleEntry.delete(0,"end")
9617  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9618  AWGBShape.set(AWGAShape.get())
9619  #
9620 # ReMakeAWGwaves()
9621 # UpdateAwgCont()
9622 #
9624  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
9625 
9626  if AWGBBurstFlag.get() == 1:
9627  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
9628  if (AWGBCyclesString == None): # If Cancel pressed, then None
9629  return
9630  AWGBCycles = int(AWGBCyclesString)
9631  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
9632  if (AWGBDelayString == None): # If Cancel pressed, then None
9633  return
9634  AWGBBurstDelay = float(AWGBDelayString)
9635  ReMakeAWGwaves()
9636 #
9637 def BAWGBAmpl(temp):
9638  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9639 
9640  try:
9641  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
9642  if AWGBMode.get() == 0: # Source Voltage measure current mode
9643  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
9644  if AWGBAmplvalue > 5.00:
9645  AWGBAmplvalue = 5.00
9646  AWGBAmplEntry.delete(0,"end")
9647  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9648  if AWGBAmplvalue < 0.00:
9649  AWGBAmplvalue = 0.00
9650  AWGBAmplEntry.delete(0,"end")
9651  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9652  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
9653  if AWGBAmplvalue > 2.5:
9654  AWGBAmplvalue = 2.5
9655  AWGBAmplEntry.delete(0,"end")
9656  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9657  if AWGBAmplvalue < -2.50:
9658  AWGBAmplvalue = -2.50
9659  AWGBAmplEntry.delete(0,"end")
9660  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9661  elif AWGBMode.get() == 1: # Source current measure voltage mode
9662  if AWGBAmplvalue > 200.00:
9663  AWGBAmplvalue = 200.00
9664  AWGBAmplEntry.delete(0,"end")
9665  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9666  if AWGBAmplvalue < -200.00:
9667  AWGBAmplvalue = -200.00
9668  AWGBAmplEntry.delete(0,"end")
9669  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9670  except:
9671  AWGBAmplEntry.delete(0,"end")
9672  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9673 #
9674 def BAWGBOffset(temp):
9675  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9676 
9677  try:
9678  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
9679  if AWGBMode.get() == 0: # Source Voltage measure current mode
9680  if AWGBOffsetvalue > 5.00:
9681  AWGBOffsetvalue = 5.00
9682  AWGBOffsetEntry.delete(0,"end")
9683  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9684  if AWGBOffsetvalue < 0.00:
9685  AWGBOffsetvalue = 0.00
9686  AWGBOffsetEntry.delete(0,"end")
9687  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9688  elif AWGBMode.get() == 1: # Source current measure voltage mode
9689  if AWGBOffsetvalue > 200.00:
9690  AWGBOffsetvalue = 200.00
9691  AWGBOffsetEntry.delete(0,"end")
9692  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9693  if AWGBOffsetvalue < -200.00:
9694  AWGBOffsetvalue = -200.00
9695  AWGBOffsetEntry.delete(0,"end")
9696  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9697  except:
9698  AWGBOffsetEntry.delete(0,"end")
9699  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9700 #
9701 def BAWGBFreq(temp):
9702  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
9703  global BodeScreenStatus, BodeDisp
9704 
9705  try:
9706  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
9707  except:
9708  AWGBFreqEntry.delete(0,"end")
9709  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9710  if AWG_2X.get() == 2:
9711  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
9712  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
9713  AWGBFreqvalue = 90000
9714  AWGBFreqEntry.delete(0,"end")
9715  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9716  else:
9717  if AWGBFreqvalue > 50000: # max freq is 50KHz
9718  AWGBFreqvalue = 50000
9719  AWGBFreqEntry.delete(0,"end")
9720  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9721  else:
9722  if AWGBFreqvalue > 25000: # max freq is 25KHz
9723  AWGBFreqvalue = 25000
9724  AWGBFreqEntry.delete(0,"end")
9725  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9726  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
9727  AWGBFreqvalue = 10
9728  AWGBFreqEntry.delete(0,"end")
9729  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9730  # UpdateAWGB()
9731 
9733  global AWGbPhaseDelay, phaseblab, awgbph, awgbdel
9734 
9735  if AWGBPhaseDelay.get() == 0:
9736  phaseblab.configure(text="Deg")
9737  awgbph.configure(style="WPhase.TRadiobutton")
9738  awgbdel.configure(style="GPhase.TRadiobutton")
9739  elif AWGBPhaseDelay.get() == 1:
9740  phaseblab.configure(text="mSec")
9741  awgbph.configure(style="GPhase.TRadiobutton")
9742  awgbdel.configure(style="WPhase.TRadiobutton")
9743 
9744 def BAWGBPhase(temp):
9745  global AWGBPhaseEntry, AWGBPhasevalue
9746 
9747  try:
9748  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
9749  except:
9750  AWGBPhaseEntry.delete(0,"end")
9751  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9752 
9753  if AWGBPhasevalue > 360: # max phase is 360 degrees
9754  AWGBPhasevalue = 360
9755  AWGBPhaseEntry.delete(0,"end")
9756  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9757  if AWGBPhasevalue < 0: # min phase is 0 degrees
9758  AWGBPhasevalue = 0
9759  AWGBPhaseEntry.delete(0,"end")
9760  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9761 
9762 def BAWGBDutyCycle(temp):
9763  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
9764 
9765  try:
9766  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
9767  except:
9768  AWGBDutyCycleEntry.delete(0,"end")
9769  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9770 
9771  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
9772  AWGBDutyCyclevalue = 1
9773  AWGBDutyCycleEntry.delete(0,"end")
9774  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
9775  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
9776  AWGBDutyCyclevalue = 0
9777  AWGBDutyCycleEntry.delete(0,"end")
9778  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9779  # UpdateAWGB()
9780 
9782  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
9783 
9784  if AWGBShape.get() == 0:
9785  AWGBWave = 'dc'
9786  duty2lab.config(text="%")
9787  BAWGBPhaseDelay()
9788  if AWGBShape.get() == 1:
9789  AWGBWave = 'sine'
9790  duty2lab.config(text="%")
9791  BAWGBPhaseDelay()
9792  if AWGBShape.get() == 2:
9793  AWGBWave = 'triangle'
9794  duty2lab.config(text="%")
9795  BAWGBPhaseDelay()
9796  if AWGBShape.get() == 3:
9797  AWGBWave = 'sawtooth'
9798  duty2lab.config(text="%")
9799  BAWGBPhaseDelay()
9800  if AWGBShape.get() == 4:
9801  AWGBWave = 'square'
9802  duty2lab.config(text="%")
9803  BAWGBPhaseDelay()
9804  if AWGBShape.get() == 5:
9805  AWGBWave = 'stairstep'
9806  duty2lab.config(text="%")
9807  BAWGBPhaseDelay()
9808  if AWGBShape.get() > 5:
9809  AWGBWave = 'arbitrary'
9810  if AWG_2X.get() == 1:
9811  CHB.mode = CHA.mode
9812  AWGBWave = 'arbitrary'
9813  # UpdateAWGB()
9814 
9816  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X
9817 
9818  # Read values from CVS file
9819  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
9820  try:
9821  CSVFile = open(filename)
9822  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
9823  CSVFile.seek(0)
9824  #csv_f = csv.reader(CSVFile, dialect)
9825  csv_f = csv.reader(CSVFile, csv.excel)
9826  except:
9827  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
9828  AWGBwaveform = []
9829  ColumnNum = 0
9830  ColumnSel = 0
9831  RowNum = 0
9832  for row in csv_f:
9833  if len(row) > 1 and ColumnSel == 0:
9834  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
9835  ColumnNum = int(RequestColumn) - 1
9836  ColumnLen = str(len(row))
9837  ColumnSel = 1
9838  try:
9839  colnum = 0
9840  for col in row:
9841  if colnum == ColumnNum:
9842  AWGBwaveform.append(float(col))
9843  colnum += 1
9844  except:
9845  print( 'skipping non-numeric row', RowNum)
9846  RowNum += 1
9847  AWGBwaveform = numpy.array(AWGBwaveform)
9849  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9850  CSVFile.close()
9851  UpdateAwgCont()
9852 
9853 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
9855  global AWG_2X, AWGB2X, AWGBwaveform
9856 
9857  if AWG_2X.get() == 2:
9858  Tempwaveform = []
9859  AWGB2X = []
9860  AWGB2X = AWGBwaveform[::2] # even numbered samples
9861  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
9862  AWGBwaveform = Tempwaveform
9863 #
9865  global AWGBwaveform, AWGBLength, awgwindow
9866  global AWG_2X, AWGA2X
9867 
9868 # Read values from WAV file
9869  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
9870  try:
9871  spf = wave.open(filename,'r')
9872  except:
9873  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
9874  AWGBwaveform = []
9875  #If Stereo
9876  if spf.getnchannels() == 2:
9877  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
9878  return()
9879  #Extract Raw Audio from Wav File
9880  Length = spf.getnframes()
9881  if Length > 90000: # limit to first 90K samples
9882  Length = 90000
9883  signal = spf.readframes(Length)
9884  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
9885  # offset and scale for 0 5 V range
9886  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
9887  AWGBwaveform = numpy.array(AWGBwaveform)
9889  AWGBLength.config(text = "L = " + str(len(AWGBwaveform))) # change displayed value
9890  spf.close()
9891  UpdateAwgCont()
9892 
9894  global AWGBwaveform, AWGBLength, awgwindow
9895 
9896  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
9897  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
9898 
9900  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
9901  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
9902  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
9903  global DFiltACoef, DFiltBCoef
9904  global AWG_2X, AWGA2X
9905 
9906  TempString = AWGBMathString
9907  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
9908  if (AWGBMathString == None): # If Cancel pressed, then None
9909  AWGBMathString = TempString
9910  return
9911  AWGBwaveform = eval(AWGBMathString)
9912  AWGBwaveform = numpy.array(AWGBwaveform)
9914  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9915  UpdateAwgCont()
9916 #
9918  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
9919  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9920  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9921 
9922  Max_termStr = askstring("AWG B Fourier", "\nEnter Max Harmonic:\n", parent=awgwindow)
9923  if (Max_termStr == None): # If Cancel pressed, then None
9924  return
9925  Max_term = int(Max_termStr)
9926 
9927  BAWGBAmpl(0)
9928  BAWGBOffset(0)
9929  BAWGBFreq(0)
9930  if AWG_2X.get() == 1:
9931  TempRate = (BaseSampleRate*2)
9932  else:
9933  TempRate = BaseSampleRate
9934  AWGBwaveform = []
9935  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, TempRate/AWGBFreqvalue)) # the fundamental
9936  k = 3
9937  while k <= Max_term:
9938  # Add odd harmonics up to max_term
9939  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, TempRate/AWGBFreqvalue)))
9940  AWGBwaveform = AWGBwaveform + Harmonic
9941  k = k + 2 # skip even numbers
9942  if AWG_Amp_Mode.get() == 0:
9943  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
9944  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
9945  else:
9946  amplitude = AWGBAmplvalue
9947  offset = AWGBOffsetvalue
9948  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
9950  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9951  duty2lab.config(text="Harmonics")
9952  UpdateAwgCont()
9953 #
9955  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
9956  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
9957  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
9958 
9959  BAWGBAmpl(0)
9960  BAWGBOffset(0)
9961  BAWGBFreq(0)
9962  BAWGBPhase(0)
9963  BAWGBDutyCycle(0)
9964 
9965  if AWGBFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
9966  AWGBShape.set(1)
9967  BAWGBShape()
9968  UpdateAwgCont()
9969  return
9970 
9971  if AWGBFreqvalue > 0.0:
9972  if AWG_2X.get() == 2:
9973  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
9974  else:
9975  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
9976  else:
9977  AWGBperiodvalue = 10.0
9978 
9979  if AWGBPhaseDelay.get() == 0:
9980  if AWGBPhasevalue > 0:
9981  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
9982  else:
9983  AWGBdelayvalue = 0.0
9984  elif AWGBPhaseDelay.get() == 1:
9985  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
9986  Cycles = int(32768/AWGBperiodvalue)
9987  if Cycles < 1:
9988  Cycles = 1
9989  RecLength = int(Cycles * AWGBperiodvalue)
9990  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9991  RecLength = RecLength + 1
9992  AWGBwaveform = []
9993  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
9994  if AWGBMode.get() == 1: # convert to mA
9995  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
9996  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
9997  else:
9998  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
9999  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
10000  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10001  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10002  #
10003  if AWG_2X.get() == 2:
10004  Tempwaveform = []
10005  AWGB2X = []
10006  AWGB2X = AWGBwaveform[::2] # even numbered samples
10007  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
10008  AWGBwaveform = Tempwaveform
10009  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10010  BAWGBPhaseDelay()
10011  duty2lab.config(text="%")
10012  UpdateAwgCont()
10013 #
10015  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
10016  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10017  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10018 
10019  BAWGBAmpl(0)
10020  BAWGBOffset(0)
10021  BAWGBFreq(0)
10022  BAWGBPhase(0)
10023  BAWGBDutyCycle(0)
10024 
10025  if AWGBFreqvalue > 0.0:
10026  if AWG_2X.get() == 2:
10027  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10028  else:
10029  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10030  else:
10031  AWGBperiodvalue = 0.0
10032  if AWG_Amp_Mode.get() == 1:
10033  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10034  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10035  else:
10036  MaxV = AWGBOffsetvalue
10037  MinV = AWGBAmplvalue
10038 
10039  PulseWidth = int(AWGBDutyCyclevalue*100)
10040  PulseSamples = int(AWGBperiodvalue/PulseWidth)
10041  AWGBwaveform = []
10042  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
10043  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
10044  # print(v)
10045  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
10046  if j >= v:
10047  AWGBwaveform.append(MaxV) # j>=v?1:0
10048  else:
10049  AWGBwaveform.append(MinV) # j>=v?1:0
10051  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10052  duty2lab.config(text="PWidth")
10053  UpdateAwgCont()
10054 #
10056  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
10057  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
10058  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10059 
10060  BAWGBAmpl(0)
10061  BAWGBOffset(0)
10062  BAWGBFreq(0)
10063  BAWGBPhase(0)
10064  BAWGBDutyCycle(0)
10065 
10066  if AWGBFreqvalue > 0.0:
10067  if AWG_2X.get() == 1:
10068  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
10069  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10070  AWGBperiodvalue = AWGBperiodvalue + 1
10071  else:
10072  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10073  else:
10074  AWGBperiodvalue = 0.0
10075  if AWG_Amp_Mode.get() == 1:
10076  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10077  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10078  else:
10079  MaxV = AWGBOffsetvalue
10080  MinV = AWGBAmplvalue
10081 
10082  if AWGBPhaseDelay.get() == 0:
10083  if AWGBPhasevalue > 0:
10084  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10085  else:
10086  AWGBdelayvalue = 0.0
10087  elif AWGBPhaseDelay.get() == 1:
10088  AWGBdelayvalue = AWGBPhasevalue * SampleRate / 1000
10089 
10090  Cycles = int(AWGBDutyCyclevalue*100)
10091  NCycles = -1 * Cycles
10092  AWGBwaveform = []
10093  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, SAMPLErate/AWGBFreqvalue))
10094  amplitude = (MaxV-MinV) / 2.0
10095  offset = (MaxV+MinV) / 2.0
10096  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10097  Cycles = int(37500/AWGBperiodvalue)
10098  if Cycles < 1:
10099  Cycles = 1
10100  if Cycles > 1:
10101  Extend = int((Cycles-1.0)*AWGBperiodvalue/2.0)
10102  AWGBwaveform = numpy.pad(AWGBwaveform, (Extend,Extend), 'wrap')
10103  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10105  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10106  #BAWGAPhaseDelay()
10107  duty2lab.config(text="Cycles")
10108  UpdateAwgCont()
10109 #
10111  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10112  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10113  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10114  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10115  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10116 
10117  BAWGBAmpl(0)
10118  BAWGBOffset(0)
10119  BAWGBFreq(0)
10120  BAWGBPhase(0)
10121  BAWGBDutyCycle(0)
10122 
10123  if AWGBFreqvalue > 0.0:
10124  if AWG_2X.get() == 2:
10125  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10126  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10127  else:
10128  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10129  SamplesPermS = int(BaseSampleRate/1000) # 100
10130  else:
10131  AWGBperiodvalue = 0.0
10132  if AWG_Amp_Mode.get() == 1:
10133  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10134  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10135  else:
10136  MaxV = AWGBOffsetvalue
10137  MinV = AWGBAmplvalue
10138  AWGBwaveform = []
10139  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
10140  if SlopeValue <= 0:
10141  SlopeValue = 1
10142  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10143  if PulseWidth <=0:
10144  PulseWidth = 1
10145  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
10146  if Remainder <= 0:
10147  Remainder = 1
10148  PulseWidth = PulseWidth - SlopeValue
10149  if PulseWidth <=0:
10150  PulseWidth = 1
10151  StepAmp = (MaxV - MinV)/2
10152  StepOff = (MaxV + MinV)/2
10153  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
10154  MidArray = numpy.ones(PulseWidth) * MinV
10155  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
10156  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
10157  if AWGBBurstFlag.get() == 1:
10158  TempOneCycle = AWGBwaveform
10159  for i in range(AWGBCycles-1):
10160  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10161  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10162  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10164  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10165  duty2lab.config(text="%")
10166  phaseblab.config(text = "Rise Time")
10167  UpdateAwgCont()
10168 #
10170  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10171  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10172  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10173  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10174  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10175 
10176  BAWGBAmpl(0)
10177  BAWGBOffset(0)
10178  BAWGBFreq(0)
10179  BAWGBPhase(0)
10180  BAWGBDutyCycle(0)
10181 
10182  if AWGBFreqvalue > 0.0:
10183  if AWG_2X.get() == 2:
10184  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10185  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10186  else:
10187  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10188  SamplesPermS = int(BaseSampleRate/1000) # 100
10189  else:
10190  AWGBperiodvalue = 0.0
10191  if AWG_Amp_Mode.get() == 1:
10192  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10193  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10194  else:
10195  MaxV = AWGBOffsetvalue
10196  MinV = AWGBAmplvalue
10197  AWGBwaveform = []
10198  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
10199  if SlopeValue <= 0:
10200  SlopeValue = 1
10201  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10202  if PulseWidth <=0:
10203  PulseWidth = 1
10204  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
10205  if Remainder <= 0:
10206  Remainder = 1
10207  PulseWidth = PulseWidth - SlopeValue
10208  if PulseWidth <=0:
10209  PulseWidth = 1
10210  StepValue = (MaxV - MinV) / SlopeValue
10211  SampleValue = MinV
10212  for i in range(SlopeValue):
10213  AWGBwaveform.append(SampleValue)
10214  SampleValue = SampleValue + StepValue
10215  for i in range(PulseWidth):
10216  AWGBwaveform.append(MaxV)
10217  for i in range(SlopeValue):
10218  AWGBwaveform.append(SampleValue)
10219  SampleValue = SampleValue - StepValue
10220  for i in range(Remainder):
10221  AWGBwaveform.append(MinV)
10222  if AWGBBurstFlag.get() == 1:
10223  TempOneCycle = AWGBwaveform
10224  for i in range(AWGBCycles-1):
10225  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10226  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10227  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10229  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10230  duty2lab.config(text="%")
10231  phaseblab.config(text = "Rise Time")
10232  UpdateAwgCont()
10233 #
10235  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10236  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10237  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10238  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10239  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10240 
10241  BAWGBAmpl(0)
10242  BAWGBOffset(0)
10243  BAWGBFreq(0)
10244  BAWGBPhase(0)
10245 
10246  try:
10247  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
10248  except:
10249  AWGBDutyCycleEntry.delete(0,"end")
10250  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
10251 
10252  if AWGBFreqvalue > 0.0:
10253  if AWG_2X.get() == 2:
10254  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10255  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10256  else:
10257  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10258  SamplesPermS = int(BaseSampleRate/1000) # 100
10259  else:
10260  AWGBperiodvalue = 0.0
10261  if AWG_Amp_Mode.get() == 1:
10262  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10263  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10264  else:
10265  MaxV = AWGBOffsetvalue
10266  MinV = AWGBAmplvalue
10267  AWGBwaveform = []
10268  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
10269  if SlopeValue <= 0:
10270  SlopeValue = 1
10271  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
10272  if PulseWidth <=0:
10273  PulseWidth = 1
10274  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
10275  if Remainder <= 0:
10276  Remainder = 1
10277  PulseWidth = PulseWidth - SlopeValue
10278  if PulseWidth <=0:
10279  PulseWidth = 1
10280  StepValue = (MaxV - MinV) / SlopeValue
10281  SampleValue = MinV
10282  for i in range(SlopeValue):
10283  AWGBwaveform.append(SampleValue)
10284  SampleValue = SampleValue + StepValue
10285  for i in range(PulseWidth):
10286  AWGBwaveform.append(MaxV)
10287  for i in range(SlopeValue):
10288  AWGBwaveform.append(SampleValue)
10289  SampleValue = SampleValue - StepValue
10290  for i in range(Remainder):
10291  AWGBwaveform.append(MinV)
10292  if AWGBBurstFlag.get() == 1:
10293  TempOneCycle = AWGBwaveform
10294  for i in range(AWGBCycles-1):
10295  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10296  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10297  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10299  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10300  duty2lab.config(text="Width mS")
10301  phaseblab.config(text = "Rise Time")
10302  UpdateAwgCont()
10303 #
10305  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10306  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10307  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10308  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10309  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10310 
10311  BAWGBAmpl(0)
10312  BAWGBOffset(0)
10313  BAWGBFreq(0)
10314  BAWGBPhase(0)
10315  BAWGBDutyCycle(0)
10316 
10317  if AWGBFreqvalue > 0.0:
10318  if AWG_2X.get() == 2:
10319  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10320  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10321  else:
10322  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10323  SamplesPermS = int(BaseSampleRate/1000) # 100
10324  else:
10325  AWGBperiodvalue = 0.0
10326  if AWG_Amp_Mode.get() == 1:
10327  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10328  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10329  else:
10330  MaxV = AWGBOffsetvalue
10331  MinV = AWGBAmplvalue
10332  AWGBwaveform = []
10333  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
10334  if SlopeValue <= 0:
10335  SlopeValue = 1
10336  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10337  if PulseWidth <=0:
10338  PulseWidth = 1
10339  Remainder = int(AWGBperiodvalue - PulseWidth)
10340  if Remainder <= 0:
10341  Remainder = 1
10342  PulseWidth = PulseWidth - SlopeValue
10343  if PulseWidth <=0:
10344  PulseWidth = 1
10345  StepValue = (MaxV - MinV) / SlopeValue
10346  SampleValue = MinV
10347  for i in range(SlopeValue):
10348  AWGBwaveform.append(SampleValue)
10349  SampleValue = SampleValue + StepValue
10350  for i in range(PulseWidth):
10351  AWGBwaveform.append(MaxV)
10352  for i in range(Remainder):
10353  AWGBwaveform.append(MinV)
10354  if AWGBBurstFlag.get() == 1:
10355  TempOneCycle = AWGBwaveform
10356  for i in range(AWGBCycles-1):
10357  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10358  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10359  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10361  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10362  duty2lab.config(text="%")
10363  phaseblab.config(text = "Slope Time")
10364  UpdateAwgCont()
10365 #
10367  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10368  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10369  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10370  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10371  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10372 
10373  BAWGBAmpl(0)
10374  BAWGBOffset(0)
10375  BAWGBFreq(0)
10376  BAWGBPhase(0)
10377  BAWGBDutyCycle(0)
10378 
10379  if AWGBFreqvalue > 0.0:
10380  if AWG_2X.get() == 2:
10381  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10382  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10383  else:
10384  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10385  SamplesPermS = int(BaseSampleRate/1000) # 100
10386  else:
10387  AWGBperiodvalue = 0.0
10388  if AWG_Amp_Mode.get() == 1:
10389  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10390  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10391  else:
10392  MaxV = AWGBOffsetvalue
10393  MinV = AWGBAmplvalue
10394  #
10395  if AWGBPhaseDelay.get() == 0:
10396  if AWGBPhasevalue > 0:
10397  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10398  else:
10399  AWGBdelayvalue = 0.0
10400  elif AWGBPhaseDelay.get() == 1:
10401  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
10402  #
10403  AWGBwaveform = []
10404  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10405  if PulseWidth <=0:
10406  PulseWidth = 1
10407  Remainder = int(AWGBperiodvalue - PulseWidth)
10408  if Remainder <= 0:
10409  Remainder = 1
10410  UpStepValue = (MaxV - MinV) / PulseWidth
10411  DownStepValue = (MaxV - MinV) / Remainder
10412  SampleValue = MinV
10413  for i in range(PulseWidth):
10414  AWGBwaveform.append(SampleValue)
10415  SampleValue = SampleValue + UpStepValue
10416  for i in range(Remainder):
10417  AWGBwaveform.append(SampleValue)
10418  SampleValue = SampleValue - DownStepValue
10419  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10420  if AWGBBurstFlag.get() == 1:
10421  TempOneCycle = AWGBwaveform
10422  for i in range(AWGBCycles-1):
10423  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10424  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10425  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10427  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10428  BAWGBPhaseDelay()
10429  duty2lab.config(text = "Symmetry")
10430  UpdateAwgCont()
10431 #
10433  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10434  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10435  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10436  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10437  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10438 
10439  BAWGBAmpl(0)
10440  BAWGBOffset(0)
10441  BAWGBFreq(0)
10442  BAWGBPhase(0)
10443  BAWGBDutyCycle(0)
10444 
10445  if AWGBFreqvalue > 0.0:
10446  if AWG_2X.get() == 2:
10447  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10448  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10449  else:
10450  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10451  SamplesPermS = int(BaseSampleRate/1000) # 100
10452  else:
10453  AWGBperiodvalue = 0.0
10454  MaxV = AWGBOffsetvalue
10455  MinV = AWGBAmplvalue
10456  if AWG_Amp_Mode.get() == 1:
10457  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10458  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10459  else:
10460  MaxV = AWGBOffsetvalue
10461  MinV = AWGBAmplvalue
10462  AWGBwaveform = []
10463  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
10464  if AWGBPhaseDelay.get() == 0:
10465  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
10466  elif AWGBPhaseDelay.get() == 1:
10467  DelayValue = int(AWGBPhasevalue*SamplesPermS)
10468  for i in range(DelayValue-PulseWidth):
10469  AWGBwaveform.append((MinV+MaxV)/2)
10470  for i in range(PulseWidth):
10471  AWGBwaveform.append(MaxV)
10472  for i in range(PulseWidth):
10473  AWGBwaveform.append(MinV)
10474  DelayValue = int(AWGBperiodvalue-DelayValue)
10475  for i in range(DelayValue-PulseWidth):
10476  AWGBwaveform.append((MinV+MaxV)/2)
10477  if AWGBBurstFlag.get() == 1:
10478  TempOneCycle = AWGBwaveform
10479  for i in range(AWGBCycles-1):
10480  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10481  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10482  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10484  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10485  UpdateAwgCont()
10486 
10488  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
10489  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10490  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10491  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10492 
10493  BAWGBAmpl(0)
10494  BAWGBOffset(0)
10495  BAWGBFreq(0)
10496 
10497  if AWGBFreqvalue > 0.0:
10498  if AWG_2X.get() == 2:
10499  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10500  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10501  else:
10502  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10503  SamplesPermS = int(BaseSampleRate/1000) # 100
10504  else:
10505  AWGBperiodvalue = 0.0
10506 
10507  if AWGBAmplvalue > AWGBOffsetvalue:
10508  MinV = AWGBOffsetvalue
10509  MaxV = AWGBAmplvalue
10510  else:
10511  MaxV = AWGBOffsetvalue
10512  MinV = AWGBAmplvalue
10513  if AWG_Amp_Mode.get() == 1:
10514  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10515  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10516  AWGBwaveform = []
10517  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
10518  Mid = (MaxV+MinV)/2
10519  if AWGBBurstFlag.get() == 1:
10520  TempOneCycle = AWGBwaveform
10521  for i in range(AWGBCycles-1):
10522  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10523  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10524  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
10526  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10527  UpdateAwgCont()
10528 
10530  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
10531  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10532  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10533  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10534 
10535  BAWGBAmpl(0)
10536  BAWGBOffset(0)
10537  BAWGBFreq(0)
10538 
10539  if AWGBFreqvalue > 0.0:
10540  if AWG_2X.get() == 2:
10541  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10542  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10543  else:
10544  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10545  SamplesPermS = int(BaseSampleRate/1000) # 100
10546  else:
10547  AWGBperiodvalue = 0.0
10548  if AWGBAmplvalue > AWGBOffsetvalue:
10549  MinV = AWGBOffsetvalue
10550  MaxV = AWGBAmplvalue
10551  else:
10552  MaxV = AWGBOffsetvalue
10553  MinV = AWGBAmplvalue
10554  if AWG_Amp_Mode.get() == 1:
10555  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10556  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10557  AWGBwaveform = []
10558  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
10559  Mid = (MaxV+MinV)/2
10560  if AWGBBurstFlag.get() == 1:
10561  TempOneCycle = AWGBwaveform
10562  for i in range(AWGBCycles-1):
10563  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10564  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10565  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
10567  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10568  UpdateAwgCont()
10569 
10571  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
10572 
10573  if AWGBMode.get() == 0: # Source Voltage measure current mode
10574  label_txt = "SVMI"
10575  elif AWGBMode.get() == 1: # Source current measure voltage mode
10576  label_txt = "SIMV"
10577  elif AWGBMode.get() == 2: # High impedance mode
10578  label_txt = "Hi-Z"
10579  if AWGBIOMode.get() > 0: # Split Input / Output mode
10580  if HWRevOne == "D":
10581  if AWGBMode.get() == 0:
10582  AWGBMode.set(1)
10583  CHB.set_mode('i') # channel must be in source current mode for rev D boards
10584  label_txt = "SIMV"
10585  label_txt = label_txt + " Split I/O"
10586  label_txt = label_txt + " Mode"
10587  AWGBModeLabel.config(text = label_txt ) # change displayed value
10588  ReMakeAWGwaves()
10589  #UpdateAwgCont()
10590 
10592  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
10593  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
10594  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
10595  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
10596  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
10597  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10598  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag
10599 
10600  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
10601  amp2lab.config(text = "Min Ch B" ) # change displayed value
10602  off2lab.config(text = "Max Ch B" ) # change displayed value
10603  else:
10604  amp2lab.config(text = "Amp Ch B" )
10605  off2lab.config(text = "Off Ch B" )
10606 #
10607  if AWG_2X.get() == 1:
10608  AWGBWave = 'arbitrary'
10609  if AWGBFreqvalue > 0.0:
10610  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
10611  else:
10612  AWGBperiodvalue = 0.0
10613 #
10614  if AWGBPhaseDelay.get() == 0:
10615  if AWGBWave == 'square':
10616  AWGBPhasevalue = AWGBPhasevalue + 270.0
10617  if AWGBPhasevalue > 359:
10618  AWGBPhasevalue = AWGBPhasevalue - 360
10619  if AWGBPhasevalue > 0:
10620  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10621  else:
10622  AWGBdelayvalue = 0.0
10623  elif AWGBPhaseDelay.get() == 1:
10624  AWGBdelayvalue = AWGBPhasevalue * 100
10625 #
10626  if AWGBTerm.get() == 0: # Open termination
10627  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
10628  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
10629  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
10630  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
10631  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
10632  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
10633  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
10634  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
10635 
10636  if AWGBWave == 'dc':
10637  if AWG_2X.get() == 1:
10638  AWGBWave == 'arbitrary'
10639  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
10640  else:
10641  if AWGBMode.get() == 0: # Source Voltage measure current mode
10642  if AWGBIOMode.get() == 0:
10643  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
10644  else:
10645  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
10646  CHB.constant(AWGBOffsetvalue)
10647  if AWGBMode.get() == 1: # Source current measure Voltage mode
10648  if AWGBIOMode.get() == 0:
10649  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
10650  else:
10651  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
10652  CHB.constant(AWGBOffsetvalue/1000)
10653  if AWGBMode.get() == 2: # Hi impedance mode
10654  if AWGBIOMode.get() == 0:
10655  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
10656  else:
10657  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
10658 #
10659  if AWGBIOMode.get() > 0: # Split Input / Output mode
10660  if HWRevOne == "D":
10661  AWGBMode.set(1)
10662  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
10663 #
10664  else:
10665  if AWGBMode.get() == 0: # Source Voltage measure current mode
10666  if AWGBIOMode.get() == 0:
10667  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
10668  else:
10669  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
10670  if AWGBMode.get() == 1: # Source current measure Voltage mode
10671  if AWGBIOMode.get() == 0:
10672  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
10673  else:
10674  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
10675  AWGBOffsetvalue = AWGBOffsetvalue/1000
10676  AWGBAmplvalue = AWGBAmplvalue/1000
10677  if AWGBMode.get() == 2: # Hi impedance mode
10678  if AWGBIOMode.get() == 0:
10679  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
10680  else:
10681  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
10682  else:
10683  if AWG_Amp_Mode.get() == 1:
10684  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10685  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10686  else:
10687  MaxV = AWGBOffsetvalue
10688  MinV = AWGBAmplvalue
10689  try: # keep going even if low level library returns an error
10690  if AWGBWave == 'sine':
10691  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10692  elif AWGBWave == 'triangle':
10693  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10694  elif AWGBWave == 'sawtooth':
10695  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10696  elif AWGBWave == 'square':
10697  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
10698  elif AWGBWave == 'stairstep':
10699  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10700  elif AWGBWave == 'arbitrary':
10701  if AWGSync.get() == 0:
10702  AWGBRepeatFlag.set(1)
10703  if AWG_2X.get() == 1:
10704  AWGBWave == 'arbitrary'
10705  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
10706  else:
10707  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
10708  except:
10709  donothing()
10710  if AWGBIOMode.get() > 0: # Split Input / Output mode
10711  if HWRevOne == "D":
10712  AWGBMode.set(1)
10713  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
10714 #
10716  global session, CHA, CHB, AWGSync
10717  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
10718  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
10719  if session.continuous:
10720  session.end()
10721  BAWGEnab() # set-up new AWG settings
10722  time.sleep(0.01) # wait awhile here for some reason
10723  session.start(0)
10724 #
10726  UpdateAwgCont()
10727 
10728 def BAWGEnab():
10729  global AWGAMode, AWGBMode, AWGSync
10730  global CHA, CHB, discontloop, contloop, session
10731 
10732  # Stream = False
10733  # print "Updateing AWGs"
10734  BAWGAAmpl(0)
10735  BAWGAOffset(0)
10736  BAWGAFreq(0)
10737  BAWGAPhase(0)
10738  BAWGADutyCycle(0)
10739  BAWGAShape()
10740  BAWGBAmpl(0)
10741  BAWGBOffset(0)
10742  BAWGBFreq(0)
10743  BAWGBPhase(0)
10744  BAWGBDutyCycle(0)
10745  BAWGBShape()
10746  UpdateAWGA()
10747  UpdateAWGB()
10748 
10749 def BAWGSync():
10750  global RUNstatus, AWGSync, session, CHA, CHB
10751 
10752  if (RUNstatus.get() == 1): # do this only if running
10753  if AWGSync.get() == 0:
10754  #UpdateAwgCont()
10755  session.flush()
10756  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
10757  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
10758  BAWGEnab()
10759  session.start(0)
10760  time.sleep(0.02) # wait awhile here for some reason
10761  elif session.continuous:
10762  session.end()
10763  session.flush()
10764  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
10765  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
10766 
10767 # ======= Spectrum Analyzer functions ===========
10768 #
10770  global CANVASwidthF, CANVASheightF, freqwindow
10771  global COLORtext
10772  # ask for file name
10773  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
10774  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
10775  if MarkerNum > 0 or ColorMode.get() > 0:
10776  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
10777  else: # temp change text color to black
10778  COLORtext = "#000000"
10780  # save postscript file
10781  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
10782  #
10783  COLORtext = "#ffffff"
10785 #
10786 def Bnot():
10787  print( "Routine not made yet")
10788 
10790  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
10791  ShowC1_VdB.set(1)
10792  ShowC1_P.set(1)
10793  ShowC2_VdB.set(1)
10794  ShowC2_P.set(1)
10795 
10797  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
10798  ShowC1_VdB.set(0)
10799  ShowC1_P.set(0)
10800  ShowC2_VdB.set(0)
10801  ShowC2_P.set(0)
10802 
10804  global RUNstatus
10805  global FreqTraceMode
10806 
10807  FreqTraceMode.set(1)
10808  if RUNstatus.get() == 0: # Update if stopped
10810  if RUNstatus.get() == 2: # Restart if running
10811  RUNstatus.set(4)
10812 
10814  global RUNstatus
10815  global FreqTraceMode
10816 
10817  FreqTraceMode.set(2)
10818  if RUNstatus.get() == 0: # Update if stopped
10820  if RUNstatus.get() == 2: # Restart if running
10821  RUNstatus.set(4)
10822 
10824  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
10825 
10826  FreqTraceMode.set(3)
10827 
10828  if RUNstatus.get() == 0: # Update if stopped
10830  if RUNstatus.get() == 2: # Restart if running
10831  RUNstatus.set(4)
10832 
10834  global FreqTraceMode, TRACEresetFreq
10835 
10836  if FreqTraceMode.get()==3:
10837  TRACEresetFreq = True
10838 
10840  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
10841  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
10842  global T1Pline, T2Pline, T1PRline, T2PRline
10843  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
10844  global PeakxM, PeakyM, PeakMdb, PeakfreqM
10845  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
10846  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
10847  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
10848 
10849  if ShowC1_VdB.get() == 1:
10850  T1FRline = T1Fline
10851  PeakxRA = PeakxA
10852  PeakyRA = PeakyA
10853  PeakdbRA = PeakdbA
10854  PeakfreqRA = PeakfreqA
10855  if ShowC2_VdB.get() == 1:
10856  T2FRline = T2Fline
10857  PeakxRB = PeakxB
10858  PeakyRB = PeakyB
10859  PeakdbRB = PeakdbB
10860  PeakfreqRB = PeakfreqB
10861  if ShowC1_P.get() == 1:
10862  T1PRline = T1Pline
10863  if ShowC2_P.get() == 1:
10864  T2PRline = T2Pline
10865  if ShowMathSA.get() > 0:
10866  TFRMline = TFMline
10867  PeakxRM = PeakxM
10868  PeakyRM = PeakyM
10869  PeakRMdb = PeakMdb
10870  PeakfreqRM = PeakfreqM
10871 
10872  UpdateFreqTrace() # Always Update
10873 #
10875  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
10876  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
10877  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
10878  global TAPline, TBPline, TAPRline, TBPRline
10879  global TIARline, TIAXline, TIAMagline, TIAAngline
10880  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
10881  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
10882  global PeakxM, PeakyM, PeakMdb, PeakfreqM
10883  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
10884  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
10885  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
10886 
10887  if ShowCA_VdB.get() == 1:
10888  TAFRline = TAFline
10889  PeakxRA = PeakxA
10890  PeakyRA = PeakyA
10891  PeakdbRA = PeakdbA
10892  PeakfreqRA = PeakfreqA
10893  if ShowCB_VdB.get() == 1:
10894  TBFRline = TBFline
10895  PeakxRB = PeakxB
10896  PeakyRB = PeakyB
10897  PeakdbRB = PeakdbB
10898  PeakfreqRB = PeakfreqB
10899  if ShowCA_P.get() == 1:
10900  TAPRline = TAPline
10901  if ShowCB_P.get() == 1:
10902  TBPRline = TBPline
10903  if ShowMathBP.get() > 0:
10904  TBPRMline = TBPMline
10905  PeakxRM = PeakxM
10906  PeakyRM = PeakyM
10907  PeakRMdb = PeakMdb
10908  PeakfreqRM = PeakfreqM
10909  if Show_Rseries.get() > 0:
10910  RefIARline = TIARline
10911  if Show_Xseries.get() > 0:
10912  RefIAXline = TIAXline
10913  if Show_Magnitude.get() > 0:
10914  RefIAMagline = TIAMagline
10915  if Show_Angle.get() > 0:
10916  RefIAAngline = TIAAngline
10917  UpdateBodeTrace() # Always Update
10918 #
10919 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
10920  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
10921  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
10922 
10923  # Set the TRACEsize variable
10924  if ShowCA_VdB.get() == 1:
10925  TRACEsize = len(FSweepAdB) # Set the trace length
10926  elif ShowCA_VdB.get() == 1:
10927  TRACEsize = len(FSweepBdB)
10928  if TRACEsize == 0: # If no trace, skip rest of this routine
10929  return()
10930 # ask if save as magnitude or dB
10931  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
10932 # Yes 1 = dB, No 0 = Mag
10933  # Make the file name and open it
10934  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
10935  filename = "Bode-" + tme
10936  filename = filename + ".csv"
10937  # open file to save data
10938  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
10939  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
10940  DataFile = open(filename,'a') # Open output file
10941  HeaderString = 'Frequency-#, '
10942  if ShowCA_VdB.get() == 1:
10943  if dB == 1:
10944  HeaderString = HeaderString + 'CA-dB, '
10945  if dB == 0:
10946  HeaderString = HeaderString + 'CA-Mag, '
10947  if ShowCB_VdB.get() == 1:
10948  if dB == 1:
10949  HeaderString = HeaderString + 'CB-dB, '
10950  if dB == 0:
10951  HeaderString = HeaderString + 'CB-Mag, '
10952  if ShowCA_P.get() == 1:
10953  HeaderString = HeaderString + 'Phase A-B, '
10954  if ShowCB_P.get() == 1:
10955  HeaderString = HeaderString + 'Phase B-A, '
10956  HeaderString = HeaderString + '\n'
10957  DataFile.write( HeaderString )
10958 
10959  n = 0
10960  while n < len(FSweepAdB):
10961  F = FBins[FStep[n]] # look up frequency bin in list of bins
10962  txt = str(F)
10963  if ShowCA_VdB.get() == 1:
10964  V = 10 * math.log10(float(FSweepAdB[n])) + 17 # Add 17 dB for max value of +10 dB
10965  if dB == 0:
10966  V = 10.0**(V/20.0)
10967  txt = txt + "," + str(V)
10968  if ShowCB_VdB.get() == 1:
10969  V = 10 * math.log10(float(FSweepBdB[n])) + 17 # Add 17 dB for max value of +10 dB
10970  if dB == 0:
10971  V = 10.0**(V/20.0)
10972  txt = txt + "," + str(V)
10973  if ShowCA_P.get() == 1:
10974  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
10975  if RelPhase > 180:
10976  RelPhase = RelPhase - 360
10977  elif RelPhase < -180:
10978  RelPhase = RelPhase + 360
10979  txt = txt + "," + str(RelPhase)
10980  if ShowCB_P.get() == 1:
10981  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
10982  if RelPhase > 180:
10983  RelPhase = RelPhase - 360
10984  elif RelPhase < -180:
10985  RelPhase = RelPhase + 360
10986  txt = txt + "," + str(RelPhase)
10987  txt = txt + "\n"
10988  DataFile.write(txt)
10989  n = n + 1
10990 
10991  DataFile.close() # Close the file
10992 
10994  global iawindow, FStep, FBins
10995  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
10996 
10997  if NetworkScreenStatus.get() > 0:
10998  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
10999  filename = "Impedance-" + tme
11000  filename = filename + ".csv"
11001  # open file to save data
11002  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
11003  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
11004  DataFile = open(filename,'a') # Open output file
11005  HeaderString = 'Frequency, Series R, Seriec X, Series Z, Series Angle'
11006  HeaderString = HeaderString + '\n'
11007  DataFile.write( HeaderString )
11008 
11009  n = 0
11010  while n < len(NSweepSeriesR):
11011  F = FBins[FStep[n]] # look up frequency bin in list of bins
11012  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
11013  txt = txt + "\n"
11014  DataFile.write(txt)
11015  n = n + 1
11016  DataFile.close() # Close the file
11017  else:
11018  return
11019 #
11020 def BStartSA():
11021  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
11022  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
11023  global Two_X_Sample, ADC_Mux_Mode
11024 
11025  #AWGSync.set(0) # always run in continuous mode
11026  if DevID == "No Device":
11027  showwarning("WARNING","No Device Plugged In!")
11028  elif FWRevOne == 0.0:
11029  showwarning("WARNING","Out of data Firmware!")
11030  else:
11031  if PowerStatus == 0:
11032  PowerStatus = 1
11033  PwrBt.config(style="Pwr.TButton",text="PWR-On")
11034  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
11035 
11036  if ShowC1_VdB.get() == 0 and ShowC2_VdB.get() == 0 and ShowMathSA.get() == 0 and ShowC1_P.get() == 0 and ShowC2_P.get() == 0:
11037  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
11038  return()
11039  try:
11040  StopFrequency = float(StopFreqEntry.get())
11041  except:
11042  StopFreqEntry.delete(0,"end")
11043  StopFreqEntry.insert(0,50000)
11044  StopFrequency = 50000
11045  if FWRevOne > 2.16:
11046  if StopFrequency >= 50000:
11047  Two_X_Sample.set(1)
11048  else:
11049  Two_X_Sample.set(0)
11050  ADC_Mux_Mode.set(0)
11051  SetADC_Mux()
11052  #
11053  BStart()
11054 #
11055  UpdateFreqAll() # Always Update
11056 
11057 def BStopSA():
11058  global RUNstatus, session, AWGSync
11059 
11060  if (RUNstatus.get() == 1):
11061  RUNstatus.set(0)
11062  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11063  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
11064  if AWGSync.get() == 0: # running in continuous mode
11065  CHA.constant(0.0)
11066  CHB.constant(0.0)
11067  # print "Stoping continuous mode"
11068  if session.continuous:
11069  # print "Stoping Is Continuous? ", session.continuous
11070  time.sleep(0.02)
11071  #print "Is Continuous? ", session.continuous
11072  else:
11073  contloop = 0
11074  discontloop = 1
11075  session.cancel()
11076  elif (RUNstatus.get() == 2):
11077  RUNstatus.set(3)
11078  elif (RUNstatus.get() == 3):
11079  RUNstatus.set(3)
11080  elif (RUNstatus.get() == 4):
11081  RUNstatus.set(3)
11082  UpdateFreqAll() # Always Update
11083 
11084 def Blevel1():
11085  global DBlevel
11086  global RUNstatus
11087 
11088  DBlevel.set(DBlevel.get() - 1)
11089 
11090  if RUNstatus.get() == 0: # Update if stopped
11091  UpdateFreqTrace()
11092 
11093 def Blevel2():
11094  global DBlevel
11095  global RUNstatus
11096 
11097  DBlevel.set(DBlevel.get() + 1)
11098 
11099  if RUNstatus.get() == 0: # Update if stopped
11100  UpdateFreqTrace()
11101 
11102 def Blevel3():
11103  global DBlevel
11104  global RUNstatus
11105 
11106  DBlevel.set(DBlevel.get() - 10)
11107 
11108  if RUNstatus.get() == 0: # Update if stopped
11109  UpdateFreqTrace()
11110 
11111 def Blevel4():
11112  global DBlevel
11113  global RUNstatus
11114 
11115  DBlevel.set(DBlevel.get() + 10)
11116 
11117  if RUNstatus.get() == 0: # Update if stopped
11118  UpdateFreqTrace()
11119 #
11121  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
11122  global SMPfftpwrTwo, SMPfft, FFTwindow
11123  global TRACEresetFreq
11124 
11125  if FFTwindow.get() != 8:
11126  if (SMPfftpwrTwo.get() > 6): # Min 64
11127  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
11128  TRACEresetFreq = True # Reset trace peak and trace average
11129  SMPfft = 2 ** int(SMPfftpwrTwo.get())
11130 
11131  if RUNstatus.get() == 0: # Update if stopped
11132  if SpectrumScreenStatus.get() > 0:
11134  if IAScreenStatus.get() > 0:
11135  UpdateIAScreen()
11136  if RUNstatus.get() == 2: # Restart if running
11137  RUNstatus.set(4)
11138 
11140  global RUNstatus
11141  global SMPfftpwrTwo, SMPfft, FFTwindow
11142  global TRACEresetFreq
11143 
11144  if FFTwindow.get() != 8:
11145  if (SMPfftpwrTwo.get() < 16): # Max 65536
11146  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
11147  TRACEresetFREQ = True # Reset trace peak and trace average
11148  SMPfft = 2 ** int(SMPfftpwrTwo.get())
11149 
11150  if RUNstatus.get() == 0: # Update if stopped
11151  if SpectrumScreenStatus.get() > 0:
11153  if IAScreenStatus.get() > 0:
11154  UpdateIAScreen()
11155  if RUNstatus.get() == 2: # Restart if running
11156  RUNstatus.set(4)
11157 
11158 def BDBdiv1():
11159  global DBdivindex
11160  global RUNstatus
11161 
11162  if (DBdivindex.get() >= 1):
11163  DBdivindex.set(DBdivindex.get() - 1)
11164 
11165  if RUNstatus.get() == 0: # Update if stopped
11166  UpdateFreqTrace()
11167 
11168 def BDBdiv2():
11169  global DBdivindex
11170  global DBdivlist
11171  global RUNstatus
11172 
11173  if (DBdivindex.get() < len(DBdivlist) - 1):
11174  DBdivindex.set(DBdivindex.get() + 1)
11175 
11176  if RUNstatus.get() == 0: # Update if stopped
11177  UpdateFreqTrace()
11178 #----- Bode Plot controls
11179 def BStartBP():
11180  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
11181  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
11182  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
11183  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
11184  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
11185  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
11186  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
11187  global BeginIndex, EndIndex
11188 
11189  if DevID == "No Device":
11190  showwarning("WARNING","No Device Plugged In!")
11191  elif FWRevOne == 0.0:
11192  showwarning("WARNING","Out of data Firmware!")
11193  else:
11194  if PowerStatus == 0:
11195  PowerStatus = 1
11196  PwrBt.config(style="Pwr.TButton",text="PWR-On")
11197  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
11198 
11199  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
11200  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
11201  return()
11202  #
11203  if ZEROstuffing.get() < 3:
11204  ZEROstuffing.set(3)
11205  CutDC.set(1) # set to remove DC
11206  try:
11207  EndFreq = float(StopBodeEntry.get())
11208  except:
11209  StopBodeEntry.delete(0,"end")
11210  StopBodeEntry.insert(0,10000)
11211  EndFreq = 10000
11212  if FWRevOne > 2.16:
11213  if EndFreq >= 20000:
11214  Two_X_Sample.set(1)
11215  FBins = numpy.linspace(0, 100000, num=16384)
11216  else:
11217  Two_X_Sample.set(0)
11218  FBins = numpy.linspace(0, 50000, num=16384)
11219  ADC_Mux_Mode.set(0)
11220  SetADC_Mux()
11221  try:
11222  BeginFreq = float(StartBodeEntry.get())
11223  except:
11224  StartBodeEntry.delete(0,"end")
11225  StartBodeEntry.insert(0,100)
11226  BeginFreq = 100
11227  #
11228  if FSweepMode.get() == 1:
11229  if AWGAMode.get() == 2:
11230  AWGAMode.set(0) # Set AWG A to SVMI
11231  AWGAShape.set(18) # Set Shape to Sine
11232  if Two_X_Sample.get() == 1:
11233  AWGBIOMode.set(1)
11234  AWGBMode.set(0)
11235  else:
11236  AWGBMode.set(2) # Set AWG B to Hi-Z
11237  AWG_2X.set(0)
11238  BAWG2X()
11239  Reset_Freq = AWGAFreqEntry.get()
11240  if FSweepMode.get() == 2:
11241  if AWGBMode.get() == 2:
11242  AWGBMode.set(0) # Set AWG B to SVMI
11243  AWGBShape.set(18) # Set Shape to Sine
11244  if Two_X_Sample.get() == 1:
11245  AWGAIOMode.set(1)
11246  AWGAMode.set(0)
11247  else:
11248  AWGAMode.set(2) # Set AWG A to Hi-Z
11249  AWG_2X.set(0)
11250  BAWG2X()
11251  Reset_Freq = AWGBFreqEntry.get()
11252  if FSweepMode.get() == 3: # using external Minigen
11253  AWGAMode.set(2) # Set AWG A to Hi-Z
11254  AWGBMode.set(2) # Set AWG B to Hi-Z
11255  try:
11256  NSteps.set(float(SweepStepBodeEntry.get()))
11257  except:
11258  SweepStepBodeEntry.delete(0,"end")
11259  SweepStepBodeEntry.insert(0, NSteps.get())
11260  #
11261  if FSweepMode.get() > 0:
11262  LoopNum.set(1)
11263  NyquistFreq = SAMPLErate/2
11264  BeginIndex = int((BeginFreq/NyquistFreq)*16384)
11265  EndIndex = int((EndFreq/NyquistFreq)*16384)
11266  if NSteps.get() < 5:
11267  NSteps.set(5)
11268  if HScaleBP.get() == 1:
11269  LogFStop = math.log10(EndIndex)
11270  try:
11271  LogFStart = math.log10(BeginIndex)
11272  except:
11273  LogFStart = 1.0
11274  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
11275  else:
11276  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
11277  BStart()
11278  # UpdateBodeAll() # Always Update
11279 #
11280 def BStopBP():
11281  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
11282 
11283  if FSweepMode.get() == 1:
11284  AWGAFreqEntry.delete(0,"end")
11285  AWGAFreqEntry.insert(0, Reset_Freq)
11286  if FSweepMode.get() == 2:
11287  AWGBFreqEntry.delete(0,"end")
11288  AWGBFreqEntry.insert(0, Reset_Freq)
11289 #
11290  if (RUNstatus.get() == 1):
11291  RUNstatus.set(0)
11292  if AWGSync.get() == 0: # running in continuous mode
11293  session.cancel() # cancel continuous session mode while paused
11294  elif (RUNstatus.get() == 2):
11295  RUNstatus.set(3)
11296  elif (RUNstatus.get() == 3):
11297  RUNstatus.set(3)
11298  elif (RUNstatus.get() == 4):
11299  RUNstatus.set(3)
11300  UpdateBodeAll() # Always Update
11301 #
11303  global DBlevelBP
11304  global RUNstatus
11305 
11306  DBlevelBP.set(DBlevelBP.get() - 1)
11307 
11308  if RUNstatus.get() == 0: # Update if stopped
11309  UpdateBodeTrace()
11310 
11312  global DBlevelBP
11313  global RUNstatus
11314 
11315  DBlevelBP.set(DBlevelBP.get() + 1)
11316 
11317  if RUNstatus.get() == 0: # Update if stopped
11318  UpdateBodeTrace()
11319 
11321  global DBlevelBP
11322  global RUNstatus
11323 
11324  DBlevelBP.set(DBlevelBP.get() - 10)
11325 
11326  if RUNstatus.get() == 0: # Update if stopped
11327  UpdateBodeTrace()
11328 
11330  global DBlevelBP
11331  global RUNstatus
11332 
11333  DBlevelBP.set(DBlevelBP.get() + 10)
11334 
11335  if RUNstatus.get() == 0: # Update if stopped
11336  UpdateBodeTrace()
11337 
11339  global DBdivindexBP
11340  global RUNstatus
11341 
11342  if (DBdivindexBP.get() >= 1):
11343  DBdivindexBP.set(DBdivindexBP.get() - 1)
11344 
11345  if RUNstatus.get() == 0: # Update if stopped
11346  UpdateBodeTrace()
11347 
11349  global DBdivindexBP
11350  global DBdivlist
11351  global RUNstatus
11352 
11353  if (DBdivindexBP.get() < len(DBdivlist) - 1):
11354  DBdivindexBP.set(DBdivindexBP.get() + 1)
11355 
11356  if RUNstatus.get() == 0: # Update if stopped
11357  UpdateBodeTrace()
11358 #
11360  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11361  ShowCA_VdB.set(1)
11362  ShowCA_P.set(1)
11363  ShowCB_VdB.set(1)
11364  ShowCB_P.set(1)
11365 
11367  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11368  ShowCA_VdB.set(0)
11369  ShowCA_P.set(0)
11370  ShowCB_VdB.set(0)
11371  ShowCB_P.set(0)
11372 # Bode Plot refresh
11373 def UpdateBodeAll(): # Update Data, trace and screen
11374  global FFTBuffA, FFTBuffB
11375  global SMPfft
11376 
11377  # DoFFT() # Fast Fourier transformation
11378  MakeBodeTrace() # Update the traces
11379  UpdateBodeScreen() # Update the screen
11380 
11381 def UpdateBodeTrace(): # Update trace and screen
11382  MakeBodeTrace() # Update traces
11383  UpdateBodeScreen() # Update the screen
11384 
11385 def UpdateBodeScreen(): # Update screen with trace and text
11386  MakeBodeScreen() # Update the screen
11387 
11388 # ============================================ Freq Main routine ====================================================
11389 
11390 def UpdateFreqAll(): # Update Data, trace and screen
11391  global FFTBuffA, FFTBuffB
11392  global SMPfft
11393 
11394  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
11395  return
11396 
11397  # DoFFT() # Fast Fourier transformation
11398  MakeFreqTrace() # Update the traces
11399  UpdateFreqScreen() # Update the screen
11400 
11401 def UpdateFreqTrace(): # Update trace and screen
11402  MakeFreqTrace() # Update traces
11403  UpdateFreqScreen() # Update the screen
11404 
11405 def UpdateFreqScreen(): # Update screen with trace and text
11406  MakeFreqScreen() # Update the screen
11407 
11408 def DoFFT(): # Fast Fourier transformation
11409  global FFTBuffA, FFTBuffB
11410  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
11411  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
11412  global FFTmemoryB, FFTresultB
11413  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
11414  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
11415  global FFTwindowshape, FFTbandwidth
11416  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
11417  global SMPfft, LoopNum, IA_Ext_Conf
11418  global STARTsample, STOPsample
11419  global TRACEaverage, FreqTraceMode, FSweepMode
11420  global TRACEresetFreq, ZEROstuffing
11421  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
11422  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
11423 
11424  # T1 = time.time() # For time measurement of FFT routine
11425  REX = []
11426  PhaseA = []
11427  PhaseB = []
11428  # Convert list to numpy array REX for faster Numpy calculations
11429  # Take the first fft samples
11430  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
11431 
11432  # Set Analog level display value MAX value is 5 volts for ALM1000
11433  REX = REX / 5.0
11434 
11435  # Do the FFT window function
11436  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
11437 
11438  # Zero stuffing of array for better interpolation of peak level of signals
11439  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11440  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11441 
11442  # Save previous trace in memory for max or average trace
11443  FFTmemoryA = FFTresultA
11444  if FreqTraceMode.get() == 3:
11445  PhaseMemoryA = PhaseA
11446 
11447  # FFT with numpy
11448  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11449  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
11450  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11451  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
11452 
11453  le = int(len(ALL) / 2) # Only half is used, other half is mirror
11454  ALL = ALL[0:le] # So take only first half of the array
11455  PhaseA = PhaseA[0:le]
11456  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11457  Totalcorr = Totalcorr * Totalcorr # For POWER!
11458  FFTresultA = Totalcorr * ALL
11459 #
11460  REX = []
11461  # Convert list to numpy array REX for faster Numpy calculations
11462  # Take the first fft samples
11463  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
11464 
11465  # Set level display value MAX value is 5 volts for ALM1000
11466  REX = REX / 5.0
11467 
11468  # Do the FFT window function
11469  try:
11470  REX = REX * FFTwindowshape # The windowing shape function only over the samples
11471  except:
11472  return
11473  # Zero stuffing of array for better interpolation of peak level of signals
11474  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11475  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11476 
11477  # Save previous trace in memory for max or average trace
11478  FFTmemoryB = FFTresultB
11479  if FreqTraceMode.get() == 3:
11480  PhaseMemoryB = PhaseB
11481  # FFT with numpy
11482  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11483  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
11484  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11485  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
11486 
11487  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
11488  ALL = ALL[0:le] # So take only first half of the array
11489  PhaseB = PhaseB[0:le]
11490  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11491  Totalcorr = Totalcorr * Totalcorr # For POWER!
11492  FFTresultB = Totalcorr * ALL
11493 #
11494  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
11495  REX = []
11496  PhaseAB = []
11497  # Convert list to numpy array REX for faster Numpy calculations
11498  # Take the first fft samples
11499  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
11500 
11501  # Set level display value MAX value is 5 volts for ALM1000
11502  REX = REX / 5.0
11503 
11504  # Do the FFT window function
11505  REX = REX * FFTwindowshape # The windowing shape function only over the samples
11506 
11507  # Zero stuffing of array for better interpolation of peak level of signals
11508  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11509  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11510 
11511  # Save previous trace in memory for max or average trace
11512  # FFTmemoryB = FFTresultB
11513  # if FreqTraceMode.get() == 3:
11514  # PhaseMemoryB = PhaseB
11515  # FFT with numpy
11516  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11517  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
11518  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11519  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
11520 
11521  le = len(ALL) / 2 # Only half is used, other half is mirror
11522  ALL = ALL[:le] # So take only first half of the array
11523  PhaseAB = PhaseAB[:le]
11524  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11525  Totalcorr = Totalcorr * Totalcorr # For POWER!
11526  FFTresultAB = Totalcorr * ALL
11527 #
11528  TRACEsize = int(len(FFTresultB))
11529  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
11530  if SpectrumScreenStatus.get() > 0:
11531  try:
11532  StartFrequency = float(StartFreqEntry.get())
11533  except:
11534  StartFreqEntry.delete(0,"end")
11535  StartFreqEntry.insert(0,100)
11536  StartFrequency = 100
11537  STARTsample = StartFrequency / Fsample
11538  else:
11539  STARTsample = 0.0
11540  if LoopNum.get() == 1:
11541  PhaseMemoryB = PhaseB
11542  FSweepAdB = []
11543  FSweepBdB = []
11544  FSweepAPh = []
11545  FSweepBPh = []
11546  if NetworkScreenStatus.get() > 0:
11547  NSweepSeriesR = []
11548  NSweepSeriesX = []
11549  NSweepSeriesMag = [] # in ohms
11550  NSweepSeriesAng = [] # in degrees
11551  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
11552  if FSweepMode.get() == 1:
11553  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11554  if ptmax > STARTsample:
11555  STARTsample = ptmax
11556  i = 0
11557  while i < 6:
11558  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11559  i = i + 1
11560  if FSweepMode.get() == 2:
11561  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11562  if ptmax > STARTsample:
11563  STARTsample = ptmax
11564  i = 0
11565  while i < 6:
11566  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11567  i = i + 1
11568 
11569  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
11570  if FSweepMode.get() == 1:
11571  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11572  if ptmax > STARTsample:
11573  STARTsample = ptmax
11574  i = 0
11575  while i < 6:
11576  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11577  i = i + 1
11578  if FSweepMode.get() == 2:
11579  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11580  if ptmax > STARTsample:
11581  STARTsample = ptmax
11582  i = 0
11583  while i < 6:
11584  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11585  i = i + 1
11586  if len(FFTresultB) == len(FFTmemoryB):
11587  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
11588  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
11589  try:
11590  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
11591  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
11592  except:
11593  FFTmemoryB = FFTresultB
11594  PhaseMemoryB = PhaseB
11595 #
11596  TRACEsize = int(len(FFTresultA))
11597  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
11598  if SpectrumScreenStatus.get() > 0:
11599  STARTsample = StartFrequency / Fsample
11600  else:
11601  STARTsample = 0.0
11602  if LoopNum.get() == 1:
11603  PhaseMemoryA = PhaseA
11604  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
11605  if FSweepMode.get() == 1:
11606  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11607  if ptmax > STARTsample:
11608  STARTsample = ptmax
11609  i = 0
11610  while i < 6:
11611  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11612  i = i + 1
11613  if FSweepMode.get() == 2:
11614  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11615  if ptmax > STARTsample:
11616  STARTsample = ptmax
11617  i = 0
11618  while i < 6:
11619  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11620  i = i + 1
11621 
11622  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
11623  if FSweepMode.get() == 1:
11624  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11625  if ptmax > STARTsample:
11626  STARTsample = ptmax
11627  i = 0
11628  while i < 6:
11629  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11630  i = i + 1
11631  if FSweepMode.get() == 2:
11632  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11633  if ptmax > STARTsample:
11634  STARTsample = ptmax
11635  i = 0
11636  while i < 6:
11637  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11638  i = i + 1
11639 #
11640  if len(FFTresultA) == len(FFTmemoryA):
11641  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
11642  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
11643  try:
11644  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
11645  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
11646  except:
11647  FFTmemoryA = FFTresultA
11648  PhaseMemoryA = PhaseA
11649 #
11650  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
11651  FSweepAdB.append(numpy.amax(FFTresultA))
11652  FSweepBdB.append(numpy.amax(FFTresultB))
11653  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
11654  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
11655 
11656  TRACEresetFreq = False # Trace reset done
11657 
11658 def MakeFreqTrace(): # Update the grid and trace
11659  global FFTmemoryA, FFTresultA
11660  global FFTmemoryB, FFTresultB
11661  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
11662  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
11663  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
11664  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
11665  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
11666  global PeakfreqA, PeakfreqB, Two_X_Sample
11667  global DBdivindex # Index value
11668  global DBdivlist # dB per division list
11669  global DBlevel # Reference level
11670  global GRHF,GRWF # Screenheight, Screenwidth
11671  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
11672  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
11673  global STARTsample, STOPsample, LoopNum, FSweepMode
11674  global FreqTraceMode
11675  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline
11676  global Vdiv # Number of vertical divisions
11677  global X0LF, Y0TF # Left top X value, Left top Y value
11678 
11679  # Set the TRACEsize variable
11680  TRACEsize = 0
11681  try:
11682  StartFrequency = float(StartFreqEntry.get())
11683  except:
11684  StartFreqEntry.delete(0,"end")
11685  StartFreqEntry.insert(0,100)
11686  StartFrequency = 100
11687  try:
11688  StopFrequency = float(StopFreqEntry.get())
11689  except:
11690  StopFreqEntry.delete(0,"end")
11691  StopFreqEntry.insert(0,50000)
11692  StopFrequency = 50000
11693  if StartFrequency > StopFrequency :
11694  StopFreqEntry.delete(0,"end")
11695  StopFreqEntry.insert(0,50000)
11696  StopFrequency = 50000
11697  if StopFrequency < StartFrequency :
11698  StopFreqEntry.delete(0,"end")
11699  StopFreqEntry.insert(0,50000)
11700  StopFrequency = 50000
11701  try:
11702  Phasecenter = int(PhCenFreqEntry.get())
11703  RelPhaseCenter.set(Phasecenter)
11704  except:
11705  PhCenFreqEntry.delete(0,"end")
11706  PhCenFreqEntry.insert(0,0)
11707  RelPhaseCenter.set(0)
11708  Phasecenter = 0
11709  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
11710  TRACEsize = len(FFTresultA) # Set the trace length
11711  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
11712  TRACEsize = len(FFTresultB)
11713  if TRACEsize == 0: # If no trace, skip rest of this routine
11714  return()
11715  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
11716  PhaseA = PhaseMemoryA
11717  PhaseB = PhaseMemoryB
11718  # Vertical conversion factors (level dBs) and border limits
11719  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
11720  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
11721  Ymin = Y0TF # Minimum position of screen grid (top)
11722  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
11723  Yphconv = float(GRHF) / 360
11724  Yp = float(Y0TF) + Yphconv + 180
11725  # Horizontal conversion factors (frequency Hz) and border limits
11726  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
11727  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
11728  LogFStop = math.log10(StopFrequency)
11729  try:
11730  LogFStart = math.log10(StartFrequency)
11731  except:
11732  LogFStart = 0.0
11733  LogFpixel = (LogFStop - LogFStart) / GRWF
11734  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
11735  STARTsample = int(math.ceil(STARTsample)) # First within screen range
11736 
11737  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
11738  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
11739 
11740  MAXsample = TRACEsize # Just an out of range check
11741  if STARTsample > (MAXsample - 1):
11742  STARTsample = MAXsample - 1
11743 
11744  if STOPsample > MAXsample:
11745  STOPsample = MAXsample
11746 
11747  T1Fline = []
11748  T2Fline = []
11749  T1Pline = []
11750  T2Pline = []
11751  TFMline = []
11752  n = STARTsample
11753  PeakIndexA = PeakIndexB = n
11754  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
11755  while n <= STOPsample:
11756  F = n * Fsample
11757  if HScale.get() == 1:
11758  try:
11759  LogF = math.log10(F) # convet to log Freq
11760  x = X0LF + (LogF - LogFStart)/LogFpixel
11761  except:
11762  x = X0LF
11763  else:
11764  x = X0LF + (F - StartFrequency) / Fpixel
11765  if ShowC1_VdB.get() == 1:
11766  T1Fline.append(int(x + 0.5))
11767  try:
11768  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
11769  ya = Yc - Yconv * dbA # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11770  except:
11771  ya = Ymax
11772  if (ya < Ymin):
11773  ya = Ymin
11774  if (ya > Ymax):
11775  ya = Ymax
11776  if dbA > PeakdbA:
11777  PeakdbA = dbA
11778  PeakyA = int(ya + 0.5)
11779  PeakxA = int(x + 0.5)
11780  PeakfreqA = F
11781  PeakIndexA = n
11782  T1Fline.append(int(ya + 0.5))
11783  if ShowC2_VdB.get() == 1:
11784  T2Fline.append(int(x + 0.5))
11785  try:
11786  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11787  yb = Yc - Yconv * dbB
11788  except:
11789  yb = Ymax
11790  if (yb < Ymin):
11791  yb = Ymin
11792  if (yb > Ymax):
11793  yb = Ymax
11794  if dbB > PeakdbB:
11795  PeakdbB = dbB
11796  PeakyB = int(yb + 0.5)
11797  PeakxB = int(x + 0.5)
11798  PeakfreqB = F
11799  PeakIndexB = n
11800  T2Fline.append(int(yb + 0.5))
11801  if ShowC1_P.get() == 1:
11802  T1Pline.append(int(x + 0.5))
11803  if FSweepMode.get() > 0:
11804  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
11805  else:
11806  RelPhase = PhaseA[n]-PhaseB[n]
11807  RelPhase = RelPhase - Phasecenter
11808  if RelPhase > 180:
11809  RelPhase = RelPhase - 360
11810  elif RelPhase < -180:
11811  RelPhase = RelPhase + 360
11812  if Two_X_Sample.get() == 0:
11813  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
11814  RelPhase = RelPhase + PhErr - 12.0
11815  else:
11816  RelPhase = RelPhase - 9.0
11817  ya = Yp - Yphconv * RelPhase
11818  T1Pline.append(int(ya + 0.5))
11819  if ShowC2_P.get() == 1:
11820  T2Pline.append(int(x + 0.5))
11821  if FSweepMode.get() > 0:
11822  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
11823  else:
11824  RelPhase = PhaseB[n]-PhaseA[n]
11825  RelPhase = RelPhase - Phasecenter
11826  if RelPhase > 180:
11827  RelPhase = RelPhase - 360
11828  elif RelPhase < -180:
11829  RelPhase = RelPhase + 360
11830  if Two_X_Sample.get() == 0:
11831  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
11832  RelPhase = RelPhase - PhErr - 12.0
11833  else:
11834  RelPhase = RelPhase - 9.0
11835  ya = Yp - Yphconv * RelPhase
11836  T2Pline.append(int(ya + 0.5))
11837  if ShowMathSA.get() > 0:
11838  TFMline.append(int(x + 0.5))
11839  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
11840  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11841  if ShowMathSA.get() == 1:
11842  MdB = dbA - dbB
11843  elif ShowMathSA.get() == 2:
11844  MdB = dbB - dbA
11845  yb = Yc - Yconv * MdB
11846  if (yb < Ymin):
11847  yb = Ymin
11848  if (yb > Ymax):
11849  yb = Ymax
11850  if MdB > PeakMdb:
11851  PeakMdb = MdB
11852  PeakyM = int(yb + 0.5)
11853  PeakxM = int(x + 0.5)
11854  PeakfreqM = F
11855  TFMline.append(int(yb + 0.5))
11856  n = n + 1
11857 # make Bode Plot Traces
11858 def MakeBodeTrace(): # Update the grid and trace
11859  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
11860  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
11861  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
11862  global PeakxM, PeakyM, PeakMdb, PeakfreqM
11863  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
11864  global DBdivindexBP # Index value
11865  global DBdivlist # dB per division list
11866  global DBlevelBP # Reference level
11867  global GRHBP # Screenheight
11868  global GRWBP # Screenwidth
11869  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
11870  global StartBodeEntry, StopBodeEntry
11871  global STARTsample, STOPsample, LoopNum, FSweepMode
11872  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
11873  global TAFline, TBFline, TBPMline, TAPline, TBPline
11874  global Vdiv # Number of vertical divisions
11875  global X0LBP # Left top X value
11876  global Y0TBP # Left top Y value
11877  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
11878  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
11879  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
11880 
11881  # Set the TRACEsize variable
11882  TRACEsize = 0
11883  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
11884  TRACEsize = len(FStep) # Set the trace length
11885  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
11886  TRACEsize = len(FStep)
11887  if TRACEsize == 0: # If no trace, skip rest of this routine
11888  return()
11889  #
11890  try:
11891  EndFreq = float(StopBodeEntry.get())
11892  except:
11893  StopBodeEntry.delete(0,"end")
11894  StopBodeEntry.insert(0,10000)
11895  EndFreq = 10000
11896  try:
11897  BeginFreq = float(StartBodeEntry.get())
11898  except:
11899  StartBodeEntry.delete(0,"end")
11900  StartBodeEntry.insert(0,100)
11901  BeginFreq = 100
11902  try:
11903  Phasecenter = int(PhCenBodeEntry.get())
11904  RelPhaseCenter.set(Phasecenter)
11905  except:
11906  PhCenBodeEntry.delete(0,"end")
11907  PhCenBodeEntry.insert(0,0)
11908  RelPhaseCenter.set(0)
11909  Phasecenter = 0
11910  try:
11911  Impedcenter = int(ImCenBodeEntry.get())
11912  ImpedanceCenter.set(Impedcenter)
11913  except:
11914  ImCenBodeEntry.delete(0,"end")
11915  ImCenBodeEntry.insert(0,0)
11916  ImpedanceCenter.set(0)
11917  Impedcenter = 0
11918  #
11919  HalfSAMPLErate = SAMPLErate/2
11920  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
11921  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
11922  CurrentFreqX = X0LBP + 14
11923  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
11924  # Vertical conversion factors (level dBs) and border limits
11925  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
11926  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
11927  Ymin = Y0TBP # Minimum position of screen grid (top)
11928  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
11929  Yphconv = float(GRHBP) / 360 # degrees per pixel
11930  Yp = float(Y0TBP) + Yphconv + 180
11931  x1 = X0LBP + 14
11932  # Horizontal conversion factors (frequency Hz) and border limits
11933  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
11934  LogFStop = math.log10(EndFreq)
11935  try:
11936  LogFStart = math.log10(BeginFreq)
11937  except:
11938  LogFStart = 0.0
11939  LogFpixel = (LogFStop - LogFStart) / GRWBP
11940  TAFline = []
11941  TBFline = []
11942  TAPline = []
11943  TBPline = []
11944  TIARline = []
11945  TIAXline = []
11946  TIAMagline = []
11947  TIAAngline = []
11948  TBPMline = []
11949  PeakdbA = -200
11950  PeakdbB = -200
11951  PeakMdb = -200
11952  n = 0
11953  for n in range(len(FSweepAdB)): # while n < len(FStep):
11954  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
11955  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
11956  else:
11957  F = FBins[int(FStep[0])]
11958  if F >= BeginFreq and F <= EndFreq:
11959  if HScaleBP.get() == 1:
11960  try:
11961  LogF = math.log10(F) # convet to log Freq
11962  x = x1 + (LogF - LogFStart)/LogFpixel
11963  except:
11964  x = x1
11965  else:
11966  x = x1 + (F - BeginFreq) / Fpixel
11967  CurrentFreqX = x
11968  if ShowCA_VdB.get() == 1:
11969  TAFline.append(int(x + 0.5))
11970  try:
11971  dbA = (10 * math.log10(float(FSweepAdB[n])) + 17) # Convert power to DBs, except for log(0) error
11972  ya = Yc - Yconv * dbA # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11973  except:
11974  ya = Ymax
11975  if (ya < Ymin):
11976  ya = Ymin
11977  if (ya > Ymax):
11978  ya = Ymax
11979  if dbA > PeakdbA:
11980  PeakdbA = dbA
11981  PeakyA = int(ya + 0.5)
11982  PeakxA = int(x + 0.5)
11983  PeakfreqA = F
11984  TAFline.append(int(ya + 0.5))
11985  if ShowCB_VdB.get() == 1:
11986  TBFline.append(int(x + 0.5))
11987  try:
11988  dbB = (10 * math.log10(float(FSweepBdB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11989  yb = Yc - Yconv * dbB
11990  except:
11991  yb = Ymax
11992  if (yb < Ymin):
11993  yb = Ymin
11994  if (yb > Ymax):
11995  yb = Ymax
11996  if dbB > PeakdbB:
11997  PeakdbB = dbB
11998  PeakyB = int(yb + 0.5)
11999  PeakxB = int(x + 0.5)
12000  PeakfreqB = F
12001  TBFline.append(int(yb + 0.5))
12002  if ShowCA_P.get() == 1:
12003  TAPline.append(int(x + 0.5))
12004  RelPhase = FSweepAPh[n] - FSweepBPh[n]
12005  RelPhase = RelPhase - Phasecenter
12006  if RelPhase > 180:
12007  RelPhase = RelPhase - 360
12008  elif RelPhase < -180:
12009  RelPhase = RelPhase + 360
12010  if Two_X_Sample.get() == 0:
12011  PhErr = 0.0018 * F # calculate phase error due half sample period offset
12012  RelPhase = RelPhase + PhErr - PhaseOffset1x
12013  else:
12014  RelPhase = RelPhase - PhaseOffset2x
12015  ya = Yp - Yphconv * RelPhase
12016  TAPline.append(int(ya + 0.5))
12017  if ShowCB_P.get() == 1:
12018  TBPline.append(int(x + 0.5))
12019  RelPhase = FSweepBPh[n] - FSweepAPh[n]
12020  RelPhase = RelPhase - Phasecenter
12021  if RelPhase > 180:
12022  RelPhase = RelPhase - 360
12023  elif RelPhase < -180:
12024  RelPhase = RelPhase + 360
12025  if Two_X_Sample.get() == 0:
12026  PhErr = 0.0018 * F # calculate phase error due half sample period offset
12027  RelPhase = RelPhase - PhErr - PhaseOffset1x
12028  else:
12029  RelPhase = RelPhase - PhaseOffset2x
12030  ya = Yp - Yphconv * RelPhase
12031  TBPline.append(int(ya + 0.5))
12032  if ShowMathBP.get() > 0:
12033  TBPMline.append(int(x + 0.5))
12034  dbA = (10 * math.log10(float(FSweepAdB[n])) + 17) # Convert power to DBs, except for log(0) error
12035  dbB = (10 * math.log10(float(FSweepBdB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12036  if ShowMathBP.get() == 1:
12037  MdB = dbA - dbB
12038  elif ShowMathBP.get() == 2:
12039  MdB = dbB - dbA
12040  yb = Yc - Yconv * MdB
12041  if (yb < Ymin):
12042  yb = Ymin
12043  if (yb > Ymax):
12044  yb = Ymax
12045  if MdB > PeakMdb:
12046  PeakMdb = MdB
12047  PeakyM = int(yb + 0.5)
12048  PeakxM = int(x + 0.5)
12049  PeakfreqM = F
12050  TBPMline.append(int(yb + 0.5))
12051 # draw impedance trace if necessary
12052  if NetworkScreenStatus.get() > 0:
12053  ycenter = Y0TBP + (GRHBP/2)
12054  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
12055  n = 0
12056  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
12057  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
12058  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
12059  else:
12060  F = FBins[int(FStep[0])]
12061  if F >= BeginFreq and F <= EndFreq:
12062  if HScaleBP.get() == 1:
12063  try:
12064  LogF = math.log10(F) # convet to log Freq
12065  x = x1 + (LogF - LogFStart)/LogFpixel
12066  except:
12067  x = x1
12068  else:
12069  x = x1 + (F - BeginFreq) / Fpixel
12070  if Show_Rseries.get() == 1:
12071  TIARline.append(int(x + 0.5))
12072  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
12073  if (y1 < Ymin):
12074  y1 = Ymin
12075  if (y1 > Ymax):
12076  y1 = Ymax
12077  TIARline.append(y1)
12078  if Show_Xseries.get() == 1:
12079  TIAXline.append(int(x + 0.5))
12080  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
12081  if (y1 < Ymin):
12082  y1 = Ymin
12083  if (y1 > Ymax):
12084  y1 = Ymax
12085  TIAXline.append(y1)
12086  if Show_Magnitude.get() == 1:
12087  TIAMagline.append(int(x + 0.5))
12088  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
12089  if (y1 < Ymin):
12090  y1 = Ymin
12091  if (y1 > Ymax):
12092  y1 = Ymax
12093  TIAMagline.append(y1)
12094  if Show_Angle.get() == 1:
12095  TIAAngline.append(int(x + 0.5))
12096  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
12097  if (y1 < Ymin):
12098  y1 = Ymin
12099  if (y1 > Ymax):
12100  y1 = Ymax
12101  TIAAngline.append(y1)
12102 #
12103 def MakeBodeScreen(): # Update the screen with traces and text
12104  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
12105  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12106  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12107  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12108  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12109  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12110  global COLORgrid # The colors
12111  global COLORsignalband, COLORtext
12112  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
12113  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
12114  global DBdivindexBP # Index value
12115  global DBdivlist # dB per division list
12116  global DBlevelBP # Reference level
12117  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
12118  global X0LBP # Left top X value
12119  global Y0TBP # Left top Y value
12120  global GRWBP # Screenwidth
12121  global GRHBP # Screenheight
12122  global FontSize
12123  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
12124  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
12125  global SMPfft # number of FFT samples
12126  global StartBodeEntry, StopBodeEntry
12127  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
12128  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
12129  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
12130  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
12131  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
12132  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
12133  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
12134  global TAPRline, TBPRline
12135  global TRACEaverage # Number of traces for averageing
12136  global FreqTraceMode # 1 normal 2 max 3 average
12137  global Vdiv, ResScale # Number of vertical divisions
12138  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
12139  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
12140 
12141  # Delete all items on the screen
12142  MarkerFreqNum = 0
12143  Bodeca.delete(ALL) # remove all items
12144 
12145  try:
12146  EndFreq = float(StopBodeEntry.get())
12147  except:
12148  StopBodeEntry.delete(0,"end")
12149  StopBodeEntry.insert(0,10000)
12150  EndFreq = 10000
12151  try:
12152  BeginFreq = float(StartBodeEntry.get())
12153  except:
12154  StartBodeEntry.delete(0,"end")
12155  StartBodeEntry.insert(0,100)
12156  BeginFreq = 100
12157  try:
12158  Phasecenter = int(PhCenBodeEntry.get())
12159  RelPhaseCenter.set(Phasecenter)
12160  except:
12161  PhCenBodeEntry.delete(0,"end")
12162  PhCenBodeEntry.insert(0,0)
12163  RelPhaseCenter.set(0)
12164  Phasecenter = 0
12165  try:
12166  Impedcenter = int(ImCenBodeEntry.get())
12167  ImpedanceCenter.set(Impedcenter)
12168  except:
12169  ImCenBodeEntry.delete(0,"end")
12170  ImCenBodeEntry.insert(0,0)
12171  ImpedanceCenter.set(0)
12172  Impedcenter = 0
12173  #
12174  # Draw horizontal grid lines
12175  i = 0
12176  x1 = X0LBP + 14
12177  x2 = x1 + GRWBP
12178  while (i <= Vdiv.get()):
12179  y = Y0TBP + i * GRHBP/Vdiv.get()
12180  Dline = [x1,y,x2,y]
12181  if i == 0 or i == Vdiv.get():
12182  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12183  else:
12184  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12185  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
12186  Vaxis_label = str(Vaxis_value)
12187  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
12188  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
12189  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
12190  Vaxis_label = str(Vaxis_value)
12191  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
12192  if NetworkScreenStatus.get() > 0:
12193  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
12194  RperDiv = float(ResScale.get())
12195  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
12196  if Vaxis_value > 500 or Vaxis_value < -500:
12197  Vaxis_value = Vaxis_value/1000.0
12198  if Vaxis_value > 5 or Vaxis_value < -5:
12199  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
12200  else:
12201  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
12202  else:
12203  Vaxis_label = ' {0:.0f} '.format(Vaxis_value)
12204  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
12205  i = i + 1
12206  # Draw vertical grid lines
12207  i = 0
12208  y1 = Y0TBP
12209  y2 = Y0TBP + GRHBP
12210  if HScaleBP.get() == 1:
12211  F = 1.0
12212  LogFStop = math.log10(EndFreq)
12213  try:
12214  LogFStart = math.log10(BeginFreq)
12215  except:
12216  LogFStart = 0.0
12217  LogFpixel = (LogFStop - LogFStart) / GRWBP
12218  # draw left and right edges
12219  while F <= EndFreq:
12220  if F >= BeginFreq:
12221  try:
12222  LogF = math.log10(F) # convet to log Freq
12223  x = x1 + (LogF - LogFStart)/LogFpixel
12224  except:
12225  x = x1
12226  Dline = [x,y1,x,y2]
12227  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
12228  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12229  axis_label = str(F)
12230  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
12231  else:
12232  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12233 
12234  if F < 10:
12235  F = F + 1
12236  elif F < 100:
12237  F = F + 10
12238  elif F < 1000:
12239  F = F + 100
12240  elif F < 1000:
12241  F = F + 100
12242  elif F < 10000:
12243  F = F + 1000
12244  elif F < 100000:
12245  F = F + 10000
12246  elif F < 200000:
12247  F = F + 10000
12248  else:
12249  Freqdiv = (EndFreq - BeginFreq) / 10
12250  while (i < 11):
12251  x = x1 + i * GRWBP/10
12252  Dline = [x,y1,x,y2]
12253  if i == 0 or i == 10:
12254  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12255  else:
12256  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12257  axis_value = BeginFreq + (i * Freqdiv)
12258  axis_label = str(axis_value)
12259  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
12260  i = i + 1
12261  # Draw X - Y cursors if needed
12262  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
12263  LogFStop = math.log10(EndFreq)
12264  try:
12265  LogFStart = math.log10(BeginFreq)
12266  except:
12267  LogFStart = 0.0
12268  LogFpixel = (LogFStop - LogFStart) / GRWBP
12269  if ShowBPCur.get() > 0:
12270  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
12271  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
12272  # Horizontal conversion factors (frequency Hz) and border limits
12273  if HScaleBP.get() == 1:
12274  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
12275  else:
12276  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
12277  XFString = ' {0:.2f} '.format(xfreq)
12278  V_label = XFString + " Hz"
12279  Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
12280 #
12281  if ShowBdBCur.get() > 0:
12282  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
12283  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
12284  if ShowBdBCur.get() == 1:
12285  # Vertical conversion factors (level dBs) and border limits
12286  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
12287  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
12288  yvdB = ((Yc-BdBCursor)/Yconv)
12289  VdBString = ' {0:.1f} '.format(yvdB)
12290  V_label = VdBString + " dBV"
12291  else:
12292  # Vertical conversion factors (level degrees) and border limits
12293  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
12294  Yc = float(Y0TBP) # Yc is the 180 degree position
12295  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
12296  VdBString = ' {0:.1f} '.format(yvdB)
12297  V_label = VdBString + " Deg"
12298  Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
12299  #
12300  SmoothBool = SmoothCurvesBP.get()
12301  # Draw traces
12302  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
12303  # Write the trace CHA
12304  if OverRangeFlagA == 1:
12305  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12306  else:
12307  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12308  if ShowMarkerBP.get() == 1:
12309  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
12310  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
12311  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
12312  # Write the trace CHB
12313  if OverRangeFlagB == 1:
12314  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12315  else:
12316  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12317  if ShowMarkerBP.get() == 1:
12318  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
12319  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
12320  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
12321  # Write the phase trace A-B
12322  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12323  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
12324  # Write the phase trace A-B
12325  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12326  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
12327  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12328  if ShowMarkerBP.get() == 1:
12329  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
12330  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
12331  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
12332  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12333  if ShowMarkerBP.get() == 1:
12334  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
12335  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
12336  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
12337  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12338  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
12339  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12340  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
12341  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12342  if ShowMarkerBP.get() == 1:
12343  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
12344  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
12345  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
12346  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12347  if ShowMarkerBP.get() == 1:
12348  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
12349  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
12350  if Show_Rseries.get() == 1 and len(TIARline) > 4:
12351  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12352  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
12353  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12354  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
12355  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12356  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
12357  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12358  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
12359  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12360  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
12361  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12362  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
12363  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12364  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
12365  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12366 
12367  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
12368  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
12369  if HScaleBP.get() == 1:
12370  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
12371  else:
12372  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
12373  XFString = ' {0:.0f} '.format(xfreq)
12374  V_label = XFString + " Hz"
12375  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
12376  # General information on top of the grid
12377 
12378  txt = " Sample rate: " + str(SAMPLErate)
12379  txt = txt + " FFT samples: " + str(SMPfft)
12380 
12381  txt = txt + " " + FFTwindowname
12382 
12383  x = X0LBP
12384  y = 12
12385  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12386 
12387  # Start and stop frequency and dB/div and trace mode
12388  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
12389  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
12390  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
12391  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
12392 
12393  x = X0LBP
12394  y = Y0TBP+GRHBP+23
12395  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12396 
12397  if FreqTraceMode.get() == 1:
12398  txt ="Normal mode "
12399 
12400  if FreqTraceMode.get() == 2:
12401  txt = "Peak hold mode "
12402 
12403  if FreqTraceMode.get() == 3:
12404  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
12405 
12406  if ZEROstuffing.get() > 0:
12407  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
12408  # Runstatus and level information
12409  if (RUNstatus.get() == 0):
12410  txt = txt + " Stopped "
12411  else:
12412  if BodeDisp.get() == 1:
12413  txt = txt + " Running "
12414  else:
12415  txt = txt + " Display off "
12416  if FSweepMode.get() > 0:
12417  txt = txt + " Freq Step = " + str(LoopNum.get())
12418  x = X0LBP
12419  y = Y0TBP+GRHBP+34
12420  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12421 
12422 # Impedance analyzer routines -----
12423 def UpdateIAAll(): # Update Data, trace and screen
12424  global FFTBuffA, FFTBuffB
12425  global SMPfft
12426 
12427  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
12428  return
12429 
12430  MakeIATrace() # Update the traces
12431  UpdateIAScreen() # Update the screen
12432 
12433 def UpdateIATrace(): # Update trace and screen
12434  MakeIATrace() # Update traces
12435  UpdateIAScreen() # Update the screen
12436 
12437 def UpdateIAScreen(): # Update screen with trace and text
12438  MakeIAScreen() # Update the screen
12439  root.update() # Activate updated screens
12440 #
12442 
12443 # Input Variables
12444  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
12445  #(VZ/VA)from vector voltmeter
12446  # global VVangle # angle in degrees between VZ and VA
12447  global RsystemEntry # resistance of series resistor or power divider
12448 # Computed outputs
12449  # global VVangleCosine # cosine of vector voltmeter angle
12450  global ImpedanceMagnitude # in ohms
12451  global ImpedanceAngle # in degrees
12452  global ImpedanceRseries, ImpedanceXseries # in ohms
12453  global IA_Ext_Conf
12454 
12455  DEG2RAD = (math.pi / 180.0)
12456  SMALL = 1E-20
12457  try:
12458  ResValue = float(RsystemEntry.get())
12459  except:
12460  ResValue = 1000.0
12461 
12462  VA = math.pow(10,(PeakdbA/20))
12463  VB = math.pow(10,(PeakdbB/20))
12464  VVangleCosine = math.cos(math.radians(PeakRelPhase))
12465  if IA_Ext_Conf.get() == 1:
12466  VAB = math.pow(10,(PeakdbAB/20))
12467  VZ = VAB # VZ=VA-VB
12468  # VI = VB
12469  else:
12470  VZ = VB # VZ=VB
12471  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
12472  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
12473  Za = ResValue * VA / VI
12474  ImpedanceRseries = Za * costheta - ResValue
12475  ImpedanceMagnitude = ResValue * VZ / VI
12476  ImpedanceXseries = math.sqrt(ImpedanceMagnitude**2 - ImpedanceRseries**2)
12477 
12478  if(PeakRelPhase < 0.0):
12479  ImpedanceXseries = -ImpedanceXseries
12480  if IA_Ext_Conf.get() == 1:
12481  ImpedanceRseries = -ImpedanceRseries
12482  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
12483 #
12484 def MakeIATrace(): # Update the grid and trace
12485  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
12486  global FFTmemoryB, FFTresultB
12487  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
12488  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
12489  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
12490  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
12491  global DBdivindex # Index value
12492  global DBdivlist # dB per division list
12493  global DBlevel # Reference level
12494  global GRHIA # Screenheight
12495  global GRWIA # Screenwidth
12496  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
12497  global STARTsample, STOPsample, LoopNum, FSweepMode
12498  global TRACEmode, Two_X_Sample, IA_Ext_Conf
12499  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
12500  global Vdiv # Number of vertical divisions
12501  global X0LIA # Left top X value
12502  global Y0TIA # Left top Y value
12503  global ImpedanceMagnitude # in ohms
12504  global ImpedanceAngle # in degrees
12505  global ImpedanceRseries, ImpedanceXseries # in ohms
12506 
12507  # Set the TRACEsize variable
12508  TRACEsize = len(FFTresultA) # Set the trace length
12509  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
12510  # Horizontal conversion factors (frequency Hz) and border limits
12511  STARTsample = 0 # First sample in FFTresult[] that is used
12512  STARTsample = int(math.ceil(STARTsample)) # First within screen range
12513  if Two_X_Sample.get() == 0:
12514  STOPsample = 45000 / Fsample # Last sample in FFTresult[] that is used
12515  else:
12516  STOPsample = 90000 / Fsample
12517  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
12518 #
12519  try:
12520  GainCorrection = float(eval(GainCorEntry.get()))
12521  except:
12522  GainCorEntry.delete(0,END)
12523  GainCorEntry.insert(0, GainCorrection)
12524 
12525  try:
12526  PhaseCorrection = float(eval(PhaseCorEntry.get()))
12527  except:
12528  PhaseCorEntry.delete(0,END)
12529  PhaseCorEntry.insert(0, PhaseCorrection)
12530 
12531  MAXsample = TRACEsize # Just an out of range check
12532  if STARTsample > (MAXsample - 1):
12533  STARTsample = MAXsample - 1
12534 
12535  if STOPsample > MAXsample:
12536  STOPsample = MAXsample
12537 
12538  n = STARTsample
12539  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
12540  PeakphaseA = PhaseA[n]
12541  PeakphaseB = PhaseB[n]
12542  #PeakphaseAB = PhaseAB[n]
12543  PeakSample = n
12544 
12545  PeakdbA = (10 * math.log10(float(FFTresultA[n])) + 17)
12546  PeakdbB = (10 * math.log10(float(FFTresultB[n])) + 17)
12547  PeakMdb = PeakdbA - PeakdbB
12548  if IA_Ext_Conf.get() == 1:
12549  PeakdbAB = (10 * math.log10(float(FFTresultAB[n])) + 17)
12550  while n <= STOPsample:
12551  F = n * Fsample
12552  try:
12553  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
12554  except:
12555  dbA = -200
12556  if dbA > PeakdbA:
12557  PeakdbA = dbA
12558  PeakfreqA = F
12559  PeakphaseA = PhaseA[n]
12560  PeakSample = n
12561 
12562  try:
12563  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12564  except:
12565  dbB = -200
12566  if dbB > PeakdbB:
12567  PeakdbB = dbB
12568  PeakfreqB = F
12569  PeakphaseB = PhaseB[n]
12570 
12571  if IA_Ext_Conf.get() == 1:
12572  try:
12573  dbAB = (10 * math.log10(float(FFTresultAB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12574  except:
12575  dbAB = -200
12576  if dbAB > PeakdbAB:
12577  PeakdbAB = dbAB
12578  PeakphaseAB = PhaseAB[n]
12579  RelPhase = PhaseA[n]-PhaseB[n]
12580  if RelPhase > 180:
12581  RelPhase = RelPhase - 360
12582  elif RelPhase < -180:
12583  RelPhase = RelPhase + 360
12584  if Two_X_Sample.get() == 0:
12585  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
12586  RelPhase = RelPhase + PhErr - 12.0
12587  else:
12588  RelPhase = RelPhase - 9.0
12589  n = n + 1
12590  if IA_Ext_Conf.get() == 1:
12591  PeakRelPhase = PeakphaseAB-PeakphaseA
12592  else:
12593  PeakRelPhase = PeakphaseB-PeakphaseA
12594 #
12595  if PeakRelPhase > 180:
12596  PeakRelPhase = PeakRelPhase - 360
12597  elif PeakRelPhase < -180:
12598  PeakRelPhase = PeakRelPhase + 360
12599  if Two_X_Sample.get() == 0:
12600  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
12601  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
12602  else:
12603  PeakRelPhase = PeakRelPhase + PhaseCorrection
12604  PeakdbB = PeakdbB + GainCorrection
12605  DoImpedance()
12606 
12608 def MakeIAScreen(): # Update the screen with traces and text
12609  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
12610  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12611  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
12612  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12613  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12614  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12615  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry
12616  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
12617  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
12618  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
12619  global ResScale, DisplaySeries # Ohms per div
12620  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
12621  global X0LIA # Left top X value
12622  global Y0TIA # Left top Y value
12623  global GRWIA # Screenwidth
12624  global GRHIA # Screenheight
12625  global FontSize
12626  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
12627  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
12628  global SMPfft # number of FFT samples
12629  global TRACEaverage # Number of traces for averageing
12630  global FreqTraceMode # 1 normal 2 max 3 average
12631  global Vdiv # Number of vertical divisions
12632  global ImpedanceMagnitude # in ohms
12633  global ImpedanceAngle # in degrees
12634  global ImpedanceRseries, ImpedanceXseries # in ohms
12635  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
12636 
12637  if LoopNum.get() > 1:
12638  if NetworkScreenStatus.get() > 0:
12639  NSweepSeriesR.append(ImpedanceRseries)
12640  NSweepSeriesX.append(ImpedanceXseries)
12641  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
12642  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
12643  # Delete all items on the screen
12644  IAca.delete(ALL) # remove all items
12645  SmoothBool = SmoothCurvesBP.get()
12646  # Draw circular grid lines
12647  i = 1
12648  xcenter = GRWIA/2
12649  ycenter = GRHIA/2
12650  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
12651  OhmsperPixel = float(ResScale.get())/Radius
12652  TRadius = Radius * Vdiv.get() # 5
12653  x1 = X0LIA
12654  x2 = X0LIA + GRWIA
12655  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
12656  while (i <= Vdiv.get()):
12657  x0 = xcenter - ( i * Radius )
12658  x1 = xcenter + ( i * Radius )
12659  y0 = ycenter - ( i * Radius )
12660  y1 = ycenter + ( i * Radius )
12661  ResTxt = float(ResScale.get()) * i
12662  IAca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
12663  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
12664  IAca.create_text(xright, y0, text=str(ResTxt), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
12665  #
12666  i = i + 1
12667  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
12668  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
12669  RAngle = math.radians(45)
12670  y = TRadius*math.sin(RAngle)
12671  x = TRadius*math.cos(RAngle)
12672  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
12673  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
12674  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
12675  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
12676  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
12677  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
12678 # Draw traces
12679  # Add saved line if there
12680  if IASweepSaved.get() > 0:
12681  if len(TIAMRline) > 4:
12682  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12683 #
12684  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
12685  if x1 > 1500:
12686  x1 = xright
12687  elif x1 < -500:
12688  x1 = xcenter - xright
12689  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, width=TRACEwidth.get())
12690  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
12691  if y1 > 1500:
12692  y1 = xright
12693  elif y1 < -500:
12694  y1 = ycenter - xright
12695  xmag = x1
12696  ymag = y1
12697  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, width=TRACEwidth.get())
12698  MagRadius = ImpedanceMagnitude / OhmsperPixel
12699  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
12700  if y1 > 1500:
12701  y1 = xright
12702  elif y1 < -500:
12703  y1 = ycenter - xright
12704  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
12705  if x1 > 1500:
12706  x1 = xright
12707  elif x1 < -500:
12708  x1 = xcenter - xright
12709  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, width=TRACEwidth.get())
12710 #
12711  TIAMline = []
12712  if len(NSweepSeriesMag) > 2:
12713  index = 0
12714  while index < len(NSweepSeriesMag):
12715  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
12716  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
12717  if y1 > 1500:
12718  y1 = xright
12719  elif y1 < -500:
12720  y1 = ycenter - xright
12721  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
12722  if x1 > 1500:
12723  x1 = xright
12724  elif x1 < -500:
12725  x1 = xcenter - xright
12726  TIAMline.append(x1)
12727  TIAMline.append(y1)
12728  index = index + 1
12729  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12730 # display warning if input out of range
12731  if OverRangeFlagA == 1:
12732  x = X0LIA+GRWIA+10
12733  y = Y0TIA+GRHIA-40
12734  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
12735  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
12736  if OverRangeFlagB == 1:
12737  x = X0LIA+GRWIA+10
12738  y = Y0TIA+GRHIA-10
12739  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
12740  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
12741  # General information on top of the grid
12742 
12743  txt = " Sample rate: " + str(SAMPLErate)
12744  txt = txt + " FFT samples: " + str(SMPfft)
12745 
12746  txt = txt + " " + FFTwindowname
12747 
12748  x = X0LIA
12749  y = 12
12750  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12751  #
12752  x = X0LIA + GRWIA + 4
12753  y = 24
12754  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
12755  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12756  y = y + 24
12757  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
12758  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12759  y = y + 24
12760  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
12761  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12762  y = y + 24
12763  txt = "Impedance Magnitude"
12764  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12765  y = y + 24
12766  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
12767  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12768  y = y + 24
12769  txt = "Impedance Angle"
12770  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12771  y = y + 24
12772  txt = ' {0:.1f} '.format(ImpedanceAngle)
12773  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12774  y = y + 24
12775  txt = "Impedance R series"
12776  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12777  y = y + 24
12778  txt = ' {0:.1f} '.format(ImpedanceRseries)
12779  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12780  y = y + 24
12781  txt = "Impedance X series"
12782  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12783  y = y + 24
12784  txt = ' {0:.1f} '.format(ImpedanceXseries)
12785  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12786 #
12787  if ImpedanceXseries < 0: # calculate series capacitance
12788  y = y + 24
12789  try:
12790  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
12791  except:
12792  Cseries = 0
12793  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
12794  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
12795  Cparallel = Cparallel * 1E6 # convert to micro Farads
12796  Rparallel = ImpedanceRseries * (1+Qseries**2)
12797  Cseries = Cseries * 1E6 # convert to micro Farads
12798  if DisplaySeries.get() == 0:
12799  txt = "Series Capacitance"
12800  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12801  y = y + 20
12802  if Cseries < 1:
12803  Cseries = Cseries * 1E3
12804  if Cseries < 1:
12805  Cseries = Cseries * 1E3
12806  txt = ' {0:.1f} '.format(Cseries) + "pF"
12807  else:
12808  txt = ' {0:.3f} '.format(Cseries) + "nF"
12809  else:
12810  txt = ' {0:.3f} '.format(Cseries) + "uF"
12811  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12812  else:
12813  txt = "Parallel"
12814  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12815  y = y + 20
12816  if Cparallel < 1:
12817  Cparallel = Cparallel * 1E3
12818  if Cparallel < 1:
12819  Cparallel = Cparallel * 1E3
12820  txt = "Capacitance " + ' {0:.1f} '.format(Cparallel) + "pF"
12821  else:
12822  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "nF"
12823  else:
12824  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
12825  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12826  y = y + 20
12827  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
12828  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12829  y = y + 20
12830  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
12831  txt = 'D = {0:.2f} '.format(dissp) + " %"
12832  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12833 
12834  elif ImpedanceXseries > 0: # calculate series inductance
12835  y = y + 24
12836  try:
12837  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
12838  except:
12839  Lseries = 0
12840  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
12841  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
12842  Lparallel = Lparallel * 1E3 # convert to millihenry
12843  Rparallel = ImpedanceRseries * (1+Qseries**2)
12844  Lseries = Lseries * 1E3 # in millihenry
12845  if DisplaySeries.get() == 0:
12846  txt = "Series Inductance"
12847  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12848  y = y + 22
12849  if Lseries < 1:
12850  Lseries = Lseries * 1E3
12851  txt = ' {0:.2f} '.format(Lseries) + "uH"
12852  else:
12853  txt = ' {0:.2f} '.format(Lseries) + "mH"
12854  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12855  else:
12856  txt = "Parallel"
12857  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12858  y = y + 20
12859  if Lparallel < 1:
12860  Lparallel = Lparallel * 1E3
12861  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "uH"
12862  else:
12863  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
12864  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12865  y = y + 20
12866  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
12867  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12868  y = y + 20
12869  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
12870  txt = 'Q = {0:.2f} '.format(qf)
12871  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12872  # Start and stop frequency and trace mode
12873  if Two_X_Sample.get() == 0:
12874  txt = "0.0 to 45000 Hz"
12875  else:
12876  txt = "0.0 to 90000 Hz"
12877  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
12878 
12879  x = X0LIA
12880  y = Y0TIA+GRHIA-13
12881  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12882  txt = " "
12883  if FreqTraceMode.get() == 1:
12884  txt ="Normal mode "
12885 
12886  if FreqTraceMode.get() == 2:
12887  txt = "Peak hold mode "
12888 
12889  if FreqTraceMode.get() == 3:
12890  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
12891 
12892  if ZEROstuffing.get() > 0:
12893  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
12894  # Runstatus and level information
12895  if (RUNstatus.get() == 0):
12896  txt = txt + " Stopped "
12897  else:
12898  txt = txt + " Running "
12899  y = Y0TIA+GRHIA
12900  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12901 #
12902 def IACaresize(event):
12903  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
12904 
12905  CANVASwidthIA = event.width - 4
12906  CANVASheightIA = event.height - 4
12907  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
12908  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
12909  UpdateIAAll()
12910 #
12911 # ================ Make IA Window ==========================
12913  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
12914  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode
12915  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
12916  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev
12917  global NetworkScreenStatus, IASweepSaved
12918 
12919  if IAScreenStatus.get() == 0:
12920  IAScreenStatus.set(1)
12921  IADisp.set(1)
12922  IACheckBox()
12923  CutDC.set(1) # set to remove DC
12924  CANVASwidthIA = 170 + GRWIA + 2 * X0LIA # The canvas width
12925  CANVASheightIA = GRHIA + Y0TIA + 10 # The canvas height
12926  AWGAMode.set(0) # Set AWG A to SVMI
12927  AWGAShape.set(1) # Set Shape to Sine
12928  AWGBMode.set(2) # Set AWG B to Hi-Z
12929  AWGSync.set(1) # Set AWGs to run sync
12930  iawindow = Toplevel()
12931  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
12932  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
12933  frame2iar = Frame(iawindow, borderwidth=5, relief=RIDGE)
12934  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
12935 
12936  frame2ia = Frame(iawindow, borderwidth=5, relief=RIDGE)
12937  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
12938 
12939  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
12940  IAca.bind("<Configure>", IACaresize)
12941  IAca.bind("<Return>", DoNothing)
12942  IAca.bind("<space>", onCanvasSpaceBar)
12943  IAca.pack(side=TOP, expand=YES, fill=BOTH)
12944 
12945  # menu buttons
12946  # right side drop down menu buttons
12947  dropmenu = Frame( frame2iar )
12948  dropmenu.pack(side=TOP)
12949  # File menu
12950  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
12951  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
12952  IAFilemenu["menu"] = IAFilemenu.menu
12953  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
12954  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
12955  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
12956  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
12957  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
12958  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
12959  IAFilemenu.menu.add_command(label="Help", command=BHelp)
12960  IAFilemenu.pack(side=LEFT, anchor=W)
12961  #
12962  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
12963  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
12964  IAOptionmenu["menu"] = IAOptionmenu.menu
12965  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
12966  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
12967  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
12968  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
12969  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
12970  if DeBugMode == 1:
12971  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
12972  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
12973  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
12974  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
12975  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
12976  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
12977  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
12978  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
12979  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
12980  IAOptionmenu.pack(side=LEFT, anchor=W)
12981  #
12982  rsemenu = Frame( frame2iar )
12983  rsemenu.pack(side=TOP)
12984  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
12985  rseb2.pack(side=RIGHT)
12986  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
12987  rseb3.pack(side=RIGHT)
12988  #
12989  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
12990  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
12991  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
12992  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
12993  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
12994  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
12995  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
12996  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
12997  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
12998  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
12999  IAFFTwindmenu.pack(side=TOP)
13000  #
13001  smpmenu = Frame( frame2iar )
13002  smpmenu.pack(side=TOP)
13003  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
13004  smpb1.pack(side=LEFT)
13005  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
13006  smpb2.pack(side=LEFT)
13007  # Temp set source resistance to 1000
13008  rsystem = Frame( frame2iar )
13009  rsystem.pack(side=TOP)
13010  rsystemlab = Label(rsystem, text="Ext Res")
13011  rsystemlab.pack(side=LEFT, anchor=W)
13012  RsystemEntry = Entry(rsystem, width=7)
13013  RsystemEntry.bind('<MouseWheel>', onTextScroll)
13014  RsystemEntry.bind('<Key>', onTextKey)
13015  RsystemEntry.pack(side=LEFT, anchor=W)
13016  RsystemEntry.delete(0,"end")
13017  RsystemEntry.insert(4,1000)
13018  # Res Sacle Spinbox
13019  ressb = Frame( frame2iar )
13020  ressb.pack(side=TOP)
13021  reslab = Label(ressb, text="Ohms/div ")
13022  reslab.pack(side=LEFT)
13023  ResScale = Spinbox(ressb, width=7, values=ResScalediv)
13024  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
13025  ResScale.pack(side=LEFT)
13026  ResScale.delete(0,"end")
13027  ResScale.insert(0,500)
13028  #
13029  GainCor = Frame( frame2iar )
13030  GainCor.pack(side=TOP)
13031  GainCorlab = Label(GainCor, text="Gain Cor dB")
13032  GainCorlab.pack(side=LEFT, anchor=W)
13033  GainCorEntry = Entry(GainCor, width=7)
13034  GainCorEntry.bind('<MouseWheel>', onTextScroll)
13035  GainCorEntry.bind('<Key>', onTextKey)
13036  GainCorEntry.pack(side=LEFT, anchor=W)
13037  GainCorEntry.delete(0,"end")
13038  GainCorEntry.insert(4,0.0)
13039  #
13040  PhaseCor = Frame( frame2iar )
13041  PhaseCor.pack(side=TOP)
13042  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
13043  PhaseCorlab.pack(side=LEFT, anchor=W)
13044  PhaseCorEntry = Entry(PhaseCor, width=7)
13045  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
13046  PhaseCorEntry.bind('<Key>', onTextKey)
13047  PhaseCorEntry.pack(side=LEFT, anchor=W)
13048  PhaseCorEntry.delete(0,"end")
13049  PhaseCorEntry.insert(4,0.0)
13050  #
13051  srclab = Label(frame2iar, text="Source")
13052  srclab.pack(side=TOP)
13053  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
13054  extsrc1.pack(side=TOP)
13055  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
13056  extsrc2.pack(side=TOP)
13057 
13058  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
13059  dismiss1button.pack(side=TOP)
13060  # add ADI logo
13061  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
13062  ADI1.pack(side=TOP)
13063 #
13065  global iawindow, IAScreenStatus, IAca, IADisp
13066 
13067  IAScreenStatus.set(0)
13068  IADisp.set(0)
13069  IACheckBox()
13070  iawindow.destroy()
13071 #
13073  global TIAMline, TIAMRline, IASweepSaved
13074 
13075  if IASweepSaved.get() > 0:
13076  TIAMRline = TIAMline
13077 #
13079  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
13080  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
13081  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
13082  global NetworkScreenStatus, NqPSweepSaved
13083 
13084  if NqPScreenStatus.get() == 0:
13085  NqPScreenStatus.set(1)
13086  NqPDisp.set(1)
13087  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
13088  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
13089  nqpwindow = Toplevel()
13090  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
13091  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
13092  #frame2iar = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13093  #frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13094 
13095  frame2nqp = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13096  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
13097 
13098  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
13099  NqPca.bind("<Configure>", NqPCaresize)
13100  NqPca.bind("<Return>", DoNothing)
13101  NqPca.bind("<space>", onCanvasSpaceBar)
13102  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
13103 #
13105  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
13106 
13107  NqPScreenStatus.set(0)
13108  NqPDisp.set(0)
13109  nqpwindow.destroy()
13110 #
13111 def NqPCaresize(event):
13112  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
13113 
13114  CANVASwidthNqP = event.width - 4
13115  CANVASheightNqP = event.height - 4
13116  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
13117  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
13118  UpdateNqPAll()
13119 
13122  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
13123  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
13124  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
13125  global Vdiv, FBins, FStep
13126  global FontSize
13127 
13128  # Delete all items on the canvas
13129  NqPca.delete(ALL) # remove all items
13130  SmoothBool = SmoothCurvesBP.get()
13131  # Draw circular grid lines
13132  i = 1
13133  xcenter = GRWNqP/2
13134  ycenter = GRHNqP/2
13135  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
13136  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
13137  TRadius = Radius * Vdiv.get() # 5
13138  x1 = X0LNqP
13139  x2 = X0LNqP + GRWNqP
13140  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
13141  while (i <= Vdiv.get()):
13142  x0 = xcenter - ( i * Radius )
13143  x1 = xcenter + ( i * Radius )
13144  y0 = ycenter - ( i * Radius )
13145  y1 = ycenter + ( i * Radius )
13146  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
13147  NqPca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
13148  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
13149  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13150  #
13151  i = i + 1
13152  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
13153  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
13154  RAngle = math.radians(45)
13155  y = TRadius*math.sin(RAngle)
13156  x = TRadius*math.cos(RAngle)
13157  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13158  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13159  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
13160  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13161  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
13162  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
13163  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
13164 # Draw traces
13165  NqPline = []
13166  if len(FSweepAdB) > 4:
13167  for index in range(len(FSweepAdB)): # while n < len(FStep):
13168  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
13169  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
13170  else:
13171  F = FBins[int(FStep[0])]
13172  # Mag value
13173  dbA = (10 * math.log10(float(FSweepAdB[index])) + 17) # Convert power to DBs, except for log(0) error
13174  dbB = (10 * math.log10(float(FSweepBdB[index])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13175  if ShowMathBP.get() == 1:
13176  MdB = dbA - dbB
13177  elif ShowMathBP.get() == 2:
13178  MdB = dbB - dbA
13179  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
13180  # Phase Value
13181  RelPhase = FSweepBPh[index] - FSweepAPh[index]
13182  if RelPhase > 180:
13183  RelPhase = RelPhase - 360
13184  elif RelPhase < -180:
13185  RelPhase = RelPhase + 360
13186  if Two_X_Sample.get() == 0:
13187  PhErr = 0.0018 * F # calculate phase error due half sample period offset
13188  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
13189  else:
13190  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
13191  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
13192  if y1 > 1500:
13193  y1 = xright
13194  elif y1 < -500:
13195  y1 = ycenter - xright
13196  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
13197  if x1 > 1500:
13198  x1 = xright
13199  elif x1 < -500:
13200  x1 = xcenter - xright
13201  NqPline.append(x1)
13202  NqPline.append(y1)
13203  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13204 #
13206  global NiCScreenStatus, NiCDisp
13207  global nicwindow, NiCca, logo, SWRev
13208  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
13209  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
13210  global NetworkScreenStatus, NiCSweepSaved
13211 
13212  if NiCScreenStatus.get() == 0:
13213  NiCScreenStatus.set(1)
13214  NiCDisp.set(1)
13215  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
13216  CANVASheightNic = GRHNiC + 60 # The canvas height
13217  nicwindow = Toplevel()
13218  nicwindow.title("Nichols Plot " + SWRev + RevDate)
13219  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
13220  #frame2iar = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13221  #frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13222 
13223  frame2nic = Frame(nicwindow, borderwidth=5, relief=RIDGE)
13224  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
13225 
13226  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
13227  NiCca.bind("<Configure>", NiCCaresize)
13228  NiCca.bind("<Return>", DoNothing)
13229  NiCca.bind("<space>", onCanvasSpaceBar)
13230  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
13231 #
13233  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
13234 
13235  NiCScreenStatus.set(0)
13236  NiCDisp.set(0)
13237  nicwindow.destroy()
13238 #
13239 def NiCCaresize(event):
13240  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
13241 
13242  CANVASwidthNic = event.width - 4
13243  CANVASheightNic = event.height - 4
13244  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
13245  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
13246  UpdateNiCAll()
13247 
13250  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
13251  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
13252  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
13253  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
13254  global FontSize
13255 
13256  Ymin = Y0TNiC # Minimum position of XY grid (top)
13257  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
13258  Xmin = X0LNiC # Minimum position of XY grid (left)
13259  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
13260  try:
13261  Phasecenter = int(PhCenBodeEntry.get())
13262  RelPhaseCenter.set(Phasecenter)
13263  except:
13264  PhCenBodeEntry.delete(0,"end")
13265  PhCenBodeEntry.insert(0,0)
13266  RelPhaseCenter.set(0)
13267  Phasecenter = 0
13268  # Delete all items on the screen
13269  MarkerNum = 0
13270  SmoothBool = SmoothCurvesBP.get()
13271  NiCca.delete(ALL) # remove all items
13272  # Draw horizontal grid lines Rel Gain Magnitude
13273  i = 0
13274  x1 = X0LNiC
13275  x2 = X0TNiC = X0LNiC + GRWNiC
13276  mg_siz = GRWNiC/10.0
13277  mg_inc = mg_siz/5.0
13278  DegPerDiv = 360 / 10
13279  while (i < Vdiv.get()+1):
13280  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
13281  y = Y0TNiC + i * GRHNiC/Vdiv.get()
13282  Dline = [x1,y,x2,y]
13283  if dBaxis_value == 0:
13284  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
13285  k = 0
13286  while (k < 10):
13287  l = 1
13288  while (l < 5): # add tick marks
13289  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
13290  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13291  l = l + 1
13292  k = k + 1
13293  else:
13294  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13295  dBaxis_label = str(dBaxis_value)
13296  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
13297 
13298  i = i + 1
13299  # Draw vertical grid lines (phase -180 to 180 10 div)
13300  i = 0
13301  y1 = Y0TNiC
13302  y2 = Y0TNiC + GRHNiC
13303  mg_siz = GRHNiC/10.0
13304  mg_inc = mg_siz/5.0
13305  #
13306  while (i < 11):
13307  x = X0LNiC + i * GRWNiC/10.0
13308  Dline = [x,y1,x,y2]
13309  axis_value = Phasecenter - 180 + (i * DegPerDiv)
13310  axis_label = str(axis_value)
13311  if ( axis_value == 0):
13312  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
13313  k = 0
13314  while (k < 10):
13315  l = 1
13316  while (l < 5): # add tick marks
13317  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
13318  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13319  l = l + 1
13320  k = k + 1
13321  else:
13322  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13323  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
13324  i = i + 1
13325  # Draw traces
13326  # Vertical conversion factors (level dBs) and border limits
13327  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13328  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
13329  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
13330  Xp = float(X0LNiC) + Xphconv * 180.0
13331  x1 = X0LNiC + 14
13332  # Horizontal conversion factors (phase deg) and border limits
13333  NiCline = []
13334  if len(FSweepAdB) > 4:
13335  index = 0
13336  for index in range(len(FSweepAdB)): # while n < len(FStep):
13337  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
13338  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
13339  else:
13340  F = FBins[int(FStep[0])]
13341  # Mag value
13342  dbA = (10 * math.log10(float(FSweepAdB[index])) + 17) # Convert power to DBs, except for log(0) error
13343  dbB = (10 * math.log10(float(FSweepBdB[index])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13344  if ShowMathBP.get() == 1:
13345  MdB = dbA - dbB
13346  elif ShowMathBP.get() == 2:
13347  MdB = dbB - dbA
13348  yb = Yc - Yconv * MdB
13349  if (yb < Ymin):
13350  yb = Ymin
13351  if (yb > Ymax):
13352  yb = Ymax
13353  # Phase Value
13354  RelPhase = FSweepBPh[index] - FSweepAPh[index]
13355  RelPhase = RelPhase - Phasecenter
13356  if RelPhase > 180:
13357  RelPhase = RelPhase - 360
13358  elif RelPhase < -180:
13359  RelPhase = RelPhase + 360
13360  if Two_X_Sample.get() == 0:
13361  PhErr = 0.0018 * F # calculate phase error due half sample period offset
13362  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
13363  else:
13364  RelPhase = RelPhase # - PhaseOffset2x
13365  xa = Xp + Xphconv * RelPhase
13366  if (xa < Xmin):
13367  xa = Ymin
13368  if (xa > Xmax):
13369  xa = Xmax
13370  NiCline.append(int(xa + 0.5))
13371  NiCline.append(int(yb + 0.5))
13372  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13373 #
13374 def UpdateNqPAll(): # Update Data, trace and screen
13375  global FFTBuffA, FFTBuffB
13376  global SMPfft
13377 
13378  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13379  return
13380  #MakeNqPTrace() # Update the traces
13381  UpdateNqPScreen() # Update the screen
13382 
13383 def UpdateNqPTrace(): # Update trace and screen
13384 
13385  #MakeNqPTrace() # Update traces
13386  UpdateNqPScreen() # Update the screen
13387 
13388 def UpdateNqPScreen(): # Update screen with trace and text
13389 
13390  MakeNqPScreen() # Update the screen
13391  root.update() # Activate updated screens
13392 #
13393 def UpdateNiCAll(): # Update Data, trace and screen
13394  global FFTBuffA, FFTBuffB
13395  global SMPfft
13396 
13397  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13398  return
13399  #MakeNiCTrace() # Update the traces
13400  UpdateNiCScreen() # Update the screen
13401 
13402 def UpdateNiCTrace(): # Update trace and screen
13403 
13404  #MakeNiCTrace() # Update traces
13405  UpdateNiCScreen() # Update the screen
13406 
13407 def UpdateNiCScreen(): # Update screen with trace and text
13408 
13409  MakeNiCScreen() # Update the screen
13410  root.update() # Activate updated screens
13411 #
13412 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
13413  global FFTmemoryA, FFTresultA
13414  global FFTmemoryB, FFTresultB
13415  global PhaseA, PhaseB, freqwindow
13416  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
13417 
13418  # Set the TRACEsize variable
13419  if ShowC1_VdB.get() == 1:
13420  TRACEsize = len(FFTresultA) # Set the trace length
13421  elif ShowC2_VdB.get() == 1:
13422  TRACEsize = len(FFTresultB)
13423  if TRACEsize == 0: # If no trace, skip rest of this routine
13424  return()
13425 # ask if save as magnitude or dB
13426  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
13427  # Make the file name and open it
13428  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13429  filename = "Spectrum-" + tme
13430  filename = filename + ".csv"
13431  # open file to save data
13432  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13433  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
13434  DataFile = open(filename,'a') # Open output file
13435  HeaderString = 'Frequency-#, '
13436  if ShowC1_VdB.get() == 1:
13437  if dB == 1:
13438  HeaderString = HeaderString + 'CA-dB, '
13439  if dB == 0:
13440  HeaderString = HeaderString + 'CA-Mag, '
13441  if ShowC2_VdB.get() == 1:
13442  if dB == 1:
13443  HeaderString = HeaderString + 'CB-dB, '
13444  if dB == 0:
13445  HeaderString = HeaderString + 'CB-Mag, '
13446  if ShowC1_P.get() == 1:
13447  HeaderString = HeaderString + 'Phase A-B, '
13448  if ShowC2_P.get() == 1:
13449  HeaderString = HeaderString + 'Phase B-A, '
13450  HeaderString = HeaderString + '\n'
13451  DataFile.write( HeaderString )
13452 
13453  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
13454 
13455  n = 0
13456  while n < TRACEsize:
13457  F = n * Fsample
13458  txt = str(F)
13459  if ShowC1_VdB.get() == 1:
13460  V = 10 * math.log10(float(FFTresultA[n])) + 17 # Add 17 dB for max value of +10 dB
13461  if dB == 0:
13462  V = 10.0**(V/20.0)
13463  txt = txt + "," + str(V)
13464  if ShowC2_VdB.get() == 1:
13465  V = 10 * math.log10(float(FFTresultB[n])) + 17 # Add 17 dB for max value of +10 dB
13466  if dB == 0:
13467  V = 10.0**(V/20.0)
13468  txt = txt + "," + str(V)
13469  if ShowC1_P.get() == 1:
13470  RelPhase = PhaseA[n]-PhaseB[n]
13471  if RelPhase > 180:
13472  RelPhase = RelPhase - 360
13473  elif RelPhase < -180:
13474  RelPhase = RelPhase + 360
13475  txt = txt + "," + str(RelPhase)
13476  if ShowC2_P.get() == 1:
13477  RelPhase = PhaseB[n]-PhaseA[n]
13478  if RelPhase > 180:
13479  RelPhase = RelPhase - 360
13480  elif RelPhase < -180:
13481  RelPhase = RelPhase + 360
13482  txt = txt + "," + str(RelPhase)
13483  txt = txt + "\n"
13484  DataFile.write(txt)
13485  n = n + 1
13486 
13487  DataFile.close() # Close the file
13488 
13490 def MakeFreqScreen(): # Update the screen with traces and text
13491  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
13492  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13493  global PeakxM, PeakyM, PeakMdb, PeakfreqM
13494  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
13495  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
13496  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
13497  global COLORgrid # The colors
13498  global COLORsignalband, COLORtext
13499  global COLORtrace1, COLORtrace2
13500  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
13501  global DBdivindex # Index value
13502  global DBdivlist # dB per division list
13503  global DBlevel # Reference level
13504  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
13505  global X0LF # Left top X value
13506  global Y0TF # Left top Y value
13507  global GRWF # Screenwidth
13508  global GRHF # Screenheight
13509  global FontSize
13510  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
13511  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
13512  global SMPfft # number of FFT samples
13513  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
13514  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
13515  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp
13516  global ShowFCur, ShowdBCur, FCursor, dBCursor
13517  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
13518  global T1PRline, T2PRline
13519  global TRACEaverage # Number of traces for averageing
13520  global FreqTraceMode # 1 normal 2 max 3 average
13521  global Vdiv # Number of vertical divisions
13522 
13523  # Delete all items on the screen
13524  MarkerFreqNum = 0
13525  Freqca.delete(ALL) # remove all items
13526  try:
13527  StartFrequency = float(StartFreqEntry.get())
13528  except:
13529  StartFreqEntry.delete(0,"end")
13530  StartFreqEntry.insert(0,100)
13531  StartFrequency = 100
13532  try:
13533  StopFrequency = float(StopFreqEntry.get())
13534  except:
13535  StopFreqEntry.delete(0,"end")
13536  StopFreqEntry.insert(0,10000)
13537  StopFrequency = 10000
13538  try:
13539  Phasecenter = int(PhCenFreqEntry.get())
13540  RelPhaseCenter.set(Phasecenter)
13541  except:
13542  PhCenFreqEntry.delete(0,"end")
13543  PhCenFreqEntry.insert(0,0)
13544  RelPhaseCenter.set(0)
13545  Phasecenter = 0
13546  # Draw horizontal grid lines
13547  i = 0
13548  x1 = X0LF
13549  x2 = X0LF + GRWF
13550  while (i <= Vdiv.get()):
13551  y = Y0TF + i * GRHF/Vdiv.get()
13552  Dline = [x1,y,x2,y]
13553  if i == 0 or i == Vdiv.get():
13554  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13555  else:
13556  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13557  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
13558  Vaxis_label = str(Vaxis_value)
13559  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
13560  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
13561  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
13562  Vaxis_value = Vaxis_value + Phasecenter
13563  Vaxis_label = str(Vaxis_value)
13564  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
13565  i = i + 1
13566  # Draw vertical grid lines
13567  i = 0
13568  y1 = Y0TF
13569  y2 = Y0TF + GRHF
13570  if HScale.get() == 1:
13571  F = 1.0
13572  LogFStop = math.log10(StopFrequency)
13573  try:
13574  LogFStart = math.log10(StartFrequency)
13575  except:
13576  LogFStart = 0.0
13577  LogFpixel = (LogFStop - LogFStart) / GRWF
13578  # draw left and right edges
13579  while F <= StopFrequency:
13580  if F >= StartFrequency:
13581  try:
13582  LogF = math.log10(F) # convet to log Freq
13583  x = X0LF + (LogF - LogFStart)/LogFpixel
13584  except:
13585  x = X0LF
13586  Dline = [x,y1,x,y2]
13587  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
13588  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13589  axis_label = str(F)
13590  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
13591  else:
13592  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13593 
13594  if F < 10:
13595  F = F + 1
13596  elif F < 100:
13597  F = F + 10
13598  elif F < 1000:
13599  F = F + 100
13600  elif F < 1000:
13601  F = F + 100
13602  elif F < 10000:
13603  F = F + 1000
13604  elif F < 100000:
13605  F = F + 10000
13606  elif F < 200000:
13607  F = F + 10000
13608  else:
13609  Freqdiv = (StopFrequency - StartFrequency) / 10
13610  while (i < 11):
13611  x = X0LF + i * GRWF/10.0
13612  Dline = [x,y1,x,y2]
13613  if i == 0 or i == 10:
13614  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13615  else:
13616  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13617  axis_value = (StartFrequency + (i * Freqdiv))
13618  axis_label = str(axis_value)
13619  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
13620  i = i + 1
13621  # Draw X - Y cursors if needed
13622  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13623  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13624  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13625  if ShowFCur.get() > 0:
13626  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
13627  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
13628  # Horizontal conversion factors (frequency Hz) and border limits
13629  if HScale.get() == 1:
13630  LogFStop = math.log10(StopFrequency)
13631  try:
13632  LogFStart = math.log10(StartFrequency)
13633  except:
13634  LogFStart = 0.0
13635  LogFpixel = (LogFStop - LogFStart) / GRWF
13636  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
13637  else:
13638  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13639  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
13640  XFString = ' {0:.2f} '.format(xfreq)
13641  V_label = XFString + " Hz"
13642  Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
13643 #
13644  if ShowdBCur.get() > 0:
13645  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
13646  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
13647  # Vertical conversion factors (level dBs) and border limits
13648  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13649  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13650  yvdB = ((Yc-dBCursor)/Yconv)
13651  VdBString = ' {0:.1f} '.format(yvdB)
13652  V_label = VdBString + " dBV"
13653  Freqca.create_text(FCursor+1, dBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
13654  #
13655  SmoothBool = SmoothCurvesSA.get()
13656  # Draw traces
13657  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
13658  # Write the trace CHA
13659  if OverRangeFlagA == 1:
13660  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13661  else:
13662  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13663  if ShowMarker.get() > 0:
13664  k = 1
13665  while k <= HarmonicMarkers.get():
13666  try:
13667  dbA = (10 * math.log10(float(FFTresultA[PeakIndexA*k])) + 17)
13668  FreqA = k*PeakIndexA*Fsample
13669  if ShowMarker.get() == 2 and k > 1:
13670  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
13671  else:
13672  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
13673  if HScale.get() == 1:
13674  try:
13675  LogF = math.log10(FreqA) # convet to log Freq
13676  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
13677  except:
13678  xA = X0LF
13679  else:
13680  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
13681  yA = Yc - Yconv * dbA
13682  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
13683  k = k + 1
13684  except:
13685  k = k + 1
13686  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
13687  # Write the trace CHB
13688  if OverRangeFlagB == 1:
13689  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13690  else:
13691  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13692  if ShowMarker.get() > 0:
13693  k = 1
13694  while k <= HarmonicMarkers.get():
13695  try:
13696  dbB = (10 * math.log10(float(FFTresultB[PeakIndexB*k])) + 17)
13697  FreqB = k*PeakIndexB*Fsample
13698  if ShowMarker.get() == 2 and k > 1:
13699  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
13700  else:
13701  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
13702  if HScale.get() == 1:
13703  try:
13704  LogF = math.log10(FreqB) # convet to log Freq
13705  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
13706  except:
13707  xB = X0LF
13708  else:
13709  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
13710  yB = Yc - Yconv * dbB
13711  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
13712  k = k + 1
13713  except:
13714  k = k + 1
13715  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
13716  # Write the phase trace A-B
13717  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13718  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
13719  # Write the phase trace A-B
13720  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13721  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
13722  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13723  if ShowMarker.get() == 1:
13724  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
13725  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
13726  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
13727  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13728  if ShowMarker.get() == 1:
13729  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
13730  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
13731  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
13732  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13733  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
13734  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13735  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
13736  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13737  if ShowMarker.get() ==1:
13738  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
13739  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
13740  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
13741  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13742  if ShowMarker.get() ==1:
13743  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
13744  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
13745  # General information on top of the grid
13746 
13747  txt = " Sample rate: " + str(SAMPLErate)
13748  txt = txt + " FFT samples: " + str(SMPfft)
13749 
13750  txt = txt + " " + FFTwindowname
13751 
13752  x = X0LF
13753  y = 12
13754  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13755 
13756  # Start and stop frequency and dB/div and trace mode
13757  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
13758  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
13759  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
13760  if FFTwindow.get() < 7:
13761  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
13762  else:
13763  txt = txt + " FFT Bandwidth = ???"
13764 
13765  x = X0LF
13766  y = Y0TF+GRHF+23
13767  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13768 
13769  if FreqTraceMode.get() == 1:
13770  txt ="Normal mode "
13771 
13772  if FreqTraceMode.get() == 2:
13773  txt = "Peak hold mode "
13774 
13775  if FreqTraceMode.get() == 3:
13776  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
13777 
13778  if ZEROstuffing.get() > 0:
13779  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
13780  # Runstatus and level information
13781  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
13782  txt = txt + " Stopped "
13783  elif SingleShotSA.get() == 1:
13784  txt = txt + " Single Shot Trace "
13785  else:
13786  if FreqDisp.get() == 1:
13787  txt = txt + " Running "
13788  else:
13789  txt = txt + " Display off "
13790  x = X0LF
13791  y = Y0TF+GRHF+34
13792  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13793 
13795  global SMPfft, FFTwindow
13796  global SMPfftpwrTwo, BodeDisp
13797  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
13798 
13799  # First some subroutines to set specific variables
13800  if BodeDisp.get() == 0:
13801  if FFTwindow.get() != 8:
13802  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
13803 
13805  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
13806  TRACEresetFreq = True # Clear the memory for averaging or peak
13807  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
13808  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
13809 
13810 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
13811  global FFTbandwidth # The FFT bandwidth
13812  global FFTwindow # Which FFT window number is selected
13813  global FFTwindowname # The name of the FFT window function
13814  global FFTwindowshape # The window shape
13815  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
13816  global SMPfft # Number of FFT samples
13817  global LastWindow, LastSMPfft
13818 
13819  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
13820  # recalculate window only if something changed
13821  return
13822  # FFTname and FFTbandwidth in milliHz
13823  FFTwindowname = "No such window"
13824  FFTbw = 0
13825 
13826  if FFTwindow.get() == 0:
13827  FFTwindowname = " Rectangular (no) window (B=1) "
13828  FFTbw = 1.0
13829 
13830  if FFTwindow.get() == 1:
13831  FFTwindowname = " Cosine window (B=1.24) "
13832  FFTbw = 1.24
13833 
13834  if FFTwindow.get() == 2:
13835  FFTwindowname = " Triangular window (B=1.33) "
13836  FFTbw = 1.33
13837 
13838  if FFTwindow.get() == 3:
13839  FFTwindowname = " Hann window (B=1.5) "
13840  FFTbw = 1.5
13841 
13842  if FFTwindow.get() == 4:
13843  FFTwindowname = " Blackman window (B=1.73) "
13844  FFTbw = 1.73
13845 
13846  if FFTwindow.get() == 5:
13847  FFTwindowname = " Nuttall window (B=2.02) "
13848  FFTbw = 2.02
13849 
13850  if FFTwindow.get() == 6:
13851  FFTwindowname = " Flat top window (B=3.77) "
13852  FFTbw = 3.77
13853 
13854  if FFTwindow.get() == 7:
13855  FFTwindowname = FFTUserWindowString
13856  FFTbw = 0.0
13857  try:
13858  FFTwindowshape = eval(FFTUserWindowString)
13859  except:
13860  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
13861  print( "Filling FFT window with Ones")
13862  elif FFTwindow.get() == 8: # window shape array read from csv file
13863  FFTwindowname = "Window Shape From file"
13864  FFTbw = 0.0
13865  else:
13866  FFTbandwidth = int(FFTbw * SAMPLErate / float(SMPfft))
13867  # Calculate the shape
13868  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
13869  n = 0
13870  while n < SMPfft:
13871  # Cosine window function - medium-dynamic range B=1.24
13872  if FFTwindow.get() == 1:
13873  w = math.sin(math.pi * n / (SMPfft - 1))
13874  FFTwindowshape[n] = w * 1.571
13875  # Triangular non-zero endpoints - medium-dynamic range B=1.33
13876  if FFTwindow.get() == 2:
13877  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
13878  FFTwindowshape[n] = w * 2.0
13879  # Hann window function - medium-dynamic range B=1.5
13880  if FFTwindow.get() == 3:
13881  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
13882  FFTwindowshape[n] = w * 2.000
13883  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
13884  if FFTwindow.get() == 4:
13885  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
13886  FFTwindowshape[n] = w * 2.381
13887  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
13888  if FFTwindow.get() == 5:
13889  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))
13890  FFTwindowshape[n] = w * 2.811
13891  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
13892  if FFTwindow.get() == 6:
13893  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))
13894  FFTwindowshape[n] = w * 1.000
13895  n = n + 1
13896  LastWindow = FFTwindow.get()
13897  LastSMPfft = SMPfft
13898 
13900  global FFTUserWindowString, freqwindow
13901 
13902  TempString = FFTUserWindowString
13903  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
13904  if (FFTUserWindowString == None): # If Cancel pressed, then None
13905  FFTUserWindowString = TempString
13906 
13908  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
13909 
13910  # Read values from CVS file
13911  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
13912  try:
13913  CSVFile = open(filename)
13914  csv_f = csv.reader(CSVFile)
13915  FFTwindowshape = []
13916  for row in csv_f:
13917  try:
13918  FFTwindowshape.append(float(row[0]))
13919  except:
13920  print( 'skipping non-numeric row')
13921  FFTwindowshape = numpy.array(FFTwindowshape)
13922  CSVFile.close()
13923  SMPfft = len(FFTwindowshape)
13924  LastSMPfft = SMPfft
13925  LastWindow = FFTwindow.get()
13926  print( SMPfft)
13927  except:
13928  showwarning("WARNING","No such file found or wrong format!")
13929 #
13931  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
13932 
13933  FCursor = event.x
13934  dBCursor = event.y
13935  if RUNstatus.get() == 0:
13937  Freqca.bind_all('<MouseWheel>', onCanvasFreqClickScroll)
13938 #
13940  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
13941  if event.widget == Freqca:
13942  ShiftKeyDwn = event.state & 1
13943  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
13944  FCursor = FCursor + event.delta/100
13945  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
13946  dBCursor = dBCursor - event.delta/100
13947  if RUNstatus.get() == 0:
13949 #
13951  global X0LF # Left top X value
13952  global Y0TF # Left top Y value
13953  global GRWF # Screenwidth
13954  global GRHF # Screenheight
13955  global FontSize
13956  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
13957  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
13958  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
13959  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
13960 
13961  if (RUNstatus.get() == 0):
13962  MarkerFreqNum = MarkerFreqNum + 1
13963  COLORmarker = COLORgrid
13964  if ShowC1_VdB.get() == 1:
13965  COLORmarker = COLORtrace1
13966  elif ShowC2_VdB.get() == 1:
13967  COLORmarker = COLORtrace2
13968  try:
13969  StartFrequency = float(StartFreqEntry.get())
13970  except:
13971  StartFreqEntry.delete(0,"end")
13972  StartFreqEntry.insert(0,100)
13973  StartFrequency = 100
13974  try:
13975  StopFrequency = float(StopFreqEntry.get())
13976  except:
13977  StopFreqEntry.delete(0,"end")
13978  StopFreqEntry.insert(0,100)
13979  StopFrequency = 100
13980  # draw X at marker point and number
13981  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
13982  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
13983  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
13984  # Vertical conversion factors (level dBs) and border limits
13985  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13986  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13987  Yphconv = float(GRHF) / 360
13988  Yp = float(Y0TF) + Yphconv + 180
13989  # Horizontal conversion factors (frequency Hz) and border limits
13990  if HScale.get() == 1:
13991  LogFStop = math.log10(StopFrequency)
13992  try:
13993  LogFStart = math.log10(StartFrequency)
13994  except:
13995  LogFStart = 0.0
13996  LogFpixel = (LogFStop - LogFStart) / GRWF
13997  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
13998  else:
13999  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
14000  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
14001 
14002  yvdB = ((Yc-event.y)/Yconv)
14003  VdBString = ' {0:.1f} '.format(yvdB)
14004  XFString = ' {0:.2f} '.format(xfreq)
14005  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
14006  if MarkerFreqNum > 1:
14007  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
14008  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
14009  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
14010  x = X0LF + 5
14011  y = Y0TF + 3 + (MarkerFreqNum*10)
14012  Justify = 'w'
14013  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
14014  x = X0LF + GRWF - 5
14015  y = Y0TF + 3 + (MarkerFreqNum*10)
14016  Justify = 'e'
14017  if MarkerLoc == 'LL' or MarkerLoc == 'll':
14018  x = X0LF + 5
14019  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
14020  Justify = 'w'
14021  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
14022  x = X0LF + GRWF - 5
14023  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
14024  Justify = 'e'
14025  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
14026  PrevdBV = yvdB
14027  PrevF = xfreq
14028 #
14029 def onCanvasSAOne(event):
14030  global ShowC1_VdB
14031  if ShowC1_VdB.get() == 0:
14032  ShowC1_VdB.set(1)
14033  else:
14034  ShowC1_VdB.set(0)
14035 #
14036 def onCanvasSATwo(event):
14037  global ShowC2_VdB
14038  if ShowC2_VdB.get() == 0:
14039  ShowC2_VdB.set(1)
14040  else:
14041  ShowC2_VdB.set(0)
14042 #
14043 def onCanvasSAThree(event):
14044  global ShowC1_P
14045  if ShowC1_P.get() == 0:
14046  ShowC1_P.set(1)
14047  else:
14048  ShowC1_P.set(0)
14049 #
14050 def onCanvasSAFour(event):
14051  global ShowC2_P
14052  if ShowC2_P.get() == 0:
14053  ShowC2_P.set(1)
14054  else:
14055  ShowC2_P.set(0)
14056 #
14057 def onCanvasSAFive(event):
14058  global ShowMarker
14059  if ShowMarker.get() == 0:
14060  ShowMarker.set(1)
14061  else:
14062  ShowMarker.set(0)
14063 #
14064 def onCanvasSASix(event):
14065  global ShowRA_VdB
14066  if ShowRA_VdB.get() == 0:
14067  ShowRA_VdB.set(1)
14068  else:
14069  ShowRA_VdB.set(0)
14070 #
14071 def onCanvasSASeven(event):
14072  global ShowRB_VdB
14073  if ShowRB_VdB.get() == 0:
14074  ShowRB_VdB.set(1)
14075  else:
14076  ShowRB_VdB.set(0)
14077 #
14078 def onCanvasSAEight(event):
14079  global ShowMathSA
14080  ShowMathSA.set(2)
14081 #
14082 def onCanvasSANine(event):
14083  global ShowMathSA
14084  ShowMathSA.set(1)
14085 #
14086 def onCanvasSAZero(event):
14087  global ShowMathSA
14088  ShowMathSA.set(0)
14089 #
14090 def onCanvasSASnap(event):
14091  BSTOREtraceSA()
14092 #
14093 def onCanvasSANormal(event):
14094  BNormalmode()
14095 #
14096 def onCanvasSAPeak(event):
14097  BPeakholdmode()
14098 
14099 def onCanvasSAReset(event):
14100  BResetFreqAvg()
14101 #
14103  BAveragemode()
14104 #
14105 def onCanvasShowFcur(event):
14106  global ShowFCur
14107  if ShowFCur.get() == 0:
14108  ShowFCur.set(1)
14109  else:
14110  ShowFCur.set(0)
14111 #
14113  global ShowdBCur
14114  if ShowdBCur.get() == 1:
14115  ShowdBCur.set(0)
14116  else:
14117  ShowdBCur.set(1)
14118 #
14119 def onCanvasShowPcur(event):
14120  global ShowdBCur
14121  if ShowdBCur.get() == 2:
14122  ShowdBCur.set(0)
14123  else:
14124  ShowdBCur.set(2)
14125 #
14127  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
14128 
14129  BPCursor = event.x
14130  BdBCursor = event.y
14131  if RUNstatus.get() == 0:
14133  Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
14134 #
14136  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
14137 
14138  # print event.state
14139  shift_key = event.state & 1
14140  if ShowBPCur.get() > 0 and shift_key == 0:
14141  BPCursor = BPCursor + event.delta/100
14142  elif ShowBdBCur.get() > 0 or shift_key == 1:
14143  BdBCursor = BdBCursor - event.delta/100
14144  if RUNstatus.get() == 0:
14146 #
14148  global X0LBP # Left top X value
14149  global Y0TBP # Left top Y value
14150  global GRWBP # Screenwidth
14151  global GRHBP # Screenheight
14152  global FontSize
14153  global Bodeca, MarkerLoc, SAMPLErate
14154  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
14155  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
14156  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
14157 
14158  if (RUNstatus.get() == 0):
14159  MarkerFreqNum = MarkerFreqNum + 1
14160  COLORmarker = COLORtrace6 # COLORgrid
14161  if ShowCA_VdB.get() == 1:
14162  COLORmarker = COLORtrace1
14163  elif ShowCB_VdB.get() == 1:
14164  COLORmarker = COLORtrace2
14165  try:
14166  EndFreq = float(StopBodeEntry.get())
14167  except:
14168  StopBodeEntry.delete(0,"end")
14169  StopBodeEntry.insert(0,10000)
14170  EndFreq = 10000
14171  try:
14172  BeginFreq = float(StartBodeEntry.get())
14173  except:
14174  StartBodeEntry.delete(0,"end")
14175  StartBodeEntry.insert(0,100)
14176  BeginFreq = 100
14177  # draw X at marker point and number
14178  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
14179  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
14180  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
14181  # Vertical conversion factors (level dBs) and border limits
14182  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14183  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14184  Yphconv = float(GRHBP) / 360
14185  Yp = float(Y0TBP) + Yphconv + 180
14186  x1 = X0LBP + 14
14187  x2 = x1 + GRWBP
14188  # Horizontal conversion factors (frequency Hz) and border limits
14189  if HScaleBP.get() == 1:
14190  LogFStop = math.log10(EndFreq)
14191  try:
14192  LogFStart = math.log10(BeginFreq)
14193  except:
14194  LogFStart = 0.0
14195  LogFpixel = (LogFStop - LogFStart) / GRWBP
14196  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
14197  else:
14198  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14199  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
14200 
14201  yvdB = ((Yc-event.y)/Yconv)
14202  VdBString = ' {0:.1f} '.format(yvdB)
14203  XFString = ' {0:.2f} '.format(xfreq)
14204  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
14205  if MarkerFreqNum > 1:
14206  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
14207  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
14208  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
14209  x = x1 + 5
14210  y = Y0TBP + 3 + (MarkerFreqNum*10)
14211  Justify = 'w'
14212  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
14213  x = x2 - 5
14214  y = Y0TBP + 3 + (MarkerFreqNum*10)
14215  Justify = 'e'
14216  if MarkerLoc == 'LL' or MarkerLoc == 'll':
14217  x = x1 + 5
14218  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
14219  Justify = 'w'
14220  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
14221  x = x2 - 5
14222  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
14223  Justify = 'e'
14224  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
14225  PrevdBV = yvdB
14226  PrevF = xfreq
14227 #
14228 def onCanvasBdOne(event):
14229  global ShowCA_VdB
14230  if ShowCA_VdB.get() == 0:
14231  ShowCA_VdB.set(1)
14232  else:
14233  ShowCA_VdB.set(0)
14234 #
14235 def onCanvasBdTwo(event):
14236  global ShowCB_VdB
14237  if ShowCB_VdB.get() == 0:
14238  ShowCB_VdB.set(1)
14239  else:
14240  ShowCB_VdB.set(0)
14241 #
14242 def onCanvasBdThree(event):
14243  global ShowCA_P
14244  if ShowCA_P.get() == 0:
14245  ShowCA_P.set(1)
14246  else:
14247  ShowCA_P.set(0)
14248 #
14249 def onCanvasBdFour(event):
14250  global ShowCB_P
14251  if ShowCB_P.get() == 0:
14252  ShowCB_P.set(1)
14253  else:
14254  ShowCB_P.set(0)
14255 #
14256 def onCanvasBdFive(event):
14257  global ShowMarkerBP
14258  if ShowMarkerBP.get() == 0:
14259  ShowMarkerBP.set(1)
14260  else:
14261  ShowMarkerBP.set(0)
14262 #
14263 def onCanvasBdSix(event):
14264  global ShowRA_VdB
14265  if ShowRA_VdB.get() == 0:
14266  ShowRA_VdB.set(1)
14267  else:
14268  ShowRA_VdB.set(0)
14269 #
14270 def onCanvasBdSeven(event):
14271  global ShowRB_VdB
14272  if ShowRB_VdB.get() == 0:
14273  ShowRB_VdB.set(1)
14274  else:
14275  ShowRB_VdB.set(0)
14276 #
14277 def onCanvasBdEight(event):
14278  global ShowMathBP
14279  ShowMathBP.set(2)
14280 #
14281 def onCanvasBdNine(event):
14282  global ShowMathBP
14283  ShowMathBP.set(1)
14284 #
14285 def onCanvasBdZero(event):
14286  global ShowMathBP
14287  ShowMathBP.set(0)
14288 #
14289 def onCanvasBdSnap(event):
14290  BSTOREtraceBP()
14291 #
14293  global ShowBPCur
14294  if ShowBPCur.get() == 0:
14295  ShowBPCur.set(1)
14296  else:
14297  ShowBPCur.set(0)
14298 #
14300  global ShowBdBCur
14301  if ShowBdBCur.get() == 1:
14302  ShowBdBCur.set(0)
14303  else:
14304  ShowBdBCur.set(1)
14305 #
14307  global ShowBdBCur
14308  if ShowBdBCur.get() == 2:
14309  ShowBdBCur.set(0)
14310  else:
14311  ShowBdBCur.set(2)
14312 #
14313 def onAWGAscroll(event):
14314  global AWGAShape
14315 
14316  onTextScroll(event)
14317  time.sleep(0.05)
14318  ReMakeAWGwaves()
14319  time.sleep(0.05)
14320 #
14321 def onAWGBscroll(event):
14322  global AWGBShape
14323 
14324  onTextScroll(event)
14325  time.sleep(0.05)
14326  ReMakeAWGwaves()
14327  time.sleep(0.05)
14328 #
14329 def onTextScroll(event): # august 7
14330  button = event.widget
14331  cursor_position = button.index(INSERT) # get current cursor position
14332  Pos = cursor_position
14333  OldVal = button.get() # get current entry string
14334  OldValfl = float(OldVal) # and its value
14335  Len = len(OldVal)
14336  Dot = OldVal.find (".") # find decimal point position
14337  Decimals = Len - Dot - 1
14338  if Dot == -1 : # no point
14339  Decimals = 0
14340  Step = 10**(Len - Pos)
14341  elif Pos <= Dot : # no point left of position
14342  Step = 10**(Dot - Pos)
14343  else :
14344  Step = 10**(Dot - Pos + 1)
14345  if event.delta > 0: # increment value
14346  NewVal = OldValfl + Step
14347  else: # decrement value
14348  NewVal = OldValfl - Step
14349  FormatStr = "{0:." + str(Decimals) + "f}"
14350  NewStr = FormatStr.format(NewVal)
14351  NewDot = NewStr.find (".")
14352  NewPos = Pos + NewDot - Dot
14353  if Decimals == 0 :
14354  NewLen = len(NewStr)
14355  NewPos = Pos + NewLen - Len
14356  button.delete(0, END) # remove old entry
14357  button.insert(0, NewStr) # insert new entry
14358  button.icursor(NewPos) # resets the insertion cursor
14359 #
14360 def onAWGAkey(event):
14361  global AWGAShape
14362 
14363  onTextKey(event)
14364  ReMakeAWGwaves()
14365 #
14366 def onAWGBkey(event):
14367  global AWGBShape
14368 
14369  onTextKey(event)
14370  ReMakeAWGwaves()
14371 #
14372 def onTextKeyAWG(event):
14373  onTextKey(event)
14374  ReMakeAWGwaves()
14375 
14376 def onTextKey(event):
14377 
14378  button = event.widget
14379  cursor_position = button.index(INSERT) # get current cursor position
14380  NewPos = cursor_position -1
14381  OldVal = button.get() # get current entry string
14382  OldDigit = OldVal[NewPos]
14383  if platform.system() == "Windows":
14384  if event.keycode == 38: # increment digit for up arrow key
14385  NewDigit = int(OldDigit) + 1
14386  elif event.keycode == 40: # decrement digit for down arrow
14387  NewDigit = int(OldDigit) - 1
14388  else:
14389  return
14390  elif platform.system() == "Linux":
14391  if event.keycode == 111: # increment digit for up arrow key
14392  NewDigit = int(OldDigit) + 1
14393  elif event.keycode == 116: # decrement digit for down arrow
14394  NewDigit = int(OldDigit) - 1
14395  else:
14396  return
14397  if OldDigit == ".": # if cursor next to decimal point nop
14398  return
14399  if NewDigit > 9:
14400  NewDigit = 0
14401  button.delete(NewPos) # remove old digit
14402  button.insert(NewPos,NewDigit) # insert new digit
14403  NewPos = cursor_position-2
14404  if NewPos < 0:
14405  return
14406  CarryDigit = OldVal[NewPos]
14407  if CarryDigit == ".": # if carry is decimal point
14408  NewPos = cursor_position-3
14409  CarryDigit = OldVal[NewPos]
14410  NewDigit = int(CarryDigit) + 1
14411  if NewDigit > 9:
14412  NewDigit = 0
14413  button.delete(NewPos) # remove old digit
14414  button.insert(NewPos,NewDigit) # insert new digit
14415  elif NewDigit < 0:
14416  NewDigit = 9
14417  button.delete(NewPos) # remove old digit
14418  button.insert(NewPos,NewDigit) # insert new digit
14419  NewPos = cursor_position-2
14420  if NewPos < 0:
14421  return
14422  CarryDigit = OldVal[NewPos]
14423  if CarryDigit == ".": # if carry is decimal point
14424  NewPos = cursor_position-3
14425  CarryDigit = OldVal[NewPos]
14426  NewDigit = int(CarryDigit) - 1
14427  if NewDigit < 0:
14428  NewDigit = 9
14429  button.delete(NewPos) # remove old digit
14430  button.insert(NewPos,NewDigit) # insert new digit
14431  else:
14432  button.delete(NewPos) # remove old digit
14433  button.insert(NewPos,NewDigit) # insert new digit
14434 #
14435 def onSpinBoxScroll(event):
14436  spbox = event.widget
14437  if event.delta > 0: # increment digit
14438  spbox.invoke('buttonup')
14439  else: # decrement digit
14440  spbox.invoke('buttondown')
14441 #
14442 # ================ Make awg sub window ==========================
14444  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
14445  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
14446  global AWGABurstFlag, AWGBBurstFlag
14447  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
14448  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
14449  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
14450  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
14451  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
14452  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
14453 
14454  if AWGScreenStatus.get() == 0:
14455  AWGScreenStatus.set(1)
14456 
14457  awgwindow = Toplevel()
14458  awgwindow.title("AWG Controls " + SWRev + RevDate)
14459  awgwindow.resizable(FALSE,FALSE)
14460  awgwindow.geometry('+0+100')
14461  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
14462  #
14463  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
14464  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
14465  #
14466  if AwgLayout == "Horz":
14467  frame2.pack(side=LEFT, expand=1, fill=X)
14468  frame3.pack(side=LEFT, expand=1, fill=X)
14469  else:
14470  frame2.pack(side=TOP, expand=1, fill=Y)
14471  frame3.pack(side=TOP, expand=1, fill=Y)
14472  # now AWG A
14473  # AWG enable sub frame
14474  AWGAMode = IntVar(0) # AWG A mode variable
14475  AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
14476  AWGATerm = IntVar(0) # AWG A termination variable
14477  AWGAShape = IntVar(0) # AWG A Wave shape variable
14478  AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
14479  AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
14480  AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
14481  AWGAMode.set(2)
14482  AWGSync = IntVar(0) # Sync start both AWG channels
14483  AWGSync.set(1)
14484  awg1eb = Frame( frame2 )
14485  awg1eb.pack(side=TOP)
14486  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
14487  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
14488  ModeAMenu["menu"] = ModeAMenu.menu
14489  ModeAMenu.menu.add_command(label="-Mode-", command=donothing)
14490  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
14491  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
14492  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
14493  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
14494  ModeAMenu.menu.add_separator()
14495  ModeAMenu.menu.add_command(label="-Term-", command=donothing)
14496  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
14497  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
14498  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
14499  ModeAMenu.pack(side=LEFT, anchor=W)
14500  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W5.TButton")
14501  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
14502  ShapeAMenu["menu"] = ShapeAMenu.menu
14503  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
14504  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
14505  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
14506  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
14507  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
14508  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
14509  ShapeAMenu.menu.add_separator()
14510  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
14511  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
14512  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
14513  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
14514  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
14515  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
14516  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
14517  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
14518  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
14519  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
14520  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
14521  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
14522  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
14523  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
14524  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
14525  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
14526  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
14527  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
14528  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
14529  ShapeAMenu.pack(side=LEFT, anchor=W)
14530  #
14531  AWGAModeLabel = Label(frame2, text="AWG A Mode")
14532  AWGAModeLabel.pack(side=TOP)
14533  #
14534  awg1ampl = Frame( frame2 )
14535  awg1ampl.pack(side=TOP)
14536  AWGAAmplEntry = Entry(awg1ampl, width=5)
14537  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
14538  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
14539  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
14540  AWGAAmplEntry.pack(side=LEFT, anchor=W)
14541  AWGAAmplEntry.delete(0,"end")
14542  AWGAAmplEntry.insert(0,0.0)
14543  amp1lab = Label(awg1ampl) #, text="Min Ch A")
14544  amp1lab.pack(side=LEFT, anchor=W)
14545  #
14546  awg1off = Frame( frame2 )
14547  awg1off.pack(side=TOP)
14548  AWGAOffsetEntry = Entry(awg1off, width=5)
14549  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
14550  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
14551  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
14552  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
14553  AWGAOffsetEntry.delete(0,"end")
14554  AWGAOffsetEntry.insert(0,0.0)
14555  off1lab = Label(awg1off) #, text="Max Ch A")
14556  off1lab.pack(side=LEFT, anchor=W)
14557  if AWG_Amp_Mode.get() == 0:
14558  amp1lab.config(text = "Min Ch A" ) # change displayed value
14559  off1lab.config(text = "Max Ch A" ) # change displayed value
14560  else:
14561  amp1lab.config(text = "Amp Ch A" )
14562  off1lab.config(text = "Off Ch A" )
14563  # AWG Frequency sub frame
14564  awg1freq = Frame( frame2 )
14565  awg1freq.pack(side=TOP)
14566  AWGAFreqEntry = Entry(awg1freq, width=7)
14567  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
14568  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
14569  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
14570  AWGAFreqEntry.pack(side=LEFT, anchor=W)
14571  AWGAFreqEntry.delete(0,"end")
14572  AWGAFreqEntry.insert(0,100.0)
14573  freq1lab = Label(awg1freq, text="Freq Ch A")
14574  freq1lab.pack(side=LEFT, anchor=W)
14575  # AWG Phase or delay select sub frame
14576  AWGAPhaseDelay = IntVar(0) #
14577  awgadelay = Frame( frame2 )
14578  awgadelay.pack(side=TOP)
14579  awgaph = Radiobutton(awgadelay, text="Phase", style="WPhase.TRadiobutton", variable=AWGAPhaseDelay, value=0, command=BAWGAPhaseDelay)
14580  awgaph.pack(side=LEFT, anchor=W)
14581  awgadel = Radiobutton(awgadelay, text="Delay", style="GPhase.TRadiobutton", variable=AWGAPhaseDelay, value=1, command=BAWGAPhaseDelay)
14582  awgadel.pack(side=LEFT, anchor=W)
14583  # AWG Phase entry sub frame
14584  awg1phase = Frame( frame2 )
14585  awg1phase.pack(side=TOP)
14586  AWGAPhaseEntry = Entry(awg1phase, width=5)
14587  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
14588  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
14589  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
14590  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
14591  AWGAPhaseEntry.delete(0,"end")
14592  AWGAPhaseEntry.insert(0,0)
14593  phasealab = Label(awg1phase, text="Deg")
14594  phasealab.pack(side=LEFT, anchor=W)
14595  # AWG duty cycle frame
14596  awg1dc = Frame( frame2 )
14597  awg1dc.pack(side=TOP)
14598  AWGADutyCycleEntry = Entry(awg1dc, width=5)
14599  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
14600  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
14601  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
14602  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
14603  AWGADutyCycleEntry.delete(0,"end")
14604  AWGADutyCycleEntry.insert(0,50)
14605  duty1lab = Label(awg1dc, text="%")
14606  duty1lab.pack(side=LEFT, anchor=W)
14607  #
14608  AWGALength = Label(frame2, text="Length")
14609  AWGALength.pack(side=TOP)
14610  #
14611  if FWRevOne > 2.16:
14612  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
14613  awg2x1.pack(side=TOP)
14614  awg2x2 = Radiobutton(frame2, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
14615  awg2x2.pack(side=TOP)
14616  awg2x3 = Radiobutton(frame2, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
14617  awg2x3.pack(side=TOP)
14618  else:
14619  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
14620  awgsync.pack(side=TOP)
14621  # now AWG B
14622  # AWG enable sub frame
14623  AWGBMode = IntVar(0) # AWG B mode variable
14624  AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
14625  AWGBTerm = IntVar(0) # AWG B termination variable
14626  AWGBShape = IntVar(0) # AWG B Wave shape variable
14627  AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
14628  AWGBMode.set(2)
14629  awg2eb = Frame( frame3 )
14630  awg2eb.pack(side=TOP)
14631  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
14632  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
14633  ModeBMenu["menu"] = ModeBMenu.menu
14634  ModeBMenu.menu.add_command(label="-Mode-", command=donothing)
14635  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
14636  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
14637  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
14638  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
14639  ModeBMenu.menu.add_separator()
14640  ModeBMenu.menu.add_command(label="-Term-", command=donothing)
14641  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
14642  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
14643  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
14644  ModeBMenu.pack(side=LEFT, anchor=W)
14645  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W5.TButton")
14646  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
14647  ShapeBMenu["menu"] = ShapeBMenu.menu
14648  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
14649  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
14650  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
14651  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
14652  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
14653  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
14654  ShapeBMenu.menu.add_separator()
14655  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
14656  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
14657  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
14658  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
14659  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
14660  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
14661  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
14662  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
14663  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
14664  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
14665  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
14666  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
14667  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
14668  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
14669  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
14670  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
14671  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
14672  ShapeBMenu.pack(side=LEFT, anchor=W)
14673  #
14674  AWGBModeLabel = Label(frame3, text="AWG A Mode")
14675  AWGBModeLabel.pack(side=TOP)
14676  #
14677  awg2ampl = Frame( frame3 )
14678  awg2ampl.pack(side=TOP)
14679  AWGBAmplEntry = Entry(awg2ampl, width=5)
14680  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
14681  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll) #
14682  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
14683  AWGBAmplEntry.pack(side=LEFT, anchor=W)
14684  AWGBAmplEntry.delete(0,"end")
14685  AWGBAmplEntry.insert(0,0.0)
14686  amp2lab = Label(awg2ampl) #, text="Min Ch B")
14687  amp2lab.pack(side=LEFT, anchor=W)
14688  #
14689  awg2off = Frame( frame3 )
14690  awg2off.pack(side=TOP)
14691  AWGBOffsetEntry = Entry(awg2off, width=5)
14692  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
14693  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
14694  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
14695  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
14696  AWGBOffsetEntry.delete(0,"end")
14697  AWGBOffsetEntry.insert(0,0.0)
14698  off2lab = Label(awg2off) #, text="Max Ch B")
14699  off2lab.pack(side=LEFT, anchor=W)
14700  if AWG_Amp_Mode.get() == 0:
14701  amp2lab.config(text = "Min Ch B" ) # change displayed value
14702  off2lab.config(text = "Max Ch B" ) # change displayed value
14703  else:
14704  amp2lab.config(text = "Amp Ch B" )
14705  off2lab.config(text = "Off Ch B" )
14706  # AWG Frequency sub frame
14707  awg2freq = Frame( frame3 )
14708  awg2freq.pack(side=TOP)
14709  AWGBFreqEntry = Entry(awg2freq, width=7)
14710  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
14711  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
14712  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
14713  AWGBFreqEntry.pack(side=LEFT, anchor=W)
14714  AWGBFreqEntry.delete(0,"end")
14715  AWGBFreqEntry.insert(0,100.0)
14716  freq2lab = Label(awg2freq, text="Freq Ch B")
14717  freq2lab.pack(side=LEFT, anchor=W)
14718  # AWG Phase or delay select sub frame
14719  AWGBPhaseDelay = IntVar(0) #
14720  awgbdelay = Frame( frame3 )
14721  awgbdelay.pack(side=TOP)
14722  awgbph = Radiobutton(awgbdelay, text="Phase", style="WPhase.TRadiobutton", variable=AWGBPhaseDelay, value=0, command=BAWGBPhaseDelay)
14723  awgbph.pack(side=LEFT, anchor=W)
14724  awgbdel = Radiobutton(awgbdelay, text="Delay", style="GPhase.TRadiobutton", variable=AWGBPhaseDelay, value=1, command=BAWGBPhaseDelay)
14725  awgbdel.pack(side=LEFT, anchor=W)
14726  # AWG Phase sub frame
14727  awg2phase = Frame( frame3 )
14728  awg2phase.pack(side=TOP)
14729  AWGBPhaseEntry = Entry(awg2phase, width=5)
14730  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
14731  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
14732  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
14733  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
14734  AWGBPhaseEntry.delete(0,"end")
14735  AWGBPhaseEntry.insert(0,0)
14736  phaseblab = Label(awg2phase, text="Deg")
14737  phaseblab.pack(side=LEFT, anchor=W)
14738  # AWG duty cycle frame
14739  awg2dc = Frame( frame3 )
14740  awg2dc.pack(side=TOP)
14741  AWGBDutyCycleEntry = Entry(awg2dc, width=5)
14742  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
14743  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
14744  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
14745  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
14746  AWGBDutyCycleEntry.delete(0,"end")
14747  AWGBDutyCycleEntry.insert(0,50)
14748  duty2lab = Label(awg2dc, text="%")
14749  duty2lab.pack(side=LEFT, anchor=W)
14750  #
14751  AWGBLength = Label(frame3, text="Length")
14752  AWGBLength.pack(side=TOP)
14753  #
14754  BisCompA = IntVar(0) # Sync start both AWG channels
14755  BisCompA.set(0)
14756  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
14757  bcompa.pack(side=TOP)
14758  if FWRevOne > 2.16:
14759  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
14760  awgsync.pack(side=TOP)
14761  #
14762  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
14763  dismissbutton.pack(side=TOP)
14764  else:
14765  awgwindow.deiconify()
14766 #
14767 def BAWG2X():
14768  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
14769 
14770  ReMakeAWGwaves()
14771  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
14772  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
14773  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
14774  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
14775  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
14776  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
14777  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
14778  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
14779  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
14780  BisCompA.set(0)
14781  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
14782  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
14783  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
14784  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
14785  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
14786  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
14787  BisCompA.set(0)
14788 #
14790  global awgwindow, AWGScreenStatus
14791 
14792  # AWGScreenStatus.set(0)
14793  awgwindow.iconify()
14794 # ===== Channel B Mux Mode sub Window =======
14796  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
14797  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
14798  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
14799  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
14800  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev
14801  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg, DualMuxMode
14802 
14803  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
14804  MuxScreenStatus.set(1)
14805  #
14806  BAWGEnab() # update AWG settings
14807  #
14808  muxwindow = Toplevel()
14809  muxwindow.title("CH-B Mux " + SWRev + RevDate)
14810  muxwindow.resizable(FALSE,FALSE)
14811  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
14812  #
14813  frameM = LabelFrame(muxwindow, text="CH B Mux", style="A10B.TLabel") #, font="Arial 10 bold", borderwidth=5, relief=RIDGE)
14814  frameM.pack(side=LEFT, expand=1, fill=Y)
14815  #
14816  # Voltage channel CHB-A
14817  frameA = Frame(frameM)
14818  frameA.pack(side=TOP)
14819  cba = Checkbutton(frameA, text='CB-A', variable=Show_CBA, command=UpdateTimeTrace)
14820  cba.pack(side=LEFT, anchor=W)
14821  CHB_Asb = Spinbox(frameA, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14822  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
14823  CHB_Asb.pack(side=LEFT)
14824  CHB_Asb.delete(0,"end")
14825  CHB_Asb.insert(0,0.5)
14826  #
14827  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
14828  CHB_Alab.pack(side=LEFT)
14829  CHB_APosEntry = Entry(frameA, width=5)
14830  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
14831  CHB_APosEntry.bind('<Key>', onTextKey)
14832  CHB_APosEntry.pack(side=LEFT)
14833  CHB_APosEntry.delete(0,"end")
14834  CHB_APosEntry.insert(0,2.5)
14835  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
14836  CHB_Aofflab.pack(side=LEFT)
14837  # Voltage channel CHB-B
14838  frameB = Frame(frameM)
14839  frameB.pack(side=TOP)
14840  cbb = Checkbutton(frameB, text='CB-B', variable=Show_CBB, command=UpdateTimeTrace)
14841  cbb.pack(side=LEFT, anchor=W)
14842  CHB_Bsb = Spinbox(frameB, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14843  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
14844  CHB_Bsb.pack(side=LEFT)
14845  CHB_Bsb.delete(0,"end")
14846  CHB_Bsb.insert(0,0.5)
14847  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
14848  CHB_Blab.pack(side=LEFT)
14849  CHB_BPosEntry = Entry(frameB, width=5)
14850  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
14851  CHB_BPosEntry.bind('<Key>', onTextKey)
14852  CHB_BPosEntry.pack(side=LEFT)
14853  CHB_BPosEntry.delete(0,"end")
14854  CHB_BPosEntry.insert(0,2.5)
14855  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
14856  CHB_Bofflab.pack(side=LEFT)
14857  # Voltage channel B-C
14858  frameC = Frame(frameM)
14859  frameC.pack(side=TOP)
14860  cbc = Checkbutton(frameC, text='CB-C', variable=Show_CBC, command=UpdateTimeTrace)
14861  cbc.pack(side=LEFT, anchor=W)
14862  CHB_Csb = Spinbox(frameC, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14863  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
14864  CHB_Csb.pack(side=LEFT)
14865  CHB_Csb.delete(0,"end")
14866  CHB_Csb.insert(0,0.5)
14867  #
14868  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
14869  CHB_Clab.pack(side=LEFT)
14870  CHB_CPosEntry = Entry(frameC, width=5)
14871  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
14872  CHB_CPosEntry.bind('<Key>', onTextKey)
14873  CHB_CPosEntry.pack(side=LEFT)
14874  CHB_CPosEntry.delete(0,"end")
14875  CHB_CPosEntry.insert(0,2.5)
14876  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
14877  CHB_Cofflab.pack(side=LEFT)
14878  # Voltage channel B-D
14879  frameD = Frame(frameM)
14880  frameD.pack(side=TOP)
14881  cbd = Checkbutton(frameD, text='CB-D', variable=Show_CBD, command=UpdateTimeTrace)
14882  cbd.pack(side=LEFT, anchor=W)
14883  CHB_Dsb = Spinbox(frameD, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14884  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
14885  CHB_Dsb.pack(side=LEFT)
14886  CHB_Dsb.delete(0,"end")
14887  CHB_Dsb.insert(0,0.5)
14888  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
14889  CHB_Dlab.pack(side=LEFT)
14890  CHB_DPosEntry = Entry(frameD, width=5)
14891  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
14892  CHB_DPosEntry.bind('<Key>', onTextKey)
14893  CHB_DPosEntry.pack(side=LEFT)
14894  CHB_DPosEntry.delete(0,"end")
14895  CHB_DPosEntry.insert(0,2.5)
14896  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
14897  CHB_Dofflab.pack(side=LEFT)
14898  frameE = Frame(frameM)
14899  frameE.pack(side=TOP)
14900  MuxEnb = IntVar(0)
14901  MuxSync = IntVar(0)
14902  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
14903  muxenab.pack(side=LEFT)
14904  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
14905  SyncButton.pack(side=LEFT)
14906  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
14907  dismissbutton.pack(side=LEFT)
14908  frameF = Frame(frameM)
14909  frameF.pack(side=TOP)
14910  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
14911  dmx.pack(side=LEFT)
14912  # Gray out main Channel B controls
14913  CHBlab.config(style="SGray.TButton")
14914  CHBofflab.config(style="SGray.TButton")
14915 #
14917  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
14918  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab
14919 
14920  if DualMuxMode.get() == 1:
14921  AWGAIOMode.set(1) # force awg A split I/O mode
14922  AWGBIOMode.set(1) # force awg A split I/O mode
14923  ShowC1_V.set(0) # force A voltage trace off
14924  CHB_Clab.config(text="CA-C V/Div")
14925  CHB_Dlab.config(text="CA-D V/Div")
14926  CHB_Cofflab.config(text="CA-C Pos")
14927  CHB_Dofflab.config(text="CA-D Pos")
14928  BAWGEnab() # update AWG settings
14929  # Gray out main Channel A controls
14930  CHAlab.config(style="SGray.TButton")
14931  CHAofflab.config(style="SGray.TButton")
14932  else:
14933  ShowC1_V.set(1) # force A voltage trace on
14934  CHB_Clab.config(text="CB-C V/Div")
14935  CHB_Dlab.config(text="CB-D V/Div")
14936  CHB_Cofflab.config(text="CB-C Pos")
14937  CHB_Dofflab.config(text="CB-D Pos")
14938  # Reset main Channel A control colors
14939  CHAlab.config(style="Rtrace1.TButton")
14940  CHAofflab.config(style="Rtrace1.TButton")
14941 #
14943  global MuxSync, hipulseimg, lowpulseimg, SyncButton
14944 
14945  if MuxSync.get() == 0:
14946  SyncButton.config(image=hipulseimg)
14947  else:
14948  SyncButton.config(image=lowpulseimg)
14949 
14951  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
14952 
14953  MuxScreenStatus.set(0)
14954  awgsync.config(state=NORMAL)
14955  # Reset main Channel B control colors
14956  CHBlab.config(style="Rtrace2.TButton")
14957  CHBofflab.config(style="Rtrace2.TButton")
14958  CHAlab.config(style="Rtrace1.TButton")
14959  CHAofflab.config(style="Rtrace1.TButton")
14960  muxwindow.destroy()
14961 #
14962 def BodeCaresize(event):
14963  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
14964 
14965  CANVASwidthBP = event.width - 4
14966  CANVASheightBP = event.height - 4
14967  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
14968  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
14969  UpdateBodeAll()
14970 #
14972  global FStepSync, DevOne
14973 
14974  if FStepSync.get() == 0:
14975  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
14976  elif FStepSync.get() == 1:
14977  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
14978  elif FStepSync.get() == 2:
14979  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
14980 #
14982  global FSweepSync, DevOne
14983 
14984  if FSweepSync.get() == 0:
14985  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
14986  elif FSweepSync.get() == 1:
14987  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
14988  elif FSweepSync.get() == 2:
14989  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
14990 #
14992  global BDSweepFile, FileSweepFreq, FileSweepAmpl
14993 
14994  if BDSweepFile.get() > 0:
14995  # Read values from CVS file
14996  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
14997  try:
14998  CSVFile = open(filename)
14999  csv_f = csv.reader(CSVFile)
15000  FileSweepFreq = []
15001  FileSweepAmpl = []
15002  for row in csv_f:
15003  try:
15004  FileSweepFreq.append(float(row[0]))
15005  FileSweepAmpl.append(float(row[1]))
15006  except:
15007  print( 'skipping non-numeric row')
15008  FileSweepFreq = numpy.array(FileSweepFreq)
15009  FileSweepAmpl = numpy.array(FileSweepAmpl)
15010  MaxAmpl = numpy.amax(FileSweepAmpl)
15011  NormAmpl = MaxAmpl
15012  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
15013  if (s == None): # If Cancel pressed, then None
15014  return()
15015  try: # Error if for example no numeric characters or OK pressed without input (s = "")
15016  v = int(s)
15017  except:
15018  s = "error"
15019 
15020  if s != "error":
15021  NormAmpl = MaxAmpl - v
15022  else:
15023  NormAmpl = MaxAmpl
15024  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
15025  CSVFile.close()
15026  StopBodeEntry.delete(0,"end")
15027  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
15028  StartBodeEntry.delete(0,"end")
15029  StartBodeEntry.insert(0,FileSweepFreq[0])
15030  SweepStepBodeEntry.delete(0,"end")
15031  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
15032  except:
15033  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
15034 #
15035 # ========== Make Bode Plot Window =============
15037  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
15038  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
15039  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
15040  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
15041  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
15042  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
15043  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
15044  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
15045  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
15046 
15047  if BodeScreenStatus.get() == 0:
15048  BodeScreenStatus.set(1)
15049  BodeDisp.set(1)
15050  BodeCheckBox()
15051  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
15052  CANVASheightBP = GRHBP + 80 # The ode canvas height
15053  CutDC.set(1) # set to remove DC
15054  AWGAMode.set(0) # Set AWG A to SVMI
15055  AWGAShape.set(1) # Set Shape to Sine
15056  AWGBMode.set(2) # Set AWG B to Hi-Z
15057  bodewindow = Toplevel()
15058  bodewindow.title("Bode Plotter " + SWRev + RevDate)
15059  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
15060  frame2bp = Frame(bodewindow, borderwidth=5, relief=RIDGE)
15061  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
15062 
15063  frame2b = Frame(bodewindow, borderwidth=5, relief=RIDGE)
15064  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
15065 
15066  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
15067  Bodeca.bind('<Configure>', BodeCaresize)
15068  Bodeca.bind('<1>', onCanvasBodeLeftClick)
15069  Bodeca.bind('<3>', onCanvasBodeRightClick)
15070  Bodeca.bind("<Up>", onCanvasUpArrow)
15071  Bodeca.bind("<Down>", onCanvasDownArrow)
15072  Bodeca.bind("<Left>", onCanvasLeftArrow)
15073  Bodeca.bind("<Right>", onCanvasRightArrow)
15074  Bodeca.bind("<space>", onCanvasSpaceBar)
15075  Bodeca.bind("1", onCanvasBdOne)
15076  Bodeca.bind("2", onCanvasBdTwo)
15077  Bodeca.bind("3", onCanvasBdThree)
15078  Bodeca.bind("4", onCanvasBdFour)
15079  Bodeca.bind("5", onCanvasBdFive)
15080  Bodeca.bind("6", onCanvasBdSix)
15081  Bodeca.bind("7", onCanvasBdSeven)
15082  Bodeca.bind("8", onCanvasBdEight)
15083  Bodeca.bind("9", onCanvasBdNine)
15084  Bodeca.bind("0", onCanvasBdZero)
15085  Bodeca.bind("f", onCanvasShowBPcur)
15086  Bodeca.bind("d", onCanvasShowBdBcur)
15087  Bodeca.bind("h", onCanvasShowPdBcur)
15088  Bodeca.bind("s", onCanvasBdSnap)
15089  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
15090 
15091  # right side drop down menu buttons
15092  dropmenu = Frame( frame2bp )
15093  dropmenu.pack(side=TOP)
15094  # File menu
15095  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15096  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
15097  BodeFilemenu["menu"] = BodeFilemenu.menu
15098  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
15099  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
15100  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
15101  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
15102  BodeFilemenu.pack(side=LEFT, anchor=W)
15103  #
15104  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15105  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
15106  BodeOptionmenu["menu"] = BodeOptionmenu.menu
15107  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15108  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
15109  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15110  BodeOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceBP)
15111  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
15112  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
15113  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
15114  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
15115  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
15116  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
15117  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
15118  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
15119  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
15120  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
15121  BodeOptionmenu.pack(side=LEFT, anchor=W)
15122  #
15123  RUNframe = Frame( frame2bp )
15124  RUNframe.pack(side=TOP)
15125  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
15126  sbode.pack(side=LEFT)
15127  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
15128  rbode.pack(side=LEFT)
15129  #
15130  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
15131  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
15132  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
15133  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15134  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15135  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15136  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15137  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15138  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15139  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15140  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
15141  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
15142  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
15143  BodeFFTwindmenu.pack(side=TOP)
15144  #
15145  tracemenu = Frame( frame2bp )
15146  tracemenu.pack(side=TOP)
15147  # Curves menu
15148  # Show channels menu
15149  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
15150  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
15151  BodeShowmenu["menu"] = BodeShowmenu.menu
15152  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
15153  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
15154  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
15155  BodeShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowCA_VdB, command=UpdateBodeAll)
15156  BodeShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowCB_VdB, command=UpdateBodeAll)
15157  BodeShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowCA_P, command=UpdateBodeAll)
15158  BodeShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowCB_P, command=UpdateBodeAll)
15159  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
15160  BodeShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathBP, value=0, command=UpdateBodeAll)
15161  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathBP, value=1, command=UpdateBodeAll)
15162  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathBP, value=2, command=UpdateBodeAll)
15163  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
15164  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
15165  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
15166  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
15167  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
15168  BodeShowmenu.menu.add_separator()
15169  BodeShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowCA_RdB, command=UpdateBodeAll)
15170  BodeShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowCB_RdB, command=UpdateBodeAll)
15171  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
15172  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
15173  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
15174  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
15175  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
15176  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
15177  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
15178  BodeShowmenu.pack(side=LEFT, anchor=W)
15179  #
15180  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
15181  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
15182  BodeMarkmenu["menu"] = BodeMarkmenu.menu
15183  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
15184  BodeMarkmenu.menu.add_checkbutton(label='Marker [5]', variable=ShowMarkerBP, command=UpdateBodeAll)
15185  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
15186  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
15187  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
15188  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowBdBCur, value=1)
15189  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowBdBCur, value=2)
15190  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowBPCur)
15191  BodeMarkmenu.pack(side=LEFT, anchor=W)
15192  #
15193  # Horz Scale
15194  HScaleBP = IntVar(0)
15195  HScaleBP.set(1)
15196  HzScale = Frame( frame2bp )
15197  HzScale.pack(side=TOP)
15198  rb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
15199  rb1.pack(side=LEFT)
15200  rb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
15201  rb2.pack(side=LEFT)
15202 
15203  DBrange = Frame( frame2bp )
15204  DBrange.pack(side=TOP)
15205  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
15206  bd3.pack(side=LEFT)
15207  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
15208  bd4.pack(side=LEFT)
15209 
15210  LVBrange = Frame( frame2bp )
15211  LVBrange.pack(side=TOP)
15212  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
15213  bd5.pack(side=LEFT)
15214  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
15215  bd6.pack(side=LEFT)
15216 
15217  LVSrange = Frame( frame2bp )
15218  LVSrange.pack(side=TOP)
15219  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
15220  bd7.pack(side=LEFT)
15221  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
15222  bd8.pack(side=LEFT)
15223 
15224  PhaseCenter = Frame( frame2bp )
15225  PhaseCenter.pack(side=TOP)
15226  PhCenlab = Label(PhaseCenter, text="Center Phase on")
15227  PhCenlab.pack(side=LEFT)
15228  PhCenBodeEntry = Entry(PhaseCenter, width=5)
15229  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
15230  PhCenBodeEntry.bind('<Key>', onTextKey)
15231  PhCenBodeEntry.pack(side=LEFT)
15232  PhCenBodeEntry.delete(0,"end")
15233  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
15234  #
15235  ImpedCenter = Frame( frame2bp )
15236  ImpedCenter.pack(side=TOP)
15237  ImCenlab = Label(ImpedCenter, text="Center Imped on")
15238  ImCenlab.pack(side=LEFT)
15239  ImCenBodeEntry = Entry(ImpedCenter, width=5)
15240  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
15241  ImCenBodeEntry.bind('<Key>', onTextKey)
15242  ImCenBodeEntry.pack(side=LEFT)
15243  ImCenBodeEntry.delete(0,"end")
15244  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
15245  # sweep generator mode menu buttons
15246  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
15247  FSweepmenu.pack(side=TOP)
15248 
15249  Frange1 = Frame( frame2bp )
15250  Frange1.pack(side=TOP)
15251  startfreqlab = Label(Frange1, text="Startfreq")
15252  startfreqlab.pack(side=LEFT)
15253  StartBodeEntry = Entry(Frange1, width=5)
15254  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
15255  StartBodeEntry.bind('<Key>', onTextKey)
15256  StartBodeEntry.pack(side=LEFT)
15257  StartBodeEntry.delete(0,"end")
15258  StartBodeEntry.insert(0,10)
15259 
15260  Frange2 = Frame( frame2bp )
15261  Frange2.pack(side=TOP)
15262  stopfreqlab = Label(Frange2, text="Stopfreq")
15263  stopfreqlab.pack(side=LEFT)
15264  StopBodeEntry = Entry(Frange2, width=5)
15265  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
15266  StopBodeEntry.bind('<Key>', onTextKey)
15267  StopBodeEntry.pack(side=LEFT)
15268  StopBodeEntry.delete(0,"end")
15269  StopBodeEntry.insert(0,10000)
15270 
15271  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
15272  sgrb1.pack(side=TOP)
15273  Frange4 = Frame( frame2bp )
15274  Frange4.pack(side=TOP)
15275  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
15276  sgrb2.pack(side=LEFT)
15277  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
15278  sgrb3.pack(side=LEFT)
15279  if MinigenScreenStatus.get() > 0:
15280  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
15281  sgrb1.pack(side=TOP)
15282  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
15283  ffcb.pack(side=TOP)
15284  Frange3 = Frame( frame2bp )
15285  Frange3.pack(side=TOP)
15286  sweepsteplab = Label(Frange3, text="Sweep Steps")
15287  sweepsteplab.pack(side=LEFT)
15288  SweepStepBodeEntry = Entry(Frange3, width=5)
15289  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
15290  SweepStepBodeEntry.bind('<Key>', onTextKey)
15291  SweepStepBodeEntry.pack(side=LEFT)
15292  SweepStepBodeEntry.delete(0,"end")
15293  SweepStepBodeEntry.insert(0,100)
15294 
15295  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
15296  sgrb5.pack(side=TOP)
15297  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
15298  sgrb6.pack(side=TOP)
15299  Plotsframe = Frame( frame2bp )
15300  Plotsframe.pack(side=TOP)
15301  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
15302  nyquistplotbutton.pack(side=LEFT)
15303  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
15304  nicholsplotbutton.pack(side=LEFT)
15305  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
15306  bodismiss1button.pack(side=TOP)
15307 
15308  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
15309  ADI2.pack(side=TOP)
15310  if ShowBallonHelp > 0:
15311  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
15312  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
15313  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
15314  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
15315  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
15316  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
15317  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
15318  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
15319  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
15320 #
15322  global bodewindow, BodeScreenStatus, ca, FSweepMode
15323 
15324  BodeScreenStatus.set(0)
15325  FSweepMode.set(0)
15326  BodeDisp.set(0)
15327  BodeCheckBox()
15328  bodewindow.destroy()
15329  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15330 #
15331 def FreqCaresize(event):
15332  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
15333 
15334  CANVASwidthF = event.width - 4
15335  CANVASheightF = event.height - 4
15336  GRWF = CANVASwidthF - (2 * X0LF) # new grid width
15337  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
15338  UpdateFreqAll()
15339 #
15340 # ================ Make spectrum sub window ==========================
15342  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
15343  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp
15344  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA
15345  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate
15346  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
15347  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
15348 
15349  if SpectrumScreenStatus.get() == 0:
15350  SpectrumScreenStatus.set(1)
15351  FreqDisp.set(1)
15352  FreqCheckBox()
15353  CANVASwidthF = GRWF + 2 * X0LF # The spectrum canvas width
15354  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
15355  freqwindow = Toplevel()
15356  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
15357  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
15358  frame2fr = Frame(freqwindow, borderwidth=5, relief=RIDGE)
15359  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
15360 
15361  frame2f = Frame(freqwindow, borderwidth=5, relief=RIDGE)
15362  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
15363 
15364  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
15365  Freqca.bind('<Configure>', FreqCaresize)
15366  Freqca.bind('<1>', onCanvasFreqLeftClick)
15367  Freqca.bind('<3>', onCanvasFreqRightClick)
15368  Freqca.bind("<Up>", onCanvasUpArrow)
15369  Freqca.bind("<Down>", onCanvasDownArrow)
15370  Freqca.bind("<Left>", onCanvasLeftArrow)
15371  Freqca.bind("<Right>", onCanvasRightArrow)
15372  Freqca.bind("<space>", onCanvasSpaceBar)
15373  Freqca.bind("1", onCanvasSAOne)
15374  Freqca.bind("2", onCanvasSATwo)
15375  Freqca.bind("3", onCanvasSAThree)
15376  Freqca.bind("4", onCanvasSAFour)
15377  Freqca.bind("5", onCanvasSAFive)
15378  Freqca.bind("6", onCanvasSASix)
15379  Freqca.bind("7", onCanvasSASeven)
15380  Freqca.bind("8", onCanvasSAEight)
15381  Freqca.bind("9", onCanvasSANine)
15382  Freqca.bind("0", onCanvasSAZero)
15383  Freqca.bind("a", onCanvasSAAverage)
15384  Freqca.bind("n", onCanvasSANormal)
15385  Freqca.bind("p", onCanvasSAPeak)
15386  Freqca.bind("r", onCanvasSAReset)
15387  Freqca.bind("f", onCanvasShowFcur)
15388  Freqca.bind("d", onCanvasShowdBcur)
15389  Freqca.bind("h", onCanvasShowPcur)
15390  Freqca.bind("s", onCanvasSASnap)
15391  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
15392  # right side drop down menu buttons
15393  dropmenu = Frame( frame2fr )
15394  dropmenu.pack(side=TOP)
15395  # File menu
15396  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15397  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
15398  SAFilemenu["menu"] = SAFilemenu.menu
15399  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
15400  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
15401  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
15402  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
15403  SAFilemenu.pack(side=LEFT, anchor=W)
15404  #
15405  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15406  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
15407  SAOptionmenu["menu"] = SAOptionmenu.menu
15408  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15409  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15410  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
15411  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15412  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
15413  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
15414  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
15415  SAOptionmenu.pack(side=LEFT, anchor=W)
15416  #
15417  RUNframe = Frame( frame2fr )
15418  RUNframe.pack(side=TOP)
15419  sb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
15420  sb.pack(side=LEFT)
15421  rb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
15422  rb.pack(side=LEFT)
15423  #
15424  Modeframe = Frame( frame2fr )
15425  Modeframe.pack(side=TOP)
15426  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
15427  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
15428  Modemenu["menu"] = Modemenu.menu
15429  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
15430  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
15431  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
15432  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
15433  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
15434  Modemenu.pack(side=LEFT)
15435  #
15436  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
15437  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
15438  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
15439  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15440  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15441  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15442  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15443  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15444  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15445  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15446  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
15447  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
15448  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
15449  SAFFTwindmenu.pack(side=LEFT)
15450  #
15451  SamplesMenu = Frame( frame2fr )
15452  SamplesMenu.pack(side=TOP)
15453  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
15454  bless.pack(side=LEFT)
15455  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
15456  bmore.pack(side=LEFT)
15457  #
15458  # Show channels menu
15459  ShowC1_VdB = IntVar(0) # curves to display variables
15460  ShowC1_P = IntVar(0)
15461  ShowC2_VdB = IntVar(0)
15462  ShowC2_P = IntVar(0)
15463  ShowMarker = IntVar(0)
15464  ShowRA_VdB = IntVar(0)
15465  ShowRA_P = IntVar(0)
15466  ShowRB_VdB = IntVar(0)
15467  ShowRB_P = IntVar(0)
15468  ShowMathSA = IntVar(0)
15469  ShowRMath = IntVar(0)
15470  #
15471  SAShowmenu = Menubutton(frame2fr, text="Curves", style="W7.TButton")
15472  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
15473  SAShowmenu["menu"] = SAShowmenu.menu
15474  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
15475  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
15476  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
15477  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
15478  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
15479  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
15480  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
15481  SAShowmenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
15482  SAShowmenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
15483  SAShowmenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
15484  SAShowmenu.menu.add_separator()
15485  SAShowmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
15486  SAShowmenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
15487  SAShowmenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
15488  SAShowmenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
15489  SAShowmenu.menu.add_separator()
15490  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
15491  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
15492  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
15493  SAShowmenu.menu.add_separator()
15494  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
15495  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
15496  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
15497  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
15498  SAShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMath, command=UpdateFreqAll)
15499  SAShowmenu.pack(side=TOP)
15500  # HScale
15501  Frange1 = Frame( frame2fr )
15502  Frange1.pack(side=TOP)
15503  startfreqlab = Label(Frange1, text="Startfreq")
15504  startfreqlab.pack(side=LEFT)
15505  StartFreqEntry = Entry(Frange1, width=5)
15506  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
15507  StartFreqEntry.bind('<Key>', onTextKey)
15508  StartFreqEntry.pack(side=LEFT)
15509  StartFreqEntry.delete(0,"end")
15510  StartFreqEntry.insert(0,10)
15511 
15512  Frange2 = Frame( frame2fr )
15513  Frange2.pack(side=TOP)
15514  stopfreqlab = Label(Frange2, text="Stopfreq")
15515  stopfreqlab.pack(side=LEFT)
15516  StopFreqEntry = Entry(Frange2, width=7)
15517  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
15518  StopFreqEntry.bind('<Key>', onTextKey)
15519  StopFreqEntry.pack(side=LEFT)
15520  StopFreqEntry.delete(0,"end")
15521  StopFreqEntry.insert(0,10000)
15522 
15523  HScale = IntVar(0)
15524  HzScale = Frame( frame2fr )
15525  HzScale.pack(side=TOP)
15526  rb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
15527  rb1.pack(side=LEFT)
15528  rb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
15529  rb2.pack(side=LEFT)
15530  #
15531  PhaseCenter = Frame( frame2fr )
15532  PhaseCenter.pack(side=TOP)
15533  PhCenlab = Label(PhaseCenter, text="Center Phase on")
15534  PhCenlab.pack(side=LEFT)
15535  PhCenFreqEntry = Entry(PhaseCenter, width=5)
15536  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
15537  PhCenFreqEntry.bind('<Key>', onTextKey)
15538  PhCenFreqEntry.pack(side=LEFT)
15539  PhCenFreqEntry.delete(0,"end")
15540  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
15541  #
15542  DBrange = Frame( frame2fr )
15543  DBrange.pack(side=TOP)
15544  b3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
15545  b3.pack(side=LEFT)
15546  b4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
15547  b4.pack(side=LEFT)
15548 
15549  LVBrange = Frame( frame2fr )
15550  LVBrange.pack(side=TOP)
15551  b5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
15552  b5.pack(side=LEFT)
15553  b6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
15554  b6.pack(side=LEFT)
15555 
15556  LVSrange = Frame( frame2fr )
15557  LVSrange.pack(side=TOP)
15558  b7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
15559  b7.pack(side=LEFT)
15560  b8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
15561  b8.pack(side=LEFT)
15562 
15563  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
15564  sadismiss1button.pack(side=TOP)
15565 
15566  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
15567  ADI2.pack(side=TOP)
15568  if ShowBallonHelp > 0:
15569  sb_tip = CreateToolTip(sb, 'Stop acquiring data')
15570  rb_tip = CreateToolTip(rb, 'Start acquiring data')
15571  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
15572  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
15573  b3_tip = CreateToolTip(b3, 'Increase number of dB/Div')
15574  b4_tip = CreateToolTip(b4, 'Decrease number of dB/Div')
15575  b5_tip = CreateToolTip(b5, 'Increase Ref Level by 10 dB')
15576  b6_tip = CreateToolTip(b6, 'Decrease Ref Level by 10 dB')
15577  b7_tip = CreateToolTip(b7, 'Increase Ref Level by 1 dB')
15578  b8_tip = CreateToolTip(b8, 'Decrease Ref Level by 1 dB')
15579  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
15580 
15582  global freqwindow, SpectrumScreenStatus, ca
15583 
15584  SpectrumScreenStatus.set(0)
15585  FreqDisp.set(0)
15586  FreqCheckBox()
15587  freqwindow.destroy()
15588  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15589 #
15590 def XYcaresize(event):
15591  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
15592  global YminXY, YmaxXY, XminXY, XmaxXY
15593 
15594  CANVASwidthXY = event.width - 4
15595  CANVASheightXY = event.height - 4
15596  GRWXY = CANVASwidthXY - int(2.25 * FontSize) - X0LXY # 18 new grid width
15597  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
15598  YminXY = Y0TXY # Minimum position of time grid (top)
15599  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
15600  XminXY = X0LXY # Minimum position of time grid (left)
15601  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
15602  UpdateXYAll()
15603 #
15604 # ================ Make spectrum sub window ==========================
15606  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, Ysignal, ShowRXY
15607  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
15608  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
15609  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
15610  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
15611 
15612  if XYScreenStatus.get() == 0:
15613  XYScreenStatus.set(1)
15614  XYDisp.set(1)
15615  XYCheckBox()
15616  YminXY = Y0TXY # Minimum position of XY grid (top)
15617  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
15618  XminXY = X0LXY # Minimum position of XY grid (left)
15619  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
15620  CANVASwidthXY = GRWXY + 18 + X0LXY # The XY canvas width
15621  CANVASheightXY = GRHXY + 80 # The XY canvas height
15622  xywindow = Toplevel()
15623  xywindow.title("X-Y Plot " + SWRev + RevDate)
15624  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
15625  frame2xyr = Frame(xywindow, borderwidth=5, relief=RIDGE)
15626  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
15627 
15628  frame2xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15629  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
15630 
15631  frame3xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15632  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
15633 
15634  frame4xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15635  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
15636 
15637  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
15638  XYca.bind('<Configure>', XYcaresize)
15639  XYca.bind('<1>', onCanvasXYLeftClick)
15640  XYca.bind('<3>', onCanvasXYRightClick)
15641  XYca.bind("<Motion>",onCanvasMouse_xy)
15642  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
15643  XYca.bind("<Up>", onCanvasUpArrow)
15644  XYca.bind("<Down>", onCanvasDownArrow)
15645  XYca.bind("<Left>", onCanvasLeftArrow)
15646  XYca.bind("<Right>", onCanvasRightArrow)
15647  XYca.bind("<space>", onCanvasSpaceBar)
15648  XYca.bind("a", onCanvasAverage)
15649  XYca.pack(side=TOP, fill=BOTH, expand=YES)
15650  #
15651  RUNframe = Frame( frame2xyr )
15652  RUNframe.pack(side=TOP)
15653  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
15654  sbxy.pack(side=LEFT)
15655  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
15656  rbxy.pack(side=LEFT)
15657  # Open Math trace menu
15658  mathbt = Button(frame2xyr, text="Math", style="W4.TButton", command = NewEnterMathControls)
15659  mathbt.pack(side=TOP) #, anchor=W)
15660  # Disply mode menu
15661  # X - Y mode signal select
15662  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
15663  AxisLabX.pack(side=TOP)
15664  chaxmenu = Frame( frame2xyr )
15665  chaxmenu.pack(side=TOP)
15666  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
15667  rbx2.pack(side=LEFT, anchor=W)
15668  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
15669  rbx3.pack(side=LEFT, anchor=W)
15670  chbxmenu = Frame( frame2xyr )
15671  chbxmenu.pack(side=TOP)
15672  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
15673  rbx4.pack(side=LEFT, anchor=W)
15674  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
15675  rbx5.pack(side=LEFT, anchor=W)
15676  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
15677  rbx7.pack(side=TOP)
15678  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
15679  rbx8.pack(side=TOP)
15680  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
15681  rbx6.pack(side=TOP)
15682  #
15683  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
15684  AxisLabY.pack(side=TOP)
15685  chaymenu = Frame( frame2xyr )
15686  chaymenu.pack(side=TOP)
15687  rby2 = Radiobutton(chaymenu, text='CA-V', variable=Ysignal, value=1, command=UpdateXYTrace)
15688  rby2.pack(side=LEFT, anchor=W)
15689  rby3 = Radiobutton(chaymenu, text='CA-I', variable=Ysignal, value=2, command=UpdateXYTrace)
15690  rby3.pack(side=LEFT, anchor=W)
15691  chbymenu = Frame( frame2xyr )
15692  chbymenu.pack(side=TOP)
15693  rby4 = Radiobutton(chbymenu, text='CB-V', variable=Ysignal, value=3, command=UpdateXYTrace)
15694  rby4.pack(side=LEFT, anchor=W)
15695  rby5 = Radiobutton(chbymenu, text='CB-I', variable=Ysignal, value=4, command=UpdateXYTrace)
15696  rby5.pack(side=LEFT, anchor=W)
15697  rby6 = Radiobutton(frame2xyr, text='Math', variable=Ysignal, value=5, command=UpdateXYTrace)
15698  rby6.pack(side=TOP)
15699  # show cursor menu buttons
15700  cursormenu = Frame( frame2xyr )
15701  cursormenu.pack(side=TOP)
15702  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
15703  cb1.pack(side=LEFT, anchor=W)
15704  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
15705  cb2.pack(side=LEFT, anchor=W)
15706  cb3 = Checkbutton(frame2xyr, text='RX-Y', variable=ShowRXY, command=UpdateXYTrace)
15707  cb3.pack(side=TOP)
15708  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
15709  cb4.pack(side=TOP)
15710  #
15711  snapbutton = Button(frame2xyr, style="W8.TButton", text="SnapShot", command=BSnapShot)
15712  snapbutton.pack(side=TOP)
15713  savebutton = Button(frame2xyr, style="W11.TButton", text="Save Screen", command=BSaveScreenXY)
15714  savebutton.pack(side=TOP)
15715  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
15716  dismissxybutton.pack(side=TOP)
15717  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
15718  ADI1xy.pack(side=TOP)
15719 
15720  # Bottom Buttons
15721  MarkerXYScale = IntVar(0)
15722  MarkerXYScale.set(1)
15723  # Voltage channel A
15724  CHAsbxy = Spinbox(frame3xy, width=4, values=CHvpdiv)
15725  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15726  CHAsbxy.pack(side=LEFT)
15727  CHAsbxy.delete(0,"end")
15728  CHAsbxy.insert(0,0.5)
15729  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
15730  CHAxylab.pack(side=LEFT)
15731 
15732  CHAVPosEntryxy = Entry(frame3xy, width=5)
15733  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
15734  CHAVPosEntryxy.bind('<Key>', onTextKey)
15735  CHAVPosEntryxy.pack(side=LEFT)
15736  CHAVPosEntryxy.delete(0,"end")
15737  CHAVPosEntryxy.insert(0,2.5)
15738  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
15739  CHAofflabxy.pack(side=LEFT)
15740  # Current channel A
15741  CHAIsbxy = Spinbox(frame3xy, width=4, values=CHipdiv)
15742  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15743  CHAIsbxy.pack(side=LEFT)
15744  CHAIsbxy.delete(0,"end")
15745  CHAIsbxy.insert(0,50.0)
15746  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
15747  CHAIlabxy.pack(side=LEFT)
15748 
15749  CHAIPosEntryxy = Entry(frame3xy, width=5)
15750  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
15751  CHAIPosEntryxy.bind('<Key>', onTextKey)
15752  CHAIPosEntryxy.pack(side=LEFT)
15753  CHAIPosEntryxy.delete(0,"end")
15754  CHAIPosEntryxy.insert(0,0.0)
15755  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
15756  CHAIofflabxy.pack(side=LEFT)
15757  # Voltage channel B
15758  CHBsbxy = Spinbox(frame4xy, width=4, values=CHvpdiv)
15759  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15760  CHBsbxy.pack(side=LEFT)
15761  CHBsbxy.delete(0,"end")
15762  CHBsbxy.insert(0,0.5)
15763  #
15764  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
15765  CHBxylab.pack(side=LEFT)
15766 
15767  CHBVPosEntryxy = Entry(frame4xy, width=5)
15768  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
15769  CHBVPosEntryxy.bind('<Key>', onTextKey)
15770  CHBVPosEntryxy.pack(side=LEFT)
15771  CHBVPosEntryxy.delete(0,"end")
15772  CHBVPosEntryxy.insert(0,2.5)
15773  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
15774  CHBofflabxy.pack(side=LEFT)
15775  # Current channel B
15776  CHBIsbxy = Spinbox(frame4xy, width=4, values=CHipdiv) #
15777  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15778  CHBIsbxy.pack(side=LEFT)
15779  CHBIsbxy.delete(0,"end")
15780  CHBIsbxy.insert(0,50.0)
15781  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
15782  CHBIlabxy.pack(side=LEFT)
15783 
15784  CHBIPosEntryxy = Entry(frame4xy, width=5)
15785  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
15786  CHBIPosEntryxy.bind('<Key>', onTextKey)
15787  CHBIPosEntryxy.pack(side=LEFT)
15788  CHBIPosEntryxy.delete(0,"end")
15789  CHBIPosEntryxy.insert(0,0.0)
15790  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
15791  CHBIofflabxy.pack(side=LEFT)
15792  #
15793  if ShowBallonHelp > 0:
15794  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
15795  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
15796  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
15797  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
15798  math_tip = CreateToolTip(mathbt, 'Open Math window')
15799  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
15800  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
15801  snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
15802  savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
15803  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
15804  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
15805  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
15806  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
15807  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
15808  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
15809  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
15810 
15812  global xywindow, XYScreenStatus, ca, XYDisp
15813 
15814  XYScreenStatus.set(0)
15815  XYDisp.set(0)
15816  XYCheckBox()
15817  xywindow.destroy()
15818  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15819 #
15820 # Optional Calibration procedure routine
15821 #
15823  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
15824  global discontloop, contloop, session, AWGSync, SWRev
15825  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
15826  # setup cal results window
15827  if FWRevOne < 2.06: # Check firmware revision level > 2.06
15828  showwarning("WARNING","Out of date Firmware Revision!")
15829  return
15830  calwindow = Toplevel()
15831  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
15832  # display wigets
15833  prlab = Label(calwindow, text="Channel Gain / Offset calibration")
15834  prlab.grid(row=0, column=0, columnspan=2, sticky=W)
15835  labelA0 = Label(calwindow, style="A12B.TLabel")
15836  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
15837  labelA0.config(text = "CA gnd Volts")
15838  labelAMax = Label(calwindow, style="A12B.TLabel")
15839  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
15840  labelAMax.config(text = "CA 584 Volts")
15841  labelAMin = Label(calwindow, style="A12B.TLabel")
15842  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
15843  labelAMin.config(text = "CA 5V Src I ")
15844  labelB0 = Label(calwindow, style="A12B.TLabel")
15845  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
15846  labelB0.config(text = "CA gnd Volts")
15847  labelBMax = Label(calwindow, style="A12B.TLabel")
15848  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
15849  labelBMax.config(text = "CB 584 Volts")
15850  labelBMin = Label(calwindow, style="A12B.TLabel")
15851  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
15852  labelBMin.config(text = "CB 5V Src I ")
15853  labelAB = Label(calwindow, style="A12B.TLabel")
15854  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
15855  labelAB.config(text = "CA 0V Src I")
15856  labelBA = Label(calwindow, style="A12B.TLabel")
15857  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
15858  labelBA.config(text = "CA 0V Src I")
15859  labelSIA0 = Label(calwindow, style="A12B.TLabel")
15860  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
15861  labelSIA0.config(text = "CA 2.5 Src 0 I")
15862  labelSIA = Label(calwindow, style="A12B.TLabel")
15863  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
15864  labelSIA.config(text = "CA 50 Src 100 ")
15865  labelSIAN = Label(calwindow, style="A12B.TLabel")
15866  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
15867  labelSIAN.config(text = "CA 50 Src -45")
15868  labelSIB0 = Label(calwindow, style="A12B.TLabel")
15869  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
15870  labelSIB0.config(text = "CB 2.5 Src 0 I")
15871  labelSIB = Label(calwindow, style="A12B.TLabel")
15872  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
15873  labelSIB.config(text = "CB 50 Src 100 ")
15874  labelSIBN = Label(calwindow, style="A12B.TLabel")
15875  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
15876  labelSIBN.config(text = "CB 50 Src -45")
15877  # set to default mux and dac settings
15878  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
15879  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
15880  AWGSync.set(1)
15881  BAWGSync()
15882  if session.continuous:
15883  print( "ending session")
15884  session.end()
15885  # Setup ADALM1000
15886  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
15887  #print(devx.calibration)
15888  try:
15889  devx.write_calibration("calib_default.txt")
15890  #print "wrote calib_default.txt"
15891  except:
15892  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
15893  devx.write_calibration(filename)
15894  #print(devx.calibration)
15895  #
15896  devidstr = DevID[17:31]
15897  filename = "calib" + devidstr + ".txt"
15898  if os.path.isfile(filename):
15899  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
15900  devx.write_calibration(filename)
15901  #print "wrote old ", filename
15902  calwindow.destroy()
15903  return
15904  else:
15905  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
15906  donothing()
15907  else:
15908  calwindow.destroy()
15909  return
15910  #
15911  CalFile = open(filename, "w")
15912  #
15913  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15914  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15915  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
15916  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
15917  ADsignal1 = [] # Ain signal array channel
15918  ADsignal1 = devx.get_samples(1010)
15919  # Pause whie user connects external voltage reference AD584
15920  BadData = 1
15921  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
15922  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
15923  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
15924  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
15925  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
15926  try:
15927  AD584act = float(RequestVRef)*1.0
15928  except:
15929  AD584act = 3.3
15930  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
15931  while (BadData): # loop till good reading
15932  # Get A and B AD584 data
15933  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15934  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15935  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
15936  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
15937  # get_samples returns a list of values for voltage [0] and current [1]
15938  for index in range(1000): # calculate average
15939  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
15940  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
15941 
15942  CHA584Raw = CHA584Raw / 1000.0 # calculate average
15943  CHB584Raw = CHB584Raw / 1000.0 # calculate average
15944  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
15945  labelAMax.config(text = VString) # change displayed value
15946  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
15947  labelBMax.config(text = VString) # change displayed value
15948  Lower = AD584act - 0.3
15949  Upper = AD584act + 0.3
15950  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
15951  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
15952  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15953  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15954  contloop = 0
15955  discontloop = 1
15956  calwindow.destroy()
15957  return
15958  else:
15959  BadData = 0
15960  #
15961  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
15962  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
15963  # Get A GND and B GND data
15964  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
15965  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
15966  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
15967  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
15968  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15969  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15970  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
15971  # get_samples returns a list of values for voltage [0] and current [1]
15972  for index in range(1000): # calculate average
15973  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
15974  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
15975  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
15976  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
15977 
15978  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
15979  CHAI0gRaw = CHAI0gRaw / 1000.0
15980  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
15981  CHBI0gRaw = CHBI0gRaw / 1000.0
15982  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
15983  labelA0.config(text = VString) # change displayed value
15984  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
15985  labelB0.config(text = VString) # change displayed value
15986  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
15987  # Get A and B data for internal 2.5 rail
15988  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15989  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15990  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
15991  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
15992  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
15993  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
15994  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
15995  # get_samples returns a list of values for voltage [0] and current [1]
15996  for index in range(1000): # calculate average
15997  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
15998  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
15999  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16000  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16001 
16002  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
16003  CHAI02p5Raw = CHAI02p5Raw / 1000.0
16004  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
16005  CHBI02p5Raw = CHBI02p5Raw / 1000.0
16006  # Get A force 0V and B force 0V data
16007  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
16008  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
16009  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16010  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16011  CHA.mode = Mode.SVMI
16012  CHA.constant(0.0)
16013  CHB.mode = Mode.SVMI
16014  CHB.constant(0.0)
16015  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16016  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
16017  # get_samples returns a list of values for voltage [0] and current [1]
16018  for index in range(1000): # calculate average
16019  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16020  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16021  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16022  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16023 
16024  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
16025  CHAI0F0Raw = CHAI0F0Raw / 1000.0
16026  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
16027  CHBI0F0Raw = CHBI0F0Raw / 1000.0
16028  # Get A force 2.5V and B force 2.5V data
16029  CHA.mode = Mode.SVMI
16030  CHA.constant(4.5)
16031  CHB.mode = Mode.SVMI
16032  CHB.constant(4.5)
16033  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16034  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
16035  # get_samples returns a list of values for voltage [0] and current [1]
16036  for index in range(1000): # calculate average
16037  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16038  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16039  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16040  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16041 
16042  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
16043  CHAI0F25Raw = CHAI0F25Raw / 1000.0
16044  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
16045  CHBI0F25Raw = CHBI0F25Raw / 1000.0
16046  #
16047  # Get A and B measure current data for int 50 res to gnd at 5V
16048  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
16049  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
16050  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16051  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
16052  CHA.mode = Mode.SVMI
16053  CHA.constant(5.0)
16054  CHB.mode = Mode.SVMI
16055  CHB.constant(5.0)
16056  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16057  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
16058  for index in range(1000): # calculate average
16059  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16060  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16061  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16062  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16063 
16064  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
16065  CHAISr5vRaw = CHAISr5vRaw / 1000.0
16066  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
16067  CHBISr5vRaw = CHBISr5vRaw / 1000.0
16068  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
16069  labelAMin.config(text = VString) # change displayed value
16070  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
16071  labelBMin.config(text = VString) # change displayed value
16072  # Get A and B measure current data for int 50 res to 2.5 V at 0V
16073  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16074  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16075  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16076  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16077  CHA.mode = Mode.SVMI
16078  CHA.constant(0.001)
16079  CHB.mode = Mode.SVMI
16080  CHB.constant(0.001)
16081  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16082  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
16083  for index in range(1000): # calculate average
16084  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16085  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16086  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16087  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16088 
16089  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
16090  CHAISr0vRaw = CHAISr0vRaw / 1000.0
16091  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
16092  CHBISr0vRaw = CHBISr0vRaw / 1000.0
16093  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
16094  labelAB.config(text = VString) # change displayed value
16095  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
16096  labelBA.config(text = VString) # change displayed value
16097 
16098  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
16099  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16100  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16101  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16102  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16103  CHA.mode = Mode.SIMV
16104  CHA.constant(0.0)
16105  CHB.mode = Mode.SIMV
16106  CHB.constant(0.0)
16107  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16108  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
16109  for index in range(1000): # calculate average
16110  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16111  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16112  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16113  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16114 
16115  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
16116  CHAISr0iRaw = CHAISr0iRaw / 1000.0
16117  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
16118  CHBISr0iRaw = CHBISr0iRaw / 1000.0
16119  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
16120  labelSIA0.config(text = VString) # change displayed value
16121  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
16122  labelSIB0.config(text = VString) # change displayed value
16123  #
16124  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
16125  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16126  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16127  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16128  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16129  CHA.mode = Mode.SIMV
16130  CHA.constant(0.045)
16131  CHB.mode = Mode.SIMV
16132  CHB.constant(0.045)
16133  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16134  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
16135  for index in range(1000): # calculate average
16136  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16137  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16138  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16139  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16140 
16141  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
16142  CHAISr100Raw = CHAISr100Raw / 1000.0
16143  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
16144  CHBISr100Raw = CHBISr100Raw / 1000.0
16145  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
16146  labelSIA.config(text = VString) # change displayed value
16147  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
16148  labelSIB.config(text = VString) # change displayed value
16149  #
16150  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
16151  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16152  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16153  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16154  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16155  CHA.mode = Mode.SIMV
16156  CHA.constant(-0.045)
16157  CHB.mode = Mode.SIMV
16158  CHB.constant(-0.045)
16159  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16160  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
16161  for index in range(1000): # calculate average
16162  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16163  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16164  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16165  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16166 
16167  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
16168  CHAISrN45Raw = CHAISrN45Raw / 1000.0
16169  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
16170  CHBISrN45Raw = CHBISrN45Raw / 1000.0
16171  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
16172  labelSIAN.config(text = VString) # change displayed value
16173  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
16174  labelSIBN.config(text = VString) # change displayed value
16175  # return all switches to open
16176  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
16177  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
16178  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16179  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16180  # Caculate voltage gain errors
16181  #
16182  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
16183  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
16184  #
16185  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
16186  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
16187  #
16188  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
16189  # print "calculated fixed 2.5 from CHA ", CHA2p5
16190  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
16191  # print "calculated fixed 2.5 from CHB ", CHB2p5
16192  #
16193  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
16194  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
16195  #
16196  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
16197  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
16198  #
16199  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
16200  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
16201  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
16202  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
16203  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
16204  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
16205  #
16206  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
16207  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
16208  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
16209  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
16210  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
16211  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
16212  # Write cal factors to file
16213  #
16214  CalFile.write('# Channel A, measure V\n')
16215  CalFile.write('</>\n')
16216  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
16217  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
16218  CalFile.write('<>\n')
16219  CalFile.write('\n')
16220  #
16221  CalFile.write('# Channel A, measure I\n')
16222  CalFile.write('</>\n')
16223  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
16224  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
16225  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
16226  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
16227  CalFile.write('<>\n')
16228  CalFile.write('\n')
16229  #
16230  CalFile.write('# Channel A, source V\n')
16231  CalFile.write('</>\n')
16232  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
16233  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
16234  CalFile.write('<>\n')
16235  CalFile.write('\n')
16236  #
16237  CalFile.write('# Channel A, source I\n')
16238  CalFile.write('</>\n')
16239  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
16240  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
16241  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
16242  CalFile.write('<>\n')
16243  CalFile.write('\n')
16244  #
16245  CalFile.write('# Channel B, measure V\n')
16246  CalFile.write('</>\n')
16247  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
16248  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
16249  CalFile.write('<>\n')
16250  CalFile.write('\n')
16251  #
16252  CalFile.write('# Channel B, measure I\n')
16253  CalFile.write('</>\n')
16254  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
16255  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
16256  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
16257  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
16258  CalFile.write('<>\n')
16259  CalFile.write('\n')
16260  #
16261  CalFile.write('# Channel B, source V\n')
16262  CalFile.write('</>\n')
16263  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
16264  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
16265  CalFile.write('<>\n')
16266  CalFile.write('\n')
16267  #
16268  CalFile.write('# Channel B source I\n')
16269  CalFile.write('</>\n')
16270  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
16271  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
16272  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
16273  CalFile.write('<>\n')
16274  #
16275  CalFile.close()
16276  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
16277  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
16278  devx.write_calibration(filename)
16279  #print "wrote new " , filename
16280  #
16281  # session.end()
16282  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
16283  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
16284  contloop = 0
16285  discontloop = 1
16286  # session.cancel()
16287  calwindow.destroy()
16288 #
16290  global cal, DevID, devx
16291 
16292  devidstr = DevID[17:31]
16293  filename = "calib" + devidstr + "test.txt"
16294  if os.path.isfile(filename):
16295  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
16296  return
16297  else:
16298  if askyesno("Continue?", "Continure with save calibration file?"): #, parent=calwindow):
16299  donothing()
16300  else:
16301  calwindow.destroy()
16302  return
16303  #
16304  CalFile = open(filename, "w")
16305  #
16306  # Write cal factors to file
16307  # [0]
16308  CalFile.write('# Channel A, measure V\n')
16309  CalFile.write('</>\n')
16310  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
16311  CHAgp = (5.0/cal[0][1])+cal[0][0]
16312  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16313  CalFile.write('<>\n')
16314  CalFile.write('\n')
16315  # [1]
16316  CalFile.write('# Channel A, measure I\n')
16317  CalFile.write('</>\n')
16318  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
16319  CHAgp = (0.1/cal[0][1])+cal[1][0]
16320  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16321  CHAgn = (-0.1/cal[0][2])+cal[1][0]
16322  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
16323  CalFile.write('<>\n')
16324  CalFile.write('\n')
16325  # [2]
16326  CalFile.write('# Channel A, source V\n')
16327  CalFile.write('</>\n')
16328  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
16329  CHAgp = (5.0/cal[2][1])+cal[2][0]
16330  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16331  CalFile.write('<>\n')
16332  CalFile.write('\n')
16333  # [3]
16334  CalFile.write('# Channel A, source I\n')
16335  CalFile.write('</>\n')
16336  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
16337  CHAgp = (0.1/cal[3][1])+cal[3][0]
16338  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16339  CHAgn = (-0.1/cal[3][2])+cal[3][0]
16340  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16341  CalFile.write('<>\n')
16342  CalFile.write('\n')
16343  # [4]
16344  CalFile.write('# Channel B, measure V\n')
16345  CalFile.write('</>\n')
16346  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
16347  CHAgp = (5.0/cal[4][1])+cal[4][0]
16348  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16349  CalFile.write('<>\n')
16350  CalFile.write('\n')
16351  # [5]
16352  CalFile.write('# Channel B, measure I\n')
16353  CalFile.write('</>\n')
16354  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
16355  CHAgp = (0.1/cal[5][1])+cal[5][0]
16356  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16357  CHAgn = (-0.1/cal[5][2])+cal[5][0]
16358  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16359  CalFile.write('<>\n')
16360  CalFile.write('\n')
16361  # [6]
16362  CalFile.write('# Channel B, source V\n')
16363  CalFile.write('</>\n')
16364  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
16365  CHAgp = (5.0/cal[6][1])+cal[6][0]
16366  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16367  CalFile.write('<>\n')
16368  CalFile.write('\n')
16369  # [7]
16370  CalFile.write('# Channel B source I\n')
16371  CalFile.write('</>\n')
16372  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
16373  CHAgp = (0.1/cal[7][1])+cal[7][0]
16374  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16375  CHAgn = (-0.1/cal[7][2])+cal[7][0]
16376  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16377  CalFile.write('<>\n')
16378  #
16379  CalFile.close()
16380 
16382 def SPIShiftOut(DValue):
16383  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
16384 
16385  binstr = bin(DValue)
16386  binlen = len(binstr)
16387  datastr = binstr[2:binlen]
16388  datalen = len(datastr)
16389  if datalen < 16:
16390  datastr = str.rjust(datastr , 16 , '0')
16391  datalen = len(datastr)
16392  i = 1
16393  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
16394  while i < datalen+1:
16395  # sending 0x50 = set to 0, 0x51 = set to 1
16396  D1code = 0x50 + int(datastr[i-1])
16397  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
16398  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
16399  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
16400  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
16401  i = i + 1
16402  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
16403 #
16404 def onFminScroll(event):
16405  onTextScroll(event)
16406  SetAD9833(event)
16407 
16408 def onMulXScroll(event):
16409  onTextScroll(event)
16410  SetAD9833(event)
16411 
16412 def SetAD9833(temp):
16413  global FminEntry, HtMulEntry, MinigenFout, MinigenMode # , Fclk, Fout
16414  global Two28, mclk, EnableHSsampling, MinigenScreenStatus
16415 
16416  if MinigenScreenStatus.get() == 0:
16417  return
16418  #
16419  MinigenMode.set(40)
16420  #
16421  try:
16422  MulX = float(eval(HtMulEntry.get()))
16423  if MulX < 1:
16424  MulX = 1
16425  except:
16426  if EnableHSsampling > 0:
16427  HtMulEntry.delete(0,END)
16428  HtMulEntry.insert(0, MulX)
16429  try:
16430  FminE = float(eval(FminEntry.get()))*1000
16431  except:
16432  if EnableHSsampling > 0:
16433  FminEntry.delete(0,END)
16434  FminEntry.insert(0, FminE/1000)
16435  if MulX == 1:
16436  Fmin = FminE
16437  else:
16438  Fmin = FminE - (FminE/MulX)
16439  #
16440  MinigenFout.delete(0,"end")
16441  MinigenFout.insert(0,Fmin)
16442  BSendMG()
16443 
16445 def BSendMG():
16446  global MinigenFclk, MinigenFout, MinigenMode
16447  global Two28, SCLKPort, SDATAPort, SLATCHPort
16448 
16449  DValue = 8192 + MinigenMode.get()
16450  SPIShiftOut(DValue)
16451  try:
16452  fout = float(eval(MinigenFout.get()))
16453  except:
16454  MinigenFout.delete(0,"end")
16455  MinigenFout.insert(0,100)
16456  try:
16457  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
16458  except:
16459  MingenFclk.delete(0,"end")
16460  MinigenFclk.insert(0,16)
16461  Freg = int((fout*Two28)/mclk)
16462  Foutstr = bin(Freg)
16463  Foutlen = len(Foutstr)
16464  datastr = Foutstr[2:Foutlen]
16465  datalen = len(datastr)
16466  if datalen < 28:
16467  datastr = str.rjust(datastr , 28 , '0')
16468  datalen = len(datastr)
16469  Fmsb = '0b01' + datastr[0:14]
16470  Flsb = '0b01' + datastr[14:]
16471  FValue = int(eval(Flsb))
16472  SPIShiftOut(FValue)
16473  FValue = int(eval(Fmsb))
16474  SPIShiftOut(FValue)
16475 
16478  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
16479  global SCLKPort, SDATAPort, SLATCHPort
16480  global GenericSerialStatus
16481  global PIO_0, PIO_1, PIO_2, PIO_3
16482 
16483  if GenericSerialStatus.get() == 1:
16484  GenericSerialStatus.set(0)
16486  if MinigenScreenStatus.get() == 0:
16487  MinigenScreenStatus.set(1)
16488  minigenwindow = Toplevel()
16489  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
16490  minigenwindow.resizable(FALSE,FALSE)
16491  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
16492  #
16493  MinigenMode = IntVar(0)
16494  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
16495  mgb1.grid(row=1, column=0, sticky=W)
16496  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
16497  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
16498  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
16499  mgb3.grid(row=2, column=0, sticky=W)
16500  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
16501  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
16502  f0lab = Label(minigenwindow, text="Mclk in MHz")
16503  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
16504  MinigenFclk = Entry(minigenwindow, width=5)
16505  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
16506  MinigenFclk.delete(0,"end")
16507  MinigenFclk.insert(0,16)
16508  f1lab = Label(minigenwindow, text="Output Freq")
16509  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
16510  MinigenFout = Entry(minigenwindow, width=8)
16511  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
16512  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
16513  MinigenFout.delete(0,"end")
16514  MinigenFout.insert(0,100)
16515  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
16516  bsn1.grid(row=5, column=0, sticky=W, pady=4)
16517  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
16518  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
16519  #
16520  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
16521  label3.grid(row=6, column=0, sticky=W)
16522  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
16523  sclk1.grid(row=6, column=1, sticky=W)
16524  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
16525  sclk2.grid(row=6, column=2, sticky=W)
16526  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
16527  sclk3.grid(row=6, column=3, sticky=W)
16528  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
16529  sclk4.grid(row=6, column=4, sticky=W)
16530  #
16531  label4 = Label(minigenwindow,text="SData PI/O Port ")
16532  label4.grid(row=7, column=0, sticky=W)
16533  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
16534  sdat1.grid(row=7, column=1, sticky=W)
16535  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
16536  sdat2.grid(row=7, column=2, sticky=W)
16537  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
16538  sdat3.grid(row=7, column=3, sticky=W)
16539  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
16540  sdat4.grid(row=7, column=4, sticky=W)
16541  #
16542  label5 = Label(minigenwindow,text="FSync PI/O Port ")
16543  label5.grid(row=8, column=0, sticky=W)
16544  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
16545  slth1.grid(row=8, column=1, sticky=W)
16546  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
16547  slth2.grid(row=8, column=2, sticky=W)
16548  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
16549  slth3.grid(row=8, column=3, sticky=W)
16550  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
16551  slth4.grid(row=8, column=4, sticky=W)
16552  #
16553 
16556  global minigenwindow, MinigenScreenStatus
16557 
16558  MinigenScreenStatus.set(0)
16559  minigenwindow.destroy()
16560 #
16561 def onMiniGenScroll(event):
16562  global ETSStatus, ETSDisp
16563 
16564  onTextScroll(event)
16565  BSendMG()
16566 
16568 def DA1ShiftOut(D1Value, D2Value):
16569  global devx
16570  global PIO_0, PIO_1, PIO_2, PIO_3
16571 
16572  binstr = bin(D1Value)
16573  binlen = len(binstr)
16574  data1str = binstr[2:binlen]
16575  datalen = len(data1str)
16576  if datalen < 16:
16577  data1str = str.rjust(data1str , 16 , '0')
16578  datalen = len(data1str)
16579  #
16580  binstr = bin(D2Value)
16581  binlen = len(binstr)
16582  data2str = binstr[2:binlen]
16583  datalen = len(data2str)
16584  if datalen < 16:
16585  data2str = str.rjust(data2str , 16 , '0')
16586  datalen = len(data2str)
16587  # sync --> PIO 0
16588  # D0 --> PIO 1
16589  # D1 --> PIO 2
16590  # SCLK --> PIO 3
16591  i = 1
16592 #
16593  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
16594  while i < datalen+1:
16595  # sending 0x50 = set to 0, 0x51 = set to 1
16596  D1code = 0x50 + int(data1str[i-1])
16597  D2code = 0x50 + int(data2str[i-1])
16598  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
16599  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
16600  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
16601  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
16602  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
16603  i = i + 1
16604  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
16605  #
16606 def BSendDA1():
16607  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
16608 
16609  try:
16610  RefValue = float(eval(REFEntry.get()))
16611  except:
16612  RefValue = 3.3
16613  try:
16614  D1Value = float(eval(DAC1Entry.get()))
16615  except:
16616  D1Value = 0.0129
16617  D1Code = int((D1Value/RefValue)*255)
16618  if D1Code > 255:
16619  D1Code = 255
16620  D1Code = D1Code + 0x2000
16621  try:
16622  D2Value = float(eval(DAC2Entry.get()))
16623  except:
16624  D2Value = 0.0129
16625  D2Code = int((D2Value/RefValue)*255)
16626  if D2Code > 255:
16627  D2Code = 255
16628  D2Code = D2Code + 0x2400
16629  try:
16630  D3Value = float(eval(DAC3Entry.get()))
16631  except:
16632  D3Value = 0.0129
16633  D3Code = int((D3Value/RefValue)*255)
16634  if D3Code > 255:
16635  D3Code = 255
16636  D3Code = D3Code + 0x2000
16637  try:
16638  D4Value = float(eval(DAC4Entry.get()))
16639  except:
16640  D4Value = 0.0129
16641  D4Code = int((D4Value/RefValue)*255)
16642  if D4Code > 255:
16643  D4Code = 255
16644  D4Code = D4Code + 0x2400
16645  #
16646  DA1ShiftOut(D1Code, D3Code)
16647  DA1ShiftOut(D2Code, D4Code)
16648 
16651  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
16652  global REFEntry, RevDate, SWRev
16653 
16654  if DA1ScreenStatus.get() == 0:
16655  DA1ScreenStatus.set(1)
16656  da1window = Toplevel()
16657  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
16658  da1window.resizable(FALSE,FALSE)
16659  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
16660 #
16661  d1lab = Label(da1window, text="DAC A1 output")
16662  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
16663  DAC1Entry = Entry(da1window, width=5)
16664  DAC1Entry.grid(row=0, column=1, sticky=W)
16665  DAC1Entry.delete(0,"end")
16666  DAC1Entry.insert(0,0)
16667  d2lab = Label(da1window, text="DAC B1 output")
16668  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
16669  DAC2Entry = Entry(da1window, width=5)
16670  DAC2Entry.grid(row=1, column=1, sticky=W)
16671  DAC2Entry.delete(0,"end")
16672  DAC2Entry.insert(0,0)
16673 
16674  d3lab = Label(da1window, text="DAC A2 output")
16675  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
16676  DAC3Entry = Entry(da1window, width=5)
16677  DAC3Entry.grid(row=2, column=1, sticky=W)
16678  DAC3Entry.delete(0,"end")
16679  DAC3Entry.insert(0,0)
16680 
16681  d4lab = Label(da1window, text="DAC B2 output")
16682  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
16683  DAC4Entry = Entry(da1window, width=5)
16684  DAC4Entry.grid(row=3, column=1, sticky=W)
16685  DAC4Entry.delete(0,"end")
16686  DAC4Entry.insert(0,0)
16687 
16688  d5lab = Label(da1window, text="Reference V")
16689  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
16690  REFEntry = Entry(da1window, width=5)
16691  REFEntry.grid(row=4, column=1, sticky=W)
16692  REFEntry.delete(0,"end")
16693  REFEntry.insert(0,3.3)
16694 
16695  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
16696  bsn1.grid(row=5, column=0, sticky=W)
16697  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
16698  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
16699 
16702  global da1window, DA1ScreenStatus
16703 
16704  DA1ScreenStatus.set(0)
16705  da1window.destroy()
16706 
16707 def DigPotShiftOut(DValue):
16708  global devx, SingleDualPot
16709  global PIO_0, PIO_1, PIO_2, PIO_3
16710 
16711  binstr = bin(DValue)
16712  binlen = len(binstr)
16713  datastr = binstr[2:binlen]
16714  datalen = len(datastr)
16715  if SingleDualPot.get() == 0: # send 10 bits of data
16716  if datalen < 10:
16717  datastr = str.rjust(datastr , 10 , '0')
16718  datalen = len(datastr)
16719  if SingleDualPot.get() == 1: # send 8 bits of data
16720  if datalen < 8:
16721  datastr = str.rjust(datastr , 8 , '0')
16722  datalen = len(datastr)
16723  if SingleDualPot.get() == 2: # send 8 bits of data
16724  if datalen < 8:
16725  datastr = str.rjust(datastr , 8 , '0')
16726  datalen = len(datastr)
16727  i = 1
16728  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
16729  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
16730  while i < datalen+1:
16731  # CS --> PIO 0
16732  # D0 --> PIO 1
16733  # D1 --> PIO 2
16734  # SCLK --> PIO 3
16735  D1code = 0x50 + int(datastr[i-1])
16736  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
16737  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
16738  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
16739  i = i + 1
16740  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
16741  #
16742 def DigPotSend(Temp):
16743  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
16744  global SingleDualPot
16745 
16746  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
16747  NumTaps = 255
16748  if SingleDualPot.get() == 2:
16749  NumTaps = 63
16750  try:
16751  DValue1 = DigPot1.get()
16752  if DValue1 > NumTaps:
16753  DValue1 = NumTaps
16754  except:
16755  DValue1 = 0
16756  try:
16757  DValue2 = DigPot2.get()
16758  if DValue2 > NumTaps:
16759  DValue2 = NumTaps
16760  except:
16761  DValue2 = 0
16762  try:
16763  DValue3 = DigPot3.get()
16764  if DValue3 > NumTaps:
16765  DValue3 = NumTaps
16766  except:
16767  DValue3 = 0
16768  try:
16769  DValue4 = DigPot4.get()
16770  if DValue4 > NumTaps:
16771  DValue4 = NumTaps
16772  except:
16773  DValue4 = 0
16774  if SendPot1.get() > 0:
16775  DigPotShiftOut(DValue1)
16776  if SendPot2.get() > 0:
16777  DigPotShiftOut(DValue2+NumTaps+1)
16778  if SendPot3.get() > 0:
16779  DigPotShiftOut(DValue3+2*(NumTaps+1))
16780  if SendPot4.get() > 0:
16781  DigPotShiftOut(DValue4+3*(NumTaps+1))
16782 
16784  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
16785 
16786  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
16787  DPotlabel.config(text="Enter number from 0 to 255")
16788  DigPot1.config(from_=0, to=255, length=256)
16789  DigPot2.config(from_=0, to=255, length=256)
16790  DigPot3.config(from_=0, to=255, length=256)
16791  DigPot4.config(from_=0, to=255, length=256)
16792  if SingleDualPot.get() == 2:
16793  DPotlabel.config(text="Enter number from 0 to 63")
16794  DigPot1.config(from_=0, to=63, length=64)
16795  DigPot2.config(from_=0, to=63, length=64)
16796  DigPot3.config(from_=0, to=63, length=64)
16797  DigPot4.config(from_=0, to=63, length=64)
16798 
16801  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
16802  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
16803  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
16804 
16805  if DigPotScreenStatus.get() == 0:
16806  DigPotScreenStatus.set(1)
16807  digpotwindow = Toplevel()
16808  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
16809  digpotwindow.resizable(FALSE,FALSE)
16810  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
16811  #
16812  SendPot1 = IntVar(0)
16813  SendPot1.set(1)
16814  SendPot2 = IntVar(0)
16815  SendPot2.set(1)
16816  SendPot3 = IntVar(0)
16817  SendPot3.set(0)
16818  SendPot4 = IntVar(0)
16819  SendPot4.set(0)
16820  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
16821  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
16822 
16823  SingleDualPot = IntVar(0)
16824  SingleDualPot.set(0)
16825  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
16826  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
16827  CompMenu["menu"] = CompMenu.menu
16828  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
16829  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
16830  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
16831  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
16832  lab1 = Checkbutton(digpotwindow,text="Pot 1", pady=0, variable=SendPot1)
16833  lab1.grid(row=2, column=0, sticky=W)
16834  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16835  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
16836  lab2 = Checkbutton(digpotwindow,text="Pot 2", pady=0, variable=SendPot2)
16837  lab2.grid(row=4, column=0, sticky=W)
16838  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16839  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
16840  lab3 = Checkbutton(digpotwindow,text="Pot 3", pady=0, variable=SendPot3)
16841  lab3.grid(row=6, column=0, sticky=W)
16842  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16843  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
16844  lab4 = Checkbutton(digpotwindow,text="Pot 4", pady=0, variable=SendPot4)
16845  lab4.grid(row=8, column=0, sticky=W)
16846  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16847  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
16848  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
16849  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
16850 
16852  global digpotwindow, DigPotScreenStatus
16853 
16854  DigPotScreenStatus.set(0)
16855  digpotwindow.destroy()
16856 
16857 def BSendGS():
16858  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
16859  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
16860 
16861  if AD5626SerialStatus.get() == 0:
16862  try:
16863  DValue = int(eval(DataBitsEntry.get()))
16864  if DValue < 0:
16865  DValue = 0
16866  except:
16867  DValue = 0
16868  try:
16869  NumBits = int(NumBitsEntry.get())
16870  if NumBits < 1:
16871  NumBits = 1
16872  except:
16873  NumBits = 8
16874  else:
16875  try:
16876  DValue = int(eval(AD5626Entry.get())*1000)
16877  if DValue < 0:
16878  DValue = 0
16879  AD5626Entry.delete(0,"end")
16880  AD5626Entry.insert(0,'0.000')
16881  if DValue > 4095:
16882  DValue = 4095
16883  AD5626Entry.delete(0,"end")
16884  AD5626Entry.insert(0,DValue/1000.0)
16885  except:
16886  DValue = 0
16887  AD5626Entry.delete(0,"end")
16888  AD5626Entry.insert(0,'0.000')
16889  NumBits = 12
16890  # print DValue
16891  binstr = bin(DValue)
16892  binlen = len(binstr)
16893  datastr = binstr[2:binlen]
16894  datalen = len(datastr)
16895  if datalen < NumBits:
16896  datastr = str.rjust(datastr , NumBits , '0')
16897  datalen = len(datastr)
16898  if SLatchPhase.get() == 0:
16899  LatchInt = 0x50
16900  LatchEnd = 0x51
16901  else:
16902  LatchInt = 0x51
16903  LatchEnd = 0x50
16904  if AD5626SerialStatus.get() > 0:
16905  LatchInt = 0x51
16906  LatchEnd = 0x50
16907  if SClockPhase.get() == 0:
16908  ClockInt = 0x50
16909  ClockEnd = 0x51
16910  else:
16911  ClockInt = 0x51
16912  ClockEnd = 0x50
16913  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
16914  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
16915  i = 1
16916  while i < datalen+1:
16917  if SerDirection.get() == 1: # for MSB first
16918  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
16919  else:
16920  D1code = 0x50 + int(datastr[i-1]) # for LSB first
16921  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
16922  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
16923  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
16924  i = i + 1
16925  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
16926  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
16927  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
16928  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
16929 
16932  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
16933  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
16934  global PIO_0, PIO_1, PIO_2, PIO_3
16935 
16936  if GenericSerialStatus.get() == 1:
16937  GenericSerialStatus.set(0)
16939  if AD5626SerialStatus.get() == 0:
16940  AD5626SerialStatus.set(1)
16941  ad5626window = Toplevel()
16942  ad5626window.title("AD5626 Output " + SWRev + RevDate)
16943  ad5626window.resizable(FALSE,FALSE)
16944  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
16945 #
16946  SLatchPhase = IntVar(0)
16947  SLatchPhase.set(0)
16948  SClockPhase = IntVar(0)
16949  SClockPhase.set(1)
16950  SerDirection = IntVar(0)
16951  SerDirection.set(0)
16952  #
16953  label2 = Label(ad5626window,text="Enter Output Volts")
16954  label2.grid(row=1, column=0, columnspan=1, sticky=W)
16955  AD5626Entry = Entry(ad5626window, width=10)
16956  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
16957  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
16958  AD5626Entry.delete(0,"end")
16959  AD5626Entry.insert(0,'0.000')
16960  #
16961  label3 = Label(ad5626window,text="SCLK PI/O Port ")
16962  label3.grid(row=2, column=0, columnspan=1, sticky=W)
16963  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
16964  sclk1.grid(row=2, column=1, sticky=W)
16965  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
16966  sclk2.grid(row=2, column=2, sticky=W)
16967  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
16968  sclk3.grid(row=2, column=3, sticky=W)
16969  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
16970  sclk4.grid(row=2, column=4, sticky=W)
16971  #
16972  label4 = Label(ad5626window,text="SData PI/O Port ")
16973  label4.grid(row=3, column=0, columnspan=1, sticky=W)
16974  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
16975  sdat1.grid(row=3, column=1, sticky=W)
16976  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
16977  sdat2.grid(row=3, column=2, sticky=W)
16978  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
16979  sdat3.grid(row=3, column=3, sticky=W)
16980  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
16981  sdat4.grid(row=3, column=4, sticky=W)
16982  #
16983  label5 = Label(ad5626window,text="Latch PI/O Port ")
16984  label5.grid(row=4, column=0, columnspan=1, sticky=W)
16985  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
16986  slth1.grid(row=4, column=1, sticky=W)
16987  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
16988  slth2.grid(row=4, column=2, sticky=W)
16989  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
16990  slth3.grid(row=4, column=3, sticky=W)
16991  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
16992  slth4.grid(row=4, column=4, sticky=W)
16993  #
16994  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
16995  bsn1.grid(row=5, column=0, sticky=W)
16996  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
16997  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
16998 #
16999 def onAD5626Scroll(event):
17000  onTextScroll(event)
17001  BSendGS()
17002 
17004  global ad5626window, AD5626SerialStatus
17005 
17006  AD5626SerialStatus.set(0)
17007  ad5626window.destroy()
17008 
17010  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
17011  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
17012  global PIO_0, PIO_1, PIO_2, PIO_3
17013 
17014  if GenericSerialStatus.get() == 0:
17015  GenericSerialStatus.set(1)
17016  serialwindow = Toplevel()
17017  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
17018  serialwindow.resizable(FALSE,FALSE)
17019  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
17020  #
17021  SCLKPort = IntVar(0)
17022  SCLKPort.set(PIO_2)
17023  SDATAPort = IntVar(0)
17024  SDATAPort.set(PIO_1)
17025  SLATCHPort = IntVar(0)
17026  SLATCHPort.set(PIO_0)
17027  SLatchPhase = IntVar(0)
17028  SClockPhase = IntVar(0)
17029  SerDirection = IntVar(0)
17030  label = Label(serialwindow,text="Enter number of Bits")
17031  label.grid(row=1, column=0, columnspan=2, sticky=W)
17032  NumBitsEntry = Entry(serialwindow, width=3)
17033  NumBitsEntry.grid(row=1, column=2, sticky=W)
17034  NumBitsEntry.delete(0,"end")
17035  NumBitsEntry.insert(0,8)
17036  #
17037  label2 = Label(serialwindow,text="Enter Data Word")
17038  label2.grid(row=2, column=0, columnspan=1, sticky=W)
17039  DataBitsEntry = Entry(serialwindow, width=10)
17040  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
17041  DataBitsEntry.delete(0,"end")
17042  DataBitsEntry.insert(0,0)
17043  #
17044  label3 = Label(serialwindow,text="SCLK PI/O Port ")
17045  label3.grid(row=3, column=0, columnspan=1, sticky=W)
17046  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
17047  sclk1.grid(row=3, column=1, sticky=W)
17048  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
17049  sclk2.grid(row=3, column=2, sticky=W)
17050  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
17051  sclk3.grid(row=3, column=3, sticky=W)
17052  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
17053  sclk4.grid(row=3, column=4, sticky=W)
17054  #
17055  label4 = Label(serialwindow,text="SData PI/O Port ")
17056  label4.grid(row=4, column=0, columnspan=1, sticky=W)
17057  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
17058  sdat1.grid(row=4, column=1, sticky=W)
17059  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
17060  sdat2.grid(row=4, column=2, sticky=W)
17061  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
17062  sdat3.grid(row=4, column=3, sticky=W)
17063  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
17064  sdat4.grid(row=4, column=4, sticky=W)
17065  #
17066  label5 = Label(serialwindow,text="Latch PI/O Port ")
17067  label5.grid(row=5, column=0, columnspan=1, sticky=W)
17068  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
17069  slth1.grid(row=5, column=1, sticky=W)
17070  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
17071  slth2.grid(row=5, column=2, sticky=W)
17072  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
17073  slth3.grid(row=5, column=3, sticky=W)
17074  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
17075  slth4.grid(row=5, column=4, sticky=W)
17076  #
17077  label6 = Label(serialwindow,text="Latch Phase ")
17078  label6.grid(row=6, column=0, columnspan=1, sticky=W)
17079  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
17080  sph1.grid(row=6, column=1, sticky=W)
17081  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
17082  sph2.grid(row=6, column=2, sticky=W)
17083  #
17084  label7 = Label(serialwindow,text="Clock Phase ")
17085  label7.grid(row=7, column=0, columnspan=1, sticky=W)
17086  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
17087  sph7.grid(row=7, column=1, sticky=W)
17088  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
17089  sph8.grid(row=7, column=2, sticky=W)
17090  #
17091  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
17092  sdir1.grid(row=8, column=0, sticky=W)
17093  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
17094  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
17095 
17096  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
17097  bsn1.grid(row=9, column=0, sticky=W)
17098  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
17099  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
17100 
17102  global serialwindow, GenericSerialStatus
17103 
17104  GenericSerialStatus.set(0)
17105  serialwindow.destroy()
17106 
17109  global digfltwindow, DigFiltStatus, RevDate, SWRev
17110  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
17111  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
17112 
17113  if DigFiltStatus.get() == 0:
17114  DigFiltStatus.set(1)
17115  digfltwindow = Toplevel()
17116  digfltwindow.title("Digital Filter " + SWRev + RevDate)
17117  digfltwindow.resizable(FALSE,FALSE)
17118  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
17119  #
17120  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
17121  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
17122  frame2.pack(side=LEFT, expand=1, fill=X)
17123  frame3.pack(side=LEFT, expand=1, fill=X)
17124  #
17125  digfilta = Frame( frame2 )
17126  digfilta.pack(side=TOP)
17127  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
17128  #titlab.grid(row=0, column=0, sticky=W)
17129  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
17130  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
17131  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
17132  lab3.grid(row=1, column=0, sticky=W)
17133  BCALenEntry = Entry(digfilta, width=3)
17134  BCALenEntry.bind("<Return>", onRetDigFiltA)
17135  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
17136  # BCALenEntry.bind('<Key>', onTextKey)
17137  BCALenEntry.grid(row=1, column=1, sticky=W)
17138  BCALenEntry.delete(0,"end")
17139  BCALenEntry.insert(0,2)
17140  bcalab = Label(digfilta, text="Length")
17141  bcalab.grid(row=1, column=2, sticky=W)
17142  DifFiltALength = Label(digfilta, text="Length = 0 ")
17143  DifFiltALength.grid(row=2, column=0, sticky=W)
17144  DifFiltAFile = Label(digfilta, text="File Name, none ")
17145  DifFiltAFile.grid(row=3, column=0, sticky=W)
17146  cald = Button(digfilta, text='Load CH A Filter Coef', command=BLoadDFiltA)
17147  cald.grid(row=4, column=0, columnspan=2, sticky=W)
17148  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
17149  camath.grid(row=5, column=0, columnspan=2, sticky=W)
17150  #
17151  digfiltb = Frame( frame3 )
17152  digfiltb.pack(side=TOP)
17153  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
17154  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
17155  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
17156  lab4.grid(row=1, column=0, sticky=W)
17157  BCBLenEntry = Entry(digfiltb, width=3)
17158  BCBLenEntry.bind("<Return>", onRetDigFiltB)
17159  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
17160  # BCALenEntry.bind('<Key>', onTextKey)
17161  BCBLenEntry.grid(row=1, column=1, sticky=W)
17162  BCBLenEntry.delete(0,"end")
17163  BCBLenEntry.insert(0,2)
17164  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
17165  DifFiltBLength.grid(row=2, column=0, sticky=W)
17166  DifFiltBFile = Label(digfiltb,text="File Name, none ")
17167  DifFiltBFile.grid(row=3, column=0, sticky=W)
17168  camath.grid(row=8, column=0, sticky=W)
17169  cbld = Button(digfiltb, text='Load CH B Filter Coef', command=BLoadDFiltB)
17170  cbld.grid(row=4, column=0, sticky=W)
17171  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
17172  cbmath.grid(row=5, column=0, sticky=W)
17173  dismissdfbutton = Button(digfiltb, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
17174  dismissdfbutton.grid(row=6, column=0, columnspan=1, sticky=W)
17175  #
17176 def onRetDigFiltA(event):
17177  BuildBoxCarA()
17178 
17179 def onDigFiltAScroll(event):
17180  onTextScroll(event)
17181  BuildBoxCarA()
17182 
17184  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
17185 
17186  if DigFiltABoxCar.get() == 0:
17187  return
17188 
17189  FLength = int(BCALenEntry.get())
17190  if FLength < 2:
17191  return
17192 
17193  DFiltACoef = [] # empty coef array
17194 
17195  for n in range(FLength):
17196  DFiltACoef.append(float(1.0/FLength))
17197 
17198  DFiltACoef = numpy.array(DFiltACoef)
17199  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17200 
17201 def onRetDigFiltB(event):
17202  BuildBoxCarB()
17203 
17204 def onDigFiltBScroll(event):
17205  onTextScroll(event)
17206  BuildBoxCarB()
17207 
17209  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
17210 
17211  if DigFiltBBoxCar.get() == 0:
17212  return
17213 
17214  FLength = int(BCBLenEntry.get())
17215  if FLength < 2:
17216  return
17217 
17218  DFiltBCoef = [] # empty coef array
17219 
17220  for n in range(FLength):
17221  DFiltBCoef.append(float(1.0/FLength))
17222 
17223  DFiltBCoef = numpy.array(DFiltBCoef)
17224  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17225 
17227  global digfltwindow, DigFiltStatus
17228 
17229  DigFiltStatus.set(0)
17230  digfltwindow.destroy()
17231 
17233  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
17234 
17235 # Read values from CVS file
17236  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
17237  try:
17238  CSVFile = open(filename)
17239  csv_f = csv.reader(CSVFile)
17240  except:
17241  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
17242  return
17243  DFiltACoef = []
17244 
17245  for row in csv_f:
17246  try:
17247  DFiltACoef.append(float(row[0]))
17248  except:
17249  print( 'skipping non-numeric row')
17250  DFiltACoef = numpy.array(DFiltACoef)
17251  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17252  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
17253  CSVFile.close()
17254 #
17256  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
17257 
17258  TempString = DigFilterAString
17259  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
17260  if (DigFilterAString == None): # If Cancel pressed, then None
17261  DigFilterAString = TempString
17262  return
17263  DFiltACoef = eval(DigFilterAString)
17264  DFiltACoef = numpy.array(DFiltACoef)
17265  coefsum = numpy.sum(DFiltACoef)
17266  DFiltACoef = DFiltACoef / coefsum
17267  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17268  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
17269 
17271  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
17272 
17273 # Read values from CVS file
17274  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
17275  try:
17276  CSVFile = open(filename)
17277  csv_f = csv.reader(CSVFile)
17278  except:
17279  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
17280  return
17281  DFiltBCoef = []
17282 
17283  for row in csv_f:
17284  try:
17285  DFiltBCoef.append(float(row[0]))
17286  except:
17287  print( 'skipping non-numeric row')
17288  DFiltBCoef = numpy.array(DFiltBCoef)
17289  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17290  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
17291  CSVFile.close()
17292 #
17294  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
17295 
17296  TempString = DigFilterBString
17297  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
17298  if (DigFilterBString == None): # If Cancel pressed, then None
17299  DigFilterBString = TempString
17300  return
17301  DFiltBCoef = eval(DigFilterBString)
17302  DFiltBCoef = numpy.array(DFiltBCoef)
17303  coefsum = numpy.sum(DFiltBCoef)
17304  DFiltBCoef = DFiltBCoef / coefsum
17305  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17306  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
17307 #
17309  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
17310 
17311  if CommandStatus.get() == 0:
17312  CommandStatus.set(1)
17313  commandwindow = Toplevel()
17314  commandwindow.title("Command Line " + SWRev + RevDate)
17315  commandwindow.resizable(FALSE,FALSE)
17316  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
17317  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
17318  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
17319  cl1 = Label(commandwindow,text="Last command:")
17320  cl1.grid(row=1, column=0, sticky=W)
17321  LastCommand = Label(commandwindow,text=" ")
17322  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
17323  ExecString = Entry(commandwindow, width=40)
17324  ExecString.bind("<Return>", RExecuteFromString)
17325  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
17326  ExecString.delete(0,"end")
17327  ExecString.insert(0,"global ; ")
17328  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
17329  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
17330  #
17331  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
17332  dismissclbutton.grid(row=4, column=1, sticky=W, pady=7)
17333 
17335  global commandwindow, CommandStatus
17336 
17337  CommandStatus.set(0)
17338  commandwindow.destroy()
17339 
17341 
17343 
17344 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
17345  global ExecString, LastCommand
17346 
17347  try:
17348  exec( ExecString.get() )
17349  LastCommand.config(text = ExecString.get() ) # change displayed last command
17350  except:
17351  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
17352  return()
17353 #
17354 def CAresize(event):
17355  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
17356 
17357  XOL = FontSize * 7
17358  CANVASwidth = event.width - 4
17359  CANVASheight = event.height - 4
17360  GRW = CANVASwidth - (2 * X0L) # new grid width
17361  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
17362  UpdateTimeAll()
17363 #
17365  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
17366  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
17367  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
17368  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
17369  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
17370  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
17371 
17372  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
17373  ChaValue1.config(text = ValueText)
17374  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
17375  ChaValue2.config(text = ValueText)
17376  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
17377  ChaValue3.config(text = ValueText)
17378  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
17379  ChaValue4.config(text = ValueText)
17380  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
17381  ChaValue5.config(text = ValueText)
17382  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
17383  ChaValue6.config(text = ValueText)
17384  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
17385  ChbValue1.config(text = ValueText)
17386  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
17387  ChbValue2.config(text = ValueText)
17388  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
17389  ChbValue3.config(text = ValueText)
17390  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
17391  ChbValue4.config(text = ValueText)
17392  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
17393  ChbValue5.config(text = ValueText)
17394  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
17395  ChbValue6.config(text = ValueText)
17396 #
17398  global measurewindow, MeasureStatus, RevDate, SWRev
17399  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
17400  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
17401  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
17402  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
17403  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
17404  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
17405 
17406  if MeasureStatus.get() == 0:
17407  MeasureStatus.set(1)
17408  measurewindow = Toplevel()
17409  measurewindow.title("Measurements " + SWRev + RevDate)
17410  measurewindow.resizable(FALSE,FALSE)
17411  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
17412  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
17413  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
17414  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
17415  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
17416  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17417  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
17418  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
17419  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
17420  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17421  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
17422  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
17423  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
17424  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17425  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
17426  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
17427  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
17428  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17429  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
17430  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
17431  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
17432  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17433  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
17434  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
17435  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
17436  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17437  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
17438  #
17439  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
17440  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
17441  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17442  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
17443  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
17444  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
17445  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17446  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
17447  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
17448  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
17449  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17450  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
17451  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
17452  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
17453  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17454  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
17455  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
17456  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
17457  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17458  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
17459  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
17460  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
17461  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17462  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
17463 #
17465  global measurewindow, MeasureStatus
17466 
17467  MeasureStatus.set(0)
17468  measurewindow.destroy()
17469 #
17471  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
17472  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
17473 
17474  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
17475  if BoardStatus.get() == 0:
17476  BoardStatus.set(1)
17477  boardwindow = Toplevel()
17478  boardwindow.title("Select Board " + RevDate)
17479  boardwindow.resizable(FALSE,FALSE)
17480  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
17481  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
17482  toplab.pack(side=TOP)
17483  for idx, devx in enumerate(session.devices):
17484  BrdText = "Board # " + str(idx)
17485  if idx == 0:
17486  devx.set_led(0b010) # LED.green
17487  FWRevOne = float(devx.fwver)
17488  HWRevOne = devx.hwver
17489  dev0 = devx #session.devices[0]
17490  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
17491  elif idx == 1:
17492  devx.set_led(0b100) # LED.blue,
17493  FWRevTwo = float(devx.fwver)
17494  HWRevTwo = devx.hwver
17495  dev1 = devx #session.devices[1]
17496  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
17497  elif idx == 2:
17498  devx.set_led(0b001) # LED.red,
17499  FWRevThree = float(devx.fwver)
17500  HWRevThree = devx.hwver
17501  dev2 = devx #session.devices[2]
17502  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
17503  else:
17504  dev3 = session.devices[3]
17505  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
17506  brd.pack(side=TOP)
17507  else:
17508  devx = session.devices[0]
17509  # devx.ignore_dataflow = True
17510  #devx.set_led(0b010) # LED.green
17511  try:
17512  FWRevOne = float(devx.fwver)
17513  HWRevOne = devx.hwver
17514  except:
17515  FWRevOne = "Before 2.06"
17516  HWRevOne = "?"
17517  dev0 = session.devices[0]
17518 #
17520  global boardwindow, BoardStatus
17521 
17522  BoardStatus.set(0)
17523  boardwindow.destroy()
17524 #
17526  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
17527  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
17528 
17529  if DevID == "No Device" or DevID == "m1k":
17530  #print("Request sample rate: " + str(SAMPLErate))
17531  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
17532  # session.add_all()
17533  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
17534  if not session.devices:
17535  print( 'No Device plugged IN!')
17536  DevID = "No Device"
17537  FWRevOne = 0.0
17538  bcon.configure(text="Recon", style="RConn.TButton")
17539  return
17540  session.configure(sample_rate=SAMPLErate)
17541  #print("Session sample rate: " + str(session.sample_rate))
17542  MakeBoardScreen()
17543  SelectBoard()
17544  bcon.configure(text="Conn", style="GConn.TButton")
17545  devx.set_adc_mux(0)
17546  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
17547  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
17548 
17552  session.start(0)
17553 #
17555  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
17556  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
17557  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
17558 
17559  if RUNstatus.get() == 1:
17560  BStop()
17561  print( "STOP")
17562 
17563  if BrdSel.get() == 0:
17564  try:
17565  session.remove(dev1)
17566  print( "Removing dev1")
17567  except:
17568  print( "Skipping dev1")
17569  try:
17570  session.remove(dev2)
17571  print( "Removing dev2")
17572  except:
17573  print( "Skipping dev2")
17574  session.add(dev0)
17575  devx = dev0
17576  #session.add(devx)
17577  if BrdSel.get() == 1:
17578  try:
17579  session.remove(dev0)
17580  print( "Removing dev0")
17581  except:
17582  print( "Skipping dev0")
17583  try:
17584  session.remove(dev2)
17585  print( "Removing dev2")
17586  except:
17587  print( "Skipping dev2")
17588  session.add(dev1)
17589  devx = dev1
17590  #session.add(devx)
17591  DevID = devx.serial
17592  print( DevID)
17593  FWRevOne = float(devx.fwver)
17594  HWRevOne = str(devx.hwver)
17595  print( FWRevOne, HWRevOne)
17596  print("Session sample rate: " + str(session.sample_rate))
17597 
17598  if IgnoreFirmwareCheck == 0:
17599  if FWRevOne < 2.17:
17600  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
17601  UpdateFirmware()
17602  cal = devx.calibration
17603  CHA = devx.channels['A'] # Open CHA
17604  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
17605  CHB = devx.channels['B'] # Open CHB
17606  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
17607  #
17608  # if session.continuous == 0:
17609  #session.start(0)
17610 
17619  devx.set_adc_mux(0)
17620  if devx.hwver == "F":
17621  print( "Rev F Board I/O ports set")
17622  PIO_0 = 28
17623  PIO_1 = 29
17624  PIO_2 = 47
17625  PIO_3 = 3
17626  PIO_4 = 4
17627  PIO_5 = 5
17628  PIO_6 = 6
17629  PIO_7 = 7
17630  else:
17631  PIO_0 = 0
17632  PIO_1 = 1
17633  PIO_2 = 2
17634  PIO_3 = 3
17635  PIO_4 = 4
17636  PIO_5 = 5
17637  PIO_6 = 6
17638  PIO_7 = 7
17639 #
17640  SDATAPort.set(PIO_1)
17641  SCLKPort.set(PIO_2)
17642  SLATCHPort.set(PIO_0)
17643 
17645  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
17646  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
17647  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
17648 
17649  if SampleRateStatus.get() == 0:
17650  SampleRateStatus.set(1)
17651  SampleRatewindow = Toplevel()
17652  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
17653  SampleRatewindow.resizable(FALSE,FALSE)
17654  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
17655  frame1 = Frame(SampleRatewindow, borderwidth=5, relief=RIDGE)
17656  frame1.grid(row=0, column=0, sticky=W)
17657  #
17658  BaseRATE = Frame( frame1 )
17659  BaseRATE.grid(row=0, column=0, sticky=W)
17660  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
17661  baseratelab.pack(side=LEFT)
17662  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
17663  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
17664  BaseRatesb.bind("<Return>", onRetSrate)
17665  BaseRatesb.pack(side=LEFT)
17666  BaseRatesb.delete(0,"end")
17667  BaseRatesb.insert(0,BaseSampleRate)
17668  #BaseRateEntry = Entry(BaseRATE, width=6) #
17669  #BaseRateEntry.pack(side=LEFT)
17670  #BaseRateEntry.bind('<MouseWheel>', onSrateScroll)
17671 
17672  #BaseRateEntry.delete(0,"end")
17673  #BaseRateEntry.insert(0,BaseSampleRate)
17674  #
17675  nextrow = 2
17676  if FWRevOne > 2.16:
17677  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
17678  twoX.grid(row=1, column=0, sticky=W)
17679  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
17680  muxlab1.grid(row=2, column=0, sticky=W)
17681  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
17682  AltSweep.grid(row=3, column=0, sticky=W)
17683  chabuttons = Frame( frame1 )
17684  chabuttons.grid(row=4, column=0, sticky=W)
17685  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
17686  muxrb1.pack(side=LEFT)
17687  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
17688  muxrb2.pack(side=LEFT)
17689  chcbuttons = Frame( frame1 )
17690  chcbuttons.grid(row=5, column=0, sticky=W)
17691  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
17692  muxrb5.pack(side=LEFT)
17693  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
17694  muxrb6.pack(side=LEFT)
17695  nextrow = 6
17696  if DeBugMode == 1:
17697  chbbuttons = Frame( frame1 )
17698  chbbuttons.grid(row=nextrow, column=0, sticky=W)
17699  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
17700  muxrb3.pack(side=LEFT)
17701  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
17702  muxrb4.pack(side=LEFT)
17703  nextrow = nextrow + 1
17704  #
17705  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
17706  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
17707 #
17709  global SampleRatewindow, SampleRateStatus
17710 
17711  SampleRateStatus.set(0)
17712  SampleRatewindow.destroy()
17713 #
17714 #
17715 def onSrateScroll(event):
17716 
17717  #onTextScroll
17718  onSpinBoxScroll(event)
17719  SetSampleRate()
17720 #
17721 def onRetSrate(event):
17722 
17723  SetSampleRate()
17724 #
17726  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
17727  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
17728 
17729  #
17730  WasRunning = 0
17731  if (RUNstatus.get() == 1):
17732  WasRunning = 1
17733  BStop() # Force Stop loop if running
17734  try:
17735  NewRate = int(BaseRatesb.get())
17736  if NewRate <= 100000: # rate has to be less than or equal to 100,000
17737  BaseSampleRate = NewRate
17738  else:
17739  BaseSampleRate = 100000
17740  BaseRatesb.delete(0,"end")
17741  BaseRatesb.insert(0,BaseSampleRate)
17742  SAMPLErate = BaseSampleRate # Scope sample rate
17743  except:
17744  donothing()
17745  session.configure(sample_rate=BaseSampleRate)
17746  # calculate actual sample rate
17747  # minimum clock cycles per sample (100ksps)
17748  m_min_per = 240
17749  # maximum clock cycles per sample (~1024 samples/s)
17750  m_max_per = 24000
17751  sample_time = 1.0 / BaseSampleRate
17752  M1K_timer_clock = 48e6
17753  m_sam_per = round(sample_time * M1K_timer_clock) / 2
17754  if (m_sam_per < m_min_per):
17755  m_sam_per = m_min_per
17756  elif (m_sam_per > m_max_per):
17757  m_sam_per = m_max_per;
17758  # convert back to the actual sample time
17759  sample_time = m_sam_per / M1K_timer_clock
17760  # convert back to the actual sample rate
17761  BaseSampleRate = int(round((1.0 / sample_time) / 2.0))
17762  SAMPLErate = BaseSampleRate # Scope sample rate
17763  AWGSAMPLErate = BaseSampleRate
17764  if ETSStatus.get() > 0:
17765  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
17766  rtsrlab.config(text=SRstring)
17767  ETSUpdate()
17768  BaseRatesb.delete(0,"end")
17769  BaseRatesb.insert(0,BaseSampleRate)
17770  ReMakeAWGwaves() # remake AWG waveforms for new rate
17771  if (WasRunning == 1):
17772  WasRunning = 0
17773  BStart() # restart loop if was running
17774 #
17775 def onStopfreqScroll(event):
17776  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
17777 
17778  onTextScroll(event)
17779  try:
17780  StopFrequency = float(StopFreqEntry.get())
17781  except:
17782  StopFreqEntry.delete(0,"end")
17783  StopFreqEntry.insert(0,50000)
17784  StopFrequency = 50000
17785  if FWRevOne > 2.16:
17786  if StopFrequency >= 50000:
17787  Two_X_Sample.set(1)
17788  ADC_Mux_Mode.set(0)
17789  SetADC_Mux()
17790  else:
17791  Two_X_Sample.set(0)
17792  ADC_Mux_Mode.set(0)
17793  SetADC_Mux()
17794 #
17795 def onStopBodeScroll(event):
17796  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
17797 
17798  onTextScroll(event)
17799  try:
17800  StopFrequency = float(StopBodeEntry.get())
17801  except:
17802  StopBodeEntry.delete(0,"end")
17803  StopBodeEntry.insert(0,20000)
17804  StopFrequency = 20000
17805  if FWRevOne > 2.16:
17806  if StopFrequency >= 20000:
17807  Two_X_Sample.set(1)
17808  ADC_Mux_Mode.set(0)
17809  SetADC_Mux()
17810  else:
17811  Two_X_Sample.set(0)
17812  ADC_Mux_Mode.set(0)
17813  SetADC_Mux()
17814 #
17816  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
17817  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
17818 
17819  if Two_X_Sample.get() == 1:
17820  if ADC_Mux_Mode.get() == 0: # VA and VB
17821  devx.set_adc_mux(1)
17822  elif ADC_Mux_Mode.get() == 1: # IA and IB
17823  devx.set_adc_mux(2)
17824  elif ADC_Mux_Mode.get() == 2: # VA and IB
17825  # cycle trhough default mux values as starting point
17826  devx.set_adc_mux(2)
17827  # now set new mux values
17828  devx.set_adc_mux(7)
17829  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
17830  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
17831  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
17832  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
17833  time.sleep(0.1)
17834  elif ADC_Mux_Mode.get() == 3: # VB and IA
17835  # cycle trhough default mux values as starting point
17836  # now set new mux values
17837  devx.set_adc_mux(7)
17838  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
17839  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
17840  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
17841  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
17842  time.sleep(0.1)
17843  elif ADC_Mux_Mode.get() == 4: # VA and IA
17844  # now set new mux values
17845  devx.set_adc_mux(4)
17846  elif ADC_Mux_Mode.get() == 5: # VB and IB
17847  # now set new mux values
17848  devx.set_adc_mux(5)
17849  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
17850  else:
17851  devx.set_adc_mux(0)
17852  SAMPLErate = BaseSampleRate
17853 #
17855  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
17856 
17857  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17858  ADC_Mux_Mode.set(0) # All four traces
17859  Alternate_Sweep_Mode.set(1)
17860  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
17861  ADC_Mux_Mode.set(0) # three traces
17862  Alternate_Sweep_Mode.set(1)
17863  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
17864  ADC_Mux_Mode.set(0) # three traces
17865  Alternate_Sweep_Mode.set(1)
17866  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17867  ADC_Mux_Mode.set(0) # three traces
17868  Alternate_Sweep_Mode.set(1)
17869  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17870  ADC_Mux_Mode.set(0) # three traces
17871  Alternate_Sweep_Mode.set(1)
17872  #
17873  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
17874  ADC_Mux_Mode.set(1) # IA and IB
17875  Alternate_Sweep_Mode.set(0)
17876  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
17877  ADC_Mux_Mode.set(1) # just IA
17878  Alternate_Sweep_Mode.set(0)
17879  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
17880  ADC_Mux_Mode.set(1) # just IB
17881  Alternate_Sweep_Mode.set(0)
17882  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
17883  ADC_Mux_Mode.set(4) # VA and IA
17884  Alternate_Sweep_Mode.set(0)
17885  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17886  ADC_Mux_Mode.set(5) # VB and IB
17887  Alternate_Sweep_Mode.set(0)
17888  else:
17889  ADC_Mux_Mode.set(0)
17890  Alternate_Sweep_Mode.set(0)
17891  SetADC_Mux()
17892  UpdateTimeTrace()
17893 #
17895  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
17896  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
17897 
17898  RUNstatus.set(0)
17899  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
17900  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
17901  print( filename)
17902  #print DevID
17903  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
17904  try:
17905  print( "Cancel current session.")
17906  session.cancel()
17907  print( session.cancelled)
17908  session.end()
17909  print( "Waiting 5...")
17910  time.sleep(5)
17911  print( "Put board in Samba mode and flash firmware.")
17912  session.flash_firmware(filename)
17913  except:
17914  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
17915 
17923  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
17924  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
17925  Bcloseexit()
17926 
17936  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
17937  global CHATestVEntry, CHATestREntry, SWRev, AWGSync
17938 
17939  if OhmStatus.get() == 0:
17940  AWGSync.set(1)
17941  OhmStatus.set(1)
17942  OhmDisp.set(1)
17943  OhmCheckBox()
17944  ohmwindow = Toplevel()
17945  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
17946  ohmwindow.resizable(FALSE,FALSE)
17947  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
17948  frame1 = Frame(ohmwindow, borderwidth=5, relief=RIDGE)
17949  frame1.grid(row=0, column=0, sticky=W)
17950  #
17951  buttons = Frame( frame1 )
17952  buttons.grid(row=0, column=0, sticky=W)
17953  rb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
17954  rb1.pack(side=LEFT)
17955  rb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
17956  rb2.pack(side=LEFT)
17957  #
17958  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
17959  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
17960  OhmA0.config(text = "0.000 Ohms")
17961 
17962  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
17963  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
17964  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
17965  #
17966  TestVA = Frame( frame1 )
17967  TestVA.grid(row=3, column=0, sticky=W)
17968  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
17969  chatestvlab.pack(side=LEFT)
17970  CHATestVEntry = Entry(TestVA, width=6) #
17971  CHATestVEntry.pack(side=LEFT)
17972  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
17973  CHATestVEntry.delete(0,"end")
17974  CHATestVEntry.insert(0,5.0)
17975  #
17976  RMode = IntVar(0)
17977  RMode.set(1)
17978  TestMode = Frame( frame1 )
17979  TestMode.grid(row=4, column=0, sticky=W)
17980  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
17981  modelab.pack(side=LEFT)
17982  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
17983  rm3.pack(side=LEFT)
17984  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
17985  rm4.pack(side=LEFT)
17986  #
17987  TestRA = Frame( frame1 )
17988  TestRA.grid(row=5, column=0, sticky=W)
17989  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
17990  chatestrlab.pack(side=LEFT)
17991  CHATestREntry = Entry(TestRA, width=6) #
17992  CHATestREntry.pack(side=LEFT)
17993  CHATestREntry.bind('<MouseWheel>', onTextScroll)
17994  CHATestREntry.delete(0,"end")
17995  CHATestREntry.insert(0,50.0)
17996  #
17997  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
17998  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
17999 #
18001  global ohmwindow, OhmStatus, OhmDisp
18002 
18003  OhmStatus.set(0)
18004  OhmDisp.set(0)
18005  OhmCheckBox()
18006  ohmwindow.destroy()
18007 #
18009  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
18010  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
18011 
18012  #
18013  if ETSStatus.get() == 0:
18014  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
18015  ETSStatus.set(1)
18016  ETSDisp.set(0)
18017  etswindow = Toplevel()
18018  etswindow.title("ETS Controls " + SWRev + RevDate)
18019  etswindow.resizable(FALSE,FALSE)
18020  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
18021  frame1 = Frame(etswindow, borderwidth=5, relief=RIDGE)
18022  frame1.grid(row=0, column=0, sticky=W)
18023  # Sampling controls Widgets
18024  SRstring = "RT Sample Rate = " + str(SAMPLErate)
18025  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
18026  rtsrlab.grid(row=1, column=0, sticky=W)
18027  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
18028  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
18029  etssrlab.grid(row=2, column=0, sticky=W)
18030  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
18031  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
18032  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
18033  enb1.grid(row=4, column=0, sticky=W)
18034  #
18035  Divx = Frame( frame1 )
18036  Divx.grid(row=5, column=0, sticky=W)
18037  DivXEntry = Entry(Divx, width=6)
18038  DivXEntry.bind('<MouseWheel>', ETSscroll)
18039  DivXEntry.pack(side=RIGHT)
18040  DivXEntry.delete(0,"end")
18041  DivXEntry.insert(0,2)
18042  divxlab = Label( Divx, text = "Divide Factor")
18043  divxlab.pack(side=RIGHT)
18044  #
18045  FOffEntry = Label(frame1, text="Samples")
18046  FOffEntry.grid(row=6, column=0, sticky=W)
18047  MulXEntry = Label( frame1, text = "Rec Len Mul")
18048  MulXEntry.grid(row=7, column=0, sticky=W)
18049  #
18050  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
18051  eqivsamplerate.grid(row=8, column=0, sticky=W)
18052  #
18053  FConv = Frame( frame1 )
18054  FConv.grid(row=9, column=0, sticky=W)
18055  FMulXEntry = Entry(FConv, width=3)
18056  FMulXEntry.bind('<MouseWheel>', ETSscroll)
18057  FMulXEntry.pack(side=RIGHT)
18058  FMulXEntry.delete(0,"end")
18059  FMulXEntry.insert(0,1)
18060  fminlab = Label( FConv, text = "Freq Multiplier")
18061  fminlab.pack(side=RIGHT)
18062  #
18063  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
18064  FminDisp.grid(row=10, column=0, sticky=W)
18065  #
18066  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
18067  mgloadbutton.grid(row=11, column=0, sticky=W)
18068  #
18069  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
18070  dirlab.grid(row=12, column=0, sticky=W)
18071  DataMode = Frame( frame1 )
18072  DataMode.grid(row=13, column=0, sticky=W)
18073  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
18074  dm3.pack(side=LEFT)
18075  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
18076  dm4.pack(side=LEFT)
18077  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
18078  tclab.grid(row=14, column=0, sticky=W)
18079  TSMode = Frame( frame1 )
18080  TSMode.grid(row=15, column=0, sticky=W)
18081  ETSts = Entry(TSMode, width=6)
18082  ETSts.bind('<MouseWheel>', ETSscroll)
18083  ETSts.pack(side=RIGHT)
18084  ETSts.delete(0,"end")
18085  ETSts.insert(0,1)
18086  ETStslab = Label( TSMode, text = "Factor")
18087  ETStslab.pack(side=RIGHT)
18088  #
18089  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
18090  etsdismissclbutton.grid(row=16, column=0, sticky=W, pady=7)
18091  ETSDisp.set(0)
18092  ETSCheckBox()
18093 #
18095  global etswindow, ETSStatus, ETSDisp
18096 
18097  ETSStatus.set(0)
18098  ETSDisp.set(0)
18099  ETSCheckBox()
18100  etswindow.destroy()
18101 #
18102 def MGLoad():
18103  global MinigenFout, Fmin, ETSDir
18104 
18105  MinigenFout.delete(0,"end")
18106  if ETSDir.get() == 0:
18107  MinigenFout.insert(0,Fmin+20)
18108  else:
18109  MinigenFout.insert(0,Fmin-20)
18110  BSendMG()
18111 #
18112 def ETSscroll(event):
18113  onTextScroll(event)
18114  ETSUpdate()
18115 #
18117  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
18118  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
18119  global FminEntry, HtMulEntry, Two_X_Sample
18120 
18121  if TIMEdiv > 0.2:
18122  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
18123  else:
18124  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
18125  if (MaxETSrecord*100) > MaxSamples:
18126  MaxETSrecord = MaxSamples / 100
18127  try:
18128  DivX = float(eval(DivXEntry.get()))
18129  if DivX < 2:
18130  DivX = 2
18131  if DivX > 75:
18132  DivX = 75
18133  DivXEntry.delete(0,END)
18134  DivXEntry.insert(0, DivX)
18135  except:
18136  DivXEntry.delete(0,END)
18137  DivXEntry.insert(0, DivX)
18138  #
18139  try:
18140  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
18141  except:
18142  FminEntry.delete(0,END)
18143  FminEntry.insert(0, 25)
18144  #
18145  FOff = 25
18146  MulX = (DivX*SAMPLErate)/(100*FOff)
18147  while MulX > MaxETSrecord:
18148  FOff = FOff + 5
18149  MulX = (DivX*SAMPLErate)/(100*FOff)
18150  FOff = 0 - FOff
18151  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
18152  MulXEntry.config(text = SRstring) # change displayed value
18153  SRstring = "Offset = " + str(FOff) + " samples"
18154  FOffEntry.config(text = SRstring) # change displayed value
18155  baseFreq = SAMPLErate/DivX
18156  try:
18157  FMul = float(eval(FMulXEntry.get()))
18158  if FMul < 1:
18159  FMul = 1
18160  FMulXEntry.delete(0,END)
18161  FMulXEntry.insert(0, int(FMul))
18162  if FMul > 75:
18163  FMul = 75
18164  FMulXEntry.delete(0,END)
18165  FMulXEntry.insert(0, int(FMul))
18166  except:
18167  FMulXEntry.delete(0,END)
18168  FMulXEntry.insert(0, int(FMul))
18169  FreqMin = baseFreq * FMul
18170  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
18171  FminDisp.config(text = SRstring) # change displayed value
18172  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
18173  eqivsamplerate.config(text = SRstring) # change displayed value
18174  # calculate time scale multiplication factor
18175  try: # catch for divide by zero
18176  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
18177  except:
18178  TscaleX = 1
18179 
18180  if TscaleX > 0:
18181  ETSDir.set(0) # set sample direction to forward if positive
18182  else:
18183  ETSDir.set(1) # set sample direction to reverse if negative
18184  TscaleX = abs(TscaleX)
18185  if Two_X_Sample.get() == 0:
18186  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
18187  else:
18188  ToffsetX = 0
18189 
18190  ETSts.delete(0,"end")
18191  ETSts.insert(0,ToffsetX)
18192 
18193  HtMulEntry.delete(0,END)
18194  HtMulEntry.insert(0, TscaleX)
18195  SRstring = "RT Sample Rate = " + str(SAMPLErate)
18196  rtsrlab.config(text=SRstring)
18197  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
18198  etssrlab.config(text=SRstring)
18199 #
18200 def Settingsscroll(event):
18201  onTextScroll(event)
18202  SettingsUpdate()
18203 #
18205  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
18206  global Settingswindow, SettingsStatus, SettingsDisp, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
18207  global AWG_Amp_Mode, SWRev
18208  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
18209  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
18210  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
18211  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
18212 
18213  if SettingsStatus.get() == 0:
18214  Settingswindow = Toplevel()
18215  Settingswindow.title("Settings " + SWRev + RevDate)
18216  Settingswindow.resizable(FALSE,FALSE)
18217  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
18218  frame1 = Frame(Settingswindow, borderwidth=5, relief=RIDGE)
18219  frame1.grid(row=0, column=0, sticky=W)
18220  #
18221  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
18222  zstlab.grid(row=0, column=0, sticky=W)
18223  zstMode = Frame( frame1 )
18224  zstMode.grid(row=0, column=1, sticky=W)
18225  ZSTuff = Entry(zstMode, width=4)
18226  ZSTuff.bind('<MouseWheel>', Settingsscroll)
18227  ZSTuff.bind('<Key>', onTextKey)
18228  ZSTuff.pack(side=RIGHT)
18229  ZSTuff.delete(0,"end")
18230  ZSTuff.insert(0,ZEROstuffing.get())
18231  #
18232  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
18233  Avglab.grid(row=1, column=0, sticky=W)
18234  AvgMode = Frame( frame1 )
18235  AvgMode.grid(row=1, column=1, sticky=W)
18236  TAvg = Entry(AvgMode, width=4)
18237  TAvg.bind('<MouseWheel>', Settingsscroll)
18238  TAvg.bind('<Key>', onTextKey)
18239  TAvg.pack(side=RIGHT)
18240  TAvg.delete(0,"end")
18241  TAvg.insert(0,TRACEaverage.get())
18242  #
18243  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
18244  HarMlab.grid(row=2, column=0, sticky=W)
18245  HarMMode = Frame( frame1 )
18246  HarMMode.grid(row=2, column=1, sticky=W)
18247  HarMon = Entry(HarMMode, width=4)
18248  HarMon.bind('<MouseWheel>', Settingsscroll)
18249  HarMon.bind('<Key>', onTextKey)
18250  HarMon.pack(side=RIGHT)
18251  HarMon.delete(0,"end")
18252  HarMon.insert(0,HarmonicMarkers.get())
18253  #
18254  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
18255  Vdivlab.grid(row=3, column=0, sticky=W)
18256  VdivMode = Frame( frame1 )
18257  VdivMode.grid(row=3, column=1, sticky=W)
18258  VDivE = Entry(VdivMode, width=4)
18259  VDivE.bind('<MouseWheel>', Settingsscroll)
18260  VDivE.bind('<Key>', onTextKey)
18261  VDivE.pack(side=RIGHT)
18262  VDivE.delete(0,"end")
18263  VDivE.insert(0,Vdiv.get())
18264  #
18265  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
18266  Twdthlab.grid(row=4, column=0, sticky=W)
18267  TwdthMode = Frame( frame1 )
18268  TwdthMode.grid(row=4, column=1, sticky=W)
18269  TwdthE = Entry(TwdthMode, width=4)
18270  TwdthE.bind('<MouseWheel>', Settingsscroll)
18271  TwdthE.bind('<Key>', onTextKey)
18272  TwdthE.pack(side=RIGHT)
18273  TwdthE.delete(0,"end")
18274  TwdthE.insert(0,TRACEwidth.get())
18275  #
18276  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
18277  Gwdthlab.grid(row=5, column=0, sticky=W)
18278  GwdthMode = Frame( frame1 )
18279  GwdthMode.grid(row=5, column=1, sticky=W)
18280  GwdthE = Entry(GwdthMode, width=4)
18281  GwdthE.bind('<MouseWheel>', Settingsscroll)
18282  GwdthE.bind('<Key>', onTextKey)
18283  GwdthE.pack(side=RIGHT)
18284  GwdthE.delete(0,"end")
18285  GwdthE.insert(0,GridWidth.get())
18286  #
18287  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
18288  AwgAmplrb1.grid(row=6, column=0, sticky=W)
18289  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
18290  AwgAmplrb2.grid(row=6, column=1, sticky=W)
18291  #
18292  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
18293  cha_Rcomplab.grid(row=7, column=0, sticky=W)
18294  cha_RcomplabMode = Frame( frame1 )
18295  cha_RcomplabMode.grid(row=7, column=1, sticky=W)
18296  cha_TC1Entry = Entry(cha_RcomplabMode, width=5)
18297  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
18298  cha_TC1Entry.bind('<Key>', onTextKey)
18299  cha_TC1Entry.pack(side=LEFT)
18300  cha_TC1Entry.delete(0,"end")
18301  cha_TC1Entry.insert(0,CHA_TC1.get())
18302  cha_A1Entry = Entry(cha_RcomplabMode, width=5)
18303  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
18304  cha_A1Entry.bind('<Key>', onTextKey)
18305  cha_A1Entry.pack(side=LEFT)
18306  cha_A1Entry.delete(0,"end")
18307  cha_A1Entry.insert(0,CHA_A1.get())
18308  #
18309  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
18310  cha_Ccomplab.grid(row=8, column=0, sticky=W)
18311  cha_CcomplabMode = Frame( frame1 )
18312  cha_CcomplabMode.grid(row=8, column=1, sticky=W)
18313  cha_TC2Entry = Entry(cha_CcomplabMode, width=5)
18314  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
18315  cha_TC2Entry.bind('<Key>', onTextKey)
18316  cha_TC2Entry.pack(side=LEFT)
18317  cha_TC2Entry.delete(0,"end")
18318  cha_TC2Entry.insert(0,CHA_TC2.get())
18319  cha_A2Entry = Entry(cha_CcomplabMode, width=5)
18320  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
18321  cha_A2Entry.bind('<Key>', onTextKey)
18322  cha_A2Entry.pack(side=LEFT)
18323  cha_A2Entry.delete(0,"end")
18324  cha_A2Entry.insert(0,CHA_A2.get())
18325  #
18326  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
18327  chb_Rcomplab.grid(row=9, column=0, sticky=W)
18328  chb_RcomplabMode = Frame( frame1 )
18329  chb_RcomplabMode.grid(row=9, column=1, sticky=W)
18330  chb_TC1Entry = Entry(chb_RcomplabMode, width=5)
18331  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
18332  chb_TC1Entry.bind('<Key>', onTextKey)
18333  chb_TC1Entry.pack(side=LEFT)
18334  chb_TC1Entry.delete(0,"end")
18335  chb_TC1Entry.insert(0,CHB_TC1.get())
18336  chb_A1Entry = Entry(chb_RcomplabMode, width=5)
18337  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
18338  chb_A1Entry.bind('<Key>', onTextKey)
18339  chb_A1Entry.pack(side=LEFT)
18340  chb_A1Entry.delete(0,"end")
18341  chb_A1Entry.insert(0,CHB_A1.get())
18342  #
18343  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
18344  chb_Ccomplab.grid(row=10, column=0, sticky=W)
18345  chb_CcomplabMode = Frame( frame1 )
18346  chb_CcomplabMode.grid(row=10, column=1, sticky=W)
18347  chb_TC2Entry = Entry(chb_CcomplabMode, width=5)
18348  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
18349  chb_TC2Entry.bind('<Key>', onTextKey)
18350  chb_TC2Entry.pack(side=LEFT)
18351  chb_TC2Entry.delete(0,"end")
18352  chb_TC2Entry.insert(0,CHB_TC2.get())
18353  chb_A2Entry = Entry(chb_CcomplabMode, width=5)
18354  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
18355  chb_A2Entry.bind('<Key>', onTextKey)
18356  chb_A2Entry.pack(side=LEFT)
18357  chb_A2Entry.delete(0,"end")
18358  chb_A2Entry.insert(0,CHB_A2.get())
18359  #
18360  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
18361  Settingsdismissbutton.grid(row=11, column=0, sticky=W, pady=7)
18362 #
18364 
18365  UpdateAWGA()
18366  UpdateAWGB()
18367 
18369  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
18370  global Settingswindow, SettingsStatus, SettingsDisp, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
18371  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
18372  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
18373  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
18374  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
18375 
18376  try:
18377  GW = int(eval(GwdthE.get()))
18378  if GW < 1:
18379  GW = 1
18380  GwdthE.delete(0,END)
18381  GwdthE.insert(0, int(GW))
18382  if GW > 5:
18383  GW = 5
18384  GwdthE.delete(0,END)
18385  GwdthE.insert(0, int(GW))
18386  except:
18387  GwdthE.delete(0,END)
18388  GwdthE.insert(0, GridWidth.get())
18389  GridWidth.set(GW)
18390  try:
18391  TW = int(eval(TwdthE.get()))
18392  if TW < 1:
18393  TW = 1
18394  TwdthE.delete(0,END)
18395  TwdthE.insert(0, int(TW))
18396  if TW > 5:
18397  TW = 5
18398  TwdthE.delete(0,END)
18399  TwdthE.insert(0, int(TW))
18400  except:
18401  TwdthE.delete(0,END)
18402  TwdthE.insert(0, TRACEwidth.get())
18403  TRACEwidth.set(TW)
18404  # Number of average sweeps for average mode
18405  try:
18406  TA = int(eval(TAvg.get()))
18407  if TA < 1:
18408  TA = 1
18409  TAvg.delete(0,END)
18410  TAvg.insert(0, int(TA))
18411  if TA > 16:
18412  TA = 16
18413  TAvg.delete(0,END)
18414  TAvg.insert(0, int(TA))
18415  except:
18416  TAvg.delete(0,END)
18417  TAvg.insert(0, TRACEaverage.get())
18418  TRACEaverage.set(TA)
18419  # Number of vertical divisions for spectrum / Bode
18420  try:
18421  VDv = int(eval(VDivE.get()))
18422  if VDv < 1:
18423  VDv = 1
18424  VDivE.delete(0,END)
18425  VDivE.insert(0, int(VDv))
18426  if VDv > 16:
18427  VDv = 16
18428  VDivE.delete(0,END)
18429  VDivE.insert(0, int(VDv))
18430  except:
18431  VDivE.delete(0,END)
18432  VDivE.insert(0, Vdiv.get())
18433  Vdiv.set(VDv)
18434  # number of Harmonic Markers in SA
18435  try:
18436  HM = int(eval(HarMon.get()))
18437  if HM < 1:
18438  HM = 1
18439  HarMon.delete(0,END)
18440  HarMon.insert(0, int(HM))
18441  if HM > 9:
18442  HM =9
18443  HarMon.delete(0,END)
18444  HarMon.insert(0, int(HM))
18445  except:
18446  HarMon.delete(0,END)
18447  HarMon.insert(0, HarmonicMarkers.get())
18448  HarmonicMarkers.set(HM)
18449  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
18450  try:
18451  ZST = int(eval(ZSTuff.get()))
18452  if ZST < 1:
18453  ZST = 1
18454  ZSTuff.delete(0,END)
18455  ZSTuff.insert(0, int(ZST))
18456  if ZST > 5:
18457  ZST = 5
18458  ZSTuff.delete(0,END)
18459  ZSTuff.insert(0, int(ZST))
18460  except:
18461  ZSTuff.delete(0,END)
18462  ZSTuff.insert(0, ZEROstuffing.get())
18463  ZEROstuffing.set(ZST)
18464 #
18465  try:
18466  TC1A = float(cha_TC1Entry.get())
18467  CHA_TC1.set(TC1A)
18468  if TC1A < 0:
18469  TC1A = 0
18470  cha_TC1Entry.delete(0,END)
18471  cha_TC1Entry.insert(0, TC1A)
18472  except:
18473  cha_TC1Entry.delete(0,END)
18474  cha_TC1Entry.insert(0, CHA_TC1.get())
18475  try:
18476  TC2A = float(cha_TC2Entry.get())
18477  CHA_TC2.set(TC2A)
18478  if TC2A < 0:
18479  TC2A = 0
18480  cha_TC2Entry.delete(0,END)
18481  cha_TC2Entry.insert(0, TC2A)
18482  except:
18483  cha_TC2Entry.delete(0,END)
18484  cha_TC2Entry.insert(0, CHA_TC2.get())
18485  #
18486  try:
18487  Gain1A = float(cha_A1Entry.get())
18488  CHA_A1.set(Gain1A)
18489  except:
18490  cha_A1Entry.delete(0,END)
18491  cha_A1Entry.insert(0, CHA_A1.get())
18492  try:
18493  Gain2A = float(cha_A2Entry.get())
18494  CHA_A2.set(Gain2A)
18495  except:
18496  cha_A2Entry.delete(0,END)
18497  cha_A2Entry.insert(0, CHA_A2.get())
18498  #
18499  try:
18500  TC1B = float(chb_TC1Entry.get())
18501  CHB_TC1.set(TC1B)
18502  if TC1B < 0:
18503  TC1B = 0
18504  chb_TC1Entry.delete(0, END)
18505  chb_TC1Entry.insert(0, TC1B)
18506  except:
18507  chb_TC1Entry.delete(0,END)
18508  chb_TC1Entry.insert(0, CHB_TC1.get())
18509  try:
18510  TC2B = float(chb_TC2Entry.get())
18511  CHB_TC2.set(TC2B)
18512  if TC2B < 0:
18513  TC2B = 0
18514  chb_TC2Entry.delete(0, END)
18515  chb_TC2Entry.insert(0, TC2B)
18516  except:
18517  chb_TC2Entry.delete(0,END)
18518  chb_TC2Entry.insert(0, CHB_TC2.get())
18519  #
18520  try:
18521  Gain1B = float(chb_A1Entry.get())
18522  CHB_A1.set(Gain1B)
18523  except:
18524  chb_A1Entry.delete(0,END)
18525  chb_A1Entry.insert(0, CHB_A1.get())
18526  try:
18527  Gain2B = float(chb_A2Entry.get())
18528  CHB_A2.set(Gain2B)
18529  except:
18530  chb_A2Entry.delete(0,END)
18531  chb_A2Entry.insert(0, CHB_A2.get())
18532  #
18534  global Settingswindow, SettingsStatus, SettingsDisp
18535 
18536  SettingsStatus.set(0)
18537  SettingsUpdate()
18538  # SettingsDisp.set(0)
18539  Settingswindow.destroy()
18540 #
18541 def onCanvasMouse_xy(event):
18542  global MouseX, MouseY, MouseWidget
18543 
18544  MouseWidget = event.widget
18545  MouseX, MouseY = event.x, event.y
18546 #
18547 # ================ Make main Screen ==========================
18548 TgInput = IntVar(0) # Trigger Input variable
18549 SingleShot = IntVar(0) # variable for single shot triger
18550 ManualTrigger = IntVar(0) # variable for Manual trigger
18551 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
18552 ShowC1_V = IntVar(0) # curves to display variables
18553 TgEdge = IntVar(0) # Trigger edge variable
18554 # Show channels variables
18555 ShowC1_V = IntVar(0) # curves to display variables
18556 ShowC1_I = IntVar(0)
18557 ShowC2_V = IntVar(0)
18558 ShowC2_I = IntVar(0)
18559 ShowAV_I = IntVar(0)
18560 ShowBV_I = IntVar(0)
18561 ShowRA_V = IntVar(0)
18562 ShowRA_I = IntVar(0)
18563 ShowRB_V = IntVar(0)
18564 ShowRB_I = IntVar(0)
18565 ShowMath = IntVar(0)
18566 Show_MathX = IntVar(0)
18567 Show_MathY = IntVar(0)
18568 AutoCenterA = IntVar(0)
18569 AutoCenterB = IntVar(0)
18570 SmoothCurves = IntVar(0)
18571 ZOHold = IntVar(0)
18572 TRACEmodeTime = IntVar(0)
18573 TRACEmodeTime.set(0)
18574 ColorMode = IntVar(0)
18575 DecimateOption = IntVar(0)
18576 MathTrace = IntVar(0)
18577 # define vertical measurment variables
18578 MeasDCV1 = IntVar(0)
18579 MeasMinV1 = IntVar(0)
18580 MeasMaxV1 = IntVar(0)
18581 MeasMidV1 = IntVar(0)
18582 MeasPPV1 = IntVar(0)
18583 MeasRMSV1 = IntVar(0)
18584 MeasRMSVA_B = IntVar(0)
18585 MeasDCI1 = IntVar(0)
18586 MeasMinI1 = IntVar(0)
18587 MeasMaxI1 = IntVar(0)
18588 MeasMidI1 = IntVar(0)
18589 MeasPPI1 = IntVar(0)
18590 MeasRMSI1 = IntVar(0)
18591 MeasDiffAB = IntVar(0)
18592 MeasDCV2 = IntVar(0)
18593 MeasMinV2 = IntVar(0)
18594 MeasMaxV2 = IntVar(0)
18595 MeasMidV2 = IntVar(0)
18596 MeasPPV2 = IntVar(0)
18597 MeasRMSV2 = IntVar(0)
18598 MeasDCI2 = IntVar(0)
18599 MeasMinI2 = IntVar(0)
18600 MeasMaxI2 = IntVar(0)
18601 MeasMidI2 = IntVar(0)
18602 MeasPPI2 = IntVar(0)
18603 MeasRMSI2 = IntVar(0)
18604 MeasDiffBA = IntVar(0)
18605 MeasUserA = IntVar(0)
18606 MeasAHW = IntVar(0)
18607 MeasALW = IntVar(0)
18608 MeasADCy = IntVar(0)
18609 MeasAPER = IntVar(0)
18610 MeasAFREQ = IntVar(0)
18611 MeasBHW = IntVar(0)
18612 MeasBLW = IntVar(0)
18613 MeasBDCy = IntVar(0)
18614 MeasBPER = IntVar(0)
18615 MeasBFREQ = IntVar(0)
18616 MeasPhase = IntVar(0)
18617 MeasTopV1 = IntVar(0)
18618 MeasBaseV1 = IntVar(0)
18619 MeasTopV2 = IntVar(0)
18620 MeasBaseV2 = IntVar(0)
18621 MeasUserB = IntVar(0)
18622 MeasDelay = IntVar(0)
18623 TimeDisp = IntVar(0)
18624 TimeDisp.set(1)
18625 XYDisp = IntVar(0)
18626 FreqDisp = IntVar(0)
18627 BodeDisp = IntVar(0)
18628 IADisp = IntVar(0)
18629 OhmDisp = IntVar(0)
18630 BodeScreenStatus = IntVar(0)
18631 BodeScreenStatus.set(0)
18632 DigScreenStatus = IntVar(0)
18633 DigScreenStatus.set(0)
18634 DacScreenStatus = IntVar(0)
18635 DacScreenStatus.set(0)
18636 MuxScreenStatus = IntVar(0)
18637 MuxScreenStatus.set(0)
18638 DualMuxMode = IntVar(0)
18639 MinigenScreenStatus = IntVar(0)
18640 MinigenScreenStatus.set(0)
18641 DA1ScreenStatus = IntVar(0)
18642 DA1ScreenStatus.set(0)
18643 DigPotScreenStatus = IntVar(0)
18644 DigPotScreenStatus.set(0)
18645 GenericSerialStatus = IntVar(0)
18646 GenericSerialStatus.set(0)
18647 AD5626SerialStatus = IntVar(0)
18648 AD5626SerialStatus.set(0)
18649 DigFiltStatus = IntVar(0)
18650 DigFiltStatus.set(0)
18651 CommandStatus = IntVar(0)
18652 CommandStatus.set(0)
18653 MeasureStatus = IntVar(0)
18654 MeasureStatus.set(0)
18655 MarkerScale = IntVar(0)
18656 MarkerScale.set(1)
18657 SettingsStatus = IntVar(0)
18658 CHA_RC_HP = IntVar(0)
18659 CHB_RC_HP = IntVar(0)
18660 #
18661 frame2r = Frame(root, borderwidth=5, relief=RIDGE)
18662 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
18663 
18664 frame1 = Frame(root, borderwidth=5, relief=RIDGE)
18665 frame1.pack(side=TOP, fill=BOTH, expand=NO)
18666 
18667 frame2 = Frame(root, borderwidth=5, relief=RIDGE)
18668 frame2.pack(side=TOP, fill=BOTH, expand=YES)
18669 
18670 frame3 = Frame(root, borderwidth=5, relief=RIDGE)
18671 frame3.pack(side=TOP, fill=BOTH, expand=NO)
18672 # define custom buttons
18673 root.style.configure("W3.TButton", width=3, relief=RAISED)
18674 root.style.configure("W4.TButton", width=4, relief=RAISED)
18675 root.style.configure("W5.TButton", width=5, relief=RAISED)
18676 root.style.configure("W7.TButton", width=7, relief=RAISED)
18677 root.style.configure("W8.TButton", width=8, relief=RAISED)
18678 root.style.configure("W9.TButton", width=9, relief=RAISED)
18679 root.style.configure("W10.TButton", width=10, relief=RAISED)
18680 root.style.configure("W11.TButton", width=11, relief=RAISED)
18681 root.style.configure("W16.TButton", width=16, relief=RAISED)
18682 root.style.configure("W17.TButton", width=17, relief=RAISED)
18683 root.style.configure("Stop.TButton", background="red", width=4, relief=RAISED)
18684 root.style.configure("Run.TButton", background="green", width=4, relief=RAISED)
18685 root.style.configure("Pwr.TButton", background="green", width=7, relief=RAISED)
18686 root.style.configure("PwrOff.TButton", background="red", width=7, relief=RAISED)
18687 root.style.configure("RConn.TButton", background="red", width=5, relief=RAISED)
18688 root.style.configure("GConn.TButton", background="green", width=5, relief=RAISED)
18689 root.style.configure("Rtrace1.TButton", background=COLORtrace1, width=7, relief=RAISED)
18690 root.style.configure("Strace1.TButton", background=COLORtrace1, width=7, relief=SUNKEN)
18691 root.style.configure("Rtrace2.TButton", background=COLORtrace2, width=7, relief=RAISED)
18692 root.style.configure("Strace2.TButton", background=COLORtrace2, width=7, relief=SUNKEN)
18693 root.style.configure("Rtrace3.TButton", background=COLORtrace3, width=7, relief=RAISED)
18694 root.style.configure("Strace3.TButton", background=COLORtrace3, width=7, relief=SUNKEN)
18695 root.style.configure("Rtrace4.TButton", background=COLORtrace4, width=7, relief=RAISED)
18696 root.style.configure("Strace4.TButton", background=COLORtrace4, width=7, relief=SUNKEN)
18697 root.style.configure("Rtrace6.TButton", background=COLORtrace6, width=7, relief=RAISED)
18698 root.style.configure("Strace6.TButton", background=COLORtrace6, width=7, relief=SUNKEN)
18699 root.style.configure("Rtrace7.TButton", background=COLORtrace7, width=7, relief=RAISED)
18700 root.style.configure("Strace7.TButton", background=COLORtrace7, width=7, relief=SUNKEN)
18701 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
18702 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
18703 root.style.configure("A10R1.TLabelframe.Label", foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
18704 root.style.configure("A10R1.TLabelframe", borderwidth=5, relief=RIDGE)
18705 root.style.configure("A10R2.TLabelframe.Label", foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
18706 root.style.configure("A10R2.TLabelframe", borderwidth=5, relief=RIDGE)
18707 root.style.configure("A10B.TLabel", foreground=COLORcanvas, font="Arial 10 bold") # Black text
18708 root.style.configure("A10R.TLabel", foreground="red", font="Arial 10 bold") # Red text
18709 root.style.configure("A10G.TLabel", foreground="green", font="Arial 10 bold") # Red text
18710 root.style.configure("A12B.TLabel", foreground=COLORcanvas, font="Arial 12 bold") # Black text
18711 root.style.configure("A16B.TLabel", foreground=COLORcanvas, font="Arial 16 bold") # Black text
18712 root.style.configure("Stop.TRadiobutton", background="red")
18713 root.style.configure("Run.TRadiobutton", background="green")
18714 root.style.configure("Disab.TCheckbutton", indicatorcolor="red")
18715 root.style.configure("Enab.TCheckbutton", indicatorcolor="green")
18716 root.style.configure("WPhase.TRadiobutton", width=5, background="white", indicatorcolor=("red", "green"))
18717 root.style.configure("GPhase.TRadiobutton", width=5, background="gray", indicatorcolor=("red", "green"))
18718 # create a pulldown menu
18719 # Trigger signals
18720 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
18721 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
18722 Triggermenu["menu"] = Triggermenu.menu
18723 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
18724 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
18725 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
18726 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
18727 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
18728 Triggermenu.menu.add_radiobutton(label='Math', variable=TgInput, value=5)
18729 Triggermenu.menu.add_radiobutton(label='MathX', variable=TgInput, value=6)
18730 Triggermenu.menu.add_radiobutton(label='MathY', variable=TgInput, value=7)
18731 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
18732 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
18733 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
18734 Triggermenu.pack(side=LEFT)
18735 #
18736 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
18737 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
18738 Edgemenu["menu"] = Edgemenu.menu
18739 Edgemenu.menu.add_radiobutton(label='Rising [+]', variable=TgEdge, value=0)
18740 Edgemenu.menu.add_radiobutton(label='Falling [-]', variable=TgEdge, value=1)
18741 Edgemenu.pack(side=LEFT)
18742 #
18743 tlab = Label(frame1, text="Trig Level")
18744 tlab.pack(side=LEFT)
18745 TRIGGERentry = Entry(frame1, width=5)
18746 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
18747 TRIGGERentry.bind("<Return>", BTriglevel)
18748 TRIGGERentry.bind('<Key>', onTextKey)
18749 TRIGGERentry.pack(side=LEFT)
18750 TRIGGERentry.delete(0,"end")
18751 TRIGGERentry.insert(0,0.0)
18752 #
18753 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
18754 tgb.pack(side=LEFT)
18755 #
18756 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
18757 hldlab.pack(side=LEFT)
18758 HoldOffentry = Entry(frame1, width=4)
18759 HoldOffentry.bind('<MouseWheel>', onTextScroll)
18760 HoldOffentry.bind("<Return>", BHoldOff)
18761 HoldOffentry.bind('<Key>', onTextKey)
18762 HoldOffentry.pack(side=LEFT)
18763 HoldOffentry.delete(0,"end")
18764 HoldOffentry.insert(0,0.0)
18765 #
18766 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
18767 hozlab.pack(side=LEFT)
18768 HozPossentry = Entry(frame1, width=4)
18769 HozPossentry.bind('<MouseWheel>', onTextScroll)
18770 HozPossentry.bind("<Return>", BHozPoss)
18771 HozPossentry.bind('<Key>', onTextKey)
18772 HozPossentry.pack(side=LEFT)
18773 HozPossentry.delete(0,"end")
18774 HozPossentry.insert(0,0.0)
18775 #
18776 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
18777 bexit.pack(side=RIGHT)
18778 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
18779 bstop.pack(side=RIGHT)
18780 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
18781 brun.pack(side=RIGHT)
18782 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
18783 PwrBt.pack(side=RIGHT)
18784 # Curves Menu
18785 Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
18786 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
18787 Showmenu["menu"] = Showmenu.menu
18788 Showmenu.menu.add_command(label="-Show-", foreground="blue", command=donothing)
18789 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
18790 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
18791 Showmenu.menu.add_checkbutton(label='CA-V [1]', variable=ShowC1_V, command=TraceSelectADC_Mux)
18792 Showmenu.menu.add_checkbutton(label='CA-I [3]', variable=ShowC1_I, command=TraceSelectADC_Mux)
18793 Showmenu.menu.add_checkbutton(label='CB-V [2]', variable=ShowC2_V, command=TraceSelectADC_Mux)
18794 Showmenu.menu.add_checkbutton(label='CB-I [4]', variable=ShowC2_I, command=TraceSelectADC_Mux)
18795 Showmenu.menu.add_checkbutton(label='Math-X', variable=Show_MathX, command=UpdateTimeTrace)
18796 Showmenu.menu.add_checkbutton(label='Math-Y', variable=Show_MathY, command=UpdateTimeTrace)
18797 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
18798 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
18799 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
18800 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
18801 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
18802 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
18803 Showmenu.menu.add_separator()
18804 Showmenu.menu.add_checkbutton(label='RA-V', variable=ShowRA_V, command=UpdateTimeTrace)
18805 Showmenu.menu.add_checkbutton(label='RA-I', variable=ShowRA_I, command=UpdateTimeTrace)
18806 Showmenu.menu.add_checkbutton(label='RB-V', variable=ShowRB_V, command=UpdateTimeTrace)
18807 Showmenu.menu.add_checkbutton(label='RB-I', variable=ShowRB_I, command=UpdateTimeTrace)
18808 Showmenu.menu.add_checkbutton(label='RMath', variable=ShowMath, command=UpdateTimeTrace)
18809 Showmenu.menu.add_separator()
18810 Showmenu.menu.add_checkbutton(label='T Cursor [t]', variable=ShowTCur, command=UpdateTimeTrace)
18811 Showmenu.menu.add_checkbutton(label='V Cursor [v]', variable=ShowVCur, command=UpdateTimeTrace)
18812 Showmenu.pack(side=RIGHT)
18813 #
18814 if ShowBallonHelp > 0:
18815  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
18816  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
18817  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
18818  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
18819  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
18820  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
18821  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
18822  brun_tip = CreateToolTip(brun, 'Start acquiring data')
18823  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
18824  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
18825 
18826 # Sampling controls Widgets
18827 if EnableHSsampling > 0:
18828  fminlab2 = Label(frame1, text="KHz")
18829  fminlab2.pack(side=RIGHT)
18830  FminEntry = Entry(frame1, width=4)
18831  FminEntry.bind('<MouseWheel>', onFminScroll)
18832  FminEntry.bind("<Return>", SetAD9833)
18833  FminEntry.pack(side=RIGHT)
18834  FminEntry.delete(0,"end")
18835  FminEntry.insert(0,25)
18836  fminlab = Label(frame1, text="Fmin")
18837  fminlab.pack(side=RIGHT)
18838  #
18839  HtMulEntry = Entry(frame1, width=4)
18840  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
18841  HtMulEntry.bind("<Return>", SetAD9833)
18842  HtMulEntry.pack(side=RIGHT)
18843  HtMulEntry.delete(0,"end")
18844  HtMulEntry.insert(0,1)
18845  mulxlab = Label( frame1, text = "Mul X")
18846  mulxlab.pack(side=RIGHT)
18847 #
18848 # Time per Div
18849 TMsb = Spinbox(frame1, width=5, values= TMpdiv, command=BTime)
18850 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
18851 TMsb.pack(side=RIGHT)
18852 TMsb.delete(0,"end")
18853 TMsb.insert(0,0.5)
18854 TMlab = Label(frame1, text="Time mS/Div")
18855 TMlab.pack(side=RIGHT)
18856 #
18857 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
18858 # add mouse left and right button click to canvas
18859 ca.bind('<Configure>', CAresize)
18860 ca.bind('<1>', onCanvasClickLeft)
18861 ca.bind('<3>', onCanvasClickRight)
18862 ca.bind("<Motion>",onCanvasMouse_xy)
18863 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
18864 ca.bind("<Down>", onCanvasDownArrow)
18865 ca.bind("<Left>", onCanvasLeftArrow)
18866 ca.bind("<Right>", onCanvasRightArrow)
18867 ca.bind("<space>", onCanvasSpaceBar)
18868 ca.bind("1", onCanvasOne)
18869 ca.bind("2", onCanvasTwo)
18870 ca.bind("3", onCanvasThree)
18871 ca.bind("4", onCanvasFour)
18872 ca.bind("5", onCanvasFive)
18873 ca.bind("6", onCanvasSix)
18874 ca.bind("7", onCanvasSeven)
18875 ca.bind("8", onCanvasEight)
18876 ca.bind("9", onCanvasNine)
18877 ca.bind("0", onCanvasZero)
18878 ca.bind("a", onCanvasAverage)
18879 ca.bind("t", onCanvasShowTcur)
18880 ca.bind("v", onCanvasShowVcur)
18881 ca.bind("s", onCanvasSnap)
18882 ca.bind("+", onCanvasTrising)
18883 ca.bind("-", onCanvasTfalling)
18884 # ca.bind('<MouseWheel>', onCanvasClickScroll)
18885 ca.pack(side=TOP, fill=BOTH, expand=YES)
18886 MouseWidget = ca
18887 # right side menu buttons
18888 dropmenu = Frame( frame2r )
18889 dropmenu.pack(side=TOP)
18890 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
18891 bcon.pack(side=LEFT, anchor=W)
18892 # File menu
18893 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
18894 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
18895 Filemenu["menu"] = Filemenu.menu
18896 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
18897 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
18898 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
18899 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
18900 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
18901 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
18902 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
18903 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
18904 Filemenu.menu.add_command(label="Help", command=BHelp)
18905 Filemenu.menu.add_command(label="About", command=BAbout)
18906 Filemenu.pack(side=LEFT, anchor=W)
18907 # Options Menu
18908 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
18909 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
18910 Optionmenu["menu"] = Optionmenu.menu
18911 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
18912 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
18913 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
18914 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
18915 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
18916 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
18917 Optionmenu.menu.add_checkbutton(label='Trace Avg [a]', variable=TRACEmodeTime)
18918 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
18919 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
18920 Optionmenu.menu.add_command(label="SnapShot [s]", command=BSnapShot)
18921 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
18922 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
18923 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
18924 if AllowFlashFirmware == 1:
18925  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
18926  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
18927 Optionmenu.pack(side=LEFT, anchor=W)
18928 #
18929 dropmenu2 = Frame( frame2r )
18930 dropmenu2.pack(side=TOP)
18931 # Open Math trace menu
18932 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
18933 mathbt.pack(side=RIGHT, anchor=W)
18934 # Measurments menu
18935 measlab = Label(dropmenu2, text="Meas")
18936 measlab.pack(side=LEFT, anchor=W)
18937 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
18938 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
18939 MeasmenuA["menu"] = MeasmenuA.menu
18940 MeasmenuA.menu.add_command(label="-CA-V-", command=donothing)
18941 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
18942 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
18943 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
18944 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
18945 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
18946 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
18947 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
18948 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
18949 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
18950 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
18951 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
18952 MeasmenuA.menu.add_separator()
18953 #
18954 MeasmenuA.menu.add_command(label="-CA-I-", command=donothing)
18955 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
18956 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
18957 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
18958 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
18959 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
18960 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
18961 MeasmenuA.menu.add_separator()
18962 #
18963 MeasmenuA.menu.add_command(label="CA-Time", command=donothing)
18964 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
18965 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
18966 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
18967 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
18968 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
18969 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
18970 #
18971 MeasmenuA.pack(side=LEFT)
18972 #
18973 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
18974 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
18975 MeasmenuB["menu"] = MeasmenuB.menu
18976 MeasmenuB.menu.add_command(label="-CB-V-", command=donothing)
18977 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
18978 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
18979 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
18980 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
18981 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
18982 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
18983 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
18984 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
18985 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
18986 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
18987 MeasmenuB.menu.add_separator()
18988 #
18989 MeasmenuB.menu.add_command(label="-CB-I-", command=donothing)
18990 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
18991 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
18992 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
18993 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
18994 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
18995 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
18996 MeasmenuB.menu.add_separator()
18997 #
18998 MeasmenuB.menu.add_command(label="CB-Time", command=donothing)
18999 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
19000 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
19001 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
19002 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
19003 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
19004 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
19005 MeasmenuB.pack(side=LEFT)
19006 #
19007 BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
19008 BuildAWGScreen.pack(side=TOP)
19009 # Mode selector
19010 timebtn = Frame( frame2r )
19011 timebtn.pack(side=TOP)
19012 ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
19013 ckb1.pack(side=LEFT)
19014 timelab = Label(timebtn, text="Time Plot")
19015 timelab.pack(side=LEFT)
19016 xybtn = Frame( frame2r )
19017 xybtn.pack(side=TOP)
19018 ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
19019 ckb2.pack(side=LEFT)
19020 BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
19021 BuildXYScreen.pack(side=TOP)
19022 #
19023 freqbtn = Frame( frame2r )
19024 freqbtn.pack(side=TOP)
19025 ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
19026 ckb3.pack(side=LEFT)
19027 BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
19028 BuildSpectrumScreen.pack(side=LEFT)
19029 #
19030 bodebtn = Frame( frame2r )
19031 bodebtn.pack(side=TOP)
19032 ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
19033 ckb5.pack(side=LEFT)
19034 BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
19035 BuildBodeScreen.pack(side=LEFT)
19036 #
19037 impdbtn = Frame( frame2r )
19038 impdbtn.pack(side=TOP)
19039 ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
19040 ckb4.pack(side=LEFT)
19041 BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
19042 BuildIAScreen.pack(side=LEFT)
19043 #
19044 dcohmbtn = Frame( frame2r )
19045 dcohmbtn.pack(side=TOP)
19046 ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
19047 ckb6.pack(side=LEFT)
19048 BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
19049 BuildOhmScreen.pack(side=LEFT)
19050 if ShowBallonHelp > 0:
19051  math_tip = CreateToolTip(mathbt, 'Open Math window')
19052  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
19053  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
19054  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open spectrum analyzer window')
19055  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
19056  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance analyzer window')
19057  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
19058 # Digital Input / Output Option screens
19059 DigScreenStatus = IntVar(0)
19060 DigScreenStatus.set(0)
19061 BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
19062 BuildDigScreen.pack(side=TOP)
19063 #
19064 # Optional plugin tools
19065 if EnablePIODACMode > 0:
19066  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
19067  BuildDacScreen.pack(side=TOP)
19068 if EnableMuxMode > 0:
19069  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
19070  BuildMuxScreen.pack(side=TOP)
19071 if EnableMinigenMode > 0:
19072  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
19073  BuildMinigenScreen.pack(side=TOP)
19074 if EnablePmodDA1Mode > 0:
19075  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
19076  BuildDA1Screen.pack(side=TOP)
19077 if EnableDigPotMode >0:
19078  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
19079  BuildDigPotScreen.pack(side=TOP)
19080 if EnableGenericSerialMode >0:
19081  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
19082  GenericSerialScreen.pack(side=TOP)
19083 if EnableAD5626SerialMode >0:
19084  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
19085  AD5626SerialScreen.pack(side=TOP)
19086 if EnableDigitalFilter >0:
19087  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
19088  DigFiltScreen.pack(side=TOP)
19089 if EnableCommandInterface > 0:
19090  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
19091  CommandLineScreen.pack(side=TOP)
19092 if EnableMeasureScreen > 0:
19093  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
19094  MeasureScreen.pack(side=TOP)
19095 if EnableETSScreen > 0:
19096  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
19097  ETSScreen.pack(side=TOP)
19098 # input probe wigets
19099 prlab = Label(frame2r, text="Adjust Gain / Offset")
19100 prlab.pack(side=TOP)
19101 # Input Probes sub frame
19102 ProbeA = Frame( frame2r )
19103 ProbeA.pack(side=TOP)
19104 gain1lab = Label(ProbeA, text="CA-V")
19105 gain1lab.pack(side=LEFT)
19106 CHAVGainEntry = Entry(ProbeA, width=5)
19107 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
19108 CHAVGainEntry.bind('<Key>', onTextKey)
19109 CHAVGainEntry.pack(side=LEFT)
19110 CHAVGainEntry.delete(0,"end")
19111 CHAVGainEntry.insert(0,1.0)
19112 CHAVOffsetEntry = Entry(ProbeA, width=5)
19113 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
19114 CHAVOffsetEntry.bind('<Key>', onTextKey)
19115 CHAVOffsetEntry.pack(side=LEFT)
19116 CHAVOffsetEntry.delete(0,"end")
19117 CHAVOffsetEntry.insert(0,0.0)
19118 #
19119 ProbeB = Frame( frame2r )
19120 ProbeB.pack(side=TOP)
19121 gain2lab = Label(ProbeB, text="CB-V")
19122 gain2lab.pack(side=LEFT)
19123 CHBVGainEntry = Entry(ProbeB, width=5)
19124 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
19125 CHBVGainEntry.bind('<Key>', onTextKey)
19126 CHBVGainEntry.pack(side=LEFT)
19127 CHBVGainEntry.delete(0,"end")
19128 CHBVGainEntry.insert(0,1.0)
19129 CHBVOffsetEntry = Entry(ProbeB, width=5)
19130 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
19131 CHBVOffsetEntry.bind('<Key>', onTextKey)
19132 CHBVOffsetEntry.pack(side=LEFT)
19133 CHBVOffsetEntry.delete(0,"end")
19134 CHBVOffsetEntry.insert(0,0.0)
19135 #
19136 ProbeAI = Frame( frame2r )
19137 ProbeAI.pack(side=TOP)
19138 gainailab = Label(ProbeAI, text="CA-I")
19139 gainailab.pack(side=LEFT)
19140 CHAIGainEntry = Entry(ProbeAI, width=5)
19141 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
19142 CHAIGainEntry.bind('<Key>', onTextKey)
19143 CHAIGainEntry.pack(side=LEFT)
19144 CHAIGainEntry.delete(0,"end")
19145 CHAIGainEntry.insert(0,1.0)
19146 CHAIOffsetEntry = Entry(ProbeAI, width=5)
19147 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
19148 CHAIOffsetEntry.bind('<Key>', onTextKey)
19149 CHAIOffsetEntry.pack(side=LEFT)
19150 CHAIOffsetEntry.delete(0,"end")
19151 CHAIOffsetEntry.insert(0,0.0)
19152 #
19153 ProbeBI = Frame( frame2r )
19154 ProbeBI.pack(side=TOP)
19155 gainbilab = Label(ProbeBI, text="CB-I")
19156 gainbilab.pack(side=LEFT)
19157 CHBIGainEntry = Entry(ProbeBI, width=5)
19158 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
19159 CHBIGainEntry.bind('<Key>', onTextKey)
19160 CHBIGainEntry.pack(side=LEFT)
19161 CHBIGainEntry.delete(0,"end")
19162 CHBIGainEntry.insert(0,1.0)
19163 CHBIOffsetEntry = Entry(ProbeBI, width=5)
19164 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
19165 CHBIOffsetEntry.bind('<Key>', onTextKey)
19166 CHBIOffsetEntry.pack(side=LEFT)
19167 CHBIOffsetEntry.delete(0,"end")
19168 CHBIOffsetEntry.insert(0,0.0)
19169 # add ADI logo Don't mess with this bit map data!
19170 ADIlogo = """
19171 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
19172 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
19173 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
19174 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
19175 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
19176 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
19177 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
19178 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
19179 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
19180 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
19181 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
19182 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
19183 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
19184 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
19185 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
19186 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
19187 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
19188 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
19189 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
19190 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
19191 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
19192 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
19193 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
19194 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
19195 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
19196 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
19197 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
19198 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
19199 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
19200 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
19201 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
19202 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
19203 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
19204 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
19205 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
19206 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
19207 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
19208 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
19209 """
19210 logo = PhotoImage(data=ADIlogo)
19211 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
19212 ADI1.pack(side=TOP)
19213 
19214 # Bottom Buttons
19215 # Voltage channel A
19216 CHAsb = Spinbox(frame3, width=4, values=CHvpdiv, command=BCHAlevel)
19217 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
19218 CHAsb.pack(side=LEFT)
19219 CHAsb.delete(0,"end")
19220 CHAsb.insert(0,0.5)
19221 #
19222 CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
19223 CHAlab.pack(side=LEFT)
19224 
19225 CHAVPosEntry = Entry(frame3, width=5)
19226 CHAVPosEntry.bind("<Return>", BOffsetA)
19227 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)
19228 CHAVPosEntry.bind('<Key>', onTextKey)
19229 CHAVPosEntry.pack(side=LEFT)
19230 CHAVPosEntry.delete(0,"end")
19231 CHAVPosEntry.insert(0,2.5)
19232 CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
19233 CHAofflab.pack(side=LEFT)
19234 # Current channel A
19235 CHAIsb = Spinbox(frame3, width=4, values=CHipdiv, command=BCHAIlevel)
19236 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
19237 CHAIsb.pack(side=LEFT)
19238 CHAIsb.delete(0,"end")
19239 CHAIsb.insert(0,50.0)
19240 CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
19241 CHAIlab.pack(side=LEFT)
19242 
19243 CHAIPosEntry = Entry(frame3, width=5)
19244 CHAIPosEntry.bind("<Return>", BIOffsetA)
19245 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)
19246 CHAIPosEntry.bind('<Key>', onTextKey)
19247 CHAIPosEntry.pack(side=LEFT)
19248 CHAIPosEntry.delete(0,"end")
19249 CHAIPosEntry.insert(0,0.0)
19250 CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
19251 CHAIofflab.pack(side=LEFT)
19252 # Voltage channel B
19253 CHBsb = Spinbox(frame3, width=4, values=CHvpdiv, command=BCHBlevel)
19254 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
19255 CHBsb.pack(side=LEFT)
19256 CHBsb.delete(0,"end")
19257 CHBsb.insert(0,0.5)
19258 #
19259 CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
19260 CHBlab.pack(side=LEFT)
19261 
19262 CHBVPosEntry = Entry(frame3, width=5)
19263 CHBVPosEntry.bind("<Return>", BOffsetB)
19264 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)
19265 CHBVPosEntry.bind('<Key>', onTextKey)
19266 CHBVPosEntry.pack(side=LEFT)
19267 CHBVPosEntry.delete(0,"end")
19268 CHBVPosEntry.insert(0,2.5)
19269 CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
19270 CHBofflab.pack(side=LEFT)
19271 # Current channel B
19272 CHBIsb = Spinbox(frame3, width=4, values=CHipdiv, command=BCHBIlevel)
19273 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
19274 CHBIsb.pack(side=LEFT)
19275 CHBIsb.delete(0,"end")
19276 CHBIsb.insert(0,50.0)
19277 CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
19278 CHBIlab.pack(side=LEFT)
19279 
19280 CHBIPosEntry = Entry(frame3, width=5)
19281 CHBIPosEntry.bind("<Return>", BIOffsetB)
19282 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)
19283 CHBIPosEntry.bind('<Key>', onTextKey)
19284 CHBIPosEntry.pack(side=LEFT)
19285 CHBIPosEntry.delete(0,"end")
19286 CHBIPosEntry.insert(0,0.0)
19287 CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
19288 CHBIofflab.pack(side=LEFT)
19289 #
19290 if ShowBallonHelp > 0:
19291  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
19292  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
19293  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
19294  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
19295  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
19296  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
19297  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
19298  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
19299 #
19300 root.geometry('+300+0')
19301 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
19302 #===== Initalize device ======
19303 if not numpy_found:
19304  root.update()
19305  showwarning("WARNING","Numpy not found!")
19306  root.destroy()
19307  exit()
19308 #
19309 BrdSel = IntVar(0)
19310 BoardStatus = IntVar(0)
19311 if pysmu_found:
19312  ConnectDevice()
19313  #session.hotplug_attach(ConnectDevice)
19314  #session.hotplug_detach(ConnectDevice)
19315  MakeAWGWindow() # always build AWG window
19316  BLoadConfig("alice-last-config.cfg") # load configuration from last session
19317 # ================ Call main routine ===============================
19318  root.update() # Activate updated screens
19319 #
19320 # Start sampling
19321  Analog_In()
19322 else:
19323  root.update()
19324  showwarning("WARNING","Pysmu not found!")
19325  root.destroy()
19326  exit()
19327 
alice-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-desktop-1.3.1.pyw:15581
alice-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-desktop-1.3.1.pyw:1963
alice-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-desktop-1.3.1.pyw:1996
alice-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-desktop-1.3.1.pyw:1906
alice-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-desktop-1.3.1.pyw:14916
alice-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-desktop-1.3.1.pyw:14795
alice-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-desktop-1.3.1.pyw:17519
alice-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-desktop-1.3.1.pyw:1368
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.1.pyw:2059
alice-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-desktop-1.3.1.pyw:17334
alice-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-desktop-1.3.1.pyw:17715
alice-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-desktop-1.3.1.pyw:14981
alice-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-desktop-1.3.1.pyw:2356
alice-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-desktop-1.3.1.pyw:11139
alice-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-desktop-1.3.1.pyw:8066
alice-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-desktop-1.3.1.pyw:4594
alice-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-desktop-1.3.1.pyw:1191
alice-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-desktop-1.3.1.pyw:13490
alice-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-desktop-1.3.1.pyw:2339
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.1.pyw:17554
alice-desktop-1.sel
def sel()
Definition: alice-desktop-1.3.1.pyw:4323
alice-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-desktop-1.3.1.pyw:9465
alice-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-desktop-1.3.1.pyw:16561
alice-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-desktop-1.3.1.pyw:2108
alice-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-desktop-1.3.1.pyw:12437
alice-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-desktop-1.3.1.pyw:9899
alice-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-desktop-1.3.1.pyw:10725
alice-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-desktop-1.3.1.pyw:18363
alice-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-desktop-1.3.1.pyw:17721
alice-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-desktop-1.3.1.pyw:10014
alice-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-desktop-1.3.1.pyw:5713
alice-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-desktop-1.3.1.pyw:8076
alice-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-desktop-1.3.1.pyw:1977
alice-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-desktop-1.3.1.pyw:12441
alice-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-desktop-1.3.1.pyw:17344
alice-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-desktop-1.3.1.pyw:13412
alice-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-desktop-1.3.1.pyw:10304
alice-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-desktop-1.3.1.pyw:9815
alice-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-desktop-1.3.1.pyw:18094
alice-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-desktop-1.3.1.pyw:8118
alice-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-desktop-1.3.1.pyw:2216
alice-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-desktop-1.3.1.pyw:12423
alice-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-desktop-1.3.1.pyw:18112
alice-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-desktop-1.3.1.pyw:9355
alice-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-desktop-1.3.1.pyw:2511
alice-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-desktop-1.3.1.pyw:12484
alice-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-desktop-1.3.1.pyw:11158
alice-desktop-1.BStopSA
def BStopSA()
Definition: alice-desktop-1.3.1.pyw:11057
alice-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-desktop-1.3.1.pyw:8110
alice-desktop-1.Analog_Fast_time
def Analog_Fast_time()
routine for time scales faster than 500 mSec/Div
Definition: alice-desktop-1.3.1.pyw:3055
alice-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-desktop-1.3.1.pyw:10803
alice-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-desktop-1.3.1.pyw:2522
alice-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-desktop-1.3.1.pyw:17270
alice-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-desktop-1.3.1.pyw:13907
alice-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-desktop-1.3.1.pyw:1722
alice-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-desktop-1.3.1.pyw:15811
alice-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-desktop-1.3.1.pyw:13393
alice-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-desktop-1.3.1.pyw:13374
alice-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-desktop-1.3.1.pyw:10874
alice-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-desktop-1.3.1.pyw:2015
alice-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-desktop-1.3.1.pyw:7518
alice-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-desktop-1.3.1.pyw:16408
alice-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-desktop-1.3.1.pyw:2449
alice-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-desktop-1.3.1.pyw:8709
alice-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.1.pyw:1459
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.1.pyw:2918
alice-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-desktop-1.3.1.pyw:12912
alice-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-desktop-1.3.1.pyw:8155
alice-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-desktop-1.3.1.pyw:11390
alice-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-desktop-1.3.1.pyw:14299
alice-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-desktop-1.3.1.pyw:17340
alice-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-desktop-1.3.1.pyw:13950
alice-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-desktop-1.3.1.pyw:2222
alice-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-desktop-1.3.1.pyw:1203
alice-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-desktop-1.3.1.pyw:13104
alice-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-desktop-1.3.1.pyw:16783
alice-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-desktop-1.3.1.pyw:14147
alice-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-desktop-1.3.1.pyw:9443
alice-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-desktop-1.3.1.pyw:10110
alice-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-desktop-1.3.1.pyw:13064
alice-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-desktop-1.3.1.pyw:14767
alice-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-desktop-1.3.1.pyw:18541
alice-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-desktop-1.3.1.pyw:11658
alice-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-desktop-1.3.1.pyw:14366
alice-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-desktop-1.3.1.pyw:8974
alice-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-desktop-1.3.1.pyw:14119
alice-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-desktop-1.3.1.pyw:8586
alice-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-desktop-1.3.1.pyw:8050
alice-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-desktop-1.3.1.pyw:13388
alice-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-desktop-1.3.1.pyw:9100
alice-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-desktop-1.3.1.pyw:16931
alice-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-desktop-1.3.1.pyw:14086
alice-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-desktop-1.3.1.pyw:8917
alice-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-desktop-1.3.1.pyw:18000
alice-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-desktop-1.3.1.pyw:14991
alice-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-desktop-1.3.1.pyw:8143
alice-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-desktop-1.3.1.pyw:10234
alice-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-desktop-1.3.1.pyw:2090
alice-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-desktop-1.3.1.pyw:1970
alice-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-desktop-1.3.1.pyw:2162
alice-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-desktop-1.3.1.pyw:8572
alice-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-desktop-1.3.1.pyw:14096
alice-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Definition: alice-desktop-1.3.1.pyw:7684
alice-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-desktop-1.3.1.pyw:14292
alice-desktop-1.CreateToolTip.tw
tw
Definition: alice-desktop-1.3.1.pyw:663
alice-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-desktop-1.3.1.pyw:14043
alice-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-desktop-1.3.1.pyw:13249
alice-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-desktop-1.3.1.pyw:16851
alice-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-desktop-1.3.1.pyw:4195
alice-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-desktop-1.3.1.pyw:8091
alice-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-desktop-1.3.1.pyw:10796
alice-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-desktop-1.3.1.pyw:8453
alice-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-desktop-1.3.1.pyw:9732
alice-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-desktop-1.3.1.pyw:4589
alice-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-desktop-1.3.1.pyw:1476
alice-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-desktop-1.3.1.pyw:2540
alice-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-desktop-1.3.1.pyw:2246
alice-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-desktop-1.3.1.pyw:1899
alice-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-desktop-1.3.1.pyw:2500
alice-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-desktop-1.3.1.pyw:17815
alice-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-desktop-1.3.1.pyw:1214
alice-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-desktop-1.3.1.pyw:14285
alice-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-desktop-1.3.1.pyw:1209
alice-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-desktop-1.3.1.pyw:17183
alice-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-desktop-1.3.1.pyw:8042
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.1.pyw:1545
alice-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-desktop-1.3.1.pyw:2204
alice-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-desktop-1.3.1.pyw:10487
alice-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-desktop-1.3.1.pyw:1288
alice-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-desktop-1.3.1.pyw:10432
alice-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-desktop-1.3.1.pyw:18008
alice-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-desktop-1.3.1.pyw:7494
alice-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-desktop-1.3.1.pyw:9864
alice-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-desktop-1.3.1.pyw:13794
alice-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-desktop-1.3.1.pyw:9762
alice-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-desktop-1.3.1.pyw:8383
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.1.pyw:3679
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.1.pyw:3661
alice-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-desktop-1.3.1.pyw:17364
alice-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-desktop-1.3.1.pyw:7532
alice-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-desktop-1.3.1.pyw:14082
alice-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-desktop-1.3.1.pyw:14270
alice-desktop-1.sel1
def sel1(temp)
Definition: alice-desktop-1.3.1.pyw:4463
alice-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-desktop-1.3.1.pyw:9781
alice-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-desktop-1.3.1.pyw:17293
alice-desktop-1.CreateToolTip.widget
widget
Definition: alice-desktop-1.3.1.pyw:657
alice-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-desktop-1.3.1.pyw:2321
alice-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-desktop-1.3.1.pyw:17644
alice-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-desktop-1.3.1.pyw:1511
alice-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-desktop-1.3.1.pyw:17009
alice-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-desktop-1.3.1.pyw:17179
alice-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-desktop-1.3.1.pyw:2186
alice-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-desktop-1.3.1.pyw:10715
alice-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-desktop-1.3.1.pyw:14090
alice-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-desktop-1.3.1.pyw:1999
alice-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-desktop-1.3.1.pyw:17201
alice-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-desktop-1.3.1.pyw:16707
alice-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-desktop-1.3.1.pyw:13121
alice-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-desktop-1.3.1.pyw:2228
alice-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-desktop-1.3.1.pyw:11320
alice-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-desktop-1.3.1.pyw:1567
alice-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-desktop-1.3.1.pyw:9171
alice-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-desktop-1.3.1.pyw:4424
alice-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-desktop-1.3.1.pyw:14228
alice-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-desktop-1.3.1.pyw:8291
alice-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-desktop-1.3.1.pyw:655
alice-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-desktop-1.3.1.pyw:13072
alice-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-desktop-1.3.1.pyw:16606
alice-desktop-1.SyncImage
def SyncImage()
Definition: alice-desktop-1.3.1.pyw:14942
alice-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-desktop-1.3.1.pyw:8635
alice-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-desktop-1.3.1.pyw:2021
alice-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-desktop-1.3.1.pyw:14277
alice-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-desktop-1.3.1.pyw:14036
alice-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-desktop-1.3.1.pyw:2047
alice-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-desktop-1.3.1.pyw:2007
alice-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-desktop-1.3.1.pyw:13407
alice-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-desktop-1.3.1.pyw:15341
alice-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-desktop-1.3.1.pyw:10570
alice-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-desktop-1.3.1.pyw:4361
alice-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-desktop-1.3.1.pyw:9595
alice-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-desktop-1.3.1.pyw:14289
alice-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Definition: alice-desktop-1.3.1.pyw:7642
alice-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-desktop-1.3.1.pyw:1197
alice-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-desktop-1.3.1.pyw:10591
alice-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-desktop-1.3.1.pyw:2138
alice-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-desktop-1.3.1.pyw:15822
alice-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-desktop-1.3.1.pyw:13205
alice-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-desktop-1.3.1.pyw:14235
alice-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-desktop-1.3.1.pyw:8629
alice-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-desktop-1.3.1.pyw:14105
alice-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-desktop-1.3.1.pyw:17208
alice-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-desktop-1.3.1.pyw:14256
alice-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-desktop-1.3.1.pyw:8058
alice-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-desktop-1.3.1.pyw:10169
alice-desktop-1.CreateToolTip.id
id
Definition: alice-desktop-1.3.1.pyw:662
alice-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-desktop-1.3.1.pyw:17397
alice-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-desktop-1.3.1.pyw:10833
alice-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-desktop-1.3.1.pyw:2469
alice-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-desktop-1.3.1.pyw:14435
alice-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-desktop-1.3.1.pyw:8071
alice-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-desktop-1.3.1.pyw:11329
alice-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-desktop-1.3.1.pyw:9744
alice-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-desktop-1.3.1.pyw:17255
alice-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-desktop-1.3.1.pyw:17708
alice-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-desktop-1.3.1.pyw:14306
alice-desktop-1.BStartSA
def BStartSA()
Definition: alice-desktop-1.3.1.pyw:11020
alice-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-desktop-1.3.1.pyw:10839
alice-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-desktop-1.3.1.pyw:8410
alice-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-desktop-1.3.1.pyw:14281
alice-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-desktop-1.3.1.pyw:17464
alice-desktop-1.Blevel3
def Blevel3()
Definition: alice-desktop-1.3.1.pyw:11102
alice-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-desktop-1.3.1.pyw:11311
alice-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-desktop-1.3.1.pyw:1356
alice-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-desktop-1.3.1.pyw:14057
alice-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-desktop-1.3.1.pyw:706
alice-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-desktop-1.3.1.pyw:11858
alice-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-desktop-1.3.1.pyw:16555
alice-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-desktop-1.3.1.pyw:14263
alice-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-desktop-1.3.1.pyw:17935
alice-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-desktop-1.3.1.pyw:14360
alice-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-desktop-1.3.1.pyw:6768
alice-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-desktop-1.3.1.pyw:8086
alice-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-desktop-1.3.1.pyw:17204
alice-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-desktop-1.3.1.pyw:2587
alice-desktop-1.BStepSync
def BStepSync()
Definition: alice-desktop-1.3.1.pyw:14971
alice-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3.1.pyw:1597
alice-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-desktop-1.3.1.pyw:10366
alice-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-desktop-1.3.1.pyw:11381
alice-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-desktop-1.3.1.pyw:7767
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.1.pyw:2857
alice-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-desktop-1.3.1.pyw:17894
alice-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-desktop-1.3.1.pyw:16477
alice-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-desktop-1.3.1.pyw:13383
alice-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-desktop-1.3.1.pyw:16382
alice-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-desktop-1.3.1.pyw:4020
alice-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-desktop-1.3.1.pyw:4562
alice-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-desktop-1.3.1.pyw:16742
alice-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-desktop-1.3.1.pyw:2547
alice-desktop-1.CAresize
def CAresize(event)
Definition: alice-desktop-1.3.1.pyw:17354
alice-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-desktop-1.3.1.pyw:8134
alice-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-desktop-1.3.1.pyw:1925
alice-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-desktop-1.3.1.pyw:16568
alice-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-desktop-1.3.1.pyw:12103
alice-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-desktop-1.3.1.pyw:8106
alice-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-desktop-1.3.1.pyw:676
alice-desktop-1.sel0
def sel0(temp)
Definition: alice-desktop-1.3.1.pyw:4430
alice-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-desktop-1.3.1.pyw:2210
alice-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-desktop-1.3.1.pyw:10529
alice-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-desktop-1.3.1.pyw:14135
alice-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-desktop-1.3.1.pyw:14064
alice-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-desktop-1.3.1.pyw:17795
alice-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-desktop-1.3.1.pyw:9917
alice-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-desktop-1.3.1.pyw:9034
alice-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-desktop-1.3.1.pyw:11302
alice-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-desktop-1.3.1.pyw:18116
alice-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-desktop-1.3.1.pyw:11401
alice-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-desktop-1.3.1.pyw:2132
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.1.pyw:3699
alice-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-desktop-1.3.1.pyw:14242
alice-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-desktop-1.3.1.pyw:13111
alice-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-desktop-1.3.1.pyw:11168
alice-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-desktop-1.3.1.pyw:16289
alice-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-desktop-1.3.1.pyw:14443
alice-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-desktop-1.3.1.pyw:8562
alice-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-desktop-1.3.1.pyw:9701
alice-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-desktop-1.3.1.pyw:14249
alice-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-desktop-1.3.1.pyw:4584
alice-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-desktop-1.3.1.pyw:13239
alice-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-desktop-1.3.1.pyw:665
alice-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-desktop-1.3.1.pyw:9674
alice-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-desktop-1.3.1.pyw:2072
alice-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-desktop-1.3.1.pyw:4061
alice-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-desktop-1.3.1.pyw:17725
alice-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-desktop-1.3.1.pyw:14078
alice-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-desktop-1.3.1.pyw:11405
alice-desktop-1.DoFFT
def DoFFT()
Definition: alice-desktop-1.3.1.pyw:11408
alice-desktop-1.onCanvasClickScroll
def onCanvasClickScroll(event)
Definition: alice-desktop-1.3.1.pyw:7541
alice-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-desktop-1.3.1.pyw:654
alice-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-desktop-1.3.1.pyw:10749
alice-desktop-1.sel3
def sel3(temp)
Definition: alice-desktop-1.3.1.pyw:4529
alice-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-desktop-1.3.1.pyw:2562
alice-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-desktop-1.3.1.pyw:2126
alice-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-desktop-1.3.1.pyw:12902
alice-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-desktop-1.3.1.pyw:8277
alice-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-desktop-1.3.1.pyw:2150
alice-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-desktop-1.3.1.pyw:15036
alice-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-desktop-1.3.1.pyw:1489
alice-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-desktop-1.3.1.pyw:11359
alice-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-desktop-1.3.1.pyw:17003
alice-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-desktop-1.3.1.pyw:15321
alice-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-desktop-1.3.1.pyw:8344
alice-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-desktop-1.3.1.pyw:4599
alice-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-desktop-1.3.1.pyw:10823
alice-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-desktop-1.3.1.pyw:18368
alice-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-desktop-1.3.1.pyw:12433
alice-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-desktop-1.3.1.pyw:14789
alice-desktop-1.CreateToolTip.text
text
Definition: alice-desktop-1.3.1.pyw:658
alice-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-desktop-1.3.1.pyw:15590
alice-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-desktop-1.3.1.pyw:13402
alice-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-desktop-1.3.1.pyw:8441
alice-desktop-1.MGLoad
def MGLoad()
Definition: alice-desktop-1.3.1.pyw:18102
alice-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-desktop-1.3.1.pyw:10813
alice-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-desktop-1.3.1.pyw:17226
alice-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-desktop-1.3.1.pyw:8034
alice-desktop-1.Blevel1
def Blevel1()
Definition: alice-desktop-1.3.1.pyw:11084
alice-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-desktop-1.3.1.pyw:4679
alice-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-desktop-1.3.1.pyw:656
alice-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-desktop-1.3.1.pyw:9301
alice-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-desktop-1.3.1.pyw:9854
alice-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-desktop-1.3.1.pyw:2240
alice-desktop-1.Blevel2
def Blevel2()
Definition: alice-desktop-1.3.1.pyw:11093
alice-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-desktop-1.3.1.pyw:2569
alice-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-desktop-1.3.1.pyw:16999
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.1.pyw:3713
alice-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-desktop-1.3.1.pyw:17108
alice-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-desktop-1.3.1.pyw:10055
alice-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-desktop-1.3.1.pyw:17232
alice-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-desktop-1.3.1.pyw:4206
alice-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Definition: alice-desktop-1.3.1.pyw:7600
alice-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-desktop-1.3.1.pyw:668
alice-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Definition: alice-desktop-1.3.1.pyw:7726
alice-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-desktop-1.3.1.pyw:13078
alice-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-desktop-1.3.1.pyw:17176
alice-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-desktop-1.3.1.pyw:7482
alice-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-desktop-1.3.1.pyw:4069
alice-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-desktop-1.3.1.pyw:17470
alice-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-desktop-1.3.1.pyw:8775
alice-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-desktop-1.3.1.pyw:8841
alice-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-desktop-1.3.1.pyw:16412
alice-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-desktop-1.3.1.pyw:14950
alice-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-desktop-1.3.1.pyw:14112
alice-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-desktop-1.3.1.pyw:9623
alice-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-desktop-1.3.1.pyw:2234
alice-desktop-1.BSendGS
def BSendGS()
Definition: alice-desktop-1.3.1.pyw:16857
alice-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-desktop-1.3.1.pyw:14376
alice-desktop-1.Bnot
def Bnot()
Definition: alice-desktop-1.3.1.pyw:10786
alice-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-desktop-1.3.1.pyw:1984
alice-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-desktop-1.3.1.pyw:8096
alice-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-desktop-1.3.1.pyw:1362
alice-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-desktop-1.3.1.pyw:14321
alice-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-desktop-1.3.1.pyw:17854
alice-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-desktop-1.3.1.pyw:8101
alice-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-desktop-1.3.1.pyw:13810
alice-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-desktop-1.3.1.pyw:2576
alice-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-desktop-1.3.1.pyw:9399
alice-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-desktop-1.3.1.pyw:12608
alice-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-desktop-1.3.1.pyw:14329
alice-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-desktop-1.3.1.pyw:8882
alice-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-desktop-1.3.1.pyw:8521
alice-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.1.pyw:1423
alice-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-desktop-1.3.1.pyw:11385
alice-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-desktop-1.3.1.pyw:8471
alice-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-desktop-1.3.1.pyw:17308
alice-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-desktop-1.3.1.pyw:1550
alice-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digitla I/O screen.
Definition: alice-desktop-1.3.1.pyw:4317
alice-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-desktop-1.3.1.pyw:2479
alice-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-desktop-1.3.1.pyw:13899
alice-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-desktop-1.3.1.pyw:8308
alice-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-desktop-1.3.1.pyw:2174
alice-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-desktop-1.3.1.pyw:2144
alice-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.1.pyw:1404
alice-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-desktop-1.3.1.pyw:2533
alice-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-desktop-1.3.1.pyw:2407
alice-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-desktop-1.3.1.pyw:682
alice-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-desktop-1.3.1.pyw:11338
alice-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-desktop-1.3.1.pyw:2554
alice-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-desktop-1.3.1.pyw:15605
alice-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-desktop-1.3.1.pyw:1350
alice-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-desktop-1.3.1.pyw:10769
alice-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-desktop-1.3.1.pyw:10789
alice-desktop-1.donothing
def donothing()
Nop.
Definition: alice-desktop-1.3.1.pyw:1993
alice-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-desktop-1.3.1.pyw:8126
alice-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-desktop-1.3.1.pyw:1944
alice-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-desktop-1.3.1.pyw:14071
alice-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-desktop-1.3.1.pyw:5960
alice-desktop-1.BStopBP
def BStopBP()
Definition: alice-desktop-1.3.1.pyw:11280
alice-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-desktop-1.3.1.pyw:18200
alice-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-desktop-1.3.1.pyw:14099
alice-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-desktop-1.3.1.pyw:10993
alice-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-desktop-1.3.1.pyw:4604
alice-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-desktop-1.3.1.pyw:11348
alice-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-desktop-1.3.1.pyw:11366
alice-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-desktop-1.3.1.pyw:2268
alice-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-desktop-1.3.1.pyw:2198
alice-desktop-1.sel2
def sel2(temp)
Definition: alice-desktop-1.3.1.pyw:4496
alice-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-desktop-1.3.1.pyw:18533
alice-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-desktop-1.3.1.pyw:14962
alice-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-desktop-1.3.1.pyw:14313
alice-desktop-1.CalcMathBuff
def CalcMathBuff()
Calculate Math buffers.
Definition: alice-desktop-1.3.1.pyw:4614
alice-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-desktop-1.3.1.pyw:15331
alice-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-desktop-1.3.1.pyw:2743
alice-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-desktop-1.3.1.pyw:9954
alice-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-desktop-1.3.1.pyw:2081
alice-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-desktop-1.3.1.pyw:652
alice-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-desktop-1.3.1.pyw:16800
alice-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-desktop-1.3.1.pyw:11120
alice-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3.1.pyw:1669
alice-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-desktop-1.3.1.pyw:7525
alice-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-desktop-1.3.1.pyw:8490
alice-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-desktop-1.3.1.pyw:17525
alice-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-desktop-1.3.1.pyw:17101
alice-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-desktop-1.3.1.pyw:10728
alice-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-desktop-1.3.1.pyw:16650
alice-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-desktop-1.3.1.pyw:672
alice-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-desktop-1.3.1.pyw:14372
alice-desktop-1.BStartBP
def BStartBP()
Definition: alice-desktop-1.3.1.pyw:11179
alice-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-desktop-1.3.1.pyw:17775
alice-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-desktop-1.3.1.pyw:10919
alice-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-desktop-1.3.1.pyw:7470
alice-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.1.pyw:1442
alice-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-desktop-1.3.1.pyw:14050
alice-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-desktop-1.3.1.pyw:18204
alice-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-desktop-1.3.1.pyw:1688
alice-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-desktop-1.3.1.pyw:4609
alice-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-desktop-1.3.1.pyw:14126
alice-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-desktop-1.3.1.pyw:16445
alice-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Definition: alice-desktop-1.3.1.pyw:7558
alice-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-desktop-1.3.1.pyw:9893
alice-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-desktop-1.3.1.pyw:11373
alice-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-desktop-1.3.1.pyw:1705
alice-desktop-1.Blevel4
def Blevel4()
Definition: alice-desktop-1.3.1.pyw:11111
alice-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-desktop-1.3.1.pyw:2489
alice-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-desktop-1.3.1.pyw:13232
alice-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-desktop-1.3.1.pyw:2421
alice-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-desktop-1.3.1.pyw:14102
alice-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-desktop-1.3.1.pyw:8653
alice-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-desktop-1.3.1.pyw:14093
alice-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-desktop-1.3.1.pyw:2459
alice-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-desktop-1.3.1.pyw:13939
alice-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-desktop-1.3.1.pyw:697
alice-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-desktop-1.3.1.pyw:2370
alice-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-desktop-1.3.1.pyw:16701
alice-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-desktop-1.3.1.pyw:8081
alice-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-desktop-1.3.1.pyw:13930
alice-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-desktop-1.3.1.pyw:14029
alice-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-desktop-1.3.1.pyw:9637
alice-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-desktop-1.3.1.pyw:7506
alice-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-desktop-1.3.1.pyw:9234
alice-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-desktop-1.3.1.pyw:1375
alice-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-desktop-1.3.1.pyw:16404