5858# use the values specified in the h file
5959# float is always defined as 32 bits
6060# 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 , \
6262 c_int16 , c_uint16 , c_int32 , c_uint32 , c_uint64 , c_void_p , c_int8 , \
6363 CFUNCTYPE
6464from ctypes import c_int32 as c_enum
@@ -173,6 +173,22 @@ class PS4000a(_PicoscopeBase):
173173 SIGGEN_TRIGGER_SOURCES = {"None" : 0 , "ScopeTrig" : 1 ,
174174 "AuxIn" : 2 , "ExtIn" : 3 , "SoftTrig" : 4 }
175175
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+
176192 def __init__ (self , serialNumber = None , connect = True ):
177193 """Load DLLs."""
178194 self .handle = None
@@ -471,6 +487,32 @@ def getTimestepFromTimebase(self, timebase):
471487 return dt
472488 return dt
473489
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+
474516 def _lowLevelSetDataBuffer (self , channel , data , downSampleMode ,
475517 segmentIndex ):
476518 """Set the data buffer.
@@ -563,10 +605,6 @@ def _lowLevelPingUnit(self):
563605 """Check connection to picoscope and return the error."""
564606 return self .lib .ps4000aPingUnit (c_int16 (self .handle ))
565607
566- ####################################################################
567- # Untested functions below #
568- # #
569- ####################################################################
570608 def _lowLevelSetSigGenBuiltInSimple (self , offsetVoltage , pkToPk , waveType ,
571609 frequency , shots , triggerType ,
572610 triggerSource , stopFreq , increment ,
@@ -577,16 +615,27 @@ def _lowLevelSetSigGenBuiltInSimple(self, offsetVoltage, pkToPk, waveType,
577615 m = self .lib .ps4000aSetSigGenBuiltIn (
578616 c_int16 (self .handle ),
579617 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 ),
584622 c_enum (sweepType ), c_enum (0 ),
585623 c_uint32 (shots ), c_uint32 (numSweeps ),
586624 c_enum (triggerType ), c_enum (triggerSource ),
587625 c_int16 (0 ))
588626 self .checkResult (m )
589627
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+
590639 def _lowLevelGetMaxDownSampleRatio (self , noOfUnaggregatedSamples ,
591640 downSampleRatioMode , segmentIndex ):
592641 maxDownSampleRatio = c_uint32 ()
0 commit comments