58
58
# use the values specified in the h file
59
59
# float is always defined as 32 bits
60
60
# double is defined as 64 bits
61
- from ctypes import byref , POINTER , create_string_buffer , c_float , \
61
+ from ctypes import byref , POINTER , create_string_buffer , c_float , c_double , \
62
62
c_int16 , c_uint16 , c_int32 , c_uint32 , c_uint64 , c_void_p , c_int8 , \
63
63
CFUNCTYPE
64
64
from ctypes import c_int32 as c_enum
@@ -173,6 +173,22 @@ class PS4000a(_PicoscopeBase):
173
173
SIGGEN_TRIGGER_SOURCES = {"None" : 0 , "ScopeTrig" : 1 ,
174
174
"AuxIn" : 2 , "ExtIn" : 3 , "SoftTrig" : 4 }
175
175
176
+ AWGPhaseAccumulatorSize = 32
177
+ AWGBufferAddressWidth = 14
178
+ AWGMaxSamples = 2 ** AWGBufferAddressWidth
179
+
180
+ AWGDACInterval = 12.5E-9 # in seconds
181
+ AWGDACFrequency = 1 / AWGDACInterval
182
+
183
+ # From the programmer's guide, p.99, defined for the PicoScope 4824. Values
184
+ # have been checked against those returned by the
185
+ # ps4000aSigGenArbitraryMinMaxValues function, with a PS4824 device
186
+ # connected.
187
+ AWGMaxVal = 32767
188
+ AWGMinVal = - 32768
189
+
190
+ AWG_INDEX_MODES = {"Single" : 0 , "Dual" : 1 , "Quad" : 2 }
191
+
176
192
def __init__ (self , serialNumber = None , connect = True ):
177
193
"""Load DLLs."""
178
194
self .handle = None
@@ -471,6 +487,32 @@ def getTimestepFromTimebase(self, timebase):
471
487
return dt
472
488
return dt
473
489
490
+ def _lowLevelSetAWGSimpleDeltaPhase (self , waveform , deltaPhase ,
491
+ offsetVoltage , pkToPk , indexMode ,
492
+ shots , triggerType , triggerSource ):
493
+ """Waveform should be an array of shorts."""
494
+ waveformPtr = waveform .ctypes .data_as (POINTER (c_int16 ))
495
+
496
+ m = self .lib .ps4000aSetSigGenArbitrary (
497
+ c_int16 (self .handle ),
498
+ c_int32 (int (offsetVoltage * 1E6 )), # offset voltage in microvolts
499
+ c_uint32 (int (pkToPk * 1E6 )), # pkToPk in microvolts
500
+ c_uint32 (int (deltaPhase )), # startDeltaPhase
501
+ c_uint32 (int (deltaPhase )), # stopDeltaPhase
502
+ c_uint32 (0 ), # deltaPhaseIncrement
503
+ c_uint32 (0 ), # dwellCount
504
+ waveformPtr , # arbitraryWaveform
505
+ c_int32 (len (waveform )), # arbitraryWaveformSize
506
+ c_enum (0 ), # sweepType for deltaPhase
507
+ c_enum (0 ), # operation (adding random noise and whatnot)
508
+ c_enum (indexMode ), # single, dual, quad
509
+ c_uint32 (shots ),
510
+ c_uint32 (0 ), # sweeps
511
+ c_uint32 (triggerType ),
512
+ c_uint32 (triggerSource ),
513
+ c_int16 (0 )) # extInThreshold
514
+ self .checkResult (m )
515
+
474
516
def _lowLevelSetDataBuffer (self , channel , data , downSampleMode ,
475
517
segmentIndex ):
476
518
"""Set the data buffer.
@@ -563,10 +605,6 @@ def _lowLevelPingUnit(self):
563
605
"""Check connection to picoscope and return the error."""
564
606
return self .lib .ps4000aPingUnit (c_int16 (self .handle ))
565
607
566
- ####################################################################
567
- # Untested functions below #
568
- # #
569
- ####################################################################
570
608
def _lowLevelSetSigGenBuiltInSimple (self , offsetVoltage , pkToPk , waveType ,
571
609
frequency , shots , triggerType ,
572
610
triggerSource , stopFreq , increment ,
@@ -577,16 +615,27 @@ def _lowLevelSetSigGenBuiltInSimple(self, offsetVoltage, pkToPk, waveType,
577
615
m = self .lib .ps4000aSetSigGenBuiltIn (
578
616
c_int16 (self .handle ),
579
617
c_int32 (int (offsetVoltage * 1000000 )),
580
- c_int32 (int (pkToPk * 1000000 )),
581
- c_int16 (waveType ),
582
- c_float (frequency ), c_float (stopFreq ),
583
- c_float (increment ), c_float (dwellTime ),
618
+ c_uint32 (int (pkToPk * 1000000 )),
619
+ c_enum (waveType ),
620
+ c_double (frequency ), c_double (stopFreq ),
621
+ c_double (increment ), c_double (dwellTime ),
584
622
c_enum (sweepType ), c_enum (0 ),
585
623
c_uint32 (shots ), c_uint32 (numSweeps ),
586
624
c_enum (triggerType ), c_enum (triggerSource ),
587
625
c_int16 (0 ))
588
626
self .checkResult (m )
589
627
628
+ def _lowLevelSigGenSoftwareControl (self , state ):
629
+ m = self .lib .ps4000aSigGenSoftwareControl (
630
+ c_int16 (self .handle ),
631
+ c_int16 (state ))
632
+ self .checkResult (m )
633
+
634
+ ####################################################################
635
+ # Untested functions below #
636
+ # #
637
+ ####################################################################
638
+
590
639
def _lowLevelGetMaxDownSampleRatio (self , noOfUnaggregatedSamples ,
591
640
downSampleRatioMode , segmentIndex ):
592
641
maxDownSampleRatio = c_uint32 ()
0 commit comments