Test and Measurement Forum

c# Built-In Waveform in AWG functions

Post your .Net discussions here

c# Built-In Waveform in AWG functions

Postby andurimees » Wed Sep 24, 2014 10:59 am

You might find, that the SDK for C# does not contain the AWG functions for the 2205MSO.
As first part of the solution, here is a code snippet for the Built-In waveforms.
The enums were kindly provided by Karunen, the rest is reverse engineering: :D


//add in Imports: #region Driver Imports
//provided by Karunen
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
        }



//add in Imports: #region Driver Imports
//found by reverse engineering of the C++ Console application:
//contradicts the syntax stipulated in the programmer's manual
Code: Select all

[DllImport(_DRIVER_FILENAME, EntryPoint = "ps2000aSetSigGenBuiltIn")]
        public static extern Int32 SetSigGenBuiltIn(
            short handle,
            int offsetVoltage,
            uint pkToPk,
            WaveType waveType,
            float startFrequency,
            float stopFrequency,
            uint increment, //not double
            uint dwellTime, //not double...
            SweepType sweepType,
            ExtraOperations operation,
            uint shots,
            uint sweeps,
            SigGenTrigType triggerType,
            SigGenTrigSource triggerSource,
            short extInThreshold);
   



//Code snippet for a single rail 1Vpp ramp...
//add in the console application:
   float freq = 1000.0F;     
   status = Imports.SetSigGenBuiltIn(
                 _handle,
                 (int) 500000, //offsetVoltage,
                 (uint) 1000000, //uint pkToPk,
                 Imports.WaveType.PS2000A_RAMP_UP, // waveType,
                 (float)freq, // Hz float startFrequency,
                 (float)freq, // Hz float stopFrequency,
                 0, // uint! Hz float increment,
                 0, // uint! float dwellTime,
                 Imports.SweepType.PS2000A_UP,
                 Imports.ExtraOperations.PS2000A_ES_OFF,
                 0, //Shots
                 0, //Sweeps
                 Imports.SigGenTrigType.PS2000A_SIGGEN_RISING,
                 Imports.SigGenTrigSource.PS2000A_SIGGEN_NONE,
                 0);
andurimees
Newbie
 
Posts: 0
Joined: Tue Sep 23, 2014 9:20 am

Re: c# Built-In Waveform in AWG functions

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

Hi,

I have updated the 2000a C# console example in the SDK and will be made available for download in a later release.

If you require it before the the new SDK build release please email support@picotech.com.

Kind Regards,
Karunen

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

Re: c# Built-In Waveform in AWG functions

Postby SteveHageman » Sun Sep 28, 2014 2:17 am

andurimees - Thanks for sharing - this worked for my 5000 series also (with a few tweaks).
SteveHageman
Newbie
 
Posts: 0
Joined: Sat Sep 27, 2014 3:05 am


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

Who is online

Users browsing this forum: No registered users and 2 guests