## Matlab ADC Conversion

### Matlab ADC Conversion

Hello everyone,

I am using a Picoscope 6402c and the Matlab Toolbox. I am little bit confused with the ADC Resolution. In the Datasheets is written that the ADC Resolution is 8 Bit, but the max ADC count is 32512 in Matlab? How is this possilbe? So how can i change the ADC Resolution in Matlab or how can i convert to int8 without information lost (meaning values above 255 dont get lost), that I can store my channel values in an int8 Matrix? It is not possible to use a int8 Pointer because SetDataBuffers only allows int16.

Best regards,

Zlatan

I am using a Picoscope 6402c and the Matlab Toolbox. I am little bit confused with the ADC Resolution. In the Datasheets is written that the ADC Resolution is 8 Bit, but the max ADC count is 32512 in Matlab? How is this possilbe? So how can i change the ADC Resolution in Matlab or how can i convert to int8 without information lost (meaning values above 255 dont get lost), that I can store my channel values in an int8 Matrix? It is not possible to use a int8 Pointer because SetDataBuffers only allows int16.

Best regards,

Zlatan

### Re: Matlab ADC Conversion

Hi Zlatan,

The driver scales the values to 16-bit integers, which is why in the Programmer's Guide the ps6000SetDataBuffer and ps6000SetDataBuffers functions take a pointer to an array of 16-bit integers as an argument.

What is the reason for wishing to convert the data to 8-bit values?

Regards,

The driver scales the values to 16-bit integers, which is why in the Programmer's Guide the ps6000SetDataBuffer and ps6000SetDataBuffers functions take a pointer to an array of 16-bit integers as an argument.

What is the reason for wishing to convert the data to 8-bit values?

Regards,

Hitesh

Software Dev. Engineer

Software Dev. Engineer

### Re: Matlab ADC Conversion

I want to run the RunBlock function in a loop with 100000 iteration an for every round i want to store the trace in a Matrix with 100000 rows and X samples. So with 16 Bit my Matrix get to large and i dont need so a high resolution.

"The driver scales the values to 16-bit integers" What does this mean?

So it is not possible to scale down to 8 Bit?

"The driver scales the values to 16-bit integers" What does this mean?

So it is not possible to scale down to 8 Bit?

### Re: Matlab ADC Conversion

Hi Zlatan,

The ps6000 driver scales the samples to 16 bits () as shown in section 3.3 (Voltage ranges) of the PicoScope 6000 Series Programmer's Guide so that digital gain can be applied for calibration purposes.

This also keeps it in line with the maximum ADC count values (-32768 to +32767) for our 12-bit and 16-bit resolution oscilloscopes in other ranges.

You may wish to consider the rapid block mode capture as this will return a vector of waveforms corresponding to each segment for the channel you are using if you use the Instrument Driver's getRapidBlockData function shown in the PS6000_IC_Generic_Driver_Rapid_Block_Plot3D example script.

The Instrument Driver's getBlockData and getRapidBlockData functions do convert the data from 16-bit ADC counts to millivolts values so one option might be to modify the adc2mv function for your purposes to cast the conversion to something other than a double (e.g. a single or int16 data type) or not convert the data to milliVolts if you just need the ADC count values.

In terms of memory usage, are you using a 64-bit version of MATLAB?

Regards,

The ps6000 driver scales the samples to 16 bits () as shown in section 3.3 (Voltage ranges) of the PicoScope 6000 Series Programmer's Guide so that digital gain can be applied for calibration purposes.

This also keeps it in line with the maximum ADC count values (-32768 to +32767) for our 12-bit and 16-bit resolution oscilloscopes in other ranges.

You may wish to consider the rapid block mode capture as this will return a vector of waveforms corresponding to each segment for the channel you are using if you use the Instrument Driver's getRapidBlockData function shown in the PS6000_IC_Generic_Driver_Rapid_Block_Plot3D example script.

The Instrument Driver's getBlockData and getRapidBlockData functions do convert the data from 16-bit ADC counts to millivolts values so one option might be to modify the adc2mv function for your purposes to cast the conversion to something other than a double (e.g. a single or int16 data type) or not convert the data to milliVolts if you just need the ADC count values.

In terms of memory usage, are you using a 64-bit version of MATLAB?

Regards,

Hitesh

Software Dev. Engineer

Software Dev. Engineer

### Re: Matlab ADC Conversion

Hi,

I am using a 64-Bit version of Matlab.

The RapidBlockData makes no sense for my application.

I want to work with the ADC Values not with the Volt values and single or int16 data type are to large.

Are the values real 16 bit values (0 to 2^16 -1) or does the driver just map the 8-Bit values to 16-bit?

Best regards,

Zlatan

I am using a 64-Bit version of Matlab.

The RapidBlockData makes no sense for my application.

I want to work with the ADC Values not with the Volt values and single or int16 data type are to large.

Are the values real 16 bit values (0 to 2^16 -1) or does the driver just map the 8-Bit values to 16-bit?

Best regards,

Zlatan

### Re: Matlab ADC Conversion

Hi Zlatan,

The driver scales the values from an 8-bit value to a 16-bit value in the range -32512 to +32512 (these values are defined in the ps6000Api.h header file).

Instead of using the

The Instrument Driver's

Please note that Pico Technology is not responsible for the content of third party sites.

Regards,

The driver scales the values from an 8-bit value to a 16-bit value in the range -32512 to +32512 (these values are defined in the ps6000Api.h header file).

Instead of using the

*getBlockData*function to retrieve the data, you can undertake the following:- Call the
*ps6000SetDataBuffer*function to setup your data buffer using a*libpointer*object (set your data type to 'int16Ptr'). - After calling any other required functions, call
*runBlock*to start the data capture. - When the device is ready, call the
*ps6000GetValues*function to retrieve the data values. - Retrieve the 16-bit values from the libpointer object(s) corresponding to each channel.

*icdevice*object, you can call the following to view help text on the Instrument Driver's*ps6000SetDataBuffer*function e.g.:Code: Select all

```
instrhelp(ps6000DeviceObj, 'ps6000SetDataBuffer');
```

*ps6000GetValues*function is a member of the Instrument Driver's Block group, so you can view the help text for the function by passing the appropriate parameters to the*instrhelp*function.Please note that Pico Technology is not responsible for the content of third party sites.

Regards,

Hitesh

Software Dev. Engineer

Software Dev. Engineer

### Re: Matlab ADC Conversion

Thank you for your descriton but this thinks, but I have already done this:

I still don't understand what is the meaning of scaling in the context. I found this lines in the ps6000Api.h:

So can i just cut out the bits 14 to 7, if 15 bit is the msb bit with the sign information to get a correct int8 value without information lost? What is the seens of scaling the value to 16 bit, when only a 8 Bit ADC is used?

Best regards,

Zlatan

Code: Select all

```
function [numSamples, overflow, channelA ] ...
= getBlockData_Trigger_AUX(ps6000DeviceObj, startIndex, segmentIndex, ratio, ratioMode)
unitHandle = ps6000DeviceObj.DriverData.unitHandle;
% Initialise variable for array of libpointers
pBuffer = libpointer;
% total number of samples to set for data buffers
totalSamples = ps6000DeviceObj.DriverData.numPreTriggerSamples + ps6000DeviceObj.DriverData.numPostTriggerSamples;
% Store array of libpointers for channel A
pBuffer(1) = libpointer('int16Ptr', zeros(totalSamples, 1, 'int16'));
setBufferStatus = calllib('ps6000', 'ps6000SetDataBuffer', ...
unitHandle, 0, pBuffer(1), totalSamples, ratioMode);
% Call ps6000GetValues
[~, numSamples, overflow] = ...
calllib('ps6000', 'ps6000GetValues', unitHandle, startIndex, ...
totalSamples, ratio, ratioMode, segmentIndex, 0);
% Retrieve data values for enabled channels
channelA = pBuffer(1).Value;
end
```

Code: Select all

```
#define PS6000_MAX_OVERSAMPLE_8BIT 256
/* Although the PS6000 uses an 8-bit ADC, it is usually possible to
* oversample (collect multiple readings at each time) by up to 256.
* the results are therefore ALWAYS scaled up to 16-bits, even if
* oversampling is not used.
*
* The maximum and minimum values returned are therefore as follows:
*/
#define PS6000_MAX_VALUE 32512
#define PS6000_MIN_VALUE -32512
```

Best regards,

Zlatan

### Re: Matlab ADC Conversion

Hi Zlatan,

As mentioned before in an earlier post:

Regards,

As mentioned before in an earlier post:

The gain applied might not be an integer number therefore I do not think you could just cut out bits 14 to 7.hitesh wrote:The ps6000 driver scales the samples to 16 bits () as shown in section 3.3 (Voltage ranges) of the PicoScope 6000 Series Programmer's Guide so that digital gain can be applied for calibration purposes.

This also keeps it in line with the maximum ADC count values (-32768 to +32767) for our 12-bit and 16-bit resolution oscilloscopes in other ranges.

Regards,

Hitesh

Software Dev. Engineer

Software Dev. Engineer

### Re: Matlab ADC Conversion

Hi,

I know what was mentioned before, but I still understand How it is possible to get form:

Hardware ADC 8-Bit -> "Magic" Scaling -> True ADC 16-Bit.

Best regards,

Zlatan

I know what was mentioned before, but I still understand How it is possible to get form:

Hardware ADC 8-Bit -> "Magic" Scaling -> True ADC 16-Bit.

Best regards,

Zlatan

### Re: Matlab ADC Conversion

Hi Zlatan,

The device (and driver) supports downsampling of data. In the case of averaging, this can lead to an effective increase in resolution and so an 8-bit value would not suffice due to resulting effective number of bits required to hold the calculated value. Therefore a 16-bit number is used to allow for this.

The article on resolution enhancement in the PicoScope 6 software might be of interest - this is a software feature in the PicoScope 6 application.

I hope this helps.

The device (and driver) supports downsampling of data. In the case of averaging, this can lead to an effective increase in resolution and so an 8-bit value would not suffice due to resulting effective number of bits required to hold the calculated value. Therefore a 16-bit number is used to allow for this.

The article on resolution enhancement in the PicoScope 6 software might be of interest - this is a software feature in the PicoScope 6 application.

I hope this helps.

Hitesh

Software Dev. Engineer

Software Dev. Engineer