Test and Measurement Forum

No support of the AWG...

Post your .Net discussions here

No support of the AWG...

Postby andurimees » Tue Sep 23, 2014 9:57 am

In the C# versions of the SDK the function
"ps2000aSetSigGenArbitrary" is not part of the DLL calls as well as a Sweep Type is not implemented.
According to page 46 of the programmer manual this function should be present.
How else can one program the AWG using c#?

Yours
Harald
andurimees
Newbie
 
Posts: 0
Joined: Tue Sep 23, 2014 9:20 am

Re: No support of the AWG...

Postby Karunen » Tue Sep 23, 2014 1:01 pm

Hi Harald,

In the PS2000AImports.cs file you will want to copy and paste the following into the 'Driver enums' region

Code: Select all
       public enum IndexMode : int
        {
            PS2000A_SINGLE,
            PS2000A_DUAL,
            PS2000A_QUAD,
            PS2000A_MAX_INDEX_MODES
        }

        public enum WaveType : int
        {
            PS2000A_SINE,
            PS2000A_SQUARE,
            PS2000A_TRIANGLE,
            PS2000A_RAMP_UP,
            PS2000A_RAMP_DOWN,
            PS2000A_SINC,
            PS2000A_GAUSSIAN,
            PS2000A_HALF_SINE,
            PS2000A_DC_VOLTAGE,
            PS2000A_WHITE_NOISE,
            PS2000A_MAX_WAVE_TYPES
        }

        public enum SweepType : int
        {
            PS2000A_UP,
            PS2000A_DOWN,
            PS2000A_UPDOWN,
            PS2000A_DOWNUP,
            PS2000A_MAX_SWEEP_TYPES
        }

        public enum ExtraOperations : int
        {
            PS2000A_ES_OFF,
            PS2000A_WHITENOISE,
            PS2000A_PRBS // Pseudo-Random Bit Stream
        }

        public enum SigGenTrigType : int
        {
            PS2000A_SIGGEN_RISING,
            PS2000A_SIGGEN_FALLING,
            PS2000A_SIGGEN_GATE_HIGH,
            PS2000A_SIGGEN_GATE_LOW
        }

        public enum SigGenTrigSource : int
        {
            PS2000A_SIGGEN_NONE,
            PS2000A_SIGGEN_SCOPE_TRIG,
            PS2000A_SIGGEN_AUX_IN,
            PS2000A_SIGGEN_EXT_IN,
            PS2000A_SIGGEN_SOFT_TRIG
        }


And copy and past this code into the 'Driver Imports' region

Code: Select all
        [DllImport(_DRIVER_FILENAME, EntryPoint = "ps2000aSetSigGenArbitrary")]
        public static extern Int32 SetSigGenArbitray(
            short handle,
             int offsetVoltage,
            uint pkTopk,
            uint StartDeltaPhase,
            uint StopDeltaPhase,
            uint deltaPhaseIncrement,
            uint dwellCount,
           ref short arbitaryWaveform,
            int arbitaryWaveformSize,
            SweepType sweepType,
            ExtraOperations operation,
            IndexMode indexMode,
            uint shots,
            uint sweeps,
            SigGenTrigType triggerType,
            SigGenTrigSource triggerSource,
            short extInThreshold);


Kind Regards,
Karunen

Technical Specialist
Pico Technology
Karunen
Zen Master
Zen Master
 
Posts: 194
Joined: Thu Nov 21, 2013 9:22 am

AWG functions...

Postby andurimees » Tue Sep 23, 2014 3:09 pm

Thanks for the fast reply.
It did not work out perfectly, but the version I managed to execute is:

Code: Select all
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps2000aSetSigGenArbitrary")]
        public static extern Int32 SetSigGenArbitrary(
            short handle,
             int offsetVoltage,
            uint pkTopk,
            uint StartDeltaPhase,
            uint StopDeltaPhase,
            uint deltaPhaseIncrement,
            uint dwellCount,
--->      ref short[] arbitaryWaveform,
            int arbitaryWaveformSize,
            SweepType sweepType,
            ExtraOperations operation,
            IndexMode indexMode,
            uint shots,
            uint sweeps,
            SigGenTrigType triggerType,
            SigGenTrigSource triggerSource,
            short extInThreshold);

where there is a "ref short[]" instead of a "ref short".

Declaring a

short[] waveForm = {0,1,2,3,4};

and calling the function with ....., ref waveForm, 5,... does at least not crash.
I have to check with my old scope what comes out.
Please comment in case I miss something fundamental!




The next function from page 47 in the programmers manual (SetSigGenBuiltIn) is also missing.
A bit of guesswork would indicate:

Code: Select all
        [DllImport(_DRIVER_FILENAME, EntryPoint = "ps2000aSetSigGenBuiltIn")]
        public static extern Int32 SetSigGenBuiltIn(
          short handle,
          int offsetVoltage,
          uint pkToPk,
          WaveType waveType,
          uint startFrequency,
          uint stopFrequency,
          uint increment,
          uint dwellTime,
          SweepType sweepType,
           uint sweeps
         );

this causes stack hiccups. Especially since the floats from the c manual are to be replaced somehow.
Maybe there is a specific type for the frequency settings? :o

Could you send me the correct DLL calls?


Yours
Harald
andurimees
Newbie
 
Posts: 0
Joined: Tue Sep 23, 2014 9:20 am

AWG behaves pretty strange!

Postby andurimees » Tue Sep 23, 2014 4:03 pm

Hi,
well, according to my beliefs, the code below should generate a ramp up.
It actually generates random voltage levels with approx. 40ms plateaus all spread
within the +/- 1V range specified.
Whatever I program as waveForm does not matter.


Code: Select all
            Int32 status;
            Int32 waveLen= 1024;
            short[] waveForm = new short[waveLen];
            short ii = 0;
            for (Int32 i = 0; i < waveLen; i++)
            {
                ii++;
                if (ii == 254) ii = 0;
                waveForm[i] = ii;
            }
             
            status=Imports.SetSigGenArbitrary(_handle,
            0, //offsetVoltage
            1000000, //peakTopeak
            1, //StartDeltaPhase
            1, //StopDeltaPhase
            0, //deltaPhaseIncrement
            0, //dwellCount,
            ref waveForm,//ref short arbitaryWaveform,
            waveLen,//arbitaryWaveformSize,
            Imports.SweepType.PS2000A_UP, //SweepType sweepType,
            Imports.ExtraOperations.PS2000A_ES_OFF, //ExtraOperations operation,
            Imports.IndexMode.PS2000A_SINGLE, //indexMode,
            0, //shots,
            0, //sweeps,
            Imports.SigGenTrigType.PS2000A_SIGGEN_RISING , //SigGenTrigType triggerType
            Imports.SigGenTrigSource.PS2000A_SIGGEN_NONE, //SigGenTrigSource triggerSource,
            0 //extInThreshold
            );

The programming manual is completely silent regarding the following:

Role and function of
ExtraOperations (how to turn it off!)
IndexMode
shots,
sweeps,

one can conclude quite a bit from the remaining functions how
triggerType,
triggerSource,
extInThreshold
as long as triggerSource=NONE really turns off trigger.


Could one please provide a simple code snippet, where a waveform is just spotted out (no frequency sweeping, no luxury)? I can surely fix the rest!

Thanks in advance...
Harald :(
andurimees
Newbie
 
Posts: 0
Joined: Tue Sep 23, 2014 9:20 am

Re: No support of the AWG...

Postby Karunen » Fri Sep 26, 2014 8:30 am

Hi Harald,

I did a mistake in imports it shouldn't have

Code: Select all
ref short[] arbitaryWaveform,


it should just be

Code: Select all
short[] arbitaryWaveform,


I have also updated the C# console to use the AWG and the in built signal generator functions and I have sent you an email where you can download this example.

Please note the StartDeltaPhase and StopDeltaPhase is what the driver uses to calculate the frequency using the points to have pass into the AWG function. So if they are set to 1 you will get a very slow waveform.

A new function has been created called ps2000aSigGenFrequencyToPhase which can be used to calculate the phase from the frequency desired. The use of this function has also been included in updated in the 2000a examples.

Kind Regards,
Karunen

Technical Specialist
Pico Technology
Karunen
Zen Master
Zen Master
 
Posts: 194
Joined: Thu Nov 21, 2013 9:22 am

Re: No support of the AWG...

Postby Pradeep » Mon May 02, 2016 10:50 am

Hi,

I am using picoscope of type 3000 series to generate the waveforms from c# code. It would be much helpful if someone shares me the code snippet for usage of "SetSigGenBuiltIn" function. My mail ID is haihellopradeep@gmail.com. Thanks in advance.
Pradeep
Newbie
 
Posts: 1
Joined: Mon Apr 04, 2016 10:21 am

Re: No support of the AWG...

Postby Hitesh » Wed May 04, 2016 2:51 pm

Hi Pradeep,

Please refer to the following post.

The example shows how to use the SetSigGenBuiltInV2() (ps3000aSetSigGenBuiltInV2()) which specifies the frequencies as double-precision floating point numbers.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 1 guest