colinoflynn / pico-python

PicoScope Python Interface
Other
101 stars 80 forks source link

Ps4000a : add built-in/arbitrary waveform generator. #193

Closed jcafhe closed 12 months ago

jcafhe commented 1 year ago

This PR adds low level methods to enable the built-in and arbitrary waveform generator feature for the PS4000a series, such that one can use the following methods:

This was tested with a PS4824 device.

Also, the last commit modifies the way in which the delta-phase value is calculated (round to the nearest integer instead of just use the int function), to better align with the sdk function ps4000aSigGenFrequencyToPhase. However, I can't be sure that the sdk function associated with a series other than the ps4000a behaves the same way, so if you think it's unsafe, I can remove the last commit.

hmaarrfk commented 1 year ago

can you comment on the float -> double change.

32 bit to 64 bit means things were either broken before, or broke now

jcafhe commented 1 year ago

I've made this change to conform to the programmer's guide and the ps4000a.h file from the sdk as well (see below, signature of the ps4000aSetSigGenBuiltIn function). Also, I first noticed type mismatch when trying to generate a built-in waveform resulting in a PICO_SIG_GEN_PARAM error (Incorrect parameter passed to signal generator), with a 4824 device.

So I can confirm it was broken before. I guess the low level method _lowLevelSetSigGenBuiltInSimple was a copy from another series (ps6000?), and you can notice it was defined below the comment # Untested functions below.

Programmer's guide:

ps4000aSetSigGenBuiltIn()

ps4000aApi.h

PREF0 PREF1 PICO_STATUS PREF2 PREF3(ps4000aSetSigGenBuiltIn)
    (
        int16_t                             handle,
        int32_t                             offsetVoltage,
        uint32_t                                pkToPk,
        PS4000A_WAVE_TYPE                   waveType,
        double                              startFrequency,
        double                              stopFrequency,
        double                              increment,
        double                              dwellTime,
        PS4000A_SWEEP_TYPE                  sweepType,
        PS4000A_EXTRA_OPERATIONS        operation,
        uint32_t                                shots,
        uint32_t                                sweeps,
        PS4000A_SIGGEN_TRIG_TYPE        triggerType,
        PS4000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                             extInThreshold
        );
jcafhe commented 12 months ago

@hmaarrfk Sorry but do you need some further details ?

hmaarrfk commented 12 months ago

if you want. I would consider a keyboard argument changing from floor to round. maybe a string argument