C++ Programming getting started

Having problems ? let us know the details here
Post Reply
jboxfordni
User
User
Posts: 2
Joined: Tue Aug 15, 2023 10:01 am

C++ Programming getting started

Post by jboxfordni »

I have downloaded the 64bit SDK and I'm trying to connect to my PicoScope 2204A.
The device works correctly in the picoscope software.
I have created a simple C++ project in visual studio 2022. The project links to the ps2000a.lib and I have copied the dll into the executable directory.
Looking at your examples on github I made a basic code below.

Code: Select all


#include "windows.h"
#include 
#include 
#include 
#include "ps2000aAPI.h"

typedef struct
{
    int16_t DCcoupled;
    int16_t range;
    int16_t enabled;
}CHANNEL_SETTINGS;

typedef struct
{
    int16_t					handle;
    PS2000A_RANGE			firstRange;
    PS2000A_RANGE			lastRange;
    uint8_t					signalGenerator;
    uint8_t					ETS;
    int16_t                 channelCount;
    int16_t					maxValue;
    CHANNEL_SETTINGS		channelSettings[PS2000A_MAX_CHANNELS];
    int16_t					digitalPorts;
    int16_t					awgBufferSize;
    double					awgDACFrequency;
} UNIT;


PICO_STATUS openDevice(UNIT* unit)
{
    PICO_STATUS status = ps2000aOpenUnit(&(unit->handle), NULL);
    return status;
}

void CloseDevice(UNIT* unit)
{
    ps2000aCloseUnit(unit->handle);
}

int main()
{
    UNIT unit;

    PICO_STATUS status = openDevice(&unit);

    if (status != PICO_OK)
    {
        std::cout << "unit not found: " << status << std::endl;
        return -1;
    }

    // continue with setup here

    CloseDevice(&unit);

    return 0;

}
The device is never found and always returns status 3.
Have I setup the project correctly? Can you explain the DYNLINK usage in the API header? if defined then I cannot call ps2000aOpenUnit in this way.

Martyn
Site Admin
Site Admin
Posts: 4501
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: C++ Programming getting started

Post by Martyn »

The 2204a is actually a ps2000 device and not a ps2000a one, so you need to use ps2000.lib ps2000.dll and the appropriate ps2000 examples from GitHub.
Martyn
Technical Support Manager

jboxfordni
User
User
Posts: 2
Joined: Tue Aug 15, 2023 10:01 am

Re: C++ Programming getting started

Post by jboxfordni »

Thanks Martyn. I am now connected to the device. The A on the device naming confused me.

Martyn
Site Admin
Site Admin
Posts: 4501
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: C++ Programming getting started

Post by Martyn »

It confuses many people but unfortunately for historical reasons we can't change it.
Martyn
Technical Support Manager

Post Reply