ALICE 1.3  1.0
Develpoer documentation
alice-HS-desktop-1.3.pyw
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: cp1252 -*-
3 
12 import __future__
13 import math
14 import time
15 try:
16  import numpy
17  numpy_found = True
18 except:
19  numpy_found = False
20 import csv
21 import wave
22 import os
23 import 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 = "(14 Feb 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, 32768, 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 VBuffMA = []
342 VBuffMB = []
343 VBuffMC = []
344 VBuffMD = []
345 VmemoryMuxA = []
346 VmemoryMuxB = []
347 VmemoryMuxC = []
348 VmemoryMuxD = []
349 #
350 DFiltACoef = [1]
351 DFiltBCoef = [1]
352 DigFiltA = IntVar(0)
353 DigFiltA.set(0)
354 DigFiltABoxCar = IntVar(0)
355 DigFiltBBoxCar = IntVar(0)
356 DigFiltB = IntVar(0)
357 DigFiltB.set(0)
358 DigBuffA = IntVar(0)
359 DigBuffB = IntVar(0)
360 DigBuffA.set(0)
361 DigBuffB.set(0)
362 VFilterA = {}
363 VFilterB = {}
364 SampleRateStatus = IntVar(0)
365 ETSStatus = IntVar(0)
366 ETSDisp = IntVar(0)
367 ETSDir = IntVar(0)
368 #
369 AWGAwaveform = []
370 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
371 AWGBwaveform = []
372 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
373 VmemoryA = numpy.ones(1) # The memory for averaging
374 VmemoryB = numpy.ones(1)
375 ImemoryA = numpy.ones(1) # The memory for averaging
376 ImemoryB = numpy.ones(1)
377 TRACEresetTime = True # True for first new trace, false for averageing
378 TRACEresetFreq = True # True for first new trace, false for averageing
379 AWGScreenStatus = IntVar(0)
380 
381 T1Vline = [] # Voltage Trace line channel A
382 T2Vline = [] # Voltage Trace line channel B
383 T1Iline = [] # Current Trace line channel A
384 T2Iline = [] # Current Trace line channel B
385 TMAVline = [] # Voltage Trace line MUX channel A
386 TMBVline = [] # Voltage Trace line MUX channel B
387 TMCVline = [] # Voltage Trace line MUX channel C
388 TMDVline = [] # Voltage Trace line MUX channel D
389 TMBRline = [] # V reference Trace line MUX channel B
390 TMCRline = [] # V reference line MUX channel C
391 TXYline = [] # XY Trace line
392 TXYRline = [] # XY reference trace line
393 Tmathline = [] # Math trace line
394 TMXline = [] # X math Trace line
395 TMYline = [] # Y math Trace line
396 T1VRline = [] # V reference Trace line channel A
397 T2VRline = [] # V reference Trace line channel B
398 T1IRline = [] # I reference Trace line channel A
399 T2IRline = [] # I reference Trace line channel B
400 TMRline = [] # Math reference Trace line
401 Triggerline = [] # Triggerline
402 Triggersymbol = [] # Trigger symbol
403 #
404 SHOWsamples = 4000 # Number of samples on the screen
405 SCstart = 0 # Start sample of the trace
406 HozPoss = 0.0
407 Is_Triggered = 0
408 #
409 TRACES = 1 # Number of traces 1 or 2
410 TRACESread = 0 # Number of traces that have been read from ALM
411 ScreenTrefresh = IntVar(0)
412 ScreenXYrefresh = IntVar(0)
413 #
414 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
415 ZEROstuffing.set(1)
416 NSteps = IntVar(0) # number of frequency sweep steps
417 NSteps.set(128)
418 LoopNum = IntVar(0)
419 LoopNum.set(1)
420 LastWindow = -1
421 LastSMPfft = 0
422 CurrentFreqX = X0LBP + 14
423 FBins = numpy.linspace(0, 50000, num=16384)
424 FStep = numpy.linspace(0, 16384, num=NSteps.get())
425 FSweepMode = IntVar(0)
426 FSweepCont = IntVar(0)
427 FStepSync = IntVar(0)
428 FSweepSync = IntVar(0)
429 ShowCA_VdB = IntVar(0) # curves to display variables
430 ShowCA_P = IntVar(0)
431 ShowCB_VdB = IntVar(0)
432 ShowCB_P = IntVar(0)
433 ShowMarkerBP = IntVar(0)
434 ShowCA_RdB = IntVar(0)
435 ShowCA_RP = IntVar(0)
436 ShowCB_RdB = IntVar(0)
437 ShowCB_RP = IntVar(0)
438 ShowMathBP = IntVar(0)
439 ShowRMathBP = IntVar(0)
440 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
441 FSweepAdB = []
442 FSweepBdB = []
443 FSweepAPh = []
444 FSweepBPh = []
445 NSweepSeriesR = []
446 NSweepSeriesX = []
447 NSweepSeriesMag = [] # in ohms
448 NSweepSeriesAng = [] # in degrees
449 NetworkScreenStatus = IntVar(0)
450 BDSweepFile = IntVar(0)
451 FileSweepFreq = []
452 FileSweepAmpl = []
453 #
454 MarkerNum = MarkerFreqNum = 0
455 ShowTCur = IntVar(0)
456 ShowVCur = IntVar(0)
457 TCursor = VCursor = 0
458 ShowXCur = IntVar(0)
459 ShowYCur = IntVar(0)
460 XCursor = YCursor = 0
461 ShowFCur = IntVar(0)
462 ShowdBCur = IntVar(0)
463 FCursor = dBCursor = 0
464 ShowBPCur = IntVar(0)
465 ShowBdBCur = IntVar(0)
466 BPCursor = BdBCursor = 0
467 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
468 PowerStatus = 1
469 TRIGGERsample = 0 # AD sample trigger point
470 DX = 0 # interpolated trigger point
471 
472 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
473 DBdivindex = IntVar(0) # 10 dB/div as initial value
474 DBdivindex.set(4)
475 DBlevel = IntVar(0) # Reference level
476 DBlevel.set(0)
477 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
478 DBdivindexBP.set(4)
479 DBlevelBP = IntVar(0) # Reference level
480 DBlevelBP.set(0)
481 hldn = 0
482 SpectrumScreenStatus = IntVar(0)
483 SmoothCurvesSA = IntVar(0)
484 SmoothCurvesBP = IntVar(0)
485 CutDC = IntVar(0)
486 IAScreenStatus = IntVar(0)
487 NqPScreenStatus = IntVar(0)
488 NqPDisp = IntVar(0)
489 NiCScreenStatus = IntVar(0)
490 NiCDisp = IntVar(0)
491 ImpedanceMagnitude = 0.0 # in ohms
492 ImpedanceAngle = 0.0 # in degrees
493 ImpedanceRseries = 0.0 # in ohms
494 ImpedanceXseries = 0.0 # in ohms
495 Show_Rseries = IntVar(0)
496 Show_Xseries = IntVar(0)
497 Show_Magnitude = IntVar(0)
498 Show_Angle = IntVar(0)
499 Show_RseriesRef = IntVar(0)
500 Show_XseriesRef = IntVar(0)
501 Show_MagnitudeRef = IntVar(0)
502 Show_AngleRef = IntVar(0)
503 
504 TIARline = []
505 TIAXline = []
506 TIAMagline = []
507 TIAAngline = []
508 TIAMline = []
509 TIAMRline = []
510 RefIARline = []
511 RefIAXline = []
512 RefIAMagline = []
513 RefIAAngline = []
514 IASource = IntVar(0)
515 
516 DisplaySeries = IntVar(0)
517 IA_Ext_Conf = IntVar(0)
518 IASweepSaved = IntVar(0)
519 OverRangeFlagA = 0
520 OverRangeFlagB = 0
521 PeakdbA = 10
522 PeakdbB = 10
523 PeakRelPhase = 0.0
524 PeakfreqA = 100
525 PeakfreqB = 1000
526 OhmStatus = IntVar(0)
527 OhmRunStatus = IntVar(0)
528 FFTbandwidth = 0 # The FFT bandwidth
529 FFTBuffA = [] # Clear the FFTBuff array for trace A
530 FFTBuffB = [] # Clear the FFTBuff array for trace B
531 FFTresultA = [] # FFT result CHA
532 PhaseA = []
533 FFTresultB = [] # FFT result CHB
534 PhaseB = []
535 FFTresultAB = []
536 FFTwindowname = "--" # The FFT window name
537 FFTmemoryA = numpy.ones(1) # The memory for averaging
538 PhaseMemoryA = numpy.ones(1)
539 FFTmemoryB = numpy.ones(1) # The memory for averaging
540 PhaseMemoryB = numpy.ones(1)
541 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
542 SMPfftpwrTwo.set(11)
543 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
544 Two28 = 268435456
545 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
546 
547 T1Fline = [] # Frequency Trace line channel A
548 T2Fline = [] # Frequency Trace line channel B
549 T1Pline = [] # Phase angle Trace line channel A - B
550 T2Pline = [] # Phase angle Trace line channel B - A
551 T1FRline = [] # F reference Trace line channel A
552 T2FRline = [] # F reference Trace line channel B
553 T1PRline = [] # Phase reference Trace line channel A - B
554 T2PRline = [] # Phase reference Trace line channel B - A
555 TFMline = [] # Frequency Math Trace
556 TFRMline = [] # Frequency reference Math Trace
557 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
558 FreqTraceMode.set(1)
559 
560 TAFline = [] # Bode Freq Trace line channel A
561 TBFline = [] # Bode Freq Trace line channel B
562 TAPline = [] # Bode Phase angle Trace line channel A - B
563 TBPline = [] # Bode Phase angle Trace line channel B - A
564 TAFRline = [] # Bode F reference Trace line channel A
565 TBFRline = [] # Bode F reference Trace line channel B
566 TAPRline = [] # Bode Phase reference Trace line channel A - B
567 TBPRline = [] # Bode Phase reference Trace line channel B - A
568 TBPMline = [] # Bode Frequency Math Trace
569 TBPRMline = [] # Bode Frequency reference Math Trace
570 #
571 MinSamplesSA = 64
572 MaxSamplesSA = 65536
573 #
574 MathScreenStatus = IntVar(0)
575 #
576 XYScreenStatus = IntVar(0)
577 Xsignal = IntVar(0) # Signal for X axis variable
578 Xsignal.set(1)
579 Ysignal = IntVar(0) # Signal for X axis variable
580 Ysignal.set(3)
581 ShowRXY = IntVar(0) # show reference XY trace
582 # show Analog Input Mux Variables
583 Show_CBA = IntVar(0)
584 Show_CBB = IntVar(0)
585 Show_CBC = IntVar(0)
586 Show_CBD = IntVar(0)
587 D0 = IntVar(0)
588 D1 = IntVar(0)
589 D2 = IntVar(0)
590 D3 = IntVar(0)
591 D4 = IntVar(0)
592 D5 = IntVar(0)
593 D6 = IntVar(0)
594 D7 = IntVar(0)
595 PIO_0 = 28
596 PIO_1 = 29
597 PIO_2 = 47
598 PIO_3 = 3
599 PIO_4 = 4
600 PIO_5 = 5
601 PIO_6 = 6
602 PIO_7 = 7
603 #
604 SCLKPort = IntVar(0)
605 SDATAPort = IntVar(0)
606 SLATCHPort = IntVar(0)
607 
608 
609 hipulse = """
610 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
611 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
612 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
613 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
614 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
615 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
616 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
617 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
618 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
619 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
620 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
621 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
622 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
623 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
624 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
625 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
626 """
627 hipulseimg = PhotoImage(data=hipulse)
628 
629 lowpulse = """
630 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
631 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
632 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
633 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
634 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
635 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
636 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
637 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
638 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
639 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
640 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
641 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
642 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
643 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
644 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
645 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
646 """
647 lowpulseimg = PhotoImage(data=lowpulse)
648 
649 class CreateToolTip(object):
650 
651  def __init__(self, widget, text='widget info'):
652  self.waittime = 500 #miliseconds
653  self.wraplength = 100 #pixels
654  self.widget = widget
655  self.text = text
656  self.widget.bind("<Enter>", self.enter)
657  self.widget.bind("<Leave>", self.leave)
658  self.widget.bind("<ButtonPress>", self.leave)
659  self.id = None
660  self.tw = None
661 
662  def enter(self, event=None):
663  self.schedule()
664 
665  def leave(self, event=None):
666  self.unschedule()
667  self.hidetip()
668 
669  def schedule(self):
670  self.unschedule()
671  self.id = self.widget.after(self.waittime, self.showtip)
672 
673  def unschedule(self):
674  id = self.id
675  self.id = None
676  if id:
677  self.widget.after_cancel(id)
678 
679  def showtip(self, event=None):
680  x = y = 0
681  x, y, cx, cy = self.widget.bbox("insert")
682  x += self.widget.winfo_rootx() + 25
683  y += self.widget.winfo_rooty() + 20
684  # creates a toplevel window
685  self.tw = Toplevel(self.widget)
686  # Leaves only the label and removes the app window
687  self.tw.wm_overrideredirect(True)
688  self.tw.wm_geometry("+%d+%d" % (x, y))
689  label = Label(self.tw, text=self.text, justify='left',
690  background="#ffffe0", relief='solid', borderwidth=1,
691  wraplength = self.wraplength)
692  label.pack(ipadx=1)
693 
694  def hidetip(self):
695  tw = self.tw
696  self.tw= None
697  if tw:
698  tw.destroy()
699 #
700 # =========== Start widgets routines =============================
701 
703 def BSaveConfig(filename):
704  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
705  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
706  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
707  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
708  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
709  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
710  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
711  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
712  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
713  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
714  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
715  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
716  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
717  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
718  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
719  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
720  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
721  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
722  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
723  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
724  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
725  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
726  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
727  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
728  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
729  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
730  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
731  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
732  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
733  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode
734  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
735  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
736  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
737  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
738  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
739  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
740  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
741  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
742  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
743  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
744  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
745  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
746  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
747  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
748  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
749  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
750  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
751  global AWGABurstFlag, AWGACycles, AWGABurstDelay
752  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
753  global SCLKPort, SDATAPort, SLATCHPort
754 
755  # open Config file for Write
756  ConfgFile = open(filename, "w")
757  # Save Window placements
758  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
759  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
760  ConfgFile.write('global GRW; GRW = ' + str(GRW) + '\n')
761  ConfgFile.write('global GRH; GRH = ' + str(GRH) + '\n')
762  # Windows configuration
763  ConfgFile.write('global MathString; MathString = "' + MathString + '"\n')
764  ConfgFile.write('global MathUnits; MathUnits = "' + MathUnits + '"\n')
765  ConfgFile.write('global MathAxis; MathAxis = "' + MathAxis + '"\n')
766  ConfgFile.write('global MathXString; MathXString = "' + MathXString + '"\n')
767  ConfgFile.write('global MathXUnits; MathXUnits = "' + MathXUnits + '"\n')
768  ConfgFile.write('global MathXAxis; MathXAxis = "' + MathXAxis + '"\n')
769  ConfgFile.write('global MathYString; MathYString = "' + MathYString + '"\n')
770  ConfgFile.write('global MathYUnits; MathYUnits = "' + MathYUnits + '"\n')
771  ConfgFile.write('global MathYAxis; MathYAxis = "' + MathYAxis + '"\n')
772  if MathScreenStatus.get() > 0:
773  ConfgFile.write('NewEnterMathControls()\n')
774  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
775  else:
776  ConfgFile.write('DestroyMathScreen()\n')
777  if XYScreenStatus.get() > 0:
778  ConfgFile.write('global GRWXY; GRWXY = ' + str(GRWXY) + '\n')
779  ConfgFile.write('global GRHXY; GRHXY = ' + str(GRHXY) + '\n')
780  ConfgFile.write('MakeXYWindow()\n')
781  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
782  ConfgFile.write('CHAsbxy.delete(0,END)\n')
783  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
784  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
785  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
786  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
787  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
788  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
789  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
790  ConfgFile.write('CHBsbxy.delete(0,END)\n')
791  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
792  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
793  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
794  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
795  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
796  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
797  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
798  else:
799  ConfgFile.write('DestroyXYScreen()\n')
800  if IAScreenStatus.get() > 0:
801  ConfgFile.write('global GRWIA; GRWIA = ' + str(GRWIA) + '\n')
802  ConfgFile.write('global GRHIA; GRHIA = ' + str(GRHIA) + '\n')
803  ConfgFile.write('MakeIAWindow()\n')
804  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
805  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
806  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
807  ConfgFile.write('RsystemEntry.delete(0,END)\n')
808  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
809  ConfgFile.write('ResScale.delete(0,END)\n')
810  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
811  ConfgFile.write('GainCorEntry.delete(0,END)\n')
812  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
813  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
814  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
815  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
816  else:
817  ConfgFile.write('DestroyIAScreen()\n')
818  if SpectrumScreenStatus.get() > 0:
819  ConfgFile.write('global GRWF; GRWF = ' + str(GRWF) + '\n')
820  ConfgFile.write('global GRHF; GRHF = ' + str(GRHF) + '\n')
821  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
822  ConfgFile.write('MakeSpectrumWindow()\n')
823  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
824  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
825  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
826  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
827  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
828  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
829  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
830  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
831  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
832  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
833  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
834  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
835  else:
836  ConfgFile.write('DestroySpectrumScreen()\n')
837  if DacScreenStatus.get() > 0:
838  ConfgFile.write('MakeDacScreen()\n')
839  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
840  else:
841  ConfgFile.write('DestroyDacScreen()\n')
842  if DigScreenStatus.get() > 0:
843  ConfgFile.write('MakeDigScreen()\n')
844  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
845  else:
846  ConfgFile.write('DestroyDigScreen()\n')
847  if MinigenScreenStatus.get() == 1:
848  ConfgFile.write('MakeMinigenWindow()\n')
849  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
850  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
851  ConfgFile.write('MinigenFout.delete(0,END)\n')
852  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
853  ConfgFile.write('MinigenFclk.delete(0,END)\n')
854  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
855  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
856  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
857  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
858  else:
859  ConfgFile.write('DestroyMinigenScreen()\n')
860  if MuxScreenStatus.get() == 1:
861  ConfgFile.write('MakeMuxModeWindow()\n')
862  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
863  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
864  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
865  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
866  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
867  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
868  ConfgFile.write('CHB_Asb.delete(0,END)\n')
869  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
870  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
871  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
872  ConfgFile.write('CHB_Csb.delete(0,END)\n')
873  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
874  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
875  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
876  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
877  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
878  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
879  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
880  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
881  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
882  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
883  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
884  else:
885  ConfgFile.write('DestroyMuxScreen()\n')
886  if BodeScreenStatus.get() == 1:
887  ConfgFile.write('global GRWBP; GRWBP = ' + str(GRWBP) + '\n')
888  ConfgFile.write('global GRHBP; GRHBP = ' + str(GRHBP) + '\n')
889  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
890  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
891  ConfgFile.write('MakeBodeWindow()\n')
892  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
893  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
894  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
895  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
896  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
897  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
898  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
899  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
900  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
901  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
902  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
903  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
904  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
905  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
906  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
907  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
908  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
909  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
910  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
911  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
912  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
913  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
914  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
915  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
916  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
917  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
918  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
919  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
920  else:
921  ConfgFile.write('DestroyBodeScreen()\n')
922  if MeasureStatus.get() == 1:
923  # Save strings
924  ConfgFile.write('global ChaLableSrring1; ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
925  ConfgFile.write('global ChaLableSrring2; ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
926  ConfgFile.write('global ChaLableSrring3; ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
927  ConfgFile.write('global ChaLableSrring4; ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
928  ConfgFile.write('global ChaLableSrring5; ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
929  ConfgFile.write('global ChaLableSrring6; ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
930  ConfgFile.write('global ChbLableSrring1; ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
931  ConfgFile.write('global ChbLableSrring2; ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
932  ConfgFile.write('global ChbLableSrring3; ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
933  ConfgFile.write('global ChbLableSrring4; ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
934  ConfgFile.write('global ChbLableSrring5; ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
935  ConfgFile.write('global ChbLableSrring6; ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
936  ConfgFile.write('global ChaMeasString1; ChaMeasString1 = "' + ChaMeasString1 + '"\n')
937  ConfgFile.write('global ChaMeasString2; ChaMeasString2 = "' + ChaMeasString2 + '"\n')
938  ConfgFile.write('global ChaMeasString3; ChaMeasString3 = "' + ChaMeasString3 + '"\n')
939  ConfgFile.write('global ChaMeasString4; ChaMeasString4 = "' + ChaMeasString4 + '"\n')
940  ConfgFile.write('global ChaMeasString5; ChaMeasString5 = "' + ChaMeasString5 + '"\n')
941  ConfgFile.write('global ChaMeasString6; ChaMeasString6 = "' + ChaMeasString6 + '"\n')
942  ConfgFile.write('global ChbMeasString1; ChbMeasString1 = "' + ChbMeasString1 + '"\n')
943  ConfgFile.write('global ChbMeasString2; ChbMeasString2 = "' + ChbMeasString2 + '"\n')
944  ConfgFile.write('global ChbMeasString3; ChbMeasString3 = "' + ChbMeasString3 + '"\n')
945  ConfgFile.write('global ChbMeasString4; ChbMeasString4 = "' + ChbMeasString4 + '"\n')
946  ConfgFile.write('global ChbMeasString5; ChbMeasString5 = "' + ChbMeasString5 + '"\n')
947  ConfgFile.write('global ChbMeasString6; ChbMeasString6 = "' + ChbMeasString6 + '"\n')
948  ConfgFile.write('MakeMeasureScreen()\n')
949  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
950  else:
951  ConfgFile.write('DestroyMeasuewScreen()\n')
952  if ETSStatus.get() == 1: #
953  ConfgFile.write('MakeETSWindow()\n')
954  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
955  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
956  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
957  ConfgFile.write('FMulXEntry.delete(0,END)\n')
958  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
959  ConfgFile.write('DivXEntry.delete(0,END)\n')
960  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
961  ConfgFile.write('ETSts.delete(0,END)\n')
962  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
963  else:
964  ConfgFile.write('DestroyETSScreen()\n')
965  #
966  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
967  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
968  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
969  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
970  ConfgFile.write('HozPossentry.delete(0,"end")\n')
971  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
972  ConfgFile.write('TMsb.delete(0,END)\n')
973  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
974  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
975  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
976  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
977  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
978  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
979  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
980  ConfgFile.write('Ysignal.set(' + str(Ysignal.get()) + ')\n')
981  #
982  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
983  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
984  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
985  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
986  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
987  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
988  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
989  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
990  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
991  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
992  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
993  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
994  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
995  #
996  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
997  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
998  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
999  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1000  ConfgFile.write('CHAsb.delete(0,END)\n')
1001  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1002  ConfgFile.write('CHAIsb.delete(0,END)\n')
1003  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1004  #
1005  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1006  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1007  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1008  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1009  ConfgFile.write('CHBsb.delete(0,END)\n')
1010  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1011  ConfgFile.write('CHBIsb.delete(0,END)\n')
1012  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1013  # AWG stuff
1014  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1015  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1016  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1017  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1018  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1019  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1020  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1021  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1022  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1023  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1024  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1025  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1026  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1027  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1028  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1029  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1030  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1031  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1032  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1033  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1034  #
1035  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1036  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1037  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1038  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1039  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1040  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1041  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1042  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1043  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1044  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1045  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1046  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1047  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1048  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1049  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1050  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1051  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1052  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1053  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1054  #
1055  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1056  #
1057  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1058  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1059  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1060  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1061  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1062  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1063  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1064  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1065  #
1066  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1067  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1068  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1069  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1070  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1071  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1072  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1073  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1074  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1075  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1076  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1077  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1078  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1079  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1080  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1081  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1082  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1083  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1084  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1085  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1086  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1087  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1088  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1089  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1090  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1091  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1092  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1093  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1094  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1095  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1096  #
1097  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1098  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1099  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1100  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1101  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1102  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1103  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1104  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1105  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1106  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1107  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1108  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1109  #
1110  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1111  #
1112  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1113  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1114  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1115  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1116  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1117  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1118  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1119  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1120  # Save strings
1121  ConfgFile.write('global UserAString; UserAString = "' + UserAString + '"\n')
1122  ConfgFile.write('global UserALabel; UserALabel = "' + UserALabel + '"\n')
1123  ConfgFile.write('global UserBString; UserBString = "' + UserBString + '"\n')
1124  ConfgFile.write('global UserBLabel; UserBLabel = "' + UserBLabel + '"\n')
1125  ConfgFile.write('global AWGAMathString; AWGAMathString = "' + AWGAMathString + '"\n')
1126  ConfgFile.write('global AWGBMathString; AWGBMathString = "' + AWGBMathString + '"\n')
1127  ConfgFile.write('global FFTUserWindowString; FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1128  ConfgFile.write('global DigFilterAString; DigFilterAString = "' + DigFilterAString + '"\n')
1129  ConfgFile.write('global DigFilterBString; DigFilterBString = "' + DigFilterBString + '"\n')
1130  # save channel AC frequency compensation settings
1131  try:
1132  CHA_TC1.set(float(cha_TC1Entry.get()))
1133  CHA_TC2.set(float(cha_TC2Entry.get()))
1134  CHB_TC1.set(float(chb_TC1Entry.get()))
1135  CHB_TC2.set(float(chb_TC2Entry.get()))
1136  CHA_A1.set(float(cha_A1Entry.get()))
1137  CHA_A2.set(float(cha_A2Entry.get()))
1138  CHB_A1.set(float(chb_A1Entry.get()))
1139  CHB_A2.set(float(chb_A2Entry.get()))
1140  except:
1141  donothing()
1142  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1143  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1144  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1145  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1146  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1147  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1148  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1149  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1150  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1151  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1152  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1153  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1154  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1155  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1156  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1157  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1158  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1159  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1160  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1161  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1162  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1163  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1164  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1165  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1166  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1167  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1168 
1169  # extra Spectrum stuff
1170  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1171  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1172  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1173  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1174  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1175  #
1176  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1177  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1178  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1179  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1180  #
1181  ConfgFile.close()
1182 
1184  global iawindow
1185 
1186  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1187  BSaveConfig(filename)
1188 
1190  global freqwindow
1191 
1192  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1193  BSaveConfig(filename)
1194 
1196  global bodewindow
1197 
1198  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1199  BSaveConfig(filename)
1200 
1202  global root
1203  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1204  BSaveConfig(filename)
1205 
1206 def BLoadConfig(filename):
1207  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1208  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1209  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
1210  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1211  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1212  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1213  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1214  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1215  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1216  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1217  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1218  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1219  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1220  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1221  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1222  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1223  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1224  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1225  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1226  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1227  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1228  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1229  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1230  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1231  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1232  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1233  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1234  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
1235  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1236  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1237  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1238  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1239  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1240  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1241  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1242  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1243  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1244  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1245  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1246  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1247  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1248  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1249  global AWGABurstFlag, AWGACycles, AWGABurstDelay
1250  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
1251  global SCLKPort, SDATAPort, SLATCHPort
1252 
1253  # Read configuration values from file
1254  try:
1255  ConfgFile = open(filename)
1256  for line in ConfgFile:
1257  try:
1258  exec( line.rstrip() )
1259  except:
1260  print( "Skipping " + line.rstrip())
1261  ConfgFile.close()
1262  if DevID != "No Device":
1263  BAWGAModeLabel()
1264  BAWGBModeLabel()
1265  BAWGAPhaseDelay()
1266  BAWGBPhaseDelay()
1267  TimeCheckBox()
1268  XYCheckBox()
1269  FreqCheckBox()
1270  BodeCheckBox()
1271  IACheckBox()
1272  OhmCheckBox()
1273 #
1274  time.sleep(0.05)
1275  ReMakeAWGwaves()
1276  BTime()
1277  except:
1278  print( "Config File Not Found.")
1279 
1280 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1281  global AWGAShape, AWGBShape, BisCompA
1282 
1283  if AWGAShape.get()==9:
1284  AWGAMakeImpulse()
1285  elif AWGAShape.get()==11:
1287  elif AWGAShape.get()==15:
1288  AWGAMakeSSQ()
1289  elif AWGAShape.get()==16:
1290  AWGAMakeRamp()
1291  elif AWGAShape.get()==17:
1292  AWGAMakePWMSine()
1293  elif AWGAShape.get()==18:
1295  elif AWGAShape.get()==12:
1297  elif AWGAShape.get()==14:
1298  AWGAMakeFourier()
1299  elif AWGAShape.get()==19:
1300  AWGAMakeSinc()
1301  elif AWGAShape.get()==20:
1302  AWGAMakePulse()
1303  elif AWGAShape.get()==21:
1304  AWGAMakeFMSine()
1305  elif AWGAShape.get()==22:
1306  AWGAMakeAMSine()
1307  elif AWGAShape.get()==7:
1308  AWGAMakeUUNoise()
1309  elif AWGAShape.get()==8:
1310  AWGAMakeUGNoise()
1311 #
1312  if BisCompA.get() == 1:
1313  SetBCompA()
1314  if AWGBShape.get()==9:
1315  AWGBMakeImpulse()
1316  elif AWGBShape.get()==11:
1318  elif AWGBShape.get()==15:
1319  AWGBMakeSSQ()
1320  elif AWGBShape.get()==16:
1321  AWGBMakeRamp()
1322  elif AWGBShape.get()==17:
1323  AWGBMakePWMSine()
1324  elif AWGBShape.get()==18:
1326  elif AWGBShape.get()==12:
1328  elif AWGBShape.get()==14:
1329  AWGBMakeFourier()
1330  elif AWGBShape.get()==19:
1331  AWGBMakeSinc()
1332  elif AWGBShape.get()==20:
1333  AWGBMakePulse()
1334  elif AWGBShape.get()==7:
1335  AWGBMakeUUNoise()
1336  elif AWGBShape.get()==8:
1337  AWGBMakeUGNoise()
1338  else:
1339  UpdateAwgCont()
1340  time.sleep(0.05)
1341 
1343  global iawindow
1344 
1345  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1346  BLoadConfig(filename)
1347 
1349  global freqwindow
1350 
1351  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1352  BLoadConfig(filename)
1353 
1355  global bodewindow
1356 
1357  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1358  BLoadConfig(filename)
1359 
1361  global root
1362 
1363  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1364  BLoadConfig(filename)
1365  UpdateTimeTrace()
1366 
1367 def BgColor():
1368  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus
1369  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
1370 
1371  if ColorMode.get() > 0:
1372  COLORtext = "#000000" # 100% black
1373  COLORtrace4 = "#a0a000" # 50% yellow
1374  COLORtraceR4 = "#606000" # 25% yellow
1375  COLORcanvas = "#ffffff" # 100% white
1376  else:
1377  COLORcanvas = "#000000" # 100% black
1378  COLORtrace4 = "#ffff00" # 100% yellow
1379  COLORtraceR4 = "#808000" # 50% yellow
1380  COLORtext = "#ffffff" # 100% white
1381  ca.config(background=COLORcanvas)
1383  if SpectrumScreenStatus.get() > 0:
1384  Freqca.config(background=COLORcanvas)
1386  if XYScreenStatus.get() > 0:
1387  XYca.config(background=COLORcanvas)
1388  UpdateXYScreen()
1389  if IAScreenStatus.get() > 0:
1390  IAca.config(background=COLORcanvas)
1391  UpdateIAScreen()
1392  if BodeScreenStatus.get() > 0:
1393  Bodeca.config(background=COLORcanvas)
1395 
1397  global CANVASwidth, CANVASheight
1398  global COLORtext, MarkerNum, ColorMode
1399  # ask for file name
1400  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
1401  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
1402  if MarkerNum > 0 or ColorMode.get() > 0:
1403  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
1404  else: # temp chnage text corlor to black
1405  COLORtext = "#000000"
1407  # first save postscript file
1408  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
1409  # now convert to bit map
1410  # img = Image.open("screen_shot.eps")
1411  # img.save("screen_shot.gif", "gif")
1412  COLORtext = "#ffffff"
1414 
1416  global CANVASwidthXY, CANVASheightXY, xywindow
1417  global COLORtext, MarkerNum, ColorMode, XYca
1418  # ask for file name
1419  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
1420  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
1421  if MarkerNum > 0 or ColorMode.get() > 0:
1422  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
1423  else: # temp chnage text corlor to black
1424  COLORtext = "#000000"
1425  UpdateXYScreen()
1426  # first save postscript file
1427  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
1428  # now convert to bit map
1429  # img = Image.open("screen_shot.eps")
1430  # img.save("screen_shot.gif", "gif")
1431  COLORtext = "#ffffff"
1432  UpdateXYScreen()
1433 
1435  global CANVASwidthIA, CANVASheightIA
1436  global COLORtext, IAca, ColorMode, iawindow
1437  # ask for file name
1438  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
1439  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
1440  if ColorMode.get() > 0:
1441  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
1442  else: # temp change text color to black for Black BG
1443  COLORtext = "#000000"
1444  UpdateIAScreen()
1445  # save postscript file
1446  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
1447  #
1448  COLORtext = "#ffffff"
1449  UpdateIAScreen()
1450 
1452  global CANVASwidthBP, CANVASheightBP
1453  global COLORtext, Bodeca, bodewindow
1454  # ask for file name
1455  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
1456  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
1457  if MarkerNum > 0 or ColorMode.get() > 0:
1458  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
1459  else: # temp change text color to black
1460  COLORtext = "#000000"
1462  # save postscript file
1463  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
1464  #
1465  COLORtext = "#ffffff"
1467 
1469  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
1470 
1471  # open file to save data
1472  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
1473  DataFile = open(filename, 'w')
1474  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
1475  for index in range(len(VBuffA)):
1476  TimePnt = float((index+0.0)/SAMPLErate)
1477  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
1478  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
1479  DataFile.close()
1480 
1482  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
1483 
1484  # ask user for channel to save
1485  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I or CB-I\n\nChannel:\n", initialvalue="CA-V")
1486  if (Channel == None): # If Cancel pressed, then None
1487  return
1488  # open file to save data
1489  filename = asksaveasfilename(defaultextension = ".txt", filetypes=[("Text Columns", "*.txt")])
1490  DataFile = open(filename, 'w')
1491  for index in range(len(VBuffA)):
1492  TimePnt = float((index+0.0)/SAMPLErate)
1493  if Channel == "CA-V":
1494  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
1495  elif Channel == "CA-I":
1496  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
1497  elif Channel == "CB-V":
1498  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
1499  elif Channel == "CB-I":
1500  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
1501  DataFile.close()
1502 
1504  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
1505 
1506  # Read values from CVS file
1507  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
1508  try:
1509  CSVFile = open(filename)
1510  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
1511  CSVFile.seek(0)
1512  csv_f = csv.reader(CSVFile, dialect)
1513  VBuffA = []
1514  VBuffB = []
1515  IBuffA = []
1516  IBuffB = []
1517  SHOWsamples = 0
1518  for row in csv_f:
1519  try:
1520  VBuffA.append(float(row[1]))
1521  IBuffA.append(float(row[2]))
1522  VBuffB.append(float(row[3]))
1523  IBuffB.append(float(row[4]))
1524  SHOWsamples = SHOWsamples + 1
1525  except:
1526  print( 'skipping non-numeric row')
1527  VBuffA = numpy.array(VBuffA)
1528  IBuffA = numpy.array(IBuffA)
1529  VBuffB = numpy.array(VBuffB)
1530  IBuffB = numpy.array(IBuffB)
1531  CSVFile.close()
1532  UpdateTimeTrace()
1533  except:
1534  showwarning("WARNING","No such file found or wrong format!")
1535 
1537 def BHelp():
1538 
1539  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
1540  webbrowser.open(url,new=2)
1541 
1542 def BAbout():
1543  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
1544 
1545  try:
1546  u = urllib2.urlopen(Version_url)
1547  meta = u.info()
1548  time_string = str(meta.getheaders("Last-Modified"))
1549  except:
1550  time_string = "Unavailable"
1551  print(time_string)
1552  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
1553  "Latest Version: " + time_string[7:18] + "\n" +
1554  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
1555  "Firmware Rev " + str(FWRevOne) + "\n" +
1556  "Board Serial Number " + DevID + "\n" +
1557  "Software is provided as is without any Warranty")
1558 
1560  global T1Vline, T2Vline, T1Iline, T2Iline
1561  global TXYline, Tmathline, TMRline, TXYRline
1562  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
1563  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
1564  global MuxScreenStatus, TMCRline, TMBRline, TMAVline, TMBVline, TMCVline, TMDVline
1565  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
1566 
1567  if ShowC1_V.get() == 1:
1568  T1VRline = T1Vline # V reference Trace line channel A
1569  if ShowC2_V.get() == 1:
1570  T2VRline = T2Vline # V reference Trace line channel B
1571  if ShowC1_I.get() == 1:
1572  T1IRline = T1Iline # I reference Trace line channel A
1573  if ShowC2_I.get() == 1:
1574  T2IRline = T2Iline # I reference Trace line channel B
1575  if MathTrace.get() > 0:
1576  TMRline = Tmathline # Math reference Trace line
1577  if MuxScreenStatus.get() > 0:
1578  if Show_CBA.get() > 0:
1579  T2VRline = TMAVline # V reference Trace line Mux channel A
1580  if Show_CBB.get() > 0:
1581  TMBRline = TMBVline # V reference Trace line Mux channel B
1582  if Show_CBC.get() > 0:
1583  TMCRline = TMCVline # V reference Trace line Mux channel C
1584  if Show_CBD.get() > 0:
1585  T2IRline = TMDVline # V reference Trace line Mux channel D
1586  if len(TXYline) > 4:
1587  TXYRline = TXYline # XY reference trace line
1588 
1589 def BSaveCal():
1590  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1591  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1592  global DevID
1593  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1594  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
1595  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1596  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1597 
1598  devidstr = DevID[17:31]
1599  filename = devidstr + "_O.cal"
1600  CalFile = open(filename, "w")
1601  #
1602  CalFile.write('CHAVGainEntry.delete(0,END)\n')
1603  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1604  CalFile.write('CHBVGainEntry.delete(0,END)\n')
1605  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1606  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
1607  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1608  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
1609  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1610  #
1611  CalFile.write('CHAIGainEntry.delete(0,END)\n')
1612  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1613  CalFile.write('CHBIGainEntry.delete(0,END)\n')
1614  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1615  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
1616  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1617  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
1618  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1619  #
1620  # save channel AC frequency compensation settings
1621  try:
1622  CHA_TC1.set(float(cha_TC1Entry.get()))
1623  CHA_TC2.set(float(cha_TC2Entry.get()))
1624  CHB_TC1.set(float(chb_TC1Entry.get()))
1625  CHB_TC2.set(float(chb_TC2Entry.get()))
1626  CHA_A1.set(float(cha_A1Entry.get()))
1627  CHA_A2.set(float(cha_A2Entry.get()))
1628  CHB_A1.set(float(chb_A1Entry.get()))
1629  CHB_A2.set(float(chb_A2Entry.get()))
1630  except:
1631  donothing()
1632  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1633  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1634  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1635  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1636  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1637  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1638  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1639  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1640  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1641  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1642  CalFile.write('cha_TC1Entry.delete(0,END)\n')
1643  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1644  CalFile.write('cha_TC2Entry.delete(0,END)\n')
1645  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1646  CalFile.write('chb_TC1Entry.delete(0,END)\n')
1647  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1648  CalFile.write('chb_TC2Entry.delete(0,END)\n')
1649  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1650  CalFile.write('cha_A1Entry.delete(0,END)\n')
1651  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1652  CalFile.write('cha_A2Entry.delete(0,END)\n')
1653  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1654  CalFile.write('chb_A1Entry.delete(0,END)\n')
1655  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1656  CalFile.write('chb_A2Entry.delete(0,END)\n')
1657  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1658 
1659  CalFile.close()
1660 
1661 def BLoadCal():
1662  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1663  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1664  global DevID
1665  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
1666  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
1667  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1668  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1669 
1670  devidstr = DevID[17:31]
1671  filename = devidstr + "_O.cal"
1672  try:
1673  CalFile = open(filename)
1674  for line in CalFile:
1675  exec( line.rstrip() )
1676  CalFile.close()
1677  except:
1678  print( "Cal file for this device not found")
1679 
1681  global UserAString, UserALabel, MeasUserA
1682 
1683  TempString = UserALabel
1684  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
1685  if (UserALabel == None): # If Cancel pressed, then None
1686  MeasUserA.set(0)
1687  UserALabel = TempString
1688  return
1689  TempString = UserAString
1690  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
1691  if (UserAString == None): # If Cancel pressed, then None
1692  MeasUserA.set(0)
1693  UserAString = TempString
1694  return
1695  MeasUserA.set(1)
1696 
1698  global UserBString, UserBLabel, MeasUserB
1699 
1700  TempString = UserBLabel
1701  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
1702  if (UserBLabel == None): # If Cancel pressed, then None
1703  MeasUserB.set(0)
1704  UserBLabel = TempString
1705  return
1706  TempString = UserBString
1707  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
1708  if (UserBString == None): # If Cancel pressed, then None
1709  MeasUserB.set(0)
1710  UserBString = TempString
1711  return
1712  MeasUserB.set(1)
1713 
1715  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
1716  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
1717  global MathAxis, MathXAxis, MathYAxis, MathTrace
1718  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
1719  global formlab, xformlab, yformlab
1720 
1721  if MathScreenStatus.get() == 0:
1722  MathScreenStatus.set(1)
1723  #
1724  MathWindow = Toplevel()
1725  MathWindow.title("Math Formula " + SWRev + RevDate)
1726  MathWindow.resizable(FALSE,FALSE)
1727  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
1728  frame1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10R1.TLabelframe")
1729  frame2 = LabelFrame(MathWindow, text="Math Trace", style="A10R1.TLabelframe")
1730  frame3 = LabelFrame(MathWindow, text="X Math Trace", style="A10R1.TLabelframe")
1731  frame4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10R1.TLabelframe")
1732  # frame1.grid(row=0, column=0, sticky=W)
1733  #
1734  frame1.grid(row = 0, column=0, rowspan=3, sticky=W)
1735  frame2.grid(row = 0, column=1, sticky=W)
1736  frame3.grid(row = 1, column=1, sticky=W)
1737  frame4.grid(row = 2, column=1, sticky=W)
1738  #
1739  # Built in functions
1740  #
1741  rb1 = Radiobutton(frame1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
1742  rb1.grid(row=0, column=0, sticky=W)
1743  rb2 = Radiobutton(frame1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
1744  rb2.grid(row=1, column=0, sticky=W)
1745  rb3 = Radiobutton(frame1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
1746  rb3.grid(row=2, column=0, sticky=W)
1747  rb4 = Radiobutton(frame1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
1748  rb4.grid(row=3, column=0, sticky=W)
1749  rb5 = Radiobutton(frame1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
1750  rb5.grid(row=4, column=0, sticky=W)
1751  rb6 = Radiobutton(frame1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
1752  rb6.grid(row=5, column=0, sticky=W)
1753  rb7 = Radiobutton(frame1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
1754  rb7.grid(row=6, column=0, sticky=W)
1755  rb8 = Radiobutton(frame1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
1756  rb8.grid(row=7, column=0, sticky=W)
1757  rb9 = Radiobutton(frame1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
1758  rb9.grid(row=8, column=0, sticky=W)
1759  rb10 = Radiobutton(frame1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
1760  rb10.grid(row=9, column=0, sticky=W)
1761  rb11 = Radiobutton(frame1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
1762  rb11.grid(row=10, column=0, sticky=W)
1763  rb12 = Radiobutton(frame1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
1764  rb12.grid(row=11, column=0, sticky=W)
1765  rb13 = Radiobutton(frame1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
1766  rb13.grid(row=12, column=0, sticky=W)
1767  #
1768  # Math trace formula sub frame2
1769  #
1770  sframe2a = Frame( frame2 )
1771  sframe2a.pack(side=TOP)
1772  formlab = Label(sframe2a, text="Formula ", style= "A10B.TLabel")
1773  formlab.grid(row=0, column=0, sticky=W)
1774  formlab.pack(side=LEFT)
1775  formentry = Entry(sframe2a, width=23)
1776  formentry.grid(row=0, column=1, sticky=W)
1777  formentry.pack(side=LEFT)
1778  formentry.delete(0,"end")
1779  formentry.insert(0,MathString)
1780  sframe2b = Frame( frame2 )
1781  sframe2b.pack(side=TOP)
1782  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
1783  unitslab.grid(row=0, column=0, sticky=W)
1784  unitslab.pack(side=LEFT)
1785  unitsentry = Entry(sframe2b, width=6)
1786  unitsentry.grid(row=0, column=1, sticky=W)
1787  unitsentry.pack(side=LEFT)
1788  unitsentry.delete(0,"end")
1789  unitsentry.insert(0,MathUnits)
1790  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
1791  checkbt.grid(row=0, column=2, sticky=W)
1792  checkbt.pack(side=LEFT)
1793  sframe2c = Frame( frame2 )
1794  sframe2c.pack(side=TOP)
1795  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
1796  axislab.grid(row=0, column=0, sticky=W)
1797  axislab.pack(side=LEFT)
1798  axisentry = Entry(sframe2c, width=3)
1799  axisentry.grid(row=0, column=1, sticky=W)
1800  axisentry.pack(side=LEFT)
1801  axisentry.delete(0,"end")
1802  axisentry.insert(0,MathAxis)
1803  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
1804  applybt.grid(row=0, column=2, sticky=W)
1805  applybt.pack(side=LEFT)
1806  #
1807  # X Math trace formula sub frame3
1808  #
1809  sframe3a = Frame( frame3 )
1810  sframe3a.pack(side=TOP)
1811  xformlab = Label(sframe3a, text=" X Formula ", style= "A10B.TLabel")
1812  xformlab.grid(row=0, column=0, sticky=W)
1813  xformlab.pack(side=LEFT)
1814  xformentry = Entry(sframe3a, width=20)
1815  xformentry.grid(row=0, column=1, sticky=W)
1816  xformentry.pack(side=LEFT)
1817  xformentry.delete(0,"end")
1818  xformentry.insert(0, MathXString)
1819  sframe3b = Frame( frame3 )
1820  sframe3b.pack(side=TOP)
1821  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
1822  xunitslab.grid(row=0, column=0, sticky=W)
1823  xunitslab.pack(side=LEFT)
1824  xunitsentry = Entry(sframe3b, width=6)
1825  xunitsentry.grid(row=0, column=1, sticky=W)
1826  xunitsentry.pack(side=LEFT)
1827  xunitsentry.delete(0,"end")
1828  xunitsentry.insert(0, MathXUnits)
1829  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
1830  xcheckbt.grid(row=0, column=2, sticky=W)
1831  xcheckbt.pack(side=LEFT)
1832  sframe3c = Frame( frame3 )
1833  sframe3c.pack(side=TOP)
1834  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
1835  xaxislab.grid(row=0, column=0, sticky=W)
1836  xaxislab.pack(side=LEFT)
1837  xaxisentry = Entry(sframe3c, width=3)
1838  xaxisentry.grid(row=0, column=1, sticky=W)
1839  xaxisentry.pack(side=LEFT)
1840  xaxisentry.delete(0,"end")
1841  xaxisentry.insert(0, MathXAxis)
1842  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
1843  xapplybt.grid(row=0, column=3, sticky=W)
1844  xapplybt.pack(side=LEFT)
1845  #
1846  # Math trace formula sub frame4
1847  #
1848  sframe4a = Frame( frame4 )
1849  sframe4a.pack(side=TOP)
1850  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
1851  yformlab.grid(row=0, column=0, sticky=W)
1852  yformlab.pack(side=LEFT)
1853  yformentry = Entry(sframe4a, width=20)
1854  yformentry.grid(row=0, column=1, sticky=W)
1855  yformentry.pack(side=LEFT)
1856  yformentry.delete(0,"end")
1857  yformentry.insert(0,MathYString)
1858  sframe4b = Frame( frame4 )
1859  sframe4b.pack(side=TOP)
1860  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
1861  yunitslab.grid(row=0, column=0, sticky=W)
1862  yunitslab.pack(side=LEFT)
1863  yunitsentry = Entry(sframe4b, width=6)
1864  yunitsentry.grid(row=0, column=1, sticky=W)
1865  yunitsentry.pack(side=LEFT)
1866  yunitsentry.delete(0,"end")
1867  yunitsentry.insert(0,MathYUnits)
1868  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
1869  ycheckbt.grid(row=0, column=2, sticky=W)
1870  ycheckbt.pack(side=LEFT)
1871  sframe4c = Frame( frame4 )
1872  sframe4c.pack(side=TOP)
1873  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
1874  yaxislab.grid(row=0, column=0, sticky=W)
1875  yaxislab.pack(side=LEFT)
1876  yaxisentry = Entry(sframe4c, width=3)
1877  yaxisentry.grid(row=0, column=1, sticky=W)
1878  yaxisentry.pack(side=LEFT)
1879  yaxisentry.delete(0,"end")
1880  yaxisentry.insert(0,MathYAxis)
1881  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
1882  yapplybt.grid(row=0, column=3, sticky=W)
1883  yapplybt.pack(side=LEFT)
1884 
1885  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
1886  dismissbutton.grid(row=3, column=0, sticky=W)
1887 
1888  if RUNstatus.get() > 0:
1889  UpdateTimeTrace()
1890 
1892  global MathScreenStatus, MathWindow
1893 
1894  if MathScreenStatus.get() == 1:
1895  MathScreenStatus.set(0)
1896  MathWindow.destroy()
1897 
1899  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
1900  global VBuffA, VBuffB, IBuffA, IBuffB
1901  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
1902  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
1903  global FFTBuffA, FFTBuffB, FFTwindowshape
1904  global AWGAwaveform, AWGBwaveform
1905  global Show_MathX, Show_MathY
1906  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
1907  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
1908 
1909  t = 0
1910  TempString = formentry.get()
1911  try:
1912  MathResult = eval(TempString)
1913  formlab.configure(text="Formula ", style= "A10G.TLabel")
1914  except:
1915  formlab.configure(text="Formula ", style= "A10R.TLabel")
1916 
1918  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
1919  global VBuffA, VBuffB, IBuffA, IBuffB
1920  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
1921  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
1922  global FFTBuffA, FFTBuffB, FFTwindowshape
1923  global AWGAwaveform, AWGBwaveform
1924  global Show_MathX, Show_MathY
1925  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
1926  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
1927 
1928  t = 0
1929  TempString = xformentry.get()
1930  try:
1931  MathResult = eval(TempString)
1932  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
1933  except:
1934  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
1935 
1937  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
1938  global VBuffA, VBuffB, IBuffA, IBuffB
1939  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
1940  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
1941  global FFTBuffA, FFTBuffB, FFTwindowshape
1942  global AWGAwaveform, AWGBwaveform
1943  global Show_MathX, Show_MathY
1944  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
1945  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
1946 
1947  t = 0
1948  TempString = yformentry.get()
1949  try:
1950  MathResult = eval(TempString)
1951  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
1952  except:
1953  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
1954 
1956  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
1957 
1958  MathString = formentry.get()
1959  MathUnits = unitsentry.get()
1960  MathAxis = axisentry.get()
1961 
1963  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
1964 
1965  MathXString = xformentry.get()
1966  MathXUnits = xunitsentry.get()
1967  MathXAxis = xaxisentry.get()
1968 
1970  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
1971 
1972  MathYString = yformentry.get()
1973  MathYUnits = yunitsentry.get()
1974  MathYAxis = yaxisentry.get()
1975 
1977  global MarkerLoc
1978 
1979  TempString = MarkerLoc
1980  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
1981  if (MarkerLoc == None): # If Cancel pressed, then None
1982  MarkerLoc = TempString
1983  UpdateTimeTrace()
1984 
1986  global RUNstatus
1987 
1988 def DoNothing(event):
1989  global RUNstatus
1990 
1992  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
1993  ShowC1_V.set(1)
1994  ShowC1_I.set(1)
1995  ShowC2_V.set(1)
1996  ShowC2_I.set(1)
1997  UpdateTimeTrace()
1998 
2000  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
2001  ShowC1_V.set(0)
2002  ShowC1_I.set(0)
2003  ShowC2_V.set(0)
2004  ShowC2_I.set(0)
2005  UpdateTimeTrace()
2006 
2008  global TgEdge
2009 
2010 # TRIGCOND trigcondRisingPositive = 0
2011 # TRIGCOND trigcondFallingNegative = 1
2012 
2014  global TgInput, TRIGGERlevel, TRIGGERentry
2015  global MaxV1, MinV1, MaxV2, MinV2
2016  global MaxI1, MinI1, MaxI2, MinI2
2017  # set new trigger level to mid point of waveform
2018  MidV1 = (MaxV1+MinV1)/2
2019  MidV2 = (MaxV2+MinV2)/2
2020  MidI1 = (MaxI1+MinI1)/2
2021  MidI2 = (MaxI2+MinI2)/2
2022  if (TgInput.get() == 0):
2023  DCString = "0.0"
2024  elif (TgInput.get() == 1 ):
2025  DCString = ' {0:.2f} '.format(MidV1)
2026  elif (TgInput.get() == 2 ):
2027  DCString = ' {0:.2f} '.format(MidI1)
2028  elif (TgInput.get() == 3 ):
2029  DCString = ' {0:.2f} '.format(MidV2)
2030  elif (TgInput.get() == 4 ):
2031  DCString = ' {0:.2f} '.format(MidI2)
2032 
2033  TRIGGERlevel = eval(DCString)
2034  TRIGGERentry.delete(0,END)
2035  TRIGGERentry.insert(4, DCString)
2036 
2037  UpdateTimeTrace() # Always Update
2038 
2040  global TgInput
2041 
2042 # if (TgInput.get() == 0):
2043  # no trigger
2044 # elif (TgInput.get() == 1):
2045  # trigger source set to detector of analog in channels
2046  # auto trigger timeout value
2047 # elif (TgInput.get() == 2):
2048  # trigger source set to detector of analog in channels
2049  # 0 disables auto trigger
2050 
2051 def BTriglevel(event):
2052  global TRIGGERlevel, TRIGGERentry
2053 
2054  # evalute entry string to a numerical value
2055  try:
2056  TRIGGERlevel = float(eval(TRIGGERentry.get()))
2057  except:
2058  TRIGGERentry.delete(0,END)
2059  TRIGGERentry.insert(0, TRIGGERlevel)
2060  # set new trigger level
2061 
2062  UpdateTimeTrace() # Always Update
2063 
2064 def BHoldOff(event):
2065  global HoldOff, HoldOffentry
2066 
2067  try:
2068  HoldOff = float(eval(HoldOffentry.get()))
2069  except:
2070  HoldOffentry.delete(0,END)
2071  HoldOffentry.insert(0, HoldOff)
2072 # Set Horx possition from entry widget
2073 def BHozPoss(event):
2074  global HozPoss, HozPossentry
2075 
2076  try:
2077  HozPoss = float(eval(HozPossentry.get()))
2078  except:
2079  HozPossentry.delete(0,END)
2080  HozPossentry.insert(0, HozPoss)
2081 #
2083  global HozPossentry, TgInput, TMsb
2084 
2085  # get time scale
2086  try:
2087  TIMEdiv = float(eval(TMsb.get()))
2088  except:
2089  TIMEdiv = 0.5
2090  TMsb.delete(0,"end")
2091  TMsb.insert(0,TIMEdiv)
2092  # prevent divide by zero error
2093  if TIMEdiv < 0.0002:
2094  TIMEdiv = 0.01
2095  if TgInput.get() > 0:
2096  HozPoss = -5 * TIMEdiv
2097  HozPossentry.delete(0,END)
2098  HozPossentry.insert(0, HozPoss)
2099 #
2101  global HoldOffentry, HoldOff, TgInput, TMsb
2102 
2103 # get time scale
2104  try:
2105  TIMEdiv = float(eval(TMsb.get()))
2106  except:
2107  TIMEdiv = 0.5
2108  TMsb.delete(0,"end")
2109  TMsb.insert(0,TIMEdiv)
2110  # prevent divide by zero error
2111  if TIMEdiv < 0.0002:
2112  TIMEdiv = 0.01
2113  if TgInput.get() == 0:
2114  HoldOff = HoldOff + TIMEdiv
2115  HoldOffentry.delete(0,END)
2116  HoldOffentry.insert(0, HoldOff)
2117 
2119  global CHB_APosEntry, DCVMuxA
2120 
2121  CHB_APosEntry.delete(0,"end")
2122  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
2123 #
2125  global CHB_BPosEntry, DCVMuxB
2126 
2127  CHB_BPosEntry.delete(0,"end")
2128  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
2129 #
2131  global CHB_CPosEntry, DCVMuxC
2132 
2133  CHB_CPosEntry.delete(0,"end")
2134  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
2135 #
2137  global CHD_BPosEntry, DCVMuxD
2138 
2139  CHB_DPosEntry.delete(0,"end")
2140  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
2141 #
2143  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2144 
2145  if MarkerScale.get() != 1:
2146  MarkerScale.set(5)
2147  CHB_Alab.config(style="Rtrace2.TButton")
2148  CHB_Blab.config(style="Strace6.TButton")
2149  CHB_Clab.config(style="Strace7.TButton")
2150  CHB_Dlab.config(style="Strace4.TButton")
2151  else:
2152  MarkerScale.set(0)
2153 #
2155  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2156 
2157  if MarkerScale.get() != 1:
2158  MarkerScale.set(6)
2159  CHB_Alab.config(style="Strace2.TButton")
2160  CHB_Blab.config(style="Rtrace6.TButton")
2161  CHB_Clab.config(style="Strace7.TButton")
2162  CHB_Dlab.config(style="Strace4.TButton")
2163  else:
2164  MarkerScale.set(0)
2165 #
2167  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2168 
2169  if MarkerScale.get() != 1:
2170  MarkerScale.set(7)
2171  CHB_Alab.config(style="Strace2.TButton")
2172  CHB_Blab.config(style="Strace6.TButton")
2173  CHB_Clab.config(style="Rtrace7.TButton")
2174  CHB_Dlab.config(style="Strace4.TButton")
2175  else:
2176  MarkerScale.set(0)
2177 #
2179  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2180 
2181  if MarkerScale.get() != 1:
2182  MarkerScale.set(8)
2183  CHB_Alab.config(style="Strace2.TButton")
2184  CHB_Blab.config(style="Strace6.TButton")
2185  CHB_Clab.config(style="Strace7.TButton")
2186  CHB_Dlab.config(style="Rtrace4.TButton")
2187  else:
2188  MarkerScale.set(0)
2189 #
2191  global CHAVPosEntry, DCV1
2192 
2193  CHAVPosEntry.delete(0,"end")
2194  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
2195 #
2197  global CHBVPosEntry, DCV2
2198 
2199  CHBVPosEntry.delete(0,"end")
2200  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
2201 #
2203  global CHAIPosEntry, DCI1
2204 
2205  CHAIPosEntry.delete(0,"end")
2206  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
2207 #
2209  global CHBIPosEntry, DCI2
2210 
2211  CHBIPosEntry.delete(0,"end")
2212  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
2213 #
2215  global CHAVPosEntryxy, DCV1
2216 
2217  CHAVPosEntryxy.delete(0,"end")
2218  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
2219 #
2221  global CHBVPosEntryxy, DCV2
2222 
2223  CHBVPosEntryxy.delete(0,"end")
2224  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
2225 #
2227  global CHAIPosEntryxy, DCI1
2228 
2229  CHAIPosEntryxy.delete(0,"end")
2230  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
2231 #
2233  global CHBIPosEntryxy, DCI2
2234 
2235  CHBIPosEntryxy.delete(0,"end")
2236  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
2237 
2239  global RUNstatus, session, CHA, CHB, devx, AWG_2X
2240 
2241  RUNstatus.set(0)
2242  BSaveConfig("alice-last-config.cfg")
2243  # Put channels in Hi-Z and exit
2244  try:
2245  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2246  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2247  devx.set_adc_mux(0) # set ADC mux conf to default
2248  AWG_2X.set(0)
2249  BAWG2X()
2250  CHA.constant(0.0)
2251  CHB.constant(0.0)
2252  if session.continuous:
2253  session.end()
2254  except:
2255  donothing()
2256 
2257  root.destroy()
2258  exit()
2259 
2260 def BStart():
2261  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
2262  global contloop, discontloop, TIMEdiv, First_Slow_sweep
2263 
2264  if DevID == "No Device":
2265  showwarning("WARNING","No Device Plugged In!")
2266  elif FWRevOne == 0.0:
2267  showwarning("WARNING","Out of data Firmware!")
2268  else:
2269  if PowerStatus == 0:
2270  PowerStatus = 1
2271  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2272  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2273  if (RUNstatus.get() == 0):
2274  RUNstatus.set(1)
2275  if AWGSync.get() == 0:
2276  session.flush()
2277  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2278  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2279  BAWGEnab()
2280  if not session.continuous:
2281  session.start(0)
2282  time.sleep(0.02) # wait awhile here for some reason
2283  elif session.continuous:
2284  session.end()
2285  session.flush()
2286  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2287  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2288 
2300  BAWGEnab()
2301  else:
2302  contloop = 0
2303  discontloop = 1
2304  if session.continuous:
2305  session.end() # end continuous session mode
2306 
2307  # UpdateTimeScreen() # Always Update
2308  if TIMEdiv >= 100:
2309  First_Slow_sweep = 0
2310  else:
2311  First_Slow_sweep = 1
2312 #$ Start running Ohmmeter tool
2314  global session, AWGSync
2315 
2316  AWGSync.set(1)
2317  if AWGSync.get() == 0:
2318  session.flush()
2319  if not session.continuous:
2320  session.start(0)
2321  time.sleep(0.02) # wait awhile here for some reason
2322  elif session.continuous:
2323  session.end()
2324  session.flush()
2325  else:
2326  contloop = 0
2327  discontloop = 1
2328  if session.continuous:
2329  session.end() # end continuous session mode
2330 
2331 def BStartIA():
2332  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne
2333 
2334  try:
2335  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
2336  except:
2337  AWGAFreqEntry.delete(0,"end")
2338  AWGAFreqEntry.insert(0, AWGAFreqvalue)
2339  if FWRevOne > 2.16:
2340  if AWGAFreqvalue > 20000.0:
2341  Two_X_Sample.set(1)
2342  else:
2343  Two_X_Sample.set(0)
2344  SetADC_Mux()
2345  IASourceSet()
2346  BStart()
2347 
2349  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode
2350 
2351  if IASource.get() == 1:
2352  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
2353  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
2354  AWGAMode.set(2) # Set AWG A to Hi-Z
2355  else:
2356  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
2357  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
2358  AWGAMode.set(0) # Set AWG A to SVMI
2359  if AWGBIOMode.get() == 0: # if not in split I/O mode
2360  AWGBMode.set(2) # Set AWG B to Hi-Z
2361 
2362 def BStop():
2363  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
2364  global CHA, CHB, contloop, discontloop
2365 
2366  if (RUNstatus.get() == 1):
2367  RUNstatus.set(0)
2368  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2369  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2370  if AWGSync.get() == 0: # running in continuous mode
2371  CHA.constant(0.0)
2372  CHB.constant(0.0)
2373  # print "Stoping continuous mode"
2374  # session.cancel() # cancel continuous session mode while paused
2375  if session.continuous:
2376  #print "Is Continuous? ", session.continuous
2377  session.end()
2378  #time.sleep(0.02)
2379  #print "Is Continuous? ", session.continuous
2380  else:
2381  contloop = 0
2382  discontloop = 1
2383  session.cancel()
2384  elif (RUNstatus.get() == 2):
2385  RUNstatus.set(3)
2386  elif (RUNstatus.get() == 3):
2387  RUNstatus.set(3)
2388  elif (RUNstatus.get() == 4):
2389  RUNstatus.set(3)
2390  if TimeDisp.get() > 0:
2391  UpdateTimeScreen() # Always Update screens as necessary
2392  if XYDisp.get() > 0:
2393  UpdateXYScreen()
2394  if FreqDisp.get() > 0:
2396  if IADisp.get() > 0:
2397  UpdateIAScreen()
2398 
2399 def BPower():
2400  global RUNstatus, PowerStatus, devx, PwrBt
2401 
2402  if (RUNstatus.get() == 1):
2403  BStop()
2404  if PowerStatus == 1:
2405  PowerStatus = 0
2406  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
2407  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
2408  else:
2409  PowerStatus = 1
2410  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2411  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2412 
2413 def BTime():
2414  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne
2415 
2416  try: # get time scale in mSec/div
2417  TIMEdiv = float(eval(TMsb.get()))
2418  if TIMEdiv < 0.0002:
2419  TIMEdiv = 0.01
2420  TMsb.delete(0,"end")
2421  TMsb.insert(0,TIMEdiv)
2422  except:
2423  TIMEdiv = 0.5
2424  TMsb.delete(0,"end")
2425  TMsb.insert(0,TIMEdiv)
2426  # Switch to 2X sampleling if time scale small enough and not runing ETS
2427  if ETSDisp.get() == 0:
2428  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
2429  if FWRevOne > 2.16:
2430  if Samples_per_div < 20.0:
2431  Two_X_Sample.set(1)
2432  else:
2433  Two_X_Sample.set(0)
2434  SetADC_Mux()
2435  #
2436  if RUNstatus.get() == 2: # Restart if running
2437  RUNstatus.set(4)
2438 
2439  UpdateTimeTrace() # Always Update
2440 
2442  global CHAsb
2443 
2444  try:
2445  CH1vpdvLevel = float(eval(CHAsb.get()))
2446  except:
2447  CHAsb.delete(0,END)
2448  CHAsb.insert(0, CH1vpdvLevel)
2449  UpdateTimeTrace() # Always Update
2450 
2452  global CHAIsb
2453 
2454  try:
2455  CH1ipdvLevel = float(eval(CHAIsb.get()))
2456  except:
2457  CHAIsb.delete(0,END)
2458  CHAIsb.insert(0, CH1ipdvLevel)
2459  UpdateTimeTrace() # Always Update
2460 
2462  global CHBsb
2463 
2464  try:
2465  CH2vpdvLevel = float(eval(CHBsb.get()))
2466  except:
2467  CHBsb.delete(0,END)
2468  CHBsb.insert(0, CH2vpdvLevel)
2469  UpdateTimeTrace() # Always Update
2470 
2472  global CHBIsb
2473 
2474  try:
2475  CH2ipdvLevel = float(eval(CHBIsb.get()))
2476  except:
2477  CHBIsb.delete(0,END)
2478  CHBIsb.insert(0, CH2ipdvLevel)
2479  UpdateTimeTrace() # Always Update
2480 
2481 def BOffsetA(event):
2482  global CHAOffset, CHAVPosEntry
2483 
2484  try:
2485  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
2486  except:
2487  CHAVPosEntry.delete(0,END)
2488  CHAVPosEntry.insert(0, CHAOffset)
2489  # set new offset level
2490  UpdateTimeTrace() # Always Update
2491 
2492 def BIOffsetA(event):
2493  global CHAIOffset, CHAIPosEntry
2494 
2495  try:
2496  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
2497  except:
2498  CHAIPosEntry.delete(0,END)
2499  CHAIPosEntry.insert(0, CHAIOffset)
2500  # set new offset level
2501  UpdateTimeTrace() # Always Update
2502 
2503 def BOffsetB(event):
2504  global CHBOffset, CHBVPosEntry
2505 
2506  try:
2507  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
2508  except:
2509  CHBVPosEntry.delete(0,END)
2510  CHBVPosEntry.insert(0, CHBOffset)
2511  # set new offset level
2512  UpdateTimeTrace() # Always Update
2513 
2514 def BIOffsetB(event):
2515  global CHBIOffset, CHBIPosEntry
2516 
2517  try:
2518  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
2519  except:
2520  CHBIPosEntry.delete(0,END)
2521  CHBIPosEntry.insert(0, CHBIOffset)
2522  # set new offset level
2523  UpdateTimeTrace() # Always Update
2524 
2526  global TimeDisp, ckb1
2527  if TimeDisp.get() == 1:
2528  ckb1.config(style="Enab.TCheckbutton")
2529  else:
2530  ckb1.config(style="Disab.TCheckbutton")
2531 #
2533  global XYDisp, ckb2
2534  if XYDisp.get() == 1:
2535  ckb2.config(style="Enab.TCheckbutton")
2536  else:
2537  ckb2.config(style="Disab.TCheckbutton")
2538 #
2540  global FreqDisp, ckb3
2541  if FreqDisp.get() == 1:
2542  ckb3.config(style="Enab.TCheckbutton")
2543  else:
2544  ckb3.config(style="Disab.TCheckbutton")
2545 #
2547  global BodeDisp, ckb5, AWGSync
2548  if BodeDisp.get() == 1:
2549  AWGSync.set(1)
2550  ckb5.config(style="Enab.TCheckbutton")
2551  else:
2552  ckb5.config(style="Disab.TCheckbutton")
2553 #
2555  global IADisp, ckb4
2556  if IADisp.get() == 1:
2557  ckb4.config(style="Enab.TCheckbutton")
2558  else:
2559  ckb4.config(style="Disab.TCheckbutton")
2560 #
2562  global OhmDisp, ckb6
2563  if OhmDisp.get() == 1:
2564  ckb6.config(style="Enab.TCheckbutton")
2565  else:
2566  ckb6.config(style="Disab.TCheckbutton")
2567 #
2569  global ETSDisp, enb1
2570  if ETSDisp.get() == 1:
2571  enb1.config(style="Enab.TCheckbutton")
2572  else:
2573  try:
2574  enb1.config(style="Disab.TCheckbutton")
2575  except:
2576  donothing()
2577 # ========================= Main routine ====================================
2578 
2580  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
2581  global IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
2582  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
2583  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
2584  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
2585  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
2586  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2587  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2588  global SV1, SI1, SV2, SI2, SVA_B
2589  global FregPoint, FBins, FStep
2590  # Analog Mux channel measurement variables
2591  global TRACEresetTime, TRACEmodeTime
2592  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
2593  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
2594  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
2595  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
2596  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
2597  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
2598 
2599  while (True): # Main loop
2600  # RUNstatus = 1 : Open Acquisition
2601  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
2602  if TimeDisp.get() > 0 or XYDisp.get() > 0:
2603  if MuxScreenStatus.get() == 0:
2604  MuxChan = -1
2605  Analog_Time_In()
2606  else:
2607  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
2608  AWGAIOMode.set(1)
2609  AWGBIOMode.set(1)
2610  ShowC1_V.set(0) # force A voltage trace off
2611  ShowC2_V.set(0) # force B voltage trace off
2612  if HWRevOne == "D" :
2613  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
2614  AWGBMode.set(2)
2615  if AWGBIOMode.get() == 0: # if not in split I/O mode
2616  ShowC2_I.set(0) # no need to show CH-B current
2617  if MuxEnb.get() == 1:
2618  PIO2 = 0x51
2619  else:
2620  PIO2 = 0x50
2621  if MuxSync.get() == 0:
2622  PIO3 = 0x51
2623  PIO3x = 0x50
2624  else:
2625  PIO3 = 0x50
2626  PIO3x = 0x51
2627  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
2628  TRACEresetTime = True # Clear the memory for averaging
2629  elif TRACEmodeTime.get() == 1:
2630  if TRACEresetTime == True:
2631  TRACEresetTime = False
2632  # Save previous trace in memory for average trace
2633  VmemoryMuxA = VBuffMA
2634  VmemoryMuxB = VBuffMB
2635  VmemoryMuxC = VBuffMC
2636  ImemoryMuxD = VBuffMD
2637  if Show_CBA.get() == 1:
2638  MuxChan = 0
2639  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2640  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2641  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
2642  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
2643  time.sleep(0.002)
2644  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2645  Analog_Time_In()
2646  # Average mode 1, add difference / TRACEaverage to arrayif :
2647  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2648  try:
2649  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
2650  except:
2651  # buffer size mismatch so reset memory buffers
2652  VmemoryMuxA = VBuffMA
2653  if Show_CBB.get() == 1:
2654  MuxChan = 1
2655  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2656  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2657  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2658  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2659  time.sleep(0.002)
2660  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
2661  Analog_Time_In()
2662  # Average mode 1, add difference / TRACEaverage to arrayif :
2663  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2664  try:
2665  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
2666  except:
2667  # buffer size mismatch so reset memory buffers
2668  VmemoryMuxB = VBuffMB
2669  if Show_CBC.get() == 1:
2670  MuxChan = 2
2671  if DualMuxMode.get() == 1:
2672  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2673  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2674  else:
2675  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2676  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
2677  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2678  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2679  time.sleep(0.002)
2680  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2681  Analog_Time_In()
2682  # Average mode 1, add difference / TRACEaverage to arrayif :
2683  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2684  try:
2685  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
2686  except:
2687  # buffer size mismatch so reset memory buffers
2688  VmemoryMuxC = VBuffMC
2689  if Show_CBD.get() == 1:
2690  MuxChan = 3
2691  if DualMuxMode.get() == 1:
2692  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
2693  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
2694  else:
2695  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
2696  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
2697  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
2698  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
2699  time.sleep(0.002)
2700  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
2701  Analog_Time_In()
2702  # Average mode 1, add difference / TRACEaverage to arrayif :
2703  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
2704  try:
2705  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
2706  except:
2707  # buffer size mismatch so reset memory buffers
2708  VmemoryMuxD = VBuffMD
2709  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:
2710  Analog_Time_In()
2711  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
2712  if IADisp.get() > 0 or BodeDisp.get() > 0:
2713  CutDC.set(1) # remove DC portion of waveform
2714  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
2715  if BodeDisp.get() > 0:
2716  if LoopNum.get() <= len(FStep):
2717  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
2718  if FregPoint < 100.0:
2719  SMPfft = 16384
2720  elif FregPoint < 500.0:
2721  SMPfft = 8192
2722  elif FregPoint < 2000.0:
2723  SMPfft = 4096
2724  else:
2725  SMPfft = 2048
2726  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
2727  SMPfft = SMPfft * 2
2728 
2729  Analog_Freq_In()
2730  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
2731  Ohm_Analog_In()
2732  root.update_idletasks()
2733  root.update()
2734 
2736  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
2737  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
2738 
2739 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
2740  try:
2741  InOffA = float(eval(CHAVOffsetEntry.get()))
2742  except:
2743  CHAVOffsetEntry.delete(0,END)
2744  CHAVOffsetEntry.insert(0, InOffA)
2745  try:
2746  InGainA = float(eval(CHAVGainEntry.get()))
2747  except:
2748  CHAVGainEntry.delete(0,END)
2749  CHAVGainEntry.insert(0, InGainA)
2750  try:
2751  InOffB = float(eval(CHBVOffsetEntry.get()))
2752  except:
2753  CHBVOffsetEntry.delete(0,END)
2754  CHBVOffsetEntry.insert(0, InOffB)
2755  try:
2756  InGainB = float(eval(CHBVGainEntry.get()))
2757  except:
2758  CHBVGainEntry.delete(0,END)
2759  CHBVGainEntry.insert(0, InGainB)
2760  try:
2761  CurOffA = float(CHAIOffsetEntry.get())
2762  except:
2763  CurOffA = 0.0
2764  try:
2765  CurOffB = float(CHBIOffsetEntry.get())
2766  except:
2767  CurOffB = 0.0
2768  try:
2769  CurGainA = float(CHAIGainEntry.get())
2770  except:
2771  CurGainA = 1.0
2772  try:
2773  CurGainB = float(CHBIGainEntry.get())
2774  except:
2775  CurGainB = 1.0
2776  try:
2777  chatestv = float(eval(CHATestVEntry.get()))
2778  if chatestv > 5.0:
2779  chatestv = 5.0
2780  CHATestVEntry.delete(0,END)
2781  CHATestVEntry.insert(0, chatestv)
2782  except:
2783  CHATestVEntry.delete(0,END)
2784  CHATestVEntry.insert(0, chatestv)
2785  try:
2786  chatestr = float(eval(CHATestREntry.get()))
2787  except:
2788  CHATestREntry.delete(0,END)
2789  CHATestREntry.insert(0, chatestr)
2790  #
2791  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
2792  RIN = 1000000 # nominal ALM1000 input resistance is 1 Mohm
2793  # set A and B channels
2794  AWGAMode.set(0) # Set AWG A to SVMI
2795  AWGAShape.set(0) # DC
2796  AWGBMode.set(2) # Set AWG B to Hi-Z
2797  AWGAOffsetEntry.delete(0,"end")
2798  AWGAOffsetEntry.insert(0, chatestv)
2799  if RMode.get() == 0:
2800  AWGBTerm.set(0)
2801  else:
2802  AWGBTerm.set(1)
2803  #
2804  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
2805  if discontloop > 0:
2806  session.flush()
2807  else:
2808  discontloop = 1
2809  time.sleep(0.01)
2810  BAWGEnab()
2811  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
2812  # time.sleep(1000.0/SHOWsamples)
2813  else: # running in continuous mode
2814  if session.continuous:
2815  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
2816  #
2817  # get_samples returns a list of values for voltage [0] and current [1]
2818  for index in range(200): # calculate average
2819  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
2820  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
2821  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
2822  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
2823 
2824  DCVA0 = DCVA0 / 200.0 # calculate average
2825  DCVB0 = DCVB0 / 200.0 # calculate average
2826  DCIA0 = DCIA0 / 200.0 # calculate average
2827  DCIB0 = DCIB0 / 200.0 # calculate average
2828  DCVA0 = (DCVA0 - InOffA) * InGainA
2829  DCVB0 = (DCVB0 - InOffB) * InGainB
2830  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
2831  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
2832  if RMode.get() == 0: # external resistor
2833  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
2834  DCR = (DCM * RIN) / (RIN - DCM) # correct for channel B input resistance
2835  else: # use internal 50 ohm resistor
2836  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
2837  if DCR < 1000:
2838  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
2839  else:
2840  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
2841  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
2842  OhmA0.config(text = OhmString) # change displayed value
2843  OhmA1.config(text = IAString) # change displayed value
2844 #
2845  time.sleep(0.1)
2846  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
2847 
2850  global TIMEdiv, TMsb
2851  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
2852  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
2853  global InOffA, InGainA, InOffB, InGainB
2854  global CurOffA, CurOffB, CurGainA, CurGainB
2855 
2856  # get time scale
2857  try:
2858  TIMEdiv = eval(TMsb.get())
2859  except:
2860  TIMEdiv = 0.5
2861  TMsb.delete(0,"end")
2862  TMsb.insert(0,TIMEdiv)
2863  if TIMEdiv < 0.0002:
2864  TIMEdiv = 0.01
2865  #
2866 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
2867  try:
2868  InOffA = float(eval(CHAVOffsetEntry.get()))
2869  except:
2870  CHAVOffsetEntry.delete(0,END)
2871  CHAVOffsetEntry.insert(0, InOffA)
2872  try:
2873  InGainA = float(eval(CHAVGainEntry.get()))
2874  except:
2875  CHAVGainEntry.delete(0,END)
2876  CHAVGainEntry.insert(0, InGainA)
2877  try:
2878  InOffB = float(eval(CHBVOffsetEntry.get()))
2879  except:
2880  CHBVOffsetEntry.delete(0,END)
2881  CHBVOffsetEntry.insert(0, InOffB)
2882  try:
2883  InGainB = float(eval(CHBVGainEntry.get()))
2884  except:
2885  CHBVGainEntry.delete(0,END)
2886  CHBVGainEntry.insert(0, InGainB)
2887  try:
2888  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
2889  except:
2890  CurOffA = 0.0
2891  try:
2892  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
2893  except:
2894  CurOffB = 0.0
2895  try:
2896  CurGainA = float(CHAIGainEntry.get())
2897  except:
2898  CurGainA = 1.0
2899  try:
2900  CurGainB = float(CHBIGainEntry.get())
2901  except:
2902  CurGainB = 1.0
2903 # Dedecide which Fast or Slow sweep routine to call
2904  if TIMEdiv > 200:
2905  #First_Slow_sweep = 1
2907  else:
2909 #
2911  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
2912  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2913  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
2914  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
2915  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
2916  global CHA, CHB, session, devx, discontloop, contloop
2917  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, ShiftPointer
2918  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
2919  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered
2920  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
2921  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
2922  global SCREENrefresh, DCrefresh
2923  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2924  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2925  global SV1, SI1, SV2, SI2, SVA_B
2926  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2927  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
2928  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2929  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
2930  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
2931  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2932  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2933  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2934  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2935  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
2936  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
2937  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
2938  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
2939  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
2940  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
2941  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
2942  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
2943  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
2944  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
2945  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
2946  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
2947 
2948  # Starting acquisition
2949  DCVA0 = DCVB0 = DCIA0 = DCIB0= 0.0 # initalize measurment variable
2950  # Get A0 and B0 data
2951  NumSamples = 2 # int(SAMPLErate/TIMEdiv)
2952  if First_Slow_sweep == 0:
2953  BufferLen = TIMEdiv*12.0
2954 
2958  VBuffA = numpy.ones(BufferLen)
2959  VBuffB = numpy.ones(BufferLen)
2960  IBuffA = numpy.ones(BufferLen)
2961  IBuffB = numpy.ones(BufferLen)
2962  First_Slow_sweep = 1
2963  ShiftPointer = 0
2964  #
2965  # print(len(VBuffA))
2966  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
2967  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
2968  if discontloop > 0:
2969  session.flush()
2970  else:
2971  discontloop = 1
2972  #time.sleep(0.01)
2973  # print "just before awg enable"
2974  BAWGEnab()
2975  # print "just before get samples"
2976  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
2977  # waite to finish then return to open termination
2978  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
2979  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
2980  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
2981  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
2982  # time.sleep(1000.0/SHOWsamples)
2983  else: # running in continuous mode
2984  if session.continuous:
2985  if MuxScreenStatus.get() > 0:
2986  devx.flush(-1, True)
2987  DummySamples = NumSamples*2
2988  if DummySamples < 10000:
2989  DummySamples = 10000
2990  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
2991  ADsignal1 = devx.read(NumSamples, -1, True) # get samples for both channel A and B
2992  #
2993  else:
2994  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
2995  # time.sleep(0.01)
2996  # waite to finish then return to open termination
2997  #devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
2998  #devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
2999  #devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3000  #devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3001 #
3002  #print len(ADsignal1)
3003  # get_samples returns a list of values for voltage [0] and current [1]
3004  for index in range(NumSamples): # calculate average
3005  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
3006  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
3007  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
3008  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
3009  DCVA0 = DCVA0/(NumSamples) # calculate V average
3010  DCVB0 = DCVB0/(NumSamples) # calculate V average
3011  DCVA0 = (DCVA0 - InOffA) * InGainA
3012  DCVB0 = (DCVB0 - InOffB) * InGainB
3013  DCIA0 = DCIA0/(NumSamples) # calculate I average
3014  DCIB0 = DCIB0/(NumSamples) # calculate I average
3015  DCIA0 = DCIA0 * 1000 # convert to mA
3016  DCIB0 = DCIB0 * 1000 # convert to mA
3017  DCIA0 = (DCIA0 - CurOffA) * CurGainA
3018  DCIB0 = (DCIB0 - CurOffB) * CurGainB
3019 
3026  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
3027  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
3028  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
3029  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
3030 # ShiftPointer = ShiftPointer + 10
3031 # Calculate measurement values
3032  DCV1 = numpy.mean(VBuffA)
3033  DCV2 = numpy.mean(VBuffB)
3034  DCI1 = numpy.mean(IBuffA)
3035  DCI2 = numpy.mean(IBuffB)
3036 # find min and max values
3037  MinV1 = numpy.amin(VBuffA)
3038  MaxV1 = numpy.amax(VBuffA)
3039  MinV2 = numpy.amin(VBuffB)
3040  MaxV2 = numpy.amax(VBuffB)
3041  MinI1 = numpy.amin(IBuffA)
3042  MaxI1 = numpy.amax(IBuffA)
3043  MinI2 = numpy.amin(IBuffB)
3044  MaxI2 = numpy.amax(IBuffB)
3045 # RMS value = square root of average of the data record squared
3046  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA)))
3047  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA)))
3048  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB)))
3049  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB)))
3050  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA-VBuffB)))
3051 #
3052  if TimeDisp.get() > 0:
3053  UpdateTimeAll() # Update Data, trace and time screen
3054  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3055  UpdateXYAll() # Update Data, trace and XY screen
3056  if MeasureStatus.get() > 0:
3058  # RUNstatus = 3: Stop
3059  # RUNstatus = 4: Stop and restart
3060  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
3061  if RUNstatus.get() == 3:
3062  RUNstatus.set(0)
3063  if RUNstatus.get() == 4:
3064  RUNstatus.set(1)
3065  if TimeDisp.get() > 0:
3067  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3068  UpdateXYScreen()
3069  # Update tasks and screens by TKinter
3070  # update screens
3071 #
3072 
3075  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
3076  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3077  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
3078  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
3079  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
3080  global CHA, CHB, session, devx, discontloop, contloop
3081  global TRACES, TRACESread, TRACEsize
3082  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
3083  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered
3084  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
3085  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
3086  global SCREENrefresh, DCrefresh
3087  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3088  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3089  global SV1, SI1, SV2, SI2, SVA_B
3090  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3091  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
3092  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
3093  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
3094  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
3095  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3096  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3097  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3098  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3099  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
3100  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
3101  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
3102  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
3103  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
3104  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
3105  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3106  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3107  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3108  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3109  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3110  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3111 
3112  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3113  TRACEresetTime = True # Clear the memory for averaging
3114  elif TRACEmodeTime.get() == 1:
3115  if TRACEresetTime == True:
3116  TRACEresetTime = False
3117  # Save previous trace in memory for average trace
3118  VmemoryA = VBuffA
3119  VmemoryB = VBuffB
3120  ImemoryA = IBuffA
3121  ImemoryB = IBuffB
3122 
3123  try:
3124  HoldOff = float(eval(HoldOffentry.get()))
3125  if HoldOff < 0:
3126  HoldOff = 0
3127  HoldOffentry.delete(0,END)
3128  HoldOffentry.insert(0, HoldOff)
3129  except:
3130  HoldOffentry.delete(0,END)
3131  HoldOffentry.insert(0, HoldOff)
3132 #
3133  try:
3134  HozPoss = float(eval(HozPossentry.get()))
3135  except:
3136  HozPossentry.delete(0,END)
3137  HozPossentry.insert(0, HozPoss)
3138 
3139  hldn = int(HoldOff * SAMPLErate/1000 )
3140  hozpos = int(HozPoss * SAMPLErate/1000 )
3141  if hozpos < 0:
3142  hozpos = 0
3143  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
3144  onescreen = int(twoscreens/2)
3145  if hldn+hozpos > MaxSamples-twoscreens:
3146  hldn = MaxSamples-twoscreens-hozpos
3147  HoldOffentry.delete(0,END)
3148  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
3149  if ETSDisp.get() > 0:
3150  if TIMEdiv > 0.2:
3151  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
3152  else:
3153  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
3154  if (MaxETSrecord*100) > MaxSamples:
3155  MaxETSrecord = MaxSamples / 100
3156  try:
3157  DivX = float(eval(DivXEntry.get()))
3158  if DivX < 2:
3159  DivX = 2
3160  if DivX > 75:
3161  DivX = 75
3162  DivXEntry.delete(0,END)
3163  DivXEntry.insert(0, DivX)
3164  except:
3165  DivXEntry.delete(0,END)
3166  DivXEntry.insert(0, DivX)
3167  FOff = 25
3168  MulX = (DivX*SAMPLErate)/(100*FOff)
3169  while MulX > MaxETSrecord:
3170  FOff = FOff + 5
3171  MulX = (DivX*SAMPLErate)/(100*FOff)
3172  FOff = 0 - FOff
3173  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
3174  MulXEntry.config(text = SRstring) # change displayed value
3175  SRstring = "Offset = " + str(FOff) + " samples"
3176  FOffEntry.config(text = SRstring) # change displayed value
3177  SHOWsamples = int(MulX * 100)
3178  else:
3179  SHOWsamples = twoscreens + hldn + hozpos
3180  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
3181  SHOWsamples = MaxSamples
3182  if SHOWsamples < MinSamples: # or a Min of 1000 samples
3183  SHOWsamples = MinSamples
3184  if hozpos >= 0:
3185  TRIGGERsample = hldn
3186  else:
3187  TRIGGERsample = abs(hozpos)
3188  TRIGGERsample = TRIGGERsample + hozpos #
3189 # Starting acquisition
3190  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3191  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3192  if discontloop > 0:
3193  session.flush()
3194  else:
3195  discontloop = 1
3196  time.sleep(0.01)
3197  # print "just before awg enable"
3198  BAWGEnab()
3199  # print "just before get samples"
3200  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3201  # waite to finish then return to open termination
3202  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3203  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3204  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3205  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3206  # time.sleep(1000.0/SHOWsamples)
3207  else: # running in continuous mode
3208  if session.continuous:
3209  if MuxScreenStatus.get() > 0:
3210  devx.flush(-1, True)
3211  DummySamples = SHOWsamples*2
3212  if DummySamples < 20000:
3213  DummySamples = 20000
3214  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
3215  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
3216  #
3217  else:
3218  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
3219  # time.sleep(0.01)
3220  # waite to finish then return to open termination
3221  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3222  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3223  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3224  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3225  #
3226  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
3227  if ADC_Mux_Mode.get() == 0: # VA and VB
3228  VBuffA = [] # Clear the V Buff array for trace A
3229  VBuffB = [] # Clear the V Buff array for trace B
3230  elif ADC_Mux_Mode.get() == 1: # IA and IB
3231  IBuffA = [] # Clear the I Buff array for trace A
3232  IBuffB = [] # Clear the I Buff array for trace B
3233  elif ADC_Mux_Mode.get() == 4: # VA and IA
3234  VBuffA = [] # Clear the V Buff array for trace A
3235  IBuffA = [] # Clear the I Buff array for trace A
3236  elif ADC_Mux_Mode.get() == 5: # VB and IB
3237  VBuffB = [] # Clear the V Buff array for trace B
3238  IBuffB = [] # Clear the I Buff array for trace B
3239  else:
3240  VBuffA = [] # Clear the V Buff array for trace A
3241  IBuffA = [] # Clear the I Buff array for trace A
3242  VBuffB = [] # Clear the V Buff array for trace B
3243  IBuffB = [] # Clear the I Buff array for trace B
3244  increment = 1
3245  # SAMPLErate = 200000 #AWGSAMPLErate
3246  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
3247  increment = 2
3248  SAMPLErate = int(AWGSAMPLErate/increment)
3249  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
3250  increment = 4
3251  SAMPLErate = int(AWGSAMPLErate/increment)
3252  index = 0
3253  if SHOWsamples != len(ADsignal1):
3254  SHOWsamples = len(ADsignal1)
3255  while index < SHOWsamples: # build arrays and decimate if needed
3256  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
3257  if ADC_Mux_Mode.get() == 0: # VA and VB
3258  VBuffA.append(ADsignal1[index][0][0])
3259  VBuffA.append(ADsignal1[index][1][1])
3260  VBuffB.append(ADsignal1[index][0][1])
3261  VBuffB.append(ADsignal1[index][1][0])
3262  if Alternate_Sweep_Mode.get() == 0:
3263  IBuffA.append(0.0) # fill as a place holder
3264  IBuffA.append(0.0) # fill as a place holder
3265  IBuffB.append(0.0) # fill as a place holder
3266  IBuffB.append(0.0) # fill as a place holder
3267  elif ADC_Mux_Mode.get() == 1: # IA and IB
3268  IBuffA.append(ADsignal1[index][0][1])
3269  IBuffA.append(ADsignal1[index][1][0])
3270  IBuffB.append(ADsignal1[index][0][0])
3271  IBuffB.append(ADsignal1[index][1][1])
3272  if Alternate_Sweep_Mode.get() == 0:
3273  VBuffA.append(0.0) # fill as a place holder
3274  VBuffA.append(0.0) # fill as a place holder
3275  VBuffB.append(0.0) # fill as a place holder
3276  VBuffB.append(0.0) # fill as a place holder
3277  elif ADC_Mux_Mode.get() == 2: # VA and IB
3278  VBuffA.append((ADsignal1[index][0][1])/1024.0)
3279  VBuffA.append((ADsignal1[index][1][0])/1024.0)
3280  #
3281  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
3282  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
3283  #
3284  if Alternate_Sweep_Mode.get() == 0:
3285  VBuffB.append(0.0) # fill as a place holder
3286  VBuffB.append(0.0) # fill as a place holder
3287  IBuffA.append(0.0) # fill as a place holder
3288  IBuffA.append(0.0) # fill as a place holder
3289  elif ADC_Mux_Mode.get() == 3: # VB and IA
3290  VBuffB.append((ADsignal1[index][0][0])/1024.0)
3291  VBuffB.append((ADsignal1[index][1][1])/1024.0)
3292  #
3293  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
3294  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
3295  #
3296  if Alternate_Sweep_Mode.get() == 0:
3297  VBuffA.append(0.0) # fill as a place holder
3298  VBuffA.append(0.0) # fill as a place holder
3299  IBuffB.append(0.0) # fill as a place holder
3300  IBuffB.append(0.0) # fill as a place holder
3301  elif ADC_Mux_Mode.get() == 4: # VA and IA
3302  VBuffA.append(ADsignal1[index][0][0])
3303  VBuffA.append(ADsignal1[index][1][1])
3304  IBuffA.append(ADsignal1[index][0][1])
3305  IBuffA.append(ADsignal1[index][1][0])
3306  if Alternate_Sweep_Mode.get() == 0:
3307  VBuffB.append(0.0) # fill as a place holder
3308  VBuffB.append(0.0) # fill as a place holder
3309  IBuffB.append(0.0) # fill as a place holder
3310  IBuffB.append(0.0) # fill as a place holder
3311  elif ADC_Mux_Mode.get() == 5: # VB and IB
3312  VBuffB.append(ADsignal1[index][0][1])
3313  VBuffB.append(ADsignal1[index][1][0])
3314  IBuffB.append(ADsignal1[index][0][0])
3315  IBuffB.append(ADsignal1[index][1][1])
3316  if Alternate_Sweep_Mode.get() == 0:
3317  VBuffA.append(0.0) # fill as a place holder
3318  VBuffA.append(0.0) # fill as a place holder
3319  IBuffA.append(0.0) # fill as a place holder
3320  IBuffA.append(0.0) # fill as a place holder
3321  else:
3322  VBuffA.append(ADsignal1[index][0][0])
3323  IBuffA.append(ADsignal1[index][0][1])
3324  VBuffB.append(ADsignal1[index][1][0])
3325  IBuffB.append(ADsignal1[index][1][1])
3326  index = index + increment
3327 #
3328  SHOWsamples = len(VBuffA)
3329  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
3330  if ADC_Mux_Mode.get() == 0: # VA and VB
3331  VBuffA = numpy.array(VBuffA)
3332  VBuffB = numpy.array(VBuffB)
3333  VBuffA = (VBuffA - InOffA) * InGainA
3334  VBuffB = (VBuffB - InOffB) * InGainB
3335  ADC_Mux_Mode.set(1) # switch mode
3336  Last_ADC_Mux_Mode = 0
3337  elif ADC_Mux_Mode.get() == 1: # IA and IB
3338  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3339  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3340  IBuffA = (IBuffA - CurOffA) * CurGainA
3341  IBuffB = (IBuffB - CurOffB) * CurGainB
3342  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
3343  elif ADC_Mux_Mode.get() == 4: # VA and IA
3344  VBuffA = numpy.array(VBuffA)
3345  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3346  IBuffA = (IBuffA - CurOffA) * CurGainA
3347  VBuffA = (VBuffA - InOffA) * InGainA
3348  ADC_Mux_Mode.set(1) # switch mode
3349  Last_ADC_Mux_Mode = 4
3350  elif ADC_Mux_Mode.get() == 5: # VB and IB
3351  VBuffB = numpy.array(VBuffB)
3352  VBuffB = (VBuffB - InOffB) * InGainB
3353  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3354  IBuffB = (IBuffB - CurOffB) * CurGainB
3355  ADC_Mux_Mode.set(1) # switch mode
3356  Last_ADC_Mux_Mode = 5
3357  SetADC_Mux()
3358  #
3359  else:
3360  VBuffA = numpy.array(VBuffA)
3361  VBuffB = numpy.array(VBuffB)
3362  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
3363  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
3364  VBuffA = (VBuffA - InOffA) * InGainA
3365  VBuffB = (VBuffB - InOffB) * InGainB
3366  IBuffA = (IBuffA - CurOffA) * CurGainA
3367  IBuffB = (IBuffB - CurOffB) * CurGainB
3368  TRACESread = 2
3369 # temp ETS calculations
3370  if ETSDisp.get() > 0:
3371  baseFreq = SAMPLErate/DivX
3372  #
3373  VAets = []
3374  VBets = []
3375  IAets = []
3376  IBets = []
3377  index = 0
3378  try:
3379  FMul = float(eval(FminEntry.get()))
3380  if FMul < 1:
3381  FMul = 1
3382  FMulXEntry.delete(0,END)
3383  FMulXEntry.insert(0, int(FMul))
3384  if FMul > 75:
3385  FMul = 75
3386  FMulXEntry.delete(0,END)
3387  FMulXEntry.insert(0, int(FMul))
3388  except:
3389  FMulXEntry.delete(0,END)
3390  FMulXEntry.insert(0, int(FMul))
3391  Fmin = baseFreq * FMul
3392  FminE = float(SAMPLErate + FOff)
3393  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
3394  # length of record set my Multiplcation factor
3395  tot_cycles = int((MulX*100)/Samples_Cycle)
3396  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
3397  if tot_cycles > SHOWsamples:
3398  tot_cycles = SHOWsamples-1
3399  # now sort RT data into ETS sample buffers
3400  while index < SHOWsamples:
3401  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
3402  IndexValue = int(tot_cycles * Dpart)
3403  if IndexValue > SHOWsamples:
3404  IndexValue = SHOWsamples-1
3405  if IndexValue > tot_cycles:
3406  IndexValue = tot_cycles
3407  if ETSDir.get() == 0:
3408  VAets.append(VBuffA[IndexValue])
3409  VBets.append(VBuffB[IndexValue])
3410  IAets.append(IBuffA[IndexValue])
3411  IBets.append(IBuffB[IndexValue])
3412  else:
3413  VAets.append(VBuffA[tot_cycles-IndexValue])
3414  VBets.append(VBuffB[tot_cycles-IndexValue])
3415  IAets.append(IBuffA[tot_cycles-IndexValue])
3416  IBets.append(IBuffB[tot_cycles-IndexValue])
3417  index = index + 1
3418  SHiftFact = 5
3419  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
3420  VBuffA = VAets
3421  VBuffB = VBets
3422  IBuffA = IAets
3423  IBuffB = IBets
3424  VBuffA = numpy.array(VBuffA)
3425  VBuffB = numpy.array(VBuffB)
3426  IBuffA = numpy.array(IBuffA)
3427  IBuffB = numpy.array(IBuffB)
3428  try:
3429  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
3430  except:
3431  TimeCorrection = SHiftFact
3432  if ETSDir.get() == 0:
3433  VBuffB = numpy.roll(VBuffB, TimeCorrection)
3434  IBuffB = numpy.roll(IBuffB, TimeCorrection)
3435  else:
3436  VBuffB = numpy.roll(VBuffB, TimeCorrection)
3437  IBuffB = numpy.roll(IBuffB, TimeCorrection)
3438  SHOWsamples = twoscreens + hldn + hozpos
3439 # Check if Input channel RC high pass compensation checked
3440  if CHA_RC_HP.get() == 1:
3441  try:
3442  TC1A = float(cha_TC1Entry.get())
3443  if TC1A < 0:
3444  TC1A = 0
3445  cha_TC1Entry.delete(0,END)
3446  cha_TC1Entry.insert(0, TC1A)
3447  except:
3448  TC1A = CHA_TC1.get()
3449  try:
3450  TC2A = float(cha_TC2Entry.get())
3451  if TC2A < 0:
3452  TC2A = 0
3453  cha_TC2Entry.delete(0,END)
3454  cha_TC2Entry.insert(0, TC2A)
3455  except:
3456  TC2A = CHA_TC2.get()
3457  #
3458  try:
3459  Gain1A = float(cha_A1Entry.get())
3460  except:
3461  Gain1A = CHA_A1.get()
3462  try:
3463  Gain2A = float(cha_A2Entry.get())
3464  except:
3465  Gain2A = CHA_A2.get()
3466  #
3467  if len(VBuffA) > 4:
3468  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
3469  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
3470  if CHB_RC_HP.get() == 1:
3471  try:
3472  TC1B = float(chb_TC1Entry.get())
3473  if TC1B < 0:
3474  TC1B = 0
3475  chb_TC1Entry.delete(0, END)
3476  chb_TC1Entry.insert(0, TC1B)
3477  except:
3478  TC1B = CHB_TC1.get()
3479  try:
3480  TC2B = float(chb_TC2Entry.get())
3481  if TC2B < 0:
3482  TC2B = 0
3483  chb_TC2Entry.delete(0, END)
3484  chb_TC2Entry.insert(0, TC2B)
3485  except:
3486  TC2B = CHB_TC2.get()
3487  #
3488  try:
3489  Gain1B = float(chb_A1Entry.get())
3490  except:
3491  Gain1B = CHB_A1.get()
3492  try:
3493  Gain2B = float(chb_A2Entry.get())
3494  except:
3495  Gain2B = CHB_A2.get()
3496  #
3497  if len(VBuffB) > 4:
3498  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
3499  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
3500 # check if digital filter box checked
3501  if DigFiltA.get() == 1:
3502  if len(DFiltACoef) > 1:
3503  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
3504  if DigFiltB.get() == 1:
3505  if len(DFiltBCoef) > 1:
3506  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
3507 # Find trigger sample point if necessary
3508  LShift = 0
3509  if TgInput.get() == 1:
3510  FindTriggerSample(VBuffA)
3511  if TgInput.get() == 2:
3512  FindTriggerSample(IBuffA)
3513  if TgInput.get() == 3:
3514  FindTriggerSample(VBuffB)
3515  if TgInput.get() == 4:
3516  FindTriggerSample(IBuffB)
3517  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
3518  # Average mode 1, add difference / TRACEaverage to array
3519  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
3520  LShift = 0 - TRIGGERsample
3521  VBuffA = numpy.roll(VBuffA, LShift)
3522  VBuffB = numpy.roll(VBuffB, LShift)
3523  IBuffA = numpy.roll(IBuffA, LShift)
3524  IBuffB = numpy.roll(IBuffB, LShift)
3525  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
3526  try:
3527  if DualMuxMode.get() == 0 and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
3528  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
3529  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
3530  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
3531  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
3532  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
3533  except:
3534  # buffer size mismatch so reset memory buffers
3535  VmemoryA = VBuffA
3536  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
3537  VmemoryB = VBuffB
3538  ImemoryA = IBuffA
3539  ImemoryB = IBuffB
3540  if TgInput.get() == 1:
3541  ReInterploateTrigger(VBuffA)
3542  if TgInput.get() == 2:
3543  ReInterploateTrigger(IBuffA)
3544  if TgInput.get() == 3:
3545  ReInterploateTrigger(VBuffB)
3546  if TgInput.get() == 4:
3547  ReInterploateTrigger(IBuffB)
3548 # DC value = average of the data record
3549  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
3550  Endsample = hldn+onescreen # average over only one screen's worth of samples
3551  else:
3552  Endsample = SHOWsamples - 10 # average over all samples
3553  if MeasGateStatus.get() == 1:
3554  if (MeasGateRight-MeasGateLeft) > 0:
3555  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
3556  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
3557  DCV1 = numpy.mean(VBuffA[hldn:Endsample])
3558  DCV2 = numpy.mean(VBuffB[hldn:Endsample])
3559  # convert current values to mA
3560  DCI1 = numpy.mean(IBuffA[hldn:Endsample])
3561  DCI2 = numpy.mean(IBuffB[hldn:Endsample])
3562 # find min and max values
3563  MinV1 = numpy.amin(VBuffA[hldn:Endsample])
3564  MaxV1 = numpy.amax(VBuffA[hldn:Endsample])
3565  MinV2 = numpy.amin(VBuffB[hldn:Endsample])
3566  MaxV2 = numpy.amax(VBuffB[hldn:Endsample])
3567  MinI1 = numpy.amin(IBuffA[hldn:Endsample])
3568  MaxI1 = numpy.amax(IBuffA[hldn:Endsample])
3569  MinI2 = numpy.amin(IBuffB[hldn:Endsample])
3570  MaxI2 = numpy.amax(IBuffB[hldn:Endsample])
3571 # RMS value = square root of average of the data record squared
3572  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample])))
3573  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[hldn:Endsample])))
3574  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[hldn:Endsample])))
3575  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[hldn:Endsample])))
3576  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample]-VBuffB[hldn:Endsample])))
3577 # Transfer to mux buffers as necessary
3578  if TgInput.get() > 0 and MuxChan > -1 and TRACEmodeTime.get() != 1:
3579  # if triggering left shift all arrays such that trigger point is at index 0
3580  LShift = 0 - TRIGGERsample
3581  VBuffA = numpy.roll(VBuffA, LShift)
3582  VBuffB = numpy.roll(VBuffB, LShift)
3583  IBuffA = numpy.roll(IBuffA, LShift)
3584  IBuffB = numpy.roll(IBuffB, LShift)
3585  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
3586  if MuxChan > -1:
3587  Dval0 = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
3588  Dval1 = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
3589  #print Dval0[0], Dval1[0], MuxChan
3590  if Show_CBA.get() == 1 and Dval0[0] == 0 and Dval1[0] == 0:
3591  DCVMuxA = DCV2
3592  MinVMuxA = MinV2
3593  MaxVMuxA = MaxV2
3594  MidVMuxA = (MaxV2+MinV2)/2.0
3595  PPVMuxA = MaxV2-MinV2
3596  SVMuxA = SV2
3597  VBuffMA = VBuffB
3598  if Show_CBB.get() == 1 and Dval0[0] == 1 and Dval1[0] == 0:
3599  DCVMuxB = DCV2
3600  MinVMuxB = MinV2
3601  MaxVMuxB = MaxV2
3602  MidVMuxB = (MaxV2+MinV2)/2.0
3603  PPVMuxB = MaxV2-MinV2
3604  SVMuxB = SV2
3605  VBuffMB = VBuffB
3606  if Show_CBC.get() == 1 and Dval0[0] == 0 and Dval1[0] == 1:
3607  if DualMuxMode.get() == 1:
3608  DCVMuxC = DCV1
3609  MinVMuxC = MinV1
3610  MaxVMuxC = MaxV1
3611  MidVMuxC = (MaxV1+MinV1)/2.0
3612  PPVMuxC = MaxV1-MinV1
3613  SVMuxC = SV1
3614  VBuffMC = VBuffA
3615  else:
3616  DCVMuxC = DCV2
3617  MinVMuxC = MinV2
3618  MaxVMuxC = MaxV2
3619  MidVMuxC = (MaxV2+MinV2)/2.0
3620  PPVMuxC = MaxV2-MinV2
3621  SVMuxC = SV2
3622  VBuffMC = VBuffB
3623  if Show_CBD.get() == 1 and Dval0[0] == 1 and Dval1[0] == 1:
3624  if DualMuxMode.get() == 1:
3625  DCVMuxD = DCV1
3626  MinVMuxD = MinV1
3627  MaxVMuxD = MaxV1
3628  MidVMuxD = (MaxV1+MinV1)/2.0
3629  PPVMuxD = MaxV1-MinV1
3630  SVMuxD = SV1
3631  VBuffMD = VBuffA
3632  else:
3633  DCVMuxD = DCV2
3634  MinVMuxD = MinV2
3635  MaxVMuxD = MaxV2
3636  MidVMuxD = (MaxV2+MinV2)/2.0
3637  PPVMuxD = MaxV2-MinV2
3638  SVMuxD = SV2
3639  VBuffMD = VBuffB
3640 #
3641  if TimeDisp.get() > 0:
3642  UpdateTimeAll() # Update Data, trace and time screen
3643  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3644  UpdateXYAll() # Update Data, trace and XY screen
3645  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
3646  BStop() # RUNstatus.set(0)
3647  SingleShot.set(0)
3648  if ManualTrigger.get() == 1: # Manual trigger is on
3649  BStop() # RUNstatus.set(0)
3650  if MeasureStatus.get() > 0:
3652  # RUNstatus = 3: Stop
3653  # RUNstatus = 4: Stop and restart
3654  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
3655  if RUNstatus.get() == 3:
3656  RUNstatus.set(0)
3657  if RUNstatus.get() == 4:
3658  RUNstatus.set(1)
3659  if TimeDisp.get() > 0:
3661  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
3662  UpdateXYScreen()
3663  # Update tasks and screens by TKinter
3664  # update screens
3665 #
3666 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
3667 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
3668 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
3669 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
3670 
3671 
3673 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
3674  global SAMPLErate
3675 
3676  OutBuff = []
3677  n = len(InBuff)
3678  Delta = 1.0/SAMPLErate
3679  TC = TC1 * 1.0E-6
3680  Alpha = TC / (TC + Delta)
3681  OutBuff.append(InBuff[1]-InBuff[0]) # set inital sample to derivative (difference of first two samples)
3682  i = 1
3683  while i < n:
3684  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
3685  i += 1
3686  OutBuff = numpy.array(OutBuff)
3687  OutBuff = InBuff + (OutBuff * Gain)
3688  return OutBuff
3689 
3691 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
3692  global SAMPLErate
3693 
3694  OutBuff = []
3695  n = len(InBuff)
3696  Delta = 1.0/SAMPLErate
3697  TC = TC1 * 1.0E-6
3698  Alpha = Delta / (TC + Delta)
3699  i = 1
3700  OutBuff.append(Alpha*InBuff[0])
3701  while i < n:
3702  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
3703  i += 1
3704  OutBuff = numpy.array(OutBuff)
3705  OutBuff = (OutBuff * Gain)
3706  return OutBuff
3707 
3711 def shift_buffer(arr, num, fill_value=numpy.nan):
3712  result = numpy.empty_like(arr)
3713  if num > 0:
3714  result[:num] = fill_value
3715  result[num:] = arr[:-num]
3716  elif num < 0:
3717  result[num:] = fill_value
3718  result[:num] = arr[-num:]
3719  else:
3720  result[:] = arr
3721  return result
3722 
3723 
3726  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
3727  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
3728  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
3729  global NSteps, LoopNum, FSweepMode, FStep, FBins
3730  global StartFreqEntry, StopFreqEntry, HoldOffentry
3731  global session, CHA, CHB, devx, MaxSamples, discontloop
3732  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
3733  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
3734  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
3735  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
3736  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
3737  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3738  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
3739  global BDSweepFile, FileSweepFreq, FileSweepAmpl
3740  global PIO_0, PIO_1, PIO_2, PIO_3
3741  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3742  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3743  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3744  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3745  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
3746 
3747  HalfSAMPLErate = SAMPLErate/2
3748  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3749  try:
3750  InOffA = float(eval(CHAVOffsetEntry.get()))
3751  except:
3752  CHAVOffsetEntry.delete(0,END)
3753  CHAVOffsetEntry.insert(0, InOffA)
3754  try:
3755  InGainA = float(eval(CHAVGainEntry.get()))
3756  except:
3757  CHAVGainEntry.delete(0,END)
3758  CHAVGainEntry.insert(0, InGainA)
3759  try:
3760  InOffB = float(eval(CHBVOffsetEntry.get()))
3761  except:
3762  CHBVOffsetEntry.delete(0,END)
3763  CHBVOffsetEntry.insert(0, InOffB)
3764  try:
3765  InGainB = float(eval(CHBVGainEntry.get()))
3766  except:
3767  CHBVGainEntry.delete(0,END)
3768  CHBVGainEntry.insert(0, InGainB)
3769  try:
3770  HoldOff = float(eval(HoldOffentry.get()))
3771  if HoldOff < 0:
3772  HoldOff = 0
3773  HoldOffentry.delete(0,END)
3774  HoldOffentry.insert(0, HoldOff)
3775  except:
3776  HoldOffentry.delete(0,END)
3777  HoldOffentry.insert(0, HoldOff)
3778  #
3779  INITIALIZEstart()
3780  # Starting acquisition This is a HACK to get around non-continous AWG mode!
3781  # restart AWGs if indicated
3782  if BodeDisp.get() == 0: # make new noise waveforms each sweep
3783  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
3784  AWGAMakeUUNoise()
3785  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
3786  AWGAMakeUGNoise()
3787  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
3788  AWGBMakeUUNoise()
3789  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
3790  AWGBMakeUGNoise()
3791  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
3792  if BDSweepFile.get() == 0:
3793  if LoopNum.get() <= len(FStep):
3794  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
3795  else:
3796  FregPoint = FBins[FStep[0]]
3797  else:
3798  if LoopNum.get() <= len(FileSweepFreq): #
3799  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
3800  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
3801  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
3802  else:
3803  FregPoint = FBins[FileSweepFreq[0]]
3804  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
3805  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
3806  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
3807  if FSweepMode.get() == 1: # set new CH-A amplitude
3808  AWGAAmplEntry.delete(0,END)
3809  AWGAAmplEntry.insert(4, VMin)
3810  AWGAOffsetEntry.delete(0,END)
3811  AWGAOffsetEntry.insert(4, VMax)
3812  if FSweepMode.get() == 2: # set new CH-B amplitude
3813  AWGBAmplEntry.delete(0,END)
3814  AWGBAmplEntry.insert(4, VMin)
3815  AWGBOffsetEntry.delete(0,END)
3816  AWGBOffsetEntry.insert(4, VMax)
3817  if FSweepMode.get() == 1: # set new CH-A frequency
3818  AWGAFreqEntry.delete(0,END)
3819  AWGAFreqEntry.insert(4, FregPoint)
3821  if FSweepMode.get() == 2: # set new CH-B frequency
3822  AWGBFreqEntry.delete(0,END)
3823  AWGBFreqEntry.insert(4, FregPoint)
3825  if FSweepMode.get() == 3: # set new MiniGen frequency
3826  MinigenFout.delete(0,END)
3827  MinigenFout.insert(4, FregPoint)
3828  BSendMG()
3829  if AWGSync.get() > 0:
3830  if IAScreenStatus.get() > 0 and IASource.get() == 0:
3831  if Two_X_Sample.get() == 1:
3832  AWGBIOMode.set(1)
3833  AWGBMode.set(0)
3834  else:
3835  AWGBMode.set(2)
3836  # BAWGEnab()
3837 #
3838  hldn = int(HoldOff * 100 )
3839  if hldn > MaxSamples-SMPfft:
3840  hldn = MaxSamples-SMPfft
3841  HoldOffentry.delete(0,END)
3842  HoldOffentry.insert(0, hldn/100)
3843  if hldn < 128:
3844  hldn = 128
3845  SHOWsamples = SMPfft + hldn # get holf off extra samples
3846  if BodeDisp.get() > 0: # check if doing Bode Plot
3847  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
3848  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3849  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3850  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3851  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
3852  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3853  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
3854  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
3855  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
3856  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3857  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3858  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3859  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
3860  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3861  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
3862  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
3863  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3864  if IAScreenStatus.get() > 0 and IASource.get() == 0:
3865  if Two_X_Sample.get() == 1:
3866  AWGBIOMode.set(1)
3867  AWGBMode.set(0)
3868  else:
3869  AWGBMode.set(2)
3870  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3871  if discontloop > 0:
3872  session.flush()
3873  else:
3874  discontloop = 1
3875  BAWGEnab()
3876  try:
3877  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3878  except:
3879  donothing()
3880  # waite to finish then return to open termination
3881  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3882  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3883  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3884  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3885  else: # running in continuous mode
3886  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
3887  #
3888  else:
3889  if session.continuous:
3890  ADsignal1 = devx.read(SHOWsamples, -1, True)
3891  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
3892  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3893  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3894  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3895  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3896  FFTBuffA = [] # Clear the FFTBuff array for trace A
3897  FFTBuffB = [] # Clear the FFTBuff array for trace B
3898  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
3899  index = hldn # skip first hldn samples
3900  if SHOWsamples != len(ADsignal1):
3901  SHOWsamples = len(ADsignal1)
3902  while index < SHOWsamples:
3903  if Two_X_Sample.get() == 1:
3904  if ADC_Mux_Mode.get() == 0: # VA and VB
3905  FFTBuffA.append(ADsignal1[index][0][0])
3906  FFTBuffA.append(ADsignal1[index][1][1])
3907  FFTBuffB.append(ADsignal1[index][0][1])
3908  FFTBuffB.append(ADsignal1[index][1][0])
3909  else:
3910  VAdata = ADsignal1[index][0][0]
3911  FFTBuffA.append(VAdata)
3912  VBdata = ADsignal1[index][1][0]
3913  FFTBuffB.append(VBdata)
3914  if VAdata > 5.0 or VAdata < 0.0:
3915  OverRangeFlagA = 1
3916 
3917  if VBdata > 5.0 or VBdata < 0.0:
3918  OverRangeFlagB = 1
3919  index = index + 1
3920 
3921  FFTBuffA = numpy.array(FFTBuffA)
3922  FFTBuffB = numpy.array(FFTBuffB)
3923  FFTBuffA = (FFTBuffA - InOffA) * InGainA
3924  FFTBuffB = (FFTBuffB - InOffB) * InGainB
3925  DCA = numpy.average(FFTBuffA)
3926  DCB = numpy.average(FFTBuffB)
3927  if CutDC.get() == 1:
3928  FFTBuffA = FFTBuffA - DCA
3929  FFTBuffB = FFTBuffB - DCB
3930 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3931  if CHA_RC_HP.get() == 1:
3932  try:
3933  TC1A = float(cha_TC1Entry.get())
3934  if TC1A < 0:
3935  TC1A = 0
3936  cha_TC1Entry.delete(0,END)
3937  cha_TC1Entry.insert(0, TC1A)
3938  except:
3939  TC1A = CHA_TC1.get()
3940  try:
3941  TC2A = float(cha_TC2Entry.get())
3942  if TC2A < 0:
3943  TC2A = 0
3944  cha_TC2Entry.delete(0,END)
3945  cha_TC2Entry.insert(0, TC2A)
3946  except:
3947  TC2A = CHA_TC2.get()
3948  #
3949  try:
3950  Gain1A = float(cha_A1Entry.get())
3951  except:
3952  Gain1A = CHA_A1.get()
3953  try:
3954  Gain2A = float(cha_A2Entry.get())
3955  except:
3956  Gain2A = CHA_A2.get()
3957  #
3958  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
3959  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
3960  if CHB_RC_HP.get() == 1:
3961  try:
3962  TC1B = float(chb_TC1Entry.get())
3963  if TC1B < 0:
3964  TC1B = 0
3965  chb_TC1Entry.delete(0, END)
3966  chb_TC1Entry.insert(0, TC1B)
3967  except:
3968  TC1B = CHB_TC1.get()
3969  try:
3970  TC2B = float(chb_TC2Entry.get())
3971  if TC2B < 0:
3972  TC2B = 0
3973  chb_TC2Entry.delete(0, END)
3974  chb_TC2Entry.insert(0, TC2B)
3975  except:
3976  TC2B = CHB_TC2.get()
3977  #
3978  try:
3979  Gain1B = float(chb_A1Entry.get())
3980  except:
3981  Gain1B = CHB_A1.get()
3982  try:
3983  Gain2B = float(chb_A2Entry.get())
3984  except:
3985  Gain2B = CHB_A2.get()
3986  #
3987  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
3988  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
3989 # check if digital filter box checked
3990  if DigFiltA.get() == 1:
3991  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
3992  if DigFiltB.get() == 1:
3993  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
3994  DoFFT()
3995  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
3996  UpdateFreqAll() # Update spectrum Data, trace and screen
3997  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
3998  UpdateIAAll()
3999  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
4000  UpdateBodeAll()
4001  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
4002  UpdateNqPAll()
4003  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
4004  UpdateNiCAll()
4005  if SingleShotSA.get() == 1: # Single shot sweep is on
4006  RUNstatus.set(0)
4007 # RUNstatus = 3: Stop
4008 # RUNstatus = 4: Stop and restart
4009  if (RUNstatus.get() == 3) or (RUNstatus.get() == 4):
4010  if RUNstatus.get() == 3:
4011  RUNstatus.set(0) # Status is stopped
4012  if RUNstatus.get() == 4:
4013  RUNstatus.set(1) # Status is (re)start
4014  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
4015  UpdateFreqScreen() # Freq UpdateScreen() call
4016  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
4017  UpdateIAScreen()
4018  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
4019  LoopNum.set(LoopNum.get() + 1)
4020  if LoopNum.get() > NSteps.get():
4021  if FSweepMode.get() == 1:
4022  AWGAFreqEntry.delete(0,"end")
4023  AWGAFreqEntry.insert(0, Reset_Freq)
4024  if FSweepMode.get() == 2:
4025  AWGBFreqEntry.delete(0,"end")
4026  AWGBFreqEntry.insert(0, Reset_Freq)
4027 #
4028  LoopNum.set(1)
4029  if FSweepCont.get() == 0:
4030  RUNstatus.set(0)
4031 
4033  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
4034  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
4035  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
4036  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4037  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4038  global VABase, VATop, VBBase, VBTop
4039 
4040  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
4041  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
4042  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
4043  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
4044  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
4045  LowerPeak = 0
4046  UpperPeak = 0
4047  b = 0
4048  while (b < 4999):
4049  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
4050  LowerPeak = b
4051  VABase = HBuffA[1][b]
4052  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
4053  UpperPeak = b
4054  VATop = HBuffA[1][b]
4055  b = b + 1
4056  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
4057  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
4058  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
4059  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
4060  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
4061  LowerPeak = 0
4062  UpperPeak = 0
4063  b = 0
4064  while (b < 4999):
4065  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
4066  LowerPeak = b
4067  VBBase = HBuffB[1][b]
4068  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
4069  UpperPeak = b
4070  VBTop = HBuffB[1][b]
4071  b = b + 1
4072 
4074  global HistAsPercent
4075 
4076  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
4077  HistAsPercent = 1
4078  else:
4079  HistAsPercent = 0
4080 
4081 def FindRisingEdge(Trace1, Trace2):
4082  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
4083  # global VBuffA, VBuffB
4084  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
4085  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
4086  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
4087 
4088  anr1 = bnr1 = 0
4089  anf1 = bnf1 = 1
4090  anr2 = bnr2 = 2
4091  hldn = int(HoldOff * SAMPLErate/1000)
4092  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
4093  Trace1 = numpy.roll(Trace1, -LShift)
4094  Trace2 = numpy.roll(Trace2, -LShift)
4095  else:
4096  Trace1 = numpy.roll(Trace1, -hldn)
4097  Trace2 = numpy.roll(Trace2, -hldn)
4098  try:
4099  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
4100  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
4101  except:
4102  MidV1 = (MinV1+MaxV1)/2
4103  MidV2 = (MinV2+MaxV2)/2
4104 # search Trace 1
4105  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
4106  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
4107  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
4108  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
4109 
4110  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
4111  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
4112  if len(Arising) > 0 or len(Afalling) > 0:
4113  if Arising[0] > 0:
4114  try:
4115  anr1 = AIrising[0]
4116  except:
4117  anr1 = 0
4118  try:
4119  anr2 = AIrising[1]
4120  except:
4121  anr2 = SHOWsamples
4122  try:
4123  if AIfalling[0] < AIrising[0]:
4124  anf1 = AIfalling[1]
4125  else:
4126  anf1 = AIfalling[0]
4127  except:
4128  anf1 = 1
4129  else:
4130  try:
4131  anr1 = AIrising[1]
4132  except:
4133  anr1 = 0
4134  try:
4135  anr2 = AIrising[2]
4136  except:
4137  anr2 = SHOWsamples
4138  try:
4139  if AIfalling[1] < AIrising[1]:
4140  anf1 = AIfalling[2]
4141  else:
4142  anf1 = AIfalling[1]
4143  except:
4144  anf1 = 1
4145 # search Trace 2
4146  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
4147  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
4148  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
4149  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
4150 
4151  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
4152  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
4153  if len(Brising) > 0 or len(Bfalling) > 0:
4154  if Brising[0] > 0:
4155  try:
4156  bnr1 = BIrising[0]
4157  except:
4158  bnr1 = 0
4159  try:
4160  bnr2 = BIrising[1]
4161  except:
4162  bnr2 = SHOWsamples
4163  try:
4164  if BIfalling[0] < BIrising[0]:
4165  bnf1 = BIfalling[1]
4166  else:
4167  bnf1 = BIfalling[0]
4168  except:
4169  bnf1 = 1
4170  else:
4171  try:
4172  bnr1 = BIrising[1]
4173  except:
4174  bnr1 = 0
4175  try:
4176  bnr2 = BIrising[2]
4177  except:
4178  bnr2 = SHOWsamples
4179  try:
4180  if BIfalling[1] < BIrising[1]:
4181  bnf1 = BIfalling[2]
4182  else:
4183  bnf1 = BIfalling[1]
4184  except:
4185  bnf1 = 1
4186  #
4187  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
4188  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
4189  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
4190  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
4191  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
4192  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
4193 #
4194  if bnr1 > anr1:
4195  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
4196  else:
4197  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
4198  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
4199  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
4200  try:
4201  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
4202  except:
4203  CHABphase = 0.0
4204  if CHABphase < 0.0:
4205  CHABphase = CHABphase + 360.0
4206 
4208  global DX, TRIGGERsample, TRIGGERlevel
4209 
4210  DX = 0
4211  n = TRIGGERsample
4212  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
4213  if DY != 0.0:
4214  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
4215  else:
4216  DX = 0
4217 
4218 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
4219  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
4220  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
4221 
4222  # Set the TRACEsize variable
4223  TRACEsize = SHOWsamples # Set the trace length
4224  DX = 0
4225  Is_Triggered = 0
4226  if len(TrgBuff) == 0:
4227  return
4228  try:
4229  TrgMin = numpy.amin(TrgBuff)
4230  except:
4231  TrgMin = 0.0
4232  try:
4233  TrgMax = numpy.amax(TrgBuff)
4234  except:
4235  TrgMax = 0.0
4236 # Find trigger sample
4237  try:
4238  if AutoLevel.get() == 1:
4239  TRIGGERlevel = (TrgMin + TrgMax)/2
4240  TRIGGERentry.delete(0,"end")
4241  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
4242  else:
4243  TRIGGERlevel = eval(TRIGGERentry.get())
4244  except:
4245  TRIGGERentry.delete(0,END)
4246  TRIGGERentry.insert(0, TRIGGERlevel)
4247 # Start from first sample after HoldOff
4248  try:
4249  HoldOff = float(eval(HoldOffentry.get()))
4250  if HoldOff < 0:
4251  HoldOff = 0
4252  HoldOffentry.delete(0,END)
4253  HoldOffentry.insert(0, HoldOff)
4254  except:
4255  HoldOffentry.delete(0,END)
4256  HoldOffentry.insert(0, HoldOff)
4257 # slide trace left right by HozPoss
4258  try:
4259  HozPoss = float(eval(HozPossentry.get()))
4260  except:
4261  HozPossentry.delete(0,END)
4262  HozPossentry.insert(0, HozPoss)
4263 
4264  hldn = int(HoldOff * SAMPLErate/1000)
4265  hozpos = int(HozPoss * SAMPLErate/1000)
4266  if hozpos >= 0:
4267  TRIGGERsample = hldn
4268  else:
4269  TRIGGERsample = abs(hozpos)
4270 #
4271  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
4272  DX = 0
4273  n = TRIGGERsample
4274  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
4275  if TRIGGERlevel2 < TrgMin:
4276  TRIGGERlevel2 = TrgMin
4277  if TRIGGERlevel2 > TrgMax:
4278  TRIGGERlevel2 = TrgMax
4279  ChInput = TrgBuff[int(n)]
4280  Prev = ChInput
4281  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
4282  n = n + 1
4283  ChInput = TrgBuff[int(n)]
4284  while (ChInput <= TRIGGERlevel) and n < Nmax:
4285  Prev = ChInput
4286  n = n + 1
4287  ChInput = TrgBuff[int(n)]
4288  DY = ChInput - Prev
4289  if DY != 0.0:
4290  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
4291  else:
4292  DX = 0
4293  if TgEdge.get() == 1:
4294  TRIGGERlevel2 = 1.01 * TRIGGERlevel
4295  if TRIGGERlevel2 < TrgMin:
4296  TRIGGERlevel2 = TrgMin
4297  if TRIGGERlevel2 > TrgMax:
4298  TRIGGERlevel2 = TrgMax
4299  ChInput = TrgBuff[int(n)]
4300  Prev = ChInput
4301  while (ChInput <= TRIGGERlevel2) and n < Nmax:
4302  n = n + 1
4303  ChInput = TrgBuff[int(n)]
4304  while (ChInput >= TRIGGERlevel) and n < Nmax:
4305  Prev = ChInput
4306  n = n + 1
4307  ChInput = TrgBuff[int(n)]
4308  DY = Prev - ChInput
4309  try:
4310  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
4311  except:
4312  DX = 0
4313 
4314 # check to insure trigger point is in bounds
4315  if n < Nmax:
4316  TRIGGERsample = n - 1
4317  Is_Triggered = 1
4318  elif n > Nmax: # Didn't find edge in first 2/3 of data set
4319  TRIGGERsample = 1 + hldn # reset to begining
4320  Is_Triggered = 0
4321  if DX > 1:
4322  DX = 1 # never more than 100% of a sample period
4323  elif DX < 0:
4324  DX = 0 # never less than 0% of a sample period
4325  if math.isnan(DX):
4326  DX = 0
4327  TRIGGERsample = TRIGGERsample + hozpos
4328 
4330  global win2, DigScreenStatus
4331 
4332  DigScreenStatus.set(0)
4333  win2.destroy()
4334 
4335 def sel():
4336  global devx, DevID
4337  global D0, D1, D2, D3, D4, D5, D6, D7
4338  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4339  # sending 0x50 = set to 0, 0x51 = set to 1
4340  if D0.get() > 0:
4341  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
4342  else:
4343  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
4344  if D1.get() > 0:
4345  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
4346  else:
4347  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
4348  if D2.get() > 0:
4349  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
4350  else:
4351  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
4352  if D3.get() > 0:
4353  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
4354  else:
4355  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
4356  if D4.get() > 0:
4357  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
4358  else:
4359  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
4360  if D5.get() > 0:
4361  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
4362  else:
4363  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
4364  if D6.get() > 0:
4365  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
4366  else:
4367  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
4368  if D7.get() > 0:
4369  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
4370  else:
4371  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
4372 
4374  global D0, D1, D2, D3, D4, D5, D6, D7
4375  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4376  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
4377  # setup Dig output window
4378  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
4379  DigScreenStatus.set(1)
4380  win2 = Toplevel()
4381  win2.title("Dig Out")
4382  win2.resizable(FALSE,FALSE)
4383  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
4384  rb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
4385  rb1.grid(row=2, column=0, sticky=W)
4386  rb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
4387  rb0z.grid(row=2, column=1, sticky=W)
4388  rb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
4389  rb2.grid(row=2, column=2, sticky=W)
4390  rb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
4391  rb3.grid(row=3, column=0, sticky=W)
4392  rb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
4393  rb3z.grid(row=3, column=1, sticky=W)
4394  rb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
4395  rb4.grid(row=3, column=2, sticky=W)
4396  rb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
4397  rb5.grid(row=4, column=0, sticky=W)
4398  rb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
4399  rb5z.grid(row=4, column=1, sticky=W)
4400  rb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
4401  rb6.grid(row=4, column=2, sticky=W)
4402  rb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
4403  rb7.grid(row=5, column=0, sticky=W)
4404  rb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
4405  rb7z.grid(row=5, column=1, sticky=W)
4406  rb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
4407  rb8.grid(row=5, column=2, sticky=W)
4408  rb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
4409  rb9.grid(row=6, column=0, sticky=W)
4410  rb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
4411  rb9z.grid(row=6, column=1, sticky=W)
4412  rb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
4413  rb10.grid(row=6, column=2, sticky=W)
4414  rb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
4415  rb11.grid(row=7, column=0, sticky=W)
4416  rb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
4417  rb11z.grid(row=7, column=1, sticky=W)
4418  rb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
4419  rb12.grid(row=7, column=2, sticky=W)
4420  rb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
4421  rb13.grid(row=8, column=0, sticky=W)
4422  rb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
4423  rb13z.grid(row=8, column=1, sticky=W)
4424  rb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
4425  rb13.grid(row=8, column=2, sticky=W)
4426  rb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
4427  rb14.grid(row=9, column=0, sticky=W)
4428  rb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
4429  rb14z.grid(row=9, column=1, sticky=W)
4430  rb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
4431  rb15.grid(row=9, column=2, sticky=W)
4432 
4433  dismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
4434  dismissbutton.grid(row=10, column=0, sticky=W)
4435 
4437  global win1, DacScreenStatus
4438 
4439  DacScreenStatus.set(0)
4440  win1.destroy()
4441 
4442 def sel0(temp):
4443  global devx, DevID
4444  global PIO_0, PIO_4
4445  global DAC0
4446  # sending 0x50 = set to 0, 0x51 = set to 1
4447  if DAC0.get() == 1:
4448  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4449  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
4450  elif DAC0.get() == 4:
4451  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4452  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
4453  elif DAC0.get() == 2:
4454  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
4455  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4456  elif DAC0.get() == 3:
4457  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
4458  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
4459  elif DAC0.get() == 5:
4460  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
4461  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4462  elif DAC0.get() == 7:
4463  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
4464  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
4465  elif DAC0.get() == 8:
4466  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
4467  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
4468  elif DAC0.get() == 6:
4469  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
4470  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
4471  elif DAC0.get() == 9:
4472  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
4473  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
4474 
4475 def sel1(temp):
4476  global devx, DevID
4477  global PIO_1, PIO_5
4478  global DAC1
4479  # sending 0x50 = set to 0, 0x51 = set to 1
4480  if DAC1.get() == 1:
4481  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4482  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
4483  elif DAC1.get() == 4:
4484  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4485  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
4486  elif DAC1.get() == 2:
4487  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
4488  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4489  elif DAC1.get() == 3:
4490  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4491  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
4492  elif DAC1.get() == 5:
4493  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4494  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4495  elif DAC1.get() == 7:
4496  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
4497  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
4498  elif DAC1.get() == 8:
4499  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
4500  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
4501  elif DAC1.get() == 6:
4502  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
4503  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
4504  elif DAC1.get() == 9:
4505  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
4506  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
4507 
4508 def sel2(temp):
4509  global devx, DevID
4510  global PIO_2, PIO_6
4511  global DAC2
4512  # sending 0x50 = set to 0, 0x51 = set to 1
4513  if DAC2.get() == 1:
4514  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4515  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
4516  elif DAC2.get() == 4:
4517  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4518  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
4519  elif DAC2.get() == 2:
4520  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
4521  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4522  elif DAC2.get() == 3:
4523  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4524  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
4525  elif DAC2.get() == 5:
4526  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4527  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4528  elif DAC2.get() == 7:
4529  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
4530  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
4531  elif DAC2.get() == 8:
4532  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
4533  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
4534  elif DAC2.get() == 6:
4535  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
4536  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
4537  elif DAC2.get() == 9:
4538  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
4539  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
4540 
4541 def sel3(temp):
4542  global devx, DevID
4543  global PIO_3, PIO_7
4544  global DAC3
4545  # sending 0x50 = set to 0, 0x51 = set to 1
4546  if DAC3.get() == 1:
4547  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4548  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
4549  elif DAC3.get() == 4:
4550  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4551  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
4552  elif DAC3.get() == 2:
4553  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
4554  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4555  elif DAC3.get() == 3:
4556  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4557  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
4558  elif DAC3.get() == 5:
4559  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4560  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4561  elif DAC3.get() == 7:
4562  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
4563  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
4564  elif DAC3.get() == 8:
4565  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
4566  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
4567  elif DAC3.get() == 6:
4568  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
4569  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
4570  elif DAC3.get() == 9:
4571  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
4572  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
4573 
4575  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
4576  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
4577  # setup Dig output window
4578  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
4579  DacScreenStatus.set(1)
4580  win1 = Toplevel()
4581  win1.title("DAC Out "+ SWRev + RevDate)
4582  win1.resizable(FALSE,FALSE)
4583  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
4584  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
4585  DAC0.grid(row=0, column=0, sticky=W)
4586  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
4587  DAC1.grid(row=0, column=1, sticky=W)
4588  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
4589  DAC2.grid(row=0, column=2, sticky=W)
4590  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
4591  DAC3.grid(row=0, column=3, sticky=W)
4592 
4593  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
4594  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
4595 
4597 
4598  MakeTimeTrace() # Update the traces
4599  UpdateTimeScreen() # Update the screen
4600 
4602 
4603  MakeTimeTrace() # Update traces
4604  UpdateTimeScreen() # Update the screen
4605 
4607 
4608  MakeTimeScreen() # Update the screen
4609  root.update() # Activate updated screens
4610 
4612 
4613  MakeXYTrace() # Update the traces
4614  UpdateXYScreen() # Update the screen
4615 
4617 
4618  MakeXYTrace() # Update traces
4619  UpdateXYScreen() # Update the screen
4620 
4622 
4623  MakeXYScreen() # Update the screen
4624  root.update() # Activate updated screens
4625 
4627  global VBuffA, VBuffB, IBuffA, IBuffB
4628  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus
4629  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4630  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4631  global FFTBuffA, FFTBuffB, FFTwindowshape
4632  global AWGAwaveform, AWGBwaveform
4633  global T1Vline, T2Vline, T1Iline, T2Iline
4634  global TMAVline, TMBVline, TMCVline, TMDVline
4635  global Tmathline, TMXline, TMYline
4636  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
4637  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
4638  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
4639  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
4640  global SHOWsamples, ZOHold, AWGBMode
4641  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
4642  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4643  global Show_MathX, Show_MathY
4644  global TRACES, TRACESread, RUNstatus
4645  global AutoCenterA, AutoCenterB
4646  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
4647  global TMpdiv # Array with time / div values in ms
4648  global TMsb # Time per div spin box variable
4649  global TIMEdiv # current spin box value
4650  global SAMPLErate, SCstart, Two_X_Sample
4651  global TRIGGERsample, TRACEsize, DX
4652  global TRIGGERlevel, TRIGGERentry, AutoLevel
4653  global InOffA, InGainA, InOffB, InGainB
4654  global CurOffA, CurOffB, CurGainA, CurGainB
4655  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4656  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4657  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4658  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
4659  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4660  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
4661  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
4662  global HozPoss, HozPossentry
4663 
4664  # Set the TRACEsize variable
4665  if len(VBuffA) < 100:
4666  return
4667  TRACEsize = SHOWsamples # Set the trace length
4668  SCstart = 0
4669  ylo = 0.0
4670  xlo = 0.0
4671  Ymin = Y0T # Minimum position of time grid (top)
4672  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
4673  Xmin = X0L # Minimum position of time grid (left)
4674  Xmax = X0L + GRW # Maximum position of time grid (right)
4675 
4676  # prevent divide by zero error
4677  if TIMEdiv < 0.0002:
4678  TIMEdiv = 0.01
4679  # Check for Auto Centering
4680  if AutoCenterA.get() > 0:
4681  CHAOffset = DCV1
4682  CHAVPosEntry.delete(0,END)
4683  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
4684  if AutoCenterB.get() > 0:
4685  CHBOffset = DCV2
4686  CHBVPosEntry.delete(0,END)
4687  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
4688  # get the vertical ranges
4689  try:
4690  CH1pdvRange = float(eval(CHAsb.get()))
4691  except:
4692  CHAsb.delete(0,END)
4693  CHAsb.insert(0, CH1vpdvRange)
4694  try:
4695  CH2pdvRange = float(eval(CHBsb.get()))
4696  except:
4697  CHBsb.delete(0,END)
4698  CHBsb.insert(0, CH2vpdvRange)
4699  try:
4700  CH1IpdvRange = float(eval(CHAIsb.get()))
4701  except:
4702  CHAIsb.delete(0,END)
4703  CHAIsb.insert(0, CH1IpdvRange)
4704  try:
4705  CH2IpdvRange = float(eval(CHBIsb.get()))
4706  except:
4707  CHBIsb.delete(0,END)
4708  CHBIsb.insert(0, CH2IpdvRange)
4709  # get the vertical offsets
4710  try:
4711  CHAOffset = float(eval(CHAVPosEntry.get()))
4712  except:
4713  CHAVPosEntry.delete(0,END)
4714  CHAVPosEntry.insert(0, CHAOffset)
4715  try:
4716  CHAIOffset = float(eval(CHAIPosEntry.get()))
4717  except:
4718  CHAIPosEntry.delete(0,END)
4719  CHAIPosEntry.insert(0, CHAIOffset)
4720  try:
4721  CHBOffset = float(eval(CHBVPosEntry.get()))
4722  except:
4723  CHBVPosEntry.delete(0,END)
4724  CHBVPosEntry.insert(0, CHBOffset)
4725  try:
4726  CHBIOffset = float(eval(CHBIPosEntry.get()))
4727  except:
4728  CHBIPosEntry.delete(0,END)
4729  CHBIPosEntry.insert(0, CHBIOffset)
4730  # prevent divide by zero error
4731  if CH1pdvRange < 0.001:
4732  CH1pdvRange = 0.001
4733  if CH2pdvRange < 0.001:
4734  CH2pdvRange = 0.001
4735  if CH1IpdvRange < 0.1:
4736  CH1IpdvRange = 0.1
4737  if CH2IpdvRange < 0.1:
4738  CH2IpdvRange = 0.1
4739 #
4740  try:
4741  HoldOff = float(eval(HoldOffentry.get()))
4742  if HoldOff < 0:
4743  HoldOff = 0
4744  HoldOffentry.delete(0,END)
4745  HoldOffentry.insert(0, HoldOff)
4746  except:
4747  HoldOffentry.delete(0,END)
4748  HoldOffentry.insert(0, HoldOff)
4749 #
4750  try:
4751  HozPoss = float(eval(HozPossentry.get()))
4752  except:
4753  HozPossentry.delete(0,END)
4754  HozPossentry.insert(0, HozPoss)
4755 #
4756  hldn = int(HoldOff * SAMPLErate/1000 )
4757  hozpos = int(HozPoss * SAMPLErate/1000 )
4758  if hozpos < 0:
4759  hozpos = 0
4760  # drawing the traces
4761  if TRACEsize == 0: # If no trace, skip rest of this routine
4762  T1Vline = [] # Trace line channel A V
4763  T2Vline = [] # Trace line channel B V
4764  T1Iline = []
4765  T2Iline = []
4766  TMAVline = [] # V Trace line Mux channel A
4767  TMBVline = [] # V Trace line Mux channel B
4768  TMCVline = [] # V Trace line Mux channel C
4769  TMDVline = [] # V Trace line Mux channel D
4770  Tmathline = [] # math trce line
4771  return()
4772 
4773  # set and/or corrected for in range
4774  if TgInput.get() > 0:
4775  SCmin = int(-1 * TRIGGERsample)
4776  SCmax = int(TRACEsize - TRIGGERsample - 0)
4777  else:
4778  SCmin = 0 # hldn
4779  SCmax = TRACEsize - 1
4780  if SCstart < SCmin: # No reading before start of array
4781  SCstart = SCmin
4782  if SCstart > SCmax: # No reading after end of array
4783  SCstart = SCmax
4784 
4785  # Make Trace lines etc.
4786 
4787  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
4788  Yconv2 = float(GRH/10.0) / CH2pdvRange
4789  YIconv1 = float(GRH/10.0) / CH1IpdvRange
4790  YIconv2 = float(GRH/10.0) / CH2IpdvRange
4791  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
4792  Xconv2 = float(GRW/10.0) / CH2pdvRange
4793  XIconv1 = float(GRW/10.0) / CH1IpdvRange
4794  XIconv2 = float(GRW/10.0) / CH2IpdvRange
4795  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
4796  try:
4797  CHMApdvRange = float(eval(CHB_Asb.get()))
4798  except:
4799  CHB_Asb.delete(0,END)
4800  CHB_Asb.insert(0, CHMApdvRange)
4801  try:
4802  CHMBpdvRange = float(eval(CHB_Bsb.get()))
4803  except:
4804  CHB_Bsb.delete(0,END)
4805  CHB_Bsb.insert(0, CHMBpdvRange)
4806  try:
4807  CHMCpdvRange = float(eval(CHB_Csb.get()))
4808  except:
4809  CHB_Csb.delete(0,END)
4810  CHB_Csb.insert(0, CHMCpdvRange)
4811  try:
4812  CHMDpdvRange = float(eval(CHB_Dsb.get()))
4813  except:
4814  CHB_Dsb.delete(0,END)
4815  CHB_Dsb.insert(0, CHMDpdvRange)
4816  YconvMA = float(GRH/10.0) / CHMApdvRange
4817  YconvMB = float(GRH/10.0) / CHMBpdvRange
4818  YconvMC = float(GRH/10.0) / CHMCpdvRange
4819  YconvMD = float(GRH/10.0) / CHMDpdvRange
4820  try:
4821  CHBAOffset = float(eval(CHB_APosEntry.get()))
4822  except:
4823  CHB_APosEntry.delete(0,END)
4824  CHB_APosEntry.insert(0, CHBAOffset)
4825  try:
4826  CHBBOffset = float(eval(CHB_BPosEntry.get()))
4827  except:
4828  CHB_BPosEntry.delete(0,END)
4829  CHB_BPosEntry.insert(0, CHBBOffset)
4830  try:
4831  CHBCOffset = float(eval(CHB_CPosEntry.get()))
4832  except:
4833  CHB_CPosEntry.delete(0,END)
4834  CHB_CPosEntry.insert(0, CHBCOffset)
4835  try:
4836  CHBDOffset = float(eval(CHB_DPosEntry.get()))
4837  except:
4838  CHB_DPosEntry.delete(0,END)
4839  CHB_DPosEntry.insert(0, CHBDOffset)
4840  if MathAxis == "V-A":
4841  YconvM = Yconv1
4842  CHMOffset = CHAOffset
4843  elif MathAxis == "V-B":
4844  YconvM = Yconv2
4845  CHMOffset = CHBOffset
4846  elif MathAxis == "I-A":
4847  YconvM = YIconv1
4848  CHMOffset = CHAIOffset
4849  elif MathAxis == "I-B":
4850  YconvM = YIconv2
4851  CHMOffset = CHBIOffset
4852  else:
4853  YconvM = Yconv1
4854  CHMOffset = CHAOffset
4855 # include ploting X and Y math formulas vs time
4856  if MathYAxis == "V-A":
4857  YconvMxy = Yconv1
4858  CHMYOffset = CHAOffset
4859  elif MathYAxis == "V-B":
4860  YconvMxy = Yconv2
4861  CHMYOffset = CHBOffset
4862  elif MathYAxis == "I-A":
4863  YconvMxy = YIconv1
4864  CHMYOffset = CHAIOffset
4865  elif MathYAxis == "I-B":
4866  YconvMxy = YIconv2
4867  CHMYOffset = CHBIOffset
4868  else:
4869  YconvMxy = Yconv1
4870  CHMYOffset = CHAOffset
4871 #
4872  if MathXAxis == "V-A":
4873  XconvMxy = Yconv1
4874  CHMXOffset = CHAOffset
4875  elif MathXAxis == "V-B":
4876  XconvMxy = Yconv2
4877  CHMXOffset = CHBOffset
4878  elif MathXAxis == "I-A":
4879  XconvMxy = YIconv1
4880  CHMXOffset = CHAIOffset
4881  elif MathXAxis == "I-B":
4882  XconvMxy = YIconv2
4883  CHMXOffset = CHBIOffset
4884  else:
4885  XconvMxy = Yconv1
4886  CHMXOffset = CHAOffset
4887 #
4888  c1 = GRH / 2.0 + Y0T # fixed correction channel A
4889  c2 = GRH / 2.0 + Y0T # fixed correction channel B
4890 
4891  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
4892  T1Vline = [] # V Trace line channel A
4893  T2Vline = [] # V Trace line channel B
4894  T1Iline = [] # I Trace line channel A
4895  T2Iline = [] # I Trace line channel B
4896  TMAVline = [] # V Trace line Mux channel A
4897  TMBVline = [] # V Trace line Mux channel B
4898  TMCVline = [] # V Trace line Mux channel C
4899  TMDVline = [] # V Trace line Mux channel D
4900  Tmathline = [] # math trce line
4901  TMXline = [] # X math Trace line
4902  TMYline = [] # Y math Trace line
4903  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
4904  return
4905  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
4906  if t < 0:
4907  t = 0
4908  x = 0 # Horizontal screen pixel
4909 #
4910  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
4911  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
4912  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
4913  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
4914  DvY1 = DvY2 = DiY1 = DiY2 = 0
4915 #
4916  if (DISsamples <= GRW):
4917  Xstep = GRW / DISsamples
4918  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
4919  xa = int((Xstep/-2.5) - (Xstep*DX))
4920  else:
4921  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
4922  x = 0 - int(Xstep*DX)
4923  Tstep = 1
4924  x1 = 0 # x position of trace line
4925  xa1 = 0
4926  y1 = 0.0 # y position of trace line
4927  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
4928  ytemp = IBuffA[t]
4929  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
4930  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
4931  if MuxScreenStatus.get() == 1:
4932  if len(VBuffMA) > 4:
4933  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
4934  if len(VBuffMB) > 4:
4935  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
4936  if len(VBuffMC) > 4:
4937  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
4938  if len(VBuffMD) > 4:
4939  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
4940  ytemp = IBuffB[t]
4941  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
4942  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
4943  if TgInput.get() == 0:
4944  Xlimit = GRW
4945  else:
4946  Xlimit = GRW+Xstep
4947  while x <= Xlimit:
4948  if t < TRACEsize:
4949  xa1 = xa + X0L
4950  x1 = x + X0L
4951  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
4952  ytemp = IBuffA[t]
4953  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
4954 
4955  if y1 < Ymin: # clip waveform if going off grid
4956  y1 = Ymin
4957  if y1 > Ymax:
4958  y1 = Ymax
4959  if yi1 < Ymin:
4960  yi1 = Ymin
4961  if yi1 > Ymax:
4962  yi1 = Ymax
4963  if ShowC1_V.get() == 1 :
4964  if ZOHold.get() == 1:
4965  T1Vline.append(int(xa1))
4966  T1Vline.append(int(ypv1))
4967  T1Vline.append(int(xa1))
4968  T1Vline.append(int(y1))
4969  else:
4970  T1Vline.append(int(xa1))
4971  T1Vline.append(int(y1))
4972  DvY1 = ypv1 - y1
4973  ypv1 = y1
4974  if ShowC1_I.get() == 1:
4975  if ZOHold.get() == 1:
4976  T1Iline.append(int(xa1))
4977  T1Iline.append(int(ypi1))
4978  T1Iline.append(int(xa1))
4979  T1Iline.append(int(yi1))
4980  else:
4981  T1Iline.append(int(xa1))
4982  T1Iline.append(int(yi1))
4983  DiY1 = ypi1 - yi1
4984  ypi1 = yi1
4985  if ShowC2_V.get() == 1:
4986  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
4987  if y1 < Ymin: # clip waveform if going off grid
4988  y1 = Ymin
4989  if y1 > Ymax:
4990  y1 = Ymax
4991  if ZOHold.get() == 1:
4992  T2Vline.append(int(x1))
4993  T2Vline.append(int(ypv2))
4994  T2Vline.append(int(x1))
4995  T2Vline.append(int(y1))
4996  else:
4997  T2Vline.append(int(x1))
4998  T2Vline.append(int(y1))
4999  DvY2 = ypv2 - y1
5000  ypv2 = y1
5001  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
5002  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
5003  if y1 < Ymin: # clip waveform if going off grid
5004  y1 = Ymin
5005  if y1 > Ymax:
5006  y1 = Ymax
5007  if ZOHold.get() == 1:
5008  TMAVline.append(int(x1))
5009  TMAVline.append(int(ypvma))
5010  TMAVline.append(int(x1))
5011  TMAVline.append(int(y1))
5012  else:
5013  TMAVline.append(int(x1))
5014  TMAVline.append(int(y1))
5015  ypvma = y1
5016  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5017  Xfine = MouseX - X0L - x
5018  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
5019  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
5020  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
5021  if y1 < Ymin: # clip waveform if going off grid
5022  y1 = Ymin
5023  if y1 > Ymax:
5024  y1 = Ymax
5025  if ZOHold.get() == 1:
5026  TMBVline.append(int(x1))
5027  TMBVline.append(int(ypvmb))
5028  TMBVline.append(int(x1))
5029  TMBVline.append(int(y1))
5030  else:
5031  TMBVline.append(int(x1))
5032  TMBVline.append(int(y1))
5033  ypvmb = y1
5034  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5035  Xfine = MouseX - X0L - x
5036  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
5037  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
5038  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
5039  if y1 < Ymin: # clip waveform if going off grid
5040  y1 = Ymin
5041  if y1 > Ymax:
5042  y1 = Ymax
5043  if ZOHold.get() == 1:
5044  TMCVline.append(int(x1))
5045  TMCVline.append(int(ypvmc))
5046  TMCVline.append(int(x1))
5047  TMCVline.append(int(y1))
5048  else:
5049  TMCVline.append(int(x1))
5050  TMCVline.append(int(y1))
5051  ypvmc = y1
5052  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5053  Xfine = MouseX - X0L - x
5054  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
5055  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
5056  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
5057  if y1 < Ymin: # clip waveform if going off grid
5058  y1 = Ymin
5059  if y1 > Ymax:
5060  y1 = Ymax
5061  if ZOHold.get() == 1:
5062  TMDVline.append(int(x1))
5063  TMDVline.append(int(ypvmd))
5064  TMDVline.append(int(x1))
5065  TMDVline.append(int(y1))
5066  else:
5067  TMDVline.append(int(x1))
5068  TMDVline.append(int(y1))
5069  ypvmd = y1
5070  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
5071  Xfine = MouseX - X0L - x
5072  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
5073  if ShowC2_I.get() == 1:
5074  ytemp = IBuffB[t]
5075  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
5076  if yi1 < Ymin:
5077  yi1 = Ymin
5078  if yi1 > Ymax:
5079  yi1 = Ymax
5080  if (ZOHold.get() == 1):
5081  T2Iline.append(int(x1))
5082  T2Iline.append(int(ypi2))
5083  T2Iline.append(int(x1))
5084  T2Iline.append(int(yi1))
5085  else:
5086  T2Iline.append(int(x1))
5087  T2Iline.append(int(yi1))
5088  DiY2 = ypi2 - yi1
5089  ypi2 = yi1
5090  if MathTrace.get() > 0:
5091  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
5092  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
5093 
5094  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
5095  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
5096 
5097  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
5098  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
5099 
5100  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
5101  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
5102  ytemp = YIconv1 * (Ypower - CHAIOffset)
5103  y1 = int(c1 - ytemp)
5104 
5105  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
5106  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
5107  ytemp = YIconv2 * (Ypower - CHBIOffset)
5108  y1 = int(c2 - ytemp)
5109 
5110  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
5111  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
5112  ytemp = YIconv1 * (Yohms - CHAIOffset)
5113  y1 = int(c1 - ytemp)
5114 
5115  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
5116  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
5117  ytemp = YIconv2 * (Yohms - CHBIOffset)
5118  y1 = int(c2 - ytemp)
5119 
5120  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
5121  Ydif = (IBuffA[t] - IBuffB[t])# in mA
5122  ytemp = YIconv1 * (Ydif - CHAIOffset)
5123  y1 = int(c2 - ytemp)
5124 
5125  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
5126  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
5127  ytemp = YIconv2 * (Ydif - CHBIOffset)
5128  y1 = int(c2 - ytemp)
5129 
5130  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
5131  try:
5132  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
5133  except:
5134  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
5135 
5136  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
5137  try:
5138  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
5139  except:
5140  Y1 = (IBuffB[t] / 0.000001)
5141  ytemp = YIconv2 * (Y1 - CHBIOffset)
5142  y1 = int(c2 - ytemp)
5143 
5144  elif MathTrace.get() == 12: # plot from equation string
5145  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
5146  try:
5147  MathResult = eval(MathString)
5148  MathResult = MathResult - CHMOffset
5149  y1 = int(c1 - YconvM * MathResult)
5150  except:
5151  RUNstatus.set(0)
5152  x = Xlimit + 1 # exit loop
5153 
5154  if y1 < Ymin: # clip waveform if going off grid
5155  y1 = Ymin
5156  if y1 > Ymax:
5157  y1 = Ymax
5158  if ZOHold.get() == 1: # connet the dots with stair step
5159  Tmathline.append(int(x1))
5160  Tmathline.append(int(ypm))
5161  Tmathline.append(int(x1))
5162  Tmathline.append(int(y1))
5163  else: # connet the dots with single line
5164  Tmathline.append(int(x1))
5165  Tmathline.append(int(y1))
5166  ypm = y1
5167  if Show_MathX.get() > 0:
5168  try:
5169  MathResult = eval(MathXString)
5170  MathResult = MathResult - CHMXOffset
5171  y1 = int(c1 - XconvMxy * MathResult)
5172  except:
5173  RUNstatus.set(0)
5174  x = Xlimit + 1 # exit loop
5175 
5176  if y1 < Ymin: # clip waveform if going off grid
5177  y1 = Ymin
5178  if y1 > Ymax:
5179  y1 = Ymax
5180  if ZOHold.get() == 1: # connet the dots with stair step
5181  TMXline.append(int(x1))
5182  TMXline.append(int(ypmx))
5183  TMXline.append(int(x1))
5184  TMXline.append(int(y1))
5185  else: # connet the dots with single line
5186  TMXline.append(int(x1))
5187  TMXline.append(int(y1))
5188  ypmx = y1
5189  if Show_MathY.get() > 0:
5190  try:
5191  MathResult = eval(MathYString)
5192  MathResult = MathResult - CHMYOffset
5193  y1 = int(c1 - YconvMxy * MathResult)
5194  except:
5195  RUNstatus.set(0)
5196  x = Xlimit + 1 # exit loop
5197 
5198  if y1 < Ymin: # clip waveform if going off grid
5199  y1 = Ymin
5200  if y1 > Ymax:
5201  y1 = Ymax
5202  if ZOHold.get() == 1: # connet the dots with stair step
5203  TMYline.append(int(x1))
5204  TMYline.append(int(ypmy))
5205  TMYline.append(int(x1))
5206  TMYline.append(int(y1))
5207  else: # connet the dots with single line
5208  TMYline.append(int(x1))
5209  TMYline.append(int(y1))
5210  ypmy = y1
5211  # remember trace verticle pixel at X mouse location
5212  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
5213  Xfine = MouseX - X0L - x
5214  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
5215  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
5216  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
5217  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
5218  t = int(t + Tstep)
5219  x = x + Xstep
5220  xa = xa + Xstep
5221 
5222  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
5223  Xstep = 1
5224  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
5225  x1 = 0.0 # x position of trace line
5226  ylo = 0.0 # ymin position of trace 1 line
5227  yhi = 0.0 # ymax position of trace 1 line
5228 
5229  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
5230  if t > len(VBuffA)-1:
5231  t = 0
5232  if t < 0:
5233  t = 0
5234  x = 0 # Horizontal screen pixel
5235  ft = t # time point with fractions
5236  while (x <= GRW):
5237  if (t < TRACEsize):
5238  if (t >= len(VBuffA)):
5239  t = len(VBuffA)-2
5240  x = GRW
5241  x1 = x + X0L
5242  ylo = VBuffA[t] - CHAOffset
5243  ilo = IBuffA[t] - CHAIOffset
5244  yhi = ylo
5245  ihi = ilo
5246  n = t
5247  while n < (t + Tstep) and n < TRACEsize:
5248  if ( ShowC1_V.get() == 1 ):
5249  v = VBuffA[t] - CHAOffset
5250  if v < ylo:
5251  ylo = v
5252  if v > yhi:
5253  yhi = v
5254  if ( ShowC1_I.get() == 1 ):
5255  i = IBuffA[t] - CHAIOffset
5256  if i < ilo:
5257  ilo = i
5258  if i > ihi:
5259  ihi = i
5260  n = n + 1
5261  if ( ShowC1_V.get() == 1 ):
5262  ylo = int(c1 - Yconv1 * ylo)
5263  yhi = int(c1 - Yconv1 * yhi)
5264  if (ylo < Ymin):
5265  ylo = Ymin
5266  if (ylo > Ymax):
5267  ylo = Ymax
5268  if (yhi < Ymin):
5269  yhi = Ymin
5270  if (yhi > Ymax):
5271  yhi = Ymax
5272  T1Vline.append(int(x1))
5273  T1Vline.append(int(ylo))
5274  T1Vline.append(int(x1))
5275  T1Vline.append(int(yhi))
5276  ypv1 = ylo
5277  if ( ShowC1_I.get() == 1 ):
5278  ilo = int(c1 - YIconv1 * ilo)
5279  ihi = int(c1 - YIconv1 * ihi)
5280  if (ilo < Ymin):
5281  ilo = Ymin
5282  if (ilo > Ymax):
5283  ilo = Ymax
5284  if (ihi < Ymin):
5285  ihi = Ymin
5286  if (ihi > Ymax):
5287  ihi = Ymax
5288  T1Iline.append(int(x1))
5289  T1Iline.append(int(ilo))
5290  T1Iline.append(int(x1))
5291  T1Iline.append(int(ihi))
5292  ypi1 = ilo
5293  ylo = VBuffB[t] - CHBOffset
5294  ilo = IBuffB[t] - CHBIOffset
5295  yhi = ylo
5296  ihi = ilo
5297  n = t
5298  if MuxScreenStatus.get() == 0:
5299  while n < (t + Tstep) and n < TRACEsize:
5300  if ( ShowC2_V.get() == 1 ):
5301  v = VBuffB[t] - CHBOffset
5302  if v < ylo:
5303  ylo = v
5304  if v > yhi:
5305  yhi = v
5306  if ( ShowC2_I.get() == 1 ):
5307  i = IBuffB[t] - CHBIOffset
5308  if i < ilo:
5309  ilo = i
5310  if i > ihi:
5311  ihi = i
5312  n = n + 1
5313  if ( ShowC2_V.get() == 1 ):
5314  ylo = int(c2 - Yconv2 * ylo)
5315  yhi = int(c2 - Yconv2 * yhi)
5316  if (ylo < Ymin):
5317  ylo = Ymin
5318  if (ylo > Ymax):
5319  ylo = Ymax
5320 
5321  if (yhi < Ymin):
5322  yhi = Ymin
5323  if (yhi > Ymax):
5324  yhi = Ymax
5325  T2Vline.append(int(x1))
5326  T2Vline.append(int(ylo))
5327  T2Vline.append(int(x1))
5328  T2Vline.append(int(yhi))
5329  ypv2 = ylo
5330  if ( ShowC2_I.get() == 1 ):
5331  ilo = int(c2 - YIconv2 * ilo)
5332  ihi = int(c2 - YIconv2 * 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  T2Iline.append(int(x1))
5342  T2Iline.append(int(ilo))
5343  T2Iline.append(int(x1))
5344  T2Iline.append(int(ihi))
5345  ypi2 = ilo
5346  else:
5347  if Show_CBA.get() == 1 and len(VBuffMA)>4:
5348  if t < len(VBuffMA):
5349  ylo = VBuffMA[t] - CHBAOffset
5350  yhi = ylo
5351  n = t
5352  while n < (t + Tstep) and n < len(VBuffMA):
5353  v = VBuffMA[t] - CHBAOffset
5354  if v < ylo:
5355  ylo = v
5356  if v > yhi:
5357  yhi = v
5358  n = n + 1
5359  ylo = int(c2 - YconvMA * ylo)
5360  yhi = int(c2 - YconvMA * yhi)
5361  if (ylo < Ymin):
5362  ylo = Ymin
5363  if (ylo > Ymax):
5364  ylo = Ymax
5365  if (yhi < Ymin):
5366  yhi = Ymin
5367  if (yhi > Ymax):
5368  yhi = Ymax
5369  TMAVline.append(int(x1))
5370  TMAVline.append(int(ylo))
5371  TMAVline.append(int(x1))
5372  TMAVline.append(int(yhi))
5373  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5374  MouseMuxA = ylo
5375  if Show_CBB.get() == 1 and len(VBuffMB)>4:
5376  if t < len(VBuffMB):
5377  ylo = VBuffMB[t] - CHBBOffset
5378  yhi = ylo
5379  n = t
5380  while n < (t + Tstep) and n < len(VBuffMB):
5381  v = VBuffMB[t] - CHBBOffset
5382  if v < ylo:
5383  ylo = v
5384  if v > yhi:
5385  yhi = v
5386  n = n + 1
5387  ylo = int(c2 - YconvMB * ylo)
5388  yhi = int(c2 - YconvMB * yhi)
5389  if (ylo < Ymin):
5390  ylo = Ymin
5391  if (ylo > Ymax):
5392  ylo = Ymax
5393  if (yhi < Ymin):
5394  yhi = Ymin
5395  if (yhi > Ymax):
5396  yhi = Ymax
5397  TMBVline.append(int(x1))
5398  TMBVline.append(int(ylo))
5399  TMBVline.append(int(x1))
5400  TMBVline.append(int(yhi))
5401  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5402  MouseMuxB = ylo
5403  if Show_CBC.get() == 1 and len(VBuffMC)>4:
5404  if t < len(VBuffMC):
5405  ylo = VBuffMC[t] - CHBCOffset
5406  yhi = ylo
5407  n = t
5408  while n < (t + Tstep) and n < len(VBuffMC):
5409  v = VBuffMC[t] - CHBCOffset
5410  if v < ylo:
5411  ylo = v
5412  if v > yhi:
5413  yhi = v
5414  n = n + 1
5415  ylo = int(c2 - YconvMC * ylo)
5416  yhi = int(c2 - YconvMC * yhi)
5417  if (ylo < Ymin):
5418  ylo = Ymin
5419  if (ylo > Ymax):
5420  ylo = Ymax
5421  if (yhi < Ymin):
5422  yhi = Ymin
5423  if (yhi > Ymax):
5424  yhi = Ymax
5425  TMCVline.append(int(x1))
5426  TMCVline.append(int(ylo))
5427  TMCVline.append(int(x1))
5428  TMCVline.append(int(yhi))
5429  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5430  MouseMuxC = ylo
5431  if Show_CBD.get() == 1 and len(VBuffMD)>4:
5432  if t < len(VBuffMD):
5433  ylo = VBuffMD[t] - CHBDOffset
5434  yhi = ylo
5435  n = t
5436  while n < (t + Tstep) and n < len(VBuffMD):
5437  v = VBuffMD[t] - CHBDOffset
5438  if v < ylo:
5439  ylo = v
5440  if v > yhi:
5441  yhi = v
5442  n = n + 1
5443  ylo = int(c2 - YconvMD * ylo)
5444  yhi = int(c2 - YconvMD * yhi)
5445  if (ylo < Ymin):
5446  ylo = Ymin
5447  if (ylo > Ymax):
5448  ylo = Ymax
5449  if (yhi < Ymin):
5450  yhi = Ymin
5451  if (yhi > Ymax):
5452  yhi = Ymax
5453  TMDVline.append(int(x1))
5454  TMDVline.append(int(ylo))
5455  TMDVline.append(int(x1))
5456  TMDVline.append(int(yhi))
5457  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
5458  MouseMuxD = ylo
5459  if ( ShowC2_I.get() == 1 ):
5460  while n < (t + Tstep) and n < TRACEsize:
5461  i = IBuffB[t] - CHBIOffset
5462  if i < ilo:
5463  ilo = i
5464  if i > ihi:
5465  ihi = i
5466  n = n + 1
5467  ilo = int(c2 - YIconv2 * ilo)
5468  ihi = int(c2 - YIconv2 * ihi)
5469  if (ilo < Ymin):
5470  ilo = Ymin
5471  if (ilo > Ymax):
5472  ilo = Ymax
5473  if (ihi < Ymin):
5474  ihi = Ymin
5475  if (ihi > Ymax):
5476  ihi = Ymax
5477  T2Iline.append(int(x1))
5478  T2Iline.append(int(ilo))
5479  T2Iline.append(int(x1))
5480  T2Iline.append(int(ihi))
5481  if MathTrace.get() > 0:
5482  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
5483  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
5484 
5485  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
5486  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
5487 
5488  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
5489  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
5490 
5491  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
5492  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
5493  ytemp = YIconv1 * (Ypower - CHAIOffset)
5494  y1 = int(c1 - ytemp)
5495 
5496  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
5497  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
5498  ytemp = YIconv2 * (Ypower - CHBIOffset)
5499  y1 = int(c2 - ytemp)
5500 
5501  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
5502  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
5503  ytemp = YIconv1 * (Yohms- CHAIOffset)
5504  y1 = int(c1 - ytemp)
5505 
5506  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
5507  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
5508  ytemp = YIconv2 * (Yohms - CHBIOffset)
5509  y1 = int(c2 - ytemp)
5510 
5511  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
5512  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
5513  ytemp = YIconv1 * (Ydif - CHAIOffset)
5514  y1 = int(c2 - ytemp)
5515 
5516  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
5517  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
5518  ytemp = YIconv2 * (Ydif - CHBIOffset)
5519  y1 = int(c2 - ytemp)
5520 
5521  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
5522  try:
5523  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
5524  except:
5525  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
5526  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
5527  try:
5528  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
5529  except:
5530  Y1 = (IBuffB[t] / 0.000001)
5531  ytemp = YIconv2 * (Y1 - CHBIOffset)
5532  y1 = int(c2 - ytemp)
5533 
5534  elif MathTrace.get() == 12: # plot from equation string
5535  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
5536  try:
5537  MathResult = eval(MathString)
5538  MathResult = MathResult - CHMOffset
5539  y1 = int(c1 - YconvM * MathResult)
5540  except:
5541  RUNstatus.set(0)
5542  x = GRW + 1
5543 
5544  if (y1 < Ymin):
5545  y1 = Ymin
5546  if (y1 > Ymax):
5547  y1 = Ymax
5548  if (ZOHold.get() == 1):
5549  Tmathline.append(int(x1))
5550  Tmathline.append(int(ypm))
5551  Tmathline.append(int(x1))
5552  Tmathline.append(int(y1))
5553  else:
5554  Tmathline.append(int(x1))
5555  Tmathline.append(int(y1))
5556  ypm = y1
5557  if Show_MathX.get() > 0:
5558  try:
5559  MathResult = eval(MathXString)
5560  MathResult = MathResult - CHMXOffset
5561  y1 = int(c1 - XconvMxy * MathResult)
5562  except:
5563  RUNstatus.set(0)
5564  x = GRW + 1
5565 
5566  if y1 < Ymin: # clip waveform if going off grid
5567  y1 = Ymin
5568  if y1 > Ymax:
5569  y1 = Ymax
5570  if ZOHold.get() == 1: # connet the dots with stair step
5571  TMXline.append(int(x1))
5572  TMXline.append(int(ypmx))
5573  TMXline.append(int(x1))
5574  TMXline.append(int(y1))
5575  else: # connet the dots with single line
5576  TMXline.append(int(x1))
5577  TMXline.append(int(y1))
5578  ypmx = y1
5579  if Show_MathY.get() > 0:
5580  try:
5581  MathResult = eval(MathYString)
5582  MathResult = MathResult - CHMYOffset
5583  y1 = int(c1 - YconvMxy * MathResult)
5584  except:
5585  RUNstatus.set(0)
5586  x = GRW + 1
5587 
5588  if y1 < Ymin: # clip waveform if going off grid
5589  y1 = Ymin
5590  if y1 > Ymax:
5591  y1 = Ymax
5592  if ZOHold.get() == 1: # connet the dots with stair step
5593  TMYline.append(int(x1))
5594  TMYline.append(int(ypmy))
5595  TMYline.append(int(x1))
5596  TMYline.append(int(y1))
5597  else: # connet the dots with single line
5598  TMYline.append(int(x1))
5599  TMYline.append(int(y1))
5600  ypmy = y1
5601  ft = ft + Tstep
5602  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
5603  MouseCAV = ypv1
5604  MouseCAI = ypi1
5605  MouseCBV = ypv2
5606  MouseCBI = ypi2
5607  t = int(ft)
5608  if (t > len(VBuffA)):
5609  t = len(VBuffA)-2
5610  x = GRW
5611  x = x + Xstep
5612 
5613  # Make trigger triangle pointer
5614  Triggerline = [] # Trigger pointer
5615  Triggersymbol = [] # Trigger symbol
5616  if TgInput.get() > 0:
5617  if TgInput.get() == 1 : # triggering on CA-V
5618  x1 = X0L
5619  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) # / InGainA
5620  y1 = int(c1 - ytemp)
5621  elif TgInput.get() == 2: # triggering on CA-I
5622  x1 = X0L+GRW
5623  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
5624  elif TgInput.get() == 3: # triggering on CB-V
5625  x1 = X0L
5626  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) # / InGainB
5627  y1 = int(c2 - ytemp)
5628  elif TgInput.get() == 4: # triggering on CB-I
5629  x1 = X0L+GRW
5630  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
5631 
5632  if (y1 < Ymin):
5633  y1 = Ymin
5634  if (y1 > Ymax):
5635  y1 = Ymax
5636  Triggerline.append(int(x1-5))
5637  Triggerline.append(int(y1+5))
5638  Triggerline.append(int(x1+5))
5639  Triggerline.append(int(y1))
5640  Triggerline.append(int(x1-5))
5641  Triggerline.append(int(y1-5))
5642  Triggerline.append(int(x1-5))
5643  Triggerline.append(int(y1+5))
5644  x1 = X0L + (GRW/2)
5645  if TgEdge.get() == 0: # draw rising edge symbol
5646  y1 = -3
5647  y2 = -13
5648  else:
5649  y1 = -13
5650  y2 = -3
5651  Triggersymbol.append(int(x1-10))
5652  Triggersymbol.append(int(Ymin+y1))
5653  Triggersymbol.append(int(x1))
5654  Triggersymbol.append(int(Ymin+y1))
5655  Triggersymbol.append(int(x1))
5656  Triggersymbol.append(int(Ymin+y2))
5657  Triggersymbol.append(int(x1+10))
5658  Triggersymbol.append(int(Ymin+y2))
5659 
5661  global VBuffA, VBuffB, IBuffA, IBuffB
5662  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
5663  global TXYline, MathXString, MathYString, MathXAxis, MathYAxis
5664  global HoldOff, HoldOffentry
5665  global X0LXY, Y0TXY, GRWXY, GRHXY
5666  global YminXY, YmaxXY, XminXY, XmaxXY
5667  global SHOWsamples, ZOHold, AWGBMode
5668  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
5669  global TRACES, TRACESread, RUNstatus
5670  global Xsignal, Ysignal
5671  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
5672  global TMpdiv # Array with time / div values in ms
5673  global TMsb # Time per div spin box variable
5674  global TIMEdiv # current spin box value
5675  global SAMPLErate
5676  global SCstart, MathString
5677  global TRIGGERsample, TRACEsize, DX
5678  global TRIGGERlevel, TRIGGERentry, AutoLevel
5679  global InOffA, InGainA, InOffB, InGainB
5680  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5681  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5682  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
5683  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
5684  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
5685  global HozPoss, HozPossentry
5686 
5687  # Set the TRACEsize variable
5688  if len(VBuffA) < 100:
5689  return
5690  TRACEsize = SHOWsamples # Set the trace length
5691  SCstart = 0
5692  ylo = 0.0
5693  xlo = 0.0
5694  # get the vertical ranges
5695  try:
5696  CH1pdvRange = float(eval(CHAsbxy.get()))
5697  except:
5698  CHAsbxy.delete(0,END)
5699  CHAsbxy.insert(0, CH1vpdvRange)
5700  try:
5701  CH2pdvRange = float(eval(CHBsbxy.get()))
5702  except:
5703  CHBsbxy.delete(0,END)
5704  CHBsbxy.insert(0, CH2vpdvRange)
5705  try:
5706  CH1IpdvRange = float(eval(CHAIsbxy.get()))
5707  except:
5708  CHAIsbxy.delete(0,END)
5709  CHAIsbxy.insert(0, CH1IpdvRange)
5710  try:
5711  CH2IpdvRange = float(eval(CHBIsbxy.get()))
5712  except:
5713  CHBIsbxy.delete(0,END)
5714  CHBIsbxy.insert(0, CH2IpdvRange)
5715  # get the vertical offsets
5716  try:
5717  CHAOffset = float(eval(CHAVPosEntryxy.get()))
5718  except:
5719  CHAVPosEntryxy.delete(0,END)
5720  CHAVPosEntryxy.insert(0, CHAOffset)
5721  try:
5722  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
5723  except:
5724  CHAIPosEntryxy.delete(0,END)
5725  CHAIPosEntryxy.insert(0, CHAIOffset)
5726  try:
5727  CHBOffset = float(eval(CHBVPosEntryxy.get()))
5728  except:
5729  CHBVPosEntry.delete(0,END)
5730  CHBVPosEntry.insert(0, CHBOffset)
5731  try:
5732  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
5733  except:
5734  CHBIPosEntryxy.delete(0,END)
5735  CHBIPosEntryxy.insert(0, CHBIOffset)
5736  # prevent divide by zero error
5737  if CH1pdvRange < 0.001:
5738  CH1pdvRange = 0.001
5739  if CH2pdvRange < 0.001:
5740  CH2pdvRange = 0.001
5741  if CH1IpdvRange < 0.1:
5742  CH1IpdvRange = 0.1
5743  if CH2IpdvRange < 0.1:
5744  CH2IpdvRange = 0.1
5745  #
5746  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
5747  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
5748  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
5749  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
5750  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
5751  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
5752  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
5753  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
5754 
5755  if MathYAxis == "V-A":
5756  YconvMxy = Yconv1
5757  CHMYOffset = CHAOffset
5758  elif MathYAxis == "V-B":
5759  YconvMxy = Yconv2
5760  CHMYOffset = CHBOffset
5761  elif MathYAxis == "I-A":
5762  YconvMxy = YIconv1
5763  CHMYOffset = CHAIOffset
5764  elif MathYAxis == "I-B":
5765  YconvMxy = YIconv2
5766  CHMYOffset = CHBIOffset
5767  else:
5768  YconvMxy = Yconv1
5769  CHMYOffset = CHAOffset
5770  if MathXAxis == "V-A":
5771  XconvMxy = Xconv1
5772  CHMXOffset = CHAOffset
5773  elif MathXAxis == "V-B":
5774  XconvMxy = Xconv2
5775  CHMXOffset = CHBOffset
5776  elif MathYAxis == "I-A":
5777  XconvMxy = XIconv1
5778  CHMXOffset = CHAIOffset
5779  elif MathXAxis == "I-B":
5780  XconvMxy = XIconv2
5781  CHMXOffset = CHBIOffset
5782  else:
5783  XconvMxy = Xconv1
5784  CHMXOffset = CHAOffset
5785  # draw an X/Y plot
5786  TXYline = [] # XY Trace line
5787  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
5788  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
5789  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
5790  while (t < TRACEsize):
5791  if (Xsignal.get() == 3 and Ysignal.get() == 1): # mode CAV/CBV
5792  ylo = VBuffA[t] - CHAOffset
5793  xlo = VBuffB[t] - CHBOffset
5794  ylo = int(c1 - Yconv1 * ylo)
5795  xlo = int(c2 + Xconv2 * xlo)
5796  elif (Xsignal.get() == 1 and Ysignal.get() == 3): # mode CBV/CAV
5797  ylo = VBuffB[t] - CHBOffset
5798  xlo = VBuffA[t] - CHAOffset
5799  ylo = int(c1 - Yconv2 * ylo)
5800  xlo = int(c2 + Xconv1 * xlo)
5801  elif (Xsignal.get() == 5 and Ysignal.get() == 3): # mode CBV/Math
5802  if ( MathTrace.get() == 2): # plot difference of CA-V and CB-V
5803  ylo = VBuffB[t] - CHBOffset
5804  ylo = int(c1 - Yconv2 * ylo)
5805  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
5806  xlo = int(c2 + Xconv1 * xlo)
5807  elif (Xsignal.get() == 5 and Ysignal.get() == 4): # mode CBI/Math
5808  if ( MathTrace.get() == 2): # plot difference of CA-V and CB-V
5809  ylo = (IBuffB[t]) - CHBIOffset
5810  ylo = int(c1 - YIconv2 * ylo)
5811  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
5812  xlo = int(c2 + Xconv1 * xlo)
5813  elif (Xsignal.get() == 5 and Ysignal.get() == 2): # mode CAI/Math
5814  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5815  ylo = (IBuffA[t]) - CHAIOffset
5816  ylo = int(c1 - YIconv1 * ylo)
5817  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
5818  xlo = int(c2 + Xconv2 * xlo)
5819  elif (Xsignal.get() == 3 and Ysignal.get() == 5): # mode Math/CBV
5820  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
5821  ylo = VBuffA[t] - VBuffB[t] - CHAOffset
5822  ylo = int(c1 - Yconv1 * ylo)
5823  xlo = VBuffB[t] - CHBOffset
5824  xlo = int(c2 + Xconv2 * xlo)
5825  elif (Xsignal.get() == 5 and Ysignal.get() == 1): # mode CAV/Math
5826  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5827  ylo = VBuffA[t] - CHAOffset
5828  ylo = int(c1 - Yconv1 * ylo)
5829  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
5830  xlo = int(c2 + Xconv2 * xlo)
5831  elif (Xsignal.get() == 1 and Ysignal.get() == 5): # mode Math/CAV
5832  if MathTrace.get() == 3: # plot difference of CB-V and CA-V
5833  ylo = VBuffB[t] - VBuffA[t] - CHBOffset
5834  ylo = int(c1 - Yconv2 * ylo)
5835  xlo = VBuffA[t] - CHAOffset
5836  xlo = int(c2 + Xconv1 * xlo)
5837  elif (Xsignal.get() == 1 and Ysignal.get() == 2): # mode CAI/CAV
5838  ylo = (IBuffA[t]) - CHAIOffset
5839  xlo = VBuffA[t] - CHAOffset
5840  ylo = int(c1 - YIconv1 * ylo)
5841  xlo = int(c2 + Xconv1 * xlo)
5842  elif (Xsignal.get() == 3 and Ysignal.get() == 2): # mode CAI/CBV
5843  ylo = (IBuffA[t]) - CHAIOffset
5844  xlo = VBuffB[t] - CHBOffset
5845  ylo = int(c1 - YIconv1 * ylo)
5846  xlo = int(c2 + Xconv2 * xlo)
5847  elif (Xsignal.get() == 2 and Ysignal.get() == 1): # mode CAV/CAI
5848  ylo = VBuffA[t] - CHAOffset
5849  xlo = (IBuffA[t]) - CHAIOffset
5850  ylo = int(c1 - Yconv1 * ylo)
5851  xlo = int(c2 + XIconv1 * xlo)
5852  elif (Xsignal.get() == 2 and Ysignal.get() == 3): # mode CBV/CAI
5853  ylo = VBuffB[t] - CHBOffset
5854  xlo = (IBuffA[t]) - CHAIOffset
5855  ylo = int(c1 - Yconv2 * ylo)
5856  xlo = int(c2 + XIconv1 * xlo)
5857  elif (Xsignal.get() == 3 and Ysignal.get() == 4): # mode CBI/CBV
5858  ylo = (IBuffB[t]) - CHBIOffset
5859  xlo = VBuffB[t] - CHBOffset
5860  ylo = int(c1 - YIconv2 * ylo)
5861  xlo = int(c2 + Xconv2 * xlo)
5862  elif (Xsignal.get() == 4 and Ysignal.get() == 3): # mode CBV/CBI
5863  ylo = VBuffB[t] - CHBOffset
5864  xlo = (IBuffB[t]) - CHBIOffset
5865  ylo = int(c1 - Yconv2 * ylo)
5866  xlo = int(c2 + XIconv2 * xlo)
5867  elif (Xsignal.get() == 4 and Ysignal.get() == 2): # mode CAI/CBI
5868  ylo = (IBuffA[t]) - CHAIOffset
5869  xlo = (IBuffB[t]) - CHBIOffset
5870  ylo = int(c1 - YIconv1 * ylo)
5871  xlo = int(c2 + XIconv2 * xlo)
5872  elif (Xsignal.get() == 2 and Ysignal.get() == 4): # mode CBI/CAI
5873  ylo = (IBuffB[t]) - CHBIOffset
5874  xlo = (IBuffA[t]) - CHAIOffset
5875  ylo = int(c1 - YIconv2 * ylo)
5876  xlo = int(c2 + XIconv1 * xlo)
5877  elif (Xsignal.get() == 1 and Ysignal.get() == 4): # mode CBI/CAV
5878  ylo = (IBuffB[t]) - CHBIOffset
5879  xlo = VBuffA[t] - CHAOffset
5880  ylo = int(c1 - YIconv2 * ylo)
5881  xlo = int(c2 + Xconv1 * xlo)
5882  elif (Xsignal.get() == 5 and Ysignal.get() == 5): # mode MathYString/MathXString
5883  try:
5884  MathResult = eval(MathYString)
5885  MathResult = MathResult - CHMYOffset
5886  ylo = int(c1 - YconvMxy * MathResult)
5887  except:
5888  RUNstatus.set(0)
5889  try:
5890  MathResult = eval(MathXString)
5891  MathResult = MathResult - CHMXOffset
5892  xlo = int(c2 + XconvMxy * MathResult)
5893  except:
5894  RUNstatus.set(0)
5895  if ylo < YminXY: # clip waveform if going off grid
5896  ylo = YminXY
5897  if ylo > YmaxXY:
5898  ylo = YmaxXY
5899  if xlo < XminXY: # clip waveform if going off grid
5900  xlo = XminXY
5901  if xlo > XmaxXY:
5902  xlo = XmaxXY
5903  TXYline.append(int(xlo))
5904  TXYline.append(int(ylo))
5905  t = int(t + 1)
5906 
5908  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
5909  global TMXline, TMYline
5910  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
5911  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
5912  global VBuffA, VBuffB, IBuffA, IBuffB
5913  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus
5914  global TMAVline, TMBVline, TMCVline, TMDVline, TMCRline, TMBRline
5915  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
5916  global X0L # Left top X value
5917  global Y0T # Left top Y value
5918  global GRW # Screenwidth
5919  global GRH # Screenheight
5920  global FontSize, EnableHSsampling, ETSDisp
5921  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
5922  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
5923  global ShowXCur, ShowYCur, TCursor, VCursor
5924  global SHOWsamples # Number of samples in data record
5925  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowRXY, Show_MathX, Show_MathY
5926  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
5927  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
5928  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
5929  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
5930  global CHAsb # spinbox Index for channel 1 V
5931  global CHBsb # spinbox Index for channel 2 V
5932  global CHAOffset # Offset value for channel 1 V
5933  global CHBOffset # Offset value for channel 2 V
5934  global CHAIsb # spinbox Index for channel 1 I
5935  global CHBIsb # spinbox Index for channel 2 I
5936  global CHAIOffset # Offset value for channel 1 I
5937  global CHBIOffset # Offset value for channel 2 I
5938  global TMpdiv # Array with time / div values in ms
5939  global TMsb # Time per div spin box variable
5940  global TIMEdiv # current spin box value
5941  global SAMPLErate, contloop, discontloop, HtMulEntry
5942  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
5943  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
5944  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
5945  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
5946  global CANVASwidth, CANVASheight
5947  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
5948  global ScreenTrefresh, SmoothCurves, Is_Triggered
5949  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
5950  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
5951  # Analog Mux channel measurement variables
5952  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
5953  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
5954  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
5955  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
5956  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
5957  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
5958  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
5959  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
5960  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
5961  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
5962  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
5963  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
5964  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
5965  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
5966  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
5967  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
5968  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
5969  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
5970  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
5971  global D0, D1, D2, D3, D4, D5, D6, D7
5972  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
5973  global HozPoss, HozPossentry
5974  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
5975  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
5976  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
5977  #
5978  Ymin = Y0T # Minimum position of time grid (top)
5979  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
5980  try:
5981  InOffA = float(eval(CHAVOffsetEntry.get()))
5982  except:
5983  CHAVOffsetEntry.delete(0,END)
5984  CHAVOffsetEntry.insert(0, InOffA)
5985  try:
5986  InGainA = float(eval(CHAVGainEntry.get()))
5987  except:
5988  CHAVGainEntry.delete(0,END)
5989  CHAVGainEntry.insert(0, InGainA)
5990  try:
5991  InOffB = float(eval(CHBVOffsetEntry.get()))
5992  except:
5993  CHBVOffsetEntry.delete(0,END)
5994  CHBVOffsetEntry.insert(0, InOffB)
5995  try:
5996  InGainB = float(eval(CHBVGainEntry.get()))
5997  except:
5998  CHBVGainEntry.delete(0,END)
5999  CHBVGainEntry.insert(0, InGainB)
6000  # get time scale
6001  try:
6002  TIMEdiv = eval(TMsb.get())
6003  except:
6004  TIMEdiv = 0.5
6005  TMsb.delete(0,"end")
6006  TMsb.insert(0,TIMEdiv)
6007  if TIMEdiv < 0.0002:
6008  TIMEdiv = 0.1
6009  DISsamples = (10.0 * TIMEdiv) # grid width in time
6010  Tstep = DISsamples / GRW # time in mS per pixel
6011  # get the vertical ranges
6012  try:
6013  CH1pdvRange = float(eval(CHAsb.get()))
6014  except:
6015  CHAsb.delete(0,END)
6016  CHAsb.insert(0, CH1vpdvRange)
6017  try:
6018  CH2pdvRange = float(eval(CHBsb.get()))
6019  except:
6020  CHBsb.delete(0,END)
6021  CHBsb.insert(0, CH2vpdvRange)
6022  try:
6023  CH1IpdvRange = float(eval(CHAIsb.get()))
6024  except:
6025  CHAIsb.delete(0,END)
6026  CHAIsb.insert(0, CH1IpdvRange)
6027  try:
6028  CH2IpdvRange = float(eval(CHBIsb.get()))
6029  except:
6030  CHBIsb.delete(0,END)
6031  CHBIsb.insert(0, CH2IpdvRange)
6032  # get the vertical offsets
6033  try:
6034  CHAOffset = float(eval(CHAVPosEntry.get()))
6035  except:
6036  CHAVPosEntry.delete(0,END)
6037  CHAVPosEntry.insert(0, CHAOffset)
6038  try:
6039  CHAIOffset = float(eval(CHAIPosEntry.get()))
6040  except:
6041  CHAIPosEntry.delete(0,END)
6042  CHAIPosEntry.insert(0, CHAIOffset)
6043  try:
6044  CHBOffset = float(eval(CHBVPosEntry.get()))
6045  except:
6046  CHBVPosEntry.delete(0,END)
6047  CHBVPosEntry.insert(0, CHBOffset)
6048  try:
6049  CHBIOffset = float(eval(CHBIPosEntry.get()))
6050  except:
6051  CHBIPosEntry.delete(0,END)
6052  CHBIPosEntry.insert(0, CHBIOffset)
6053  try:
6054  HoldOff = float(eval(HoldOffentry.get()))
6055  if HoldOff < 0:
6056  HoldOff = 0
6057  except:
6058  HoldOffentry.delete(0,END)
6059  HoldOffentry.insert(0, HoldOff)
6060  if ETSDisp.get() > 0:
6061  try:
6062  Mulx = float(eval(HtMulEntry.get()))
6063  if Mulx < 1:
6064  Mulx = 1
6065  except:
6066  Mulx = 1
6067  if EnableHSsampling > 0:
6068  HtMulEntry.delete(0,END)
6069  HtMulEntry.insert(0, 1)
6070  else:
6071  Mulx = 1
6072  # slide trace left right by HozPoss
6073  try:
6074  HozPoss = float(eval(HozPossentry.get()))
6075  except:
6076  HozPossentry.delete(0,END)
6077  HozPossentry.insert(0, HozPoss)
6078  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6079  try:
6080  CHMApdvRange = float(eval(CHB_Asb.get()))
6081  except:
6082  CHB_Asb.delete(0,END)
6083  CHB_Asb.insert(0, CHMApdvRange)
6084  try:
6085  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6086  except:
6087  CHB_Bsb.delete(0,END)
6088  CHB_Bsb.insert(0, CHMBpdvRange)
6089  try:
6090  CHMCpdvRange = float(eval(CHB_Csb.get()))
6091  except:
6092  CHB_Csb.delete(0,END)
6093  CHB_Csb.insert(0, CHMCpdvRange)
6094  try:
6095  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6096  except:
6097  CHB_Dsb.delete(0,END)
6098  CHB_Dsb.insert(0, CHMDpdvRange)
6099  if CHMApdvRange < 0.001:
6100  CHMApdvRange = 0.001
6101  if CHMBpdvRange < 0.001:
6102  CHMBpdvRange = 0.001
6103  if CHMCpdvRange < 0.001:
6104  CHMCpdvRange = 0.001
6105  if CHMDpdvRange < 0.001:
6106  CHMDpdvRange = 0.001
6107  try:
6108  CHBAOffset = float(eval(CHB_APosEntry.get()))
6109  except:
6110  CHB_APosEntry.delete(0,END)
6111  CHB_APosEntry.insert(0, CHBAOffset)
6112  try:
6113  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6114  except:
6115  CHB_BPosEntry.delete(0,END)
6116  CHB_BPosEntry.insert(0, CHBBOffset)
6117  try:
6118  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6119  except:
6120  CHB_CPosEntry.delete(0,END)
6121  CHB_CPosEntry.insert(0, CHBCOffset)
6122  try:
6123  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6124  except:
6125  CHB_DPosEntry.delete(0,END)
6126  CHB_DPosEntry.insert(0, CHBDOffset)
6127  # prevent divide by zero error
6128  if CH1pdvRange < 0.001:
6129  CH1pdvRange = 0.001
6130  if CH2pdvRange < 0.001:
6131  CH2pdvRange = 0.001
6132  if CH1IpdvRange < 0.1:
6133  CH1IpdvRange = 0.1
6134  if CH2IpdvRange < 0.1:
6135  CH2IpdvRange = 0.1
6136  vt = HoldOff + HozPoss # invert sign and scale to mSec
6137  if ScreenTrefresh.get() == 0:
6138  # Delete all items on the screen
6139  ca.delete(ALL) # remove all items
6140  MarkerNum = 0
6141  # Draw horizontal grid lines
6142  i = 0
6143  x1 = X0L
6144  x2 = X0L + GRW
6145  mg_siz = GRW/10.0
6146  mg_inc = mg_siz/5.0
6147  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)
6148  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)
6149  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)
6150  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)
6151  # vertical scale text labels
6152  RightOffset = FontSize * 3
6153  LeftOffset = int(FontSize/2)
6154  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
6155  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
6156  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
6157  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
6158  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
6159  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
6160  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
6161  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
6162  #
6163  while (i < 11):
6164  y = Y0T + i * GRH/10.0
6165  Dline = [x1,y,x2,y]
6166  if i == 5:
6167  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
6168  k = 0
6169  while (k < 10):
6170  l = 1
6171  while (l < 5):
6172  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
6173  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6174  l = l + 1
6175  k = k + 1
6176  else:
6177  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6178 
6179  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
6180  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6181  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
6182  Vaxis_label = str(round(Vaxis_value,3 ))
6183  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
6184 
6185  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
6186  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6187  Iaxis_label = str(round(Iaxis_value, 3))
6188  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
6189 
6190  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
6191  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6192  Vaxis_label = str(round(Vaxis_value, 3))
6193  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
6194 
6195  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
6196  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6197  Iaxis_label = str(round(Iaxis_value, 3))
6198  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
6199  if MuxScreenStatus.get() == 1:
6200  if Show_CBA.get() == 1:
6201  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
6202  Vaxis_label = str(round(Vaxis_value, 3))
6203  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
6204  if Show_CBB.get() == 1:
6205  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
6206  Iaxis_label = str(round(Iaxis_value, 3))
6207  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
6208  if Show_CBC.get() == 1:
6209  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
6210  Iaxis_label = str(round(Iaxis_value, 3))
6211  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
6212  if Show_CBD.get() == 1:
6213  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
6214  Iaxis_label = str(round(Iaxis_value, 3))
6215  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
6216  i = i + 1
6217  # Draw vertical grid lines
6218  i = 0
6219  y1 = Y0T
6220  y2 = Y0T + GRH
6221  mg_siz = GRH/10.0
6222  mg_inc = mg_siz/5.0
6223  vx = TIMEdiv/Mulx
6224  vt = HoldOff/Mulx # invert sign and scale to mSec
6225  # vx = TIMEdiv
6226  while (i < 11):
6227  x = X0L + i * GRW/10.0
6228  Dline = [x,y1,x,y2]
6229  if (i == 5):
6230  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
6231  k = 0
6232  while (k < 10):
6233  l = 1
6234  while (l < 5):
6235  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
6236  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6237  l = l + 1
6238  k = k + 1
6239  #
6240  if vx >= 1000:
6241  axis_value = ((i * vx)+ vt) / 1000.0
6242  axis_label = str(int(axis_value)) + " S"
6243  if vx < 1000 and vx >= 1:
6244  axis_value = (i * vx) + vt
6245  axis_label = str(int(axis_value)) + " mS"
6246  if vx < 1:
6247  axis_value = ((i * vx) + vt) * 1000.0
6248  axis_label = str(int(axis_value)) + " uS"
6249  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
6250  else:
6251  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6252  if vx >= 1000:
6253  axis_value = ((i * vx)+ vt) / 1000.0
6254  axis_label = str(int(axis_value)) + " S"
6255  if vx < 1000 and vx >= 1:
6256  axis_value = (i * vx) + vt
6257  axis_label = str(int(axis_value)) + " mS"
6258  if vx < 1:
6259  axis_value = ((i * vx) + vt) * 1000.0
6260  axis_label = str(int(axis_value)) + " uS"
6261  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
6262 
6263  i = i + 1
6264  # Write the trigger line if available
6265  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
6266  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
6267  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
6268  if TgInput.get() == 1:
6269  TgLabel = "CA-V"
6270  if TgInput.get() == 2:
6271  TgLabel = "CA-I"
6272  if TgInput.get() == 3:
6273  TgLabel = "CB-V"
6274  if TgInput.get() == 4:
6275  TgLabel = "CB-I"
6276  if Is_Triggered == 1:
6277  TgLabel = TgLabel + " Triggered"
6278  else:
6279  TgLabel = TgLabel + " Not Triggered"
6280  if SingleShot.get() > 0:
6281  TgLabel = TgLabel + " Armed"
6282  x = X0L + (GRW/2) + 12
6283  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
6284  # Draw T - V Cursor lines if required
6285  if MarkerScale.get() == 0:
6286  Yconv1 = float(GRH/10.0) / CH1pdvRange
6287  Yoffset1 = CHAOffset
6288  COLORmarker = COLORtrace1
6289  Units = " V"
6290  if MarkerScale.get() == 1:
6291  MouseY = MouseCAV
6292  Yconv1 = float(GRH/10.0) / CH1pdvRange
6293  Yoffset1 = CHAOffset
6294  COLORmarker = COLORtrace1
6295  Units = " V"
6296  if MarkerScale.get() == 2:
6297  MouseY = MouseCBV
6298  Yconv1 = float(GRH/10.0) / CH2pdvRange
6299  Yoffset1 = CHBOffset
6300  COLORmarker = COLORtrace2
6301  Units = " V"
6302  if MarkerScale.get() == 3:
6303  MouseY = MouseCAI
6304  Yconv1 = float(GRH/10.0) / CH1IpdvRange
6305  Yoffset1 = CHAIOffset
6306  COLORmarker = COLORtrace3
6307  Units = " mA"
6308  if MarkerScale.get() == 4:
6309  MouseY = MouseCBI
6310  Yconv1 = float(GRH/10.0) / CH2IpdvRange
6311  Yoffset1 = CHBIOffset
6312  COLORmarker = COLORtrace4
6313  Units = " mA"
6314  # Analog Mux settings
6315  if MarkerScale.get() == 5:
6316  MouseY = MouseMuxA
6317  Yconv1 = float(GRH/10.0) / CHMApdvRange
6318  Yoffset1 = CHBAOffset
6319  COLORmarker = COLORtrace2
6320  Units = " V"
6321  if MarkerScale.get() == 6:
6322  MouseY = MouseMuxB
6323  Yconv1 = float(GRH/10.0) / CHMBpdvRange
6324  Yoffset1 = CHBBOffset
6325  COLORmarker = COLORtrace6
6326  Units = " V"
6327  if MarkerScale.get() == 7:
6328  MouseY = MouseMuxC
6329  Yconv1 = float(GRH/10.0) / CHMCpdvRange
6330  Yoffset1 = CHBCOffset
6331  COLORmarker = COLORtrace7
6332  Units = " V"
6333  if MarkerScale.get() == 8:
6334  MouseY = MouseMuxD
6335  Yconv1 = float(GRH/10.0) / CHMDpdvRange
6336  Yoffset1 = CHBDOffset
6337  COLORmarker = COLORtrace4
6338  Units = " V"
6339 #
6340  if ShowTCur.get() > 0:
6341  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
6342  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6343  Tpoint = ((TCursor-X0L) * Tstep) + vt
6344  Tpoint = Tpoint/Mulx
6345  if Tpoint >= 1000:
6346  axis_value = Tpoint / 1000.0
6347  V_label = str(int(axis_value)) + " S"
6348  if Tpoint < 1000 and vx >= 1:
6349  axis_value = Tpoint
6350  V_label = str(int(axis_value)) + " mS"
6351  if Tpoint < 1:
6352  axis_value = Tpoint * 1000.0
6353  V_label = str(int(axis_value)) + " uS"
6354  ca.create_text(TCursor+1, VCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
6355  if ShowVCur.get() > 0:
6356  Dline = [X0L, VCursor, X0L+GRW, VCursor]
6357  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
6358  c1 = GRH / 2 + Y0T # fixed Y correction
6359  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
6360  V1String = ' {0:.3f} '.format(-yvolts)
6361  V_label = V1String + Units
6362  ca.create_text(TCursor+1, VCursor+5, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
6363  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
6364  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
6365  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
6366  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6367  Tpoint = ((MouseX-X0L) * Tstep) + vt
6368  Tpoint = Tpoint/Mulx
6369  if Tpoint >= 1000:
6370  axis_value = Tpoint / 1000.0
6371  V_label = str(int(axis_value)) + " S"
6372  if Tpoint < 1000 and Tpoint >= 1:
6373  axis_value = Tpoint
6374  V_label = str(int(axis_value)) + " mS"
6375  if Tpoint < 1:
6376  axis_value = Tpoint * 1000.0
6377  V_label = str(int(axis_value)) + " uS"
6378  ca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
6379  Dline = [X0L, MouseY, X0L+GRW, MouseY]
6380  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
6381  c1 = GRH / 2 + Y0T # fixed Y correction
6382  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
6383  V1String = ' {0:.3f} '.format(-yvolts)
6384  V_label = V1String + Units
6385  ca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
6386 #
6387  if MeasGateStatus.get() == 1:
6388  LeftGate = X0L + MeasGateLeft / Tstep
6389  RightGate = X0L + MeasGateRight / Tstep
6390  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), fill=COLORtrace5)
6391  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), fill=COLORtrace7)
6392 #
6393  SmoothBool = SmoothCurves.get()
6394  # Write the traces if available
6395  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
6396  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
6397  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
6398  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
6399  if len(T2Vline) > 4: # Write the trace 2 if active
6400  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6401  if len(T2Iline) > 4:
6402  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6403  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
6404  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6405  if len(TMXline) > 4 : # Write X Math tace if active
6406  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6407  if len(TMYline) > 4 : # Write Y Math tace if active
6408  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6409  if MuxScreenStatus.get() == 1:
6410  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
6411  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6412  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
6413  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6414  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
6415  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6416  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
6417  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6418  if ShowRB_V.get() == 1 and len(TMBRline) > 4:
6419  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6420  if ShowRB_I.get() == 1 and len(TMCRline) > 4:
6421  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6422  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
6423  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6424  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
6425  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6426  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
6427  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6428  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
6429  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6430  if ShowMath.get() == 1 and len(TMRline) > 4:
6431  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
6432 
6433  # General information on top of the grid
6434  # Sweep information
6435  if session.continuous:
6436  sttxt = "Running Continuous"
6437  else:
6438  sttxt = "Running Discontinuous"
6439  if TRACEmodeTime.get() == 1:
6440  sttxt = sttxt + " Averaging"
6441  if ManualTrigger.get() == 1:
6442  sttxt = "Manual Trigger"
6443  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
6444  sttxt = "Stopped"
6445  if ScreenTrefresh.get() == 1:
6446  sttxt = sttxt + " Persistance ON"
6447  # Delete text at bottom of screen
6448  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
6449  for n in de:
6450  ca.delete(n)
6451  # Delete text at top of screen
6452  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
6453  for n in de:
6454  ca.delete(n)
6455  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
6456  x = X0L+2
6457  y = 12
6458  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6459  # digital I/O indicators
6460  x2 = X0L + GRW
6461  BoxColor = "#808080" # gray
6462  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
6463  if D0.get() == 0 and D4.get() == 0:
6464  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
6465  if Dval[0] == 1:
6466  BoxColor = "#00ff00" # 100% green
6467  elif Dval[0] == 0:
6468  BoxColor = "#ff0000" # 100% red
6469  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
6470  else:
6471  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
6472  if D1.get() == 0 and D5.get() == 0:
6473  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
6474  if Dval[0] == 1:
6475  BoxColor = "#00ff00" # 100% green
6476  elif Dval[0] == 0:
6477  BoxColor = "#ff0000" # 100% red
6478  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
6479  else:
6480  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
6481  if D2.get() == 0 and D6.get() == 0:
6482  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
6483  if Dval[0] == 1:
6484  BoxColor = "#00ff00" # 100% green
6485  elif Dval[0] == 0:
6486  BoxColor = "#ff0000" # 100% red
6487  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
6488  else:
6489  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
6490  if D3.get() == 0 and D7.get() == 0:
6491  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
6492  if Dval[0] == 1:
6493  BoxColor = "#00ff00" # 100% green
6494  elif Dval[0] == 0:
6495  BoxColor = "#ff0000" # 100% red
6496  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
6497  else:
6498  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
6499  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
6500  # Time sweep information and view at information
6501  vx = TIMEdiv/Mulx
6502  if vx >= 1000:
6503  txt = str(int(vx/1000.0)) + " S/div"
6504  if vx < 1000 and vx >= 1:
6505  txt = str(int(vx)) + " mS/div"
6506  if vx < 1:
6507  txt = str(int(vx * 1000.0)) + " uS/div"
6508 
6509  txt = txt + " "
6510  #
6511  txt = txt + "View at "
6512  if abs(vt) >= 1000:
6513  txt = txt + str(int(vt / 1000.0)) + " S "
6514  if abs(vt) < 1000 and abs(vt) >= 1:
6515  txt = txt + str(int(vt)) + " mS "
6516  if abs(vt) < 1:
6517  txt = txt + str(int(vt * 1000.0)) + " uS "
6518  # print period and frequency of displayed channels
6519  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
6520  FindRisingEdge(VBuffA,VBuffB)
6521  if ShowC1_V.get() == 1:
6522  if MeasAHW.get() == 1:
6523  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
6524  if MeasALW.get() == 1:
6525  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
6526  if MeasADCy.get() == 1:
6527  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
6528  if MeasAPER.get() == 1:
6529  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
6530  if MeasAFREQ.get() == 1:
6531  txt = txt + " CA Freq = "
6532  ChaF = CHAfreq*Mulx
6533  if ChaF < 1000:
6534  V1String = ' {0:.1f} '.format(ChaF)
6535  txt = txt + str(V1String) + " Hz "
6536  if ChaF > 1000 and ChaF < 1000000:
6537  V1String = ' {0:.1f} '.format(ChaF/1000)
6538  txt = txt + str(V1String) + " KHz "
6539  if ChaF > 1000000:
6540  V1String = ' {0:.1f} '.format(ChaF/1000000)
6541  txt = txt + str(V1String) + " MHz "
6542  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
6543  if ShowC2_V.get() == 1:
6544  if MeasBHW.get() == 1:
6545  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
6546  if MeasBLW.get() == 1:
6547  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
6548  if MeasBDCy.get() == 1:
6549  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
6550  if MeasBPER.get() == 1:
6551  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
6552  if MeasBFREQ.get() == 1:
6553  txt = txt + " CB Freq = "
6554  ChaF = CHBfreq*Mulx
6555  if ChaF < 1000:
6556  V1String = ' {0:.1f} '.format(ChaF)
6557  txt = txt + str(V1String) + " Hz "
6558  if ChaF > 1000 and ChaF < 1000000:
6559  V1String = ' {0:.1f} '.format(ChaF/1000)
6560  txt = txt + str(V1String) + " KHz "
6561  if ChaF > 1000000:
6562  V1String = ' {0:.1f} '.format(ChaF/1000000)
6563  txt = txt + str(V1String) + " MHz "
6564  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
6565  if MuxScreenStatus.get() == 0:
6566  if MeasPhase.get() == 1:
6567  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
6568  if MeasDelay.get() == 1:
6569  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
6570 
6571  x = X0L
6572  y = Y0T+GRH+int(2.5 *FontSize) # 20
6573  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6574  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
6575  MakeHistogram()
6576  txt = " "
6577  if ShowC1_V.get() == 1:
6578  # Channel A information
6579  if CHA_RC_HP.get() == 1:
6580  txt = "CHA: HP "
6581  else:
6582  txt = "CHA: "
6583  txt = txt + str(CH1pdvRange) + " V/div"
6584  if MeasDCV1.get() == 1:
6585  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
6586  if MeasMaxV1.get() == 1:
6587  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
6588  if MeasTopV1.get() == 1:
6589  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
6590  if MeasMinV1.get() == 1:
6591  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
6592  if MeasBaseV1.get() == 1:
6593  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
6594  if MeasMidV1.get() == 1:
6595  MidV1 = (MaxV1+MinV1)/2.0
6596  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
6597  if MeasPPV1.get() == 1:
6598  PPV1 = MaxV1-MinV1
6599  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
6600  if MeasRMSV1.get() == 1:
6601  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
6602  if MeasRMSVA_B.get() == 1:
6603  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
6604  if MeasDiffAB.get() == 1:
6605  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
6606  if MeasUserA.get() == 1:
6607  try:
6608  TempValue = eval(UserAString)
6609  V1String = ' {0:.4f} '.format(TempValue)
6610  except:
6611  V1String = "####"
6612  txt = txt + UserALabel + " = " + V1String
6613  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
6614  txt = "CHA: "
6615  txt = txt + str(CH1IpdvRange) + " mA/div"
6616  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
6617  txt = txt + "CHA: "
6618  txt = txt + str(CH1IpdvRange) + " mA/div"
6619  if ShowC1_I.get() == 1:
6620  if MeasDCI1.get() == 1:
6621  V1String = ' {0:.2f} '.format(DCI1)
6622  txt = txt + " AvgI = " + V1String
6623  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
6624  try:
6625  Resvalue = (DCV1/DCI1)*1000
6626  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
6627  except:
6628  txt = txt + " Res = OverRange"
6629  if MeasMaxI1.get() == 1:
6630  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
6631  if MeasMinI1.get() == 1:
6632  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
6633  if MeasMidI1.get() == 1:
6634  MidI1 = (MaxI1+MinI1)/2.0
6635  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
6636  if MeasPPI1.get() == 1:
6637  PPI1 = MaxI1-MinI1
6638  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
6639  if MeasRMSI1.get() == 1:
6640  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
6641 
6642  x = X0L
6643  y = Y0T+GRH+(4*FontSize) # 32
6644  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6645  txt= " "
6646  # Channel B information
6647  if MuxScreenStatus.get() == 1:
6648  txt = "CHB-Mux: "
6649  if Show_CBA.get() > 0:
6650  FindRisingEdge(VBuffA,VBuffMA)
6651  elif Show_CBB.get() > 0:
6652  FindRisingEdge(VBuffA,VBuffMB)
6653  elif Show_CBC.get() > 0:
6654  FindRisingEdge(VBuffA,VBuffMC)
6655  elif Show_CBD.get() > 0:
6656  FindRisingEdge(VBuffA,VBuffMD)
6657  if MeasPhase.get() == 1:
6658  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
6659  if MeasDelay.get() == 1:
6660  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
6661  if MeasUserB.get() == 1:
6662  try:
6663  TempValue = eval(UserBString)
6664  V1String = ' {0:.4f} '.format(TempValue)
6665  except:
6666  V1String = "####"
6667  txt = txt + UserBLabel + " = " + V1String
6668  if ShowC2_V.get() == 1:
6669  if CHB_RC_HP.get() == 1:
6670  txt = "CHB: HP "
6671  else:
6672  txt = "CHB: "
6673  txt = txt + str(CH2pdvRange) + " V/div"
6674  if MeasDCV2.get() == 1:
6675  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
6676  if MeasMaxV2.get() == 1:
6677  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
6678  if MeasTopV2.get() == 1:
6679  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
6680  if MeasMinV2.get() == 1:
6681  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
6682  if MeasBaseV2.get() == 1:
6683  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
6684  if MeasMidV2.get() == 1:
6685  MidV2 = (MaxV2+MinV2)/2.0
6686  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
6687  if MeasPPV2.get() == 1:
6688  PPV2 = MaxV2-MinV2
6689  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
6690  if MeasRMSV2.get() == 1:
6691  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
6692  if MeasDiffBA.get() == 1:
6693  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
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_I.get() == 1 and ShowC2_V.get() == 0):
6702  txt = "CHB: "
6703  txt = txt + str(CH2IpdvRange) + " mA/div"
6704  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
6705  txt = txt + "CHB: "
6706  txt = txt + str(CH2IpdvRange) + " mA/div"
6707  if ShowC2_I.get() == 1:
6708  if MeasDCI2.get() == 1:
6709  V1String = ' {0:.2f} '.format(DCI2)
6710  txt = txt + " AvgI = " + V1String
6711  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
6712  try:
6713  Resvalue = (DCV2/DCI2)*1000
6714  R1String = ' {0:.1f} '.format(Resvalue)
6715  txt = txt + " Res = " + R1String
6716  except:
6717  txt = txt + " Res = OverRange"
6718  if MeasMaxI2.get() == 1:
6719  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
6720  if MeasMinI2.get() == 1:
6721  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
6722  if MeasMidI2.get() == 1:
6723  MidI2 = (MaxI2+MinI2)/2.0
6724  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
6725  if MeasPPI2.get() == 1:
6726  PPI2 = MaxI2-MinI2
6727  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
6728  if MeasRMSI2.get() == 1:
6729  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
6730 
6731  x = X0L
6732  y = Y0T+GRH+int(5.5*FontSize) # 44
6733  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
6734 
6736  global TXYline # active trave lines
6737  global Tmathline, TMRline, TXYRline
6738  global X0LXY # Left top X value
6739  global Y0TXY # Left top Y value
6740  global GRWXY # Screenwidth
6741  global GRHXY # Screenheight
6742  global FontSize
6743  global XYca, MouseX, MouseY, MouseWidget
6744  global ShowXCur, ShowYCur, XCursor, YCursor
6745  global SHOWsamples # Number of samples in data record
6746  global ShowRXY, ShowMath, MathUnits, MathXUnits, MathYUnits
6747  global Xsignal, Ysignal, MathXAxis, MathYAxis
6748  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
6749  global CHAsbxy # spinbox Index for channel 1 V
6750  global CHBsbxy # spinbox Index for channel 2 V
6751  global CHAOffset # Offset value for channel 1 V
6752  global CHBOffset # Offset value for channel 2 V
6753  global CHAIsbxy # spinbox Index for channel 1 I
6754  global CHBIsbxy # spinbox Index for channel 2 I
6755  global CHAIOffset # Offset value for channel 1 I
6756  global CHBIOffset # Offset value for channel 2 I
6757  global TMpdiv # Array with time / div values in ms
6758  global TMsb # Time per div spin box variable
6759  global TIMEdiv # current spin box value
6760  global SAMPLErate
6761  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
6762  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7 # The colors
6763  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
6764  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5
6765  global CANVASwidthXY, CANVASheightXY
6766  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
6767  global ScreenXYrefresh, SmoothCurves
6768  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
6769  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
6770  global SV1, SI1, SV2, SI2, CHABphase
6771  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
6772  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
6773  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
6774  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
6775  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
6776  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
6777  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
6778  global AWGAShape, AWGBShape
6779  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6780  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6781  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
6782  global DacScreenStatus, DigScreenStatus
6783  global D0, D1, D2, D3, D4, D5, D6, D7
6784  global DevID, devx, MarkerNum, MarkerScale
6785  global HozPoss, HozPossentry
6786  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
6787  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
6788  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
6789  #
6790  Ymin = Y0TXY # Minimum position of screen grid (top)
6791  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
6792  try:
6793  InOffA = float(eval(CHAVOffsetEntry.get()))
6794  except:
6795  CHAVOffsetEntry.delete(0,END)
6796  CHAVOffsetEntry.insert(0, InOffA)
6797  try:
6798  InGainA = float(eval(CHAVGainEntry.get()))
6799  except:
6800  CHAVGainEntry.delete(0,END)
6801  CHAVGainEntry.insert(0, InGainA)
6802  try:
6803  InOffB = float(eval(CHBVOffsetEntry.get()))
6804  except:
6805  CHBVOffsetEntry.delete(0,END)
6806  CHBVOffsetEntry.insert(0, InOffB)
6807  try:
6808  InGainB = float(eval(CHBVGainEntry.get()))
6809  except:
6810  CHBVGainEntry.delete(0,END)
6811  CHBVGainEntry.insert(0, InGainB)
6812 #
6813  try:
6814  CH1pdvRange = float(eval(CHAsbxy.get()))
6815  except:
6816  CHAsbxy.delete(0,END)
6817  CHAsbxy.insert(0, CH1vpdvRange)
6818  try:
6819  CH2pdvRange = float(eval(CHBsbxy.get()))
6820  except:
6821  CHBsbxy.delete(0,END)
6822  CHBsbxy.insert(0, CH2vpdvRange)
6823  try:
6824  CH1IpdvRange = float(eval(CHAIsbxy.get()))
6825  except:
6826  CHAIsbxy.delete(0,END)
6827  CHAIsbxy.insert(0, CH1IpdvRange)
6828  try:
6829  CH2IpdvRange = float(eval(CHBIsbxy.get()))
6830  except:
6831  CHBIsbxy.delete(0,END)
6832  CHBIsbxy.insert(0, CH2IpdvRange)
6833  # get the vertical offsets
6834  try:
6835  CHAOffset = float(eval(CHAVPosEntryxy.get()))
6836  except:
6837  CHAVPosEntryxy.delete(0,END)
6838  CHAVPosEntryxy.insert(0, CHAOffset)
6839  try:
6840  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
6841  except:
6842  CHAIPosEntryxy.delete(0,END)
6843  CHAIPosEntryxy.insert(0, CHAIOffset)
6844  try:
6845  CHBOffset = float(eval(CHBVPosEntryxy.get()))
6846  except:
6847  CHBVPosEntry.delete(0,END)
6848  CHBVPosEntry.insert(0, CHBOffset)
6849  try:
6850  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
6851  except:
6852  CHBIPosEntryxy.delete(0,END)
6853  CHBIPosEntryxy.insert(0, CHBIOffset)
6854  # prevent divide by zero error
6855  if CH1pdvRange < 0.001:
6856  CH1pdvRange = 0.001
6857  if CH2pdvRange < 0.001:
6858  CH2pdvRange = 0.001
6859  if CH1IpdvRange < 0.05:
6860  CH1IpdvRange = 0.05
6861  if CH2IpdvRange < 0.05:
6862  CH2IpdvRange = 0.05
6863  # If drawing histograms adjust offset based on range such that bottom grid is zero
6864  if Xsignal.get() == 6:
6865  CHAIOffset = 5 * CH1IpdvRange
6866  if Xsignal.get() == 7:
6867  CHBIOffset = 5 * CH2IpdvRange
6868  if ScreenXYrefresh.get() == 0:
6869  # Delete all items on the screen
6870  MarkerNum = 0
6871  XYca.delete(ALL) # remove all items
6872  # Draw horizontal grid lines
6873  i = 0
6874  x1 = X0LXY
6875  x2 = X0LXY + GRWXY
6876  mg_siz = GRWXY/10.0
6877  mg_inc = mg_siz/5.0
6878  while (i < 11):
6879  y = Y0TXY + i * GRHXY/10.0
6880  Dline = [x1,y,x2,y]
6881  if i == 5:
6882  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
6883  k = 0
6884  while (k < 10):
6885  l = 1
6886  while (l < 5):
6887  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
6888  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6889  l = l + 1
6890  k = k + 1
6891  else:
6892  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6893  if Ysignal.get() == 2 or Xsignal.get() == 6:
6894  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6895  Iaxis_label = str(round(Iaxis_value, 3))
6896  XYca.create_text(x1-3, y, text=Iaxis_label, fill=COLORtrace3, anchor="e", font=("arial", FontSize ))
6897  elif Ysignal.get() == 4 or Xsignal.get() == 7:
6898  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6899  Iaxis_label = str(round(Iaxis_value, 3))
6900  XYca.create_text(x1-3, y, text=Iaxis_label, fill=COLORtrace4, anchor="e", font=("arial", FontSize ))
6901  elif Ysignal.get() == 1:
6902  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6903  Vaxis_label = str(round(Vaxis_value, 3))
6904  XYca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
6905  elif Ysignal.get() == 3:
6906  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6907  Vaxis_label = str(round(Vaxis_value, 3))
6908  XYca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
6909  elif Ysignal.get() == 5:
6910  TempCOLOR = COLORtrace5
6911  if MathTrace.get() == 2:
6912  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6913  elif MathTrace.get() == 3:
6914  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6915  else:
6916  if MathYAxis == "V-A":
6917  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6918  TempCOLOR = COLORtrace1
6919  elif MathYAxis == "V-B":
6920  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
6921  TempCOLOR = COLORtrace2
6922  elif MathYAxis == "I-A":
6923  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
6924  TempCOLOR = COLORtrace3
6925  elif MathYAxis == "I-B":
6926  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
6927  TempCOLOR = COLORtrace4
6928  else:
6929  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
6930  Vaxis_label = str(round(Vaxis_value, 3))
6931  XYca.create_text(x1-3, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
6932  i = i + 1
6933  # Draw vertical grid lines
6934  i = 0
6935  y1 = Y0TXY
6936  y2 = Y0TXY + GRHXY
6937  mg_siz = GRHXY/10.0
6938  mg_inc = mg_siz/5.0
6939  #
6940  while (i < 11):
6941  x = X0LXY + i * GRWXY/10.0
6942  Dline = [x,y1,x,y2]
6943  if (i == 5):
6944  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
6945  k = 0
6946  while (k < 10):
6947  l = 1
6948  while (l < 5):
6949  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
6950  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6951  l = l + 1
6952  k = k + 1
6953  if Xsignal.get() == 1 or Xsignal.get() == 6: #
6954  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
6955  Vaxis_label = str(round(Vaxis_value, 3))
6956  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
6957  elif Xsignal.get() == 3 or Xsignal.get() == 7:
6958  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
6959  Vaxis_label = str(round(Vaxis_value, 3))
6960  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
6961  elif Xsignal.get() == 2:
6962  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
6963  Iaxis_label = str(round(Iaxis_value, 3))
6964  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
6965  elif Xsignal.get() == 4:
6966  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
6967  Iaxis_label = str(round(Iaxis_value, 3))
6968  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
6969  elif Xsignal.get() == 5:
6970  TempCOLOR = COLORtrace5
6971  if MathTrace.get() == 2:
6972  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
6973  elif MathTrace.get() == 3:
6974  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
6975  else:
6976  if MathXAxis == "V-A":
6977  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
6978  TempCOLOR = COLORtrace1
6979  elif MathXAxis == "V-B":
6980  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
6981  TempCOLOR = COLORtrace2
6982  elif MathXAxis == "I-A":
6983  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
6984  TempCOLOR = COLORtrace3
6985  elif MathXAxis == "I-B":
6986  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
6987  TempCOLOR = COLORtrace4
6988  else:
6989  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
6990  TempCOLOR = COLORtrace5
6991  Vaxis_label = str(round(Vaxis_value, 3))
6992  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
6993  else:
6994  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
6995  if Xsignal.get() == 1 or Xsignal.get() == 6:
6996  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
6997  Vaxis_label = str(round(Vaxis_value, 3))
6998  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
6999  elif Xsignal.get() == 3 or Xsignal.get() == 7:
7000  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7001  Vaxis_label = str(round(Vaxis_value, 3))
7002  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
7003  elif Xsignal.get() == 2:
7004  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7005  Iaxis_label = str(round(Iaxis_value, 3))
7006  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
7007  elif Xsignal.get() == 4:
7008  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7009  Iaxis_label = str(round(Iaxis_value, 3))
7010  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
7011  elif Xsignal.get() == 5:
7012  TempCOLOR = COLORtrace5
7013  if MathTrace.get() == 2:
7014  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7015  elif MathTrace.get() == 3:
7016  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7017  else:
7018  if MathXAxis == "V-A":
7019  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7020  TempCOLOR = COLORtrace1
7021  elif MathXAxis == "V-B":
7022  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
7023  TempCOLOR = COLORtrace2
7024  elif MathXAxis == "I-A":
7025  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
7026  TempCOLOR = COLORtrace3
7027  elif MathXAxis == "I-B":
7028  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
7029  TempCOLOR = COLORtrace4
7030  else:
7031  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
7032  Vaxis_label = str(round(Vaxis_value, 3))
7033  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
7034  i = i + 1
7035 # Draw traces
7036  if len(TXYline) > 4: # Avoid writing lines with 1 coordinate
7037  if Xsignal.get() == 1:
7038  XYca.create_line(TXYline, fill=COLORtrace1, width=TRACEwidth.get())
7039  elif Xsignal.get() == 2:
7040  XYca.create_line(TXYline, fill=COLORtrace3, width=TRACEwidth.get())
7041  elif Xsignal.get() == 3:
7042  XYca.create_line(TXYline, fill=COLORtrace2, width=TRACEwidth.get())
7043  elif Xsignal.get() == 4:
7044  XYca.create_line(TXYline, fill=COLORtrace4, width=TRACEwidth.get())
7045  elif Xsignal.get() == 5 or Ysignal.get() == 5:
7046  XYca.create_line(TXYline, fill=COLORtrace5, width=TRACEwidth.get())
7047  if len(TXYRline) > 4 and ShowRXY.get() == 1:
7048  XYca.create_line(TXYRline, fill=COLORtraceR1, width=TRACEwidth.get())
7049 # Draw Histogram Traces
7050  if Xsignal.get() == 6:
7051  MakeHistogram()
7052  b = 0
7053  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7054  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
7055  y1 = Y0TXY + GRHXY
7056  # print Yconv1, y1
7057  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7058  while b < 4999: #
7059  if HistAsPercent == 1: # convert to percent of total sample count
7060  ylo = float(HBuffA[0][b]) / len(VBuffA)
7061  ylo = ylo * 100.0
7062  else:
7063  ylo = HBuffA[0][b] #
7064  ylo = int(y1 - (Yconv1 * ylo))
7065  if ylo > Ymax:
7066  ylo = Ymax
7067  if ylo < Ymin:
7068  ylo = Ymin
7069  xlo = HBuffA[1][b] - CHAOffset
7070  xlo = int(c2 + Xconv1 * xlo)
7071  Dline = [xlo,y1,xlo,ylo]
7072  XYca.create_line(Dline, fill=COLORtrace1)
7073  b = b + 1
7074  if Xsignal.get() == 7:
7075  MakeHistogram()
7076  b = 0
7077  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7078  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
7079  y1 = Y0TXY + GRHXY
7080  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7081  while b < 4999: #
7082  if HistAsPercent == 1: # convert to percent
7083  ylo = float(HBuffB[0][b]) / len(VBuffB)
7084  ylo = ylo * 100.0
7085  else:
7086  ylo = HBuffB[0][b]
7087  ylo = int(y1 - Yconv1 * ylo)
7088  if ylo > Ymax:
7089  ylo = Ymax
7090  if ylo < Ymin:
7091  ylo = Ymin
7092  xlo = HBuffB[1][b] - CHBOffset
7093  xlo = int(c2 + Xconv1 * xlo)
7094  Dline = [xlo,y1,xlo,ylo]
7095  XYca.create_line(Dline, fill=COLORtrace2)
7096  b = b + 1
7097 # Draw X - Y Cursor lines if required
7098  if Xsignal.get() == 1 or Xsignal.get() == 6:
7099  Xconv1 = float(GRWXY/10) / CH1pdvRange
7100  Xoffset1 = CHAOffset
7101  COLORXmarker = COLORtrace1
7102  X_label = " V"
7103  if Xsignal.get() == 2:
7104  Xconv1 = float(GRWXY/10) / CH1IpdvRange
7105  Xoffset1 = CHAIOffset
7106  COLORXmarker = COLORtrace3
7107  X_label = " mA"
7108  if Xsignal.get() == 3 or Xsignal.get() == 7:
7109  Xconv1 = float(GRWXY/10) / CH2pdvRange
7110  Xoffset1 = CHBOffset
7111  COLORXmarker = COLORtrace2
7112  X_label = " V"
7113  if Xsignal.get() == 4:
7114  Xconv1 = float(GRWXY/10) / CH2IpdvRange
7115  Xoffset1 = CHBIOffset
7116  COLORmarker = COLORtrace4
7117  X_label = " mA"
7118  if Xsignal.get() == 5:
7119  X_label = MathXUnits
7120  if MathXAxis == "V-A":
7121  Xconv1 = float(GRWXY/10) / CH1pdvRange
7122  Xoffset1 = CHAOffset
7123  COLORXmarker = COLORtrace1
7124  elif MathXAxis == "V-B":
7125  Xconv1 = float(GRWXY/10) / CH2pdvRange
7126  Xoffset1 = CHBOffset
7127  COLORXmarker = COLORtrace2
7128  elif MathXAxis == "I-A":
7129  Xconv1 = float(GRWXY/10) / CH1IpdvRange
7130  Xoffset1 = CHAIOffset
7131  COLORXmarker = COLORtrace3
7132  elif MathXAxis == "I-B":
7133  Xconv1 = float(GRWXY/10) / CH2IpdvRange
7134  Xoffset1 = CHBIOffset
7135  COLORXmarker = COLORtrace4
7136  else:
7137  Xconv1 = float(GRWXY/10) / CH1pdvRange
7138  Xoffset1 = CHAOffset
7139  COLORXmarker = COLORtrace1
7140 #
7141  if Ysignal.get() == 1 or Ysignal.get() == 6:
7142  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7143  Yoffset1 = CHAOffset
7144  COLORYmarker = COLORtrace1
7145  Y_label = " V"
7146  if Ysignal.get() == 2:
7147  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7148  Yoffset1 = CHAIOffset
7149  COLORYmarker = COLORtrace3
7150  Y_label = " mA"
7151  if Ysignal.get() == 3 or Ysignal.get() == 7:
7152  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
7153  Yoffset1 = CHBOffset
7154  COLORYmarker = COLORtrace2
7155  Y_label = " V"
7156  if Ysignal.get() == 4:
7157  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7158  Yoffset1 = CHBIOffset
7159  COLORYmarker = COLORtrace4
7160  Y_label = " mA"
7161  if Ysignal.get() == 5:
7162  Y_label = MathYUnits
7163  if MathYAxis == "V-A":
7164  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7165  Yoffset1 = CHAOffset
7166  COLORYmarker = COLORtrace1
7167  elif MathYAxis == "V-B":
7168  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
7169  Yoffset1 = CHBOffset
7170  COLORYmarker = COLORtrace2
7171  elif MathYAxis == "I-A":
7172  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
7173  Yoffset1 = CHAIOffset
7174  COLORYmarker = COLORtrace3
7175  elif MathYAxis == "I-B":
7176  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
7177  Yoffset1 = CHBIOffset
7178  COLORYmarker = COLORtrace4
7179  else:
7180  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
7181  Yoffset1 = CHAOffset
7182  COLORYmarker = COLORtrace1
7183  if ShowXCur.get() > 0:
7184  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
7185  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
7186  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
7187  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
7188  XString = ' {0:.3f} '.format(xvolts)
7189  V_label = XString + X_label
7190  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
7191  if ShowYCur.get() > 0:
7192  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
7193  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
7194  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
7195  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
7196  V1String = ' {0:.3f} '.format(-yvolts)
7197  V_label = V1String + Y_label
7198  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
7199  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
7200  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
7201  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
7202  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
7203  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
7204  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
7205  XString = ' {0:.3f} '.format(xvolts)
7206  V_label = XString + X_label
7207  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
7208  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
7209  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
7210  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
7211  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
7212  V1String = ' {0:.3f} '.format(-yvolts)
7213  V_label = V1String + Y_label
7214  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
7215 #
7216 # General information on top of the grid
7217 # Sweep information
7218  sttxt = "Running"
7219  if TRACEmodeTime.get() == 1:
7220  sttxt = sttxt + " Averaging"
7221  if ManualTrigger.get() == 1:
7222  sttxt = "Manual Trigger"
7223  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
7224  sttxt = "Stopped"
7225  if ScreenXYrefresh.get() == 1:
7226  sttxt = sttxt + " Persistance ON"
7227  # Delete text at bottom of screen
7228  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
7229  for n in de:
7230  XYca.delete(n)
7231  # Delete text at top of screen
7232  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
7233  for n in de:
7234  XYca.delete(n)
7235  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7236  x = X0LXY
7237  y = 12
7238  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7239  # digital I/O indicators
7240  x2 = X0LXY + GRWXY
7241  BoxColor = "#808080" # gray
7242  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
7243  if D0.get() == 0 and D4.get() == 0:
7244  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
7245  if Dval[0] == 1:
7246  BoxColor = "#00ff00" # 100% green
7247  elif Dval[0] == 0:
7248  BoxColor = "#ff0000" # 100% red
7249  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
7250  else:
7251  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
7252  if D1.get() == 0 and D5.get() == 0:
7253  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
7254  if Dval[0] == 1:
7255  BoxColor = "#00ff00" # 100% green
7256  elif Dval[0] == 0:
7257  BoxColor = "#ff0000" # 100% red
7258  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
7259  else:
7260  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
7261  if D2.get() == 0 and D6.get() == 0:
7262  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
7263  if Dval[0] == 1:
7264  BoxColor = "#00ff00" # 100% green
7265  elif Dval[0] == 0:
7266  BoxColor = "#ff0000" # 100% red
7267  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
7268  else:
7269  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
7270  if D3.get() == 0 and D7.get() == 0:
7271  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
7272  if Dval[0] == 1:
7273  BoxColor = "#00ff00" # 100% green
7274  elif Dval[0] == 0:
7275  BoxColor = "#ff0000" # 100% red
7276  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
7277  else:
7278  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
7279  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
7280  # print period and frequency of displayed channels
7281  txt = " "
7282  if Xsignal.get() == 1 or Xsignal.get() == 3:
7283  FindRisingEdge(VBuffA, VBuffB)
7284  if Xsignal.get() == 1:
7285  if MeasAHW.get() == 1:
7286  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
7287  if MeasALW.get() == 1:
7288  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
7289  if MeasADCy.get() == 1:
7290  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
7291  if MeasAPER.get() == 1:
7292  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
7293  if MeasAFREQ.get() == 1:
7294  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
7295  if Xsignal.get() == 3:
7296  if MeasBHW.get() == 1:
7297  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
7298  if MeasBLW.get() == 1:
7299  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
7300  if MeasBDCy.get() == 1:
7301  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
7302  if MeasBPER.get() == 1:
7303  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
7304  if MeasBFREQ.get() == 1:
7305  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
7306  if MeasPhase.get() == 1:
7307  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
7308 
7309  x = X0LXY
7310  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
7311  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7312  txt = " "
7313  if Xsignal.get() == 1 or Ysignal.get() == 1 or Xsignal.get() == 6:
7314  # Channel A information
7315  txt = "CHA: "
7316  txt = txt + str(CH1pdvRange) + " V/div"
7317  if MeasDCV1.get() == 1:
7318  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
7319  if MeasMaxV1.get() == 1:
7320  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
7321  if MeasTopV1.get() == 1:
7322  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
7323  if MeasMinV1.get() == 1:
7324  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
7325  if MeasBaseV1.get() == 1:
7326  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
7327  if MeasMidV1.get() == 1:
7328  MidV1 = (MaxV1+MinV1)/2
7329  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
7330  if MeasPPV1.get() == 1:
7331  PPV1 = MaxV1-MinV1
7332  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
7333  if MeasRMSV1.get() == 1:
7334  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
7335  if MeasUserA.get() == 1:
7336  try:
7337  TempValue = eval(UserAString)
7338  V1String = ' {0:.4f} '.format(TempValue)
7339  except:
7340  V1String = "####"
7341  txt = txt + UserALabel + " = " + V1String
7342  if Xsignal.get() == 2:
7343  txt = "CHA: "
7344  txt = txt + str(CH1IpdvRange) + " mA/div"
7345  elif (Xsignal.get() == 2):
7346  txt = txt + "CHA: "
7347  txt = txt + str(CH1IpdvRange) + " mA/div"
7348  if Xsignal.get() == 2 or Ysignal.get() == 2:
7349  if MeasDCI1.get() == 1:
7350  V1String = ' {0:.2f} '.format(DCI1)
7351  txt = txt + " AvgI = " + V1String
7352  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
7353  try:
7354  Resvalue = (DCV1/DCI1)*1000
7355  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7356  except:
7357  txt = txt + " Res = OverRange"
7358  if MeasMaxI1.get() == 1:
7359  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
7360  if MeasMinI1.get() == 1:
7361  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
7362  if MeasMidI1.get() == 1:
7363  MidI1 = (MaxI1+MinI1)/2
7364  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
7365  if MeasPPI1.get() == 1:
7366  PPI1 = MaxI1-MinI1
7367  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
7368  if MeasRMSI1.get() == 1:
7369  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
7370 
7371  x = X0LXY
7372  y = Y0TXY+GRHXY+int(4*FontSize) # 32
7373  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7374  txt= " "
7375  # Channel B information
7376  if Xsignal.get() == 3 or Ysignal.get() == 3 or Xsignal.get() == 7:
7377  txt = "CHB: "
7378  txt = txt + str(CH2pdvRange) + " V/div"
7379  if MeasDCV2.get() == 1:
7380  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
7381  if MeasMaxV2.get() == 1:
7382  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
7383  if MeasTopV2.get() == 1:
7384  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
7385  if MeasMinV2.get() == 1:
7386  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
7387  if MeasBaseV2.get() == 1:
7388  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
7389  if MeasMidV2.get() == 1:
7390  MidV2 = (MaxV2+MinV2)/2
7391  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
7392  if MeasPPV2.get() == 1:
7393  PPV2 = MaxV2-MinV2
7394  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
7395  if MeasRMSV2.get() == 1:
7396  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
7397  if MeasUserB.get() == 1:
7398  try:
7399  TempValue = eval(UserBString)
7400  V1String = ' {0:.4f} '.format(TempValue)
7401  except:
7402  V1String = "####"
7403  txt = txt + UserBLabel + " = " + V1String
7404  if Xsignal.get() == 4:
7405  txt = "CHB: "
7406  txt = txt + str(CH2IpdvRange) + " mA/div"
7407  elif Xsignal.get() == 4:
7408  txt = txt + "CHB: "
7409  txt = txt + str(CH2IpdvRange) + " mA/div"
7410  if Xsignal.get() == 4 or Ysignal.get() == 4:
7411  if MeasDCI2.get() == 1:
7412  V1String = ' {0:.2f} '.format(DCI2)
7413  txt = txt + " AvgI = " + V1String
7414  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
7415  try:
7416  Resvalue = (DCV2/DCI2)*1000
7417  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
7418  except:
7419  txt = txt + " Res = OverRange"
7420  if MeasMaxI2.get() == 1:
7421  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
7422  if MeasMinI2.get() == 1:
7423  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
7424  if MeasMidI2.get() == 1:
7425  MidI2 = (MaxI2+MinI2)/2
7426  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
7427  if MeasPPI2.get() == 1:
7428  PPI2 = MaxI2-MinI2
7429  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
7430  if MeasRMSI2.get() == 1:
7431  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
7432 
7433  x = X0LXY
7434  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
7435  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7436 #
7438  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7439 
7440  if MarkerScale.get() != 1:
7441  MarkerScale.set(1)
7442  CHAlab.config(style="Rtrace1.TButton")
7443  CHBlab.config(style="Strace2.TButton")
7444  CHAIlab.config(style="Strace3.TButton")
7445  CHBIlab.config(style="Strace4.TButton")
7446  else:
7447  MarkerScale.set(0)
7448 #
7450  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7451 
7452  if MarkerScale.get() != 3:
7453  MarkerScale.set(3)
7454  CHAlab.config(style="Strace1.TButton")
7455  CHBlab.config(style="Strace2.TButton")
7456  CHAIlab.config(style="Rtrace3.TButton")
7457  CHBIlab.config(style="Strace4.TButton")
7458  else:
7459  MarkerScale.set(0)
7460 
7462  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7463 
7464  if MarkerScale.get() != 2:
7465  MarkerScale.set(2)
7466  CHAlab.config(style="Strace1.TButton")
7467  CHBlab.config(style="Rtrace2.TButton")
7468  CHAIlab.config(style="Strace3.TButton")
7469  CHBIlab.config(style="Strace4.TButton")
7470  else:
7471  MarkerScale.set(0)
7472 
7474  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
7475 
7476  if MarkerScale.get() != 3:
7477  MarkerScale.set(4)
7478  CHAlab.config(style="Strace1.TButton")
7479  CHBlab.config(style="Strace2.TButton")
7480  CHAIlab.config(style="Strace3.TButton")
7481  CHBIlab.config(style="Rtrace4.TButton")
7482  else:
7483  MarkerScale.set(0)
7484 #
7486  global MarkerXYScale, CHAxylab, CHBxylab
7487 
7488  MarkerXYScale.set(1)
7489  CHAxylab.config(style="Rtrace1.TButton")
7490  CHBxylab.config(style="Strace2.TButton")
7491 
7493  global MarkerXYScale, CHAxylab, CHBxylab
7494 
7495  MarkerXYScale.set(2)
7496  CHBxylab.config(style="Rtrace2.TButton")
7497  CHAxylab.config(style="Strace1.TButton")
7498 #
7500  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
7501 
7502  TCursor = event.x
7503  VCursor = event.y
7504  if RUNstatus.get() == 0:
7506  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
7507 #
7509  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
7510  if event.widget == ca:
7511  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
7512  ShiftKeyDwn = event.state & 1
7513  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
7514  TCursor = TCursor + event.delta/100
7515  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
7516  VCursor = VCursor - event.delta/100
7517  else:
7518  try:
7519  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
7520  except:
7521  donothing()
7522  if RUNstatus.get() == 0:
7524 #
7525 def onCanvasUpArrow(event):
7526  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
7527 
7528  shift_key = event.state & 1
7529  if event.widget == ca:
7530  if ShowVCur.get() > 0 and shift_key == 0:
7531  VCursor = VCursor - 1
7532  elif ShowVCur.get() > 0 and shift_key == 1:
7533  VCursor = VCursor - 5
7534  if RUNstatus.get() == 0:
7536  try:
7537  if event.widget == XYca:
7538  if ShowYCur.get() > 0 and shift_key == 0:
7539  YCursor = YCursor - 1
7540  elif ShowYCur.get() > 0 and shift_key == 1:
7541  YCursor = YCursor - 5
7542  if RUNstatus.get() == 0:
7543  UpdateXYScreen()
7544  except:
7545  donothing()
7546  try:
7547  if event.widget == Freqca:
7548  if ShowdBCur.get() > 0 and shift_key == 0:
7549  dBCursor = dBCursor - 1
7550  elif ShowdBCur.get() > 0 and shift_key == 1:
7551  dBCursor = dBCursor - 5
7552  if RUNstatus.get() == 0:
7554  except:
7555  donothing()
7556  try:
7557  if event.widget == Bodeca:
7558  if ShowBdBCur.get() > 0 and shift_key == 0:
7559  BdBCursor = BdBCursor - 1
7560  elif ShowBdBCur.get() > 0 and shift_key == 1:
7561  BdBCursor = BdBCursor - 5
7562  if RUNstatus.get() == 0:
7564  except:
7565  donothing()
7566 #
7568  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
7569 
7570  shift_key = event.state & 1
7571  if event.widget == ca:
7572  if ShowVCur.get() > 0 and shift_key == 0:
7573  VCursor = VCursor + 1
7574  elif ShowVCur.get() > 0 and shift_key == 1:
7575  VCursor = VCursor + 5
7576  if RUNstatus.get() == 0:
7578  try:
7579  if event.widget == XYca:
7580  if ShowYCur.get() > 0 and shift_key == 0:
7581  YCursor = YCursor + 1
7582  elif ShowYCur.get() > 0 and shift_key == 1:
7583  YCursor = YCursor + 5
7584  if RUNstatus.get() == 0:
7585  UpdateXYScreen()
7586  except:
7587  donothing()
7588  try:
7589  if event.widget == Freqca:
7590  if ShowdBCur.get() > 0 and shift_key == 0:
7591  dBCursor = dBCursor + 1
7592  elif ShowdBCur.get() > 0 and shift_key == 1:
7593  dBCursor = dBCursor + 5
7594  if RUNstatus.get() == 0:
7596  except:
7597  donothing()
7598  try:
7599  if event.widget == Bodeca:
7600  if ShowBdBCur.get() > 0 and shift_key == 0:
7601  BdBCursor = BdBCursor + 1
7602  elif ShowBdBCur.get() > 0 and shift_key == 1:
7603  BdBCursor = BdBCursor + 5
7604  if RUNstatus.get() == 0:
7606  except:
7607  donothing()
7608 #
7610  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
7611 
7612  shift_key = event.state & 1
7613  if event.widget == ca:
7614  if ShowTCur.get() > 0 and shift_key == 0:
7615  TCursor = TCursor - 1
7616  elif ShowTCur.get() > 0 and shift_key == 1:
7617  TCursor = TCursor - 5
7618  if RUNstatus.get() == 0:
7620  try:
7621  if event.widget == XYca:
7622  if ShowXCur.get() > 0 and shift_key == 0:
7623  XCursor = XCursor - 1
7624  elif ShowXCur.get() > 0 and shift_key == 1:
7625  XCursor = XCursor - 5
7626  if RUNstatus.get() == 0:
7627  UpdateXYScreen()
7628  except:
7629  donothing()
7630  try:
7631  if event.widget == Freqca:
7632  if ShowFCur.get() > 0 and shift_key == 0:
7633  FCursor = FCursor - 1
7634  elif ShowFCur.get() > 0 and shift_key == 1:
7635  FCursor = FCursor - 5
7636  if RUNstatus.get() == 0:
7638  except:
7639  donothing()
7640  try:
7641  if event.widget == Bodeca:
7642  if ShowBPCur.get() > 0 and shift_key == 0:
7643  BPCursor = BPCursor - 1
7644  elif ShowBPCur.get() > 0 and shift_key == 1:
7645  BPCursor = BPCursor - 5
7646  if RUNstatus.get() == 0:
7648  except:
7649  donothing()
7650 #
7652  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
7653 
7654  shift_key = event.state & 1
7655  if event.widget == ca:
7656  if ShowTCur.get() > 0 and shift_key == 0:
7657  TCursor = TCursor + 1
7658  elif ShowTCur.get() > 0 and shift_key == 1:
7659  TCursor = TCursor + 5
7660  if RUNstatus.get() == 0:
7662  try:
7663  if event.widget == XYca:
7664  if ShowXCur.get() > 0 and shift_key == 0:
7665  XCursor = XCursor + 1
7666  elif ShowXCur.get() > 0 and shift_key == 1:
7667  XCursor = XCursor + 5
7668  if RUNstatus.get() == 0:
7669  UpdateXYScreen()
7670  except:
7671  donothing()
7672  try:
7673  if event.widget == Freqca:
7674  if ShowFCur.get() > 0 and shift_key == 0:
7675  FCursor = FCursor + 1
7676  elif ShowFCur.get() > 0 and shift_key == 1:
7677  FCursor = FCursor + 5
7678  if RUNstatus.get() == 0:
7680  except:
7681  donothing()
7682  try:
7683  if event.widget == Bodeca:
7684  if ShowBPCur.get() > 0 and shift_key == 0:
7685  BPCursor = BPCursor + 1
7686  elif ShowBPCur.get() > 0 and shift_key == 1:
7687  BPCursor = BPCursor + 5
7688  if RUNstatus.get() == 0:
7690  except:
7691  donothing()
7692 #
7693 def onCanvasSpaceBar(event):
7694  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
7695 
7696  if event.widget == ca:
7697  if RUNstatus.get() == 0:
7698  BStart()
7699  elif RUNstatus.get() > 0:
7700  BStop()
7701  try:
7702  if event.widget == XYca:
7703  if RUNstatus.get() == 0:
7704  BStart()
7705  elif RUNstatus.get() > 0:
7706  BStop()
7707  except:
7708  donothing()
7709  try:
7710  if event.widget == IAca:
7711  if RUNstatus.get() == 0:
7712  BStart()
7713  elif RUNstatus.get() > 0:
7714  BStop()
7715  except:
7716  donothing()
7717  try:
7718  if event.widget == Freqca:
7719  if RUNstatus.get() == 0:
7720  BStartSA()
7721  elif RUNstatus.get() > 0:
7722  BStopSA()
7723  except:
7724  donothing()
7725  try:
7726  if event.widget == Bodeca:
7727  if RUNstatus.get() == 0:
7728  BStartBP()
7729  elif RUNstatus.get() > 0:
7730  BStopBP()
7731  except:
7732  donothing()
7733 #
7735  global X0L # Left top X value
7736  global Y0T # Left top Y value
7737  global GRW # Screenwidth
7738  global GRH # Screenheight
7739  global FontSize
7740  global ca, MarkerLoc
7741  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
7742  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
7743  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
7744  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
7745  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
7746  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
7747  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
7748  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
7749  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
7750  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
7751 
7752  try:
7753  HoldOff = float(eval(HoldOffentry.get()))
7754  if HoldOff < 0:
7755  HoldOff = 0
7756  except:
7757  HoldOffentry.delete(0,END)
7758  HoldOffentry.insert(0, HoldOff)
7759  # get time scale
7760  try:
7761  TIMEdiv = float(eval(TMsb.get()))
7762  except:
7763  TIMEdiv = 0.5
7764  TMsb.delete(0,"end")
7765  TMsb.insert(0,TIMEdiv)
7766  # prevent divide by zero error
7767  if TIMEdiv < 0.0002:
7768  TIMEdiv = 0.01
7769  # add markers only if stopped
7770  if (RUNstatus.get() == 0):
7771  MarkerNum = MarkerNum + 1
7772  # get the vertical ranges
7773  try:
7774  CH1pdvRange = float(eval(CHAsb.get()))
7775  except:
7776  CHAsb.delete(0,END)
7777  CHAsb.insert(0, CH1vpdvRange)
7778  try:
7779  CH2pdvRange = float(eval(CHBsb.get()))
7780  except:
7781  CHBsb.delete(0,END)
7782  CHBsb.insert(0, CH2vpdvRange)
7783  try:
7784  CH1IpdvRange = float(eval(CHAIsb.get()))
7785  except:
7786  CHAIsb.delete(0,END)
7787  CHAIsb.insert(0, CH1IpdvRange)
7788  try:
7789  CH2IpdvRange = float(eval(CHBIsb.get()))
7790  except:
7791  CHBIsb.delete(0,END)
7792  CHBIsb.insert(0, CH2IpdvRange)
7793  # get the vertical offsets
7794  try:
7795  CHAOffset = float(eval(CHAVPosEntry.get()))
7796  except:
7797  CHAVPosEntry.delete(0,END)
7798  CHAVPosEntry.insert(0, CHAOffset)
7799  try:
7800  CHAIOffset = float(eval(CHAIPosEntry.get()))
7801  except:
7802  CHAIPosEntry.delete(0,END)
7803  CHAIPosEntry.insert(0, CHAIOffset)
7804  try:
7805  CHBOffset = float(eval(CHBVPosEntry.get()))
7806  except:
7807  CHBVPosEntry.delete(0,END)
7808  CHBVPosEntry.insert(0, CHBOffset)
7809  try:
7810  CHBIOffset = float(eval(CHBIPosEntry.get()))
7811  except:
7812  CHBIPosEntry.delete(0,END)
7813  CHBIPosEntry.insert(0, CHBIOffset)
7814  # prevent divide by zero error
7815  if CH1pdvRange < 0.001:
7816  CH1pdvRange = 0.001
7817  if CH2pdvRange < 0.001:
7818  CH2pdvRange = 0.001
7819  if CH1IpdvRange < 1.0:
7820  CH1IpdvRange = 1.0
7821  if CH2IpdvRange < 1.0:
7822  CH2IpdvRange = 1.0
7823 #
7824  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
7825  try:
7826  CHMApdvRange = float(eval(CHB_Asb.get()))
7827  except:
7828  CHB_Asb.delete(0,END)
7829  CHB_Asb.insert(0, CHMApdvRange)
7830  try:
7831  CHMBpdvRange = float(eval(CHB_Bsb.get()))
7832  except:
7833  CHB_Bsb.delete(0,END)
7834  CHB_Bsb.insert(0, CHMBpdvRange)
7835  try:
7836  CHMCpdvRange = float(eval(CHB_Csb.get()))
7837  except:
7838  CHB_Csb.delete(0,END)
7839  CHB_Csb.insert(0, CHMCpdvRange)
7840  try:
7841  CHMDpdvRange = float(eval(CHB_Dsb.get()))
7842  except:
7843  CHB_Dsb.delete(0,END)
7844  CHB_Dsb.insert(0, CHMDpdvRange)
7845  YconvMA = float(GRH/10.0) / CHMApdvRange
7846  YconvMB = float(GRH/10.0) / CHMBpdvRange
7847  YconvMC = float(GRH/10.0) / CHMCpdvRange
7848  YconvMD = float(GRH/10.0) / CHMDpdvRange
7849  try:
7850  CHBAOffset = float(eval(CHB_APosEntry.get()))
7851  except:
7852  CHB_APosEntry.delete(0,END)
7853  CHB_APosEntry.insert(0, CHBAOffset)
7854  try:
7855  CHBBOffset = float(eval(CHB_BPosEntry.get()))
7856  except:
7857  CHB_BPosEntry.delete(0,END)
7858  CHB_BPosEntry.insert(0, CHBBOffset)
7859  try:
7860  CHBCOffset = float(eval(CHB_CPosEntry.get()))
7861  except:
7862  CHB_CPosEntry.delete(0,END)
7863  CHB_CPosEntry.insert(0, CHBCOffset)
7864  try:
7865  CHBDOffset = float(eval(CHB_DPosEntry.get()))
7866  except:
7867  CHB_DPosEntry.delete(0,END)
7868  CHB_DPosEntry.insert(0, CHBDOffset)
7869  Yoffset1 = CHAOffset
7870  if MarkerScale.get() == 1:
7871  Yconv1 = float(GRH/10.0) / CH1pdvRange
7872  Yoffset1 = CHAOffset
7873  COLORmarker = COLORtrace1
7874  Units = " V"
7875  elif MarkerScale.get() == 2:
7876  Yconv1 = float(GRH/10.0) / CH2pdvRange
7877  Yoffset1 = CHBOffset
7878  COLORmarker = COLORtrace2
7879  Units = " V"
7880  elif MarkerScale.get() == 3:
7881  Yconv1 = float(GRH/10.0) / CH1IpdvRange
7882  Yoffset1 = CHAIOffset
7883  COLORmarker = COLORtrace3
7884  Units = " mA"
7885  elif MarkerScale.get() == 4:
7886  Yconv1 = float(GRH/10.0) / CH2IpdvRange
7887  Yoffset1 = CHBIOffset
7888  COLORmarker = COLORtrace4
7889  Units = " mA"
7890  # Aanalog Mux settings
7891  elif MarkerScale.get() == 5:
7892  Yconv1 = float(GRH/10.0) / CHMApdvRange
7893  Yoffset1 = CHBAOffset
7894  COLORmarker = COLORtrace2
7895  Units = " V"
7896  elif MarkerScale.get() == 6:
7897  Yconv1 = float(GRH/10.0) / CHMBpdvRange
7898  Yoffset1 = CHBBOffset
7899  COLORmarker = COLORtrace6
7900  Units = " V"
7901  elif MarkerScale.get() == 7:
7902  Yconv1 = float(GRH/10.0) / CHMCpdvRange
7903  Yoffset1 = CHBCOffset
7904  COLORmarker = COLORtrace7
7905  Units = " V"
7906  elif MarkerScale.get() == 8:
7907  Yconv1 = float(GRH/10.0) / CHMDpdvRange
7908  Yoffset1 = CHBDOffset
7909  COLORmarker = COLORtrace4
7910  Units = " V"
7911  else:
7912  Yconv1 = float(GRH/10.0) / CH1pdvRange
7913  Yoffset1 = CHAOffset
7914  COLORmarker = COLORtrace1
7915  Units = " V"
7916  #
7917  c1 = GRH / 2.0 + Y0T # fixed correction channel A
7918  xc1 = GRW / 2.0 + X0L
7919  c2 = GRH / 2.0 + Y0T # fixed correction channel B
7920  # draw X at marker point and number
7921  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
7922  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
7923  DISsamples = (10.0 * TIMEdiv) # grid width in time
7924  Tstep = DISsamples / GRW # time in mS per pixel
7925  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
7926  TString = ' {0:.2f} '.format(Tpoint)
7927  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
7928  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
7929  V1String = ' {0:.3f} '.format(-yvolts)
7930  else:
7931  V1String = ' {0:.1f} '.format(-yvolts)
7932  V_label = str(MarkerNum) + " " + TString + " mS, " + V1String
7933  V_label = V_label + Units
7934  if MarkerNum > 1:
7935  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
7936  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
7937  else:
7938  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
7939  DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
7940  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
7941  V_label = V_label + " Delta " + DeltaT + " mS, " + DeltaV
7942  V_label = V_label + Units
7943  V_label = V_label + ", Freq " + DFreq + " KHz"
7944  # place in upper left unless specified otherwise
7945  x = X0L + 5
7946  y = Y0T + 3 + (MarkerNum*10)
7947  Justify = 'w'
7948  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
7949  x = X0L + GRW - 5
7950  y = Y0T + 3 + (MarkerNum*10)
7951  Justify = 'e'
7952  if MarkerLoc == 'LL' or MarkerLoc == 'll':
7953  x = X0L + 5
7954  y = Y0T + GRH + 3 - (MarkerNum*10)
7955  Justify = 'w'
7956  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
7957  x = X0L + GRW - 5
7958  y = Y0T + GRH + 3 - (MarkerNum*10)
7959  Justify = 'e'
7960  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
7961  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
7962  PrevV = yvolts
7963  PrevT = Tpoint
7964  else:
7965  if MeasGateStatus.get() == 1:
7966  DISsamples = (10.0 * TIMEdiv) # grid width in time
7967  Tstep = DISsamples / GRW # time in mS per pixel
7968  if MeasGateNum == 0:
7969  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
7970  MeasGateNum = 1
7971  else:
7972  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
7973  MeasGateNum = 0
7974  LeftGate = X0L + MeasGateLeft / Tstep
7975  RightGate = X0L + MeasGateRight / Tstep
7976  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
7977  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
7978 
7979 #
7980 def onCanvasOne(event):
7981  global ShowC1_V
7982 
7983  if ShowC1_V.get() == 0:
7984  ShowC1_V.set(1)
7985  else:
7986  ShowC1_V.set(0)
7987 #
7988 def onCanvasTwo(event):
7989  global ShowC2_V
7990 
7991  if ShowC2_V.get() == 0:
7992  ShowC2_V.set(1)
7993  else:
7994  ShowC2_V.set(0)
7995 #
7996 def onCanvasThree(event):
7997  global ShowC1_I
7998 
7999  if ShowC1_I.get() == 0:
8000  ShowC1_I.set(1)
8001  else:
8002  ShowC1_I.set(0)
8003 #
8004 def onCanvasFour(event):
8005  global ShowC2_I
8006 
8007  if ShowC2_I.get() == 0:
8008  ShowC2_I.set(1)
8009  else:
8010  ShowC2_I.set(0)
8011 #
8012 def onCanvasFive(event):
8013  global MathTrace
8014 
8015  MathTrace.set(1)
8016 #
8017 def onCanvasSix(event):
8018  global MathTrace
8019 
8020  MathTrace.set(2)
8021 #
8022 def onCanvasSeven(event):
8023  global MathTrace
8024 
8025  MathTrace.set(3)
8026 #
8027 def onCanvasEight(event):
8028  global MathTrace
8029 
8030  MathTrace.set(10)
8031 #
8032 def onCanvasNine(event):
8033  global MathTrace
8034 
8035  MathTrace.set(12)
8036 #
8037 def onCanvasZero(event):
8038  global MathTrace
8039 
8040  MathTrace.set(0)
8041 #
8042 def onCanvasTrising(event):
8043  global TgEdge
8044 
8045  TgEdge.set(0)
8046 #
8047 def onCanvasTfalling(event):
8048  global TgEdge
8049 
8050  TgEdge.set(1)
8051 #
8052 def onCanvasSnap(event):
8053 
8054  BSnapShot()
8055 #
8056 def onCanvasAverage(event):
8057  global TRACEmodeTime
8058 
8059  if TRACEmodeTime.get() == 0:
8060  TRACEmodeTime.set(1)
8061  else:
8062  TRACEmodeTime.set(0)
8063 #
8064 def onCanvasShowTcur(event):
8065  global ShowTCur
8066 
8067  if ShowTCur.get() == 0:
8068  ShowTCur.set(1)
8069  else:
8070  ShowTCur.set(0)
8071 #
8072 def onCanvasShowVcur(event):
8073  global ShowVCur
8074 
8075  if ShowVCur.get() == 0:
8076  ShowVCur.set(1)
8077  else:
8078  ShowVCur.set(0)
8079 #
8081  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
8082 
8083  XCursor = event.x
8084  YCursor = event.y
8085  if RUNstatus.get() == 0:
8086  UpdateXYScreen()
8087  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
8088 #
8090  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
8091  if event.widget == XYca:
8092  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
8093  ShiftKeyDwn = event.state & 1
8094  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
8095  XCursor = XCursor + event.delta/100
8096  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
8097  YCursor = YCursor - event.delta/100
8098  if RUNstatus.get() == 0:
8099  UpdateXYScreen()
8100 #
8102  global X0LXY # Left top X value
8103  global Y0TXY # Left top Y value
8104  global GRWXY # Screenwidth
8105  global GRHXY # Screenheight
8106  global FontSize
8107  global XYca
8108  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
8109  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
8110  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
8111  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
8112  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
8113  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
8114  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
8115  # add markers only if stopped
8116  #
8117  if (RUNstatus.get() == 0):
8118  MarkerNum = MarkerNum + 1
8119  try:
8120  CH1pdvRange = float(eval(CHAsbxy.get()))
8121  except:
8122  CHAsbxy.delete(0,END)
8123  CHAsbxy.insert(0, CH1vpdvRange)
8124  try:
8125  CH2pdvRange = float(eval(CHBsbxy.get()))
8126  except:
8127  CHBsb.delete(0,END)
8128  CHBsb.insert(0, CH2vpdvRange)
8129  try:
8130  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8131  except:
8132  CHAIsbxy.delete(0,END)
8133  CHAIsbxy.insert(0, CH1IpdvRange)
8134  try:
8135  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8136  except:
8137  CHBIsbxy.delete(0,END)
8138  CHBIsbxy.insert(0, CH2IpdvRange)
8139  # get the vertical offsets
8140  try:
8141  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8142  except:
8143  CHAVPosEntryxy.delete(0,END)
8144  CHAVPosEntryxy.insert(0, CHAOffset)
8145  try:
8146  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8147  except:
8148  CHAIPosEntryxy.delete(0,END)
8149  CHAIPosEntryxy.insert(0, CHAIOffset)
8150  try:
8151  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8152  except:
8153  CHBVPosEntryxy.delete(0,END)
8154  CHBVPosEntryxy.insert(0, CHBOffset)
8155  try:
8156  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8157  except:
8158  CHBIPosEntryxy.delete(0,END)
8159  CHBIPosEntryxy.insert(0, CHBIOffset)
8160  # prevent divide by zero error
8161  if CH1pdvRange < 0.001:
8162  CH1pdvRange = 0.001
8163  if CH2pdvRange < 0.001:
8164  CH2pdvRange = 0.001
8165  if CH1IpdvRange < 1.0:
8166  CH1IpdvRange = 1.0
8167  if CH2IpdvRange < 1.0:
8168  CH2IpdvRange = 1.0
8169  try:
8170  HoldOff = float(eval(HoldOffentry.get()))
8171  if HoldOff < 0:
8172  HoldOff = 0
8173  except:
8174  HoldOffentry.delete(0,END)
8175  HoldOffentry.insert(0, HoldOff)
8176  #
8177  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
8178  Xconv1 = float(GRWXY/10) / CH1pdvRange
8179  Yconv2 = float(GRHXY/10) / CH2pdvRange
8180  Xconv2 = float(GRWXY/10) / CH2pdvRange
8181  # YIconv1 = float(GRH/10) / CH1IpdvRange
8182  # YIconv2 = float(GRH/10) / CH2IpdvRange
8183  COLORmarker = COLORtext
8184  Yoffset1 = CHAOffset
8185  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
8186  xc1 = GRWXY / 2 + X0LXY
8187  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
8188  # draw X at marker point and number
8189  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
8190  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
8191  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
8192  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
8193  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
8194  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
8195  VyString = ' {0:.3f} '.format(-yvolts)
8196  VxString = ' {0:.3f} '.format(-xvolts)
8197  V_label = str(MarkerNum) + " " + VxString + " V, " + VyString + " V"
8198  if MarkerNum > 1:
8199  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
8200  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
8201  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
8202  x = X0LXY + 5
8203  y = Y0TXY + 3 + (MarkerNum*10)
8204  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
8205  PrevY = yvolts
8206  PrevX = xvolts
8207  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
8208  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
8209  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
8210  VyString = ' {0:.3f} '.format(-yvolts)
8211  VxString = ' {0:.3f} '.format(-xvolts)
8212  V_label = str(MarkerNum) + " " + VxString + " V, " + VyString + " V"
8213  if MarkerNum > 1:
8214  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
8215  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
8216  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
8217  x = X0LXY + 5
8218  y = Y0TXY + 3 + (MarkerNum*10)
8219  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
8220  PrevY = yvolts
8221  PrevX = xvolts
8222 #
8223 def Wrap(InArray, WrFactor):
8224  # Build new array by skipping WrFactor samples and wrapping back around
8225  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
8226  # effectively multiplies the frequency content by WrFactor
8227  OutArray = []
8228  OutArray = numpy.array(OutArray)
8229  InArray = numpy.array(InArray)
8230  EndIndex = len(InArray)
8231  StartIndex = 0
8232  while StartIndex < WrFactor:
8233  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
8234  StartIndex = StartIndex + 1
8235  return OutArray
8236 #
8237 def UnWrap(InArray, WrFactor):
8238  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
8239  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
8240  # effectively divided the frequency content by WrFactor
8241  OutArray = []
8242  InArray = numpy.array(InArray)
8243  EndIndex = int(len(InArray)/WrFactor)
8244  StartIndex = 0
8245  while StartIndex < EndIndex:
8246  LoopIndex = 0
8247  while LoopIndex < WrFactor:
8248  OutArray.append(InArray[StartIndex+LoopIndex])
8249  LoopIndex = LoopIndex + 1
8250  StartIndex = StartIndex + 1
8251  OutArray = numpy.array(OutArray)
8252  return OutArray
8253 #
8254 def Write_WAV(data, repeat, filename):
8255  global SAMPLErate
8256  # write data array to mono .wav file 100KSPS
8257  # copy buffer repeat times in output file
8258  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
8259  wavfile = wave.open(filename, "w")
8260  nchannels = 1
8261  sampwidth = 2
8262  framerate = SAMPLErate
8263  amplitude = 32766
8264  nframes = len(data)
8265  comptype = "NONE"
8266  compname = "not compressed"
8267  wavfile.setparams((nchannels,
8268  sampwidth,
8269  framerate,
8270  nframes,
8271  comptype,
8272  compname))
8273  # Normalize data
8274  ArrN = numpy.array(data)
8275  ArrN /= numpy.max(numpy.abs(data))
8276  frames = []
8277  for s in ArrN:
8278  mul = int(s * amplitude)
8279  # print "s: %f mul: %d" % (s, mul)
8280  frames.append(struct.pack('h', mul))
8281  print( len(frames))
8282  frames = ''.join(frames)
8283  print( len(frames))
8284  for x in xrange(0, repeat):
8285  print( x )
8286  wavfile.writeframes(frames)
8287  wavfile.close()
8288 
8289 # =========== Awg functions ==================
8290 def BAWGAAmpl(temp):
8291  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8292 
8293  try:
8294  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
8295  except:
8296  AWGAAmplEntry.delete(0,"end")
8297  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8298  #
8299  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
8300  if AWGAMode.get() == 0: # Source Voltage measure current mode
8301  if AWGAAmplvalue > 5.00:
8302  AWGAAmplvalue = 5.00
8303  AWGAAmplEntry.delete(0,"end")
8304  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8305  if AWGAAmplvalue < 0.00:
8306  AWGAAmplvalue = 0.00
8307  AWGAAmplEntry.delete(0,"end")
8308  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8309  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
8310  if AWGAMode.get() == 0: # Source Voltage measure current mode
8311  if AWGAAmplvalue > 2.5:
8312  AWGAAmplvalue = 2.5
8313  AWGAAmplEntry.delete(0,"end")
8314  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8315  if AWGAAmplvalue < -2.50:
8316  AWGAAmplvalue = -2.50
8317  AWGAAmplEntry.delete(0,"end")
8318  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8319  if AWGAMode.get() == 1: # Source current measure voltage mode
8320  if AWGAAmplvalue > 200.00:
8321  AWGAAmplvalue = 200.00
8322  AWGAAmplEntry.delete(0,"end")
8323  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8324  if AWGAAmplvalue < -200.00:
8325  AWGAAmplvalue = -200.00
8326  AWGAAmplEntry.delete(0,"end")
8327  AWGAAmplEntry.insert(0, AWGAAmplvalue)
8328 #
8329 def BAWGAOffset(temp):
8330  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8331 
8332  try:
8333  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
8334  except:
8335  AWGAOffsetEntry.delete(0,"end")
8336  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8337  if AWGAMode.get() == 0: # Source Voltage measure current mode
8338  if AWGAOffsetvalue > 5.00:
8339  AWGAOffsetvalue = 5.00
8340  AWGAOffsetEntry.delete(0,"end")
8341  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8342  if AWGAOffsetvalue < 0.00:
8343  AWGAOffsetvalue = 0.00
8344  AWGAOffsetEntry.delete(0,"end")
8345  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8346  if AWGAMode.get() == 1: # Source current measure voltage mode
8347  if AWGAOffsetvalue > 200.00:
8348  AWGAOffsetvalue = 200.00
8349  AWGAOffsetEntry.delete(0,"end")
8350  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8351  if AWGAOffsetvalue < -200.00:
8352  AWGAOffsetvalue = -200.00
8353  AWGAOffsetEntry.delete(0,"end")
8354  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
8355 #
8356 def BAWGAFreq(temp):
8357  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X
8358  global BodeScreenStatus, BodeDisp
8359 
8360  try:
8361  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
8362  except:
8363  AWGAFreqEntry.delete(0,"end")
8364  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8365  if AWG_2X.get() == 1:
8366  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
8367  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
8368  AWGAFreqvalue = 90000
8369  AWGAFreqEntry.delete(0,"end")
8370  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8371  else:
8372  if AWGAFreqvalue > 50000: # max freq is 50KHz
8373  AWGAFreqvalue = 50000
8374  AWGAFreqEntry.delete(0,"end")
8375  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8376  else:
8377  if AWGAFreqvalue > 25000: # max freq is 25KHz
8378  AWGAFreqvalue = 25000
8379  AWGAFreqEntry.delete(0,"end")
8380  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8381  if AWGAFreqvalue < 0: # Set negative frequency entry to 0
8382  AWGAFreqvalue = 10
8383  AWGAFreqEntry.delete(0,"end")
8384  AWGAFreqEntry.insert(0, AWGAFreqvalue)
8385  #UpdateAWGA()
8386 
8388  global AWGAPhaseDelay, phasealab, awgaph, awgadel
8389 
8390  if AWGAPhaseDelay.get() == 0:
8391  phasealab.configure(text="Deg")
8392  awgaph.configure(style="WPhase.TRadiobutton")
8393  awgadel.configure(style="GPhase.TRadiobutton")
8394  elif AWGAPhaseDelay.get() == 1:
8395  phasealab.configure(text="mSec")
8396  awgaph.configure(style="GPhase.TRadiobutton")
8397  awgadel.configure(style="WPhase.TRadiobutton")
8398 
8399 def BAWGAPhase(temp):
8400  global AWGAPhaseEntry, AWGAPhasevalue
8401 
8402  try:
8403  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
8404  except:
8405  AWGAPhaseEntry.delete(0,"end")
8406  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8407 
8408  if AWGAPhasevalue > 360: # max phase is 360 degrees
8409  AWGAPhasevalue = 360
8410  AWGAPhaseEntry.delete(0,"end")
8411  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8412  if AWGAPhasevalue < 0: # min phase is 0 degrees
8413  AWGAPhasevalue = 0
8414  AWGAPhaseEntry.delete(0,"end")
8415  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
8416 
8417 def BAWGADutyCycle(temp):
8418  global AWGADutyCycleEntry, AWGADutyCyclevalue
8419 
8420  try:
8421  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
8422  except:
8423  AWGADutyCycleEntry.delete(0,"end")
8424  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
8425 
8426  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
8427  AWGADutyCyclevalue = 1
8428  AWGADutyCycleEntry.delete(0,"end")
8429  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
8430  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
8431  AWGADutyCyclevalue = 0
8432  AWGADutyCycleEntry.delete(0,"end")
8433  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
8434  #UpdateAWGA()
8435 
8437  global AWGAShape, AWGAWave, phasealab, duty1lab
8438 
8439  if AWGAShape.get() == 0:
8440  AWGAWave = 'dc'
8441  duty1lab.config(text="%")
8442  BAWGAPhaseDelay()
8443  if AWGAShape.get() == 1:
8444  AWGAWave = 'sine'
8445  duty1lab.config(text="%")
8446  BAWGAPhaseDelay()
8447  if AWGAShape.get() == 2:
8448  AWGAWave = 'triangle'
8449  duty1lab.config(text="%")
8450  BAWGAPhaseDelay()
8451  if AWGAShape.get() == 3:
8452  AWGAWave = 'sawtooth'
8453  duty1lab.config(text="%")
8454  BAWGAPhaseDelay()
8455  if AWGAShape.get() == 4:
8456  AWGAWave = 'square'
8457  duty1lab.config(text="%")
8458  BAWGAPhaseDelay()
8459  if AWGAShape.get() == 5:
8460  AWGAWave = 'stairstep'
8461  duty1lab.config(text="%")
8462  BAWGAPhaseDelay()
8463  if AWGAShape.get() > 5:
8464  AWGAWave = 'arbitrary'
8465  # UpdateAWGA()
8466 
8468  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X
8469 
8470  # Read values from CVS file
8471  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
8472  try:
8473  CSVFile = open(filename)
8474  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
8475  CSVFile.seek(0)
8476  #csv_f = csv.reader(CSVFile, dialect)
8477  csv_f = csv.reader(CSVFile, csv.excel)
8478  except:
8479  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
8480  # print csv_f.dialect
8481  AWGAwaveform = []
8482  ColumnNum = 0
8483  ColumnSel = 0
8484  RowNum = 0
8485  for row in csv_f:
8486  # print 'found row = ', row
8487  if len(row) > 1 and ColumnSel == 0:
8488  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
8489  ColumnNum = int(RequestColumn) - 1
8490  ColumnLen = str(len(row))
8491  ColumnSel = 1
8492  try:
8493  colnum = 0
8494  for col in row:
8495  if colnum == ColumnNum:
8496  AWGAwaveform.append(float(col))
8497  colnum += 1
8498  except:
8499  print( 'skipping non-numeric row', RowNum)
8500  RowNum += 1
8501  AWGAwaveform = numpy.array(AWGAwaveform)
8503  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8504  CSVFile.close()
8505  UpdateAwgCont()
8506 
8507 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
8509  global AWG_2X, AWGA2X, AWGAwaveform
8510 
8511  if AWG_2X.get() == 1:
8512  Tempwaveform = []
8513  AWGA2X = []
8514  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
8515  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
8516  AWGAwaveform = Tempwaveform
8517 #
8519  global AWGABurstFlag, AWGACycles, AWGABurstDelay
8520 
8521  if AWGABurstFlag.get() == 1:
8522  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
8523  if (AWGACyclesString == None): # If Cancel pressed, then None
8524  return
8525  AWGACycles = int(AWGACyclesString)
8526  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
8527  if (AWGADelayString == None): # If Cancel pressed, then None
8528  return
8529  AWGABurstDelay = float(AWGADelayString)
8530  ReMakeAWGwaves()
8531 #
8533  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
8534  global AWG_2X, AWGA2X
8535 
8536 # Read values from WAV file
8537  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
8538  try:
8539  spf = wave.open(filename,'r')
8540  except:
8541  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
8542  AWGAwaveform = []
8543  AWGBwaveform = []
8544  Length = spf.getnframes()
8545  if Length > 90000:
8546  Length = 90000
8547  # If Stereo put first channel in AWGA and second channel in AWGB
8548  if spf.getnchannels() == 2:
8549  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
8550  signal = spf.readframes(Length)
8551  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
8552  n = 0
8553  while n < Length*2:
8554  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
8555  n = n + 1
8556  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
8557  n = n + 1
8558  AWGAwaveform = numpy.array(AWGAwaveform)
8559  AWGBwaveform = numpy.array(AWGBwaveform)
8560  AWGALength.config(text = "L = " + str(len(AWGAwaveform))) # change displayed value
8561  AWGBLength.config(text = "L = " + str(len(AWGBwaveform))) # change displayed value
8562  AWGBShape.set(AWGAShape.get())
8563  else:
8564  #Extract Raw Audio from Wav File
8565  signal = spf.readframes(Length)
8566  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
8567  # offset and scale for 0 5 V range
8568  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
8569  AWGAwaveform = numpy.array(AWGAwaveform)
8571  AWGALength.config(text = "L = " + str(len(AWGAwaveform))) # change displayed value
8572  spf.close()
8573  UpdateAwgCont()
8574 
8576  global AWGAwaveform, AWGALength, awgwindow
8577 
8578  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
8579  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
8580 
8582  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
8583  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
8584  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
8585  global DFiltACoef, DFiltBCoef
8586  global AWG_2X, AWGA2X
8587 
8588  TempString = AWGAMathString
8589  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
8590  if (AWGAMathString == None): # If Cancel pressed, then None
8591  AWGAMathString = TempString
8592  return
8593  AWGAwaveform = eval(AWGAMathString)
8594  AWGAwaveform = numpy.array(AWGAwaveform)
8596  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8597  UpdateAwgCont()
8598 #
8600  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8601  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8602  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab
8603 
8604  BAWGAAmpl(0)
8605  BAWGAOffset(0)
8606  BAWGAFreq(0)
8607  BAWGAPhase(0)
8608  BAWGADutyCycle(0)
8609 
8610  if AWGAFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
8611  AWGAShape.set(1)
8612  BAWGAShape()
8613  UpdateAwgCont()
8614  return
8615 
8616  if AWGAFreqvalue > 0.0:
8617  if AWG_2X.get() == 1:
8618  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8619  else:
8620  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8621  else:
8622  AWGAperiodvalue = 10.0
8623 
8624  if AWGAPhaseDelay.get() == 0:
8625  if AWGAPhasevalue > 0:
8626  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
8627  else:
8628  AWGAdelayvalue = 0.0
8629  elif AWGAPhaseDelay.get() == 1:
8630  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
8631  Cycles = int(32768/AWGAperiodvalue)
8632  if Cycles < 1:
8633  Cycles = 1
8634  RecLength = int(Cycles * AWGAperiodvalue)
8635  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8636  RecLength = RecLength + 1
8637  AWGAwaveform = []
8638  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
8639  if AWGAMode.get() == 1: # convert to mA
8640  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8641  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8642  else:
8643  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8644  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8645  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8646  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8647 #
8649  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8650  BAWGAPhaseDelay()
8651  duty1lab.config(text="%")
8652  phasealab.config(text="Delay")
8653  UpdateAwgCont()
8654 #
8656  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8657  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8658  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab
8659 
8660  BAWGAAmpl(0)
8661  BAWGAOffset(0)
8662  BAWGAFreq(0)
8663 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
8664  duty1lab.config(text = "M Index")
8665  phasealab.config(text = "M Freq")
8666 
8667  if AWGAFreqvalue > 0.0:
8668  if AWG_2X.get() == 1:
8669  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8670  else:
8671  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8672  else:
8673  AWGAperiodvalue = 10.0
8674 
8675  try:
8676  ModFreq = float(eval(AWGAPhaseEntry.get()))
8677  except:
8678  ModFreq = 10
8679  AWGAPhaseEntry.delete(0,"end")
8680  AWGAPhaseEntry.insert(0, ModFreq)
8681 
8682  if ModFreq < 10:
8683  ModFreq = 10
8684  AWGAPhaseEntry.delete(0,"end")
8685  AWGAPhaseEntry.insert(0, ModFreq)
8686 
8687  if AWG_2X.get() == 1:
8688  MODperiodvalue = (BaseSampleRate*2)/ModFreq
8689  else:
8690  MODperiodvalue = BaseSampleRate/ModFreq
8691 
8692  try:
8693  ModIndex = float(eval(AWGADutyCycleEntry.get()))
8694  except:
8695  ModIndex = 1.0
8696  AWGADutyCycleEntry.delete(0,"end")
8697  AWGADutyCycleEntry.insert(0, ModIndex)
8698 
8699  ModCycles = int(32768/MODperiodvalue) # find a whole number of cycles
8700  if ModCycles < 1:
8701  ModCycles = 1
8702  RecLength = int(ModCycles * MODperiodvalue)
8703  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8704  RecLength = RecLength + 1
8705  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
8706  AWGAwaveform = []
8707  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
8708  if AWGAMode.get() == 1: # convert to mA
8709  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8710  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8711  else:
8712  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8713  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8714  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8715  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8716 #
8717  SplitAWGAwaveform() # if needed
8718  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8719  UpdateAwgCont()
8720 #
8722  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8723  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
8724  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab
8725 
8726  BAWGAAmpl(0)
8727  BAWGAOffset(0)
8728  BAWGAFreq(0)
8729 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
8730  duty1lab.config(text = "M Index")
8731  phasealab.config(text = "M Freq")
8732 
8733  if AWGAFreqvalue > 0.0:
8734  if AWG_2X.get() == 1:
8735  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
8736  else:
8737  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8738  else:
8739  AWGAperiodvalue = 10.0
8740 
8741  try:
8742  ModFreq = float(eval(AWGAPhaseEntry.get()))
8743  except:
8744  ModFreq = 10
8745  AWGAPhaseEntry.delete(0,"end")
8746  AWGAPhaseEntry.insert(0, ModFreq)
8747 
8748  if ModFreq < 10:
8749  ModFreq = 10
8750  AWGAPhaseEntry.delete(0,"end")
8751  AWGAPhaseEntry.insert(0, ModFreq)
8752 
8753  if AWG_2X.get() == 1:
8754  MODperiodvalue = (BaseSampleRate*2)/ModFreq
8755  else:
8756  MODperiodvalue = BaseSampleRate/ModFreq
8757 
8758  try:
8759  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
8760  except:
8761  ModIndex = 50.0
8762  AWGADutyCycleEntry.delete(0,"end")
8763  AWGADutyCycleEntry.insert(0, ModIndex)
8764 
8765  ModCycles = int(32768/MODperiodvalue) # find a whole number of cycles
8766  if ModCycles < 1:
8767  ModCycles = 1
8768  RecLength = int(ModCycles * MODperiodvalue)
8769  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8770  RecLength = RecLength + 1
8771  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
8772  AWGAwaveform = []
8773  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
8774  if AWGAMode.get() == 1: # convert to mA
8775  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
8776  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
8777  else:
8778  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
8779  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
8780  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8781  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8782 #
8783  SplitAWGAwaveform() # if needed
8784  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8785  UpdateAwgCont()
8786 #
8788  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
8789  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8790  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8791 
8792  BAWGAAmpl(0)
8793  BAWGAOffset(0)
8794  BAWGAFreq(0)
8795  BAWGAPhase(0)
8796  BAWGADutyCycle(0)
8797 
8798  if AWGAFreqvalue > 0.0:
8799  if AWG_2X.get() == 1:
8800  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
8801  else:
8802  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8803  else:
8804  AWGAperiodvalue = 0.0
8805  if AWG_Amp_Mode.get() == 1:
8806  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
8807  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
8808  else:
8809  MaxV = AWGAOffsetvalue
8810  MinV = AWGAAmplvalue
8811 
8812  PulseWidth = int(AWGADutyCyclevalue*100)
8813  PulseSamples = int(AWGAperiodvalue/PulseWidth)
8814  AWGAwaveform = []
8815  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
8816  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
8817  # print(v)
8818  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
8819  if j >= v:
8820  AWGAwaveform.append(MaxV) # j>=v?1:0
8821  else:
8822  AWGAwaveform.append(MinV) # j>=v?1:0
8824  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8825  duty1lab.config(text="PWidth")
8826  UpdateAwgCont()
8827 #
8829  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
8830  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8831  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8832 
8833  BAWGAAmpl(0)
8834  BAWGAOffset(0)
8835  BAWGAFreq(0)
8836  BAWGADutyCycle(0)
8837 
8838  Max_term = int(AWGADutyCyclevalue*100)
8839  if AWG_2X.get() == 1:
8840  TempRate = (BaseSampleRate*2)
8841  else:
8842  TempRate = BaseSampleRate
8843  AWGAwaveform = []
8844  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, TempRate/AWGAFreqvalue)) # the fundamental
8845  k = 3
8846  while k <= Max_term:
8847  # Add odd harmonics up to max_term
8848  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, TempRate/AWGAFreqvalue)))
8849  AWGAwaveform = AWGAwaveform + Harmonic
8850  k = k + 2 # skip even numbers
8851  if AWG_Amp_Mode.get() == 0:
8852  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
8853  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
8854  else:
8855  amplitude = AWGAAmplvalue
8856  offset = AWGAOffsetvalue
8857  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8859  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8860  duty1lab.config(text="Harmonics")
8861  UpdateAwgCont()
8862 #
8864  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
8865  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
8866  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8867 
8868  BAWGAAmpl(0)
8869  BAWGAOffset(0)
8870  BAWGAFreq(0)
8871  BAWGAPhase(0)
8872  BAWGADutyCycle(0)
8873 
8874  if AWGAFreqvalue > 0.0:
8875  if AWG_2X.get() == 1:
8876  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
8877  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
8878  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8879  AWGAperiodvalue = AWGAperiodvalue + 1
8880  else:
8881  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8882  SamplesPermS = int(BaseSampleRate/1000) # 100
8883  else:
8884  AWGAperiodvalue = 0.0
8885  if AWG_Amp_Mode.get() == 1:
8886  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
8887  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
8888  else:
8889  MaxV = AWGAOffsetvalue
8890  MinV = AWGAAmplvalue
8891 
8892  if AWGAPhaseDelay.get() == 0:
8893  if AWGAPhasevalue > 0:
8894  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
8895  else:
8896  AWGAdelayvalue = 0.0
8897  elif AWGAPhaseDelay.get() == 1:
8898  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
8899 
8900  Cycles = int(AWGADutyCyclevalue*100)
8901  NCycles = -1 * Cycles
8902  AWGAwaveform = []
8903  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, SAMPLErate/AWGAFreqvalue))
8904  amplitude = (MaxV-MinV) / 2.0
8905  offset = (MaxV+MinV) / 2.0
8906  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
8907  Cycles = int(37500/AWGAperiodvalue)
8908  if Cycles < 1:
8909  Cycles = 1
8910  if Cycles > 1:
8911  Extend = int((Cycles-1.0)*AWGAperiodvalue/2.0)
8912  AWGAwaveform = numpy.pad(AWGAwaveform, (Extend,Extend), 'wrap')
8913  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
8915  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8916  #BAWGAPhaseDelay()
8917  duty1lab.config(text="Cycles")
8918  UpdateAwgCont()
8919 #
8921  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
8922  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8923  global AWGABurstFlag, AWGACycles, AWGABurstDelay
8924  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8925 
8926  BAWGAAmpl(0)
8927  BAWGAOffset(0)
8928  BAWGAFreq(0)
8929  BAWGAPhase(0)
8930  BAWGADutyCycle(0)
8931 
8932  if AWGAFreqvalue > 0.0:
8933  if AWG_2X.get() == 1:
8934  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
8935  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
8936  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8937  AWGAperiodvalue = AWGAperiodvalue + 1
8938  else:
8939  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
8940  SamplesPermS = int(BaseSampleRate/1000) # 100
8941  else:
8942  AWGAperiodvalue = 0.0
8943  if AWG_Amp_Mode.get() == 1:
8944  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
8945  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
8946  else:
8947  MaxV = AWGAOffsetvalue
8948  MinV = AWGAAmplvalue
8949  AWGAwaveform = []
8950  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
8951  if SlopeValue <= 0:
8952  SlopeValue = 1
8953  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
8954  if PulseWidth <=0:
8955  PulseWidth = 1
8956  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
8957  if Remainder <= 0:
8958  Remainder = 1
8959  PulseWidth = PulseWidth - SlopeValue
8960  if PulseWidth <=0:
8961  PulseWidth = 1
8962  StepAmp = (MaxV - MinV)/2
8963  StepOff = (MaxV + MinV)/2
8964  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
8965  MidArray = numpy.ones(PulseWidth) * MinV
8966  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
8967  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
8968  if AWGABurstFlag.get() == 1:
8969  TempOneCycle = AWGAwaveform
8970  for i in range(AWGACycles-1):
8971  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
8972  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
8973  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
8975  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
8976  duty1lab.config(text="%")
8977  phasealab.config(text = "Rise Time")
8978  UpdateAwgCont()
8979 #
8981  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
8982  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
8983  global AWGABurstFlag, AWGACycles, AWGABurstDelay
8984  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
8985 
8986  BAWGAAmpl(0)
8987  BAWGAOffset(0)
8988  BAWGAFreq(0)
8989  BAWGAPhase(0)
8990  BAWGADutyCycle(0)
8991 
8992  if AWGAFreqvalue > 0.0:
8993  if AWG_2X.get() == 1:
8994  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
8995  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
8996  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
8997  AWGAperiodvalue = AWGAperiodvalue + 1
8998  else:
8999  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9000  SamplesPermS = int(BaseSampleRate/1000) # 100
9001  else:
9002  AWGAperiodvalue = 0.0
9003  if AWG_Amp_Mode.get() == 1:
9004  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9005  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9006  else:
9007  MaxV = AWGAOffsetvalue
9008  MinV = AWGAAmplvalue
9009  AWGAwaveform = []
9010  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9011  if SlopeValue <= 0:
9012  SlopeValue = 1
9013  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9014  if PulseWidth <=0:
9015  PulseWidth = 1
9016  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
9017  if Remainder <= 0:
9018  Remainder = 1
9019  PulseWidth = PulseWidth - SlopeValue
9020  if PulseWidth <=0:
9021  PulseWidth = 1
9022  StepValue = (MaxV - MinV) / SlopeValue
9023  SampleValue = MinV
9024  for i in range(SlopeValue):
9025  AWGAwaveform.append(SampleValue)
9026  SampleValue = SampleValue + StepValue
9027  for i in range(PulseWidth):
9028  AWGAwaveform.append(MaxV)
9029  for i in range(SlopeValue):
9030  AWGAwaveform.append(SampleValue)
9031  SampleValue = SampleValue - StepValue
9032  for i in range(Remainder):
9033  AWGAwaveform.append(MinV)
9034  if AWGABurstFlag.get() == 1:
9035  TempOneCycle = AWGAwaveform
9036  for i in range(AWGACycles-1):
9037  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9038  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9039  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9041  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9042  duty1lab.config(text="%")
9043  phasealab.config(text = "Rise Time")
9044  UpdateAwgCont()
9045 #
9047  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9048  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9049  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9050  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9051 
9052  BAWGAAmpl(0)
9053  BAWGAOffset(0)
9054  BAWGAFreq(0)
9055  BAWGAPhase(0)
9056 
9057  try:
9058  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
9059  except:
9060  AWGADutyCycleEntry.delete(0,"end")
9061  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
9062 
9063  if AWGAFreqvalue > 0.0:
9064  if AWG_2X.get() == 1:
9065  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9066  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9067  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9068  AWGAperiodvalue = AWGAperiodvalue + 1
9069  else:
9070  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9071  SamplesPermS = int(BaseSampleRate/1000) # 100
9072  else:
9073  AWGAperiodvalue = 0.0
9074  if AWG_Amp_Mode.get() == 1:
9075  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9076  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9077  else:
9078  MaxV = AWGAOffsetvalue
9079  MinV = AWGAAmplvalue
9080  AWGAwaveform = []
9081  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9082  if SlopeValue <= 0:
9083  SlopeValue = 1
9084  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
9085  if PulseWidth <=0:
9086  PulseWidth = 1
9087  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
9088  if Remainder <= 0:
9089  Remainder = 1
9090  PulseWidth = PulseWidth - SlopeValue
9091  if PulseWidth <=0:
9092  PulseWidth = 1
9093  StepValue = (MaxV - MinV) / SlopeValue
9094  SampleValue = MinV
9095  for i in range(SlopeValue):
9096  AWGAwaveform.append(SampleValue)
9097  SampleValue = SampleValue + StepValue
9098  for i in range(PulseWidth):
9099  AWGAwaveform.append(MaxV)
9100  for i in range(SlopeValue):
9101  AWGAwaveform.append(SampleValue)
9102  SampleValue = SampleValue - StepValue
9103  for i in range(Remainder):
9104  AWGAwaveform.append(MinV)
9105  if AWGABurstFlag.get() == 1:
9106  TempOneCycle = AWGAwaveform
9107  for i in range(AWGACycles-1):
9108  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9109  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9110  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9112  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9113  duty1lab.config(text="Width mS")
9114  phasealab.config(text = "Rise Time")
9115  UpdateAwgCont()
9116 #
9118  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
9119  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9120  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9121  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9122 
9123  BAWGAAmpl(0)
9124  BAWGAOffset(0)
9125  BAWGAFreq(0)
9126  BAWGAPhase(0)
9127  BAWGADutyCycle(0)
9128 
9129  if AWGAFreqvalue > 0.0:
9130  if AWG_2X.get() == 1:
9131  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9132  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9133  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9134  AWGAperiodvalue = AWGAperiodvalue + 1
9135  else:
9136  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9137  SamplesPermS = int(BaseSampleRate/1000) # 100
9138  else:
9139  AWGAperiodvalue = 0.0
9140  if AWG_Amp_Mode.get() == 1:
9141  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9142  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9143  else:
9144  MaxV = AWGAOffsetvalue
9145  MinV = AWGAAmplvalue
9146  AWGAwaveform = []
9147  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
9148  if SlopeValue <= 0:
9149  SlopeValue = 1
9150  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9151  if PulseWidth <=0:
9152  PulseWidth = 1
9153  Remainder = int(AWGAperiodvalue - PulseWidth)
9154  if Remainder <= 0:
9155  Remainder = 1
9156  PulseWidth = PulseWidth - SlopeValue
9157  if PulseWidth <=0:
9158  PulseWidth = 1
9159  StepValue = (MaxV - MinV) / SlopeValue
9160  SampleValue = MinV
9161  for i in range(SlopeValue):
9162  AWGAwaveform.append(SampleValue)
9163  SampleValue = SampleValue + StepValue
9164  for i in range(PulseWidth):
9165  AWGAwaveform.append(MaxV)
9166  for i in range(Remainder):
9167  AWGAwaveform.append(MinV)
9168  if AWGABurstFlag.get() == 1:
9169  TempOneCycle = AWGAwaveform
9170  for i in range(AWGACycles-1):
9171  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9172  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
9173  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
9175  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9176  duty1lab.config(text="%")
9177  phasealab.config(text = "Slope Time")
9178  UpdateAwgCont()
9179 #
9181  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
9182  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9183  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9184  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9185 
9186  BAWGAAmpl(0)
9187  BAWGAOffset(0)
9188  BAWGAFreq(0)
9189  BAWGAPhase(0)
9190  BAWGADutyCycle(0)
9191 
9192  if AWGAFreqvalue > 0.0:
9193  if AWG_2X.get() == 1:
9194  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9195  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9196  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9197  AWGAperiodvalue = AWGAperiodvalue + 1
9198  else:
9199  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
9200  SamplesPermS = int(BaseSampleRate/1000) # 100
9201  else:
9202  AWGAperiodvalue = 0.0
9203  if AWG_Amp_Mode.get() == 1:
9204  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9205  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9206  else:
9207  MaxV = AWGAOffsetvalue
9208  MinV = AWGAAmplvalue
9209  #
9210  if AWGAPhaseDelay.get() == 0:
9211  if AWGAPhasevalue > 0:
9212  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9213  else:
9214  AWGAdelayvalue = 0.0
9215  elif AWGAPhaseDelay.get() == 1:
9216  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
9217  #
9218  AWGAwaveform = []
9219  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
9220  if PulseWidth <=0:
9221  PulseWidth = 1
9222  Remainder = int(AWGAperiodvalue - PulseWidth)
9223  if Remainder <= 0:
9224  Remainder = 1
9225  UpStepValue = (MaxV - MinV) / PulseWidth
9226  DownStepValue = (MaxV - MinV) / Remainder
9227  SampleValue = MinV
9228  for i in range(PulseWidth):
9229  AWGAwaveform.append(SampleValue)
9230  SampleValue = SampleValue + UpStepValue
9231  for i in range(Remainder):
9232  AWGAwaveform.append(SampleValue)
9233  SampleValue = SampleValue - DownStepValue
9234  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
9235  if AWGABurstFlag.get() == 1:
9236  TempOneCycle = AWGAwaveform
9237  for i in range(AWGACycles-1):
9238  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9239  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9240  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
9242  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9243  BAWGAPhaseDelay()
9244  duty1lab.config(text = "Symmetry")
9245  UpdateAwgCont()
9246 #
9248  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9249  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
9250  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9251  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9252 
9253  BAWGAAmpl(0)
9254  BAWGAOffset(0)
9255  BAWGAFreq(0)
9256  BAWGAPhase(0)
9257  BAWGADutyCycle(0)
9258 
9259  if AWGAFreqvalue > 0.0:
9260  if AWG_2X.get() == 1:
9261  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9262  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9263  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9264  AWGAperiodvalue = AWGAperiodvalue + 1
9265  else:
9266  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9267  SamplesPermS = int(BaseSampleRate/1000) # 100
9268  else:
9269  AWGAperiodvalue = 0.0
9270  if AWG_Amp_Mode.get() == 1:
9271  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9272  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9273  else:
9274  MaxV = AWGAOffsetvalue
9275  MinV = AWGAAmplvalue
9276  AWGAwaveform = []
9277  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
9278  if AWGAPhaseDelay.get() == 0:
9279  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
9280  elif AWGAPhaseDelay.get() == 1:
9281  DelayValue = int(AWGAPhasevalue*SamplesPermS)
9282  for i in range(DelayValue-PulseWidth):
9283  AWGAwaveform.append((MinV+MaxV)/2.0)
9284  for i in range(PulseWidth):
9285  AWGAwaveform.append(MaxV)
9286  for i in range(PulseWidth):
9287  AWGAwaveform.append(MinV)
9288  DelayValue = int(AWGAperiodvalue-DelayValue)
9289  for i in range(DelayValue-PulseWidth):
9290  AWGAwaveform.append((MinV+MaxV)/2.0)
9291  if AWGABurstFlag.get() == 1:
9292  TempOneCycle = AWGAwaveform
9293  for i in range(AWGACycles-1):
9294  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9295  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9296  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
9298  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9299  UpdateAwgCont()
9300 
9302  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
9303  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9304  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9305  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9306 
9307  BAWGAAmpl(0)
9308  BAWGAOffset(0)
9309  BAWGAFreq(0)
9310 
9311  if AWGAFreqvalue > 0.0:
9312  if AWG_2X.get() == 1:
9313  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9314  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9315  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9316  AWGAperiodvalue = AWGAperiodvalue + 1
9317  else:
9318  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9319  SamplesPermS = int(BaseSampleRate/1000) # 100
9320  else:
9321  AWGAperiodvalue = 0.0
9322  if AWG_Amp_Mode.get() == 1:
9323  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9324  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9325  else:
9326  if AWGAAmplvalue > AWGAOffsetvalue:
9327  MinV = AWGAOffsetvalue
9328  MaxV = AWGAAmplvalue
9329  else:
9330  MaxV = AWGAOffsetvalue
9331  MinV = AWGAAmplvalue
9332  AWGAwaveform = []
9333  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
9334  Mid = (MaxV+MinV)/2.0
9335  if AWGABurstFlag.get() == 1:
9336  TempOneCycle = AWGAwaveform
9337  for i in range(AWGACycles-1):
9338  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9339  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9340  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
9342  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9343  UpdateAwgCont()
9344 
9346  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
9347  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9348  global AWGABurstFlag, AWGACycles, AWGABurstDelay
9349  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9350 
9351  BAWGAAmpl(0)
9352  BAWGAOffset(0)
9353  BAWGAFreq(0)
9354 
9355  if AWGAFreqvalue > 0.0:
9356  if AWG_2X.get() == 1:
9357  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
9358  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
9359  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9360  AWGAperiodvalue = AWGAperiodvalue + 1
9361  else:
9362  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
9363  SamplesPermS = int(BaseSampleRate/1000) # 100
9364  else:
9365  AWGAperiodvalue = 0.0
9366  if AWG_Amp_Mode.get() == 1:
9367  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9368  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9369  else:
9370  if AWGAAmplvalue > AWGAOffsetvalue:
9371  MinV = AWGAOffsetvalue
9372  MaxV = AWGAAmplvalue
9373  else:
9374  MaxV = AWGAOffsetvalue
9375  MinV = AWGAAmplvalue
9376  AWGAwaveform = []
9377  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
9378  Mid = (MaxV+MinV)/2.0
9379  if AWGABurstFlag.get() == 1:
9380  TempOneCycle = AWGAwaveform
9381  for i in range(AWGACycles-1):
9382  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
9383  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
9384  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
9386  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
9387  UpdateAwgCont()
9388 
9390  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
9391  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9392 
9393  if AWGAMode.get() == 0: # Source Voltage measure current mode
9394  label_txt = "SVMI"
9395  elif AWGAMode.get() == 1: # Source current measure voltage mode
9396  label_txt = "SIMV"
9397  elif AWGAMode.get() == 2: # High impedance mode
9398  label_txt = "Hi-Z"
9399  if AWGAIOMode.get() > 0: # Split Input / Output mode
9400  if HWRevOne == "D":
9401  if AWGAMode.get() == 0:
9402  AWGAMode.set(1)
9403  CHA.set_mode('i') # channel must be in source current mode for rev D boards
9404  label_txt = "SIMV"
9405  label_txt = label_txt + " Split I/O"
9406  label_txt = label_txt + " Mode"
9407  AWGAModeLabel.config(text = label_txt ) # change displayed value
9408  ReMakeAWGwaves()
9409  #UpdateAwgCont()
9410 
9412  global AWGAAmplvalue, AWGAOffsetvalue
9413  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
9414  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
9415  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
9416  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9417  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
9418 
9419  BAWGAAmpl(0)
9420  BAWGAOffset(0)
9421  BAWGAFreq(0)
9422  BAWGAPhase(0)
9423  BAWGADutyCycle(0)
9424  BAWGAShape()
9425 
9426  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
9427  amp1lab.config(text = "Min Ch A" ) # change displayed value
9428  off1lab.config(text = "Max Ch A" ) # change displayed value
9429  else:
9430  amp1lab.config(text = "Amp Ch A" )
9431  off1lab.config(text = "Off Ch A" )
9432 
9433  if AWGAFreqvalue > 0.0:
9434  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
9435  else:
9436  AWGAperiodvalue = 0.0
9437 
9438  if AWGAPhaseDelay.get() == 0:
9439  if AWGAWave == 'square':
9440  AWGAPhasevalue = AWGAPhasevalue + 270.0
9441  if AWGAPhasevalue > 359:
9442  AWGAPhasevalue = AWGAPhasevalue - 360
9443  if AWGAPhasevalue > 0:
9444  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
9445  else:
9446  AWGAdelayvalue = 0.0
9447  elif AWGAPhaseDelay.get() == 1:
9448  AWGAdelayvalue = AWGAPhasevalue * 100
9449 
9450  if AWGATerm.get() == 0: # Open termination
9451  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
9452  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
9453  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
9454  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
9455  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
9456  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
9457  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
9458  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
9459 
9460  if AWGAWave == 'dc':
9461  if AWG_2X.get() == 2:
9462  AWGAWave == 'arbitrary'
9463  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
9464  else:
9465  if AWGAMode.get() == 0: # Source Voltage measure current mode
9466  if AWGAIOMode.get() == 0:
9467  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
9468  else:
9469  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
9470  CHA.constant(AWGAOffsetvalue)
9471  #
9472  if AWGAMode.get() == 1: # Source current measure voltage mode
9473  if AWGAIOMode.get() == 0:
9474  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
9475  else:
9476  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
9477  CHA.constant(AWGAOffsetvalue/1000)
9478  #
9479  if AWGAMode.get() == 2: # High impedance mode
9480  if AWGAIOMode.get() == 0:
9481  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
9482  else:
9483  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
9484  #
9485  if AWGAIOMode.get() > 0: # Split Input / Output mode
9486  if HWRevOne == "D":
9487  AWGAMode.set(1)
9488  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
9489 #
9490  else:
9491  if AWGAMode.get() == 0: # Source Voltage measure current mode
9492  if AWGAIOMode.get() == 0:
9493  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
9494  else:
9495  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
9496  if AWGAMode.get() == 1: # Source current measure voltage mode
9497  if AWGAIOMode.get() == 0:
9498  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
9499  else:
9500  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
9501  AWGAOffsetvalue = AWGAOffsetvalue/1000
9502  AWGAAmplvalue = AWGAAmplvalue/1000
9503  if AWGAMode.get() == 2: # High impedance mode
9504  if AWGAIOMode.get() == 0:
9505  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
9506  else:
9507  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
9508  else:
9509  if AWG_Amp_Mode.get() == 1:
9510  MaxV = (AWGAOffsetvalue+AWGAAmplvalue)
9511  MinV = (AWGAOffsetvalue-AWGAAmplvalue)
9512  else:
9513  MaxV = AWGAOffsetvalue
9514  MinV = AWGAAmplvalue
9515  try:
9516  if AWGAWave == 'sine':
9517  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9518  elif AWGAWave == 'triangle':
9519  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9520  elif AWGAWave == 'sawtooth':
9521  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9522  elif AWGAWave == 'square':
9523  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
9524  elif AWGAWave == 'stairstep':
9525  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
9526  elif AWGAWave == 'arbitrary':
9527  if AWGSync.get() == 0:
9528  AWGARepeatFlag.set(1)
9529  if AWG_2X.get() == 2:
9530  AWGAWave == 'arbitrary'
9531  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
9532  else:
9533  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
9534  except:
9535  donothing()
9536  if AWGAIOMode.get() > 0: # Split Input / Output mode
9537  if HWRevOne == "D":
9538  AWGAMode.set(1)
9539  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
9540 # AWG B functions
9542  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
9543  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
9544  global BisCompA
9545 
9546  # if BisCompA.get() == 1:
9547  # sawp Min and Max values
9548  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
9549  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
9550  AWGBAmplEntry.delete(0,"end")
9551  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
9552  AWGBOffsetEntry.delete(0,"end")
9553  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
9554  # copy everything else
9555  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
9556  AWGBFreqEntry.delete(0,"end")
9557  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9558  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
9559  AWGBPhaseEntry.delete(0,"end")
9560  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9561  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
9562  AWGBDutyCycleEntry.delete(0,"end")
9563  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9564  AWGBShape.set(AWGAShape.get())
9565  #
9566 # ReMakeAWGwaves()
9567 # UpdateAwgCont()
9568 #
9570  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
9571 
9572  if AWGBBurstFlag.get() == 1:
9573  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
9574  if (AWGBCyclesString == None): # If Cancel pressed, then None
9575  return
9576  AWGBCycles = int(AWGBCyclesString)
9577  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
9578  if (AWGBDelayString == None): # If Cancel pressed, then None
9579  return
9580  AWGBBurstDelay = float(AWGBDelayString)
9581  ReMakeAWGwaves()
9582 #
9583 def BAWGBAmpl(temp):
9584  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9585 
9586  try:
9587  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
9588  if AWGBMode.get() == 0: # Source Voltage measure current mode
9589  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
9590  if AWGBAmplvalue > 5.00:
9591  AWGBAmplvalue = 5.00
9592  AWGBAmplEntry.delete(0,"end")
9593  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9594  if AWGBAmplvalue < 0.00:
9595  AWGBAmplvalue = 0.00
9596  AWGBAmplEntry.delete(0,"end")
9597  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9598  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
9599  if AWGBAmplvalue > 2.5:
9600  AWGBAmplvalue = 2.5
9601  AWGBAmplEntry.delete(0,"end")
9602  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9603  if AWGBAmplvalue < -2.50:
9604  AWGBAmplvalue = -2.50
9605  AWGBAmplEntry.delete(0,"end")
9606  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9607  elif AWGBMode.get() == 1: # Source current measure voltage mode
9608  if AWGBAmplvalue > 200.00:
9609  AWGBAmplvalue = 200.00
9610  AWGBAmplEntry.delete(0,"end")
9611  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9612  if AWGBAmplvalue < -200.00:
9613  AWGBAmplvalue = -200.00
9614  AWGBAmplEntry.delete(0,"end")
9615  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9616  except:
9617  AWGBAmplEntry.delete(0,"end")
9618  AWGBAmplEntry.insert(0, AWGBAmplvalue)
9619 #
9620 def BAWGBOffset(temp):
9621  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9622 
9623  try:
9624  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
9625  if AWGBMode.get() == 0: # Source Voltage measure current mode
9626  if AWGBOffsetvalue > 5.00:
9627  AWGBOffsetvalue = 5.00
9628  AWGBOffsetEntry.delete(0,"end")
9629  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9630  if AWGBOffsetvalue < 0.00:
9631  AWGBOffsetvalue = 0.00
9632  AWGBOffsetEntry.delete(0,"end")
9633  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9634  elif AWGBMode.get() == 1: # Source current measure voltage mode
9635  if AWGBOffsetvalue > 200.00:
9636  AWGBOffsetvalue = 200.00
9637  AWGBOffsetEntry.delete(0,"end")
9638  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9639  if AWGBOffsetvalue < -200.00:
9640  AWGBOffsetvalue = -200.00
9641  AWGBOffsetEntry.delete(0,"end")
9642  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9643  except:
9644  AWGBOffsetEntry.delete(0,"end")
9645  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
9646 #
9647 def BAWGBFreq(temp):
9648  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
9649  global BodeScreenStatus, BodeDisp
9650 
9651  try:
9652  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
9653  except:
9654  AWGBFreqEntry.delete(0,"end")
9655  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9656  if AWG_2X.get() == 2:
9657  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
9658  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
9659  AWGBFreqvalue = 90000
9660  AWGBFreqEntry.delete(0,"end")
9661  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9662  else:
9663  if AWGBFreqvalue > 50000: # max freq is 50KHz
9664  AWGBFreqvalue = 50000
9665  AWGBFreqEntry.delete(0,"end")
9666  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9667  else:
9668  if AWGBFreqvalue > 25000: # max freq is 25KHz
9669  AWGBFreqvalue = 25000
9670  AWGBFreqEntry.delete(0,"end")
9671  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9672  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
9673  AWGBFreqvalue = 10
9674  AWGBFreqEntry.delete(0,"end")
9675  AWGBFreqEntry.insert(0, AWGBFreqvalue)
9676  # UpdateAWGB()
9677 
9679  global AWGbPhaseDelay, phaseblab, awgbph, awgbdel
9680 
9681  if AWGBPhaseDelay.get() == 0:
9682  phaseblab.configure(text="Deg")
9683  awgbph.configure(style="WPhase.TRadiobutton")
9684  awgbdel.configure(style="GPhase.TRadiobutton")
9685  elif AWGBPhaseDelay.get() == 1:
9686  phaseblab.configure(text="mSec")
9687  awgbph.configure(style="GPhase.TRadiobutton")
9688  awgbdel.configure(style="WPhase.TRadiobutton")
9689 
9690 def BAWGBPhase(temp):
9691  global AWGBPhaseEntry, AWGBPhasevalue
9692 
9693  try:
9694  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
9695  except:
9696  AWGBPhaseEntry.delete(0,"end")
9697  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9698 
9699  if AWGBPhasevalue > 360: # max phase is 360 degrees
9700  AWGBPhasevalue = 360
9701  AWGBPhaseEntry.delete(0,"end")
9702  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9703  if AWGBPhasevalue < 0: # min phase is 0 degrees
9704  AWGBPhasevalue = 0
9705  AWGBPhaseEntry.delete(0,"end")
9706  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
9707 
9708 def BAWGBDutyCycle(temp):
9709  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
9710 
9711  try:
9712  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
9713  except:
9714  AWGBDutyCycleEntry.delete(0,"end")
9715  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9716 
9717  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
9718  AWGBDutyCyclevalue = 1
9719  AWGBDutyCycleEntry.delete(0,"end")
9720  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
9721  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
9722  AWGBDutyCyclevalue = 0
9723  AWGBDutyCycleEntry.delete(0,"end")
9724  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
9725  # UpdateAWGB()
9726 
9728  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
9729 
9730  if AWGBShape.get() == 0:
9731  AWGBWave = 'dc'
9732  duty2lab.config(text="%")
9733  BAWGBPhaseDelay()
9734  if AWGBShape.get() == 1:
9735  AWGBWave = 'sine'
9736  duty2lab.config(text="%")
9737  BAWGBPhaseDelay()
9738  if AWGBShape.get() == 2:
9739  AWGBWave = 'triangle'
9740  duty2lab.config(text="%")
9741  BAWGBPhaseDelay()
9742  if AWGBShape.get() == 3:
9743  AWGBWave = 'sawtooth'
9744  duty2lab.config(text="%")
9745  BAWGBPhaseDelay()
9746  if AWGBShape.get() == 4:
9747  AWGBWave = 'square'
9748  duty2lab.config(text="%")
9749  BAWGBPhaseDelay()
9750  if AWGBShape.get() == 5:
9751  AWGBWave = 'stairstep'
9752  duty2lab.config(text="%")
9753  BAWGBPhaseDelay()
9754  if AWGBShape.get() > 5:
9755  AWGBWave = 'arbitrary'
9756  if AWG_2X.get() == 1:
9757  CHB.mode = CHA.mode
9758  AWGBWave = 'arbitrary'
9759  # UpdateAWGB()
9760 
9762  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X
9763 
9764  # Read values from CVS file
9765  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
9766  try:
9767  CSVFile = open(filename)
9768  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
9769  CSVFile.seek(0)
9770  #csv_f = csv.reader(CSVFile, dialect)
9771  csv_f = csv.reader(CSVFile, csv.excel)
9772  except:
9773  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
9774  AWGBwaveform = []
9775  ColumnNum = 0
9776  ColumnSel = 0
9777  RowNum = 0
9778  for row in csv_f:
9779  if len(row) > 1 and ColumnSel == 0:
9780  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
9781  ColumnNum = int(RequestColumn) - 1
9782  ColumnLen = str(len(row))
9783  ColumnSel = 1
9784  try:
9785  colnum = 0
9786  for col in row:
9787  if colnum == ColumnNum:
9788  AWGBwaveform.append(float(col))
9789  colnum += 1
9790  except:
9791  print( 'skipping non-numeric row', RowNum)
9792  RowNum += 1
9793  AWGBwaveform = numpy.array(AWGBwaveform)
9795  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9796  CSVFile.close()
9797  UpdateAwgCont()
9798 
9799 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
9801  global AWG_2X, AWGB2X, AWGBwaveform
9802 
9803  if AWG_2X.get() == 2:
9804  Tempwaveform = []
9805  AWGB2X = []
9806  AWGB2X = AWGBwaveform[::2] # even numbered samples
9807  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
9808  AWGBwaveform = Tempwaveform
9809 #
9811  global AWGBwaveform, AWGBLength, awgwindow
9812  global AWG_2X, AWGA2X
9813 
9814 # Read values from WAV file
9815  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
9816  try:
9817  spf = wave.open(filename,'r')
9818  except:
9819  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
9820  AWGBwaveform = []
9821  #If Stereo
9822  if spf.getnchannels() == 2:
9823  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
9824  return()
9825  #Extract Raw Audio from Wav File
9826  Length = spf.getnframes()
9827  if Length > 90000: # limit to first 90K samples
9828  Length = 90000
9829  signal = spf.readframes(Length)
9830  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
9831  # offset and scale for 0 5 V range
9832  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
9833  AWGBwaveform = numpy.array(AWGBwaveform)
9835  AWGBLength.config(text = "L = " + str(len(AWGBwaveform))) # change displayed value
9836  spf.close()
9837  UpdateAwgCont()
9838 
9840  global AWGBwaveform, AWGBLength, awgwindow
9841 
9842  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
9843  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
9844 
9846  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
9847  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
9848  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
9849  global DFiltACoef, DFiltBCoef
9850  global AWG_2X, AWGA2X
9851 
9852  TempString = AWGBMathString
9853  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
9854  if (AWGBMathString == None): # If Cancel pressed, then None
9855  AWGBMathString = TempString
9856  return
9857  AWGBwaveform = eval(AWGBMathString)
9858  AWGBwaveform = numpy.array(AWGBwaveform)
9860  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9861  UpdateAwgCont()
9862 #
9864  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
9865  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9866  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
9867 
9868  Max_termStr = askstring("AWG B Fourier", "\nEnter Max Harmonic:\n", parent=awgwindow)
9869  if (Max_termStr == None): # If Cancel pressed, then None
9870  return
9871  Max_term = int(Max_termStr)
9872 
9873  BAWGBAmpl(0)
9874  BAWGBOffset(0)
9875  BAWGBFreq(0)
9876  if AWG_2X.get() == 1:
9877  TempRate = (BaseSampleRate*2)
9878  else:
9879  TempRate = BaseSampleRate
9880  AWGBwaveform = []
9881  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, TempRate/AWGBFreqvalue)) # the fundamental
9882  k = 3
9883  while k <= Max_term:
9884  # Add odd harmonics up to max_term
9885  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, TempRate/AWGBFreqvalue)))
9886  AWGBwaveform = AWGBwaveform + Harmonic
9887  k = k + 2 # skip even numbers
9888  if AWG_Amp_Mode.get() == 0:
9889  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
9890  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
9891  else:
9892  amplitude = AWGBAmplvalue
9893  offset = AWGBOffsetvalue
9894  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
9896  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9897  duty2lab.config(text="Harmonics")
9898  UpdateAwgCont()
9899 #
9901  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
9902  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
9903  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
9904 
9905  BAWGBAmpl(0)
9906  BAWGBOffset(0)
9907  BAWGBFreq(0)
9908  BAWGBPhase(0)
9909  BAWGBDutyCycle(0)
9910 
9911  if AWGBFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
9912  AWGBShape.set(1)
9913  BAWGBShape()
9914  UpdateAwgCont()
9915  return
9916 
9917  if AWGBFreqvalue > 0.0:
9918  if AWG_2X.get() == 2:
9919  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
9920  else:
9921  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
9922  else:
9923  AWGBperiodvalue = 10.0
9924 
9925  if AWGBPhaseDelay.get() == 0:
9926  if AWGBPhasevalue > 0:
9927  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
9928  else:
9929  AWGBdelayvalue = 0.0
9930  elif AWGBPhaseDelay.get() == 1:
9931  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
9932  Cycles = int(32768/AWGBperiodvalue)
9933  if Cycles < 1:
9934  Cycles = 1
9935  RecLength = int(Cycles * AWGBperiodvalue)
9936  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
9937  RecLength = RecLength + 1
9938  AWGBwaveform = []
9939  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
9940  if AWGBMode.get() == 1: # convert to mA
9941  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
9942  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
9943  else:
9944  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
9945  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
9946  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
9947  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
9948  #
9949  if AWG_2X.get() == 2:
9950  Tempwaveform = []
9951  AWGB2X = []
9952  AWGB2X = AWGBwaveform[::2] # even numbered samples
9953  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
9954  AWGBwaveform = Tempwaveform
9955  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9956  BAWGBPhaseDelay()
9957  duty2lab.config(text="%")
9958  UpdateAwgCont()
9959 #
9961  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
9962  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
9963  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
9964 
9965  BAWGBAmpl(0)
9966  BAWGBOffset(0)
9967  BAWGBFreq(0)
9968  BAWGBPhase(0)
9969  BAWGBDutyCycle(0)
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 = 0.0
9978  if AWG_Amp_Mode.get() == 1:
9979  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
9980  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
9981  else:
9982  MaxV = AWGBOffsetvalue
9983  MinV = AWGBAmplvalue
9984 
9985  PulseWidth = int(AWGBDutyCyclevalue*100)
9986  PulseSamples = int(AWGBperiodvalue/PulseWidth)
9987  AWGBwaveform = []
9988  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
9989  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
9990  # print(v)
9991  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
9992  if j >= v:
9993  AWGBwaveform.append(MaxV) # j>=v?1:0
9994  else:
9995  AWGBwaveform.append(MinV) # j>=v?1:0
9997  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
9998  duty2lab.config(text="PWidth")
9999  UpdateAwgCont()
10000 #
10002  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
10003  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
10004  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10005 
10006  BAWGBAmpl(0)
10007  BAWGBOffset(0)
10008  BAWGBFreq(0)
10009  BAWGBPhase(0)
10010  BAWGBDutyCycle(0)
10011 
10012  if AWGBFreqvalue > 0.0:
10013  if AWG_2X.get() == 1:
10014  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
10015  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10016  AWGBperiodvalue = AWGBperiodvalue + 1
10017  else:
10018  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10019  else:
10020  AWGBperiodvalue = 0.0
10021  if AWG_Amp_Mode.get() == 1:
10022  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10023  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10024  else:
10025  MaxV = AWGBOffsetvalue
10026  MinV = AWGBAmplvalue
10027 
10028  if AWGBPhaseDelay.get() == 0:
10029  if AWGBPhasevalue > 0:
10030  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10031  else:
10032  AWGBdelayvalue = 0.0
10033  elif AWGBPhaseDelay.get() == 1:
10034  AWGBdelayvalue = AWGBPhasevalue * SampleRate / 1000
10035 
10036  Cycles = int(AWGBDutyCyclevalue*100)
10037  NCycles = -1 * Cycles
10038  AWGBwaveform = []
10039  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, SAMPLErate/AWGBFreqvalue))
10040  amplitude = (MaxV-MinV) / 2.0
10041  offset = (MaxV+MinV) / 2.0
10042  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
10043  Cycles = int(37500/AWGBperiodvalue)
10044  if Cycles < 1:
10045  Cycles = 1
10046  if Cycles > 1:
10047  Extend = int((Cycles-1.0)*AWGBperiodvalue/2.0)
10048  AWGBwaveform = numpy.pad(AWGBwaveform, (Extend,Extend), 'wrap')
10049  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10051  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10052  #BAWGAPhaseDelay()
10053  duty2lab.config(text="Cycles")
10054  UpdateAwgCont()
10055 #
10057  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10058  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10059  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10060  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10061  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10062 
10063  BAWGBAmpl(0)
10064  BAWGBOffset(0)
10065  BAWGBFreq(0)
10066  BAWGBPhase(0)
10067  BAWGBDutyCycle(0)
10068 
10069  if AWGBFreqvalue > 0.0:
10070  if AWG_2X.get() == 2:
10071  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10072  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10073  else:
10074  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10075  SamplesPermS = int(BaseSampleRate/1000) # 100
10076  else:
10077  AWGBperiodvalue = 0.0
10078  if AWG_Amp_Mode.get() == 1:
10079  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10080  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10081  else:
10082  MaxV = AWGBOffsetvalue
10083  MinV = AWGBAmplvalue
10084  AWGBwaveform = []
10085  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
10086  if SlopeValue <= 0:
10087  SlopeValue = 1
10088  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10089  if PulseWidth <=0:
10090  PulseWidth = 1
10091  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
10092  if Remainder <= 0:
10093  Remainder = 1
10094  PulseWidth = PulseWidth - SlopeValue
10095  if PulseWidth <=0:
10096  PulseWidth = 1
10097  StepAmp = (MaxV - MinV)/2
10098  StepOff = (MaxV + MinV)/2
10099  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
10100  MidArray = numpy.ones(PulseWidth) * MinV
10101  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
10102  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
10103  if AWGBBurstFlag.get() == 1:
10104  TempOneCycle = AWGBwaveform
10105  for i in range(AWGBCycles-1):
10106  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10107  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10108  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10110  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10111  duty2lab.config(text="%")
10112  phaseblab.config(text = "Rise Time")
10113  UpdateAwgCont()
10114 #
10116  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10117  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10118  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10119  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10120  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10121 
10122  BAWGBAmpl(0)
10123  BAWGBOffset(0)
10124  BAWGBFreq(0)
10125  BAWGBPhase(0)
10126  BAWGBDutyCycle(0)
10127 
10128  if AWGBFreqvalue > 0.0:
10129  if AWG_2X.get() == 2:
10130  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10131  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10132  else:
10133  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10134  SamplesPermS = int(BaseSampleRate/1000) # 100
10135  else:
10136  AWGBperiodvalue = 0.0
10137  if AWG_Amp_Mode.get() == 1:
10138  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10139  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10140  else:
10141  MaxV = AWGBOffsetvalue
10142  MinV = AWGBAmplvalue
10143  AWGBwaveform = []
10144  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
10145  if SlopeValue <= 0:
10146  SlopeValue = 1
10147  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10148  if PulseWidth <=0:
10149  PulseWidth = 1
10150  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
10151  if Remainder <= 0:
10152  Remainder = 1
10153  PulseWidth = PulseWidth - SlopeValue
10154  if PulseWidth <=0:
10155  PulseWidth = 1
10156  StepValue = (MaxV - MinV) / SlopeValue
10157  SampleValue = MinV
10158  for i in range(SlopeValue):
10159  AWGBwaveform.append(SampleValue)
10160  SampleValue = SampleValue + StepValue
10161  for i in range(PulseWidth):
10162  AWGBwaveform.append(MaxV)
10163  for i in range(SlopeValue):
10164  AWGBwaveform.append(SampleValue)
10165  SampleValue = SampleValue - StepValue
10166  for i in range(Remainder):
10167  AWGBwaveform.append(MinV)
10168  if AWGBBurstFlag.get() == 1:
10169  TempOneCycle = AWGBwaveform
10170  for i in range(AWGBCycles-1):
10171  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10172  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10173  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10175  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10176  duty2lab.config(text="%")
10177  phaseblab.config(text = "Rise Time")
10178  UpdateAwgCont()
10179 #
10181  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10182  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10183  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10184  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10185  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10186 
10187  BAWGBAmpl(0)
10188  BAWGBOffset(0)
10189  BAWGBFreq(0)
10190  BAWGBPhase(0)
10191 
10192  try:
10193  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
10194  except:
10195  AWGBDutyCycleEntry.delete(0,"end")
10196  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
10197 
10198  if AWGBFreqvalue > 0.0:
10199  if AWG_2X.get() == 2:
10200  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10201  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10202  else:
10203  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10204  SamplesPermS = int(BaseSampleRate/1000) # 100
10205  else:
10206  AWGBperiodvalue = 0.0
10207  if AWG_Amp_Mode.get() == 1:
10208  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10209  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10210  else:
10211  MaxV = AWGBOffsetvalue
10212  MinV = AWGBAmplvalue
10213  AWGBwaveform = []
10214  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
10215  if SlopeValue <= 0:
10216  SlopeValue = 1
10217  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
10218  if PulseWidth <=0:
10219  PulseWidth = 1
10220  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
10221  if Remainder <= 0:
10222  Remainder = 1
10223  PulseWidth = PulseWidth - SlopeValue
10224  if PulseWidth <=0:
10225  PulseWidth = 1
10226  StepValue = (MaxV - MinV) / SlopeValue
10227  SampleValue = MinV
10228  for i in range(SlopeValue):
10229  AWGBwaveform.append(SampleValue)
10230  SampleValue = SampleValue + StepValue
10231  for i in range(PulseWidth):
10232  AWGBwaveform.append(MaxV)
10233  for i in range(SlopeValue):
10234  AWGBwaveform.append(SampleValue)
10235  SampleValue = SampleValue - StepValue
10236  for i in range(Remainder):
10237  AWGBwaveform.append(MinV)
10238  if AWGBBurstFlag.get() == 1:
10239  TempOneCycle = AWGBwaveform
10240  for i in range(AWGBCycles-1):
10241  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10242  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10243  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10245  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10246  duty2lab.config(text="Width mS")
10247  phaseblab.config(text = "Rise Time")
10248  UpdateAwgCont()
10249 #
10251  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10252  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10253  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10254  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10255  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10256 
10257  BAWGBAmpl(0)
10258  BAWGBOffset(0)
10259  BAWGBFreq(0)
10260  BAWGBPhase(0)
10261  BAWGBDutyCycle(0)
10262 
10263  if AWGBFreqvalue > 0.0:
10264  if AWG_2X.get() == 2:
10265  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10266  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10267  else:
10268  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10269  SamplesPermS = int(BaseSampleRate/1000) # 100
10270  else:
10271  AWGBperiodvalue = 0.0
10272  if AWG_Amp_Mode.get() == 1:
10273  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10274  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10275  else:
10276  MaxV = AWGBOffsetvalue
10277  MinV = AWGBAmplvalue
10278  AWGBwaveform = []
10279  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
10280  if SlopeValue <= 0:
10281  SlopeValue = 1
10282  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10283  if PulseWidth <=0:
10284  PulseWidth = 1
10285  Remainder = int(AWGBperiodvalue - PulseWidth)
10286  if Remainder <= 0:
10287  Remainder = 1
10288  PulseWidth = PulseWidth - SlopeValue
10289  if PulseWidth <=0:
10290  PulseWidth = 1
10291  StepValue = (MaxV - MinV) / SlopeValue
10292  SampleValue = MinV
10293  for i in range(SlopeValue):
10294  AWGBwaveform.append(SampleValue)
10295  SampleValue = SampleValue + StepValue
10296  for i in range(PulseWidth):
10297  AWGBwaveform.append(MaxV)
10298  for i in range(Remainder):
10299  AWGBwaveform.append(MinV)
10300  if AWGBBurstFlag.get() == 1:
10301  TempOneCycle = AWGBwaveform
10302  for i in range(AWGBCycles-1):
10303  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10304  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10305  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10307  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10308  duty2lab.config(text="%")
10309  phaseblab.config(text = "Slope Time")
10310  UpdateAwgCont()
10311 #
10313  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10314  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10315  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10316  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10317  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10318 
10319  BAWGBAmpl(0)
10320  BAWGBOffset(0)
10321  BAWGBFreq(0)
10322  BAWGBPhase(0)
10323  BAWGBDutyCycle(0)
10324 
10325  if AWGBFreqvalue > 0.0:
10326  if AWG_2X.get() == 2:
10327  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10328  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10329  else:
10330  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10331  SamplesPermS = int(BaseSampleRate/1000) # 100
10332  else:
10333  AWGBperiodvalue = 0.0
10334  if AWG_Amp_Mode.get() == 1:
10335  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10336  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10337  else:
10338  MaxV = AWGBOffsetvalue
10339  MinV = AWGBAmplvalue
10340  #
10341  if AWGBPhaseDelay.get() == 0:
10342  if AWGBPhasevalue > 0:
10343  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10344  else:
10345  AWGBdelayvalue = 0.0
10346  elif AWGBPhaseDelay.get() == 1:
10347  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
10348  #
10349  AWGBwaveform = []
10350  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
10351  if PulseWidth <=0:
10352  PulseWidth = 1
10353  Remainder = int(AWGBperiodvalue - PulseWidth)
10354  if Remainder <= 0:
10355  Remainder = 1
10356  UpStepValue = (MaxV - MinV) / PulseWidth
10357  DownStepValue = (MaxV - MinV) / Remainder
10358  SampleValue = MinV
10359  for i in range(PulseWidth):
10360  AWGBwaveform.append(SampleValue)
10361  SampleValue = SampleValue + UpStepValue
10362  for i in range(Remainder):
10363  AWGBwaveform.append(SampleValue)
10364  SampleValue = SampleValue - DownStepValue
10365  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
10366  if AWGBBurstFlag.get() == 1:
10367  TempOneCycle = AWGBwaveform
10368  for i in range(AWGBCycles-1):
10369  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10370  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10371  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10373  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10374  BAWGBPhaseDelay()
10375  duty2lab.config(text = "Symmetry")
10376  UpdateAwgCont()
10377 #
10379  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
10380  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
10381  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10382  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10383  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10384 
10385  BAWGBAmpl(0)
10386  BAWGBOffset(0)
10387  BAWGBFreq(0)
10388  BAWGBPhase(0)
10389  BAWGBDutyCycle(0)
10390 
10391  if AWGBFreqvalue > 0.0:
10392  if AWG_2X.get() == 2:
10393  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10394  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10395  else:
10396  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10397  SamplesPermS = int(BaseSampleRate/1000) # 100
10398  else:
10399  AWGBperiodvalue = 0.0
10400  MaxV = AWGBOffsetvalue
10401  MinV = AWGBAmplvalue
10402  if AWG_Amp_Mode.get() == 1:
10403  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10404  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10405  else:
10406  MaxV = AWGBOffsetvalue
10407  MinV = AWGBAmplvalue
10408  AWGBwaveform = []
10409  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
10410  if AWGBPhaseDelay.get() == 0:
10411  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
10412  elif AWGBPhaseDelay.get() == 1:
10413  DelayValue = int(AWGBPhasevalue*SamplesPermS)
10414  for i in range(DelayValue-PulseWidth):
10415  AWGBwaveform.append((MinV+MaxV)/2)
10416  for i in range(PulseWidth):
10417  AWGBwaveform.append(MaxV)
10418  for i in range(PulseWidth):
10419  AWGBwaveform.append(MinV)
10420  DelayValue = int(AWGBperiodvalue-DelayValue)
10421  for i in range(DelayValue-PulseWidth):
10422  AWGBwaveform.append((MinV+MaxV)/2)
10423  if AWGBBurstFlag.get() == 1:
10424  TempOneCycle = AWGBwaveform
10425  for i in range(AWGBCycles-1):
10426  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10427  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10428  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
10430  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10431  UpdateAwgCont()
10432 
10434  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
10435  global AWGBLength, AWGBperiodvalue, 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 
10443  if AWGBFreqvalue > 0.0:
10444  if AWG_2X.get() == 2:
10445  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10446  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10447  else:
10448  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10449  SamplesPermS = int(BaseSampleRate/1000) # 100
10450  else:
10451  AWGBperiodvalue = 0.0
10452 
10453  if AWGBAmplvalue > AWGBOffsetvalue:
10454  MinV = AWGBOffsetvalue
10455  MaxV = AWGBAmplvalue
10456  else:
10457  MaxV = AWGBOffsetvalue
10458  MinV = AWGBAmplvalue
10459  if AWG_Amp_Mode.get() == 1:
10460  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10461  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10462  AWGBwaveform = []
10463  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
10464  Mid = (MaxV+MinV)/2
10465  if AWGBBurstFlag.get() == 1:
10466  TempOneCycle = AWGBwaveform
10467  for i in range(AWGBCycles-1):
10468  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10469  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10470  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
10472  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10473  UpdateAwgCont()
10474 
10476  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
10477  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10478  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
10479  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
10480 
10481  BAWGBAmpl(0)
10482  BAWGBOffset(0)
10483  BAWGBFreq(0)
10484 
10485  if AWGBFreqvalue > 0.0:
10486  if AWG_2X.get() == 2:
10487  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
10488  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10489  else:
10490  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
10491  SamplesPermS = int(BaseSampleRate/1000) # 100
10492  else:
10493  AWGBperiodvalue = 0.0
10494  if AWGBAmplvalue > AWGBOffsetvalue:
10495  MinV = AWGBOffsetvalue
10496  MaxV = AWGBAmplvalue
10497  else:
10498  MaxV = AWGBOffsetvalue
10499  MinV = AWGBAmplvalue
10500  if AWG_Amp_Mode.get() == 1:
10501  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10502  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10503  AWGBwaveform = []
10504  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
10505  Mid = (MaxV+MinV)/2
10506  if AWGBBurstFlag.get() == 1:
10507  TempOneCycle = AWGBwaveform
10508  for i in range(AWGBCycles-1):
10509  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
10510  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
10511  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
10513  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
10514  UpdateAwgCont()
10515 
10517  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
10518 
10519  if AWGBMode.get() == 0: # Source Voltage measure current mode
10520  label_txt = "SVMI"
10521  elif AWGBMode.get() == 1: # Source current measure voltage mode
10522  label_txt = "SIMV"
10523  elif AWGBMode.get() == 2: # High impedance mode
10524  label_txt = "Hi-Z"
10525  if AWGBIOMode.get() > 0: # Split Input / Output mode
10526  if HWRevOne == "D":
10527  if AWGBMode.get() == 0:
10528  AWGBMode.set(1)
10529  CHB.set_mode('i') # channel must be in source current mode for rev D boards
10530  label_txt = "SIMV"
10531  label_txt = label_txt + " Split I/O"
10532  label_txt = label_txt + " Mode"
10533  AWGBModeLabel.config(text = label_txt ) # change displayed value
10534  ReMakeAWGwaves()
10535  #UpdateAwgCont()
10536 
10538  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
10539  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
10540  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
10541  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
10542  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
10543  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10544  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag
10545 
10546  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
10547  amp2lab.config(text = "Min Ch B" ) # change displayed value
10548  off2lab.config(text = "Max Ch B" ) # change displayed value
10549  else:
10550  amp2lab.config(text = "Amp Ch B" )
10551  off2lab.config(text = "Off Ch B" )
10552 #
10553  if AWG_2X.get() == 1:
10554  AWGBWave = 'arbitrary'
10555  if AWGBFreqvalue > 0.0:
10556  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
10557  else:
10558  AWGBperiodvalue = 0.0
10559 #
10560  if AWGBPhaseDelay.get() == 0:
10561  if AWGBWave == 'square':
10562  AWGBPhasevalue = AWGBPhasevalue + 270.0
10563  if AWGBPhasevalue > 359:
10564  AWGBPhasevalue = AWGBPhasevalue - 360
10565  if AWGBPhasevalue > 0:
10566  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
10567  else:
10568  AWGBdelayvalue = 0.0
10569  elif AWGBPhaseDelay.get() == 1:
10570  AWGBdelayvalue = AWGBPhasevalue * 100
10571 #
10572  if AWGBTerm.get() == 0: # Open termination
10573  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
10574  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
10575  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
10576  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
10577  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
10578  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
10579  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
10580  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
10581 
10582  if AWGBWave == 'dc':
10583  if AWG_2X.get() == 1:
10584  AWGBWave == 'arbitrary'
10585  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
10586  else:
10587  if AWGBMode.get() == 0: # Source Voltage measure current mode
10588  if AWGBIOMode.get() == 0:
10589  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
10590  else:
10591  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
10592  CHB.constant(AWGBOffsetvalue)
10593  if AWGBMode.get() == 1: # Source current measure Voltage mode
10594  if AWGBIOMode.get() == 0:
10595  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
10596  else:
10597  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
10598  CHB.constant(AWGBOffsetvalue/1000)
10599  if AWGBMode.get() == 2: # Hi impedance mode
10600  if AWGBIOMode.get() == 0:
10601  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
10602  else:
10603  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
10604 #
10605  if AWGBIOMode.get() > 0: # Split Input / Output mode
10606  if HWRevOne == "D":
10607  AWGBMode.set(1)
10608  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
10609 #
10610  else:
10611  if AWGBMode.get() == 0: # Source Voltage measure current mode
10612  if AWGBIOMode.get() == 0:
10613  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
10614  else:
10615  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
10616  if AWGBMode.get() == 1: # Source current measure Voltage mode
10617  if AWGBIOMode.get() == 0:
10618  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
10619  else:
10620  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
10621  AWGBOffsetvalue = AWGBOffsetvalue/1000
10622  AWGBAmplvalue = AWGBAmplvalue/1000
10623  if AWGBMode.get() == 2: # Hi impedance mode
10624  if AWGBIOMode.get() == 0:
10625  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
10626  else:
10627  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
10628  else:
10629  if AWG_Amp_Mode.get() == 1:
10630  MaxV = (AWGBOffsetvalue+AWGBAmplvalue)
10631  MinV = (AWGBOffsetvalue-AWGBAmplvalue)
10632  else:
10633  MaxV = AWGBOffsetvalue
10634  MinV = AWGBAmplvalue
10635  try: # keep going even if low level library returns an error
10636  if AWGBWave == 'sine':
10637  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10638  elif AWGBWave == 'triangle':
10639  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10640  elif AWGBWave == 'sawtooth':
10641  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10642  elif AWGBWave == 'square':
10643  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
10644  elif AWGBWave == 'stairstep':
10645  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
10646  elif AWGBWave == 'arbitrary':
10647  if AWGSync.get() == 0:
10648  AWGBRepeatFlag.set(1)
10649  if AWG_2X.get() == 1:
10650  AWGBWave == 'arbitrary'
10651  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
10652  else:
10653  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
10654  except:
10655  donothing()
10656  if AWGBIOMode.get() > 0: # Split Input / Output mode
10657  if HWRevOne == "D":
10658  AWGBMode.set(1)
10659  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
10660 #
10662  global session, CHA, CHB, AWGSync
10663  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
10664  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
10665  if session.continuous:
10666  session.end()
10667  BAWGEnab() # set-up new AWG settings
10668  time.sleep(0.01) # wait awhile here for some reason
10669  session.start(0)
10670 #
10672  UpdateAwgCont()
10673 
10674 def BAWGEnab():
10675  global AWGAMode, AWGBMode, AWGSync
10676  global CHA, CHB, discontloop, contloop, session
10677 
10678  # Stream = False
10679  # print "Updateing AWGs"
10680  BAWGAAmpl(0)
10681  BAWGAOffset(0)
10682  BAWGAFreq(0)
10683  BAWGAPhase(0)
10684  BAWGADutyCycle(0)
10685  BAWGAShape()
10686  BAWGBAmpl(0)
10687  BAWGBOffset(0)
10688  BAWGBFreq(0)
10689  BAWGBPhase(0)
10690  BAWGBDutyCycle(0)
10691  BAWGBShape()
10692  UpdateAWGA()
10693  UpdateAWGB()
10694 
10695 def BAWGSync():
10696  global RUNstatus, AWGSync, session, CHA, CHB
10697 
10698  if (RUNstatus.get() == 1): # do this only if running
10699  if AWGSync.get() == 0:
10700  #UpdateAwgCont()
10701  session.flush()
10702  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
10703  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
10704  BAWGEnab()
10705  session.start(0)
10706  time.sleep(0.02) # wait awhile here for some reason
10707  elif session.continuous:
10708  session.end()
10709  session.flush()
10710  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
10711  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
10712 
10713 # ======= Spectrum Analyzer functions ===========
10714 #
10716  global CANVASwidthF, CANVASheightF, freqwindow
10717  global COLORtext
10718  # ask for file name
10719  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
10720  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
10721  if MarkerNum > 0 or ColorMode.get() > 0:
10722  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
10723  else: # temp change text color to black
10724  COLORtext = "#000000"
10726  # save postscript file
10727  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
10728  #
10729  COLORtext = "#ffffff"
10731 #
10732 def Bnot():
10733  print( "Routine not made yet")
10734 
10736  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
10737  ShowC1_VdB.set(1)
10738  ShowC1_P.set(1)
10739  ShowC2_VdB.set(1)
10740  ShowC2_P.set(1)
10741 
10743  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
10744  ShowC1_VdB.set(0)
10745  ShowC1_P.set(0)
10746  ShowC2_VdB.set(0)
10747  ShowC2_P.set(0)
10748 
10750  global RUNstatus
10751  global FreqTraceMode
10752 
10753  FreqTraceMode.set(1)
10754  if RUNstatus.get() == 0: # Update if stopped
10756  if RUNstatus.get() == 2: # Restart if running
10757  RUNstatus.set(4)
10758 
10760  global RUNstatus
10761  global FreqTraceMode
10762 
10763  FreqTraceMode.set(2)
10764  if RUNstatus.get() == 0: # Update if stopped
10766  if RUNstatus.get() == 2: # Restart if running
10767  RUNstatus.set(4)
10768 
10770  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
10771 
10772  FreqTraceMode.set(3)
10773 
10774  if RUNstatus.get() == 0: # Update if stopped
10776  if RUNstatus.get() == 2: # Restart if running
10777  RUNstatus.set(4)
10778 
10780  global FreqTraceMode, TRACEresetFreq
10781 
10782  if FreqTraceMode.get()==3:
10783  TRACEresetFreq = True
10784 
10786  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
10787  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
10788  global T1Pline, T2Pline, T1PRline, T2PRline
10789  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
10790  global PeakxM, PeakyM, PeakMdb, PeakfreqM
10791  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
10792  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
10793  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
10794 
10795  if ShowC1_VdB.get() == 1:
10796  T1FRline = T1Fline
10797  PeakxRA = PeakxA
10798  PeakyRA = PeakyA
10799  PeakdbRA = PeakdbA
10800  PeakfreqRA = PeakfreqA
10801  if ShowC2_VdB.get() == 1:
10802  T2FRline = T2Fline
10803  PeakxRB = PeakxB
10804  PeakyRB = PeakyB
10805  PeakdbRB = PeakdbB
10806  PeakfreqRB = PeakfreqB
10807  if ShowC1_P.get() == 1:
10808  T1PRline = T1Pline
10809  if ShowC2_P.get() == 1:
10810  T2PRline = T2Pline
10811  if ShowMathSA.get() > 0:
10812  TFRMline = TFMline
10813  PeakxRM = PeakxM
10814  PeakyRM = PeakyM
10815  PeakRMdb = PeakMdb
10816  PeakfreqRM = PeakfreqM
10817 
10818  UpdateFreqTrace() # Always Update
10819 #
10821  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
10822  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
10823  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
10824  global TAPline, TBPline, TAPRline, TBPRline
10825  global TIARline, TIAXline, TIAMagline, TIAAngline
10826  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
10827  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
10828  global PeakxM, PeakyM, PeakMdb, PeakfreqM
10829  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
10830  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
10831  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
10832 
10833  if ShowCA_VdB.get() == 1:
10834  TAFRline = TAFline
10835  PeakxRA = PeakxA
10836  PeakyRA = PeakyA
10837  PeakdbRA = PeakdbA
10838  PeakfreqRA = PeakfreqA
10839  if ShowCB_VdB.get() == 1:
10840  TBFRline = TBFline
10841  PeakxRB = PeakxB
10842  PeakyRB = PeakyB
10843  PeakdbRB = PeakdbB
10844  PeakfreqRB = PeakfreqB
10845  if ShowCA_P.get() == 1:
10846  TAPRline = TAPline
10847  if ShowCB_P.get() == 1:
10848  TBPRline = TBPline
10849  if ShowMathBP.get() > 0:
10850  TBPRMline = TBPMline
10851  PeakxRM = PeakxM
10852  PeakyRM = PeakyM
10853  PeakRMdb = PeakMdb
10854  PeakfreqRM = PeakfreqM
10855  if Show_Rseries.get() > 0:
10856  RefIARline = TIARline
10857  if Show_Xseries.get() > 0:
10858  RefIAXline = TIAXline
10859  if Show_Magnitude.get() > 0:
10860  RefIAMagline = TIAMagline
10861  if Show_Angle.get() > 0:
10862  RefIAAngline = TIAAngline
10863  UpdateBodeTrace() # Always Update
10864 #
10865 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
10866  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
10867  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
10868 
10869  # Set the TRACEsize variable
10870  if ShowCA_VdB.get() == 1:
10871  TRACEsize = len(FSweepAdB) # Set the trace length
10872  elif ShowCA_VdB.get() == 1:
10873  TRACEsize = len(FSweepBdB)
10874  if TRACEsize == 0: # If no trace, skip rest of this routine
10875  return()
10876 # ask if save as magnitude or dB
10877  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
10878 # Yes 1 = dB, No 0 = Mag
10879  # Make the file name and open it
10880  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
10881  filename = "Bode-" + tme
10882  filename = filename + ".csv"
10883  # open file to save data
10884  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
10885  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
10886  DataFile = open(filename,'a') # Open output file
10887  HeaderString = 'Frequency-#, '
10888  if ShowCA_VdB.get() == 1:
10889  if dB == 1:
10890  HeaderString = HeaderString + 'CA-dB, '
10891  if dB == 0:
10892  HeaderString = HeaderString + 'CA-Mag, '
10893  if ShowCB_VdB.get() == 1:
10894  if dB == 1:
10895  HeaderString = HeaderString + 'CB-dB, '
10896  if dB == 0:
10897  HeaderString = HeaderString + 'CB-Mag, '
10898  if ShowCA_P.get() == 1:
10899  HeaderString = HeaderString + 'Phase A-B, '
10900  if ShowCB_P.get() == 1:
10901  HeaderString = HeaderString + 'Phase B-A, '
10902  HeaderString = HeaderString + '\n'
10903  DataFile.write( HeaderString )
10904 
10905  n = 0
10906  while n < len(FSweepAdB):
10907  F = FBins[FStep[n]] # look up frequency bin in list of bins
10908  txt = str(F)
10909  if ShowCA_VdB.get() == 1:
10910  V = 10 * math.log10(float(FSweepAdB[n])) + 17 # Add 17 dB for max value of +10 dB
10911  if dB == 0:
10912  V = 10.0**(V/20.0)
10913  txt = txt + "," + str(V)
10914  if ShowCB_VdB.get() == 1:
10915  V = 10 * math.log10(float(FSweepBdB[n])) + 17 # Add 17 dB for max value of +10 dB
10916  if dB == 0:
10917  V = 10.0**(V/20.0)
10918  txt = txt + "," + str(V)
10919  if ShowCA_P.get() == 1:
10920  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
10921  if RelPhase > 180:
10922  RelPhase = RelPhase - 360
10923  elif RelPhase < -180:
10924  RelPhase = RelPhase + 360
10925  txt = txt + "," + str(RelPhase)
10926  if ShowCB_P.get() == 1:
10927  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
10928  if RelPhase > 180:
10929  RelPhase = RelPhase - 360
10930  elif RelPhase < -180:
10931  RelPhase = RelPhase + 360
10932  txt = txt + "," + str(RelPhase)
10933  txt = txt + "\n"
10934  DataFile.write(txt)
10935  n = n + 1
10936 
10937  DataFile.close() # Close the file
10938 
10940  global iawindow, FStep, FBins
10941  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
10942 
10943  if NetworkScreenStatus.get() > 0:
10944  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
10945  filename = "Impedance-" + tme
10946  filename = filename + ".csv"
10947  # open file to save data
10948  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
10949  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
10950  DataFile = open(filename,'a') # Open output file
10951  HeaderString = 'Frequency, Series R, Seriec X, Series Z, Series Angle'
10952  HeaderString = HeaderString + '\n'
10953  DataFile.write( HeaderString )
10954 
10955  n = 0
10956  while n < len(NSweepSeriesR):
10957  F = FBins[FStep[n]] # look up frequency bin in list of bins
10958  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
10959  txt = txt + "\n"
10960  DataFile.write(txt)
10961  n = n + 1
10962  DataFile.close() # Close the file
10963  else:
10964  return
10965 #
10966 def BStartSA():
10967  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
10968  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
10969  global Two_X_Sample, ADC_Mux_Mode
10970 
10971  #AWGSync.set(0) # always run in continuous mode
10972  if DevID == "No Device":
10973  showwarning("WARNING","No Device Plugged In!")
10974  elif FWRevOne == 0.0:
10975  showwarning("WARNING","Out of data Firmware!")
10976  else:
10977  if PowerStatus == 0:
10978  PowerStatus = 1
10979  PwrBt.config(style="Pwr.TButton",text="PWR-On")
10980  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
10981 
10982  if ShowC1_VdB.get() == 0 and ShowC2_VdB.get() == 0 and ShowMathSA.get() == 0 and ShowC1_P.get() == 0 and ShowC2_P.get() == 0:
10983  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
10984  return()
10985  try:
10986  StopFrequency = float(StopFreqEntry.get())
10987  except:
10988  StopFreqEntry.delete(0,"end")
10989  StopFreqEntry.insert(0,50000)
10990  StopFrequency = 50000
10991  if FWRevOne > 2.16:
10992  if StopFrequency >= 50000:
10993  Two_X_Sample.set(1)
10994  else:
10995  Two_X_Sample.set(0)
10996  ADC_Mux_Mode.set(0)
10997  SetADC_Mux()
10998  #
10999  BStart()
11000 #
11001  UpdateFreqAll() # Always Update
11002 
11003 def BStopSA():
11004  global RUNstatus, session, AWGSync
11005 
11006  if (RUNstatus.get() == 1):
11007  RUNstatus.set(0)
11008  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11009  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
11010  if AWGSync.get() == 0: # running in continuous mode
11011  CHA.constant(0.0)
11012  CHB.constant(0.0)
11013  # print "Stoping continuous mode"
11014  if session.continuous:
11015  # print "Stoping Is Continuous? ", session.continuous
11016  time.sleep(0.02)
11017  #print "Is Continuous? ", session.continuous
11018  else:
11019  contloop = 0
11020  discontloop = 1
11021  session.cancel()
11022  elif (RUNstatus.get() == 2):
11023  RUNstatus.set(3)
11024  elif (RUNstatus.get() == 3):
11025  RUNstatus.set(3)
11026  elif (RUNstatus.get() == 4):
11027  RUNstatus.set(3)
11028  UpdateFreqAll() # Always Update
11029 
11030 def Blevel1():
11031  global DBlevel
11032  global RUNstatus
11033 
11034  DBlevel.set(DBlevel.get() - 1)
11035 
11036  if RUNstatus.get() == 0: # Update if stopped
11037  UpdateFreqTrace()
11038 
11039 def Blevel2():
11040  global DBlevel
11041  global RUNstatus
11042 
11043  DBlevel.set(DBlevel.get() + 1)
11044 
11045  if RUNstatus.get() == 0: # Update if stopped
11046  UpdateFreqTrace()
11047 
11048 def Blevel3():
11049  global DBlevel
11050  global RUNstatus
11051 
11052  DBlevel.set(DBlevel.get() - 10)
11053 
11054  if RUNstatus.get() == 0: # Update if stopped
11055  UpdateFreqTrace()
11056 
11057 def Blevel4():
11058  global DBlevel
11059  global RUNstatus
11060 
11061  DBlevel.set(DBlevel.get() + 10)
11062 
11063  if RUNstatus.get() == 0: # Update if stopped
11064  UpdateFreqTrace()
11065 #
11067  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
11068  global SMPfftpwrTwo, SMPfft, FFTwindow
11069  global TRACEresetFreq
11070 
11071  if FFTwindow.get() != 8:
11072  if (SMPfftpwrTwo.get() > 6): # Min 64
11073  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
11074  TRACEresetFreq = True # Reset trace peak and trace average
11075  SMPfft = 2 ** int(SMPfftpwrTwo.get())
11076 
11077  if RUNstatus.get() == 0: # Update if stopped
11078  if SpectrumScreenStatus.get() > 0:
11080  if IAScreenStatus.get() > 0:
11081  UpdateIAScreen()
11082  if RUNstatus.get() == 2: # Restart if running
11083  RUNstatus.set(4)
11084 
11086  global RUNstatus
11087  global SMPfftpwrTwo, SMPfft, FFTwindow
11088  global TRACEresetFreq
11089 
11090  if FFTwindow.get() != 8:
11091  if (SMPfftpwrTwo.get() < 16): # Max 65536
11092  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
11093  TRACEresetFREQ = True # Reset trace peak and trace average
11094  SMPfft = 2 ** int(SMPfftpwrTwo.get())
11095 
11096  if RUNstatus.get() == 0: # Update if stopped
11097  if SpectrumScreenStatus.get() > 0:
11099  if IAScreenStatus.get() > 0:
11100  UpdateIAScreen()
11101  if RUNstatus.get() == 2: # Restart if running
11102  RUNstatus.set(4)
11103 
11104 def BDBdiv1():
11105  global DBdivindex
11106  global RUNstatus
11107 
11108  if (DBdivindex.get() >= 1):
11109  DBdivindex.set(DBdivindex.get() - 1)
11110 
11111  if RUNstatus.get() == 0: # Update if stopped
11112  UpdateFreqTrace()
11113 
11114 def BDBdiv2():
11115  global DBdivindex
11116  global DBdivlist
11117  global RUNstatus
11118 
11119  if (DBdivindex.get() < len(DBdivlist) - 1):
11120  DBdivindex.set(DBdivindex.get() + 1)
11121 
11122  if RUNstatus.get() == 0: # Update if stopped
11123  UpdateFreqTrace()
11124 #----- Bode Plot controls
11125 def BStartBP():
11126  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
11127  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
11128  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
11129  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
11130  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
11131  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
11132  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
11133  global BeginIndex, EndIndex
11134 
11135  if DevID == "No Device":
11136  showwarning("WARNING","No Device Plugged In!")
11137  elif FWRevOne == 0.0:
11138  showwarning("WARNING","Out of data Firmware!")
11139  else:
11140  if PowerStatus == 0:
11141  PowerStatus = 1
11142  PwrBt.config(style="Pwr.TButton",text="PWR-On")
11143  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
11144 
11145  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
11146  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
11147  return()
11148  #
11149  if ZEROstuffing.get() < 3:
11150  ZEROstuffing.set(3)
11151  CutDC.set(1) # set to remove DC
11152  try:
11153  EndFreq = float(StopBodeEntry.get())
11154  except:
11155  StopBodeEntry.delete(0,"end")
11156  StopBodeEntry.insert(0,10000)
11157  EndFreq = 10000
11158  if FWRevOne > 2.16:
11159  if EndFreq >= 20000:
11160  Two_X_Sample.set(1)
11161  FBins = numpy.linspace(0, 100000, num=16384)
11162  else:
11163  Two_X_Sample.set(0)
11164  FBins = numpy.linspace(0, 50000, num=16384)
11165  ADC_Mux_Mode.set(0)
11166  SetADC_Mux()
11167  try:
11168  BeginFreq = float(StartBodeEntry.get())
11169  except:
11170  StartBodeEntry.delete(0,"end")
11171  StartBodeEntry.insert(0,100)
11172  BeginFreq = 100
11173  #
11174  if FSweepMode.get() == 1:
11175  if AWGAMode.get() == 2:
11176  AWGAMode.set(0) # Set AWG A to SVMI
11177  AWGAShape.set(18) # Set Shape to Sine
11178  if Two_X_Sample.get() == 1:
11179  AWGBIOMode.set(1)
11180  AWGBMode.set(0)
11181  else:
11182  AWGBMode.set(2) # Set AWG B to Hi-Z
11183  AWG_2X.set(0)
11184  BAWG2X()
11185  Reset_Freq = AWGAFreqEntry.get()
11186  if FSweepMode.get() == 2:
11187  if AWGBMode.get() == 2:
11188  AWGBMode.set(0) # Set AWG B to SVMI
11189  AWGBShape.set(18) # Set Shape to Sine
11190  if Two_X_Sample.get() == 1:
11191  AWGAIOMode.set(1)
11192  AWGAMode.set(0)
11193  else:
11194  AWGAMode.set(2) # Set AWG A to Hi-Z
11195  AWG_2X.set(0)
11196  BAWG2X()
11197  Reset_Freq = AWGBFreqEntry.get()
11198  if FSweepMode.get() == 3: # using external Minigen
11199  AWGAMode.set(2) # Set AWG A to Hi-Z
11200  AWGBMode.set(2) # Set AWG B to Hi-Z
11201  try:
11202  NSteps.set(float(SweepStepBodeEntry.get()))
11203  except:
11204  SweepStepBodeEntry.delete(0,"end")
11205  SweepStepBodeEntry.insert(0, NSteps.get())
11206  #
11207  if FSweepMode.get() > 0:
11208  LoopNum.set(1)
11209  NyquistFreq = SAMPLErate/2
11210  BeginIndex = int((BeginFreq/NyquistFreq)*16384)
11211  EndIndex = int((EndFreq/NyquistFreq)*16384)
11212  if NSteps.get() < 5:
11213  NSteps.set(5)
11214  if HScaleBP.get() == 1:
11215  LogFStop = math.log10(EndIndex)
11216  try:
11217  LogFStart = math.log10(BeginIndex)
11218  except:
11219  LogFStart = 1.0
11220  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
11221  else:
11222  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
11223  BStart()
11224  # UpdateBodeAll() # Always Update
11225 #
11226 def BStopBP():
11227  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
11228 
11229  if FSweepMode.get() == 1:
11230  AWGAFreqEntry.delete(0,"end")
11231  AWGAFreqEntry.insert(0, Reset_Freq)
11232  if FSweepMode.get() == 2:
11233  AWGBFreqEntry.delete(0,"end")
11234  AWGBFreqEntry.insert(0, Reset_Freq)
11235 #
11236  if (RUNstatus.get() == 1):
11237  RUNstatus.set(0)
11238  if AWGSync.get() == 0: # running in continuous mode
11239  session.cancel() # cancel continuous session mode while paused
11240  elif (RUNstatus.get() == 2):
11241  RUNstatus.set(3)
11242  elif (RUNstatus.get() == 3):
11243  RUNstatus.set(3)
11244  elif (RUNstatus.get() == 4):
11245  RUNstatus.set(3)
11246  UpdateBodeAll() # Always Update
11247 #
11249  global DBlevelBP
11250  global RUNstatus
11251 
11252  DBlevelBP.set(DBlevelBP.get() - 1)
11253 
11254  if RUNstatus.get() == 0: # Update if stopped
11255  UpdateBodeTrace()
11256 
11258  global DBlevelBP
11259  global RUNstatus
11260 
11261  DBlevelBP.set(DBlevelBP.get() + 1)
11262 
11263  if RUNstatus.get() == 0: # Update if stopped
11264  UpdateBodeTrace()
11265 
11267  global DBlevelBP
11268  global RUNstatus
11269 
11270  DBlevelBP.set(DBlevelBP.get() - 10)
11271 
11272  if RUNstatus.get() == 0: # Update if stopped
11273  UpdateBodeTrace()
11274 
11276  global DBlevelBP
11277  global RUNstatus
11278 
11279  DBlevelBP.set(DBlevelBP.get() + 10)
11280 
11281  if RUNstatus.get() == 0: # Update if stopped
11282  UpdateBodeTrace()
11283 
11285  global DBdivindexBP
11286  global RUNstatus
11287 
11288  if (DBdivindexBP.get() >= 1):
11289  DBdivindexBP.set(DBdivindexBP.get() - 1)
11290 
11291  if RUNstatus.get() == 0: # Update if stopped
11292  UpdateBodeTrace()
11293 
11295  global DBdivindexBP
11296  global DBdivlist
11297  global RUNstatus
11298 
11299  if (DBdivindexBP.get() < len(DBdivlist) - 1):
11300  DBdivindexBP.set(DBdivindexBP.get() + 1)
11301 
11302  if RUNstatus.get() == 0: # Update if stopped
11303  UpdateBodeTrace()
11304 #
11306  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11307  ShowCA_VdB.set(1)
11308  ShowCA_P.set(1)
11309  ShowCB_VdB.set(1)
11310  ShowCB_P.set(1)
11311 
11313  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
11314  ShowCA_VdB.set(0)
11315  ShowCA_P.set(0)
11316  ShowCB_VdB.set(0)
11317  ShowCB_P.set(0)
11318 # Bode Plot refresh
11319 def UpdateBodeAll(): # Update Data, trace and screen
11320  global FFTBuffA, FFTBuffB
11321  global SMPfft
11322 
11323  # DoFFT() # Fast Fourier transformation
11324  MakeBodeTrace() # Update the traces
11325  UpdateBodeScreen() # Update the screen
11326 
11327 def UpdateBodeTrace(): # Update trace and screen
11328  MakeBodeTrace() # Update traces
11329  UpdateBodeScreen() # Update the screen
11330 
11331 def UpdateBodeScreen(): # Update screen with trace and text
11332  MakeBodeScreen() # Update the screen
11333 
11334 # ============================================ Freq Main routine ====================================================
11335 
11336 def UpdateFreqAll(): # Update Data, trace and screen
11337  global FFTBuffA, FFTBuffB
11338  global SMPfft
11339 
11340  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
11341  return
11342 
11343  # DoFFT() # Fast Fourier transformation
11344  MakeFreqTrace() # Update the traces
11345  UpdateFreqScreen() # Update the screen
11346 
11347 def UpdateFreqTrace(): # Update trace and screen
11348  MakeFreqTrace() # Update traces
11349  UpdateFreqScreen() # Update the screen
11350 
11351 def UpdateFreqScreen(): # Update screen with trace and text
11352  MakeFreqScreen() # Update the screen
11353 
11354 def DoFFT(): # Fast Fourier transformation
11355  global FFTBuffA, FFTBuffB
11356  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
11357  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
11358  global FFTmemoryB, FFTresultB
11359  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
11360  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
11361  global FFTwindowshape, FFTbandwidth
11362  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
11363  global SMPfft, LoopNum, IA_Ext_Conf
11364  global STARTsample, STOPsample
11365  global TRACEaverage, FreqTraceMode, FSweepMode
11366  global TRACEresetFreq, ZEROstuffing
11367  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
11368  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
11369 
11370  # T1 = time.time() # For time measurement of FFT routine
11371  REX = []
11372  PhaseA = []
11373  PhaseB = []
11374  # Convert list to numpy array REX for faster Numpy calculations
11375  # Take the first fft samples
11376  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
11377 
11378  # Set Analog level display value MAX value is 5 volts for ALM1000
11379  REX = REX / 5.0
11380 
11381  # Do the FFT window function
11382  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
11383 
11384  # Zero stuffing of array for better interpolation of peak level of signals
11385  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11386  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11387 
11388  # Save previous trace in memory for max or average trace
11389  FFTmemoryA = FFTresultA
11390  if FreqTraceMode.get() == 3:
11391  PhaseMemoryA = PhaseA
11392 
11393  # FFT with numpy
11394  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11395  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
11396  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11397  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
11398 
11399  le = int(len(ALL) / 2) # Only half is used, other half is mirror
11400  ALL = ALL[0:le] # So take only first half of the array
11401  PhaseA = PhaseA[0:le]
11402  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11403  Totalcorr = Totalcorr * Totalcorr # For POWER!
11404  FFTresultA = Totalcorr * ALL
11405 #
11406  REX = []
11407  # Convert list to numpy array REX for faster Numpy calculations
11408  # Take the first fft samples
11409  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
11410 
11411  # Set level display value MAX value is 5 volts for ALM1000
11412  REX = REX / 5.0
11413 
11414  # Do the FFT window function
11415  try:
11416  REX = REX * FFTwindowshape # The windowing shape function only over the samples
11417  except:
11418  return
11419  # Zero stuffing of array for better interpolation of peak level of signals
11420  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11421  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11422 
11423  # Save previous trace in memory for max or average trace
11424  FFTmemoryB = FFTresultB
11425  if FreqTraceMode.get() == 3:
11426  PhaseMemoryB = PhaseB
11427  # FFT with numpy
11428  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11429  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
11430  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11431  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
11432 
11433  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
11434  ALL = ALL[0:le] # So take only first half of the array
11435  PhaseB = PhaseB[0:le]
11436  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11437  Totalcorr = Totalcorr * Totalcorr # For POWER!
11438  FFTresultB = Totalcorr * ALL
11439 #
11440  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
11441  REX = []
11442  PhaseAB = []
11443  # Convert list to numpy array REX for faster Numpy calculations
11444  # Take the first fft samples
11445  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
11446 
11447  # Set level display value MAX value is 5 volts for ALM1000
11448  REX = REX / 5.0
11449 
11450  # Do the FFT window function
11451  REX = REX * FFTwindowshape # The windowing shape function only over the samples
11452 
11453  # Zero stuffing of array for better interpolation of peak level of signals
11454  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
11455  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
11456 
11457  # Save previous trace in memory for max or average trace
11458  # FFTmemoryB = FFTresultB
11459  # if FreqTraceMode.get() == 3:
11460  # PhaseMemoryB = PhaseB
11461  # FFT with numpy
11462  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
11463  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
11464  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
11465  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
11466 
11467  le = len(ALL) / 2 # Only half is used, other half is mirror
11468  ALL = ALL[:le] # So take only first half of the array
11469  PhaseAB = PhaseAB[:le]
11470  Totalcorr = float(ZEROstuffingvalue)/ fftsamples # For VOLTAGE!
11471  Totalcorr = Totalcorr * Totalcorr # For POWER!
11472  FFTresultAB = Totalcorr * ALL
11473 #
11474  TRACEsize = int(len(FFTresultB))
11475  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
11476  if SpectrumScreenStatus.get() > 0:
11477  try:
11478  StartFrequency = float(StartFreqEntry.get())
11479  except:
11480  StartFreqEntry.delete(0,"end")
11481  StartFreqEntry.insert(0,100)
11482  StartFrequency = 100
11483  STARTsample = StartFrequency / Fsample
11484  else:
11485  STARTsample = 0.0
11486  if LoopNum.get() == 1:
11487  PhaseMemoryB = PhaseB
11488  FSweepAdB = []
11489  FSweepBdB = []
11490  FSweepAPh = []
11491  FSweepBPh = []
11492  if NetworkScreenStatus.get() > 0:
11493  NSweepSeriesR = []
11494  NSweepSeriesX = []
11495  NSweepSeriesMag = [] # in ohms
11496  NSweepSeriesAng = [] # in degrees
11497  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
11498  if FSweepMode.get() == 1:
11499  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11500  if ptmax > STARTsample:
11501  STARTsample = ptmax
11502  i = 0
11503  while i < 6:
11504  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11505  i = i + 1
11506  if FSweepMode.get() == 2:
11507  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11508  if ptmax > STARTsample:
11509  STARTsample = ptmax
11510  i = 0
11511  while i < 6:
11512  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11513  i = i + 1
11514 
11515  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
11516  if FSweepMode.get() == 1:
11517  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11518  if ptmax > STARTsample:
11519  STARTsample = ptmax
11520  i = 0
11521  while i < 6:
11522  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11523  i = i + 1
11524  if FSweepMode.get() == 2:
11525  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11526  if ptmax > STARTsample:
11527  STARTsample = ptmax
11528  i = 0
11529  while i < 6:
11530  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
11531  i = i + 1
11532  if len(FFTresultB) == len(FFTmemoryB):
11533  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
11534  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
11535  try:
11536  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
11537  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
11538  except:
11539  FFTmemoryB = FFTresultB
11540  PhaseMemoryB = PhaseB
11541 #
11542  TRACEsize = int(len(FFTresultA))
11543  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
11544  if SpectrumScreenStatus.get() > 0:
11545  STARTsample = StartFrequency / Fsample
11546  else:
11547  STARTsample = 0.0
11548  if LoopNum.get() == 1:
11549  PhaseMemoryA = PhaseA
11550  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
11551  if FSweepMode.get() == 1:
11552  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11553  if ptmax > STARTsample:
11554  STARTsample = ptmax
11555  i = 0
11556  while i < 6:
11557  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11558  i = i + 1
11559  if FSweepMode.get() == 2:
11560  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11561  if ptmax > STARTsample:
11562  STARTsample = ptmax
11563  i = 0
11564  while i < 6:
11565  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11566  i = i + 1
11567 
11568  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
11569  if FSweepMode.get() == 1:
11570  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
11571  if ptmax > STARTsample:
11572  STARTsample = ptmax
11573  i = 0
11574  while i < 6:
11575  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11576  i = i + 1
11577  if FSweepMode.get() == 2:
11578  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
11579  if ptmax > STARTsample:
11580  STARTsample = ptmax
11581  i = 0
11582  while i < 6:
11583  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
11584  i = i + 1
11585 #
11586  if len(FFTresultA) == len(FFTmemoryA):
11587  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
11588  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
11589  try:
11590  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
11591  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
11592  except:
11593  FFTmemoryA = FFTresultA
11594  PhaseMemoryA = PhaseA
11595 #
11596  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
11597  FSweepAdB.append(numpy.amax(FFTresultA))
11598  FSweepBdB.append(numpy.amax(FFTresultB))
11599  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
11600  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
11601 
11602  TRACEresetFreq = False # Trace reset done
11603 
11604 def MakeFreqTrace(): # Update the grid and trace
11605  global FFTmemoryA, FFTresultA
11606  global FFTmemoryB, FFTresultB
11607  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
11608  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
11609  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
11610  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
11611  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
11612  global PeakfreqA, PeakfreqB, Two_X_Sample
11613  global DBdivindex # Index value
11614  global DBdivlist # dB per division list
11615  global DBlevel # Reference level
11616  global GRHF,GRWF # Screenheight, Screenwidth
11617  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
11618  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
11619  global STARTsample, STOPsample, LoopNum, FSweepMode
11620  global FreqTraceMode
11621  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline
11622  global Vdiv # Number of vertical divisions
11623  global X0LF, Y0TF # Left top X value, Left top Y value
11624 
11625  # Set the TRACEsize variable
11626  TRACEsize = 0
11627  try:
11628  StartFrequency = float(StartFreqEntry.get())
11629  except:
11630  StartFreqEntry.delete(0,"end")
11631  StartFreqEntry.insert(0,100)
11632  StartFrequency = 100
11633  try:
11634  StopFrequency = float(StopFreqEntry.get())
11635  except:
11636  StopFreqEntry.delete(0,"end")
11637  StopFreqEntry.insert(0,50000)
11638  StopFrequency = 50000
11639  if StartFrequency > StopFrequency :
11640  StopFreqEntry.delete(0,"end")
11641  StopFreqEntry.insert(0,50000)
11642  StopFrequency = 50000
11643  if StopFrequency < StartFrequency :
11644  StopFreqEntry.delete(0,"end")
11645  StopFreqEntry.insert(0,50000)
11646  StopFrequency = 50000
11647  try:
11648  Phasecenter = int(PhCenFreqEntry.get())
11649  RelPhaseCenter.set(Phasecenter)
11650  except:
11651  PhCenFreqEntry.delete(0,"end")
11652  PhCenFreqEntry.insert(0,0)
11653  RelPhaseCenter.set(0)
11654  Phasecenter = 0
11655  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
11656  TRACEsize = len(FFTresultA) # Set the trace length
11657  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
11658  TRACEsize = len(FFTresultB)
11659  if TRACEsize == 0: # If no trace, skip rest of this routine
11660  return()
11661  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
11662  PhaseA = PhaseMemoryA
11663  PhaseB = PhaseMemoryB
11664  # Vertical conversion factors (level dBs) and border limits
11665  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
11666  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
11667  Ymin = Y0TF # Minimum position of screen grid (top)
11668  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
11669  Yphconv = float(GRHF) / 360
11670  Yp = float(Y0TF) + Yphconv + 180
11671  # Horizontal conversion factors (frequency Hz) and border limits
11672  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
11673  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
11674  LogFStop = math.log10(StopFrequency)
11675  try:
11676  LogFStart = math.log10(StartFrequency)
11677  except:
11678  LogFStart = 0.0
11679  LogFpixel = (LogFStop - LogFStart) / GRWF
11680  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
11681  STARTsample = int(math.ceil(STARTsample)) # First within screen range
11682 
11683  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
11684  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
11685 
11686  MAXsample = TRACEsize # Just an out of range check
11687  if STARTsample > (MAXsample - 1):
11688  STARTsample = MAXsample - 1
11689 
11690  if STOPsample > MAXsample:
11691  STOPsample = MAXsample
11692 
11693  T1Fline = []
11694  T2Fline = []
11695  T1Pline = []
11696  T2Pline = []
11697  TFMline = []
11698  n = STARTsample
11699  PeakIndexA = PeakIndexB = n
11700  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
11701  while n <= STOPsample:
11702  F = n * Fsample
11703  if HScale.get() == 1:
11704  try:
11705  LogF = math.log10(F) # convet to log Freq
11706  x = X0LF + (LogF - LogFStart)/LogFpixel
11707  except:
11708  x = X0LF
11709  else:
11710  x = X0LF + (F - StartFrequency) / Fpixel
11711  if ShowC1_VdB.get() == 1:
11712  T1Fline.append(int(x + 0.5))
11713  try:
11714  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
11715  ya = Yc - Yconv * dbA # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11716  except:
11717  ya = Ymax
11718  if (ya < Ymin):
11719  ya = Ymin
11720  if (ya > Ymax):
11721  ya = Ymax
11722  if dbA > PeakdbA:
11723  PeakdbA = dbA
11724  PeakyA = int(ya + 0.5)
11725  PeakxA = int(x + 0.5)
11726  PeakfreqA = F
11727  PeakIndexA = n
11728  T1Fline.append(int(ya + 0.5))
11729  if ShowC2_VdB.get() == 1:
11730  T2Fline.append(int(x + 0.5))
11731  try:
11732  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11733  yb = Yc - Yconv * dbB
11734  except:
11735  yb = Ymax
11736  if (yb < Ymin):
11737  yb = Ymin
11738  if (yb > Ymax):
11739  yb = Ymax
11740  if dbB > PeakdbB:
11741  PeakdbB = dbB
11742  PeakyB = int(yb + 0.5)
11743  PeakxB = int(x + 0.5)
11744  PeakfreqB = F
11745  PeakIndexB = n
11746  T2Fline.append(int(yb + 0.5))
11747  if ShowC1_P.get() == 1:
11748  T1Pline.append(int(x + 0.5))
11749  if FSweepMode.get() > 0:
11750  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
11751  else:
11752  RelPhase = PhaseA[n]-PhaseB[n]
11753  RelPhase = RelPhase - Phasecenter
11754  if RelPhase > 180:
11755  RelPhase = RelPhase - 360
11756  elif RelPhase < -180:
11757  RelPhase = RelPhase + 360
11758  if Two_X_Sample.get() == 0:
11759  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
11760  RelPhase = RelPhase + PhErr - 12.0
11761  else:
11762  RelPhase = RelPhase - 9.0
11763  ya = Yp - Yphconv * RelPhase
11764  T1Pline.append(int(ya + 0.5))
11765  if ShowC2_P.get() == 1:
11766  T2Pline.append(int(x + 0.5))
11767  if FSweepMode.get() > 0:
11768  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
11769  else:
11770  RelPhase = PhaseB[n]-PhaseA[n]
11771  RelPhase = RelPhase - Phasecenter
11772  if RelPhase > 180:
11773  RelPhase = RelPhase - 360
11774  elif RelPhase < -180:
11775  RelPhase = RelPhase + 360
11776  if Two_X_Sample.get() == 0:
11777  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
11778  RelPhase = RelPhase - PhErr - 12.0
11779  else:
11780  RelPhase = RelPhase - 9.0
11781  ya = Yp - Yphconv * RelPhase
11782  T2Pline.append(int(ya + 0.5))
11783  if ShowMathSA.get() > 0:
11784  TFMline.append(int(x + 0.5))
11785  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
11786  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11787  if ShowMathSA.get() == 1:
11788  MdB = dbA - dbB
11789  elif ShowMathSA.get() == 2:
11790  MdB = dbB - dbA
11791  yb = Yc - Yconv * MdB
11792  if (yb < Ymin):
11793  yb = Ymin
11794  if (yb > Ymax):
11795  yb = Ymax
11796  if MdB > PeakMdb:
11797  PeakMdb = MdB
11798  PeakyM = int(yb + 0.5)
11799  PeakxM = int(x + 0.5)
11800  PeakfreqM = F
11801  TFMline.append(int(yb + 0.5))
11802  n = n + 1
11803 # make Bode Plot Traces
11804 def MakeBodeTrace(): # Update the grid and trace
11805  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
11806  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
11807  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
11808  global PeakxM, PeakyM, PeakMdb, PeakfreqM
11809  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
11810  global DBdivindexBP # Index value
11811  global DBdivlist # dB per division list
11812  global DBlevelBP # Reference level
11813  global GRHBP # Screenheight
11814  global GRWBP # Screenwidth
11815  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
11816  global StartBodeEntry, StopBodeEntry
11817  global STARTsample, STOPsample, LoopNum, FSweepMode
11818  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
11819  global TAFline, TBFline, TBPMline, TAPline, TBPline
11820  global Vdiv # Number of vertical divisions
11821  global X0LBP # Left top X value
11822  global Y0TBP # Left top Y value
11823  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
11824  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
11825  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
11826 
11827  # Set the TRACEsize variable
11828  TRACEsize = 0
11829  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
11830  TRACEsize = len(FStep) # Set the trace length
11831  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
11832  TRACEsize = len(FStep)
11833  if TRACEsize == 0: # If no trace, skip rest of this routine
11834  return()
11835  #
11836  try:
11837  EndFreq = float(StopBodeEntry.get())
11838  except:
11839  StopBodeEntry.delete(0,"end")
11840  StopBodeEntry.insert(0,10000)
11841  EndFreq = 10000
11842  try:
11843  BeginFreq = float(StartBodeEntry.get())
11844  except:
11845  StartBodeEntry.delete(0,"end")
11846  StartBodeEntry.insert(0,100)
11847  BeginFreq = 100
11848  try:
11849  Phasecenter = int(PhCenBodeEntry.get())
11850  RelPhaseCenter.set(Phasecenter)
11851  except:
11852  PhCenBodeEntry.delete(0,"end")
11853  PhCenBodeEntry.insert(0,0)
11854  RelPhaseCenter.set(0)
11855  Phasecenter = 0
11856  try:
11857  Impedcenter = int(ImCenBodeEntry.get())
11858  ImpedanceCenter.set(Impedcenter)
11859  except:
11860  ImCenBodeEntry.delete(0,"end")
11861  ImCenBodeEntry.insert(0,0)
11862  ImpedanceCenter.set(0)
11863  Impedcenter = 0
11864  #
11865  HalfSAMPLErate = SAMPLErate/2
11866  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
11867  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
11868  CurrentFreqX = X0LBP + 14
11869  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
11870  # Vertical conversion factors (level dBs) and border limits
11871  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
11872  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
11873  Ymin = Y0TBP # Minimum position of screen grid (top)
11874  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
11875  Yphconv = float(GRHBP) / 360 # degrees per pixel
11876  Yp = float(Y0TBP) + Yphconv + 180
11877  x1 = X0LBP + 14
11878  # Horizontal conversion factors (frequency Hz) and border limits
11879  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
11880  LogFStop = math.log10(EndFreq)
11881  try:
11882  LogFStart = math.log10(BeginFreq)
11883  except:
11884  LogFStart = 0.0
11885  LogFpixel = (LogFStop - LogFStart) / GRWBP
11886  TAFline = []
11887  TBFline = []
11888  TAPline = []
11889  TBPline = []
11890  TIARline = []
11891  TIAXline = []
11892  TIAMagline = []
11893  TIAAngline = []
11894  TBPMline = []
11895  PeakdbA = -200
11896  PeakdbB = -200
11897  PeakMdb = -200
11898  n = 0
11899  for n in range(len(FSweepAdB)): # while n < len(FStep):
11900  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
11901  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
11902  else:
11903  F = FBins[int(FStep[0])]
11904  if F >= BeginFreq and F <= EndFreq:
11905  if HScaleBP.get() == 1:
11906  try:
11907  LogF = math.log10(F) # convet to log Freq
11908  x = x1 + (LogF - LogFStart)/LogFpixel
11909  except:
11910  x = x1
11911  else:
11912  x = x1 + (F - BeginFreq) / Fpixel
11913  CurrentFreqX = x
11914  if ShowCA_VdB.get() == 1:
11915  TAFline.append(int(x + 0.5))
11916  try:
11917  dbA = (10 * math.log10(float(FSweepAdB[n])) + 17) # Convert power to DBs, except for log(0) error
11918  ya = Yc - Yconv * dbA # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11919  except:
11920  ya = Ymax
11921  if (ya < Ymin):
11922  ya = Ymin
11923  if (ya > Ymax):
11924  ya = Ymax
11925  if dbA > PeakdbA:
11926  PeakdbA = dbA
11927  PeakyA = int(ya + 0.5)
11928  PeakxA = int(x + 0.5)
11929  PeakfreqA = F
11930  TAFline.append(int(ya + 0.5))
11931  if ShowCB_VdB.get() == 1:
11932  TBFline.append(int(x + 0.5))
11933  try:
11934  dbB = (10 * math.log10(float(FSweepBdB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11935  yb = Yc - Yconv * dbB
11936  except:
11937  yb = Ymax
11938  if (yb < Ymin):
11939  yb = Ymin
11940  if (yb > Ymax):
11941  yb = Ymax
11942  if dbB > PeakdbB:
11943  PeakdbB = dbB
11944  PeakyB = int(yb + 0.5)
11945  PeakxB = int(x + 0.5)
11946  PeakfreqB = F
11947  TBFline.append(int(yb + 0.5))
11948  if ShowCA_P.get() == 1:
11949  TAPline.append(int(x + 0.5))
11950  RelPhase = FSweepAPh[n] - FSweepBPh[n]
11951  RelPhase = RelPhase - Phasecenter
11952  if RelPhase > 180:
11953  RelPhase = RelPhase - 360
11954  elif RelPhase < -180:
11955  RelPhase = RelPhase + 360
11956  if Two_X_Sample.get() == 0:
11957  PhErr = 0.0018 * F # calculate phase error due half sample period offset
11958  RelPhase = RelPhase + PhErr - PhaseOffset1x
11959  else:
11960  RelPhase = RelPhase - PhaseOffset2x
11961  ya = Yp - Yphconv * RelPhase
11962  TAPline.append(int(ya + 0.5))
11963  if ShowCB_P.get() == 1:
11964  TBPline.append(int(x + 0.5))
11965  RelPhase = FSweepBPh[n] - FSweepAPh[n]
11966  RelPhase = RelPhase - Phasecenter
11967  if RelPhase > 180:
11968  RelPhase = RelPhase - 360
11969  elif RelPhase < -180:
11970  RelPhase = RelPhase + 360
11971  if Two_X_Sample.get() == 0:
11972  PhErr = 0.0018 * F # calculate phase error due half sample period offset
11973  RelPhase = RelPhase - PhErr - PhaseOffset1x
11974  else:
11975  RelPhase = RelPhase - PhaseOffset2x
11976  ya = Yp - Yphconv * RelPhase
11977  TBPline.append(int(ya + 0.5))
11978  if ShowMathBP.get() > 0:
11979  TBPMline.append(int(x + 0.5))
11980  dbA = (10 * math.log10(float(FSweepAdB[n])) + 17) # Convert power to DBs, except for log(0) error
11981  dbB = (10 * math.log10(float(FSweepBdB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
11982  if ShowMathBP.get() == 1:
11983  MdB = dbA - dbB
11984  elif ShowMathBP.get() == 2:
11985  MdB = dbB - dbA
11986  yb = Yc - Yconv * MdB
11987  if (yb < Ymin):
11988  yb = Ymin
11989  if (yb > Ymax):
11990  yb = Ymax
11991  if MdB > PeakMdb:
11992  PeakMdb = MdB
11993  PeakyM = int(yb + 0.5)
11994  PeakxM = int(x + 0.5)
11995  PeakfreqM = F
11996  TBPMline.append(int(yb + 0.5))
11997 # draw impedance trace if necessary
11998  if NetworkScreenStatus.get() > 0:
11999  ycenter = Y0TBP + (GRHBP/2)
12000  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
12001  n = 0
12002  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
12003  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
12004  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
12005  else:
12006  F = FBins[int(FStep[0])]
12007  if F >= BeginFreq and F <= EndFreq:
12008  if HScaleBP.get() == 1:
12009  try:
12010  LogF = math.log10(F) # convet to log Freq
12011  x = x1 + (LogF - LogFStart)/LogFpixel
12012  except:
12013  x = x1
12014  else:
12015  x = x1 + (F - BeginFreq) / Fpixel
12016  if Show_Rseries.get() == 1:
12017  TIARline.append(int(x + 0.5))
12018  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
12019  if (y1 < Ymin):
12020  y1 = Ymin
12021  if (y1 > Ymax):
12022  y1 = Ymax
12023  TIARline.append(y1)
12024  if Show_Xseries.get() == 1:
12025  TIAXline.append(int(x + 0.5))
12026  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
12027  if (y1 < Ymin):
12028  y1 = Ymin
12029  if (y1 > Ymax):
12030  y1 = Ymax
12031  TIAXline.append(y1)
12032  if Show_Magnitude.get() == 1:
12033  TIAMagline.append(int(x + 0.5))
12034  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
12035  if (y1 < Ymin):
12036  y1 = Ymin
12037  if (y1 > Ymax):
12038  y1 = Ymax
12039  TIAMagline.append(y1)
12040  if Show_Angle.get() == 1:
12041  TIAAngline.append(int(x + 0.5))
12042  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
12043  if (y1 < Ymin):
12044  y1 = Ymin
12045  if (y1 > Ymax):
12046  y1 = Ymax
12047  TIAAngline.append(y1)
12048 #
12049 def MakeBodeScreen(): # Update the screen with traces and text
12050  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
12051  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12052  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12053  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12054  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12055  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12056  global COLORgrid # The colors
12057  global COLORsignalband, COLORtext
12058  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
12059  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
12060  global DBdivindexBP # Index value
12061  global DBdivlist # dB per division list
12062  global DBlevelBP # Reference level
12063  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
12064  global X0LBP # Left top X value
12065  global Y0TBP # Left top Y value
12066  global GRWBP # Screenwidth
12067  global GRHBP # Screenheight
12068  global FontSize
12069  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
12070  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
12071  global SMPfft # number of FFT samples
12072  global StartBodeEntry, StopBodeEntry
12073  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
12074  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
12075  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
12076  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
12077  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
12078  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
12079  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
12080  global TAPRline, TBPRline
12081  global TRACEaverage # Number of traces for averageing
12082  global FreqTraceMode # 1 normal 2 max 3 average
12083  global Vdiv, ResScale # Number of vertical divisions
12084  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
12085  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
12086 
12087  # Delete all items on the screen
12088  MarkerFreqNum = 0
12089  Bodeca.delete(ALL) # remove all items
12090 
12091  try:
12092  EndFreq = float(StopBodeEntry.get())
12093  except:
12094  StopBodeEntry.delete(0,"end")
12095  StopBodeEntry.insert(0,10000)
12096  EndFreq = 10000
12097  try:
12098  BeginFreq = float(StartBodeEntry.get())
12099  except:
12100  StartBodeEntry.delete(0,"end")
12101  StartBodeEntry.insert(0,100)
12102  BeginFreq = 100
12103  try:
12104  Phasecenter = int(PhCenBodeEntry.get())
12105  RelPhaseCenter.set(Phasecenter)
12106  except:
12107  PhCenBodeEntry.delete(0,"end")
12108  PhCenBodeEntry.insert(0,0)
12109  RelPhaseCenter.set(0)
12110  Phasecenter = 0
12111  try:
12112  Impedcenter = int(ImCenBodeEntry.get())
12113  ImpedanceCenter.set(Impedcenter)
12114  except:
12115  ImCenBodeEntry.delete(0,"end")
12116  ImCenBodeEntry.insert(0,0)
12117  ImpedanceCenter.set(0)
12118  Impedcenter = 0
12119  #
12120  # Draw horizontal grid lines
12121  i = 0
12122  x1 = X0LBP + 14
12123  x2 = x1 + GRWBP
12124  while (i <= Vdiv.get()):
12125  y = Y0TBP + i * GRHBP/Vdiv.get()
12126  Dline = [x1,y,x2,y]
12127  if i == 0 or i == Vdiv.get():
12128  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12129  else:
12130  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12131  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
12132  Vaxis_label = str(Vaxis_value)
12133  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
12134  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
12135  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
12136  Vaxis_label = str(Vaxis_value)
12137  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
12138  if NetworkScreenStatus.get() > 0:
12139  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
12140  RperDiv = float(ResScale.get())
12141  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
12142  if Vaxis_value > 500 or Vaxis_value < -500:
12143  Vaxis_value = Vaxis_value/1000.0
12144  if Vaxis_value > 5 or Vaxis_value < -5:
12145  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
12146  else:
12147  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
12148  else:
12149  Vaxis_label = ' {0:.0f} '.format(Vaxis_value)
12150  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
12151  i = i + 1
12152  # Draw vertical grid lines
12153  i = 0
12154  y1 = Y0TBP
12155  y2 = Y0TBP + GRHBP
12156  if HScaleBP.get() == 1:
12157  F = 1.0
12158  LogFStop = math.log10(EndFreq)
12159  try:
12160  LogFStart = math.log10(BeginFreq)
12161  except:
12162  LogFStart = 0.0
12163  LogFpixel = (LogFStop - LogFStart) / GRWBP
12164  # draw left and right edges
12165  while F <= EndFreq:
12166  if F >= BeginFreq:
12167  try:
12168  LogF = math.log10(F) # convet to log Freq
12169  x = x1 + (LogF - LogFStart)/LogFpixel
12170  except:
12171  x = x1
12172  Dline = [x,y1,x,y2]
12173  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
12174  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12175  axis_label = str(F)
12176  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
12177  else:
12178  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12179 
12180  if F < 10:
12181  F = F + 1
12182  elif F < 100:
12183  F = F + 10
12184  elif F < 1000:
12185  F = F + 100
12186  elif F < 1000:
12187  F = F + 100
12188  elif F < 10000:
12189  F = F + 1000
12190  elif F < 100000:
12191  F = F + 10000
12192  elif F < 200000:
12193  F = F + 10000
12194  else:
12195  Freqdiv = (EndFreq - BeginFreq) / 10
12196  while (i < 11):
12197  x = x1 + i * GRWBP/10
12198  Dline = [x,y1,x,y2]
12199  if i == 0 or i == 10:
12200  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
12201  else:
12202  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
12203  axis_value = BeginFreq + (i * Freqdiv)
12204  axis_label = str(axis_value)
12205  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
12206  i = i + 1
12207  # Draw X - Y cursors if needed
12208  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
12209  LogFStop = math.log10(EndFreq)
12210  try:
12211  LogFStart = math.log10(BeginFreq)
12212  except:
12213  LogFStart = 0.0
12214  LogFpixel = (LogFStop - LogFStart) / GRWBP
12215  if ShowBPCur.get() > 0:
12216  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
12217  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
12218  # Horizontal conversion factors (frequency Hz) and border limits
12219  if HScaleBP.get() == 1:
12220  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
12221  else:
12222  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
12223  XFString = ' {0:.2f} '.format(xfreq)
12224  V_label = XFString + " Hz"
12225  Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
12226 #
12227  if ShowBdBCur.get() > 0:
12228  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
12229  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
12230  if ShowBdBCur.get() == 1:
12231  # Vertical conversion factors (level dBs) and border limits
12232  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
12233  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
12234  yvdB = ((Yc-BdBCursor)/Yconv)
12235  VdBString = ' {0:.1f} '.format(yvdB)
12236  V_label = VdBString + " dBV"
12237  else:
12238  # Vertical conversion factors (level degrees) and border limits
12239  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
12240  Yc = float(Y0TBP) # Yc is the 180 degree position
12241  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
12242  VdBString = ' {0:.1f} '.format(yvdB)
12243  V_label = VdBString + " Deg"
12244  Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
12245  #
12246  SmoothBool = SmoothCurvesBP.get()
12247  # Draw traces
12248  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
12249  # Write the trace CHA
12250  if OverRangeFlagA == 1:
12251  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12252  else:
12253  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12254  if ShowMarkerBP.get() == 1:
12255  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
12256  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
12257  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
12258  # Write the trace CHB
12259  if OverRangeFlagB == 1:
12260  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12261  else:
12262  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12263  if ShowMarkerBP.get() == 1:
12264  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
12265  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
12266  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
12267  # Write the phase trace A-B
12268  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12269  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
12270  # Write the phase trace A-B
12271  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12272  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
12273  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12274  if ShowMarkerBP.get() == 1:
12275  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
12276  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
12277  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
12278  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12279  if ShowMarkerBP.get() == 1:
12280  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
12281  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
12282  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
12283  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12284  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
12285  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12286  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
12287  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12288  if ShowMarkerBP.get() == 1:
12289  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
12290  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
12291  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
12292  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12293  if ShowMarkerBP.get() == 1:
12294  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
12295  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
12296  if Show_Rseries.get() == 1 and len(TIARline) > 4:
12297  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12298  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
12299  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12300  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
12301  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12302  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
12303  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12304  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
12305  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12306  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
12307  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12308  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
12309  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12310  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
12311  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12312 
12313  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
12314  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
12315  if HScaleBP.get() == 1:
12316  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
12317  else:
12318  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
12319  XFString = ' {0:.0f} '.format(xfreq)
12320  V_label = XFString + " Hz"
12321  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
12322  # General information on top of the grid
12323 
12324  txt = " Sample rate: " + str(SAMPLErate)
12325  txt = txt + " FFT samples: " + str(SMPfft)
12326 
12327  txt = txt + " " + FFTwindowname
12328 
12329  x = X0LBP
12330  y = 12
12331  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12332 
12333  # Start and stop frequency and dB/div and trace mode
12334  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
12335  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
12336  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
12337  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
12338 
12339  x = X0LBP
12340  y = Y0TBP+GRHBP+23
12341  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12342 
12343  if FreqTraceMode.get() == 1:
12344  txt ="Normal mode "
12345 
12346  if FreqTraceMode.get() == 2:
12347  txt = "Peak hold mode "
12348 
12349  if FreqTraceMode.get() == 3:
12350  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
12351 
12352  if ZEROstuffing.get() > 0:
12353  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
12354  # Runstatus and level information
12355  if (RUNstatus.get() == 0):
12356  txt = txt + " Stopped "
12357  else:
12358  if BodeDisp.get() == 1:
12359  txt = txt + " Running "
12360  else:
12361  txt = txt + " Display off "
12362  if FSweepMode.get() > 0:
12363  txt = txt + " Freq Step = " + str(LoopNum.get())
12364  x = X0LBP
12365  y = Y0TBP+GRHBP+34
12366  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12367 
12368 # Impedance analyzer routines -----
12369 def UpdateIAAll(): # Update Data, trace and screen
12370  global FFTBuffA, FFTBuffB
12371  global SMPfft
12372 
12373  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
12374  return
12375 
12376  MakeIATrace() # Update the traces
12377  UpdateIAScreen() # Update the screen
12378 
12379 def UpdateIATrace(): # Update trace and screen
12380  MakeIATrace() # Update traces
12381  UpdateIAScreen() # Update the screen
12382 
12383 def UpdateIAScreen(): # Update screen with trace and text
12384  MakeIAScreen() # Update the screen
12385  root.update() # Activate updated screens
12386 #
12388 
12389 # Input Variables
12390  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
12391  #(VZ/VA)from vector voltmeter
12392  # global VVangle # angle in degrees between VZ and VA
12393  global RsystemEntry # resistance of series resistor or power divider
12394 # Computed outputs
12395  # global VVangleCosine # cosine of vector voltmeter angle
12396  global ImpedanceMagnitude # in ohms
12397  global ImpedanceAngle # in degrees
12398  global ImpedanceRseries, ImpedanceXseries # in ohms
12399  global IA_Ext_Conf
12400 
12401  DEG2RAD = (math.pi / 180.0)
12402  SMALL = 1E-20
12403  try:
12404  ResValue = float(RsystemEntry.get())
12405  except:
12406  ResValue = 1000.0
12407 
12408  VA = math.pow(10,(PeakdbA/20))
12409  VB = math.pow(10,(PeakdbB/20))
12410  VVangleCosine = math.cos(math.radians(PeakRelPhase))
12411  if IA_Ext_Conf.get() == 1:
12412  VAB = math.pow(10,(PeakdbAB/20))
12413  VZ = VAB # VZ=VA-VB
12414  # VI = VB
12415  else:
12416  VZ = VB # VZ=VB
12417  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
12418  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
12419  Za = ResValue * VA / VI
12420  ImpedanceRseries = Za * costheta - ResValue
12421  ImpedanceMagnitude = ResValue * VZ / VI
12422  ImpedanceXseries = math.sqrt(ImpedanceMagnitude**2 - ImpedanceRseries**2)
12423 
12424  if(PeakRelPhase < 0.0):
12425  ImpedanceXseries = -ImpedanceXseries
12426  if IA_Ext_Conf.get() == 1:
12427  ImpedanceRseries = -ImpedanceRseries
12428  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
12429 #
12430 def MakeIATrace(): # Update the grid and trace
12431  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
12432  global FFTmemoryB, FFTresultB
12433  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
12434  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
12435  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
12436  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
12437  global DBdivindex # Index value
12438  global DBdivlist # dB per division list
12439  global DBlevel # Reference level
12440  global GRHIA # Screenheight
12441  global GRWIA # Screenwidth
12442  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
12443  global STARTsample, STOPsample, LoopNum, FSweepMode
12444  global TRACEmode, Two_X_Sample, IA_Ext_Conf
12445  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
12446  global Vdiv # Number of vertical divisions
12447  global X0LIA # Left top X value
12448  global Y0TIA # Left top Y value
12449  global ImpedanceMagnitude # in ohms
12450  global ImpedanceAngle # in degrees
12451  global ImpedanceRseries, ImpedanceXseries # in ohms
12452 
12453  # Set the TRACEsize variable
12454  TRACEsize = len(FFTresultA) # Set the trace length
12455  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
12456  # Horizontal conversion factors (frequency Hz) and border limits
12457  STARTsample = 0 # First sample in FFTresult[] that is used
12458  STARTsample = int(math.ceil(STARTsample)) # First within screen range
12459  if Two_X_Sample.get() == 0:
12460  STOPsample = 45000 / Fsample # Last sample in FFTresult[] that is used
12461  else:
12462  STOPsample = 90000 / Fsample
12463  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
12464 #
12465  try:
12466  GainCorrection = float(eval(GainCorEntry.get()))
12467  except:
12468  GainCorEntry.delete(0,END)
12469  GainCorEntry.insert(0, GainCorrection)
12470 
12471  try:
12472  PhaseCorrection = float(eval(PhaseCorEntry.get()))
12473  except:
12474  PhaseCorEntry.delete(0,END)
12475  PhaseCorEntry.insert(0, PhaseCorrection)
12476 
12477  MAXsample = TRACEsize # Just an out of range check
12478  if STARTsample > (MAXsample - 1):
12479  STARTsample = MAXsample - 1
12480 
12481  if STOPsample > MAXsample:
12482  STOPsample = MAXsample
12483 
12484  n = STARTsample
12485  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
12486  PeakphaseA = PhaseA[n]
12487  PeakphaseB = PhaseB[n]
12488  #PeakphaseAB = PhaseAB[n]
12489  PeakSample = n
12490 
12491  PeakdbA = (10 * math.log10(float(FFTresultA[n])) + 17)
12492  PeakdbB = (10 * math.log10(float(FFTresultB[n])) + 17)
12493  PeakMdb = PeakdbA - PeakdbB
12494  if IA_Ext_Conf.get() == 1:
12495  PeakdbAB = (10 * math.log10(float(FFTresultAB[n])) + 17)
12496  while n <= STOPsample:
12497  F = n * Fsample
12498  try:
12499  dbA = (10 * math.log10(float(FFTresultA[n])) + 17) # Convert power to DBs, except for log(0) error
12500  except:
12501  dbA = -200
12502  if dbA > PeakdbA:
12503  PeakdbA = dbA
12504  PeakfreqA = F
12505  PeakphaseA = PhaseA[n]
12506  PeakSample = n
12507 
12508  try:
12509  dbB = (10 * math.log10(float(FFTresultB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12510  except:
12511  dbB = -200
12512  if dbB > PeakdbB:
12513  PeakdbB = dbB
12514  PeakfreqB = F
12515  PeakphaseB = PhaseB[n]
12516 
12517  if IA_Ext_Conf.get() == 1:
12518  try:
12519  dbAB = (10 * math.log10(float(FFTresultAB[n])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
12520  except:
12521  dbAB = -200
12522  if dbAB > PeakdbAB:
12523  PeakdbAB = dbAB
12524  PeakphaseAB = PhaseAB[n]
12525  RelPhase = PhaseA[n]-PhaseB[n]
12526  if RelPhase > 180:
12527  RelPhase = RelPhase - 360
12528  elif RelPhase < -180:
12529  RelPhase = RelPhase + 360
12530  if Two_X_Sample.get() == 0:
12531  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
12532  RelPhase = RelPhase + PhErr - 12.0
12533  else:
12534  RelPhase = RelPhase - 9.0
12535  n = n + 1
12536  if IA_Ext_Conf.get() == 1:
12537  PeakRelPhase = PeakphaseAB-PeakphaseA
12538  else:
12539  PeakRelPhase = PeakphaseB-PeakphaseA
12540 #
12541  if PeakRelPhase > 180:
12542  PeakRelPhase = PeakRelPhase - 360
12543  elif PeakRelPhase < -180:
12544  PeakRelPhase = PeakRelPhase + 360
12545  if Two_X_Sample.get() == 0:
12546  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
12547  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
12548  else:
12549  PeakRelPhase = PeakRelPhase + PhaseCorrection
12550  PeakdbB = PeakdbB + GainCorrection
12551  DoImpedance()
12552 
12554 def MakeIAScreen(): # Update the screen with traces and text
12555  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
12556  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12557  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
12558  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12559  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12560  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12561  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry
12562  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
12563  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
12564  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
12565  global ResScale, DisplaySeries # Ohms per div
12566  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
12567  global X0LIA # Left top X value
12568  global Y0TIA # Left top Y value
12569  global GRWIA # Screenwidth
12570  global GRHIA # Screenheight
12571  global FontSize
12572  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
12573  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
12574  global SMPfft # number of FFT samples
12575  global TRACEaverage # Number of traces for averageing
12576  global FreqTraceMode # 1 normal 2 max 3 average
12577  global Vdiv # Number of vertical divisions
12578  global ImpedanceMagnitude # in ohms
12579  global ImpedanceAngle # in degrees
12580  global ImpedanceRseries, ImpedanceXseries # in ohms
12581  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
12582 
12583  if LoopNum.get() > 1:
12584  if NetworkScreenStatus.get() > 0:
12585  NSweepSeriesR.append(ImpedanceRseries)
12586  NSweepSeriesX.append(ImpedanceXseries)
12587  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
12588  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
12589  # Delete all items on the screen
12590  IAca.delete(ALL) # remove all items
12591  SmoothBool = SmoothCurvesBP.get()
12592  # Draw circular grid lines
12593  i = 1
12594  xcenter = GRWIA/2
12595  ycenter = GRHIA/2
12596  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
12597  OhmsperPixel = float(ResScale.get())/Radius
12598  TRadius = Radius * Vdiv.get() # 5
12599  x1 = X0LIA
12600  x2 = X0LIA + GRWIA
12601  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
12602  while (i <= Vdiv.get()):
12603  x0 = xcenter - ( i * Radius )
12604  x1 = xcenter + ( i * Radius )
12605  y0 = ycenter - ( i * Radius )
12606  y1 = ycenter + ( i * Radius )
12607  ResTxt = float(ResScale.get()) * i
12608  IAca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
12609  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
12610  IAca.create_text(xright, y0, text=str(ResTxt), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
12611  #
12612  i = i + 1
12613  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
12614  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
12615  RAngle = math.radians(45)
12616  y = TRadius*math.sin(RAngle)
12617  x = TRadius*math.cos(RAngle)
12618  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
12619  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
12620  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
12621  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
12622  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
12623  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
12624 # Draw traces
12625  # Add saved line if there
12626  if IASweepSaved.get() > 0:
12627  if len(TIAMRline) > 4:
12628  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12629 #
12630  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
12631  if x1 > 1500:
12632  x1 = xright
12633  elif x1 < -500:
12634  x1 = xcenter - xright
12635  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, width=TRACEwidth.get())
12636  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
12637  if y1 > 1500:
12638  y1 = xright
12639  elif y1 < -500:
12640  y1 = ycenter - xright
12641  xmag = x1
12642  ymag = y1
12643  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, width=TRACEwidth.get())
12644  MagRadius = ImpedanceMagnitude / OhmsperPixel
12645  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
12646  if y1 > 1500:
12647  y1 = xright
12648  elif y1 < -500:
12649  y1 = ycenter - xright
12650  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
12651  if x1 > 1500:
12652  x1 = xright
12653  elif x1 < -500:
12654  x1 = xcenter - xright
12655  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, width=TRACEwidth.get())
12656 #
12657  TIAMline = []
12658  if len(NSweepSeriesMag) > 2:
12659  index = 0
12660  while index < len(NSweepSeriesMag):
12661  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
12662  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
12663  if y1 > 1500:
12664  y1 = xright
12665  elif y1 < -500:
12666  y1 = ycenter - xright
12667  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
12668  if x1 > 1500:
12669  x1 = xright
12670  elif x1 < -500:
12671  x1 = xcenter - xright
12672  TIAMline.append(x1)
12673  TIAMline.append(y1)
12674  index = index + 1
12675  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
12676 # display warning if input out of range
12677  if OverRangeFlagA == 1:
12678  x = X0LIA+GRWIA+10
12679  y = Y0TIA+GRHIA-40
12680  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
12681  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
12682  if OverRangeFlagB == 1:
12683  x = X0LIA+GRWIA+10
12684  y = Y0TIA+GRHIA-10
12685  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
12686  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
12687  # General information on top of the grid
12688 
12689  txt = " Sample rate: " + str(SAMPLErate)
12690  txt = txt + " FFT samples: " + str(SMPfft)
12691 
12692  txt = txt + " " + FFTwindowname
12693 
12694  x = X0LIA
12695  y = 12
12696  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12697  #
12698  x = X0LIA + GRWIA + 4
12699  y = 24
12700  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
12701  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12702  y = y + 24
12703  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
12704  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12705  y = y + 24
12706  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
12707  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12708  y = y + 24
12709  txt = "Impedance Magnitude"
12710  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12711  y = y + 24
12712  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
12713  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12714  y = y + 24
12715  txt = "Impedance Angle"
12716  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12717  y = y + 24
12718  txt = ' {0:.1f} '.format(ImpedanceAngle)
12719  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12720  y = y + 24
12721  txt = "Impedance R series"
12722  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12723  y = y + 24
12724  txt = ' {0:.1f} '.format(ImpedanceRseries)
12725  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12726  y = y + 24
12727  txt = "Impedance X series"
12728  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12729  y = y + 24
12730  txt = ' {0:.1f} '.format(ImpedanceXseries)
12731  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
12732 #
12733  if ImpedanceXseries < 0: # calculate series capacitance
12734  y = y + 24
12735  try:
12736  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
12737  except:
12738  Cseries = 0
12739  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
12740  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
12741  Cparallel = Cparallel * 1E6 # convert to micro Farads
12742  Rparallel = ImpedanceRseries * (1+Qseries**2)
12743  Cseries = Cseries * 1E6 # convert to micro Farads
12744  if DisplaySeries.get() == 0:
12745  txt = "Series Capacitance"
12746  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12747  y = y + 20
12748  if Cseries < 1:
12749  Cseries = Cseries * 1E3
12750  if Cseries < 1:
12751  Cseries = Cseries * 1E3
12752  txt = ' {0:.1f} '.format(Cseries) + "pF"
12753  else:
12754  txt = ' {0:.3f} '.format(Cseries) + "nF"
12755  else:
12756  txt = ' {0:.3f} '.format(Cseries) + "uF"
12757  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12758  else:
12759  txt = "Parallel"
12760  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12761  y = y + 20
12762  if Cparallel < 1:
12763  Cparallel = Cparallel * 1E3
12764  if Cparallel < 1:
12765  Cparallel = Cparallel * 1E3
12766  txt = "Capacitance " + ' {0:.1f} '.format(Cparallel) + "pF"
12767  else:
12768  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "nF"
12769  else:
12770  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
12771  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12772  y = y + 20
12773  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
12774  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12775  y = y + 20
12776  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
12777  txt = 'D = {0:.2f} '.format(dissp) + " %"
12778  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12779 
12780  elif ImpedanceXseries > 0: # calculate series inductance
12781  y = y + 24
12782  try:
12783  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
12784  except:
12785  Lseries = 0
12786  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
12787  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
12788  Lparallel = Lparallel * 1E3 # convert to millihenry
12789  Rparallel = ImpedanceRseries * (1+Qseries**2)
12790  Lseries = Lseries * 1E3 # in millihenry
12791  if DisplaySeries.get() == 0:
12792  txt = "Series Inductance"
12793  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12794  y = y + 22
12795  if Lseries < 1:
12796  Lseries = Lseries * 1E3
12797  txt = ' {0:.2f} '.format(Lseries) + "uH"
12798  else:
12799  txt = ' {0:.2f} '.format(Lseries) + "mH"
12800  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12801  else:
12802  txt = "Parallel"
12803  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12804  y = y + 20
12805  if Lparallel < 1:
12806  Lparallel = Lparallel * 1E3
12807  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "uH"
12808  else:
12809  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
12810  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12811  y = y + 20
12812  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
12813  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12814  y = y + 20
12815  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
12816  txt = 'Q = {0:.2f} '.format(qf)
12817  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
12818  # Start and stop frequency and trace mode
12819  if Two_X_Sample.get() == 0:
12820  txt = "0.0 to 45000 Hz"
12821  else:
12822  txt = "0.0 to 90000 Hz"
12823  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
12824 
12825  x = X0LIA
12826  y = Y0TIA+GRHIA-13
12827  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12828  txt = " "
12829  if FreqTraceMode.get() == 1:
12830  txt ="Normal mode "
12831 
12832  if FreqTraceMode.get() == 2:
12833  txt = "Peak hold mode "
12834 
12835  if FreqTraceMode.get() == 3:
12836  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
12837 
12838  if ZEROstuffing.get() > 0:
12839  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
12840  # Runstatus and level information
12841  if (RUNstatus.get() == 0):
12842  txt = txt + " Stopped "
12843  else:
12844  txt = txt + " Running "
12845  y = Y0TIA+GRHIA
12846  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
12847 #
12848 def IACaresize(event):
12849  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
12850 
12851  CANVASwidthIA = event.width - 4
12852  CANVASheightIA = event.height - 4
12853  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
12854  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
12855  UpdateIAAll()
12856 #
12857 # ================ Make IA Window ==========================
12859  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
12860  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode
12861  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
12862  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev
12863  global NetworkScreenStatus, IASweepSaved
12864 
12865  if IAScreenStatus.get() == 0:
12866  IAScreenStatus.set(1)
12867  IADisp.set(1)
12868  IACheckBox()
12869  CutDC.set(1) # set to remove DC
12870  CANVASwidthIA = 170 + GRWIA + 2 * X0LIA # The canvas width
12871  CANVASheightIA = GRHIA + Y0TIA + 10 # The canvas height
12872  AWGAMode.set(0) # Set AWG A to SVMI
12873  AWGAShape.set(1) # Set Shape to Sine
12874  AWGBMode.set(2) # Set AWG B to Hi-Z
12875  AWGSync.set(1) # Set AWGs to run sync
12876  iawindow = Toplevel()
12877  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
12878  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
12879  frame2iar = Frame(iawindow, borderwidth=5, relief=RIDGE)
12880  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
12881 
12882  frame2ia = Frame(iawindow, borderwidth=5, relief=RIDGE)
12883  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
12884 
12885  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
12886  IAca.bind("<Configure>", IACaresize)
12887  IAca.bind("<Return>", DoNothing)
12888  IAca.bind("<space>", onCanvasSpaceBar)
12889  IAca.pack(side=TOP, expand=YES, fill=BOTH)
12890 
12891  # menu buttons
12892  # right side drop down menu buttons
12893  dropmenu = Frame( frame2iar )
12894  dropmenu.pack(side=TOP)
12895  # File menu
12896  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
12897  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
12898  IAFilemenu["menu"] = IAFilemenu.menu
12899  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
12900  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
12901  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
12902  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
12903  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
12904  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
12905  IAFilemenu.menu.add_command(label="Help", command=BHelp)
12906  IAFilemenu.pack(side=LEFT, anchor=W)
12907  #
12908  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
12909  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
12910  IAOptionmenu["menu"] = IAOptionmenu.menu
12911  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
12912  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
12913  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
12914  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
12915  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
12916  if DeBugMode == 1:
12917  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
12918  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
12919  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
12920  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
12921  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
12922  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
12923  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
12924  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
12925  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
12926  IAOptionmenu.pack(side=LEFT, anchor=W)
12927  #
12928  rsemenu = Frame( frame2iar )
12929  rsemenu.pack(side=TOP)
12930  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
12931  rseb2.pack(side=RIGHT)
12932  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
12933  rseb3.pack(side=RIGHT)
12934  #
12935  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
12936  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
12937  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
12938  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
12939  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
12940  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
12941  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
12942  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
12943  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
12944  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
12945  IAFFTwindmenu.pack(side=TOP)
12946  #
12947  smpmenu = Frame( frame2iar )
12948  smpmenu.pack(side=TOP)
12949  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
12950  smpb1.pack(side=LEFT)
12951  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
12952  smpb2.pack(side=LEFT)
12953  # Temp set source resistance to 1000
12954  rsystem = Frame( frame2iar )
12955  rsystem.pack(side=TOP)
12956  rsystemlab = Label(rsystem, text="Ext Res")
12957  rsystemlab.pack(side=LEFT, anchor=W)
12958  RsystemEntry = Entry(rsystem, width=7)
12959  RsystemEntry.bind('<MouseWheel>', onTextScroll)
12960  RsystemEntry.bind('<Key>', onTextKey)
12961  RsystemEntry.pack(side=LEFT, anchor=W)
12962  RsystemEntry.delete(0,"end")
12963  RsystemEntry.insert(4,1000)
12964  # Res Sacle Spinbox
12965  ressb = Frame( frame2iar )
12966  ressb.pack(side=TOP)
12967  reslab = Label(ressb, text="Ohms/div ")
12968  reslab.pack(side=LEFT)
12969  ResScale = Spinbox(ressb, width=7, values=ResScalediv)
12970  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
12971  ResScale.pack(side=LEFT)
12972  ResScale.delete(0,"end")
12973  ResScale.insert(0,500)
12974  #
12975  GainCor = Frame( frame2iar )
12976  GainCor.pack(side=TOP)
12977  GainCorlab = Label(GainCor, text="Gain Cor dB")
12978  GainCorlab.pack(side=LEFT, anchor=W)
12979  GainCorEntry = Entry(GainCor, width=7)
12980  GainCorEntry.bind('<MouseWheel>', onTextScroll)
12981  GainCorEntry.bind('<Key>', onTextKey)
12982  GainCorEntry.pack(side=LEFT, anchor=W)
12983  GainCorEntry.delete(0,"end")
12984  GainCorEntry.insert(4,0.0)
12985  #
12986  PhaseCor = Frame( frame2iar )
12987  PhaseCor.pack(side=TOP)
12988  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
12989  PhaseCorlab.pack(side=LEFT, anchor=W)
12990  PhaseCorEntry = Entry(PhaseCor, width=7)
12991  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
12992  PhaseCorEntry.bind('<Key>', onTextKey)
12993  PhaseCorEntry.pack(side=LEFT, anchor=W)
12994  PhaseCorEntry.delete(0,"end")
12995  PhaseCorEntry.insert(4,0.0)
12996  #
12997  srclab = Label(frame2iar, text="Source")
12998  srclab.pack(side=TOP)
12999  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
13000  extsrc1.pack(side=TOP)
13001  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
13002  extsrc2.pack(side=TOP)
13003 
13004  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
13005  dismiss1button.pack(side=TOP)
13006  # add ADI logo
13007  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
13008  ADI1.pack(side=TOP)
13009 #
13011  global iawindow, IAScreenStatus, IAca, IADisp
13012 
13013  IAScreenStatus.set(0)
13014  IADisp.set(0)
13015  IACheckBox()
13016  iawindow.destroy()
13017 #
13019  global TIAMline, TIAMRline, IASweepSaved
13020 
13021  if IASweepSaved.get() > 0:
13022  TIAMRline = TIAMline
13023 #
13025  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
13026  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
13027  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
13028  global NetworkScreenStatus, NqPSweepSaved
13029 
13030  if NqPScreenStatus.get() == 0:
13031  NqPScreenStatus.set(1)
13032  NqPDisp.set(1)
13033  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
13034  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
13035  nqpwindow = Toplevel()
13036  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
13037  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
13038  #frame2iar = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13039  #frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13040 
13041  frame2nqp = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13042  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
13043 
13044  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
13045  NqPca.bind("<Configure>", NqPCaresize)
13046  NqPca.bind("<Return>", DoNothing)
13047  NqPca.bind("<space>", onCanvasSpaceBar)
13048  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
13049 #
13051  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
13052 
13053  NqPScreenStatus.set(0)
13054  NqPDisp.set(0)
13055  nqpwindow.destroy()
13056 #
13057 def NqPCaresize(event):
13058  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
13059 
13060  CANVASwidthNqP = event.width - 4
13061  CANVASheightNqP = event.height - 4
13062  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
13063  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
13064  UpdateNqPAll()
13065 
13068  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
13069  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
13070  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
13071  global Vdiv, FBins, FStep
13072  global FontSize
13073 
13074  # Delete all items on the canvas
13075  NqPca.delete(ALL) # remove all items
13076  SmoothBool = SmoothCurvesBP.get()
13077  # Draw circular grid lines
13078  i = 1
13079  xcenter = GRWNqP/2
13080  ycenter = GRHNqP/2
13081  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
13082  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
13083  TRadius = Radius * Vdiv.get() # 5
13084  x1 = X0LNqP
13085  x2 = X0LNqP + GRWNqP
13086  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
13087  while (i <= Vdiv.get()):
13088  x0 = xcenter - ( i * Radius )
13089  x1 = xcenter + ( i * Radius )
13090  y0 = ycenter - ( i * Radius )
13091  y1 = ycenter + ( i * Radius )
13092  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
13093  NqPca.create_oval ( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
13094  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
13095  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13096  #
13097  i = i + 1
13098  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=2)
13099  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=2)
13100  RAngle = math.radians(45)
13101  y = TRadius*math.sin(RAngle)
13102  x = TRadius*math.cos(RAngle)
13103  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13104  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
13105  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
13106  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
13107  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
13108  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
13109  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
13110 # Draw traces
13111  NqPline = []
13112  if len(FSweepAdB) > 4:
13113  for index in range(len(FSweepAdB)): # while n < len(FStep):
13114  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
13115  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
13116  else:
13117  F = FBins[int(FStep[0])]
13118  # Mag value
13119  dbA = (10 * math.log10(float(FSweepAdB[index])) + 17) # Convert power to DBs, except for log(0) error
13120  dbB = (10 * math.log10(float(FSweepBdB[index])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13121  if ShowMathBP.get() == 1:
13122  MdB = dbA - dbB
13123  elif ShowMathBP.get() == 2:
13124  MdB = dbB - dbA
13125  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
13126  # Phase Value
13127  RelPhase = FSweepBPh[index] - FSweepAPh[index]
13128  if RelPhase > 180:
13129  RelPhase = RelPhase - 360
13130  elif RelPhase < -180:
13131  RelPhase = RelPhase + 360
13132  if Two_X_Sample.get() == 0:
13133  PhErr = 0.0018 * F # calculate phase error due half sample period offset
13134  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
13135  else:
13136  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
13137  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
13138  if y1 > 1500:
13139  y1 = xright
13140  elif y1 < -500:
13141  y1 = ycenter - xright
13142  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
13143  if x1 > 1500:
13144  x1 = xright
13145  elif x1 < -500:
13146  x1 = xcenter - xright
13147  NqPline.append(x1)
13148  NqPline.append(y1)
13149  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13150 #
13152  global NiCScreenStatus, NiCDisp
13153  global nicwindow, NiCca, logo, SWRev
13154  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
13155  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
13156  global NetworkScreenStatus, NiCSweepSaved
13157 
13158  if NiCScreenStatus.get() == 0:
13159  NiCScreenStatus.set(1)
13160  NiCDisp.set(1)
13161  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
13162  CANVASheightNic = GRHNiC + 60 # The canvas height
13163  nicwindow = Toplevel()
13164  nicwindow.title("Nichols Plot " + SWRev + RevDate)
13165  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
13166  #frame2iar = Frame(nqpwindow, borderwidth=5, relief=RIDGE)
13167  #frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
13168 
13169  frame2nic = Frame(nicwindow, borderwidth=5, relief=RIDGE)
13170  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
13171 
13172  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
13173  NiCca.bind("<Configure>", NiCCaresize)
13174  NiCca.bind("<Return>", DoNothing)
13175  NiCca.bind("<space>", onCanvasSpaceBar)
13176  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
13177 #
13179  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
13180 
13181  NiCScreenStatus.set(0)
13182  NiCDisp.set(0)
13183  nicwindow.destroy()
13184 #
13185 def NiCCaresize(event):
13186  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
13187 
13188  CANVASwidthNic = event.width - 4
13189  CANVASheightNic = event.height - 4
13190  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
13191  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
13192  UpdateNiCAll()
13193 
13196  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
13197  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
13198  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
13199  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
13200  global FontSize
13201 
13202  Ymin = Y0TNiC # Minimum position of XY grid (top)
13203  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
13204  Xmin = X0LNiC # Minimum position of XY grid (left)
13205  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
13206  try:
13207  Phasecenter = int(PhCenBodeEntry.get())
13208  RelPhaseCenter.set(Phasecenter)
13209  except:
13210  PhCenBodeEntry.delete(0,"end")
13211  PhCenBodeEntry.insert(0,0)
13212  RelPhaseCenter.set(0)
13213  Phasecenter = 0
13214  # Delete all items on the screen
13215  MarkerNum = 0
13216  SmoothBool = SmoothCurvesBP.get()
13217  NiCca.delete(ALL) # remove all items
13218  # Draw horizontal grid lines Rel Gain Magnitude
13219  i = 0
13220  x1 = X0LNiC
13221  x2 = X0TNiC = X0LNiC + GRWNiC
13222  mg_siz = GRWNiC/10.0
13223  mg_inc = mg_siz/5.0
13224  DegPerDiv = 360 / 10
13225  while (i < Vdiv.get()+1):
13226  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
13227  y = Y0TNiC + i * GRHNiC/Vdiv.get()
13228  Dline = [x1,y,x2,y]
13229  if dBaxis_value == 0:
13230  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
13231  k = 0
13232  while (k < 10):
13233  l = 1
13234  while (l < 5): # add tick marks
13235  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
13236  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13237  l = l + 1
13238  k = k + 1
13239  else:
13240  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13241  dBaxis_label = str(dBaxis_value)
13242  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
13243 
13244  i = i + 1
13245  # Draw vertical grid lines (phase -180 to 180 10 div)
13246  i = 0
13247  y1 = Y0TNiC
13248  y2 = Y0TNiC + GRHNiC
13249  mg_siz = GRHNiC/10.0
13250  mg_inc = mg_siz/5.0
13251  #
13252  while (i < 11):
13253  x = X0LNiC + i * GRWNiC/10.0
13254  Dline = [x,y1,x,y2]
13255  axis_value = Phasecenter - 180 + (i * DegPerDiv)
13256  axis_label = str(axis_value)
13257  if ( axis_value == 0):
13258  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
13259  k = 0
13260  while (k < 10):
13261  l = 1
13262  while (l < 5): # add tick marks
13263  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
13264  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13265  l = l + 1
13266  k = k + 1
13267  else:
13268  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13269  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
13270  i = i + 1
13271  # Draw traces
13272  # Vertical conversion factors (level dBs) and border limits
13273  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13274  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
13275  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
13276  Xp = float(X0LNiC) + Xphconv * 180.0
13277  x1 = X0LNiC + 14
13278  # Horizontal conversion factors (phase deg) and border limits
13279  NiCline = []
13280  if len(FSweepAdB) > 4:
13281  index = 0
13282  for index in range(len(FSweepAdB)): # while n < len(FStep):
13283  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
13284  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
13285  else:
13286  F = FBins[int(FStep[0])]
13287  # Mag value
13288  dbA = (10 * math.log10(float(FSweepAdB[index])) + 17) # Convert power to DBs, except for log(0) error
13289  dbB = (10 * math.log10(float(FSweepBdB[index])) + 17) # Add 17 dB for max value of +10 dB ALSO in CSV file routine!
13290  if ShowMathBP.get() == 1:
13291  MdB = dbA - dbB
13292  elif ShowMathBP.get() == 2:
13293  MdB = dbB - dbA
13294  yb = Yc - Yconv * MdB
13295  if (yb < Ymin):
13296  yb = Ymin
13297  if (yb > Ymax):
13298  yb = Ymax
13299  # Phase Value
13300  RelPhase = FSweepBPh[index] - FSweepAPh[index]
13301  RelPhase = RelPhase - Phasecenter
13302  if RelPhase > 180:
13303  RelPhase = RelPhase - 360
13304  elif RelPhase < -180:
13305  RelPhase = RelPhase + 360
13306  if Two_X_Sample.get() == 0:
13307  PhErr = 0.0018 * F # calculate phase error due half sample period offset
13308  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
13309  else:
13310  RelPhase = RelPhase # - PhaseOffset2x
13311  xa = Xp + Xphconv * RelPhase
13312  if (xa < Xmin):
13313  xa = Ymin
13314  if (xa > Xmax):
13315  xa = Xmax
13316  NiCline.append(int(xa + 0.5))
13317  NiCline.append(int(yb + 0.5))
13318  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13319 #
13320 def UpdateNqPAll(): # Update Data, trace and screen
13321  global FFTBuffA, FFTBuffB
13322  global SMPfft
13323 
13324  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13325  return
13326  #MakeNqPTrace() # Update the traces
13327  UpdateNqPScreen() # Update the screen
13328 
13329 def UpdateNqPTrace(): # Update trace and screen
13330 
13331  #MakeNqPTrace() # Update traces
13332  UpdateNqPScreen() # Update the screen
13333 
13334 def UpdateNqPScreen(): # Update screen with trace and text
13335 
13336  MakeNqPScreen() # Update the screen
13337  root.update() # Activate updated screens
13338 #
13339 def UpdateNiCAll(): # Update Data, trace and screen
13340  global FFTBuffA, FFTBuffB
13341  global SMPfft
13342 
13343  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13344  return
13345  #MakeNiCTrace() # Update the traces
13346  UpdateNiCScreen() # Update the screen
13347 
13348 def UpdateNiCTrace(): # Update trace and screen
13349 
13350  #MakeNiCTrace() # Update traces
13351  UpdateNiCScreen() # Update the screen
13352 
13353 def UpdateNiCScreen(): # Update screen with trace and text
13354 
13355  MakeNiCScreen() # Update the screen
13356  root.update() # Activate updated screens
13357 #
13358 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
13359  global FFTmemoryA, FFTresultA
13360  global FFTmemoryB, FFTresultB
13361  global PhaseA, PhaseB, freqwindow
13362  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
13363 
13364  # Set the TRACEsize variable
13365  if ShowC1_VdB.get() == 1:
13366  TRACEsize = len(FFTresultA) # Set the trace length
13367  elif ShowC2_VdB.get() == 1:
13368  TRACEsize = len(FFTresultB)
13369  if TRACEsize == 0: # If no trace, skip rest of this routine
13370  return()
13371 # ask if save as magnitude or dB
13372  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
13373  # Make the file name and open it
13374  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13375  filename = "Spectrum-" + tme
13376  filename = filename + ".csv"
13377  # open file to save data
13378  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13379  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
13380  DataFile = open(filename,'a') # Open output file
13381  HeaderString = 'Frequency-#, '
13382  if ShowC1_VdB.get() == 1:
13383  if dB == 1:
13384  HeaderString = HeaderString + 'CA-dB, '
13385  if dB == 0:
13386  HeaderString = HeaderString + 'CA-Mag, '
13387  if ShowC2_VdB.get() == 1:
13388  if dB == 1:
13389  HeaderString = HeaderString + 'CB-dB, '
13390  if dB == 0:
13391  HeaderString = HeaderString + 'CB-Mag, '
13392  if ShowC1_P.get() == 1:
13393  HeaderString = HeaderString + 'Phase A-B, '
13394  if ShowC2_P.get() == 1:
13395  HeaderString = HeaderString + 'Phase B-A, '
13396  HeaderString = HeaderString + '\n'
13397  DataFile.write( HeaderString )
13398 
13399  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
13400 
13401  n = 0
13402  while n < TRACEsize:
13403  F = n * Fsample
13404  txt = str(F)
13405  if ShowC1_VdB.get() == 1:
13406  V = 10 * math.log10(float(FFTresultA[n])) + 17 # Add 17 dB for max value of +10 dB
13407  if dB == 0:
13408  V = 10.0**(V/20.0)
13409  txt = txt + "," + str(V)
13410  if ShowC2_VdB.get() == 1:
13411  V = 10 * math.log10(float(FFTresultB[n])) + 17 # Add 17 dB for max value of +10 dB
13412  if dB == 0:
13413  V = 10.0**(V/20.0)
13414  txt = txt + "," + str(V)
13415  if ShowC1_P.get() == 1:
13416  RelPhase = PhaseA[n]-PhaseB[n]
13417  if RelPhase > 180:
13418  RelPhase = RelPhase - 360
13419  elif RelPhase < -180:
13420  RelPhase = RelPhase + 360
13421  txt = txt + "," + str(RelPhase)
13422  if ShowC2_P.get() == 1:
13423  RelPhase = PhaseB[n]-PhaseA[n]
13424  if RelPhase > 180:
13425  RelPhase = RelPhase - 360
13426  elif RelPhase < -180:
13427  RelPhase = RelPhase + 360
13428  txt = txt + "," + str(RelPhase)
13429  txt = txt + "\n"
13430  DataFile.write(txt)
13431  n = n + 1
13432 
13433  DataFile.close() # Close the file
13434 
13436 def MakeFreqScreen(): # Update the screen with traces and text
13437  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
13438  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13439  global PeakxM, PeakyM, PeakMdb, PeakfreqM
13440  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
13441  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
13442  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
13443  global COLORgrid # The colors
13444  global COLORsignalband, COLORtext
13445  global COLORtrace1, COLORtrace2
13446  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
13447  global DBdivindex # Index value
13448  global DBdivlist # dB per division list
13449  global DBlevel # Reference level
13450  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
13451  global X0LF # Left top X value
13452  global Y0TF # Left top Y value
13453  global GRWF # Screenwidth
13454  global GRHF # Screenheight
13455  global FontSize
13456  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
13457  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
13458  global SMPfft # number of FFT samples
13459  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
13460  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
13461  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp
13462  global ShowFCur, ShowdBCur, FCursor, dBCursor
13463  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
13464  global T1PRline, T2PRline
13465  global TRACEaverage # Number of traces for averageing
13466  global FreqTraceMode # 1 normal 2 max 3 average
13467  global Vdiv # Number of vertical divisions
13468 
13469  # Delete all items on the screen
13470  MarkerFreqNum = 0
13471  Freqca.delete(ALL) # remove all items
13472  try:
13473  StartFrequency = float(StartFreqEntry.get())
13474  except:
13475  StartFreqEntry.delete(0,"end")
13476  StartFreqEntry.insert(0,100)
13477  StartFrequency = 100
13478  try:
13479  StopFrequency = float(StopFreqEntry.get())
13480  except:
13481  StopFreqEntry.delete(0,"end")
13482  StopFreqEntry.insert(0,10000)
13483  StopFrequency = 10000
13484  try:
13485  Phasecenter = int(PhCenFreqEntry.get())
13486  RelPhaseCenter.set(Phasecenter)
13487  except:
13488  PhCenFreqEntry.delete(0,"end")
13489  PhCenFreqEntry.insert(0,0)
13490  RelPhaseCenter.set(0)
13491  Phasecenter = 0
13492  # Draw horizontal grid lines
13493  i = 0
13494  x1 = X0LF
13495  x2 = X0LF + GRWF
13496  while (i <= Vdiv.get()):
13497  y = Y0TF + i * GRHF/Vdiv.get()
13498  Dline = [x1,y,x2,y]
13499  if i == 0 or i == Vdiv.get():
13500  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13501  else:
13502  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13503  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
13504  Vaxis_label = str(Vaxis_value)
13505  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
13506  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
13507  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
13508  Vaxis_value = Vaxis_value + Phasecenter
13509  Vaxis_label = str(Vaxis_value)
13510  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
13511  i = i + 1
13512  # Draw vertical grid lines
13513  i = 0
13514  y1 = Y0TF
13515  y2 = Y0TF + GRHF
13516  if HScale.get() == 1:
13517  F = 1.0
13518  LogFStop = math.log10(StopFrequency)
13519  try:
13520  LogFStart = math.log10(StartFrequency)
13521  except:
13522  LogFStart = 0.0
13523  LogFpixel = (LogFStop - LogFStart) / GRWF
13524  # draw left and right edges
13525  while F <= StopFrequency:
13526  if F >= StartFrequency:
13527  try:
13528  LogF = math.log10(F) # convet to log Freq
13529  x = X0LF + (LogF - LogFStart)/LogFpixel
13530  except:
13531  x = X0LF
13532  Dline = [x,y1,x,y2]
13533  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
13534  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13535  axis_label = str(F)
13536  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
13537  else:
13538  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13539 
13540  if F < 10:
13541  F = F + 1
13542  elif F < 100:
13543  F = F + 10
13544  elif F < 1000:
13545  F = F + 100
13546  elif F < 1000:
13547  F = F + 100
13548  elif F < 10000:
13549  F = F + 1000
13550  elif F < 100000:
13551  F = F + 10000
13552  elif F < 200000:
13553  F = F + 10000
13554  else:
13555  Freqdiv = (StopFrequency - StartFrequency) / 10
13556  while (i < 11):
13557  x = X0LF + i * GRWF/10.0
13558  Dline = [x,y1,x,y2]
13559  if i == 0 or i == 10:
13560  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
13561  else:
13562  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
13563  axis_value = (StartFrequency + (i * Freqdiv))
13564  axis_label = str(axis_value)
13565  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
13566  i = i + 1
13567  # Draw X - Y cursors if needed
13568  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13569  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13570  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13571  if ShowFCur.get() > 0:
13572  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
13573  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
13574  # Horizontal conversion factors (frequency Hz) and border limits
13575  if HScale.get() == 1:
13576  LogFStop = math.log10(StopFrequency)
13577  try:
13578  LogFStart = math.log10(StartFrequency)
13579  except:
13580  LogFStart = 0.0
13581  LogFpixel = (LogFStop - LogFStart) / GRWF
13582  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
13583  else:
13584  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13585  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
13586  XFString = ' {0:.2f} '.format(xfreq)
13587  V_label = XFString + " Hz"
13588  Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
13589 #
13590  if ShowdBCur.get() > 0:
13591  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
13592  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
13593  # Vertical conversion factors (level dBs) and border limits
13594  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13595  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13596  yvdB = ((Yc-dBCursor)/Yconv)
13597  VdBString = ' {0:.1f} '.format(yvdB)
13598  V_label = VdBString + " dBV"
13599  Freqca.create_text(FCursor+1, dBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
13600  #
13601  SmoothBool = SmoothCurvesSA.get()
13602  # Draw traces
13603  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
13604  # Write the trace CHA
13605  if OverRangeFlagA == 1:
13606  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13607  else:
13608  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13609  if ShowMarker.get() > 0:
13610  k = 1
13611  while k <= HarmonicMarkers.get():
13612  try:
13613  dbA = (10 * math.log10(float(FFTresultA[PeakIndexA*k])) + 17)
13614  FreqA = k*PeakIndexA*Fsample
13615  if ShowMarker.get() == 2 and k > 1:
13616  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
13617  else:
13618  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
13619  if HScale.get() == 1:
13620  try:
13621  LogF = math.log10(FreqA) # convet to log Freq
13622  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
13623  except:
13624  xA = X0LF
13625  else:
13626  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
13627  yA = Yc - Yconv * dbA
13628  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
13629  k = k + 1
13630  except:
13631  k = k + 1
13632  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
13633  # Write the trace CHB
13634  if OverRangeFlagB == 1:
13635  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13636  else:
13637  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13638  if ShowMarker.get() > 0:
13639  k = 1
13640  while k <= HarmonicMarkers.get():
13641  try:
13642  dbB = (10 * math.log10(float(FFTresultB[PeakIndexB*k])) + 17)
13643  FreqB = k*PeakIndexB*Fsample
13644  if ShowMarker.get() == 2 and k > 1:
13645  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
13646  else:
13647  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
13648  if HScale.get() == 1:
13649  try:
13650  LogF = math.log10(FreqB) # convet to log Freq
13651  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
13652  except:
13653  xB = X0LF
13654  else:
13655  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
13656  yB = Yc - Yconv * dbB
13657  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
13658  k = k + 1
13659  except:
13660  k = k + 1
13661  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
13662  # Write the phase trace A-B
13663  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13664  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
13665  # Write the phase trace A-B
13666  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13667  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
13668  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13669  if ShowMarker.get() == 1:
13670  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
13671  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
13672  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
13673  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13674  if ShowMarker.get() == 1:
13675  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
13676  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
13677  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
13678  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13679  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
13680  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13681  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
13682  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13683  if ShowMarker.get() ==1:
13684  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
13685  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
13686  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
13687  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
13688  if ShowMarker.get() ==1:
13689  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
13690  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
13691  # General information on top of the grid
13692 
13693  txt = " Sample rate: " + str(SAMPLErate)
13694  txt = txt + " FFT samples: " + str(SMPfft)
13695 
13696  txt = txt + " " + FFTwindowname
13697 
13698  x = X0LF
13699  y = 12
13700  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13701 
13702  # Start and stop frequency and dB/div and trace mode
13703  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
13704  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
13705  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
13706  if FFTwindow.get() < 7:
13707  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
13708  else:
13709  txt = txt + " FFT Bandwidth = ???"
13710 
13711  x = X0LF
13712  y = Y0TF+GRHF+23
13713  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13714 
13715  if FreqTraceMode.get() == 1:
13716  txt ="Normal mode "
13717 
13718  if FreqTraceMode.get() == 2:
13719  txt = "Peak hold mode "
13720 
13721  if FreqTraceMode.get() == 3:
13722  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
13723 
13724  if ZEROstuffing.get() > 0:
13725  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
13726  # Runstatus and level information
13727  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
13728  txt = txt + " Stopped "
13729  elif SingleShotSA.get() == 1:
13730  txt = txt + " Single Shot Trace "
13731  else:
13732  if FreqDisp.get() == 1:
13733  txt = txt + " Running "
13734  else:
13735  txt = txt + " Display off "
13736  x = X0LF
13737  y = Y0TF+GRHF+34
13738  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
13739 
13741  global SMPfft, FFTwindow
13742  global SMPfftpwrTwo, BodeDisp
13743  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
13744 
13745  # First some subroutines to set specific variables
13746  if BodeDisp.get() == 0:
13747  if FFTwindow.get() != 8:
13748  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
13749 
13751  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
13752  TRACEresetFreq = True # Clear the memory for averaging or peak
13753  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
13754  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
13755 
13756 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
13757  global FFTbandwidth # The FFT bandwidth
13758  global FFTwindow # Which FFT window number is selected
13759  global FFTwindowname # The name of the FFT window function
13760  global FFTwindowshape # The window shape
13761  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
13762  global SMPfft # Number of FFT samples
13763  global LastWindow, LastSMPfft
13764 
13765  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
13766  # recalculate window only if something changed
13767  return
13768  # FFTname and FFTbandwidth in milliHz
13769  FFTwindowname = "No such window"
13770  FFTbw = 0
13771 
13772  if FFTwindow.get() == 0:
13773  FFTwindowname = " Rectangular (no) window (B=1) "
13774  FFTbw = 1.0
13775 
13776  if FFTwindow.get() == 1:
13777  FFTwindowname = " Cosine window (B=1.24) "
13778  FFTbw = 1.24
13779 
13780  if FFTwindow.get() == 2:
13781  FFTwindowname = " Triangular window (B=1.33) "
13782  FFTbw = 1.33
13783 
13784  if FFTwindow.get() == 3:
13785  FFTwindowname = " Hann window (B=1.5) "
13786  FFTbw = 1.5
13787 
13788  if FFTwindow.get() == 4:
13789  FFTwindowname = " Blackman window (B=1.73) "
13790  FFTbw = 1.73
13791 
13792  if FFTwindow.get() == 5:
13793  FFTwindowname = " Nuttall window (B=2.02) "
13794  FFTbw = 2.02
13795 
13796  if FFTwindow.get() == 6:
13797  FFTwindowname = " Flat top window (B=3.77) "
13798  FFTbw = 3.77
13799 
13800  if FFTwindow.get() == 7:
13801  FFTwindowname = FFTUserWindowString
13802  FFTbw = 0.0
13803  try:
13804  FFTwindowshape = eval(FFTUserWindowString)
13805  except:
13806  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
13807  print( "Filling FFT window with Ones")
13808  elif FFTwindow.get() == 8: # window shape array read from csv file
13809  FFTwindowname = "Window Shape From file"
13810  FFTbw = 0.0
13811  else:
13812  FFTbandwidth = int(FFTbw * SAMPLErate / float(SMPfft))
13813  # Calculate the shape
13814  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
13815  n = 0
13816  while n < SMPfft:
13817  # Cosine window function - medium-dynamic range B=1.24
13818  if FFTwindow.get() == 1:
13819  w = math.sin(math.pi * n / (SMPfft - 1))
13820  FFTwindowshape[n] = w * 1.571
13821  # Triangular non-zero endpoints - medium-dynamic range B=1.33
13822  if FFTwindow.get() == 2:
13823  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
13824  FFTwindowshape[n] = w * 2.0
13825  # Hann window function - medium-dynamic range B=1.5
13826  if FFTwindow.get() == 3:
13827  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
13828  FFTwindowshape[n] = w * 2.000
13829  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
13830  if FFTwindow.get() == 4:
13831  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
13832  FFTwindowshape[n] = w * 2.381
13833  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
13834  if FFTwindow.get() == 5:
13835  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))
13836  FFTwindowshape[n] = w * 2.811
13837  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
13838  if FFTwindow.get() == 6:
13839  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))
13840  FFTwindowshape[n] = w * 1.000
13841  n = n + 1
13842  LastWindow = FFTwindow.get()
13843  LastSMPfft = SMPfft
13844 
13846  global FFTUserWindowString, freqwindow
13847 
13848  TempString = FFTUserWindowString
13849  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
13850  if (FFTUserWindowString == None): # If Cancel pressed, then None
13851  FFTUserWindowString = TempString
13852 
13854  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
13855 
13856  # Read values from CVS file
13857  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
13858  try:
13859  CSVFile = open(filename)
13860  csv_f = csv.reader(CSVFile)
13861  FFTwindowshape = []
13862  for row in csv_f:
13863  try:
13864  FFTwindowshape.append(float(row[0]))
13865  except:
13866  print( 'skipping non-numeric row')
13867  FFTwindowshape = numpy.array(FFTwindowshape)
13868  CSVFile.close()
13869  SMPfft = len(FFTwindowshape)
13870  LastSMPfft = SMPfft
13871  LastWindow = FFTwindow.get()
13872  print( SMPfft)
13873  except:
13874  showwarning("WARNING","No such file found or wrong format!")
13875 #
13877  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
13878 
13879  FCursor = event.x
13880  dBCursor = event.y
13881  if RUNstatus.get() == 0:
13883  Freqca.bind_all('<MouseWheel>', onCanvasFreqClickScroll)
13884 #
13886  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
13887  if event.widget == Freqca:
13888  ShiftKeyDwn = event.state & 1
13889  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
13890  FCursor = FCursor + event.delta/100
13891  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
13892  dBCursor = dBCursor - event.delta/100
13893  if RUNstatus.get() == 0:
13895 #
13897  global X0LF # Left top X value
13898  global Y0TF # Left top Y value
13899  global GRWF # Screenwidth
13900  global GRHF # Screenheight
13901  global FontSize
13902  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
13903  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
13904  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
13905  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
13906 
13907  if (RUNstatus.get() == 0):
13908  MarkerFreqNum = MarkerFreqNum + 1
13909  COLORmarker = COLORgrid
13910  if ShowC1_VdB.get() == 1:
13911  COLORmarker = COLORtrace1
13912  elif ShowC2_VdB.get() == 1:
13913  COLORmarker = COLORtrace2
13914  try:
13915  StartFrequency = float(StartFreqEntry.get())
13916  except:
13917  StartFreqEntry.delete(0,"end")
13918  StartFreqEntry.insert(0,100)
13919  StartFrequency = 100
13920  try:
13921  StopFrequency = float(StopFreqEntry.get())
13922  except:
13923  StopFreqEntry.delete(0,"end")
13924  StopFreqEntry.insert(0,100)
13925  StopFrequency = 100
13926  # draw X at marker point and number
13927  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
13928  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
13929  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
13930  # Vertical conversion factors (level dBs) and border limits
13931  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13932  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13933  Yphconv = float(GRHF) / 360
13934  Yp = float(Y0TF) + Yphconv + 180
13935  # Horizontal conversion factors (frequency Hz) and border limits
13936  if HScale.get() == 1:
13937  LogFStop = math.log10(StopFrequency)
13938  try:
13939  LogFStart = math.log10(StartFrequency)
13940  except:
13941  LogFStart = 0.0
13942  LogFpixel = (LogFStop - LogFStart) / GRWF
13943  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
13944  else:
13945  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13946  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
13947 
13948  yvdB = ((Yc-event.y)/Yconv)
13949  VdBString = ' {0:.1f} '.format(yvdB)
13950  XFString = ' {0:.2f} '.format(xfreq)
13951  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
13952  if MarkerFreqNum > 1:
13953  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
13954  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
13955  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
13956  x = X0LF + 5
13957  y = Y0TF + 3 + (MarkerFreqNum*10)
13958  Justify = 'w'
13959  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
13960  x = X0LF + GRWF - 5
13961  y = Y0TF + 3 + (MarkerFreqNum*10)
13962  Justify = 'e'
13963  if MarkerLoc == 'LL' or MarkerLoc == 'll':
13964  x = X0LF + 5
13965  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
13966  Justify = 'w'
13967  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
13968  x = X0LF + GRWF - 5
13969  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
13970  Justify = 'e'
13971  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
13972  PrevdBV = yvdB
13973  PrevF = xfreq
13974 #
13975 def onCanvasSAOne(event):
13976  global ShowC1_VdB
13977  if ShowC1_VdB.get() == 0:
13978  ShowC1_VdB.set(1)
13979  else:
13980  ShowC1_VdB.set(0)
13981 #
13982 def onCanvasSATwo(event):
13983  global ShowC2_VdB
13984  if ShowC2_VdB.get() == 0:
13985  ShowC2_VdB.set(1)
13986  else:
13987  ShowC2_VdB.set(0)
13988 #
13989 def onCanvasSAThree(event):
13990  global ShowC1_P
13991  if ShowC1_P.get() == 0:
13992  ShowC1_P.set(1)
13993  else:
13994  ShowC1_P.set(0)
13995 #
13996 def onCanvasSAFour(event):
13997  global ShowC2_P
13998  if ShowC2_P.get() == 0:
13999  ShowC2_P.set(1)
14000  else:
14001  ShowC2_P.set(0)
14002 #
14003 def onCanvasSAFive(event):
14004  global ShowMarker
14005  if ShowMarker.get() == 0:
14006  ShowMarker.set(1)
14007  else:
14008  ShowMarker.set(0)
14009 #
14010 def onCanvasSASix(event):
14011  global ShowRA_VdB
14012  if ShowRA_VdB.get() == 0:
14013  ShowRA_VdB.set(1)
14014  else:
14015  ShowRA_VdB.set(0)
14016 #
14017 def onCanvasSASeven(event):
14018  global ShowRB_VdB
14019  if ShowRB_VdB.get() == 0:
14020  ShowRB_VdB.set(1)
14021  else:
14022  ShowRB_VdB.set(0)
14023 #
14024 def onCanvasSAEight(event):
14025  global ShowMathSA
14026  ShowMathSA.set(2)
14027 #
14028 def onCanvasSANine(event):
14029  global ShowMathSA
14030  ShowMathSA.set(1)
14031 #
14032 def onCanvasSAZero(event):
14033  global ShowMathSA
14034  ShowMathSA.set(0)
14035 #
14036 def onCanvasSASnap(event):
14037  BSTOREtraceSA()
14038 #
14039 def onCanvasSANormal(event):
14040  BNormalmode()
14041 #
14042 def onCanvasSAPeak(event):
14043  BPeakholdmode()
14044 
14045 def onCanvasSAReset(event):
14046  BResetFreqAvg()
14047 #
14049  BAveragemode()
14050 #
14051 def onCanvasShowFcur(event):
14052  global ShowFCur
14053  if ShowFCur.get() == 0:
14054  ShowFCur.set(1)
14055  else:
14056  ShowFCur.set(0)
14057 #
14059  global ShowdBCur
14060  if ShowdBCur.get() == 1:
14061  ShowdBCur.set(0)
14062  else:
14063  ShowdBCur.set(1)
14064 #
14065 def onCanvasShowPcur(event):
14066  global ShowdBCur
14067  if ShowdBCur.get() == 2:
14068  ShowdBCur.set(0)
14069  else:
14070  ShowdBCur.set(2)
14071 #
14073  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
14074 
14075  BPCursor = event.x
14076  BdBCursor = event.y
14077  if RUNstatus.get() == 0:
14079  Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
14080 #
14082  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
14083 
14084  # print event.state
14085  shift_key = event.state & 1
14086  if ShowBPCur.get() > 0 and shift_key == 0:
14087  BPCursor = BPCursor + event.delta/100
14088  elif ShowBdBCur.get() > 0 or shift_key == 1:
14089  BdBCursor = BdBCursor - event.delta/100
14090  if RUNstatus.get() == 0:
14092 #
14094  global X0LBP # Left top X value
14095  global Y0TBP # Left top Y value
14096  global GRWBP # Screenwidth
14097  global GRHBP # Screenheight
14098  global FontSize
14099  global Bodeca, MarkerLoc, SAMPLErate
14100  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
14101  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
14102  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
14103 
14104  if (RUNstatus.get() == 0):
14105  MarkerFreqNum = MarkerFreqNum + 1
14106  COLORmarker = COLORtrace6 # COLORgrid
14107  if ShowCA_VdB.get() == 1:
14108  COLORmarker = COLORtrace1
14109  elif ShowCB_VdB.get() == 1:
14110  COLORmarker = COLORtrace2
14111  try:
14112  EndFreq = float(StopBodeEntry.get())
14113  except:
14114  StopBodeEntry.delete(0,"end")
14115  StopBodeEntry.insert(0,10000)
14116  EndFreq = 10000
14117  try:
14118  BeginFreq = float(StartBodeEntry.get())
14119  except:
14120  StartBodeEntry.delete(0,"end")
14121  StartBodeEntry.insert(0,100)
14122  BeginFreq = 100
14123  # draw X at marker point and number
14124  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
14125  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
14126  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
14127  # Vertical conversion factors (level dBs) and border limits
14128  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14129  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14130  Yphconv = float(GRHBP) / 360
14131  Yp = float(Y0TBP) + Yphconv + 180
14132  x1 = X0LBP + 14
14133  x2 = x1 + GRWBP
14134  # Horizontal conversion factors (frequency Hz) and border limits
14135  if HScaleBP.get() == 1:
14136  LogFStop = math.log10(EndFreq)
14137  try:
14138  LogFStart = math.log10(BeginFreq)
14139  except:
14140  LogFStart = 0.0
14141  LogFpixel = (LogFStop - LogFStart) / GRWBP
14142  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
14143  else:
14144  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14145  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
14146 
14147  yvdB = ((Yc-event.y)/Yconv)
14148  VdBString = ' {0:.1f} '.format(yvdB)
14149  XFString = ' {0:.2f} '.format(xfreq)
14150  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
14151  if MarkerFreqNum > 1:
14152  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
14153  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
14154  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
14155  x = x1 + 5
14156  y = Y0TBP + 3 + (MarkerFreqNum*10)
14157  Justify = 'w'
14158  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
14159  x = x2 - 5
14160  y = Y0TBP + 3 + (MarkerFreqNum*10)
14161  Justify = 'e'
14162  if MarkerLoc == 'LL' or MarkerLoc == 'll':
14163  x = x1 + 5
14164  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
14165  Justify = 'w'
14166  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
14167  x = x2 - 5
14168  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
14169  Justify = 'e'
14170  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
14171  PrevdBV = yvdB
14172  PrevF = xfreq
14173 #
14174 def onCanvasBdOne(event):
14175  global ShowCA_VdB
14176  if ShowCA_VdB.get() == 0:
14177  ShowCA_VdB.set(1)
14178  else:
14179  ShowCA_VdB.set(0)
14180 #
14181 def onCanvasBdTwo(event):
14182  global ShowCB_VdB
14183  if ShowCB_VdB.get() == 0:
14184  ShowCB_VdB.set(1)
14185  else:
14186  ShowCB_VdB.set(0)
14187 #
14188 def onCanvasBdThree(event):
14189  global ShowCA_P
14190  if ShowCA_P.get() == 0:
14191  ShowCA_P.set(1)
14192  else:
14193  ShowCA_P.set(0)
14194 #
14195 def onCanvasBdFour(event):
14196  global ShowCB_P
14197  if ShowCB_P.get() == 0:
14198  ShowCB_P.set(1)
14199  else:
14200  ShowCB_P.set(0)
14201 #
14202 def onCanvasBdFive(event):
14203  global ShowMarkerBP
14204  if ShowMarkerBP.get() == 0:
14205  ShowMarkerBP.set(1)
14206  else:
14207  ShowMarkerBP.set(0)
14208 #
14209 def onCanvasBdSix(event):
14210  global ShowRA_VdB
14211  if ShowRA_VdB.get() == 0:
14212  ShowRA_VdB.set(1)
14213  else:
14214  ShowRA_VdB.set(0)
14215 #
14216 def onCanvasBdSeven(event):
14217  global ShowRB_VdB
14218  if ShowRB_VdB.get() == 0:
14219  ShowRB_VdB.set(1)
14220  else:
14221  ShowRB_VdB.set(0)
14222 #
14223 def onCanvasBdEight(event):
14224  global ShowMathBP
14225  ShowMathBP.set(2)
14226 #
14227 def onCanvasBdNine(event):
14228  global ShowMathBP
14229  ShowMathBP.set(1)
14230 #
14231 def onCanvasBdZero(event):
14232  global ShowMathBP
14233  ShowMathBP.set(0)
14234 #
14235 def onCanvasBdSnap(event):
14236  BSTOREtraceBP()
14237 #
14239  global ShowBPCur
14240  if ShowBPCur.get() == 0:
14241  ShowBPCur.set(1)
14242  else:
14243  ShowBPCur.set(0)
14244 #
14246  global ShowBdBCur
14247  if ShowBdBCur.get() == 1:
14248  ShowBdBCur.set(0)
14249  else:
14250  ShowBdBCur.set(1)
14251 #
14253  global ShowBdBCur
14254  if ShowBdBCur.get() == 2:
14255  ShowBdBCur.set(0)
14256  else:
14257  ShowBdBCur.set(2)
14258 #
14259 def onAWGAscroll(event):
14260  global AWGAShape
14261 
14262  onTextScroll(event)
14263  time.sleep(0.05)
14264  ReMakeAWGwaves()
14265  time.sleep(0.05)
14266 #
14267 def onAWGBscroll(event):
14268  global AWGBShape
14269 
14270  onTextScroll(event)
14271  time.sleep(0.05)
14272  ReMakeAWGwaves()
14273  time.sleep(0.05)
14274 #
14275 def onTextScroll(event): # august 7
14276  button = event.widget
14277  cursor_position = button.index(INSERT) # get current cursor position
14278  Pos = cursor_position
14279  OldVal = button.get() # get current entry string
14280  OldValfl = float(OldVal) # and its value
14281  Len = len(OldVal)
14282  Dot = OldVal.find (".") # find decimal point position
14283  Decimals = Len - Dot - 1
14284  if Dot == -1 : # no point
14285  Decimals = 0
14286  Step = 10**(Len - Pos)
14287  elif Pos <= Dot : # no point left of position
14288  Step = 10**(Dot - Pos)
14289  else :
14290  Step = 10**(Dot - Pos + 1)
14291  if event.delta > 0: # increment value
14292  NewVal = OldValfl + Step
14293  else: # decrement value
14294  NewVal = OldValfl - Step
14295  FormatStr = "{0:." + str(Decimals) + "f}"
14296  NewStr = FormatStr.format(NewVal)
14297  NewDot = NewStr.find (".")
14298  NewPos = Pos + NewDot - Dot
14299  if Decimals == 0 :
14300  NewLen = len(NewStr)
14301  NewPos = Pos + NewLen - Len
14302  button.delete(0, END) # remove old entry
14303  button.insert(0, NewStr) # insert new entry
14304  button.icursor(NewPos) # resets the insertion cursor
14305 #
14306 def onAWGAkey(event):
14307  global AWGAShape
14308 
14309  onTextKey(event)
14310  ReMakeAWGwaves()
14311 #
14312 def onAWGBkey(event):
14313  global AWGBShape
14314 
14315  onTextKey(event)
14316  ReMakeAWGwaves()
14317 #
14318 def onTextKeyAWG(event):
14319  onTextKey(event)
14320  ReMakeAWGwaves()
14321 
14322 def onTextKey(event):
14323 
14324  button = event.widget
14325  cursor_position = button.index(INSERT) # get current cursor position
14326  NewPos = cursor_position -1
14327  OldVal = button.get() # get current entry string
14328  OldDigit = OldVal[NewPos]
14329  if platform.system() == "Windows":
14330  if event.keycode == 38: # increment digit for up arrow key
14331  NewDigit = int(OldDigit) + 1
14332  elif event.keycode == 40: # decrement digit for down arrow
14333  NewDigit = int(OldDigit) - 1
14334  else:
14335  return
14336  elif platform.system() == "Linux":
14337  if event.keycode == 111: # increment digit for up arrow key
14338  NewDigit = int(OldDigit) + 1
14339  elif event.keycode == 116: # decrement digit for down arrow
14340  NewDigit = int(OldDigit) - 1
14341  else:
14342  return
14343  if OldDigit == ".": # if cursor next to decimal point nop
14344  return
14345  if NewDigit > 9:
14346  NewDigit = 0
14347  button.delete(NewPos) # remove old digit
14348  button.insert(NewPos,NewDigit) # insert new digit
14349  NewPos = cursor_position-2
14350  if NewPos < 0:
14351  return
14352  CarryDigit = OldVal[NewPos]
14353  if CarryDigit == ".": # if carry is decimal point
14354  NewPos = cursor_position-3
14355  CarryDigit = OldVal[NewPos]
14356  NewDigit = int(CarryDigit) + 1
14357  if NewDigit > 9:
14358  NewDigit = 0
14359  button.delete(NewPos) # remove old digit
14360  button.insert(NewPos,NewDigit) # insert new digit
14361  elif NewDigit < 0:
14362  NewDigit = 9
14363  button.delete(NewPos) # remove old digit
14364  button.insert(NewPos,NewDigit) # insert new digit
14365  NewPos = cursor_position-2
14366  if NewPos < 0:
14367  return
14368  CarryDigit = OldVal[NewPos]
14369  if CarryDigit == ".": # if carry is decimal point
14370  NewPos = cursor_position-3
14371  CarryDigit = OldVal[NewPos]
14372  NewDigit = int(CarryDigit) - 1
14373  if NewDigit < 0:
14374  NewDigit = 9
14375  button.delete(NewPos) # remove old digit
14376  button.insert(NewPos,NewDigit) # insert new digit
14377  else:
14378  button.delete(NewPos) # remove old digit
14379  button.insert(NewPos,NewDigit) # insert new digit
14380 #
14381 def onSpinBoxScroll(event):
14382  spbox = event.widget
14383  if event.delta > 0: # increment digit
14384  spbox.invoke('buttonup')
14385  else: # decrement digit
14386  spbox.invoke('buttondown')
14387 #
14388 # ================ Make awg sub window ==========================
14390  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
14391  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
14392  global AWGABurstFlag, AWGBBurstFlag
14393  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
14394  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
14395  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
14396  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
14397  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
14398  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
14399 
14400  if AWGScreenStatus.get() == 0:
14401  AWGScreenStatus.set(1)
14402 
14403  awgwindow = Toplevel()
14404  awgwindow.title("AWG Controls " + SWRev + RevDate)
14405  awgwindow.resizable(FALSE,FALSE)
14406  awgwindow.geometry('+0+100')
14407  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
14408  #
14409  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
14410  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
14411  #
14412  if AwgLayout == "Horz":
14413  frame2.pack(side=LEFT, expand=1, fill=X)
14414  frame3.pack(side=LEFT, expand=1, fill=X)
14415  else:
14416  frame2.pack(side=TOP, expand=1, fill=Y)
14417  frame3.pack(side=TOP, expand=1, fill=Y)
14418  # now AWG A
14419  # AWG enable sub frame
14420  AWGAMode = IntVar(0) # AWG A mode variable
14421  AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
14422  AWGATerm = IntVar(0) # AWG A termination variable
14423  AWGAShape = IntVar(0) # AWG A Wave shape variable
14424  AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
14425  AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
14426  AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
14427  AWGAMode.set(2)
14428  AWGSync = IntVar(0) # Sync start both AWG channels
14429  AWGSync.set(1)
14430  awg1eb = Frame( frame2 )
14431  awg1eb.pack(side=TOP)
14432  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
14433  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
14434  ModeAMenu["menu"] = ModeAMenu.menu
14435  ModeAMenu.menu.add_command(label="-Mode-", command=donothing)
14436  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
14437  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
14438  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
14439  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
14440  ModeAMenu.menu.add_separator()
14441  ModeAMenu.menu.add_command(label="-Term-", command=donothing)
14442  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
14443  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
14444  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
14445  ModeAMenu.pack(side=LEFT, anchor=W)
14446  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W5.TButton")
14447  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
14448  ShapeAMenu["menu"] = ShapeAMenu.menu
14449  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
14450  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
14451  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
14452  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
14453  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
14454  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
14455  ShapeAMenu.menu.add_separator()
14456  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
14457  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
14458  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
14459  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
14460  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
14461  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
14462  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
14463  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
14464  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
14465  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
14466  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
14467  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
14468  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
14469  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
14470  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
14471  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
14472  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
14473  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
14474  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
14475  ShapeAMenu.pack(side=LEFT, anchor=W)
14476  #
14477  AWGAModeLabel = Label(frame2, text="AWG A Mode")
14478  AWGAModeLabel.pack(side=TOP)
14479  #
14480  awg1ampl = Frame( frame2 )
14481  awg1ampl.pack(side=TOP)
14482  AWGAAmplEntry = Entry(awg1ampl, width=5)
14483  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
14484  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
14485  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
14486  AWGAAmplEntry.pack(side=LEFT, anchor=W)
14487  AWGAAmplEntry.delete(0,"end")
14488  AWGAAmplEntry.insert(0,0.0)
14489  amp1lab = Label(awg1ampl) #, text="Min Ch A")
14490  amp1lab.pack(side=LEFT, anchor=W)
14491  #
14492  awg1off = Frame( frame2 )
14493  awg1off.pack(side=TOP)
14494  AWGAOffsetEntry = Entry(awg1off, width=5)
14495  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
14496  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
14497  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
14498  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
14499  AWGAOffsetEntry.delete(0,"end")
14500  AWGAOffsetEntry.insert(0,0.0)
14501  off1lab = Label(awg1off) #, text="Max Ch A")
14502  off1lab.pack(side=LEFT, anchor=W)
14503  if AWG_Amp_Mode.get() == 0:
14504  amp1lab.config(text = "Min Ch A" ) # change displayed value
14505  off1lab.config(text = "Max Ch A" ) # change displayed value
14506  else:
14507  amp1lab.config(text = "Amp Ch A" )
14508  off1lab.config(text = "Off Ch A" )
14509  # AWG Frequency sub frame
14510  awg1freq = Frame( frame2 )
14511  awg1freq.pack(side=TOP)
14512  AWGAFreqEntry = Entry(awg1freq, width=7)
14513  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
14514  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
14515  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
14516  AWGAFreqEntry.pack(side=LEFT, anchor=W)
14517  AWGAFreqEntry.delete(0,"end")
14518  AWGAFreqEntry.insert(0,100.0)
14519  freq1lab = Label(awg1freq, text="Freq Ch A")
14520  freq1lab.pack(side=LEFT, anchor=W)
14521  # AWG Phase or delay select sub frame
14522  AWGAPhaseDelay = IntVar(0) #
14523  awgadelay = Frame( frame2 )
14524  awgadelay.pack(side=TOP)
14525  awgaph = Radiobutton(awgadelay, text="Phase", style="WPhase.TRadiobutton", variable=AWGAPhaseDelay, value=0, command=BAWGAPhaseDelay)
14526  awgaph.pack(side=LEFT, anchor=W)
14527  awgadel = Radiobutton(awgadelay, text="Delay", style="GPhase.TRadiobutton", variable=AWGAPhaseDelay, value=1, command=BAWGAPhaseDelay)
14528  awgadel.pack(side=LEFT, anchor=W)
14529  # AWG Phase entry sub frame
14530  awg1phase = Frame( frame2 )
14531  awg1phase.pack(side=TOP)
14532  AWGAPhaseEntry = Entry(awg1phase, width=5)
14533  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
14534  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
14535  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
14536  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
14537  AWGAPhaseEntry.delete(0,"end")
14538  AWGAPhaseEntry.insert(0,0)
14539  phasealab = Label(awg1phase, text="Deg")
14540  phasealab.pack(side=LEFT, anchor=W)
14541  # AWG duty cycle frame
14542  awg1dc = Frame( frame2 )
14543  awg1dc.pack(side=TOP)
14544  AWGADutyCycleEntry = Entry(awg1dc, width=5)
14545  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
14546  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
14547  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
14548  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
14549  AWGADutyCycleEntry.delete(0,"end")
14550  AWGADutyCycleEntry.insert(0,50)
14551  duty1lab = Label(awg1dc, text="%")
14552  duty1lab.pack(side=LEFT, anchor=W)
14553  #
14554  AWGALength = Label(frame2, text="Length")
14555  AWGALength.pack(side=TOP)
14556  #
14557  if FWRevOne > 2.16:
14558  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
14559  awg2x1.pack(side=TOP)
14560  awg2x2 = Radiobutton(frame2, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
14561  awg2x2.pack(side=TOP)
14562  awg2x3 = Radiobutton(frame2, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
14563  awg2x3.pack(side=TOP)
14564  else:
14565  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
14566  awgsync.pack(side=TOP)
14567  # now AWG B
14568  # AWG enable sub frame
14569  AWGBMode = IntVar(0) # AWG B mode variable
14570  AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
14571  AWGBTerm = IntVar(0) # AWG B termination variable
14572  AWGBShape = IntVar(0) # AWG B Wave shape variable
14573  AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
14574  AWGBMode.set(2)
14575  awg2eb = Frame( frame3 )
14576  awg2eb.pack(side=TOP)
14577  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
14578  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
14579  ModeBMenu["menu"] = ModeBMenu.menu
14580  ModeBMenu.menu.add_command(label="-Mode-", command=donothing)
14581  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
14582  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
14583  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
14584  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
14585  ModeBMenu.menu.add_separator()
14586  ModeBMenu.menu.add_command(label="-Term-", command=donothing)
14587  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
14588  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
14589  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
14590  ModeBMenu.pack(side=LEFT, anchor=W)
14591  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W5.TButton")
14592  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
14593  ShapeBMenu["menu"] = ShapeBMenu.menu
14594  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
14595  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
14596  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
14597  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
14598  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
14599  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
14600  ShapeBMenu.menu.add_separator()
14601  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
14602  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
14603  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
14604  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
14605  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
14606  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
14607  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
14608  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
14609  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
14610  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
14611  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
14612  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
14613  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
14614  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
14615  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
14616  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
14617  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
14618  ShapeBMenu.pack(side=LEFT, anchor=W)
14619  #
14620  AWGBModeLabel = Label(frame3, text="AWG A Mode")
14621  AWGBModeLabel.pack(side=TOP)
14622  #
14623  awg2ampl = Frame( frame3 )
14624  awg2ampl.pack(side=TOP)
14625  AWGBAmplEntry = Entry(awg2ampl, width=5)
14626  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
14627  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll) #
14628  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
14629  AWGBAmplEntry.pack(side=LEFT, anchor=W)
14630  AWGBAmplEntry.delete(0,"end")
14631  AWGBAmplEntry.insert(0,0.0)
14632  amp2lab = Label(awg2ampl) #, text="Min Ch B")
14633  amp2lab.pack(side=LEFT, anchor=W)
14634  #
14635  awg2off = Frame( frame3 )
14636  awg2off.pack(side=TOP)
14637  AWGBOffsetEntry = Entry(awg2off, width=5)
14638  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
14639  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
14640  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
14641  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
14642  AWGBOffsetEntry.delete(0,"end")
14643  AWGBOffsetEntry.insert(0,0.0)
14644  off2lab = Label(awg2off) #, text="Max Ch B")
14645  off2lab.pack(side=LEFT, anchor=W)
14646  if AWG_Amp_Mode.get() == 0:
14647  amp2lab.config(text = "Min Ch B" ) # change displayed value
14648  off2lab.config(text = "Max Ch B" ) # change displayed value
14649  else:
14650  amp2lab.config(text = "Amp Ch B" )
14651  off2lab.config(text = "Off Ch B" )
14652  # AWG Frequency sub frame
14653  awg2freq = Frame( frame3 )
14654  awg2freq.pack(side=TOP)
14655  AWGBFreqEntry = Entry(awg2freq, width=7)
14656  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
14657  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
14658  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
14659  AWGBFreqEntry.pack(side=LEFT, anchor=W)
14660  AWGBFreqEntry.delete(0,"end")
14661  AWGBFreqEntry.insert(0,100.0)
14662  freq2lab = Label(awg2freq, text="Freq Ch B")
14663  freq2lab.pack(side=LEFT, anchor=W)
14664  # AWG Phase or delay select sub frame
14665  AWGBPhaseDelay = IntVar(0) #
14666  awgbdelay = Frame( frame3 )
14667  awgbdelay.pack(side=TOP)
14668  awgbph = Radiobutton(awgbdelay, text="Phase", style="WPhase.TRadiobutton", variable=AWGBPhaseDelay, value=0, command=BAWGBPhaseDelay)
14669  awgbph.pack(side=LEFT, anchor=W)
14670  awgbdel = Radiobutton(awgbdelay, text="Delay", style="GPhase.TRadiobutton", variable=AWGBPhaseDelay, value=1, command=BAWGBPhaseDelay)
14671  awgbdel.pack(side=LEFT, anchor=W)
14672  # AWG Phase sub frame
14673  awg2phase = Frame( frame3 )
14674  awg2phase.pack(side=TOP)
14675  AWGBPhaseEntry = Entry(awg2phase, width=5)
14676  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
14677  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
14678  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
14679  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
14680  AWGBPhaseEntry.delete(0,"end")
14681  AWGBPhaseEntry.insert(0,0)
14682  phaseblab = Label(awg2phase, text="Deg")
14683  phaseblab.pack(side=LEFT, anchor=W)
14684  # AWG duty cycle frame
14685  awg2dc = Frame( frame3 )
14686  awg2dc.pack(side=TOP)
14687  AWGBDutyCycleEntry = Entry(awg2dc, width=5)
14688  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
14689  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
14690  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
14691  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
14692  AWGBDutyCycleEntry.delete(0,"end")
14693  AWGBDutyCycleEntry.insert(0,50)
14694  duty2lab = Label(awg2dc, text="%")
14695  duty2lab.pack(side=LEFT, anchor=W)
14696  #
14697  AWGBLength = Label(frame3, text="Length")
14698  AWGBLength.pack(side=TOP)
14699  #
14700  BisCompA = IntVar(0) # Sync start both AWG channels
14701  BisCompA.set(0)
14702  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
14703  bcompa.pack(side=TOP)
14704  if FWRevOne > 2.16:
14705  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
14706  awgsync.pack(side=TOP)
14707  #
14708  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
14709  dismissbutton.pack(side=TOP)
14710  else:
14711  awgwindow.deiconify()
14712 #
14713 def BAWG2X():
14714  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
14715 
14716  ReMakeAWGwaves()
14717  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
14718  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
14719  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
14720  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
14721  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
14722  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
14723  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
14724  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
14725  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
14726  BisCompA.set(0)
14727  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
14728  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
14729  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
14730  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
14731  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
14732  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
14733  BisCompA.set(0)
14734 #
14736  global awgwindow, AWGScreenStatus
14737 
14738  # AWGScreenStatus.set(0)
14739  awgwindow.iconify()
14740 # ===== Channel B Mux Mode sub Window =======
14742  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
14743  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
14744  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
14745  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
14746  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev
14747  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg, DualMuxMode
14748 
14749  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
14750  MuxScreenStatus.set(1)
14751  #
14752  BAWGEnab() # update AWG settings
14753  #
14754  muxwindow = Toplevel()
14755  muxwindow.title("CH-B Mux " + SWRev + RevDate)
14756  muxwindow.resizable(FALSE,FALSE)
14757  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
14758  #
14759  frameM = LabelFrame(muxwindow, text="CH B Mux", style="A10B.TLabel") #, font="Arial 10 bold", borderwidth=5, relief=RIDGE)
14760  frameM.pack(side=LEFT, expand=1, fill=Y)
14761  #
14762  # Voltage channel CHB-A
14763  frameA = Frame(frameM)
14764  frameA.pack(side=TOP)
14765  cba = Checkbutton(frameA, text='CB-A', variable=Show_CBA, command=UpdateTimeTrace)
14766  cba.pack(side=LEFT, anchor=W)
14767  CHB_Asb = Spinbox(frameA, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14768  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
14769  CHB_Asb.pack(side=LEFT)
14770  CHB_Asb.delete(0,"end")
14771  CHB_Asb.insert(0,0.5)
14772  #
14773  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
14774  CHB_Alab.pack(side=LEFT)
14775  CHB_APosEntry = Entry(frameA, width=5)
14776  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
14777  CHB_APosEntry.bind('<Key>', onTextKey)
14778  CHB_APosEntry.pack(side=LEFT)
14779  CHB_APosEntry.delete(0,"end")
14780  CHB_APosEntry.insert(0,2.5)
14781  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
14782  CHB_Aofflab.pack(side=LEFT)
14783  # Voltage channel CHB-B
14784  frameB = Frame(frameM)
14785  frameB.pack(side=TOP)
14786  cbb = Checkbutton(frameB, text='CB-B', variable=Show_CBB, command=UpdateTimeTrace)
14787  cbb.pack(side=LEFT, anchor=W)
14788  CHB_Bsb = Spinbox(frameB, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14789  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
14790  CHB_Bsb.pack(side=LEFT)
14791  CHB_Bsb.delete(0,"end")
14792  CHB_Bsb.insert(0,0.5)
14793  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
14794  CHB_Blab.pack(side=LEFT)
14795  CHB_BPosEntry = Entry(frameB, width=5)
14796  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
14797  CHB_BPosEntry.bind('<Key>', onTextKey)
14798  CHB_BPosEntry.pack(side=LEFT)
14799  CHB_BPosEntry.delete(0,"end")
14800  CHB_BPosEntry.insert(0,2.5)
14801  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
14802  CHB_Bofflab.pack(side=LEFT)
14803  # Voltage channel B-C
14804  frameC = Frame(frameM)
14805  frameC.pack(side=TOP)
14806  cbc = Checkbutton(frameC, text='CB-C', variable=Show_CBC, command=UpdateTimeTrace)
14807  cbc.pack(side=LEFT, anchor=W)
14808  CHB_Csb = Spinbox(frameC, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14809  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
14810  CHB_Csb.pack(side=LEFT)
14811  CHB_Csb.delete(0,"end")
14812  CHB_Csb.insert(0,0.5)
14813  #
14814  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
14815  CHB_Clab.pack(side=LEFT)
14816  CHB_CPosEntry = Entry(frameC, width=5)
14817  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
14818  CHB_CPosEntry.bind('<Key>', onTextKey)
14819  CHB_CPosEntry.pack(side=LEFT)
14820  CHB_CPosEntry.delete(0,"end")
14821  CHB_CPosEntry.insert(0,2.5)
14822  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
14823  CHB_Cofflab.pack(side=LEFT)
14824  # Voltage channel B-D
14825  frameD = Frame(frameM)
14826  frameD.pack(side=TOP)
14827  cbd = Checkbutton(frameD, text='CB-D', variable=Show_CBD, command=UpdateTimeTrace)
14828  cbd.pack(side=LEFT, anchor=W)
14829  CHB_Dsb = Spinbox(frameD, width=4, values=CHvpdiv, command=UpdateTimeTrace)
14830  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
14831  CHB_Dsb.pack(side=LEFT)
14832  CHB_Dsb.delete(0,"end")
14833  CHB_Dsb.insert(0,0.5)
14834  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
14835  CHB_Dlab.pack(side=LEFT)
14836  CHB_DPosEntry = Entry(frameD, width=5)
14837  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
14838  CHB_DPosEntry.bind('<Key>', onTextKey)
14839  CHB_DPosEntry.pack(side=LEFT)
14840  CHB_DPosEntry.delete(0,"end")
14841  CHB_DPosEntry.insert(0,2.5)
14842  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
14843  CHB_Dofflab.pack(side=LEFT)
14844  frameE = Frame(frameM)
14845  frameE.pack(side=TOP)
14846  MuxEnb = IntVar(0)
14847  MuxSync = IntVar(0)
14848  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
14849  muxenab.pack(side=LEFT)
14850  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
14851  SyncButton.pack(side=LEFT)
14852  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
14853  dismissbutton.pack(side=LEFT)
14854  frameF = Frame(frameM)
14855  frameF.pack(side=TOP)
14856  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
14857  dmx.pack(side=LEFT)
14858  # Gray out main Channel B controls
14859  CHBlab.config(style="SGray.TButton")
14860  CHBofflab.config(style="SGray.TButton")
14861 #
14863  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
14864  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab
14865 
14866  if DualMuxMode.get() == 1:
14867  AWGAIOMode.set(1) # force awg A split I/O mode
14868  AWGBIOMode.set(1) # force awg A split I/O mode
14869  ShowC1_V.set(0) # force A voltage trace off
14870  CHB_Clab.config(text="CA-C V/Div")
14871  CHB_Dlab.config(text="CA-D V/Div")
14872  CHB_Cofflab.config(text="CA-C Pos")
14873  CHB_Dofflab.config(text="CA-D Pos")
14874  BAWGEnab() # update AWG settings
14875  # Gray out main Channel A controls
14876  CHAlab.config(style="SGray.TButton")
14877  CHAofflab.config(style="SGray.TButton")
14878  else:
14879  ShowC1_V.set(1) # force A voltage trace on
14880  CHB_Clab.config(text="CB-C V/Div")
14881  CHB_Dlab.config(text="CB-D V/Div")
14882  CHB_Cofflab.config(text="CB-C Pos")
14883  CHB_Dofflab.config(text="CB-D Pos")
14884  # Reset main Channel A control colors
14885  CHAlab.config(style="Rtrace1.TButton")
14886  CHAofflab.config(style="Rtrace1.TButton")
14887 #
14889  global MuxSync, hipulseimg, lowpulseimg, SyncButton
14890 
14891  if MuxSync.get() == 0:
14892  SyncButton.config(image=hipulseimg)
14893  else:
14894  SyncButton.config(image=lowpulseimg)
14895 
14897  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
14898 
14899  MuxScreenStatus.set(0)
14900  awgsync.config(state=NORMAL)
14901  # Reset main Channel B control colors
14902  CHBlab.config(style="Rtrace2.TButton")
14903  CHBofflab.config(style="Rtrace2.TButton")
14904  CHAlab.config(style="Rtrace1.TButton")
14905  CHAofflab.config(style="Rtrace1.TButton")
14906  muxwindow.destroy()
14907 #
14908 def BodeCaresize(event):
14909  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
14910 
14911  CANVASwidthBP = event.width - 4
14912  CANVASheightBP = event.height - 4
14913  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
14914  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
14915  UpdateBodeAll()
14916 #
14918  global FStepSync, DevOne
14919 
14920  if FStepSync.get() == 0:
14921  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
14922  elif FStepSync.get() == 1:
14923  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
14924  elif FStepSync.get() == 2:
14925  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
14926 #
14928  global FSweepSync, DevOne
14929 
14930  if FSweepSync.get() == 0:
14931  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
14932  elif FSweepSync.get() == 1:
14933  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
14934  elif FSweepSync.get() == 2:
14935  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
14936 #
14938  global BDSweepFile, FileSweepFreq, FileSweepAmpl
14939 
14940  if BDSweepFile.get() > 0:
14941  # Read values from CVS file
14942  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
14943  try:
14944  CSVFile = open(filename)
14945  csv_f = csv.reader(CSVFile)
14946  FileSweepFreq = []
14947  FileSweepAmpl = []
14948  for row in csv_f:
14949  try:
14950  FileSweepFreq.append(float(row[0]))
14951  FileSweepAmpl.append(float(row[1]))
14952  except:
14953  print( 'skipping non-numeric row')
14954  FileSweepFreq = numpy.array(FileSweepFreq)
14955  FileSweepAmpl = numpy.array(FileSweepAmpl)
14956  MaxAmpl = numpy.amax(FileSweepAmpl)
14957  NormAmpl = MaxAmpl
14958  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
14959  if (s == None): # If Cancel pressed, then None
14960  return()
14961  try: # Error if for example no numeric characters or OK pressed without input (s = "")
14962  v = int(s)
14963  except:
14964  s = "error"
14965 
14966  if s != "error":
14967  NormAmpl = MaxAmpl - v
14968  else:
14969  NormAmpl = MaxAmpl
14970  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
14971  CSVFile.close()
14972  StopBodeEntry.delete(0,"end")
14973  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
14974  StartBodeEntry.delete(0,"end")
14975  StartBodeEntry.insert(0,FileSweepFreq[0])
14976  SweepStepBodeEntry.delete(0,"end")
14977  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
14978  except:
14979  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
14980 #
14981 # ========== Make Bode Plot Window =============
14983  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
14984  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
14985  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
14986  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
14987  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
14988  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
14989  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
14990  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
14991  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
14992 
14993  if BodeScreenStatus.get() == 0:
14994  BodeScreenStatus.set(1)
14995  BodeDisp.set(1)
14996  BodeCheckBox()
14997  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
14998  CANVASheightBP = GRHBP + 80 # The ode canvas height
14999  CutDC.set(1) # set to remove DC
15000  AWGAMode.set(0) # Set AWG A to SVMI
15001  AWGAShape.set(1) # Set Shape to Sine
15002  AWGBMode.set(2) # Set AWG B to Hi-Z
15003  bodewindow = Toplevel()
15004  bodewindow.title("Bode Plotter " + SWRev + RevDate)
15005  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
15006  frame2bp = Frame(bodewindow, borderwidth=5, relief=RIDGE)
15007  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
15008 
15009  frame2b = Frame(bodewindow, borderwidth=5, relief=RIDGE)
15010  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
15011 
15012  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
15013  Bodeca.bind('<Configure>', BodeCaresize)
15014  Bodeca.bind('<1>', onCanvasBodeLeftClick)
15015  Bodeca.bind('<3>', onCanvasBodeRightClick)
15016  Bodeca.bind("<Up>", onCanvasUpArrow)
15017  Bodeca.bind("<Down>", onCanvasDownArrow)
15018  Bodeca.bind("<Left>", onCanvasLeftArrow)
15019  Bodeca.bind("<Right>", onCanvasRightArrow)
15020  Bodeca.bind("<space>", onCanvasSpaceBar)
15021  Bodeca.bind("1", onCanvasBdOne)
15022  Bodeca.bind("2", onCanvasBdTwo)
15023  Bodeca.bind("3", onCanvasBdThree)
15024  Bodeca.bind("4", onCanvasBdFour)
15025  Bodeca.bind("5", onCanvasBdFive)
15026  Bodeca.bind("6", onCanvasBdSix)
15027  Bodeca.bind("7", onCanvasBdSeven)
15028  Bodeca.bind("8", onCanvasBdEight)
15029  Bodeca.bind("9", onCanvasBdNine)
15030  Bodeca.bind("0", onCanvasBdZero)
15031  Bodeca.bind("f", onCanvasShowBPcur)
15032  Bodeca.bind("d", onCanvasShowBdBcur)
15033  Bodeca.bind("h", onCanvasShowPdBcur)
15034  Bodeca.bind("s", onCanvasBdSnap)
15035  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
15036 
15037  # right side drop down menu buttons
15038  dropmenu = Frame( frame2bp )
15039  dropmenu.pack(side=TOP)
15040  # File menu
15041  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15042  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
15043  BodeFilemenu["menu"] = BodeFilemenu.menu
15044  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
15045  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
15046  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
15047  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
15048  BodeFilemenu.pack(side=LEFT, anchor=W)
15049  #
15050  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15051  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
15052  BodeOptionmenu["menu"] = BodeOptionmenu.menu
15053  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15054  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
15055  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15056  BodeOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceBP)
15057  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
15058  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
15059  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
15060  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
15061  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
15062  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
15063  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
15064  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
15065  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
15066  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
15067  BodeOptionmenu.pack(side=LEFT, anchor=W)
15068  #
15069  RUNframe = Frame( frame2bp )
15070  RUNframe.pack(side=TOP)
15071  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
15072  sbode.pack(side=LEFT)
15073  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
15074  rbode.pack(side=LEFT)
15075  #
15076  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
15077  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
15078  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
15079  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15080  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15081  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15082  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15083  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15084  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15085  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15086  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
15087  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
15088  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
15089  BodeFFTwindmenu.pack(side=TOP)
15090  #
15091  tracemenu = Frame( frame2bp )
15092  tracemenu.pack(side=TOP)
15093  # Curves menu
15094  # Show channels menu
15095  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
15096  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
15097  BodeShowmenu["menu"] = BodeShowmenu.menu
15098  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
15099  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
15100  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
15101  BodeShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowCA_VdB, command=UpdateBodeAll)
15102  BodeShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowCB_VdB, command=UpdateBodeAll)
15103  BodeShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowCA_P, command=UpdateBodeAll)
15104  BodeShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowCB_P, command=UpdateBodeAll)
15105  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
15106  BodeShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathBP, value=0, command=UpdateBodeAll)
15107  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathBP, value=1, command=UpdateBodeAll)
15108  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathBP, value=2, command=UpdateBodeAll)
15109  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
15110  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
15111  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
15112  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
15113  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
15114  BodeShowmenu.menu.add_separator()
15115  BodeShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowCA_RdB, command=UpdateBodeAll)
15116  BodeShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowCB_RdB, command=UpdateBodeAll)
15117  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
15118  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
15119  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
15120  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
15121  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
15122  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
15123  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
15124  BodeShowmenu.pack(side=LEFT, anchor=W)
15125  #
15126  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
15127  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
15128  BodeMarkmenu["menu"] = BodeMarkmenu.menu
15129  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
15130  BodeMarkmenu.menu.add_checkbutton(label='Marker [5]', variable=ShowMarkerBP, command=UpdateBodeAll)
15131  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
15132  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
15133  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
15134  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowBdBCur, value=1)
15135  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowBdBCur, value=2)
15136  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowBPCur)
15137  BodeMarkmenu.pack(side=LEFT, anchor=W)
15138  #
15139  # Horz Scale
15140  HScaleBP = IntVar(0)
15141  HScaleBP.set(1)
15142  HzScale = Frame( frame2bp )
15143  HzScale.pack(side=TOP)
15144  rb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
15145  rb1.pack(side=LEFT)
15146  rb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
15147  rb2.pack(side=LEFT)
15148 
15149  DBrange = Frame( frame2bp )
15150  DBrange.pack(side=TOP)
15151  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
15152  bd3.pack(side=LEFT)
15153  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
15154  bd4.pack(side=LEFT)
15155 
15156  LVBrange = Frame( frame2bp )
15157  LVBrange.pack(side=TOP)
15158  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
15159  bd5.pack(side=LEFT)
15160  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
15161  bd6.pack(side=LEFT)
15162 
15163  LVSrange = Frame( frame2bp )
15164  LVSrange.pack(side=TOP)
15165  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
15166  bd7.pack(side=LEFT)
15167  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
15168  bd8.pack(side=LEFT)
15169 
15170  PhaseCenter = Frame( frame2bp )
15171  PhaseCenter.pack(side=TOP)
15172  PhCenlab = Label(PhaseCenter, text="Center Phase on")
15173  PhCenlab.pack(side=LEFT)
15174  PhCenBodeEntry = Entry(PhaseCenter, width=5)
15175  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
15176  PhCenBodeEntry.bind('<Key>', onTextKey)
15177  PhCenBodeEntry.pack(side=LEFT)
15178  PhCenBodeEntry.delete(0,"end")
15179  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
15180  #
15181  ImpedCenter = Frame( frame2bp )
15182  ImpedCenter.pack(side=TOP)
15183  ImCenlab = Label(ImpedCenter, text="Center Imped on")
15184  ImCenlab.pack(side=LEFT)
15185  ImCenBodeEntry = Entry(ImpedCenter, width=5)
15186  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
15187  ImCenBodeEntry.bind('<Key>', onTextKey)
15188  ImCenBodeEntry.pack(side=LEFT)
15189  ImCenBodeEntry.delete(0,"end")
15190  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
15191  # sweep generator mode menu buttons
15192  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
15193  FSweepmenu.pack(side=TOP)
15194 
15195  Frange1 = Frame( frame2bp )
15196  Frange1.pack(side=TOP)
15197  startfreqlab = Label(Frange1, text="Startfreq")
15198  startfreqlab.pack(side=LEFT)
15199  StartBodeEntry = Entry(Frange1, width=5)
15200  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
15201  StartBodeEntry.bind('<Key>', onTextKey)
15202  StartBodeEntry.pack(side=LEFT)
15203  StartBodeEntry.delete(0,"end")
15204  StartBodeEntry.insert(0,10)
15205 
15206  Frange2 = Frame( frame2bp )
15207  Frange2.pack(side=TOP)
15208  stopfreqlab = Label(Frange2, text="Stopfreq")
15209  stopfreqlab.pack(side=LEFT)
15210  StopBodeEntry = Entry(Frange2, width=5)
15211  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
15212  StopBodeEntry.bind('<Key>', onTextKey)
15213  StopBodeEntry.pack(side=LEFT)
15214  StopBodeEntry.delete(0,"end")
15215  StopBodeEntry.insert(0,10000)
15216 
15217  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
15218  sgrb1.pack(side=TOP)
15219  Frange4 = Frame( frame2bp )
15220  Frange4.pack(side=TOP)
15221  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
15222  sgrb2.pack(side=LEFT)
15223  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
15224  sgrb3.pack(side=LEFT)
15225  if MinigenScreenStatus.get() > 0:
15226  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
15227  sgrb1.pack(side=TOP)
15228  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
15229  ffcb.pack(side=TOP)
15230  Frange3 = Frame( frame2bp )
15231  Frange3.pack(side=TOP)
15232  sweepsteplab = Label(Frange3, text="Sweep Steps")
15233  sweepsteplab.pack(side=LEFT)
15234  SweepStepBodeEntry = Entry(Frange3, width=5)
15235  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
15236  SweepStepBodeEntry.bind('<Key>', onTextKey)
15237  SweepStepBodeEntry.pack(side=LEFT)
15238  SweepStepBodeEntry.delete(0,"end")
15239  SweepStepBodeEntry.insert(0,100)
15240 
15241  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
15242  sgrb5.pack(side=TOP)
15243  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
15244  sgrb6.pack(side=TOP)
15245  Plotsframe = Frame( frame2bp )
15246  Plotsframe.pack(side=TOP)
15247  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
15248  nyquistplotbutton.pack(side=LEFT)
15249  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
15250  nicholsplotbutton.pack(side=LEFT)
15251  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
15252  bodismiss1button.pack(side=TOP)
15253 
15254  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
15255  ADI2.pack(side=TOP)
15256  if ShowBallonHelp > 0:
15257  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
15258  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
15259  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
15260  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
15261  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
15262  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
15263  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
15264  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
15265  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
15266 #
15268  global bodewindow, BodeScreenStatus, ca, FSweepMode
15269 
15270  BodeScreenStatus.set(0)
15271  FSweepMode.set(0)
15272  BodeDisp.set(0)
15273  BodeCheckBox()
15274  bodewindow.destroy()
15275  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15276 #
15277 def FreqCaresize(event):
15278  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
15279 
15280  CANVASwidthF = event.width - 4
15281  CANVASheightF = event.height - 4
15282  GRWF = CANVASwidthF - (2 * X0LF) # new grid width
15283  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
15284  UpdateFreqAll()
15285 #
15286 # ================ Make spectrum sub window ==========================
15288  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
15289  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp
15290  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA
15291  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate
15292  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
15293  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
15294 
15295  if SpectrumScreenStatus.get() == 0:
15296  SpectrumScreenStatus.set(1)
15297  FreqDisp.set(1)
15298  FreqCheckBox()
15299  CANVASwidthF = GRWF + 2 * X0LF # The spectrum canvas width
15300  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
15301  freqwindow = Toplevel()
15302  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
15303  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
15304  frame2fr = Frame(freqwindow, borderwidth=5, relief=RIDGE)
15305  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
15306 
15307  frame2f = Frame(freqwindow, borderwidth=5, relief=RIDGE)
15308  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
15309 
15310  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
15311  Freqca.bind('<Configure>', FreqCaresize)
15312  Freqca.bind('<1>', onCanvasFreqLeftClick)
15313  Freqca.bind('<3>', onCanvasFreqRightClick)
15314  Freqca.bind("<Up>", onCanvasUpArrow)
15315  Freqca.bind("<Down>", onCanvasDownArrow)
15316  Freqca.bind("<Left>", onCanvasLeftArrow)
15317  Freqca.bind("<Right>", onCanvasRightArrow)
15318  Freqca.bind("<space>", onCanvasSpaceBar)
15319  Freqca.bind("1", onCanvasSAOne)
15320  Freqca.bind("2", onCanvasSATwo)
15321  Freqca.bind("3", onCanvasSAThree)
15322  Freqca.bind("4", onCanvasSAFour)
15323  Freqca.bind("5", onCanvasSAFive)
15324  Freqca.bind("6", onCanvasSASix)
15325  Freqca.bind("7", onCanvasSASeven)
15326  Freqca.bind("8", onCanvasSAEight)
15327  Freqca.bind("9", onCanvasSANine)
15328  Freqca.bind("0", onCanvasSAZero)
15329  Freqca.bind("a", onCanvasSAAverage)
15330  Freqca.bind("n", onCanvasSANormal)
15331  Freqca.bind("p", onCanvasSAPeak)
15332  Freqca.bind("r", onCanvasSAReset)
15333  Freqca.bind("f", onCanvasShowFcur)
15334  Freqca.bind("d", onCanvasShowdBcur)
15335  Freqca.bind("h", onCanvasShowPcur)
15336  Freqca.bind("s", onCanvasSASnap)
15337  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
15338  # right side drop down menu buttons
15339  dropmenu = Frame( frame2fr )
15340  dropmenu.pack(side=TOP)
15341  # File menu
15342  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15343  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
15344  SAFilemenu["menu"] = SAFilemenu.menu
15345  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
15346  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
15347  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
15348  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
15349  SAFilemenu.pack(side=LEFT, anchor=W)
15350  #
15351  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15352  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
15353  SAOptionmenu["menu"] = SAOptionmenu.menu
15354  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15355  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15356  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
15357  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15358  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
15359  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
15360  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
15361  SAOptionmenu.pack(side=LEFT, anchor=W)
15362  #
15363  RUNframe = Frame( frame2fr )
15364  RUNframe.pack(side=TOP)
15365  sb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
15366  sb.pack(side=LEFT)
15367  rb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
15368  rb.pack(side=LEFT)
15369  #
15370  Modeframe = Frame( frame2fr )
15371  Modeframe.pack(side=TOP)
15372  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
15373  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
15374  Modemenu["menu"] = Modemenu.menu
15375  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
15376  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
15377  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
15378  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
15379  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
15380  Modemenu.pack(side=LEFT)
15381  #
15382  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
15383  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
15384  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
15385  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15386  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15387  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15388  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15389  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15390  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15391  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15392  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
15393  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
15394  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
15395  SAFFTwindmenu.pack(side=LEFT)
15396  #
15397  SamplesMenu = Frame( frame2fr )
15398  SamplesMenu.pack(side=TOP)
15399  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
15400  bless.pack(side=LEFT)
15401  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
15402  bmore.pack(side=LEFT)
15403  #
15404  # Show channels menu
15405  ShowC1_VdB = IntVar(0) # curves to display variables
15406  ShowC1_P = IntVar(0)
15407  ShowC2_VdB = IntVar(0)
15408  ShowC2_P = IntVar(0)
15409  ShowMarker = IntVar(0)
15410  ShowRA_VdB = IntVar(0)
15411  ShowRA_P = IntVar(0)
15412  ShowRB_VdB = IntVar(0)
15413  ShowRB_P = IntVar(0)
15414  ShowMathSA = IntVar(0)
15415  ShowRMath = IntVar(0)
15416  #
15417  SAShowmenu = Menubutton(frame2fr, text="Curves", style="W7.TButton")
15418  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
15419  SAShowmenu["menu"] = SAShowmenu.menu
15420  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
15421  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
15422  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
15423  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
15424  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
15425  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
15426  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
15427  SAShowmenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
15428  SAShowmenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
15429  SAShowmenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
15430  SAShowmenu.menu.add_separator()
15431  SAShowmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
15432  SAShowmenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
15433  SAShowmenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
15434  SAShowmenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
15435  SAShowmenu.menu.add_separator()
15436  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
15437  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
15438  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
15439  SAShowmenu.menu.add_separator()
15440  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
15441  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
15442  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
15443  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
15444  SAShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMath, command=UpdateFreqAll)
15445  SAShowmenu.pack(side=TOP)
15446  # HScale
15447  Frange1 = Frame( frame2fr )
15448  Frange1.pack(side=TOP)
15449  startfreqlab = Label(Frange1, text="Startfreq")
15450  startfreqlab.pack(side=LEFT)
15451  StartFreqEntry = Entry(Frange1, width=5)
15452  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
15453  StartFreqEntry.bind('<Key>', onTextKey)
15454  StartFreqEntry.pack(side=LEFT)
15455  StartFreqEntry.delete(0,"end")
15456  StartFreqEntry.insert(0,10)
15457 
15458  Frange2 = Frame( frame2fr )
15459  Frange2.pack(side=TOP)
15460  stopfreqlab = Label(Frange2, text="Stopfreq")
15461  stopfreqlab.pack(side=LEFT)
15462  StopFreqEntry = Entry(Frange2, width=7)
15463  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
15464  StopFreqEntry.bind('<Key>', onTextKey)
15465  StopFreqEntry.pack(side=LEFT)
15466  StopFreqEntry.delete(0,"end")
15467  StopFreqEntry.insert(0,10000)
15468 
15469  HScale = IntVar(0)
15470  HzScale = Frame( frame2fr )
15471  HzScale.pack(side=TOP)
15472  rb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
15473  rb1.pack(side=LEFT)
15474  rb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
15475  rb2.pack(side=LEFT)
15476  #
15477  PhaseCenter = Frame( frame2fr )
15478  PhaseCenter.pack(side=TOP)
15479  PhCenlab = Label(PhaseCenter, text="Center Phase on")
15480  PhCenlab.pack(side=LEFT)
15481  PhCenFreqEntry = Entry(PhaseCenter, width=5)
15482  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
15483  PhCenFreqEntry.bind('<Key>', onTextKey)
15484  PhCenFreqEntry.pack(side=LEFT)
15485  PhCenFreqEntry.delete(0,"end")
15486  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
15487  #
15488  DBrange = Frame( frame2fr )
15489  DBrange.pack(side=TOP)
15490  b3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
15491  b3.pack(side=LEFT)
15492  b4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
15493  b4.pack(side=LEFT)
15494 
15495  LVBrange = Frame( frame2fr )
15496  LVBrange.pack(side=TOP)
15497  b5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
15498  b5.pack(side=LEFT)
15499  b6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
15500  b6.pack(side=LEFT)
15501 
15502  LVSrange = Frame( frame2fr )
15503  LVSrange.pack(side=TOP)
15504  b7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
15505  b7.pack(side=LEFT)
15506  b8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
15507  b8.pack(side=LEFT)
15508 
15509  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
15510  sadismiss1button.pack(side=TOP)
15511 
15512  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
15513  ADI2.pack(side=TOP)
15514  if ShowBallonHelp > 0:
15515  sb_tip = CreateToolTip(sb, 'Stop acquiring data')
15516  rb_tip = CreateToolTip(rb, 'Start acquiring data')
15517  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
15518  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
15519  b3_tip = CreateToolTip(b3, 'Increase number of dB/Div')
15520  b4_tip = CreateToolTip(b4, 'Decrease number of dB/Div')
15521  b5_tip = CreateToolTip(b5, 'Increase Ref Level by 10 dB')
15522  b6_tip = CreateToolTip(b6, 'Decrease Ref Level by 10 dB')
15523  b7_tip = CreateToolTip(b7, 'Increase Ref Level by 1 dB')
15524  b8_tip = CreateToolTip(b8, 'Decrease Ref Level by 1 dB')
15525  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
15526 
15528  global freqwindow, SpectrumScreenStatus, ca
15529 
15530  SpectrumScreenStatus.set(0)
15531  FreqDisp.set(0)
15532  FreqCheckBox()
15533  freqwindow.destroy()
15534  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15535 #
15536 def XYcaresize(event):
15537  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
15538  global YminXY, YmaxXY, XminXY, XmaxXY
15539 
15540  CANVASwidthXY = event.width - 4
15541  CANVASheightXY = event.height - 4
15542  GRWXY = CANVASwidthXY - int(2.25 * FontSize) - X0LXY # 18 new grid width
15543  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
15544  YminXY = Y0TXY # Minimum position of time grid (top)
15545  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
15546  XminXY = X0LXY # Minimum position of time grid (left)
15547  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
15548  UpdateXYAll()
15549 #
15550 # ================ Make spectrum sub window ==========================
15552  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, Ysignal, ShowRXY
15553  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
15554  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
15555  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
15556  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
15557 
15558  if XYScreenStatus.get() == 0:
15559  XYScreenStatus.set(1)
15560  XYDisp.set(1)
15561  XYCheckBox()
15562  YminXY = Y0TXY # Minimum position of XY grid (top)
15563  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
15564  XminXY = X0LXY # Minimum position of XY grid (left)
15565  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
15566  CANVASwidthXY = GRWXY + 18 + X0LXY # The XY canvas width
15567  CANVASheightXY = GRHXY + 80 # The XY canvas height
15568  xywindow = Toplevel()
15569  xywindow.title("X-Y Plot " + SWRev + RevDate)
15570  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
15571  frame2xyr = Frame(xywindow, borderwidth=5, relief=RIDGE)
15572  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
15573 
15574  frame2xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15575  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
15576 
15577  frame3xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15578  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
15579 
15580  frame4xy = Frame(xywindow, borderwidth=5, relief=RIDGE)
15581  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
15582 
15583  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
15584  XYca.bind('<Configure>', XYcaresize)
15585  XYca.bind('<1>', onCanvasXYLeftClick)
15586  XYca.bind('<3>', onCanvasXYRightClick)
15587  XYca.bind("<Motion>",onCanvasMouse_xy)
15588  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
15589  XYca.bind("<Up>", onCanvasUpArrow)
15590  XYca.bind("<Down>", onCanvasDownArrow)
15591  XYca.bind("<Left>", onCanvasLeftArrow)
15592  XYca.bind("<Right>", onCanvasRightArrow)
15593  XYca.bind("<space>", onCanvasSpaceBar)
15594  XYca.bind("a", onCanvasAverage)
15595  XYca.pack(side=TOP, fill=BOTH, expand=YES)
15596  #
15597  RUNframe = Frame( frame2xyr )
15598  RUNframe.pack(side=TOP)
15599  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
15600  sbxy.pack(side=LEFT)
15601  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
15602  rbxy.pack(side=LEFT)
15603  # Open Math trace menu
15604  mathbt = Button(frame2xyr, text="Math", style="W4.TButton", command = NewEnterMathControls)
15605  mathbt.pack(side=TOP) #, anchor=W)
15606  # Disply mode menu
15607  # X - Y mode signal select
15608  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
15609  AxisLabX.pack(side=TOP)
15610  chaxmenu = Frame( frame2xyr )
15611  chaxmenu.pack(side=TOP)
15612  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
15613  rbx2.pack(side=LEFT, anchor=W)
15614  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
15615  rbx3.pack(side=LEFT, anchor=W)
15616  chbxmenu = Frame( frame2xyr )
15617  chbxmenu.pack(side=TOP)
15618  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
15619  rbx4.pack(side=LEFT, anchor=W)
15620  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
15621  rbx5.pack(side=LEFT, anchor=W)
15622  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
15623  rbx7.pack(side=TOP)
15624  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
15625  rbx8.pack(side=TOP)
15626  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
15627  rbx6.pack(side=TOP)
15628  #
15629  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
15630  AxisLabY.pack(side=TOP)
15631  chaymenu = Frame( frame2xyr )
15632  chaymenu.pack(side=TOP)
15633  rby2 = Radiobutton(chaymenu, text='CA-V', variable=Ysignal, value=1, command=UpdateXYTrace)
15634  rby2.pack(side=LEFT, anchor=W)
15635  rby3 = Radiobutton(chaymenu, text='CA-I', variable=Ysignal, value=2, command=UpdateXYTrace)
15636  rby3.pack(side=LEFT, anchor=W)
15637  chbymenu = Frame( frame2xyr )
15638  chbymenu.pack(side=TOP)
15639  rby4 = Radiobutton(chbymenu, text='CB-V', variable=Ysignal, value=3, command=UpdateXYTrace)
15640  rby4.pack(side=LEFT, anchor=W)
15641  rby5 = Radiobutton(chbymenu, text='CB-I', variable=Ysignal, value=4, command=UpdateXYTrace)
15642  rby5.pack(side=LEFT, anchor=W)
15643  rby6 = Radiobutton(frame2xyr, text='Math', variable=Ysignal, value=5, command=UpdateXYTrace)
15644  rby6.pack(side=TOP)
15645  # show cursor menu buttons
15646  cursormenu = Frame( frame2xyr )
15647  cursormenu.pack(side=TOP)
15648  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
15649  cb1.pack(side=LEFT, anchor=W)
15650  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
15651  cb2.pack(side=LEFT, anchor=W)
15652  cb3 = Checkbutton(frame2xyr, text='RX-Y', variable=ShowRXY, command=UpdateXYTrace)
15653  cb3.pack(side=TOP)
15654  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
15655  cb4.pack(side=TOP)
15656  #
15657  snapbutton = Button(frame2xyr, style="W8.TButton", text="SnapShot", command=BSnapShot)
15658  snapbutton.pack(side=TOP)
15659  savebutton = Button(frame2xyr, style="W11.TButton", text="Save Screen", command=BSaveScreenXY)
15660  savebutton.pack(side=TOP)
15661  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
15662  dismissxybutton.pack(side=TOP)
15663  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
15664  ADI1xy.pack(side=TOP)
15665 
15666  # Bottom Buttons
15667  MarkerXYScale = IntVar(0)
15668  MarkerXYScale.set(1)
15669  # Voltage channel A
15670  CHAsbxy = Spinbox(frame3xy, width=4, values=CHvpdiv)
15671  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15672  CHAsbxy.pack(side=LEFT)
15673  CHAsbxy.delete(0,"end")
15674  CHAsbxy.insert(0,0.5)
15675  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
15676  CHAxylab.pack(side=LEFT)
15677 
15678  CHAVPosEntryxy = Entry(frame3xy, width=5)
15679  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
15680  CHAVPosEntryxy.bind('<Key>', onTextKey)
15681  CHAVPosEntryxy.pack(side=LEFT)
15682  CHAVPosEntryxy.delete(0,"end")
15683  CHAVPosEntryxy.insert(0,2.5)
15684  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
15685  CHAofflabxy.pack(side=LEFT)
15686  # Current channel A
15687  CHAIsbxy = Spinbox(frame3xy, width=4, values=CHipdiv)
15688  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15689  CHAIsbxy.pack(side=LEFT)
15690  CHAIsbxy.delete(0,"end")
15691  CHAIsbxy.insert(0,50.0)
15692  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
15693  CHAIlabxy.pack(side=LEFT)
15694 
15695  CHAIPosEntryxy = Entry(frame3xy, width=5)
15696  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
15697  CHAIPosEntryxy.bind('<Key>', onTextKey)
15698  CHAIPosEntryxy.pack(side=LEFT)
15699  CHAIPosEntryxy.delete(0,"end")
15700  CHAIPosEntryxy.insert(0,0.0)
15701  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
15702  CHAIofflabxy.pack(side=LEFT)
15703  # Voltage channel B
15704  CHBsbxy = Spinbox(frame4xy, width=4, values=CHvpdiv)
15705  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15706  CHBsbxy.pack(side=LEFT)
15707  CHBsbxy.delete(0,"end")
15708  CHBsbxy.insert(0,0.5)
15709  #
15710  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
15711  CHBxylab.pack(side=LEFT)
15712 
15713  CHBVPosEntryxy = Entry(frame4xy, width=5)
15714  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
15715  CHBVPosEntryxy.bind('<Key>', onTextKey)
15716  CHBVPosEntryxy.pack(side=LEFT)
15717  CHBVPosEntryxy.delete(0,"end")
15718  CHBVPosEntryxy.insert(0,2.5)
15719  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
15720  CHBofflabxy.pack(side=LEFT)
15721  # Current channel B
15722  CHBIsbxy = Spinbox(frame4xy, width=4, values=CHipdiv) #
15723  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
15724  CHBIsbxy.pack(side=LEFT)
15725  CHBIsbxy.delete(0,"end")
15726  CHBIsbxy.insert(0,50.0)
15727  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
15728  CHBIlabxy.pack(side=LEFT)
15729 
15730  CHBIPosEntryxy = Entry(frame4xy, width=5)
15731  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
15732  CHBIPosEntryxy.bind('<Key>', onTextKey)
15733  CHBIPosEntryxy.pack(side=LEFT)
15734  CHBIPosEntryxy.delete(0,"end")
15735  CHBIPosEntryxy.insert(0,0.0)
15736  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
15737  CHBIofflabxy.pack(side=LEFT)
15738  #
15739  if ShowBallonHelp > 0:
15740  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
15741  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
15742  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
15743  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
15744  math_tip = CreateToolTip(mathbt, 'Open Math window')
15745  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
15746  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
15747  snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
15748  savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
15749  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
15750  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
15751  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
15752  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
15753  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
15754  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
15755  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
15756 
15758  global xywindow, XYScreenStatus, ca, XYDisp
15759 
15760  XYScreenStatus.set(0)
15761  XYDisp.set(0)
15762  XYCheckBox()
15763  xywindow.destroy()
15764  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
15765 #
15766 # Optional Calibration procedure routine
15767 #
15769  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
15770  global discontloop, contloop, session, AWGSync, SWRev
15771  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
15772  # setup cal results window
15773  if FWRevOne < 2.06: # Check firmware revision level > 2.06
15774  showwarning("WARNING","Out of date Firmware Revision!")
15775  return
15776  calwindow = Toplevel()
15777  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
15778  # display wigets
15779  prlab = Label(calwindow, text="Channel Gain / Offset calibration")
15780  prlab.grid(row=0, column=0, columnspan=2, sticky=W)
15781  labelA0 = Label(calwindow, style="A12B.TLabel")
15782  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
15783  labelA0.config(text = "CA gnd Volts")
15784  labelAMax = Label(calwindow, style="A12B.TLabel")
15785  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
15786  labelAMax.config(text = "CA 584 Volts")
15787  labelAMin = Label(calwindow, style="A12B.TLabel")
15788  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
15789  labelAMin.config(text = "CA 5V Src I ")
15790  labelB0 = Label(calwindow, style="A12B.TLabel")
15791  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
15792  labelB0.config(text = "CA gnd Volts")
15793  labelBMax = Label(calwindow, style="A12B.TLabel")
15794  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
15795  labelBMax.config(text = "CB 584 Volts")
15796  labelBMin = Label(calwindow, style="A12B.TLabel")
15797  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
15798  labelBMin.config(text = "CB 5V Src I ")
15799  labelAB = Label(calwindow, style="A12B.TLabel")
15800  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
15801  labelAB.config(text = "CA 0V Src I")
15802  labelBA = Label(calwindow, style="A12B.TLabel")
15803  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
15804  labelBA.config(text = "CA 0V Src I")
15805  labelSIA0 = Label(calwindow, style="A12B.TLabel")
15806  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
15807  labelSIA0.config(text = "CA 2.5 Src 0 I")
15808  labelSIA = Label(calwindow, style="A12B.TLabel")
15809  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
15810  labelSIA.config(text = "CA 50 Src 100 ")
15811  labelSIAN = Label(calwindow, style="A12B.TLabel")
15812  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
15813  labelSIAN.config(text = "CA 50 Src -45")
15814  labelSIB0 = Label(calwindow, style="A12B.TLabel")
15815  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
15816  labelSIB0.config(text = "CB 2.5 Src 0 I")
15817  labelSIB = Label(calwindow, style="A12B.TLabel")
15818  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
15819  labelSIB.config(text = "CB 50 Src 100 ")
15820  labelSIBN = Label(calwindow, style="A12B.TLabel")
15821  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
15822  labelSIBN.config(text = "CB 50 Src -45")
15823  # set to default mux and dac settings
15824  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
15825  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
15826  AWGSync.set(1)
15827  BAWGSync()
15828  if session.continuous:
15829  print( "ending session")
15830  session.end()
15831  # Setup ADALM1000
15832  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
15833  #print(devx.calibration)
15834  try:
15835  devx.write_calibration("calib_default.txt")
15836  #print "wrote calib_default.txt"
15837  except:
15838  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
15839  devx.write_calibration(filename)
15840  #print(devx.calibration)
15841  #
15842  devidstr = DevID[17:31]
15843  filename = "calib" + devidstr + ".txt"
15844  if os.path.isfile(filename):
15845  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
15846  devx.write_calibration(filename)
15847  #print "wrote old ", filename
15848  calwindow.destroy()
15849  return
15850  else:
15851  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
15852  donothing()
15853  else:
15854  calwindow.destroy()
15855  return
15856  #
15857  CalFile = open(filename, "w")
15858  #
15859  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15860  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15861  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
15862  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
15863  ADsignal1 = [] # Ain signal array channel
15864  ADsignal1 = devx.get_samples(1010)
15865  # Pause whie user connects external voltage reference AD584
15866  BadData = 1
15867  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
15868  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
15869  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
15870  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
15871  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
15872  try:
15873  AD584act = float(RequestVRef)*1.0
15874  except:
15875  AD584act = 3.3
15876  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
15877  while (BadData): # loop till good reading
15878  # Get A and B AD584 data
15879  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15880  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15881  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
15882  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
15883  # get_samples returns a list of values for voltage [0] and current [1]
15884  for index in range(1000): # calculate average
15885  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
15886  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
15887 
15888  CHA584Raw = CHA584Raw / 1000.0 # calculate average
15889  CHB584Raw = CHB584Raw / 1000.0 # calculate average
15890  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
15891  labelAMax.config(text = VString) # change displayed value
15892  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
15893  labelBMax.config(text = VString) # change displayed value
15894  Lower = AD584act - 0.3
15895  Upper = AD584act + 0.3
15896  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
15897  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
15898  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15899  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15900  contloop = 0
15901  discontloop = 1
15902  calwindow.destroy()
15903  return
15904  else:
15905  BadData = 0
15906  #
15907  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
15908  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
15909  # Get A GND and B GND data
15910  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
15911  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
15912  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
15913  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
15914  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15915  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15916  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
15917  # get_samples returns a list of values for voltage [0] and current [1]
15918  for index in range(1000): # calculate average
15919  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
15920  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
15921  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
15922  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
15923 
15924  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
15925  CHAI0gRaw = CHAI0gRaw / 1000.0
15926  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
15927  CHBI0gRaw = CHBI0gRaw / 1000.0
15928  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
15929  labelA0.config(text = VString) # change displayed value
15930  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
15931  labelB0.config(text = VString) # change displayed value
15932  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
15933  # Get A and B data for internal 2.5 rail
15934  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
15935  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
15936  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
15937  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
15938  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
15939  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
15940  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
15941  # get_samples returns a list of values for voltage [0] and current [1]
15942  for index in range(1000): # calculate average
15943  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
15944  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
15945  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
15946  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
15947 
15948  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
15949  CHAI02p5Raw = CHAI02p5Raw / 1000.0
15950  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
15951  CHBI02p5Raw = CHBI02p5Raw / 1000.0
15952  # Get A force 0V and B force 0V data
15953  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
15954  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
15955  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
15956  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
15957  CHA.mode = Mode.SVMI
15958  CHA.constant(0.0)
15959  CHB.mode = Mode.SVMI
15960  CHB.constant(0.0)
15961  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
15962  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
15963  # get_samples returns a list of values for voltage [0] and current [1]
15964  for index in range(1000): # calculate average
15965  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
15966  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
15967  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
15968  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
15969 
15970  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
15971  CHAI0F0Raw = CHAI0F0Raw / 1000.0
15972  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
15973  CHBI0F0Raw = CHBI0F0Raw / 1000.0
15974  # Get A force 2.5V and B force 2.5V data
15975  CHA.mode = Mode.SVMI
15976  CHA.constant(4.5)
15977  CHB.mode = Mode.SVMI
15978  CHB.constant(4.5)
15979  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
15980  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
15981  # get_samples returns a list of values for voltage [0] and current [1]
15982  for index in range(1000): # calculate average
15983  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
15984  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
15985  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
15986  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
15987 
15988  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
15989  CHAI0F25Raw = CHAI0F25Raw / 1000.0
15990  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
15991  CHBI0F25Raw = CHBI0F25Raw / 1000.0
15992  #
15993  # Get A and B measure current data for int 50 res to gnd at 5V
15994  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
15995  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
15996  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
15997  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
15998  CHA.mode = Mode.SVMI
15999  CHA.constant(5.0)
16000  CHB.mode = Mode.SVMI
16001  CHB.constant(5.0)
16002  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16003  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
16004  for index in range(1000): # calculate average
16005  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16006  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16007  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16008  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16009 
16010  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
16011  CHAISr5vRaw = CHAISr5vRaw / 1000.0
16012  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
16013  CHBISr5vRaw = CHBISr5vRaw / 1000.0
16014  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
16015  labelAMin.config(text = VString) # change displayed value
16016  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
16017  labelBMin.config(text = VString) # change displayed value
16018  # Get A and B measure current data for int 50 res to 2.5 V at 0V
16019  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16020  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16021  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16022  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16023  CHA.mode = Mode.SVMI
16024  CHA.constant(0.001)
16025  CHB.mode = Mode.SVMI
16026  CHB.constant(0.001)
16027  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16028  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
16029  for index in range(1000): # calculate average
16030  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16031  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16032  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16033  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16034 
16035  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
16036  CHAISr0vRaw = CHAISr0vRaw / 1000.0
16037  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
16038  CHBISr0vRaw = CHBISr0vRaw / 1000.0
16039  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
16040  labelAB.config(text = VString) # change displayed value
16041  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
16042  labelBA.config(text = VString) # change displayed value
16043 
16044  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
16045  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16046  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16047  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16048  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16049  CHA.mode = Mode.SIMV
16050  CHA.constant(0.0)
16051  CHB.mode = Mode.SIMV
16052  CHB.constant(0.0)
16053  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16054  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
16055  for index in range(1000): # calculate average
16056  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16057  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16058  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
16059  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
16060 
16061  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
16062  CHAISr0iRaw = CHAISr0iRaw / 1000.0
16063  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
16064  CHBISr0iRaw = CHBISr0iRaw / 1000.0
16065  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
16066  labelSIA0.config(text = VString) # change displayed value
16067  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
16068  labelSIB0.config(text = VString) # change displayed value
16069  #
16070  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
16071  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16072  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16073  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16074  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16075  CHA.mode = Mode.SIMV
16076  CHA.constant(0.045)
16077  CHB.mode = Mode.SIMV
16078  CHB.constant(0.045)
16079  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16080  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
16081  for index in range(1000): # calculate average
16082  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16083  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16084  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16085  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16086 
16087  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
16088  CHAISr100Raw = CHAISr100Raw / 1000.0
16089  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
16090  CHBISr100Raw = CHBISr100Raw / 1000.0
16091  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
16092  labelSIA.config(text = VString) # change displayed value
16093  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
16094  labelSIB.config(text = VString) # change displayed value
16095  #
16096  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
16097  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
16098  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
16099  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
16100  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16101  CHA.mode = Mode.SIMV
16102  CHA.constant(-0.045)
16103  CHB.mode = Mode.SIMV
16104  CHB.constant(-0.045)
16105  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
16106  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
16107  for index in range(1000): # calculate average
16108  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
16109  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
16110  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
16111  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
16112 
16113  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
16114  CHAISrN45Raw = CHAISrN45Raw / 1000.0
16115  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
16116  CHBISrN45Raw = CHBISrN45Raw / 1000.0
16117  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
16118  labelSIAN.config(text = VString) # change displayed value
16119  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
16120  labelSIBN.config(text = VString) # change displayed value
16121  # return all switches to open
16122  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
16123  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
16124  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
16125  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
16126  # Caculate voltage gain errors
16127  #
16128  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
16129  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
16130  #
16131  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
16132  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
16133  #
16134  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
16135  # print "calculated fixed 2.5 from CHA ", CHA2p5
16136  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
16137  # print "calculated fixed 2.5 from CHB ", CHB2p5
16138  #
16139  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
16140  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
16141  #
16142  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
16143  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
16144  #
16145  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
16146  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
16147  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
16148  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
16149  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
16150  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
16151  #
16152  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
16153  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
16154  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
16155  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
16156  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
16157  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
16158  # Write cal factors to file
16159  #
16160  CalFile.write('# Channel A, measure V\n')
16161  CalFile.write('</>\n')
16162  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
16163  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
16164  CalFile.write('<>\n')
16165  CalFile.write('\n')
16166  #
16167  CalFile.write('# Channel A, measure I\n')
16168  CalFile.write('</>\n')
16169  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
16170  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
16171  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
16172  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
16173  CalFile.write('<>\n')
16174  CalFile.write('\n')
16175  #
16176  CalFile.write('# Channel A, source V\n')
16177  CalFile.write('</>\n')
16178  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
16179  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
16180  CalFile.write('<>\n')
16181  CalFile.write('\n')
16182  #
16183  CalFile.write('# Channel A, source I\n')
16184  CalFile.write('</>\n')
16185  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
16186  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
16187  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
16188  CalFile.write('<>\n')
16189  CalFile.write('\n')
16190  #
16191  CalFile.write('# Channel B, measure V\n')
16192  CalFile.write('</>\n')
16193  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
16194  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
16195  CalFile.write('<>\n')
16196  CalFile.write('\n')
16197  #
16198  CalFile.write('# Channel B, measure I\n')
16199  CalFile.write('</>\n')
16200  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
16201  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
16202  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
16203  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
16204  CalFile.write('<>\n')
16205  CalFile.write('\n')
16206  #
16207  CalFile.write('# Channel B, source V\n')
16208  CalFile.write('</>\n')
16209  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
16210  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
16211  CalFile.write('<>\n')
16212  CalFile.write('\n')
16213  #
16214  CalFile.write('# Channel B source I\n')
16215  CalFile.write('</>\n')
16216  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
16217  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
16218  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
16219  CalFile.write('<>\n')
16220  #
16221  CalFile.close()
16222  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
16223  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
16224  devx.write_calibration(filename)
16225  #print "wrote new " , filename
16226  #
16227  # session.end()
16228  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
16229  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
16230  contloop = 0
16231  discontloop = 1
16232  # session.cancel()
16233  calwindow.destroy()
16234 #
16236  global cal, DevID, devx
16237 
16238  devidstr = DevID[17:31]
16239  filename = "calib" + devidstr + "test.txt"
16240  if os.path.isfile(filename):
16241  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
16242  return
16243  else:
16244  if askyesno("Continue?", "Continure with save calibration file?"): #, parent=calwindow):
16245  donothing()
16246  else:
16247  calwindow.destroy()
16248  return
16249  #
16250  CalFile = open(filename, "w")
16251  #
16252  # Write cal factors to file
16253  # [0]
16254  CalFile.write('# Channel A, measure V\n')
16255  CalFile.write('</>\n')
16256  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
16257  CHAgp = (5.0/cal[0][1])+cal[0][0]
16258  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16259  CalFile.write('<>\n')
16260  CalFile.write('\n')
16261  # [1]
16262  CalFile.write('# Channel A, measure I\n')
16263  CalFile.write('</>\n')
16264  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
16265  CHAgp = (0.1/cal[0][1])+cal[1][0]
16266  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16267  CHAgn = (-0.1/cal[0][2])+cal[1][0]
16268  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
16269  CalFile.write('<>\n')
16270  CalFile.write('\n')
16271  # [2]
16272  CalFile.write('# Channel A, source V\n')
16273  CalFile.write('</>\n')
16274  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
16275  CHAgp = (5.0/cal[2][1])+cal[2][0]
16276  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16277  CalFile.write('<>\n')
16278  CalFile.write('\n')
16279  # [3]
16280  CalFile.write('# Channel A, source I\n')
16281  CalFile.write('</>\n')
16282  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
16283  CHAgp = (0.1/cal[3][1])+cal[3][0]
16284  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16285  CHAgn = (-0.1/cal[3][2])+cal[3][0]
16286  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16287  CalFile.write('<>\n')
16288  CalFile.write('\n')
16289  # [4]
16290  CalFile.write('# Channel B, measure V\n')
16291  CalFile.write('</>\n')
16292  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
16293  CHAgp = (5.0/cal[4][1])+cal[4][0]
16294  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16295  CalFile.write('<>\n')
16296  CalFile.write('\n')
16297  # [5]
16298  CalFile.write('# Channel B, measure I\n')
16299  CalFile.write('</>\n')
16300  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
16301  CHAgp = (0.1/cal[5][1])+cal[5][0]
16302  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16303  CHAgn = (-0.1/cal[5][2])+cal[5][0]
16304  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16305  CalFile.write('<>\n')
16306  CalFile.write('\n')
16307  # [6]
16308  CalFile.write('# Channel B, source V\n')
16309  CalFile.write('</>\n')
16310  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
16311  CHAgp = (5.0/cal[6][1])+cal[6][0]
16312  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16313  CalFile.write('<>\n')
16314  CalFile.write('\n')
16315  # [7]
16316  CalFile.write('# Channel B source I\n')
16317  CalFile.write('</>\n')
16318  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
16319  CHAgp = (0.1/cal[7][1])+cal[7][0]
16320  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
16321  CHAgn = (-0.1/cal[7][2])+cal[7][0]
16322  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
16323  CalFile.write('<>\n')
16324  #
16325  CalFile.close()
16326 
16328 def SPIShiftOut(DValue):
16329  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
16330 
16331  binstr = bin(DValue)
16332  binlen = len(binstr)
16333  datastr = binstr[2:binlen]
16334  datalen = len(datastr)
16335  if datalen < 16:
16336  datastr = str.rjust(datastr , 16 , '0')
16337  datalen = len(datastr)
16338  i = 1
16339  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
16340  while i < datalen+1:
16341  # sending 0x50 = set to 0, 0x51 = set to 1
16342  D1code = 0x50 + int(datastr[i-1])
16343  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
16344  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
16345  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
16346  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
16347  i = i + 1
16348  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
16349 #
16350 def onFminScroll(event):
16351  onTextScroll(event)
16352  SetAD9833(event)
16353 
16354 def onMulXScroll(event):
16355  onTextScroll(event)
16356  SetAD9833(event)
16357 
16358 def SetAD9833(temp):
16359  global FminEntry, HtMulEntry, MinigenFout, MinigenMode # , Fclk, Fout
16360  global Two28, mclk, EnableHSsampling, MinigenScreenStatus
16361 
16362  if MinigenScreenStatus.get() == 0:
16363  return
16364  #
16365  MinigenMode.set(40)
16366  #
16367  try:
16368  MulX = float(eval(HtMulEntry.get()))
16369  if MulX < 1:
16370  MulX = 1
16371  except:
16372  if EnableHSsampling > 0:
16373  HtMulEntry.delete(0,END)
16374  HtMulEntry.insert(0, MulX)
16375  try:
16376  FminE = float(eval(FminEntry.get()))*1000
16377  except:
16378  if EnableHSsampling > 0:
16379  FminEntry.delete(0,END)
16380  FminEntry.insert(0, FminE/1000)
16381  if MulX == 1:
16382  Fmin = FminE
16383  else:
16384  Fmin = FminE - (FminE/MulX)
16385  #
16386  MinigenFout.delete(0,"end")
16387  MinigenFout.insert(0,Fmin)
16388  BSendMG()
16389 
16391 def BSendMG():
16392  global MinigenFclk, MinigenFout, MinigenMode
16393  global Two28, SCLKPort, SDATAPort, SLATCHPort
16394 
16395  DValue = 8192 + MinigenMode.get()
16396  SPIShiftOut(DValue)
16397  try:
16398  fout = float(eval(MinigenFout.get()))
16399  except:
16400  MinigenFout.delete(0,"end")
16401  MinigenFout.insert(0,100)
16402  try:
16403  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
16404  except:
16405  MingenFclk.delete(0,"end")
16406  MinigenFclk.insert(0,16)
16407  Freg = int((fout*Two28)/mclk)
16408  Foutstr = bin(Freg)
16409  Foutlen = len(Foutstr)
16410  datastr = Foutstr[2:Foutlen]
16411  datalen = len(datastr)
16412  if datalen < 28:
16413  datastr = str.rjust(datastr , 28 , '0')
16414  datalen = len(datastr)
16415  Fmsb = '0b01' + datastr[0:14]
16416  Flsb = '0b01' + datastr[14:]
16417  FValue = int(eval(Flsb))
16418  SPIShiftOut(FValue)
16419  FValue = int(eval(Fmsb))
16420  SPIShiftOut(FValue)
16421 
16424  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
16425  global SCLKPort, SDATAPort, SLATCHPort
16426  global GenericSerialStatus
16427  global PIO_0, PIO_1, PIO_2, PIO_3
16428 
16429  if GenericSerialStatus.get() == 1:
16430  GenericSerialStatus.set(0)
16432  if MinigenScreenStatus.get() == 0:
16433  MinigenScreenStatus.set(1)
16434  minigenwindow = Toplevel()
16435  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
16436  minigenwindow.resizable(FALSE,FALSE)
16437  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
16438  #
16439  MinigenMode = IntVar(0)
16440  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
16441  mgb1.grid(row=1, column=0, sticky=W)
16442  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
16443  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
16444  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
16445  mgb3.grid(row=2, column=0, sticky=W)
16446  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
16447  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
16448  f0lab = Label(minigenwindow, text="Mclk in MHz")
16449  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
16450  MinigenFclk = Entry(minigenwindow, width=5)
16451  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
16452  MinigenFclk.delete(0,"end")
16453  MinigenFclk.insert(0,16)
16454  f1lab = Label(minigenwindow, text="Output Freq")
16455  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
16456  MinigenFout = Entry(minigenwindow, width=8)
16457  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
16458  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
16459  MinigenFout.delete(0,"end")
16460  MinigenFout.insert(0,100)
16461  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
16462  bsn1.grid(row=5, column=0, sticky=W, pady=4)
16463  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
16464  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
16465  #
16466  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
16467  label3.grid(row=6, column=0, sticky=W)
16468  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
16469  sclk1.grid(row=6, column=1, sticky=W)
16470  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
16471  sclk2.grid(row=6, column=2, sticky=W)
16472  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
16473  sclk3.grid(row=6, column=3, sticky=W)
16474  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
16475  sclk4.grid(row=6, column=4, sticky=W)
16476  #
16477  label4 = Label(minigenwindow,text="SData PI/O Port ")
16478  label4.grid(row=7, column=0, sticky=W)
16479  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
16480  sdat1.grid(row=7, column=1, sticky=W)
16481  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
16482  sdat2.grid(row=7, column=2, sticky=W)
16483  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
16484  sdat3.grid(row=7, column=3, sticky=W)
16485  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
16486  sdat4.grid(row=7, column=4, sticky=W)
16487  #
16488  label5 = Label(minigenwindow,text="FSync PI/O Port ")
16489  label5.grid(row=8, column=0, sticky=W)
16490  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
16491  slth1.grid(row=8, column=1, sticky=W)
16492  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
16493  slth2.grid(row=8, column=2, sticky=W)
16494  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
16495  slth3.grid(row=8, column=3, sticky=W)
16496  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
16497  slth4.grid(row=8, column=4, sticky=W)
16498  #
16499 
16502  global minigenwindow, MinigenScreenStatus
16503 
16504  MinigenScreenStatus.set(0)
16505  minigenwindow.destroy()
16506 #
16507 def onMiniGenScroll(event):
16508  global ETSStatus, ETSDisp
16509 
16510  onTextScroll(event)
16511  BSendMG()
16512 
16514 def DA1ShiftOut(D1Value, D2Value):
16515  global devx
16516  global PIO_0, PIO_1, PIO_2, PIO_3
16517 
16518  binstr = bin(D1Value)
16519  binlen = len(binstr)
16520  data1str = binstr[2:binlen]
16521  datalen = len(data1str)
16522  if datalen < 16:
16523  data1str = str.rjust(data1str , 16 , '0')
16524  datalen = len(data1str)
16525  #
16526  binstr = bin(D2Value)
16527  binlen = len(binstr)
16528  data2str = binstr[2:binlen]
16529  datalen = len(data2str)
16530  if datalen < 16:
16531  data2str = str.rjust(data2str , 16 , '0')
16532  datalen = len(data2str)
16533  # sync --> PIO 0
16534  # D0 --> PIO 1
16535  # D1 --> PIO 2
16536  # SCLK --> PIO 3
16537  i = 1
16538 #
16539  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
16540  while i < datalen+1:
16541  # sending 0x50 = set to 0, 0x51 = set to 1
16542  D1code = 0x50 + int(data1str[i-1])
16543  D2code = 0x50 + int(data2str[i-1])
16544  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
16545  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
16546  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
16547  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
16548  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
16549  i = i + 1
16550  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
16551  #
16552 def BSendDA1():
16553  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
16554 
16555  try:
16556  RefValue = float(eval(REFEntry.get()))
16557  except:
16558  RefValue = 3.3
16559  try:
16560  D1Value = float(eval(DAC1Entry.get()))
16561  except:
16562  D1Value = 0.0129
16563  D1Code = int((D1Value/RefValue)*255)
16564  if D1Code > 255:
16565  D1Code = 255
16566  D1Code = D1Code + 0x2000
16567  try:
16568  D2Value = float(eval(DAC2Entry.get()))
16569  except:
16570  D2Value = 0.0129
16571  D2Code = int((D2Value/RefValue)*255)
16572  if D2Code > 255:
16573  D2Code = 255
16574  D2Code = D2Code + 0x2400
16575  try:
16576  D3Value = float(eval(DAC3Entry.get()))
16577  except:
16578  D3Value = 0.0129
16579  D3Code = int((D3Value/RefValue)*255)
16580  if D3Code > 255:
16581  D3Code = 255
16582  D3Code = D3Code + 0x2000
16583  try:
16584  D4Value = float(eval(DAC4Entry.get()))
16585  except:
16586  D4Value = 0.0129
16587  D4Code = int((D4Value/RefValue)*255)
16588  if D4Code > 255:
16589  D4Code = 255
16590  D4Code = D4Code + 0x2400
16591  #
16592  DA1ShiftOut(D1Code, D3Code)
16593  DA1ShiftOut(D2Code, D4Code)
16594 
16597  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
16598  global REFEntry, RevDate, SWRev
16599 
16600  if DA1ScreenStatus.get() == 0:
16601  DA1ScreenStatus.set(1)
16602  da1window = Toplevel()
16603  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
16604  da1window.resizable(FALSE,FALSE)
16605  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
16606 #
16607  d1lab = Label(da1window, text="DAC A1 output")
16608  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
16609  DAC1Entry = Entry(da1window, width=5)
16610  DAC1Entry.grid(row=0, column=1, sticky=W)
16611  DAC1Entry.delete(0,"end")
16612  DAC1Entry.insert(0,0)
16613  d2lab = Label(da1window, text="DAC B1 output")
16614  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
16615  DAC2Entry = Entry(da1window, width=5)
16616  DAC2Entry.grid(row=1, column=1, sticky=W)
16617  DAC2Entry.delete(0,"end")
16618  DAC2Entry.insert(0,0)
16619 
16620  d3lab = Label(da1window, text="DAC A2 output")
16621  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
16622  DAC3Entry = Entry(da1window, width=5)
16623  DAC3Entry.grid(row=2, column=1, sticky=W)
16624  DAC3Entry.delete(0,"end")
16625  DAC3Entry.insert(0,0)
16626 
16627  d4lab = Label(da1window, text="DAC B2 output")
16628  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
16629  DAC4Entry = Entry(da1window, width=5)
16630  DAC4Entry.grid(row=3, column=1, sticky=W)
16631  DAC4Entry.delete(0,"end")
16632  DAC4Entry.insert(0,0)
16633 
16634  d5lab = Label(da1window, text="Reference V")
16635  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
16636  REFEntry = Entry(da1window, width=5)
16637  REFEntry.grid(row=4, column=1, sticky=W)
16638  REFEntry.delete(0,"end")
16639  REFEntry.insert(0,3.3)
16640 
16641  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
16642  bsn1.grid(row=5, column=0, sticky=W)
16643  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
16644  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
16645 
16648  global da1window, DA1ScreenStatus
16649 
16650  DA1ScreenStatus.set(0)
16651  da1window.destroy()
16652 
16653 def DigPotShiftOut(DValue):
16654  global devx, SingleDualPot
16655  global PIO_0, PIO_1, PIO_2, PIO_3
16656 
16657  binstr = bin(DValue)
16658  binlen = len(binstr)
16659  datastr = binstr[2:binlen]
16660  datalen = len(datastr)
16661  if SingleDualPot.get() == 0: # send 10 bits of data
16662  if datalen < 10:
16663  datastr = str.rjust(datastr , 10 , '0')
16664  datalen = len(datastr)
16665  if SingleDualPot.get() == 1: # send 8 bits of data
16666  if datalen < 8:
16667  datastr = str.rjust(datastr , 8 , '0')
16668  datalen = len(datastr)
16669  if SingleDualPot.get() == 2: # send 8 bits of data
16670  if datalen < 8:
16671  datastr = str.rjust(datastr , 8 , '0')
16672  datalen = len(datastr)
16673  i = 1
16674  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
16675  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
16676  while i < datalen+1:
16677  # CS --> PIO 0
16678  # D0 --> PIO 1
16679  # D1 --> PIO 2
16680  # SCLK --> PIO 3
16681  D1code = 0x50 + int(datastr[i-1])
16682  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
16683  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
16684  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
16685  i = i + 1
16686  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
16687  #
16688 def DigPotSend(Temp):
16689  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
16690  global SingleDualPot
16691 
16692  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
16693  NumTaps = 255
16694  if SingleDualPot.get() == 2:
16695  NumTaps = 63
16696  try:
16697  DValue1 = DigPot1.get()
16698  if DValue1 > NumTaps:
16699  DValue1 = NumTaps
16700  except:
16701  DValue1 = 0
16702  try:
16703  DValue2 = DigPot2.get()
16704  if DValue2 > NumTaps:
16705  DValue2 = NumTaps
16706  except:
16707  DValue2 = 0
16708  try:
16709  DValue3 = DigPot3.get()
16710  if DValue3 > NumTaps:
16711  DValue3 = NumTaps
16712  except:
16713  DValue3 = 0
16714  try:
16715  DValue4 = DigPot4.get()
16716  if DValue4 > NumTaps:
16717  DValue4 = NumTaps
16718  except:
16719  DValue4 = 0
16720  if SendPot1.get() > 0:
16721  DigPotShiftOut(DValue1)
16722  if SendPot2.get() > 0:
16723  DigPotShiftOut(DValue2+NumTaps+1)
16724  if SendPot3.get() > 0:
16725  DigPotShiftOut(DValue3+2*(NumTaps+1))
16726  if SendPot4.get() > 0:
16727  DigPotShiftOut(DValue4+3*(NumTaps+1))
16728 
16730  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
16731 
16732  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
16733  DPotlabel.config(text="Enter number from 0 to 255")
16734  DigPot1.config(from_=0, to=255, length=256)
16735  DigPot2.config(from_=0, to=255, length=256)
16736  DigPot3.config(from_=0, to=255, length=256)
16737  DigPot4.config(from_=0, to=255, length=256)
16738  if SingleDualPot.get() == 2:
16739  DPotlabel.config(text="Enter number from 0 to 63")
16740  DigPot1.config(from_=0, to=63, length=64)
16741  DigPot2.config(from_=0, to=63, length=64)
16742  DigPot3.config(from_=0, to=63, length=64)
16743  DigPot4.config(from_=0, to=63, length=64)
16744 
16747  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
16748  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
16749  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
16750 
16751  if DigPotScreenStatus.get() == 0:
16752  DigPotScreenStatus.set(1)
16753  digpotwindow = Toplevel()
16754  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
16755  digpotwindow.resizable(FALSE,FALSE)
16756  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
16757  #
16758  SendPot1 = IntVar(0)
16759  SendPot1.set(1)
16760  SendPot2 = IntVar(0)
16761  SendPot2.set(1)
16762  SendPot3 = IntVar(0)
16763  SendPot3.set(0)
16764  SendPot4 = IntVar(0)
16765  SendPot4.set(0)
16766  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
16767  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
16768 
16769  SingleDualPot = IntVar(0)
16770  SingleDualPot.set(0)
16771  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
16772  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
16773  CompMenu["menu"] = CompMenu.menu
16774  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
16775  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
16776  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
16777  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
16778  lab1 = Checkbutton(digpotwindow,text="Pot 1", pady=0, variable=SendPot1)
16779  lab1.grid(row=2, column=0, sticky=W)
16780  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16781  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
16782  lab2 = Checkbutton(digpotwindow,text="Pot 2", pady=0, variable=SendPot2)
16783  lab2.grid(row=4, column=0, sticky=W)
16784  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16785  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
16786  lab3 = Checkbutton(digpotwindow,text="Pot 3", pady=0, variable=SendPot3)
16787  lab3.grid(row=6, column=0, sticky=W)
16788  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16789  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
16790  lab4 = Checkbutton(digpotwindow,text="Pot 4", pady=0, variable=SendPot4)
16791  lab4.grid(row=8, column=0, sticky=W)
16792  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
16793  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
16794  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
16795  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
16796 
16798  global digpotwindow, DigPotScreenStatus
16799 
16800  DigPotScreenStatus.set(0)
16801  digpotwindow.destroy()
16802 
16803 def BSendGS():
16804  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
16805  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
16806 
16807  if AD5626SerialStatus.get() == 0:
16808  try:
16809  DValue = int(eval(DataBitsEntry.get()))
16810  if DValue < 0:
16811  DValue = 0
16812  except:
16813  DValue = 0
16814  try:
16815  NumBits = int(NumBitsEntry.get())
16816  if NumBits < 1:
16817  NumBits = 1
16818  except:
16819  NumBits = 8
16820  else:
16821  try:
16822  DValue = int(eval(AD5626Entry.get())*1000)
16823  if DValue < 0:
16824  DValue = 0
16825  AD5626Entry.delete(0,"end")
16826  AD5626Entry.insert(0,'0.000')
16827  if DValue > 4095:
16828  DValue = 4095
16829  AD5626Entry.delete(0,"end")
16830  AD5626Entry.insert(0,DValue/1000.0)
16831  except:
16832  DValue = 0
16833  AD5626Entry.delete(0,"end")
16834  AD5626Entry.insert(0,'0.000')
16835  NumBits = 12
16836  # print DValue
16837  binstr = bin(DValue)
16838  binlen = len(binstr)
16839  datastr = binstr[2:binlen]
16840  datalen = len(datastr)
16841  if datalen < NumBits:
16842  datastr = str.rjust(datastr , NumBits , '0')
16843  datalen = len(datastr)
16844  if SLatchPhase.get() == 0:
16845  LatchInt = 0x50
16846  LatchEnd = 0x51
16847  else:
16848  LatchInt = 0x51
16849  LatchEnd = 0x50
16850  if AD5626SerialStatus.get() > 0:
16851  LatchInt = 0x51
16852  LatchEnd = 0x50
16853  if SClockPhase.get() == 0:
16854  ClockInt = 0x50
16855  ClockEnd = 0x51
16856  else:
16857  ClockInt = 0x51
16858  ClockEnd = 0x50
16859  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
16860  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
16861  i = 1
16862  while i < datalen+1:
16863  if SerDirection.get() == 1: # for MSB first
16864  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
16865  else:
16866  D1code = 0x50 + int(datastr[i-1]) # for LSB first
16867  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
16868  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
16869  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
16870  i = i + 1
16871  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
16872  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
16873  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
16874  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
16875 
16878  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
16879  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
16880  global PIO_0, PIO_1, PIO_2, PIO_3
16881 
16882  if GenericSerialStatus.get() == 1:
16883  GenericSerialStatus.set(0)
16885  if AD5626SerialStatus.get() == 0:
16886  AD5626SerialStatus.set(1)
16887  ad5626window = Toplevel()
16888  ad5626window.title("AD5626 Output " + SWRev + RevDate)
16889  ad5626window.resizable(FALSE,FALSE)
16890  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
16891 #
16892  SLatchPhase = IntVar(0)
16893  SLatchPhase.set(0)
16894  SClockPhase = IntVar(0)
16895  SClockPhase.set(1)
16896  SerDirection = IntVar(0)
16897  SerDirection.set(0)
16898  #
16899  label2 = Label(ad5626window,text="Enter Output Volts")
16900  label2.grid(row=1, column=0, columnspan=1, sticky=W)
16901  AD5626Entry = Entry(ad5626window, width=10)
16902  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
16903  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
16904  AD5626Entry.delete(0,"end")
16905  AD5626Entry.insert(0,'0.000')
16906  #
16907  label3 = Label(ad5626window,text="SCLK PI/O Port ")
16908  label3.grid(row=2, column=0, columnspan=1, sticky=W)
16909  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
16910  sclk1.grid(row=2, column=1, sticky=W)
16911  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
16912  sclk2.grid(row=2, column=2, sticky=W)
16913  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
16914  sclk3.grid(row=2, column=3, sticky=W)
16915  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
16916  sclk4.grid(row=2, column=4, sticky=W)
16917  #
16918  label4 = Label(ad5626window,text="SData PI/O Port ")
16919  label4.grid(row=3, column=0, columnspan=1, sticky=W)
16920  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
16921  sdat1.grid(row=3, column=1, sticky=W)
16922  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
16923  sdat2.grid(row=3, column=2, sticky=W)
16924  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
16925  sdat3.grid(row=3, column=3, sticky=W)
16926  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
16927  sdat4.grid(row=3, column=4, sticky=W)
16928  #
16929  label5 = Label(ad5626window,text="Latch PI/O Port ")
16930  label5.grid(row=4, column=0, columnspan=1, sticky=W)
16931  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
16932  slth1.grid(row=4, column=1, sticky=W)
16933  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
16934  slth2.grid(row=4, column=2, sticky=W)
16935  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
16936  slth3.grid(row=4, column=3, sticky=W)
16937  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
16938  slth4.grid(row=4, column=4, sticky=W)
16939  #
16940  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
16941  bsn1.grid(row=5, column=0, sticky=W)
16942  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
16943  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
16944 #
16945 def onAD5626Scroll(event):
16946  onTextScroll(event)
16947  BSendGS()
16948 
16950  global ad5626window, AD5626SerialStatus
16951 
16952  AD5626SerialStatus.set(0)
16953  ad5626window.destroy()
16954 
16956  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
16957  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
16958  global PIO_0, PIO_1, PIO_2, PIO_3
16959 
16960  if GenericSerialStatus.get() == 0:
16961  GenericSerialStatus.set(1)
16962  serialwindow = Toplevel()
16963  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
16964  serialwindow.resizable(FALSE,FALSE)
16965  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
16966  #
16967  SCLKPort = IntVar(0)
16968  SCLKPort.set(PIO_2)
16969  SDATAPort = IntVar(0)
16970  SDATAPort.set(PIO_1)
16971  SLATCHPort = IntVar(0)
16972  SLATCHPort.set(PIO_0)
16973  SLatchPhase = IntVar(0)
16974  SClockPhase = IntVar(0)
16975  SerDirection = IntVar(0)
16976  label = Label(serialwindow,text="Enter number of Bits")
16977  label.grid(row=1, column=0, columnspan=2, sticky=W)
16978  NumBitsEntry = Entry(serialwindow, width=3)
16979  NumBitsEntry.grid(row=1, column=2, sticky=W)
16980  NumBitsEntry.delete(0,"end")
16981  NumBitsEntry.insert(0,8)
16982  #
16983  label2 = Label(serialwindow,text="Enter Data Word")
16984  label2.grid(row=2, column=0, columnspan=1, sticky=W)
16985  DataBitsEntry = Entry(serialwindow, width=10)
16986  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
16987  DataBitsEntry.delete(0,"end")
16988  DataBitsEntry.insert(0,0)
16989  #
16990  label3 = Label(serialwindow,text="SCLK PI/O Port ")
16991  label3.grid(row=3, column=0, columnspan=1, sticky=W)
16992  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
16993  sclk1.grid(row=3, column=1, sticky=W)
16994  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
16995  sclk2.grid(row=3, column=2, sticky=W)
16996  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
16997  sclk3.grid(row=3, column=3, sticky=W)
16998  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
16999  sclk4.grid(row=3, column=4, sticky=W)
17000  #
17001  label4 = Label(serialwindow,text="SData PI/O Port ")
17002  label4.grid(row=4, column=0, columnspan=1, sticky=W)
17003  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
17004  sdat1.grid(row=4, column=1, sticky=W)
17005  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
17006  sdat2.grid(row=4, column=2, sticky=W)
17007  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
17008  sdat3.grid(row=4, column=3, sticky=W)
17009  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
17010  sdat4.grid(row=4, column=4, sticky=W)
17011  #
17012  label5 = Label(serialwindow,text="Latch PI/O Port ")
17013  label5.grid(row=5, column=0, columnspan=1, sticky=W)
17014  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
17015  slth1.grid(row=5, column=1, sticky=W)
17016  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
17017  slth2.grid(row=5, column=2, sticky=W)
17018  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
17019  slth3.grid(row=5, column=3, sticky=W)
17020  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
17021  slth4.grid(row=5, column=4, sticky=W)
17022  #
17023  label6 = Label(serialwindow,text="Latch Phase ")
17024  label6.grid(row=6, column=0, columnspan=1, sticky=W)
17025  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
17026  sph1.grid(row=6, column=1, sticky=W)
17027  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
17028  sph2.grid(row=6, column=2, sticky=W)
17029  #
17030  label7 = Label(serialwindow,text="Clock Phase ")
17031  label7.grid(row=7, column=0, columnspan=1, sticky=W)
17032  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
17033  sph7.grid(row=7, column=1, sticky=W)
17034  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
17035  sph8.grid(row=7, column=2, sticky=W)
17036  #
17037  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
17038  sdir1.grid(row=8, column=0, sticky=W)
17039  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
17040  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
17041 
17042  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
17043  bsn1.grid(row=9, column=0, sticky=W)
17044  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
17045  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
17046 
17048  global serialwindow, GenericSerialStatus
17049 
17050  GenericSerialStatus.set(0)
17051  serialwindow.destroy()
17052 
17055  global digfltwindow, DigFiltStatus, RevDate, SWRev
17056  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
17057  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
17058 
17059  if DigFiltStatus.get() == 0:
17060  DigFiltStatus.set(1)
17061  digfltwindow = Toplevel()
17062  digfltwindow.title("Digital Filter " + SWRev + RevDate)
17063  digfltwindow.resizable(FALSE,FALSE)
17064  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
17065  #
17066  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
17067  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
17068  frame2.pack(side=LEFT, expand=1, fill=X)
17069  frame3.pack(side=LEFT, expand=1, fill=X)
17070  #
17071  digfilta = Frame( frame2 )
17072  digfilta.pack(side=TOP)
17073  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
17074  #titlab.grid(row=0, column=0, sticky=W)
17075  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
17076  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
17077  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
17078  lab3.grid(row=1, column=0, sticky=W)
17079  BCALenEntry = Entry(digfilta, width=3)
17080  BCALenEntry.bind("<Return>", onRetDigFiltA)
17081  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
17082  # BCALenEntry.bind('<Key>', onTextKey)
17083  BCALenEntry.grid(row=1, column=1, sticky=W)
17084  BCALenEntry.delete(0,"end")
17085  BCALenEntry.insert(0,2)
17086  bcalab = Label(digfilta, text="Length")
17087  bcalab.grid(row=1, column=2, sticky=W)
17088  DifFiltALength = Label(digfilta, text="Length = 0 ")
17089  DifFiltALength.grid(row=2, column=0, sticky=W)
17090  DifFiltAFile = Label(digfilta, text="File Name, none ")
17091  DifFiltAFile.grid(row=3, column=0, sticky=W)
17092  cald = Button(digfilta, text='Load CH A Filter Coef', command=BLoadDFiltA)
17093  cald.grid(row=4, column=0, columnspan=2, sticky=W)
17094  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
17095  camath.grid(row=5, column=0, columnspan=2, sticky=W)
17096  #
17097  digfiltb = Frame( frame3 )
17098  digfiltb.pack(side=TOP)
17099  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
17100  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
17101  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
17102  lab4.grid(row=1, column=0, sticky=W)
17103  BCBLenEntry = Entry(digfiltb, width=3)
17104  BCBLenEntry.bind("<Return>", onRetDigFiltB)
17105  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
17106  # BCALenEntry.bind('<Key>', onTextKey)
17107  BCBLenEntry.grid(row=1, column=1, sticky=W)
17108  BCBLenEntry.delete(0,"end")
17109  BCBLenEntry.insert(0,2)
17110  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
17111  DifFiltBLength.grid(row=2, column=0, sticky=W)
17112  DifFiltBFile = Label(digfiltb,text="File Name, none ")
17113  DifFiltBFile.grid(row=3, column=0, sticky=W)
17114  camath.grid(row=8, column=0, sticky=W)
17115  cbld = Button(digfiltb, text='Load CH B Filter Coef', command=BLoadDFiltB)
17116  cbld.grid(row=4, column=0, sticky=W)
17117  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
17118  cbmath.grid(row=5, column=0, sticky=W)
17119  dismissdfbutton = Button(digfiltb, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
17120  dismissdfbutton.grid(row=6, column=0, columnspan=1, sticky=W)
17121  #
17122 def onRetDigFiltA(event):
17123  BuildBoxCarA()
17124 
17125 def onDigFiltAScroll(event):
17126  onTextScroll(event)
17127  BuildBoxCarA()
17128 
17130  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
17131 
17132  if DigFiltABoxCar.get() == 0:
17133  return
17134 
17135  FLength = int(BCALenEntry.get())
17136  if FLength < 2:
17137  return
17138 
17139  DFiltACoef = [] # empty coef array
17140 
17141  for n in range(FLength):
17142  DFiltACoef.append(float(1.0/FLength))
17143 
17144  DFiltACoef = numpy.array(DFiltACoef)
17145  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17146 
17147 def onRetDigFiltB(event):
17148  BuildBoxCarB()
17149 
17150 def onDigFiltBScroll(event):
17151  onTextScroll(event)
17152  BuildBoxCarB()
17153 
17155  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
17156 
17157  if DigFiltBBoxCar.get() == 0:
17158  return
17159 
17160  FLength = int(BCBLenEntry.get())
17161  if FLength < 2:
17162  return
17163 
17164  DFiltBCoef = [] # empty coef array
17165 
17166  for n in range(FLength):
17167  DFiltBCoef.append(float(1.0/FLength))
17168 
17169  DFiltBCoef = numpy.array(DFiltBCoef)
17170  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17171 
17173  global digfltwindow, DigFiltStatus
17174 
17175  DigFiltStatus.set(0)
17176  digfltwindow.destroy()
17177 
17179  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
17180 
17181 # Read values from CVS file
17182  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
17183  try:
17184  CSVFile = open(filename)
17185  csv_f = csv.reader(CSVFile)
17186  except:
17187  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
17188  return
17189  DFiltACoef = []
17190 
17191  for row in csv_f:
17192  try:
17193  DFiltACoef.append(float(row[0]))
17194  except:
17195  print( 'skipping non-numeric row')
17196  DFiltACoef = numpy.array(DFiltACoef)
17197  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17198  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
17199  CSVFile.close()
17200 #
17202  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
17203 
17204  TempString = DigFilterAString
17205  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
17206  if (DigFilterAString == None): # If Cancel pressed, then None
17207  DigFilterAString = TempString
17208  return
17209  DFiltACoef = eval(DigFilterAString)
17210  DFiltACoef = numpy.array(DFiltACoef)
17211  coefsum = numpy.sum(DFiltACoef)
17212  DFiltACoef = DFiltACoef / coefsum
17213  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
17214  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
17215 
17217  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
17218 
17219 # Read values from CVS file
17220  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
17221  try:
17222  CSVFile = open(filename)
17223  csv_f = csv.reader(CSVFile)
17224  except:
17225  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
17226  return
17227  DFiltBCoef = []
17228 
17229  for row in csv_f:
17230  try:
17231  DFiltBCoef.append(float(row[0]))
17232  except:
17233  print( 'skipping non-numeric row')
17234  DFiltBCoef = numpy.array(DFiltBCoef)
17235  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17236  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
17237  CSVFile.close()
17238 #
17240  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
17241 
17242  TempString = DigFilterBString
17243  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
17244  if (DigFilterBString == None): # If Cancel pressed, then None
17245  DigFilterBString = TempString
17246  return
17247  DFiltBCoef = eval(DigFilterBString)
17248  DFiltBCoef = numpy.array(DFiltBCoef)
17249  coefsum = numpy.sum(DFiltBCoef)
17250  DFiltBCoef = DFiltBCoef / coefsum
17251  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
17252  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
17253 #
17255  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
17256 
17257  if CommandStatus.get() == 0:
17258  CommandStatus.set(1)
17259  commandwindow = Toplevel()
17260  commandwindow.title("Command Line " + SWRev + RevDate)
17261  commandwindow.resizable(FALSE,FALSE)
17262  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
17263  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
17264  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
17265  cl1 = Label(commandwindow,text="Last command:")
17266  cl1.grid(row=1, column=0, sticky=W)
17267  LastCommand = Label(commandwindow,text=" ")
17268  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
17269  ExecString = Entry(commandwindow, width=40)
17270  ExecString.bind("<Return>", RExecuteFromString)
17271  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
17272  ExecString.delete(0,"end")
17273  ExecString.insert(0,"global ; ")
17274  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
17275  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
17276  #
17277  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
17278  dismissclbutton.grid(row=4, column=1, sticky=W, pady=7)
17279 
17281  global commandwindow, CommandStatus
17282 
17283  CommandStatus.set(0)
17284  commandwindow.destroy()
17285 
17287 
17289 
17290 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
17291  global ExecString, LastCommand
17292 
17293  try:
17294  exec( ExecString.get() )
17295  LastCommand.config(text = ExecString.get() ) # change displayed last command
17296  except:
17297  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
17298  return()
17299 #
17300 def CAresize(event):
17301  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
17302 
17303  XOL = FontSize * 7
17304  CANVASwidth = event.width - 4
17305  CANVASheight = event.height - 4
17306  GRW = CANVASwidth - (2 * X0L) # new grid width
17307  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
17308  UpdateTimeAll()
17309 #
17311  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
17312  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
17313  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
17314  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
17315  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
17316  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
17317 
17318  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
17319  ChaValue1.config(text = ValueText)
17320  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
17321  ChaValue2.config(text = ValueText)
17322  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
17323  ChaValue3.config(text = ValueText)
17324  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
17325  ChaValue4.config(text = ValueText)
17326  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
17327  ChaValue5.config(text = ValueText)
17328  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
17329  ChaValue6.config(text = ValueText)
17330  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
17331  ChbValue1.config(text = ValueText)
17332  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
17333  ChbValue2.config(text = ValueText)
17334  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
17335  ChbValue3.config(text = ValueText)
17336  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
17337  ChbValue4.config(text = ValueText)
17338  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
17339  ChbValue5.config(text = ValueText)
17340  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
17341  ChbValue6.config(text = ValueText)
17342 #
17344  global measurewindow, MeasureStatus, RevDate, SWRev
17345  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
17346  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
17347  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
17348  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
17349  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
17350  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
17351 
17352  if MeasureStatus.get() == 0:
17353  MeasureStatus.set(1)
17354  measurewindow = Toplevel()
17355  measurewindow.title("Measurements " + SWRev + RevDate)
17356  measurewindow.resizable(FALSE,FALSE)
17357  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
17358  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
17359  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
17360  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
17361  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
17362  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17363  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
17364  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
17365  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
17366  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17367  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
17368  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
17369  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
17370  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17371  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
17372  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
17373  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
17374  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17375  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
17376  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
17377  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
17378  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17379  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
17380  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
17381  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
17382  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17383  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
17384  #
17385  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
17386  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
17387  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17388  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
17389  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
17390  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
17391  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17392  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
17393  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
17394  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
17395  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17396  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
17397  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
17398  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
17399  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17400  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
17401  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
17402  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
17403  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17404  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
17405  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
17406  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
17407  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
17408  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
17409 #
17411  global measurewindow, MeasureStatus
17412 
17413  MeasureStatus.set(0)
17414  measurewindow.destroy()
17415 #
17417  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
17418  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
17419 
17420  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
17421  if BoardStatus.get() == 0:
17422  BoardStatus.set(1)
17423  boardwindow = Toplevel()
17424  boardwindow.title("Select Board " + RevDate)
17425  boardwindow.resizable(FALSE,FALSE)
17426  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
17427  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
17428  toplab.pack(side=TOP)
17429  for idx, devx in enumerate(session.devices):
17430  BrdText = "Board # " + str(idx)
17431  if idx == 0:
17432  devx.set_led(0b010) # LED.green
17433  FWRevOne = float(devx.fwver)
17434  HWRevOne = devx.hwver
17435  dev0 = devx #session.devices[0]
17436  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
17437  elif idx == 1:
17438  devx.set_led(0b100) # LED.blue,
17439  FWRevTwo = float(devx.fwver)
17440  HWRevTwo = devx.hwver
17441  dev1 = devx #session.devices[1]
17442  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
17443  elif idx == 2:
17444  devx.set_led(0b001) # LED.red,
17445  FWRevThree = float(devx.fwver)
17446  HWRevThree = devx.hwver
17447  dev2 = devx #session.devices[2]
17448  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
17449  else:
17450  dev3 = session.devices[3]
17451  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
17452  brd.pack(side=TOP)
17453  else:
17454  devx = session.devices[0]
17455  # devx.ignore_dataflow = True
17456  #devx.set_led(0b010) # LED.green
17457  try:
17458  FWRevOne = float(devx.fwver)
17459  HWRevOne = devx.hwver
17460  except:
17461  FWRevOne = "Before 2.06"
17462  HWRevOne = "?"
17463  dev0 = session.devices[0]
17464 #
17466  global boardwindow, BoardStatus
17467 
17468  BoardStatus.set(0)
17469  boardwindow.destroy()
17470 #
17472  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
17473  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
17474 
17475  if DevID == "No Device" or DevID == "m1k":
17476  #print("Request sample rate: " + str(SAMPLErate))
17477  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
17478  # session.add_all()
17479  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
17480  if not session.devices:
17481  print( 'No Device plugged IN!')
17482  DevID = "No Device"
17483  FWRevOne = 0.0
17484  bcon.configure(text="Recon", style="RConn.TButton")
17485  return
17486  session.configure(sample_rate=SAMPLErate)
17487  #print("Session sample rate: " + str(session.sample_rate))
17488  MakeBoardScreen()
17489  SelectBoard()
17490  bcon.configure(text="Conn", style="GConn.TButton")
17491  devx.set_adc_mux(0)
17492  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
17493  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
17494 
17498  session.start(0)
17499 #
17501  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
17502  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
17503  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
17504 
17505  if RUNstatus.get() == 1:
17506  BStop()
17507  print( "STOP")
17508 
17509  if BrdSel.get() == 0:
17510  try:
17511  session.remove(dev1)
17512  print( "Removing dev1")
17513  except:
17514  print( "Skipping dev1")
17515  try:
17516  session.remove(dev2)
17517  print( "Removing dev2")
17518  except:
17519  print( "Skipping dev2")
17520  session.add(dev0)
17521  devx = dev0
17522  #session.add(devx)
17523  if BrdSel.get() == 1:
17524  try:
17525  session.remove(dev0)
17526  print( "Removing dev0")
17527  except:
17528  print( "Skipping dev0")
17529  try:
17530  session.remove(dev2)
17531  print( "Removing dev2")
17532  except:
17533  print( "Skipping dev2")
17534  session.add(dev1)
17535  devx = dev1
17536  #session.add(devx)
17537  DevID = devx.serial
17538  print( DevID)
17539  FWRevOne = float(devx.fwver)
17540  HWRevOne = str(devx.hwver)
17541  print( FWRevOne, HWRevOne)
17542  print("Session sample rate: " + str(session.sample_rate))
17543 
17544  if IgnoreFirmwareCheck == 0:
17545  if FWRevOne < 2.17:
17546  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
17547  UpdateFirmware()
17548  cal = devx.calibration
17549  CHA = devx.channels['A'] # Open CHA
17550  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
17551  CHB = devx.channels['B'] # Open CHB
17552  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
17553  #
17554  # if session.continuous == 0:
17555  #session.start(0)
17556 
17565  devx.set_adc_mux(0)
17566  if devx.hwver == "F":
17567  print( "Rev F Board I/O ports set")
17568  PIO_0 = 28
17569  PIO_1 = 29
17570  PIO_2 = 47
17571  PIO_3 = 3
17572  PIO_4 = 4
17573  PIO_5 = 5
17574  PIO_6 = 6
17575  PIO_7 = 7
17576  else:
17577  PIO_0 = 0
17578  PIO_1 = 1
17579  PIO_2 = 2
17580  PIO_3 = 3
17581  PIO_4 = 4
17582  PIO_5 = 5
17583  PIO_6 = 6
17584  PIO_7 = 7
17585 #
17586  SDATAPort.set(PIO_1)
17587  SCLKPort.set(PIO_2)
17588  SLATCHPort.set(PIO_0)
17589 
17591  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
17592  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
17593  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
17594 
17595  if SampleRateStatus.get() == 0:
17596  SampleRateStatus.set(1)
17597  SampleRatewindow = Toplevel()
17598  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
17599  SampleRatewindow.resizable(FALSE,FALSE)
17600  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
17601  frame1 = Frame(SampleRatewindow, borderwidth=5, relief=RIDGE)
17602  frame1.grid(row=0, column=0, sticky=W)
17603  #
17604  BaseRATE = Frame( frame1 )
17605  BaseRATE.grid(row=0, column=0, sticky=W)
17606  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
17607  baseratelab.pack(side=LEFT)
17608  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
17609  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
17610  BaseRatesb.bind("<Return>", onRetSrate)
17611  BaseRatesb.pack(side=LEFT)
17612  BaseRatesb.delete(0,"end")
17613  BaseRatesb.insert(0,BaseSampleRate)
17614  #BaseRateEntry = Entry(BaseRATE, width=6) #
17615  #BaseRateEntry.pack(side=LEFT)
17616  #BaseRateEntry.bind('<MouseWheel>', onSrateScroll)
17617 
17618  #BaseRateEntry.delete(0,"end")
17619  #BaseRateEntry.insert(0,BaseSampleRate)
17620  #
17621  nextrow = 2
17622  if FWRevOne > 2.16:
17623  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
17624  twoX.grid(row=1, column=0, sticky=W)
17625  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
17626  muxlab1.grid(row=2, column=0, sticky=W)
17627  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
17628  AltSweep.grid(row=3, column=0, sticky=W)
17629  chabuttons = Frame( frame1 )
17630  chabuttons.grid(row=4, column=0, sticky=W)
17631  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
17632  muxrb1.pack(side=LEFT)
17633  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
17634  muxrb2.pack(side=LEFT)
17635  chcbuttons = Frame( frame1 )
17636  chcbuttons.grid(row=5, column=0, sticky=W)
17637  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
17638  muxrb5.pack(side=LEFT)
17639  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
17640  muxrb6.pack(side=LEFT)
17641  nextrow = 6
17642  if DeBugMode == 1:
17643  chbbuttons = Frame( frame1 )
17644  chbbuttons.grid(row=nextrow, column=0, sticky=W)
17645  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
17646  muxrb3.pack(side=LEFT)
17647  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
17648  muxrb4.pack(side=LEFT)
17649  nextrow = nextrow + 1
17650  #
17651  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
17652  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
17653 #
17655  global SampleRatewindow, SampleRateStatus
17656 
17657  SampleRateStatus.set(0)
17658  SampleRatewindow.destroy()
17659 #
17660 #
17661 def onSrateScroll(event):
17662 
17663  #onTextScroll
17664  onSpinBoxScroll(event)
17665  SetSampleRate()
17666 #
17667 def onRetSrate(event):
17668 
17669  SetSampleRate()
17670 #
17672  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
17673  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
17674 
17675  #
17676  WasRunning = 0
17677  if (RUNstatus.get() == 1):
17678  WasRunning = 1
17679  BStop() # Force Stop loop if running
17680  try:
17681  NewRate = int(BaseRatesb.get())
17682  if NewRate <= 100000: # rate has to be less than or equal to 100,000
17683  BaseSampleRate = NewRate
17684  else:
17685  BaseSampleRate = 100000
17686  BaseRatesb.delete(0,"end")
17687  BaseRatesb.insert(0,BaseSampleRate)
17688  SAMPLErate = BaseSampleRate # Scope sample rate
17689  except:
17690  donothing()
17691  session.configure(sample_rate=BaseSampleRate)
17692  # calculate actual sample rate
17693  # minimum clock cycles per sample (100ksps)
17694  m_min_per = 240
17695  # maximum clock cycles per sample (~1024 samples/s)
17696  m_max_per = 24000
17697  sample_time = 1.0 / BaseSampleRate
17698  M1K_timer_clock = 48e6
17699  m_sam_per = round(sample_time * M1K_timer_clock) / 2
17700  if (m_sam_per < m_min_per):
17701  m_sam_per = m_min_per
17702  elif (m_sam_per > m_max_per):
17703  m_sam_per = m_max_per;
17704  # convert back to the actual sample time
17705  sample_time = m_sam_per / M1K_timer_clock
17706  # convert back to the actual sample rate
17707  BaseSampleRate = int(round((1.0 / sample_time) / 2.0))
17708  SAMPLErate = BaseSampleRate # Scope sample rate
17709  AWGSAMPLErate = BaseSampleRate
17710  if ETSStatus.get() > 0:
17711  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
17712  rtsrlab.config(text=SRstring)
17713  ETSUpdate()
17714  BaseRatesb.delete(0,"end")
17715  BaseRatesb.insert(0,BaseSampleRate)
17716  ReMakeAWGwaves() # remake AWG waveforms for new rate
17717  if (WasRunning == 1):
17718  WasRunning = 0
17719  BStart() # restart loop if was running
17720 #
17721 def onStopfreqScroll(event):
17722  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
17723 
17724  onTextScroll(event)
17725  try:
17726  StopFrequency = float(StopFreqEntry.get())
17727  except:
17728  StopFreqEntry.delete(0,"end")
17729  StopFreqEntry.insert(0,50000)
17730  StopFrequency = 50000
17731  if FWRevOne > 2.16:
17732  if StopFrequency >= 50000:
17733  Two_X_Sample.set(1)
17734  ADC_Mux_Mode.set(0)
17735  SetADC_Mux()
17736  else:
17737  Two_X_Sample.set(0)
17738  ADC_Mux_Mode.set(0)
17739  SetADC_Mux()
17740 #
17741 def onStopBodeScroll(event):
17742  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
17743 
17744  onTextScroll(event)
17745  try:
17746  StopFrequency = float(StopBodeEntry.get())
17747  except:
17748  StopBodeEntry.delete(0,"end")
17749  StopBodeEntry.insert(0,20000)
17750  StopFrequency = 20000
17751  if FWRevOne > 2.16:
17752  if StopFrequency >= 20000:
17753  Two_X_Sample.set(1)
17754  ADC_Mux_Mode.set(0)
17755  SetADC_Mux()
17756  else:
17757  Two_X_Sample.set(0)
17758  ADC_Mux_Mode.set(0)
17759  SetADC_Mux()
17760 #
17762  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
17763  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
17764 
17765  if Two_X_Sample.get() == 1:
17766  if ADC_Mux_Mode.get() == 0: # VA and VB
17767  devx.set_adc_mux(1)
17768  elif ADC_Mux_Mode.get() == 1: # IA and IB
17769  devx.set_adc_mux(2)
17770  elif ADC_Mux_Mode.get() == 2: # VA and IB
17771  # cycle trhough default mux values as starting point
17772  devx.set_adc_mux(2)
17773  # now set new mux values
17774  devx.set_adc_mux(7)
17775  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
17776  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
17777  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
17778  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
17779  time.sleep(0.1)
17780  elif ADC_Mux_Mode.get() == 3: # VB and IA
17781  # cycle trhough default mux values as starting point
17782  # now set new mux values
17783  devx.set_adc_mux(7)
17784  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
17785  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
17786  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
17787  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
17788  time.sleep(0.1)
17789  elif ADC_Mux_Mode.get() == 4: # VA and IA
17790  # now set new mux values
17791  devx.set_adc_mux(4)
17792  elif ADC_Mux_Mode.get() == 5: # VB and IB
17793  # now set new mux values
17794  devx.set_adc_mux(5)
17795  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
17796  else:
17797  devx.set_adc_mux(0)
17798  SAMPLErate = BaseSampleRate
17799 #
17801  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
17802 
17803  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17804  ADC_Mux_Mode.set(0) # All four traces
17805  Alternate_Sweep_Mode.set(1)
17806  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
17807  ADC_Mux_Mode.set(0) # three traces
17808  Alternate_Sweep_Mode.set(1)
17809  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
17810  ADC_Mux_Mode.set(0) # three traces
17811  Alternate_Sweep_Mode.set(1)
17812  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17813  ADC_Mux_Mode.set(0) # three traces
17814  Alternate_Sweep_Mode.set(1)
17815  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17816  ADC_Mux_Mode.set(0) # three traces
17817  Alternate_Sweep_Mode.set(1)
17818  #
17819  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
17820  ADC_Mux_Mode.set(1) # IA and IB
17821  Alternate_Sweep_Mode.set(0)
17822  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
17823  ADC_Mux_Mode.set(1) # just IA
17824  Alternate_Sweep_Mode.set(0)
17825  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
17826  ADC_Mux_Mode.set(1) # just IB
17827  Alternate_Sweep_Mode.set(0)
17828  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
17829  ADC_Mux_Mode.set(4) # VA and IA
17830  Alternate_Sweep_Mode.set(0)
17831  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
17832  ADC_Mux_Mode.set(5) # VB and IB
17833  Alternate_Sweep_Mode.set(0)
17834  else:
17835  ADC_Mux_Mode.set(0)
17836  Alternate_Sweep_Mode.set(0)
17837  SetADC_Mux()
17838  UpdateTimeTrace()
17839 #
17841  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
17842  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
17843 
17844  RUNstatus.set(0)
17845  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
17846  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
17847  print( filename)
17848  #print DevID
17849  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
17850  try:
17851  print( "Cancel current session.")
17852  session.cancel()
17853  print( session.cancelled)
17854  session.end()
17855  print( "Waiting 5...")
17856  time.sleep(5)
17857  print( "Put board in Samba mode and flash firmware.")
17858  session.flash_firmware(filename)
17859  except:
17860  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
17861 
17869  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
17870  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
17871  Bcloseexit()
17872 
17882  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
17883  global CHATestVEntry, CHATestREntry, SWRev, AWGSync
17884 
17885  if OhmStatus.get() == 0:
17886  AWGSync.set(1)
17887  OhmStatus.set(1)
17888  OhmDisp.set(1)
17889  OhmCheckBox()
17890  ohmwindow = Toplevel()
17891  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
17892  ohmwindow.resizable(FALSE,FALSE)
17893  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
17894  frame1 = Frame(ohmwindow, borderwidth=5, relief=RIDGE)
17895  frame1.grid(row=0, column=0, sticky=W)
17896  #
17897  buttons = Frame( frame1 )
17898  buttons.grid(row=0, column=0, sticky=W)
17899  rb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
17900  rb1.pack(side=LEFT)
17901  rb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
17902  rb2.pack(side=LEFT)
17903  #
17904  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
17905  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
17906  OhmA0.config(text = "0.000 Ohms")
17907 
17908  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
17909  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
17910  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
17911  #
17912  TestVA = Frame( frame1 )
17913  TestVA.grid(row=3, column=0, sticky=W)
17914  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
17915  chatestvlab.pack(side=LEFT)
17916  CHATestVEntry = Entry(TestVA, width=6) #
17917  CHATestVEntry.pack(side=LEFT)
17918  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
17919  CHATestVEntry.delete(0,"end")
17920  CHATestVEntry.insert(0,5.0)
17921  #
17922  RMode = IntVar(0)
17923  RMode.set(1)
17924  TestMode = Frame( frame1 )
17925  TestMode.grid(row=4, column=0, sticky=W)
17926  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
17927  modelab.pack(side=LEFT)
17928  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
17929  rm3.pack(side=LEFT)
17930  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
17931  rm4.pack(side=LEFT)
17932  #
17933  TestRA = Frame( frame1 )
17934  TestRA.grid(row=5, column=0, sticky=W)
17935  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
17936  chatestrlab.pack(side=LEFT)
17937  CHATestREntry = Entry(TestRA, width=6) #
17938  CHATestREntry.pack(side=LEFT)
17939  CHATestREntry.bind('<MouseWheel>', onTextScroll)
17940  CHATestREntry.delete(0,"end")
17941  CHATestREntry.insert(0,50.0)
17942  #
17943  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
17944  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
17945 #
17947  global ohmwindow, OhmStatus, OhmDisp
17948 
17949  OhmStatus.set(0)
17950  OhmDisp.set(0)
17951  OhmCheckBox()
17952  ohmwindow.destroy()
17953 #
17955  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
17956  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
17957 
17958  #
17959  if ETSStatus.get() == 0:
17960  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
17961  ETSStatus.set(1)
17962  ETSDisp.set(0)
17963  etswindow = Toplevel()
17964  etswindow.title("ETS Controls " + SWRev + RevDate)
17965  etswindow.resizable(FALSE,FALSE)
17966  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
17967  frame1 = Frame(etswindow, borderwidth=5, relief=RIDGE)
17968  frame1.grid(row=0, column=0, sticky=W)
17969  # Sampling controls Widgets
17970  SRstring = "RT Sample Rate = " + str(SAMPLErate)
17971  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
17972  rtsrlab.grid(row=1, column=0, sticky=W)
17973  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
17974  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
17975  etssrlab.grid(row=2, column=0, sticky=W)
17976  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
17977  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
17978  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
17979  enb1.grid(row=4, column=0, sticky=W)
17980  #
17981  Divx = Frame( frame1 )
17982  Divx.grid(row=5, column=0, sticky=W)
17983  DivXEntry = Entry(Divx, width=6)
17984  DivXEntry.bind('<MouseWheel>', ETSscroll)
17985  DivXEntry.pack(side=RIGHT)
17986  DivXEntry.delete(0,"end")
17987  DivXEntry.insert(0,2)
17988  divxlab = Label( Divx, text = "Divide Factor")
17989  divxlab.pack(side=RIGHT)
17990  #
17991  FOffEntry = Label(frame1, text="Samples")
17992  FOffEntry.grid(row=6, column=0, sticky=W)
17993  MulXEntry = Label( frame1, text = "Rec Len Mul")
17994  MulXEntry.grid(row=7, column=0, sticky=W)
17995  #
17996  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
17997  eqivsamplerate.grid(row=8, column=0, sticky=W)
17998  #
17999  FConv = Frame( frame1 )
18000  FConv.grid(row=9, column=0, sticky=W)
18001  FMulXEntry = Entry(FConv, width=3)
18002  FMulXEntry.bind('<MouseWheel>', ETSscroll)
18003  FMulXEntry.pack(side=RIGHT)
18004  FMulXEntry.delete(0,"end")
18005  FMulXEntry.insert(0,1)
18006  fminlab = Label( FConv, text = "Freq Multiplier")
18007  fminlab.pack(side=RIGHT)
18008  #
18009  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
18010  FminDisp.grid(row=10, column=0, sticky=W)
18011  #
18012  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
18013  mgloadbutton.grid(row=11, column=0, sticky=W)
18014  #
18015  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
18016  dirlab.grid(row=12, column=0, sticky=W)
18017  DataMode = Frame( frame1 )
18018  DataMode.grid(row=13, column=0, sticky=W)
18019  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
18020  dm3.pack(side=LEFT)
18021  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
18022  dm4.pack(side=LEFT)
18023  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
18024  tclab.grid(row=14, column=0, sticky=W)
18025  TSMode = Frame( frame1 )
18026  TSMode.grid(row=15, column=0, sticky=W)
18027  ETSts = Entry(TSMode, width=6)
18028  ETSts.bind('<MouseWheel>', ETSscroll)
18029  ETSts.pack(side=RIGHT)
18030  ETSts.delete(0,"end")
18031  ETSts.insert(0,1)
18032  ETStslab = Label( TSMode, text = "Factor")
18033  ETStslab.pack(side=RIGHT)
18034  #
18035  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
18036  etsdismissclbutton.grid(row=16, column=0, sticky=W, pady=7)
18037  ETSDisp.set(0)
18038  ETSCheckBox()
18039 #
18041  global etswindow, ETSStatus, ETSDisp
18042 
18043  ETSStatus.set(0)
18044  ETSDisp.set(0)
18045  ETSCheckBox()
18046  etswindow.destroy()
18047 #
18048 def MGLoad():
18049  global MinigenFout, Fmin, ETSDir
18050 
18051  MinigenFout.delete(0,"end")
18052  if ETSDir.get() == 0:
18053  MinigenFout.insert(0,Fmin+20)
18054  else:
18055  MinigenFout.insert(0,Fmin-20)
18056  BSendMG()
18057 #
18058 def ETSscroll(event):
18059  onTextScroll(event)
18060  ETSUpdate()
18061 #
18063  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
18064  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
18065  global FminEntry, HtMulEntry, Two_X_Sample
18066 
18067  if TIMEdiv > 0.2:
18068  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
18069  else:
18070  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
18071  if (MaxETSrecord*100) > MaxSamples:
18072  MaxETSrecord = MaxSamples / 100
18073  try:
18074  DivX = float(eval(DivXEntry.get()))
18075  if DivX < 2:
18076  DivX = 2
18077  if DivX > 75:
18078  DivX = 75
18079  DivXEntry.delete(0,END)
18080  DivXEntry.insert(0, DivX)
18081  except:
18082  DivXEntry.delete(0,END)
18083  DivXEntry.insert(0, DivX)
18084  #
18085  try:
18086  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
18087  except:
18088  FminEntry.delete(0,END)
18089  FminEntry.insert(0, 25)
18090  #
18091  FOff = 25
18092  MulX = (DivX*SAMPLErate)/(100*FOff)
18093  while MulX > MaxETSrecord:
18094  FOff = FOff + 5
18095  MulX = (DivX*SAMPLErate)/(100*FOff)
18096  FOff = 0 - FOff
18097  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
18098  MulXEntry.config(text = SRstring) # change displayed value
18099  SRstring = "Offset = " + str(FOff) + " samples"
18100  FOffEntry.config(text = SRstring) # change displayed value
18101  baseFreq = SAMPLErate/DivX
18102  try:
18103  FMul = float(eval(FMulXEntry.get()))
18104  if FMul < 1:
18105  FMul = 1
18106  FMulXEntry.delete(0,END)
18107  FMulXEntry.insert(0, int(FMul))
18108  if FMul > 75:
18109  FMul = 75
18110  FMulXEntry.delete(0,END)
18111  FMulXEntry.insert(0, int(FMul))
18112  except:
18113  FMulXEntry.delete(0,END)
18114  FMulXEntry.insert(0, int(FMul))
18115  FreqMin = baseFreq * FMul
18116  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
18117  FminDisp.config(text = SRstring) # change displayed value
18118  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
18119  eqivsamplerate.config(text = SRstring) # change displayed value
18120  # calculate time scale multiplication factor
18121  try: # catch for divide by zero
18122  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
18123  except:
18124  TscaleX = 1
18125 
18126  if TscaleX > 0:
18127  ETSDir.set(0) # set sample direction to forward if positive
18128  else:
18129  ETSDir.set(1) # set sample direction to reverse if negative
18130  TscaleX = abs(TscaleX)
18131  if Two_X_Sample.get() == 0:
18132  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
18133  else:
18134  ToffsetX = 0
18135 
18136  ETSts.delete(0,"end")
18137  ETSts.insert(0,ToffsetX)
18138 
18139  HtMulEntry.delete(0,END)
18140  HtMulEntry.insert(0, TscaleX)
18141  SRstring = "RT Sample Rate = " + str(SAMPLErate)
18142  rtsrlab.config(text=SRstring)
18143  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
18144  etssrlab.config(text=SRstring)
18145 #
18146 def Settingsscroll(event):
18147  onTextScroll(event)
18148  SettingsUpdate()
18149 #
18151  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
18152  global Settingswindow, SettingsStatus, SettingsDisp, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
18153  global AWG_Amp_Mode, SWRev
18154  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
18155  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
18156  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
18157  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
18158 
18159  if SettingsStatus.get() == 0:
18160  Settingswindow = Toplevel()
18161  Settingswindow.title("Settings " + SWRev + RevDate)
18162  Settingswindow.resizable(FALSE,FALSE)
18163  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
18164  frame1 = Frame(Settingswindow, borderwidth=5, relief=RIDGE)
18165  frame1.grid(row=0, column=0, sticky=W)
18166  #
18167  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
18168  zstlab.grid(row=0, column=0, sticky=W)
18169  zstMode = Frame( frame1 )
18170  zstMode.grid(row=0, column=1, sticky=W)
18171  ZSTuff = Entry(zstMode, width=4)
18172  ZSTuff.bind('<MouseWheel>', Settingsscroll)
18173  ZSTuff.bind('<Key>', onTextKey)
18174  ZSTuff.pack(side=RIGHT)
18175  ZSTuff.delete(0,"end")
18176  ZSTuff.insert(0,ZEROstuffing.get())
18177  #
18178  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
18179  Avglab.grid(row=1, column=0, sticky=W)
18180  AvgMode = Frame( frame1 )
18181  AvgMode.grid(row=1, column=1, sticky=W)
18182  TAvg = Entry(AvgMode, width=4)
18183  TAvg.bind('<MouseWheel>', Settingsscroll)
18184  TAvg.bind('<Key>', onTextKey)
18185  TAvg.pack(side=RIGHT)
18186  TAvg.delete(0,"end")
18187  TAvg.insert(0,TRACEaverage.get())
18188  #
18189  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
18190  HarMlab.grid(row=2, column=0, sticky=W)
18191  HarMMode = Frame( frame1 )
18192  HarMMode.grid(row=2, column=1, sticky=W)
18193  HarMon = Entry(HarMMode, width=4)
18194  HarMon.bind('<MouseWheel>', Settingsscroll)
18195  HarMon.bind('<Key>', onTextKey)
18196  HarMon.pack(side=RIGHT)
18197  HarMon.delete(0,"end")
18198  HarMon.insert(0,HarmonicMarkers.get())
18199  #
18200  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
18201  Vdivlab.grid(row=3, column=0, sticky=W)
18202  VdivMode = Frame( frame1 )
18203  VdivMode.grid(row=3, column=1, sticky=W)
18204  VDivE = Entry(VdivMode, width=4)
18205  VDivE.bind('<MouseWheel>', Settingsscroll)
18206  VDivE.bind('<Key>', onTextKey)
18207  VDivE.pack(side=RIGHT)
18208  VDivE.delete(0,"end")
18209  VDivE.insert(0,Vdiv.get())
18210  #
18211  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
18212  Twdthlab.grid(row=4, column=0, sticky=W)
18213  TwdthMode = Frame( frame1 )
18214  TwdthMode.grid(row=4, column=1, sticky=W)
18215  TwdthE = Entry(TwdthMode, width=4)
18216  TwdthE.bind('<MouseWheel>', Settingsscroll)
18217  TwdthE.bind('<Key>', onTextKey)
18218  TwdthE.pack(side=RIGHT)
18219  TwdthE.delete(0,"end")
18220  TwdthE.insert(0,TRACEwidth.get())
18221  #
18222  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
18223  Gwdthlab.grid(row=5, column=0, sticky=W)
18224  GwdthMode = Frame( frame1 )
18225  GwdthMode.grid(row=5, column=1, sticky=W)
18226  GwdthE = Entry(GwdthMode, width=4)
18227  GwdthE.bind('<MouseWheel>', Settingsscroll)
18228  GwdthE.bind('<Key>', onTextKey)
18229  GwdthE.pack(side=RIGHT)
18230  GwdthE.delete(0,"end")
18231  GwdthE.insert(0,GridWidth.get())
18232  #
18233  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
18234  AwgAmplrb1.grid(row=6, column=0, sticky=W)
18235  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
18236  AwgAmplrb2.grid(row=6, column=1, sticky=W)
18237  #
18238  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
18239  cha_Rcomplab.grid(row=7, column=0, sticky=W)
18240  cha_RcomplabMode = Frame( frame1 )
18241  cha_RcomplabMode.grid(row=7, column=1, sticky=W)
18242  cha_TC1Entry = Entry(cha_RcomplabMode, width=5)
18243  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
18244  cha_TC1Entry.bind('<Key>', onTextKey)
18245  cha_TC1Entry.pack(side=LEFT)
18246  cha_TC1Entry.delete(0,"end")
18247  cha_TC1Entry.insert(0,CHA_TC1.get())
18248  cha_A1Entry = Entry(cha_RcomplabMode, width=5)
18249  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
18250  cha_A1Entry.bind('<Key>', onTextKey)
18251  cha_A1Entry.pack(side=LEFT)
18252  cha_A1Entry.delete(0,"end")
18253  cha_A1Entry.insert(0,CHA_A1.get())
18254  #
18255  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
18256  cha_Ccomplab.grid(row=8, column=0, sticky=W)
18257  cha_CcomplabMode = Frame( frame1 )
18258  cha_CcomplabMode.grid(row=8, column=1, sticky=W)
18259  cha_TC2Entry = Entry(cha_CcomplabMode, width=5)
18260  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
18261  cha_TC2Entry.bind('<Key>', onTextKey)
18262  cha_TC2Entry.pack(side=LEFT)
18263  cha_TC2Entry.delete(0,"end")
18264  cha_TC2Entry.insert(0,CHA_TC2.get())
18265  cha_A2Entry = Entry(cha_CcomplabMode, width=5)
18266  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
18267  cha_A2Entry.bind('<Key>', onTextKey)
18268  cha_A2Entry.pack(side=LEFT)
18269  cha_A2Entry.delete(0,"end")
18270  cha_A2Entry.insert(0,CHA_A2.get())
18271  #
18272  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
18273  chb_Rcomplab.grid(row=9, column=0, sticky=W)
18274  chb_RcomplabMode = Frame( frame1 )
18275  chb_RcomplabMode.grid(row=9, column=1, sticky=W)
18276  chb_TC1Entry = Entry(chb_RcomplabMode, width=5)
18277  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
18278  chb_TC1Entry.bind('<Key>', onTextKey)
18279  chb_TC1Entry.pack(side=LEFT)
18280  chb_TC1Entry.delete(0,"end")
18281  chb_TC1Entry.insert(0,CHB_TC1.get())
18282  chb_A1Entry = Entry(chb_RcomplabMode, width=5)
18283  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
18284  chb_A1Entry.bind('<Key>', onTextKey)
18285  chb_A1Entry.pack(side=LEFT)
18286  chb_A1Entry.delete(0,"end")
18287  chb_A1Entry.insert(0,CHB_A1.get())
18288  #
18289  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
18290  chb_Ccomplab.grid(row=10, column=0, sticky=W)
18291  chb_CcomplabMode = Frame( frame1 )
18292  chb_CcomplabMode.grid(row=10, column=1, sticky=W)
18293  chb_TC2Entry = Entry(chb_CcomplabMode, width=5)
18294  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
18295  chb_TC2Entry.bind('<Key>', onTextKey)
18296  chb_TC2Entry.pack(side=LEFT)
18297  chb_TC2Entry.delete(0,"end")
18298  chb_TC2Entry.insert(0,CHB_TC2.get())
18299  chb_A2Entry = Entry(chb_CcomplabMode, width=5)
18300  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
18301  chb_A2Entry.bind('<Key>', onTextKey)
18302  chb_A2Entry.pack(side=LEFT)
18303  chb_A2Entry.delete(0,"end")
18304  chb_A2Entry.insert(0,CHB_A2.get())
18305  #
18306  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
18307  Settingsdismissbutton.grid(row=11, column=0, sticky=W, pady=7)
18308 #
18310 
18311  UpdateAWGA()
18312  UpdateAWGB()
18313 
18315  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
18316  global Settingswindow, SettingsStatus, SettingsDisp, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
18317  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
18318  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
18319  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
18320  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
18321 
18322  try:
18323  GW = int(eval(GwdthE.get()))
18324  if GW < 1:
18325  GW = 1
18326  GwdthE.delete(0,END)
18327  GwdthE.insert(0, int(GW))
18328  if GW > 5:
18329  GW = 5
18330  GwdthE.delete(0,END)
18331  GwdthE.insert(0, int(GW))
18332  except:
18333  GwdthE.delete(0,END)
18334  GwdthE.insert(0, GridWidth.get())
18335  GridWidth.set(GW)
18336  try:
18337  TW = int(eval(TwdthE.get()))
18338  if TW < 1:
18339  TW = 1
18340  TwdthE.delete(0,END)
18341  TwdthE.insert(0, int(TW))
18342  if TW > 5:
18343  TW = 5
18344  TwdthE.delete(0,END)
18345  TwdthE.insert(0, int(TW))
18346  except:
18347  TwdthE.delete(0,END)
18348  TwdthE.insert(0, TRACEwidth.get())
18349  TRACEwidth.set(TW)
18350  # Number of average sweeps for average mode
18351  try:
18352  TA = int(eval(TAvg.get()))
18353  if TA < 1:
18354  TA = 1
18355  TAvg.delete(0,END)
18356  TAvg.insert(0, int(TA))
18357  if TA > 16:
18358  TA = 16
18359  TAvg.delete(0,END)
18360  TAvg.insert(0, int(TA))
18361  except:
18362  TAvg.delete(0,END)
18363  TAvg.insert(0, TRACEaverage.get())
18364  TRACEaverage.set(TA)
18365  # Number of vertical divisions for spectrum / Bode
18366  try:
18367  VDv = int(eval(VDivE.get()))
18368  if VDv < 1:
18369  VDv = 1
18370  VDivE.delete(0,END)
18371  VDivE.insert(0, int(VDv))
18372  if VDv > 16:
18373  VDv = 16
18374  VDivE.delete(0,END)
18375  VDivE.insert(0, int(VDv))
18376  except:
18377  VDivE.delete(0,END)
18378  VDivE.insert(0, Vdiv.get())
18379  Vdiv.set(VDv)
18380  # number of Harmonic Markers in SA
18381  try:
18382  HM = int(eval(HarMon.get()))
18383  if HM < 1:
18384  HM = 1
18385  HarMon.delete(0,END)
18386  HarMon.insert(0, int(HM))
18387  if HM > 9:
18388  HM =9
18389  HarMon.delete(0,END)
18390  HarMon.insert(0, int(HM))
18391  except:
18392  HarMon.delete(0,END)
18393  HarMon.insert(0, HarmonicMarkers.get())
18394  HarmonicMarkers.set(HM)
18395  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
18396  try:
18397  ZST = int(eval(ZSTuff.get()))
18398  if ZST < 1:
18399  ZST = 1
18400  ZSTuff.delete(0,END)
18401  ZSTuff.insert(0, int(ZST))
18402  if ZST > 5:
18403  ZST = 5
18404  ZSTuff.delete(0,END)
18405  ZSTuff.insert(0, int(ZST))
18406  except:
18407  ZSTuff.delete(0,END)
18408  ZSTuff.insert(0, ZEROstuffing.get())
18409  ZEROstuffing.set(ZST)
18410 #
18411  try:
18412  TC1A = float(cha_TC1Entry.get())
18413  CHA_TC1.set(TC1A)
18414  if TC1A < 0:
18415  TC1A = 0
18416  cha_TC1Entry.delete(0,END)
18417  cha_TC1Entry.insert(0, TC1A)
18418  except:
18419  cha_TC1Entry.delete(0,END)
18420  cha_TC1Entry.insert(0, CHA_TC1.get())
18421  try:
18422  TC2A = float(cha_TC2Entry.get())
18423  CHA_TC2.set(TC2A)
18424  if TC2A < 0:
18425  TC2A = 0
18426  cha_TC2Entry.delete(0,END)
18427  cha_TC2Entry.insert(0, TC2A)
18428  except:
18429  cha_TC2Entry.delete(0,END)
18430  cha_TC2Entry.insert(0, CHA_TC2.get())
18431  #
18432  try:
18433  Gain1A = float(cha_A1Entry.get())
18434  CHA_A1.set(Gain1A)
18435  except:
18436  cha_A1Entry.delete(0,END)
18437  cha_A1Entry.insert(0, CHA_A1.get())
18438  try:
18439  Gain2A = float(cha_A2Entry.get())
18440  CHA_A2.set(Gain2A)
18441  except:
18442  cha_A2Entry.delete(0,END)
18443  cha_A2Entry.insert(0, CHA_A2.get())
18444  #
18445  try:
18446  TC1B = float(chb_TC1Entry.get())
18447  CHB_TC1.set(TC1B)
18448  if TC1B < 0:
18449  TC1B = 0
18450  chb_TC1Entry.delete(0, END)
18451  chb_TC1Entry.insert(0, TC1B)
18452  except:
18453  chb_TC1Entry.delete(0,END)
18454  chb_TC1Entry.insert(0, CHB_TC1.get())
18455  try:
18456  TC2B = float(chb_TC2Entry.get())
18457  CHB_TC2.set(TC2B)
18458  if TC2B < 0:
18459  TC2B = 0
18460  chb_TC2Entry.delete(0, END)
18461  chb_TC2Entry.insert(0, TC2B)
18462  except:
18463  chb_TC2Entry.delete(0,END)
18464  chb_TC2Entry.insert(0, CHB_TC2.get())
18465  #
18466  try:
18467  Gain1B = float(chb_A1Entry.get())
18468  CHB_A1.set(Gain1B)
18469  except:
18470  chb_A1Entry.delete(0,END)
18471  chb_A1Entry.insert(0, CHB_A1.get())
18472  try:
18473  Gain2B = float(chb_A2Entry.get())
18474  CHB_A2.set(Gain2B)
18475  except:
18476  chb_A2Entry.delete(0,END)
18477  chb_A2Entry.insert(0, CHB_A2.get())
18478  #
18480  global Settingswindow, SettingsStatus, SettingsDisp
18481 
18482  SettingsStatus.set(0)
18483  SettingsUpdate()
18484  # SettingsDisp.set(0)
18485  Settingswindow.destroy()
18486 #
18487 def onCanvasMouse_xy(event):
18488  global MouseX, MouseY, MouseWidget
18489 
18490  MouseWidget = event.widget
18491  MouseX, MouseY = event.x, event.y
18492 #
18493 # ================ Make main Screen ==========================
18494 TgInput = IntVar(0) # Trigger Input variable
18495 SingleShot = IntVar(0) # variable for single shot triger
18496 ManualTrigger = IntVar(0) # variable for Manual trigger
18497 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
18498 ShowC1_V = IntVar(0) # curves to display variables
18499 TgEdge = IntVar(0) # Trigger edge variable
18500 # Show channels variables
18501 ShowC1_V = IntVar(0) # curves to display variables
18502 ShowC1_I = IntVar(0)
18503 ShowC2_V = IntVar(0)
18504 ShowC2_I = IntVar(0)
18505 ShowAV_I = IntVar(0)
18506 ShowBV_I = IntVar(0)
18507 ShowRA_V = IntVar(0)
18508 ShowRA_I = IntVar(0)
18509 ShowRB_V = IntVar(0)
18510 ShowRB_I = IntVar(0)
18511 ShowMath = IntVar(0)
18512 Show_MathX = IntVar(0)
18513 Show_MathY = IntVar(0)
18514 AutoCenterA = IntVar(0)
18515 AutoCenterB = IntVar(0)
18516 SmoothCurves = IntVar(0)
18517 ZOHold = IntVar(0)
18518 TRACEmodeTime = IntVar(0)
18519 TRACEmodeTime.set(0)
18520 ColorMode = IntVar(0)
18521 DecimateOption = IntVar(0)
18522 MathTrace = IntVar(0)
18523 # define vertical measurment variables
18524 MeasDCV1 = IntVar(0)
18525 MeasMinV1 = IntVar(0)
18526 MeasMaxV1 = IntVar(0)
18527 MeasMidV1 = IntVar(0)
18528 MeasPPV1 = IntVar(0)
18529 MeasRMSV1 = IntVar(0)
18530 MeasRMSVA_B = IntVar(0)
18531 MeasDCI1 = IntVar(0)
18532 MeasMinI1 = IntVar(0)
18533 MeasMaxI1 = IntVar(0)
18534 MeasMidI1 = IntVar(0)
18535 MeasPPI1 = IntVar(0)
18536 MeasRMSI1 = IntVar(0)
18537 MeasDiffAB = IntVar(0)
18538 MeasDCV2 = IntVar(0)
18539 MeasMinV2 = IntVar(0)
18540 MeasMaxV2 = IntVar(0)
18541 MeasMidV2 = IntVar(0)
18542 MeasPPV2 = IntVar(0)
18543 MeasRMSV2 = IntVar(0)
18544 MeasDCI2 = IntVar(0)
18545 MeasMinI2 = IntVar(0)
18546 MeasMaxI2 = IntVar(0)
18547 MeasMidI2 = IntVar(0)
18548 MeasPPI2 = IntVar(0)
18549 MeasRMSI2 = IntVar(0)
18550 MeasDiffBA = IntVar(0)
18551 MeasUserA = IntVar(0)
18552 MeasAHW = IntVar(0)
18553 MeasALW = IntVar(0)
18554 MeasADCy = IntVar(0)
18555 MeasAPER = IntVar(0)
18556 MeasAFREQ = IntVar(0)
18557 MeasBHW = IntVar(0)
18558 MeasBLW = IntVar(0)
18559 MeasBDCy = IntVar(0)
18560 MeasBPER = IntVar(0)
18561 MeasBFREQ = IntVar(0)
18562 MeasPhase = IntVar(0)
18563 MeasTopV1 = IntVar(0)
18564 MeasBaseV1 = IntVar(0)
18565 MeasTopV2 = IntVar(0)
18566 MeasBaseV2 = IntVar(0)
18567 MeasUserB = IntVar(0)
18568 MeasDelay = IntVar(0)
18569 TimeDisp = IntVar(0)
18570 TimeDisp.set(1)
18571 XYDisp = IntVar(0)
18572 FreqDisp = IntVar(0)
18573 BodeDisp = IntVar(0)
18574 IADisp = IntVar(0)
18575 OhmDisp = IntVar(0)
18576 BodeScreenStatus = IntVar(0)
18577 BodeScreenStatus.set(0)
18578 DigScreenStatus = IntVar(0)
18579 DigScreenStatus.set(0)
18580 DacScreenStatus = IntVar(0)
18581 DacScreenStatus.set(0)
18582 MuxScreenStatus = IntVar(0)
18583 MuxScreenStatus.set(0)
18584 DualMuxMode = IntVar(0)
18585 MinigenScreenStatus = IntVar(0)
18586 MinigenScreenStatus.set(0)
18587 DA1ScreenStatus = IntVar(0)
18588 DA1ScreenStatus.set(0)
18589 DigPotScreenStatus = IntVar(0)
18590 DigPotScreenStatus.set(0)
18591 GenericSerialStatus = IntVar(0)
18592 GenericSerialStatus.set(0)
18593 AD5626SerialStatus = IntVar(0)
18594 AD5626SerialStatus.set(0)
18595 DigFiltStatus = IntVar(0)
18596 DigFiltStatus.set(0)
18597 CommandStatus = IntVar(0)
18598 CommandStatus.set(0)
18599 MeasureStatus = IntVar(0)
18600 MeasureStatus.set(0)
18601 MarkerScale = IntVar(0)
18602 MarkerScale.set(1)
18603 SettingsStatus = IntVar(0)
18604 CHA_RC_HP = IntVar(0)
18605 CHB_RC_HP = IntVar(0)
18606 #
18607 frame2r = Frame(root, borderwidth=5, relief=RIDGE)
18608 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
18609 
18610 frame1 = Frame(root, borderwidth=5, relief=RIDGE)
18611 frame1.pack(side=TOP, fill=BOTH, expand=NO)
18612 
18613 frame2 = Frame(root, borderwidth=5, relief=RIDGE)
18614 frame2.pack(side=TOP, fill=BOTH, expand=YES)
18615 
18616 frame3 = Frame(root, borderwidth=5, relief=RIDGE)
18617 frame3.pack(side=TOP, fill=BOTH, expand=NO)
18618 # define custom buttons
18619 root.style.configure("W3.TButton", width=3, relief=RAISED)
18620 root.style.configure("W4.TButton", width=4, relief=RAISED)
18621 root.style.configure("W5.TButton", width=5, relief=RAISED)
18622 root.style.configure("W7.TButton", width=7, relief=RAISED)
18623 root.style.configure("W8.TButton", width=8, relief=RAISED)
18624 root.style.configure("W9.TButton", width=9, relief=RAISED)
18625 root.style.configure("W10.TButton", width=10, relief=RAISED)
18626 root.style.configure("W11.TButton", width=11, relief=RAISED)
18627 root.style.configure("W16.TButton", width=16, relief=RAISED)
18628 root.style.configure("W17.TButton", width=17, relief=RAISED)
18629 root.style.configure("Stop.TButton", background="red", width=4, relief=RAISED)
18630 root.style.configure("Run.TButton", background="green", width=4, relief=RAISED)
18631 root.style.configure("Pwr.TButton", background="green", width=7, relief=RAISED)
18632 root.style.configure("PwrOff.TButton", background="red", width=7, relief=RAISED)
18633 root.style.configure("RConn.TButton", background="red", width=5, relief=RAISED)
18634 root.style.configure("GConn.TButton", background="green", width=5, relief=RAISED)
18635 root.style.configure("Rtrace1.TButton", background=COLORtrace1, width=7, relief=RAISED)
18636 root.style.configure("Strace1.TButton", background=COLORtrace1, width=7, relief=SUNKEN)
18637 root.style.configure("Rtrace2.TButton", background=COLORtrace2, width=7, relief=RAISED)
18638 root.style.configure("Strace2.TButton", background=COLORtrace2, width=7, relief=SUNKEN)
18639 root.style.configure("Rtrace3.TButton", background=COLORtrace3, width=7, relief=RAISED)
18640 root.style.configure("Strace3.TButton", background=COLORtrace3, width=7, relief=SUNKEN)
18641 root.style.configure("Rtrace4.TButton", background=COLORtrace4, width=7, relief=RAISED)
18642 root.style.configure("Strace4.TButton", background=COLORtrace4, width=7, relief=SUNKEN)
18643 root.style.configure("Rtrace6.TButton", background=COLORtrace6, width=7, relief=RAISED)
18644 root.style.configure("Strace6.TButton", background=COLORtrace6, width=7, relief=SUNKEN)
18645 root.style.configure("Rtrace7.TButton", background=COLORtrace7, width=7, relief=RAISED)
18646 root.style.configure("Strace7.TButton", background=COLORtrace7, width=7, relief=SUNKEN)
18647 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
18648 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
18649 root.style.configure("A10R1.TLabelframe.Label", foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
18650 root.style.configure("A10R1.TLabelframe", borderwidth=5, relief=RIDGE)
18651 root.style.configure("A10R2.TLabelframe.Label", foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
18652 root.style.configure("A10R2.TLabelframe", borderwidth=5, relief=RIDGE)
18653 root.style.configure("A10B.TLabel", foreground=COLORcanvas, font="Arial 10 bold") # Black text
18654 root.style.configure("A10R.TLabel", foreground="red", font="Arial 10 bold") # Red text
18655 root.style.configure("A10G.TLabel", foreground="green", font="Arial 10 bold") # Red text
18656 root.style.configure("A12B.TLabel", foreground=COLORcanvas, font="Arial 12 bold") # Black text
18657 root.style.configure("A16B.TLabel", foreground=COLORcanvas, font="Arial 16 bold") # Black text
18658 root.style.configure("Stop.TRadiobutton", background="red")
18659 root.style.configure("Run.TRadiobutton", background="green")
18660 root.style.configure("Disab.TCheckbutton", indicatorcolor="red")
18661 root.style.configure("Enab.TCheckbutton", indicatorcolor="green")
18662 root.style.configure("WPhase.TRadiobutton", width=5, background="white", indicatorcolor=("red", "green"))
18663 root.style.configure("GPhase.TRadiobutton", width=5, background="gray", indicatorcolor=("red", "green"))
18664 # create a pulldown menu
18665 # Trigger signals
18666 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
18667 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
18668 Triggermenu["menu"] = Triggermenu.menu
18669 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
18670 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
18671 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
18672 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
18673 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
18674 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
18675 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
18676 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
18677 Triggermenu.pack(side=LEFT)
18678 #
18679 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
18680 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
18681 Edgemenu["menu"] = Edgemenu.menu
18682 Edgemenu.menu.add_radiobutton(label='Rising [+]', variable=TgEdge, value=0)
18683 Edgemenu.menu.add_radiobutton(label='Falling [-]', variable=TgEdge, value=1)
18684 Edgemenu.pack(side=LEFT)
18685 #
18686 tlab = Label(frame1, text="Trig Level")
18687 tlab.pack(side=LEFT)
18688 TRIGGERentry = Entry(frame1, width=5)
18689 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
18690 TRIGGERentry.bind("<Return>", BTriglevel)
18691 TRIGGERentry.bind('<Key>', onTextKey)
18692 TRIGGERentry.pack(side=LEFT)
18693 TRIGGERentry.delete(0,"end")
18694 TRIGGERentry.insert(0,0.0)
18695 #
18696 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
18697 tgb.pack(side=LEFT)
18698 #
18699 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
18700 hldlab.pack(side=LEFT)
18701 HoldOffentry = Entry(frame1, width=4)
18702 HoldOffentry.bind('<MouseWheel>', onTextScroll)
18703 HoldOffentry.bind("<Return>", BHoldOff)
18704 HoldOffentry.bind('<Key>', onTextKey)
18705 HoldOffentry.pack(side=LEFT)
18706 HoldOffentry.delete(0,"end")
18707 HoldOffentry.insert(0,0.0)
18708 #
18709 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
18710 hozlab.pack(side=LEFT)
18711 HozPossentry = Entry(frame1, width=4)
18712 HozPossentry.bind('<MouseWheel>', onTextScroll)
18713 HozPossentry.bind("<Return>", BHozPoss)
18714 HozPossentry.bind('<Key>', onTextKey)
18715 HozPossentry.pack(side=LEFT)
18716 HozPossentry.delete(0,"end")
18717 HozPossentry.insert(0,0.0)
18718 #
18719 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
18720 bexit.pack(side=RIGHT)
18721 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
18722 bstop.pack(side=RIGHT)
18723 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
18724 brun.pack(side=RIGHT)
18725 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
18726 PwrBt.pack(side=RIGHT)
18727 # Curves Menu
18728 Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
18729 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
18730 Showmenu["menu"] = Showmenu.menu
18731 Showmenu.menu.add_command(label="-Show-", foreground="blue", command=donothing)
18732 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
18733 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
18734 Showmenu.menu.add_checkbutton(label='CA-V [1]', variable=ShowC1_V, command=TraceSelectADC_Mux)
18735 Showmenu.menu.add_checkbutton(label='CA-I [3]', variable=ShowC1_I, command=TraceSelectADC_Mux)
18736 Showmenu.menu.add_checkbutton(label='CB-V [2]', variable=ShowC2_V, command=TraceSelectADC_Mux)
18737 Showmenu.menu.add_checkbutton(label='CB-I [4]', variable=ShowC2_I, command=TraceSelectADC_Mux)
18738 Showmenu.menu.add_checkbutton(label='Math-X', variable=Show_MathX, command=UpdateTimeTrace)
18739 Showmenu.menu.add_checkbutton(label='Math-Y', variable=Show_MathY, command=UpdateTimeTrace)
18740 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
18741 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
18742 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
18743 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
18744 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
18745 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
18746 Showmenu.menu.add_separator()
18747 Showmenu.menu.add_checkbutton(label='RA-V', variable=ShowRA_V, command=UpdateTimeTrace)
18748 Showmenu.menu.add_checkbutton(label='RA-I', variable=ShowRA_I, command=UpdateTimeTrace)
18749 Showmenu.menu.add_checkbutton(label='RB-V', variable=ShowRB_V, command=UpdateTimeTrace)
18750 Showmenu.menu.add_checkbutton(label='RB-I', variable=ShowRB_I, command=UpdateTimeTrace)
18751 Showmenu.menu.add_checkbutton(label='RMath', variable=ShowMath, command=UpdateTimeTrace)
18752 Showmenu.menu.add_separator()
18753 Showmenu.menu.add_checkbutton(label='T Cursor [t]', variable=ShowTCur, command=UpdateTimeTrace)
18754 Showmenu.menu.add_checkbutton(label='V Cursor [v]', variable=ShowVCur, command=UpdateTimeTrace)
18755 Showmenu.pack(side=RIGHT)
18756 #
18757 if ShowBallonHelp > 0:
18758  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
18759  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
18760  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
18761  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
18762  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
18763  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
18764  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
18765  brun_tip = CreateToolTip(brun, 'Start acquiring data')
18766  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
18767  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
18768 
18769 # Sampling controls Widgets
18770 if EnableHSsampling > 0:
18771  fminlab2 = Label(frame1, text="KHz")
18772  fminlab2.pack(side=RIGHT)
18773  FminEntry = Entry(frame1, width=4)
18774  FminEntry.bind('<MouseWheel>', onFminScroll)
18775  FminEntry.bind("<Return>", SetAD9833)
18776  FminEntry.pack(side=RIGHT)
18777  FminEntry.delete(0,"end")
18778  FminEntry.insert(0,25)
18779  fminlab = Label(frame1, text="Fmin")
18780  fminlab.pack(side=RIGHT)
18781  #
18782  HtMulEntry = Entry(frame1, width=4)
18783  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
18784  HtMulEntry.bind("<Return>", SetAD9833)
18785  HtMulEntry.pack(side=RIGHT)
18786  HtMulEntry.delete(0,"end")
18787  HtMulEntry.insert(0,1)
18788  mulxlab = Label( frame1, text = "Mul X")
18789  mulxlab.pack(side=RIGHT)
18790 #
18791 # Time per Div
18792 TMsb = Spinbox(frame1, width=5, values= TMpdiv, command=BTime)
18793 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
18794 TMsb.pack(side=RIGHT)
18795 TMsb.delete(0,"end")
18796 TMsb.insert(0,0.5)
18797 TMlab = Label(frame1, text="Time mS/Div")
18798 TMlab.pack(side=RIGHT)
18799 #
18800 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
18801 # add mouse left and right button click to canvas
18802 ca.bind('<Configure>', CAresize)
18803 ca.bind('<1>', onCanvasClickLeft)
18804 ca.bind('<3>', onCanvasClickRight)
18805 ca.bind("<Motion>",onCanvasMouse_xy)
18806 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
18807 ca.bind("<Down>", onCanvasDownArrow)
18808 ca.bind("<Left>", onCanvasLeftArrow)
18809 ca.bind("<Right>", onCanvasRightArrow)
18810 ca.bind("<space>", onCanvasSpaceBar)
18811 ca.bind("1", onCanvasOne)
18812 ca.bind("2", onCanvasTwo)
18813 ca.bind("3", onCanvasThree)
18814 ca.bind("4", onCanvasFour)
18815 ca.bind("5", onCanvasFive)
18816 ca.bind("6", onCanvasSix)
18817 ca.bind("7", onCanvasSeven)
18818 ca.bind("8", onCanvasEight)
18819 ca.bind("9", onCanvasNine)
18820 ca.bind("0", onCanvasZero)
18821 ca.bind("a", onCanvasAverage)
18822 ca.bind("t", onCanvasShowTcur)
18823 ca.bind("v", onCanvasShowVcur)
18824 ca.bind("s", onCanvasSnap)
18825 ca.bind("+", onCanvasTrising)
18826 ca.bind("-", onCanvasTfalling)
18827 # ca.bind('<MouseWheel>', onCanvasClickScroll)
18828 ca.pack(side=TOP, fill=BOTH, expand=YES)
18829 MouseWidget = ca
18830 # right side menu buttons
18831 dropmenu = Frame( frame2r )
18832 dropmenu.pack(side=TOP)
18833 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
18834 bcon.pack(side=LEFT, anchor=W)
18835 # File menu
18836 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
18837 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
18838 Filemenu["menu"] = Filemenu.menu
18839 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
18840 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
18841 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
18842 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
18843 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
18844 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
18845 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
18846 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
18847 Filemenu.menu.add_command(label="Help", command=BHelp)
18848 Filemenu.menu.add_command(label="About", command=BAbout)
18849 Filemenu.pack(side=LEFT, anchor=W)
18850 # Options Menu
18851 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
18852 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
18853 Optionmenu["menu"] = Optionmenu.menu
18854 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
18855 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
18856 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
18857 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
18858 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
18859 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
18860 Optionmenu.menu.add_checkbutton(label='Trace Avg [a]', variable=TRACEmodeTime)
18861 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
18862 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
18863 Optionmenu.menu.add_command(label="SnapShot [s]", command=BSnapShot)
18864 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
18865 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
18866 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
18867 if AllowFlashFirmware == 1:
18868  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
18869  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
18870 Optionmenu.pack(side=LEFT, anchor=W)
18871 #
18872 dropmenu2 = Frame( frame2r )
18873 dropmenu2.pack(side=TOP)
18874 # Open Math trace menu
18875 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
18876 mathbt.pack(side=RIGHT, anchor=W)
18877 # Measurments menu
18878 measlab = Label(dropmenu2, text="Meas")
18879 measlab.pack(side=LEFT, anchor=W)
18880 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
18881 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
18882 MeasmenuA["menu"] = MeasmenuA.menu
18883 MeasmenuA.menu.add_command(label="-CA-V-", command=donothing)
18884 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
18885 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
18886 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
18887 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
18888 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
18889 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
18890 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
18891 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
18892 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
18893 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
18894 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
18895 MeasmenuA.menu.add_separator()
18896 #
18897 MeasmenuA.menu.add_command(label="-CA-I-", command=donothing)
18898 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
18899 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
18900 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
18901 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
18902 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
18903 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
18904 MeasmenuA.menu.add_separator()
18905 #
18906 MeasmenuA.menu.add_command(label="CA-Time", command=donothing)
18907 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
18908 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
18909 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
18910 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
18911 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
18912 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
18913 #
18914 MeasmenuA.pack(side=LEFT)
18915 #
18916 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
18917 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
18918 MeasmenuB["menu"] = MeasmenuB.menu
18919 MeasmenuB.menu.add_command(label="-CB-V-", command=donothing)
18920 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
18921 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
18922 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
18923 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
18924 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
18925 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
18926 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
18927 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
18928 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
18929 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
18930 MeasmenuB.menu.add_separator()
18931 #
18932 MeasmenuB.menu.add_command(label="-CB-I-", command=donothing)
18933 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
18934 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
18935 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
18936 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
18937 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
18938 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
18939 MeasmenuB.menu.add_separator()
18940 #
18941 MeasmenuB.menu.add_command(label="CB-Time", command=donothing)
18942 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
18943 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
18944 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
18945 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
18946 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
18947 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
18948 MeasmenuB.pack(side=LEFT)
18949 #
18950 BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
18951 BuildAWGScreen.pack(side=TOP)
18952 # Mode selector
18953 timebtn = Frame( frame2r )
18954 timebtn.pack(side=TOP)
18955 ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
18956 ckb1.pack(side=LEFT)
18957 timelab = Label(timebtn, text="Time Plot")
18958 timelab.pack(side=LEFT)
18959 xybtn = Frame( frame2r )
18960 xybtn.pack(side=TOP)
18961 ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
18962 ckb2.pack(side=LEFT)
18963 BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
18964 BuildXYScreen.pack(side=TOP)
18965 #
18966 freqbtn = Frame( frame2r )
18967 freqbtn.pack(side=TOP)
18968 ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
18969 ckb3.pack(side=LEFT)
18970 BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
18971 BuildSpectrumScreen.pack(side=LEFT)
18972 #
18973 bodebtn = Frame( frame2r )
18974 bodebtn.pack(side=TOP)
18975 ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
18976 ckb5.pack(side=LEFT)
18977 BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
18978 BuildBodeScreen.pack(side=LEFT)
18979 #
18980 impdbtn = Frame( frame2r )
18981 impdbtn.pack(side=TOP)
18982 ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
18983 ckb4.pack(side=LEFT)
18984 BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
18985 BuildIAScreen.pack(side=LEFT)
18986 #
18987 dcohmbtn = Frame( frame2r )
18988 dcohmbtn.pack(side=TOP)
18989 ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
18990 ckb6.pack(side=LEFT)
18991 BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
18992 BuildOhmScreen.pack(side=LEFT)
18993 if ShowBallonHelp > 0:
18994  math_tip = CreateToolTip(mathbt, 'Open Math window')
18995  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
18996  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
18997  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open spectrum analyzer window')
18998  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
18999  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance analyzer window')
19000  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
19001 # Digital Input / Output Option screens
19002 DigScreenStatus = IntVar(0)
19003 DigScreenStatus.set(0)
19004 BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
19005 BuildDigScreen.pack(side=TOP)
19006 #
19007 # Optional plugin tools
19008 if EnablePIODACMode > 0:
19009  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
19010  BuildDacScreen.pack(side=TOP)
19011 if EnableMuxMode > 0:
19012  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
19013  BuildMuxScreen.pack(side=TOP)
19014 if EnableMinigenMode > 0:
19015  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
19016  BuildMinigenScreen.pack(side=TOP)
19017 if EnablePmodDA1Mode > 0:
19018  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
19019  BuildDA1Screen.pack(side=TOP)
19020 if EnableDigPotMode >0:
19021  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
19022  BuildDigPotScreen.pack(side=TOP)
19023 if EnableGenericSerialMode >0:
19024  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
19025  GenericSerialScreen.pack(side=TOP)
19026 if EnableAD5626SerialMode >0:
19027  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
19028  AD5626SerialScreen.pack(side=TOP)
19029 if EnableDigitalFilter >0:
19030  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
19031  DigFiltScreen.pack(side=TOP)
19032 if EnableCommandInterface > 0:
19033  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
19034  CommandLineScreen.pack(side=TOP)
19035 if EnableMeasureScreen > 0:
19036  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
19037  MeasureScreen.pack(side=TOP)
19038 if EnableETSScreen > 0:
19039  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
19040  ETSScreen.pack(side=TOP)
19041 # input probe wigets
19042 prlab = Label(frame2r, text="Adjust Gain / Offset")
19043 prlab.pack(side=TOP)
19044 # Input Probes sub frame
19045 ProbeA = Frame( frame2r )
19046 ProbeA.pack(side=TOP)
19047 gain1lab = Label(ProbeA, text="CA-V")
19048 gain1lab.pack(side=LEFT)
19049 CHAVGainEntry = Entry(ProbeA, width=5)
19050 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
19051 CHAVGainEntry.bind('<Key>', onTextKey)
19052 CHAVGainEntry.pack(side=LEFT)
19053 CHAVGainEntry.delete(0,"end")
19054 CHAVGainEntry.insert(0,1.0)
19055 CHAVOffsetEntry = Entry(ProbeA, width=5)
19056 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
19057 CHAVOffsetEntry.bind('<Key>', onTextKey)
19058 CHAVOffsetEntry.pack(side=LEFT)
19059 CHAVOffsetEntry.delete(0,"end")
19060 CHAVOffsetEntry.insert(0,0.0)
19061 #
19062 ProbeB = Frame( frame2r )
19063 ProbeB.pack(side=TOP)
19064 gain2lab = Label(ProbeB, text="CB-V")
19065 gain2lab.pack(side=LEFT)
19066 CHBVGainEntry = Entry(ProbeB, width=5)
19067 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
19068 CHBVGainEntry.bind('<Key>', onTextKey)
19069 CHBVGainEntry.pack(side=LEFT)
19070 CHBVGainEntry.delete(0,"end")
19071 CHBVGainEntry.insert(0,1.0)
19072 CHBVOffsetEntry = Entry(ProbeB, width=5)
19073 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
19074 CHBVOffsetEntry.bind('<Key>', onTextKey)
19075 CHBVOffsetEntry.pack(side=LEFT)
19076 CHBVOffsetEntry.delete(0,"end")
19077 CHBVOffsetEntry.insert(0,0.0)
19078 #
19079 ProbeAI = Frame( frame2r )
19080 ProbeAI.pack(side=TOP)
19081 gainailab = Label(ProbeAI, text="CA-I")
19082 gainailab.pack(side=LEFT)
19083 CHAIGainEntry = Entry(ProbeAI, width=5)
19084 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
19085 CHAIGainEntry.bind('<Key>', onTextKey)
19086 CHAIGainEntry.pack(side=LEFT)
19087 CHAIGainEntry.delete(0,"end")
19088 CHAIGainEntry.insert(0,1.0)
19089 CHAIOffsetEntry = Entry(ProbeAI, width=5)
19090 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
19091 CHAIOffsetEntry.bind('<Key>', onTextKey)
19092 CHAIOffsetEntry.pack(side=LEFT)
19093 CHAIOffsetEntry.delete(0,"end")
19094 CHAIOffsetEntry.insert(0,0.0)
19095 #
19096 ProbeBI = Frame( frame2r )
19097 ProbeBI.pack(side=TOP)
19098 gainbilab = Label(ProbeBI, text="CB-I")
19099 gainbilab.pack(side=LEFT)
19100 CHBIGainEntry = Entry(ProbeBI, width=5)
19101 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
19102 CHBIGainEntry.bind('<Key>', onTextKey)
19103 CHBIGainEntry.pack(side=LEFT)
19104 CHBIGainEntry.delete(0,"end")
19105 CHBIGainEntry.insert(0,1.0)
19106 CHBIOffsetEntry = Entry(ProbeBI, width=5)
19107 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
19108 CHBIOffsetEntry.bind('<Key>', onTextKey)
19109 CHBIOffsetEntry.pack(side=LEFT)
19110 CHBIOffsetEntry.delete(0,"end")
19111 CHBIOffsetEntry.insert(0,0.0)
19112 # add ADI logo Don't mess with this bit map data!
19113 ADIlogo = """
19114 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
19115 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
19116 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
19117 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
19118 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
19119 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
19120 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
19121 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
19122 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
19123 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
19124 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
19125 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
19126 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
19127 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
19128 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
19129 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
19130 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
19131 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
19132 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
19133 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
19134 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
19135 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
19136 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
19137 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
19138 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
19139 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
19140 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
19141 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
19142 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
19143 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
19144 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
19145 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
19146 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
19147 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
19148 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
19149 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
19150 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
19151 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
19152 """
19153 logo = PhotoImage(data=ADIlogo)
19154 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
19155 ADI1.pack(side=TOP)
19156 
19157 # Bottom Buttons
19158 # Voltage channel A
19159 CHAsb = Spinbox(frame3, width=4, values=CHvpdiv, command=BCHAlevel)
19160 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
19161 CHAsb.pack(side=LEFT)
19162 CHAsb.delete(0,"end")
19163 CHAsb.insert(0,0.5)
19164 #
19165 CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
19166 CHAlab.pack(side=LEFT)
19167 
19168 CHAVPosEntry = Entry(frame3, width=5)
19169 CHAVPosEntry.bind("<Return>", BOffsetA)
19170 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)
19171 CHAVPosEntry.bind('<Key>', onTextKey)
19172 CHAVPosEntry.pack(side=LEFT)
19173 CHAVPosEntry.delete(0,"end")
19174 CHAVPosEntry.insert(0,2.5)
19175 CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
19176 CHAofflab.pack(side=LEFT)
19177 # Current channel A
19178 CHAIsb = Spinbox(frame3, width=4, values=CHipdiv, command=BCHAIlevel)
19179 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
19180 CHAIsb.pack(side=LEFT)
19181 CHAIsb.delete(0,"end")
19182 CHAIsb.insert(0,50.0)
19183 CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
19184 CHAIlab.pack(side=LEFT)
19185 
19186 CHAIPosEntry = Entry(frame3, width=5)
19187 CHAIPosEntry.bind("<Return>", BIOffsetA)
19188 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)
19189 CHAIPosEntry.bind('<Key>', onTextKey)
19190 CHAIPosEntry.pack(side=LEFT)
19191 CHAIPosEntry.delete(0,"end")
19192 CHAIPosEntry.insert(0,0.0)
19193 CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
19194 CHAIofflab.pack(side=LEFT)
19195 # Voltage channel B
19196 CHBsb = Spinbox(frame3, width=4, values=CHvpdiv, command=BCHBlevel)
19197 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
19198 CHBsb.pack(side=LEFT)
19199 CHBsb.delete(0,"end")
19200 CHBsb.insert(0,0.5)
19201 #
19202 CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
19203 CHBlab.pack(side=LEFT)
19204 
19205 CHBVPosEntry = Entry(frame3, width=5)
19206 CHBVPosEntry.bind("<Return>", BOffsetB)
19207 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)
19208 CHBVPosEntry.bind('<Key>', onTextKey)
19209 CHBVPosEntry.pack(side=LEFT)
19210 CHBVPosEntry.delete(0,"end")
19211 CHBVPosEntry.insert(0,2.5)
19212 CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
19213 CHBofflab.pack(side=LEFT)
19214 # Current channel B
19215 CHBIsb = Spinbox(frame3, width=4, values=CHipdiv, command=BCHBIlevel)
19216 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
19217 CHBIsb.pack(side=LEFT)
19218 CHBIsb.delete(0,"end")
19219 CHBIsb.insert(0,50.0)
19220 CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
19221 CHBIlab.pack(side=LEFT)
19222 
19223 CHBIPosEntry = Entry(frame3, width=5)
19224 CHBIPosEntry.bind("<Return>", BIOffsetB)
19225 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)
19226 CHBIPosEntry.bind('<Key>', onTextKey)
19227 CHBIPosEntry.pack(side=LEFT)
19228 CHBIPosEntry.delete(0,"end")
19229 CHBIPosEntry.insert(0,0.0)
19230 CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
19231 CHBIofflab.pack(side=LEFT)
19232 #
19233 if ShowBallonHelp > 0:
19234  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
19235  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
19236  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
19237  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
19238  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
19239  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
19240  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
19241  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
19242 #
19243 root.geometry('+300+0')
19244 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
19245 #===== Initalize device ======
19246 if not numpy_found:
19247  root.update()
19248  showwarning("WARNING","Numpy not found!")
19249  root.destroy()
19250  exit()
19251 #
19252 BrdSel = IntVar(0)
19253 BoardStatus = IntVar(0)
19254 if pysmu_found:
19255  ConnectDevice()
19256  #session.hotplug_attach(ConnectDevice)
19257  #session.hotplug_detach(ConnectDevice)
19258  MakeAWGWindow() # always build AWG window
19259  BLoadConfig("alice-last-config.cfg") # load configuration from last session
19260 # ================ Call main routine ===============================
19261  root.update() # Activate updated screens
19262 #
19263 # Start sampling
19264  Analog_In()
19265 else:
19266  root.update()
19267  showwarning("WARNING","Pysmu not found!")
19268  root.destroy()
19269  exit()
19270 
alice-HS-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-HS-desktop-1.3.pyw:669
alice-HS-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-HS-desktop-1.3.pyw:1714
alice-HS-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-HS-desktop-1.3.pyw:8575
alice-HS-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-HS-desktop-1.3.pyw:17410
alice-HS-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-HS-desktop-1.3.pyw:16955
alice-HS-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-HS-desktop-1.3.pyw:2568
alice-HS-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-HS-desktop-1.3.pyw:8920
alice-HS-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-HS-desktop-1.3.pyw:14927
alice-HS-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-HS-desktop-1.3.pyw:16877
alice-HS-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-HS-desktop-1.3.pyw:18309
alice-HS-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-HS-desktop-1.3.pyw:11327
alice-HS-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Definition: alice-HS-desktop-1.3.pyw:7567
alice-HS-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-HS-desktop-1.3.pyw:1697
alice-HS-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-HS-desktop-1.3.pyw:2849
alice-HS-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-HS-desktop-1.3.pyw:2579
alice-HS-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-HS-desktop-1.3.pyw:17954
alice-HS-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-HS-desktop-1.3.pyw:14174
alice-HS-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-HS-desktop-1.3.pyw:17946
alice-HS-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-HS-desktop-1.3.pyw:10001
alice-HS-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-HS-desktop-1.3.pyw:16596
alice-HS-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-HS-desktop-1.3.pyw:2100
alice-HS-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-HS-desktop-1.3.pyw:14896
alice-HS-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-HS-desktop-1.3.pyw:11066
alice-HS-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-HS-desktop-1.3.pyw:11804
alice-HS-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-HS-desktop-1.3.pyw:15267
alice-HS-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-HS-desktop-1.3.pyw:10378
alice-HS-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-HS-desktop-1.3.pyw:11085
alice-HS-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-HS-desktop-1.3.pyw:2532
alice-HS-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-HS-desktop-1.3.pyw:17125
alice-HS-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-HS-desktop-1.3.pyw:14072
alice-HS-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-HS-desktop-1.3.pyw:14202
alice-HS-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-HS-desktop-1.3.pyw:11275
alice-HS-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-HS-desktop-1.3.pyw:9647
alice-HS-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-HS-desktop-1.3.pyw:3711
alice-HS-desktop-1.BHelp
def BHelp()
Open User Guide in Browser open a URL, in this case, the ALICE desk-top-users-guide.
Definition: alice-HS-desktop-1.3.pyw:1537
alice-HS-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-HS-desktop-1.3.pyw:10735
alice-HS-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-HS-desktop-1.3.pyw:2331
alice-HS-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-HS-desktop-1.3.pyw:2178
alice-HS-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-HS-desktop-1.3.pyw:11351
alice-HS-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-HS-desktop-1.3.pyw:13740
alice-HS-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-HS-desktop-1.3.pyw:10115
alice-HS-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-HS-desktop-1.3.pyw:2554
alice-HS-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-HS-desktop-1.3.pyw:14306
alice-HS-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-HS-desktop-1.3.pyw:1434
alice-HS-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-HS-desktop-1.3.pyw:10661
alice-HS-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-HS-desktop-1.3.pyw:17254
alice-HS-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-HS-desktop-1.3.pyw:2196
alice-HS-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-HS-desktop-1.3.pyw:17047
alice-HS-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-HS-desktop-1.3.pyw:14245
alice-HS-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-HS-desktop-1.3.pyw:13885
alice-HS-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-HS-desktop-1.3.pyw:16358
alice-HS-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-HS-desktop-1.3.pyw:11114
alice-HS-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-HS-desktop-1.3.pyw:13010
alice-HS-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-HS-desktop-1.3.pyw:14318
alice-HS-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-HS-desktop-1.3.pyw:17671
alice-HS-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-HS-desktop-1.3.pyw:14081
alice-HS-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-HS-desktop-1.3.pyw:8037
alice-HS-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-HS-desktop-1.3.pyw:16729
alice-HS-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-HS-desktop-1.3.pyw:5907
alice-HS-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-HS-desktop-1.3.pyw:9247
alice-HS-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-HS-desktop-1.3.pyw:17201
alice-HS-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-HS-desktop-1.3.pyw:10759
alice-HS-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-HS-desktop-1.3.pyw:11257
alice-HS-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-HS-desktop-1.3.pyw:1976
alice-HS-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-HS-desktop-1.3.pyw:16514
alice-HS-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-HS-desktop-1.3.pyw:10056
alice-HS-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-HS-desktop-1.3.pyw:2073
alice-HS-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Definition: alice-HS-desktop-1.3.pyw:7693
alice-HS-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-HS-desktop-1.3.pyw:15527
alice-HS-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-HS-desktop-1.3.pyw:14238
alice-HS-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-HS-desktop-1.3.pyw:9583
alice-HS-desktop-1.sel1
def sel1(temp)
Definition: alice-HS-desktop-1.3.pyw:4475
alice-HS-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-HS-desktop-1.3.pyw:9845
alice-HS-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-HS-desktop-1.3.pyw:8042
alice-HS-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-HS-desktop-1.3.pyw:14235
alice-HS-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-HS-desktop-1.3.pyw:1367
alice-HS-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-HS-desktop-1.3.pyw:9620
alice-HS-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-HS-desktop-1.3.pyw:13339
alice-HS-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-HS-desktop-1.3.pyw:2039
alice-HS-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-HS-desktop-1.3.pyw:2142
alice-HS-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-HS-desktop-1.3.pyw:14908
alice-HS-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-HS-desktop-1.3.pyw:8004
alice-HS-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-HS-desktop-1.3.pyw:2013
alice-HS-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-HS-desktop-1.3.pyw:14048
alice-HS-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-HS-desktop-1.3.pyw:662
alice-HS-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-HS-desktop-1.3.pyw:16552
alice-HS-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-HS-desktop-1.3.pyw:1206
alice-HS-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-HS-desktop-1.3.pyw:7485
alice-HS-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-HS-desktop-1.3.pyw:1183
alice-HS-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-HS-desktop-1.3.pyw:1468
alice-HS-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-HS-desktop-1.3.pyw:17881
alice-HS-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-HS-desktop-1.3.pyw:703
alice-HS-desktop-1.BStartBP
def BStartBP()
Definition: alice-HS-desktop-1.3.pyw:11125
alice-HS-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-HS-desktop-1.3.pyw:9411
alice-HS-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-HS-desktop-1.3.pyw:679
alice-HS-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-HS-desktop-1.3.pyw:9960
alice-HS-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-HS-desktop-1.3.pyw:1348
alice-HS-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-HS-desktop-1.3.pyw:9727
alice-HS-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-HS-desktop-1.3.pyw:2451
alice-HS-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-HS-desktop-1.3.pyw:13334
alice-HS-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-HS-desktop-1.3.pyw:11294
alice-HS-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-HS-desktop-1.3.pyw:4596
alice-HS-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-HS-desktop-1.3.pyw:1451
alice-HS-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-HS-desktop-1.3.pyw:17661
alice-HS-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-HS-desktop-1.3.pyw:8072
alice-HS-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-HS-desktop-1.3.pyw:8532
alice-HS-desktop-1.CreateToolTip.widget
widget
Definition: alice-HS-desktop-1.3.pyw:654
alice-HS-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digitla I/O screen.
Definition: alice-HS-desktop-1.3.pyw:4329
alice-HS-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-HS-desktop-1.3.pyw:9810
alice-HS-desktop-1.BStepSync
def BStepSync()
Definition: alice-HS-desktop-1.3.pyw:14917
alice-HS-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-HS-desktop-1.3.pyw:9678
alice-HS-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-HS-desktop-1.3.pyw:13853
alice-HS-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-HS-desktop-1.3.pyw:10769
alice-HS-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-HS-desktop-1.3.pyw:17590
alice-HS-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-HS-desktop-1.3.pyw:11336
alice-HS-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-HS-desktop-1.3.pyw:2154
alice-HS-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-HS-desktop-1.3.pyw:2214
alice-HS-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-HS-desktop-1.3.pyw:14051
alice-HS-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-HS-desktop-1.3.pyw:14028
alice-HS-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-HS-desktop-1.3.pyw:10820
alice-HS-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-HS-desktop-1.3.pyw:4207
alice-HS-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-HS-desktop-1.3.pyw:10671
alice-HS-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-HS-desktop-1.3.pyw:1195
alice-HS-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-HS-desktop-1.3.pyw:7996
alice-HS-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-HS-desktop-1.3.pyw:1962
alice-HS-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-HS-desktop-1.3.pyw:1891
alice-HS-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-HS-desktop-1.3.pyw:2561
alice-HS-desktop-1.donothing
def donothing()
Nop.
Definition: alice-HS-desktop-1.3.pyw:1985
alice-HS-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-HS-desktop-1.3.pyw:9863
alice-HS-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-HS-desktop-1.3.pyw:8027
alice-HS-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-HS-desktop-1.3.pyw:14188
alice-HS-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-HS-desktop-1.3.pyw:13320
alice-HS-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-HS-desktop-1.3.pyw:2481
alice-HS-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-HS-desktop-1.3.pyw:16688
alice-HS-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-HS-desktop-1.3.pyw:16507
alice-HS-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-HS-desktop-1.3.pyw:8356
alice-HS-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-HS-desktop-1.3.pyw:18062
alice-HS-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-HS-desktop-1.3.pyw:9900
alice-HS-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-HS-desktop-1.3.pyw:15757
alice-HS-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-HS-desktop-1.3.pyw:17147
alice-HS-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-HS-desktop-1.3.pyw:1589
alice-HS-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-HS-desktop-1.3.pyw:13876
alice-HS-desktop-1.CreateToolTip.id
id
Definition: alice-HS-desktop-1.3.pyw:659
alice-HS-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-HS-desktop-1.3.pyw:17129
alice-HS-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-HS-desktop-1.3.pyw:8052
alice-HS-desktop-1.sel2
def sel2(temp)
Definition: alice-HS-desktop-1.3.pyw:4508
alice-HS-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-HS-desktop-1.3.pyw:8237
alice-HS-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-HS-desktop-1.3.pyw:10715
alice-HS-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-HS-desktop-1.3.pyw:1342
alice-HS-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-HS-desktop-1.3.pyw:15277
alice-HS-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-HS-desktop-1.3.pyw:10695
alice-HS-desktop-1.MGLoad
def MGLoad()
Definition: alice-HS-desktop-1.3.pyw:18048
alice-HS-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-HS-desktop-1.3.pyw:2226
alice-HS-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-HS-desktop-1.3.pyw:18487
alice-HS-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-HS-desktop-1.3.pyw:2461
alice-HS-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-HS-desktop-1.3.pyw:8417
alice-HS-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-HS-desktop-1.3.pyw:11266
alice-HS-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-HS-desktop-1.3.pyw:3673
alice-HS-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-HS-desktop-1.3.pyw:14322
alice-HS-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-HS-desktop-1.3.pyw:18314
alice-HS-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-HS-desktop-1.3.pyw:10674
alice-HS-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-HS-desktop-1.3.pyw:10865
alice-HS-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-HS-desktop-1.3.pyw:2260
alice-HS-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-HS-desktop-1.3.pyw:7980
alice-HS-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-HS-desktop-1.3.pyw:1991
alice-HS-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-HS-desktop-1.3.pyw:14223
alice-HS-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-HS-desktop-1.3.pyw:14252
alice-HS-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-HS-desktop-1.3.pyw:4621
alice-HS-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-HS-desktop-1.3.pyw:8399
alice-HS-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-HS-desktop-1.3.pyw:8290
alice-HS-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-HS-desktop-1.3.pyw:12383
alice-HS-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-HS-desktop-1.3.pyw:653
alice-HS-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-HS-desktop-1.3.pyw:14389
alice-HS-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-HS-desktop-1.3.pyw:7473
alice-HS-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-HS-desktop-1.3.pyw:1969
alice-HS-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-HS-desktop-1.3.pyw:2546
alice-HS-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-HS-desktop-1.3.pyw:16501
alice-HS-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-HS-desktop-1.3.pyw:7461
alice-HS-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-HS-desktop-1.3.pyw:14003
alice-HS-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-HS-desktop-1.3.pyw:10516
alice-HS-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-HS-desktop-1.3.pyw:10312
alice-HS-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-HS-desktop-1.3.pyw:8223
alice-HS-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-HS-desktop-1.3.pyw:8581
alice-HS-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-HS-desktop-1.3.pyw:16391
alice-HS-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-HS-desktop-1.3.pyw:4611
alice-HS-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-HS-desktop-1.3.pyw:12379
alice-HS-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-HS-desktop-1.3.pyw:13018
alice-HS-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-HS-desktop-1.3.pyw:4606
alice-HS-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-HS-desktop-1.3.pyw:9301
alice-HS-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-HS-desktop-1.3.pyw:17122
alice-HS-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-HS-desktop-1.3.pyw:17054
alice-HS-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-HS-desktop-1.3.pyw:4574
alice-HS-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-HS-desktop-1.3.pyw:10939
alice-HS-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-HS-desktop-1.3.pyw:16746
alice-HS-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-HS-desktop-1.3.pyw:16423
alice-HS-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-HS-desktop-1.3.pyw:17286
alice-HS-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-HS-desktop-1.3.pyw:17310
alice-HS-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-HS-desktop-1.3.pyw:8721
alice-HS-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-HS-desktop-1.3.pyw:1415
alice-HS-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-HS-desktop-1.3.pyw:9708
alice-HS-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-HS-desktop-1.3.pyw:10779
alice-HS-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-HS-desktop-1.3.pyw:17416
alice-HS-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-HS-desktop-1.3.pyw:11104
alice-HS-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-HS-desktop-1.3.pyw:18058
alice-HS-desktop-1.BSendGS
def BSendGS()
Definition: alice-HS-desktop-1.3.pyw:16803
alice-HS-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-HS-desktop-1.3.pyw:14267
alice-HS-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-HS-desktop-1.3.pyw:8655
alice-HS-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-HS-desktop-1.3.pyw:8387
alice-HS-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-HS-desktop-1.3.pyw:11604
alice-HS-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-HS-desktop-1.3.pyw:1201
alice-HS-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-HS-desktop-1.3.pyw:16235
alice-HS-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-HS-desktop-1.3.pyw:9046
alice-HS-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-HS-desktop-1.3.pyw:8101
alice-HS-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-HS-desktop-1.3.pyw:9800
alice-HS-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-HS-desktop-1.3.pyw:16653
alice-HS-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-HS-desktop-1.3.pyw:14862
alice-HS-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-HS-desktop-1.3.pyw:12387
alice-HS-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-HS-desktop-1.3.pyw:7499
alice-HS-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-HS-desktop-1.3.pyw:15536
alice-HS-desktop-1.sel3
def sel3(temp)
Definition: alice-HS-desktop-1.3.pyw:4541
alice-HS-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-HS-desktop-1.3.pyw:651
alice-HS-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-HS-desktop-1.3.pyw:11284
alice-HS-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-HS-desktop-1.3.pyw:16350
alice-HS-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-HS-desktop-1.3.pyw:2136
alice-HS-desktop-1.Blevel3
def Blevel3()
Definition: alice-HS-desktop-1.3.pyw:11048
alice-HS-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-HS-desktop-1.3.pyw:14017
alice-HS-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-HS-desktop-1.3.pyw:5660
alice-HS-desktop-1.sel0
def sel0(temp)
Definition: alice-HS-desktop-1.3.pyw:4442
alice-HS-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-HS-desktop-1.3.pyw:8467
alice-HS-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-HS-desktop-1.3.pyw:3725
alice-HS-desktop-1.CreateToolTip.tw
tw
Definition: alice-HS-desktop-1.3.pyw:660
alice-HS-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-HS-desktop-1.3.pyw:11312
alice-HS-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-HS-desktop-1.3.pyw:13982
alice-HS-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-HS-desktop-1.3.pyw:1503
alice-HS-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-HS-desktop-1.3.pyw:13989
alice-HS-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-HS-desktop-1.3.pyw:16354
alice-HS-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-HS-desktop-1.3.pyw:18150
alice-HS-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-HS-desktop-1.3.pyw:8047
alice-HS-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-HS-desktop-1.3.pyw:18040
alice-HS-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-HS-desktop-1.3.pyw:13348
alice-HS-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-HS-desktop-1.3.pyw:11347
alice-HS-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-HS-desktop-1.3.pyw:13050
alice-HS-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-HS-desktop-1.3.pyw:7734
alice-HS-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-HS-desktop-1.3.pyw:9541
alice-HS-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-HS-desktop-1.3.pyw:10742
alice-HS-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-HS-desktop-1.3.pyw:13756
alice-HS-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-HS-desktop-1.3.pyw:8599
alice-HS-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-HS-desktop-1.3.pyw:11331
alice-HS-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-HS-desktop-1.3.pyw:1661
alice-HS-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-HS-desktop-1.3.pyw:1542
alice-HS-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-HS-desktop-1.3.pyw:14093
alice-HS-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-HS-desktop-1.3.pyw:13185
alice-HS-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-HS-desktop-1.3.pyw:2220
alice-HS-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-HS-desktop-1.3.pyw:13329
alice-HS-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-HS-desktop-1.3.pyw:2124
alice-HS-desktop-1.Blevel1
def Blevel1()
Definition: alice-HS-desktop-1.3.pyw:11030
alice-HS-desktop-1.Analog_Slow_time
def Analog_Slow_time()
Definition: alice-HS-desktop-1.3.pyw:2910
alice-HS-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-HS-desktop-1.3.pyw:16949
alice-HS-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-HS-desktop-1.3.pyw:12858
alice-HS-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-HS-desktop-1.3.pyw:8089
alice-HS-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-HS-desktop-1.3.pyw:17150
alice-HS-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-HS-desktop-1.3.pyw:1396
alice-HS-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-HS-desktop-1.3.pyw:13436
alice-HS-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-HS-desktop-1.3.pyw:14231
alice-HS-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-HS-desktop-1.3.pyw:1280
alice-HS-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-HS-desktop-1.3.pyw:2238
alice-HS-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-HS-desktop-1.3.pyw:2471
alice-HS-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-HS-desktop-1.3.pyw:2130
alice-HS-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-HS-desktop-1.3.pyw:9761
alice-HS-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-HS-desktop-1.3.pyw:1988
alice-HS-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-HS-desktop-1.3.pyw:12848
alice-HS-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-HS-desktop-1.3.pyw:17280
alice-HS-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-HS-desktop-1.3.pyw:14275
alice-HS-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-HS-desktop-1.3.pyw:4073
alice-HS-desktop-1.sel
def sel()
Definition: alice-HS-desktop-1.3.pyw:4335
alice-HS-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-HS-desktop-1.3.pyw:17290
alice-HS-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-HS-desktop-1.3.pyw:11248
alice-HS-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-HS-desktop-1.3.pyw:4601
alice-HS-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-HS-desktop-1.3.pyw:10433
alice-HS-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-HS-desktop-1.3.pyw:1917
alice-HS-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-HS-desktop-1.3.pyw:652
alice-HS-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-HS-desktop-1.3.pyw:9180
alice-HS-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-HS-desktop-1.3.pyw:17471
alice-HS-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-HS-desktop-1.3.pyw:1354
alice-HS-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-HS-desktop-1.3.pyw:8863
alice-HS-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-HS-desktop-1.3.pyw:14032
alice-HS-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-HS-desktop-1.3.pyw:694
alice-HS-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-HS-desktop-1.3.pyw:6735
alice-HS-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-HS-desktop-1.3.pyw:14024
alice-HS-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-HS-desktop-1.3.pyw:14065
alice-HS-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-HS-desktop-1.3.pyw:2064
alice-HS-desktop-1.onCanvasClickScroll
def onCanvasClickScroll(event)
Definition: alice-HS-desktop-1.3.pyw:7508
alice-HS-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-HS-desktop-1.3.pyw:16328
alice-HS-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-HS-desktop-1.3.pyw:4373
alice-HS-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-HS-desktop-1.3.pyw:2514
alice-HS-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-HS-desktop-1.3.pyw:12554
alice-HS-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-HS-desktop-1.3.pyw:15287
alice-HS-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-HS-desktop-1.3.pyw:14982
alice-HS-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-HS-desktop-1.3.pyw:7492
alice-HS-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-HS-desktop-1.3.pyw:7988
alice-HS-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-HS-desktop-1.3.pyw:2232
alice-HS-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-HS-desktop-1.3.pyw:12049
alice-HS-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-HS-desktop-1.3.pyw:17840
alice-HS-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-HS-desktop-1.3.pyw:17239
alice-HS-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-HS-desktop-1.3.pyw:1955
alice-HS-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-HS-desktop-1.3.pyw:2007
alice-HS-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-HS-desktop-1.3.pyw:2525
alice-HS-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-HS-desktop-1.3.pyw:14381
alice-HS-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-HS-desktop-1.3.pyw:2348
alice-HS-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-HS-desktop-1.3.pyw:2202
alice-HS-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-HS-desktop-1.3.pyw:14312
alice-HS-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-HS-desktop-1.3.pyw:2441
alice-HS-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-HS-desktop-1.3.pyw:13975
alice-HS-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-HS-desktop-1.3.pyw:8017
alice-HS-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-HS-desktop-1.3.pyw:9389
alice-HS-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-HS-desktop-1.3.pyw:2413
alice-HS-desktop-1.BTriglevel
def BTriglevel(event)
evalute trigger level entry string to a numerical value and set new trigger level
Definition: alice-HS-desktop-1.3.pyw:2051
alice-HS-desktop-1.SelectBoard
def SelectBoard()
temp = 0 print "read ADM1177 controler" print devx.ctrl_transfer( 0xa0, 0x17, 0, 0,...
Definition: alice-HS-desktop-1.3.pyw:17500
alice-HS-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-HS-desktop-1.3.pyw:17761
alice-HS-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-HS-desktop-1.3.pyw:13057
alice-HS-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-HS-desktop-1.3.pyw:14259
alice-HS-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-HS-desktop-1.3.pyw:14713
alice-HS-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-HS-desktop-1.3.pyw:17741
alice-HS-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-HS-desktop-1.3.pyw:14058
alice-HS-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-HS-desktop-1.3.pyw:2735
alice-HS-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-HS-desktop-1.3.pyw:14010
alice-HS-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-HS-desktop-1.3.pyw:18146
alice-HS-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-HS-desktop-1.3.pyw:2166
alice-HS-desktop-1.BStopBP
def BStopBP()
Definition: alice-HS-desktop-1.3.pyw:11226
alice-HS-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-HS-desktop-1.3.pyw:2082
alice-HS-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-HS-desktop-1.3.pyw:17178
alice-HS-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-HS-desktop-1.3.pyw:7437
alice-HS-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-HS-desktop-1.3.pyw:7449
alice-HS-desktop-1.Analog_Fast_time
def Analog_Fast_time()
routine for time scales faster than 50 mSec/Div
Definition: alice-HS-desktop-1.3.pyw:3074
alice-HS-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-HS-desktop-1.3.pyw:9345
alice-HS-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-HS-desktop-1.3.pyw:8032
alice-HS-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-HS-desktop-1.3.pyw:13353
alice-HS-desktop-1.BStopSA
def BStopSA()
Definition: alice-HS-desktop-1.3.pyw:11003
alice-HS-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-HS-desktop-1.3.pyw:17654
alice-HS-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-HS-desktop-1.3.pyw:1898
alice-HS-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-HS-desktop-1.3.pyw:9839
alice-HS-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-HS-desktop-1.3.pyw:13845
alice-HS-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-HS-desktop-1.3.pyw:2208
alice-HS-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-HS-desktop-1.3.pyw:14036
alice-HS-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-HS-desktop-1.3.pyw:17172
alice-HS-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-HS-desktop-1.3.pyw:13996
alice-HS-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-HS-desktop-1.3.pyw:2190
alice-HS-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-HS-desktop-1.3.pyw:14227
alice-HS-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-HS-desktop-1.3.pyw:17465
alice-HS-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-HS-desktop-1.3.pyw:12369
alice-HS-desktop-1.Blevel4
def Blevel4()
Definition: alice-HS-desktop-1.3.pyw:11057
alice-HS-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-HS-desktop-1.3.pyw:14181
alice-HS-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-HS-desktop-1.3.pyw:17667
alice-HS-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-HS-desktop-1.3.pyw:14741
alice-HS-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-HS-desktop-1.3.pyw:4626
alice-HS-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Definition: alice-HS-desktop-1.3.pyw:7609
alice-HS-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-HS-desktop-1.3.pyw:8787
alice-HS-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-HS-desktop-1.3.pyw:16945
alice-HS-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-HS-desktop-1.3.pyw:8254
alice-HS-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-HS-desktop-1.3.pyw:17154
alice-HS-desktop-1.CAresize
def CAresize(event)
Definition: alice-HS-desktop-1.3.pyw:17300
alice-HS-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-HS-desktop-1.3.pyw:8436
alice-HS-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Definition: alice-HS-desktop-1.3.pyw:7525
alice-HS-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-HS-desktop-1.3.pyw:8329
alice-HS-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-HS-desktop-1.3.pyw:8980
alice-HS-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-HS-desktop-1.3.pyw:10180
alice-HS-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-HS-desktop-1.3.pyw:1360
alice-HS-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-HS-desktop-1.3.pyw:2362
alice-HS-desktop-1.DoFFT
def DoFFT()
Definition: alice-HS-desktop-1.3.pyw:11354
alice-HS-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-HS-desktop-1.3.pyw:4436
alice-HS-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-HS-desktop-1.3.pyw:9690
alice-HS-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-HS-desktop-1.3.pyw:8828
alice-HS-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-HS-desktop-1.3.pyw:665
alice-HS-desktop-1.BStartSA
def BStartSA()
Definition: alice-HS-desktop-1.3.pyw:10966
alice-HS-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-HS-desktop-1.3.pyw:8022
alice-HS-desktop-1.Bnot
def Bnot()
Definition: alice-HS-desktop-1.3.pyw:10732
alice-HS-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-HS-desktop-1.3.pyw:14216
alice-HS-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-HS-desktop-1.3.pyw:1189
alice-HS-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-HS-desktop-1.3.pyw:13151
alice-HS-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-HS-desktop-1.3.pyw:8518
alice-HS-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-HS-desktop-1.3.pyw:1559
alice-HS-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-HS-desktop-1.3.pyw:8012
alice-HS-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-HS-desktop-1.3.pyw:14039
alice-HS-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-HS-desktop-1.3.pyw:1936
alice-HS-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-HS-desktop-1.3.pyw:12430
alice-HS-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-HS-desktop-1.3.pyw:14209
alice-HS-desktop-1.SyncImage
def SyncImage()
Definition: alice-HS-desktop-1.3.pyw:14888
alice-HS-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-HS-desktop-1.3.pyw:10537
alice-HS-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-HS-desktop-1.3.pyw:1481
alice-HS-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-HS-desktop-1.3.pyw:2539
alice-HS-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-HS-desktop-1.3.pyw:10785
alice-HS-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-HS-desktop-1.3.pyw:13358
alice-HS-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-HS-desktop-1.3.pyw:15768
alice-HS-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-HS-desktop-1.3.pyw:13178
alice-HS-desktop-1.CreateToolTip.text
text
Definition: alice-HS-desktop-1.3.pyw:655
alice-HS-desktop-1.Blevel2
def Blevel2()
Definition: alice-HS-desktop-1.3.pyw:11039
alice-HS-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-HS-desktop-1.3.pyw:11305
alice-HS-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-HS-desktop-1.3.pyw:17216
alice-HS-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-HS-desktop-1.3.pyw:2399
alice-HS-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-HS-desktop-1.3.pyw:673
alice-HS-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-HS-desktop-1.3.pyw:8080
alice-HS-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-HS-desktop-1.3.pyw:9569
alice-HS-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-HS-desktop-1.3.pyw:16647
alice-HS-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-HS-desktop-1.3.pyw:1999
alice-HS-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-HS-desktop-1.3.pyw:2313
alice-HS-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-HS-desktop-1.3.pyw:2492
alice-HS-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-HS-desktop-1.3.pyw:649
alice-HS-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-HS-desktop-1.3.pyw:14195
alice-HS-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-HS-desktop-1.3.pyw:3691
alice-HS-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-HS-desktop-1.3.pyw:14042
alice-HS-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-HS-desktop-1.3.pyw:14735
alice-HS-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-HS-desktop-1.3.pyw:17800
alice-HS-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-HS-desktop-1.3.pyw:13024
alice-HS-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-HS-desktop-1.3.pyw:2503
alice-HS-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-HS-desktop-1.3.pyw:16797
alice-HS-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-HS-desktop-1.3.pyw:8508
alice-HS-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-HS-desktop-1.3.pyw:15551
alice-HS-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-HS-desktop-1.3.pyw:9117
alice-HS-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-HS-desktop-1.3.pyw:13067
alice-HS-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-HS-desktop-1.3.pyw:8056
alice-HS-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-HS-desktop-1.3.pyw:10475
alice-HS-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-HS-desktop-1.3.pyw:10250
alice-HS-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-HS-desktop-1.3.pyw:8064
alice-HS-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-HS-desktop-1.3.pyw:4032
alice-HS-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-HS-desktop-1.3.pyw:4616
alice-HS-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-HS-desktop-1.3.pyw:1680
alice-HS-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-HS-desktop-1.3.pyw:13896
alice-HS-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-HS-desktop-1.3.pyw:14045
alice-HS-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-HS-desktop-1.3.pyw:17721
alice-HS-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-HS-desktop-1.3.pyw:17343
alice-HS-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-HS-desktop-1.3.pyw:10749
alice-HS-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-HS-desktop-1.3.pyw:13195
alice-HS-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Definition: alice-HS-desktop-1.3.pyw:7651
alice-HS-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-HS-desktop-1.3.pyw:11319
alice-HS-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-HS-desktop-1.3.pyw:2118
alice-HS-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-HS-desktop-1.3.pyw:4218
alice-HS-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-HS-desktop-1.3.pyw:14937
alice-HS-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-HS-desktop-1.3.pyw:18479
alice-HS-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-HS-desktop-1.3.pyw:4081