Python SDK and SigGen with 5242D

Post general discussions on using our drivers to write your own software here
Post Reply
cjkraz
Newbie
Posts: 0
Joined: Mon Oct 29, 2018 2:55 pm

Python SDK and SigGen with 5242D

Post by cjkraz »

Hi Guys,

I've been working on integrating the Picotech 5242D into a python application that uses both the Oscilloscope and Signal generator functionality. While I've had no issues with the Oscilloscope functions, I have come across some bumps with the Signal Generator.

Some details:
the goal is to have the signal generator trigger a shot output with a variable number of sine wave cycles (shots). The trigger of the signal generator could be either the ps5000aSigGenSoftwareControl Trigger (preferable) or by using the ps5000aSetSigGenBuiltInV2 function call.

The Problem:
While experimenting with the SDK I can setup the signal generator to output a waveform, but it doesn't seem to limit the number of cycles. Here's my function call based off the SDK example:

Code: Select all

# Output a sine wave with peak-to-peak voltage of 2 V and frequency of 10 kHz;
# handle = chandle
# offsetVoltage = 0
# pkToPk = 2000000
# waveType = ctypes.c_int16(0) = PS5000A_SINE
# startFrequency = 10 kHz
# stopFrequency = 10 kHz
# increment = 0
# dwellTime = 1
# sweepType = ctypes.c_int16(1) = PS5000A_UP
# operation = 0
# shots = 3
# sweeps = 0
# triggerType = ctypes.c_int16(0) = PS5000A_SIGGEN_RISING
# triggerSource = ctypes.c_int16(0) = PS5000A_SIGGEN_NONE
# extInThreshold = 1
wavetype = ctypes.c_int32(0)
sweepType = ctypes.c_int32(0)
triggertype = ctypes.c_int32(0)
triggerSource = ctypes.c_int32(0) 

picoStatus["SetSigGenBuiltIn"] = ps.ps5000aSetSigGenBuiltInV2(scope, 0, 500000, wavetype, 1000000, 1000000, 0, 1, 0, 0, 3, 0, triggertype, triggerSource, 1)
assert_pico_ok(picoStatus["SetSigGenBuiltIn"])
this seems to produce a continuous output rather than the limited cycle output that I'm trying to achieve.
Additionally, the function ps5000aSigGenSoftwareControl doesn't seem to be implemented through the Python wrappers, which leads to my next question: Are all the SDK functions accessible through the Python wrappers?

Hitesh

Re: Python SDK and SigGen with 5242D

Post by Hitesh »

Hi cjkraz,

In order to output a number of cycles of a waveform (or start a sweep) you need to specify a trigger for the signal generator.

You will need to change the following line to specify the trigger source that you wish to use:

Code: Select all

triggerSource = ctypes.c_int32(0) 
This number is based on the following set of enumerations which are yet to be defined in the ps5000a.py file:

Code: Select all

typedef enum enPS5000ASigGenTrigSource
{
  PS5000A_SIGGEN_NONE,
  PS5000A_SIGGEN_SCOPE_TRIG,
  PS5000A_SIGGEN_AUX_IN,
  PS5000A_SIGGEN_EXT_IN,
  PS5000A_SIGGEN_SOFT_TRIG
} PS5000A_SIGGEN_TRIG_SOURCE;
where 0 corresponds to PS5000A_SIGGEN_NONE.

The ps5000aSigGenSoftwareControl() function is defined in the ps5000a.py file - try calling SigGenSoftwareControl().

You may also find this guide useful:

https://www.picotech.com/download/manua ... ctions.pdf

Regards,

cjkraz
Newbie
Posts: 0
Joined: Mon Oct 29, 2018 2:55 pm

Re: Python SDK and SigGen with 5242D

Post by cjkraz »

Hi Hitesh,

Thanks for the feedback. So I had actually already tried what you had suggested. Where I was going wrong was the combination of triggering source and triggering type. I had used the SoftwareTrigger with the "PS5000A_SIGGEN_GATE_HIGH" which caused an error with the SDK. Playing around more, I discovered that I had to use "PS5000A_SIGGEN_RISING" to get the behavior that I was trying to achieve.

On another note,
Are there any plans on adding in any burst/shot repetition functionality? Practically exactly as described here: topic27971.html

Hitesh

Re: Python SDK and SigGen with 5242D

Post by Hitesh »

Hi cjkraz,

I've added a note to a new feature request about burst/shot repetition.

Regards,

Post Reply