Problem with ps5000aOpenUnit in C

Having problems ? let us know the details here
Post Reply
jbl
User
User
Posts: 8
Joined: Fri Dec 16, 2016 2:35 pm

Problem with ps5000aOpenUnit in C

Post by jbl »

Hi,
I'm a new user of the libps5000a.so library with gcc on a Raspberry.
I have written my first C program with this library. No problem for linking and the functions are fully called by the main program.

The first I've used is : ps5000aEnumerateUnits. It gives results. The picoscope is detected, its serial number is obtained.

The second one is ps5000aOpenUnits. It doesn't work. The return handle is -1 that means "The scope fails to open".

I wonder if there is something to do before executing my C program. The LED in front of the Pico is still red. I have connected the pico to the usb and the usbtest program gives good result. Any idea ?

Thank you for your help.

Hitesh

Re: Problem with ps5000aOpenUnit in C

Post by Hitesh »

Hi jbl,

Have you tried running your application using the sudo command?

Regards,

jbl
User
User
Posts: 8
Joined: Fri Dec 16, 2016 2:35 pm

Re: Problem with ps5000aOpenUnit in C

Post by jbl »

Hi Hitesh,
Yes, I have tried running it with sudo command or as root.
Do you think that the raspberry usb ports give enough current for the picoscope ?
The pico is supplied with a double usb plug. Perhaps should I use an external power unit.

Hitesh

Re: Problem with ps5000aOpenUnit in C

Post by Hitesh »

Hi jbl,

It's possible that this could be the case.

Which PicoScope device are you using? If it is a 2-channel device, please use the dual-headed USB cable.

You can also use this power supply with the device. This is the power supply that is provided in the box with 4-channel models.

Regards,

jbl
User
User
Posts: 8
Joined: Fri Dec 16, 2016 2:35 pm

Re: Problem with ps5000aOpenUnit in C

Post by jbl »

Hi Hitesh,
Thank you for your help.
I'm using a 5244A dual channel Picoscope and I'm using the dual-headed USB cable.
I have also tried to plug the power head in an auxiliary PC USB port and the second head in the Rasp.
No result.
Last edited by jbl on Thu Jan 05, 2017 11:15 am, edited 1 time in total.

Hitesh

Re: Problem with ps5000aOpenUnit in C

Post by Hitesh »

Hi jbl,

Could you please post your code here or e-mail it to support@picotech.com?

We can then see how the calls are being made to the driver.

Thanks,

jbl
User
User
Posts: 8
Joined: Fri Dec 16, 2016 2:35 pm

Re: Problem with ps5000aOpenUnit in C

Post by jbl »

Here is the very simple code (perhaps too simple) :

#include
#include "PicoStatus.h"
#include "ps5000aApi.h"
main(){
int16_t handle,nb,serialLg=80;
char serial[80];
PICO_STATUS device,channel;
printf("Hello Picoscope\n");

device=ps5000aEnumerateUnits(&nb,serial,&serialLg);

printf("Number of picoscopes %d\nPicoscopes : %s\n",nb,serial);

device=ps5000aOpenUnit(&handle,serial,8);
printf("handle : %d\ndevice : %x\n",handle,device);

channel=ps5000aSetChannel(handle,PS5000A_CHANNEL_A,1,PS5000A_DC,PS5000A_1V,0.0F);
printf("channel : %x\n",channel);
}

.h and .so files are in the current directory with the .c file

Compilation command : gcc Pico.c libps5000a.so
Execution command : ./a.out

This program displays :

Hello Picoscope
Number of picoscopes 1
Picoscopes : CS241/110
handle : -1
device : 3f
channel : c

Regards

Hitesh

Re: Problem with ps5000aOpenUnit in C

Post by Hitesh »

Hi jbl,

Thank you for posting the code.

Referring to this line:

Code: Select all

device=ps5000aOpenUnit(&handle,serial,8);
The resolution value of 8 is not correct. You need to use one of the enumeration values from the header file:

Code: Select all

typedef enum enPS5000ADeviceResolution
{
  PS5000A_DR_8BIT,
  PS5000A_DR_12BIT,
  PS5000A_DR_14BIT,
  PS5000A_DR_15BIT,
  PS5000A_DR_16BIT
} PS5000A_DEVICE_RESOLUTION;
Also, note that trying to pass the serial value to the ps5000aOpenUnit() function if multiple units are returned from the ps5000aEnumerateUnits() function might not work.

Hope this helps,

jbl
User
User
Posts: 8
Joined: Fri Dec 16, 2016 2:35 pm

Re: Problem with ps5000aOpenUnit in C

Post by jbl »

Good !
It's working with PS5000A_DR_8BIT.
The display is :

handle : 1
device : 11a
channel : 0

Thank you very much.

jbl
User
User
Posts: 8
Joined: Fri Dec 16, 2016 2:35 pm

Re: Problem with ps5000aOpenUnit in C

Post by jbl »

Well, it's not so good.
If we check the 11a return value in the documentation. It's better than 3f (PICO_NOT_USED).
11a gives : PICO_POWER_SUPPLY_NOT_CONNECTED.
Perhaps it means that an external power supply is mandatory to play with this library ...

Hitesh

Re: Problem with ps5000aOpenUnit in C

Post by Hitesh »

You will need to pass this status code to the ps5000aChangePowerSource() function which is documented in the Programmer's Guide.

This functionality is shown in the SDK example.

Hope this helps.

jbl
User
User
Posts: 8
Joined: Fri Dec 16, 2016 2:35 pm

Re: Problem with ps5000aOpenUnit in C

Post by jbl »

Thanks, it seems to be ok now.
The returned value is 0 (PICO_OK) and the red led in front of the Pico turned off.

Post Reply