Built-in Conversions

These functions are general functions to convert data to another format. This is particularly useful for converting ADC data to mV or calculating the needed timebase for your PicoScope.

As the conversions talk to the PicoScope to retrieve the resolution and ADC limits, the PicoScope needs to be initialized using scope.open_unit() followed by the conversion.

Example

>>> import pypicosdk as psdk
>>> scope = psdk.psospa()
>>> scope.open_unit(resolution=psdk.RESOLUTION._8BIT)
>>> scope.mv_to_adc(100, channel_range=psdk.RANGE.V1)
3251
>>> scope.close_unit()

Reference

Bases: PicoScopeBase, shared_ps6000a_psospa

PicoScope OSP (A) API specific functions

Methods:

Name Description
adc_to_mv

Converts ADC values into millivolt (mV) values.

adc_to_volts

Converts ADC values into voltage (V) values.

interval_to_timebase

Converts a time interval (between samples) into a PicoScope timebase

mv_to_adc

Converts a millivolt (mV) value to an ADC value based on the device's

sample_rate_to_timebase

Converts sample rate to a PicoScope timebase value based on the

adc_to_mv(data, channel=None)

Converts ADC values into millivolt (mV) values. The data can be from a channel buffer (dict), numpy array or single value.

Parameters:
  • data ((dict, int, float, ndarray)) –

    ADC values to be converted to millivolt values

  • channel ((int, CHANNEL, str), default: None ) –

    Channel the ADC data is from. If the data is a channel buffer dict, set to None. Defaults to None.

Returns:
  • dict | float | ndarray

    dict, int, float, np.ndarray: Data converted into millivolts (mV)

adc_to_volts(data, channel=None)

Converts ADC values into voltage (V) values. The data can be from a channel buffer (dict), numpy array or single value.

Parameters:
  • data ((dict, int, float, ndarray)) –

    ADC values to be converted to millivolt values

  • channel ((int, CHANNEL, str), default: None ) –

    Channel the ADC data is from. If the data is a channel buffer dict, set to None. Defaults to None.

Returns:
  • dict | float | ndarray

    dict, int, float, np.ndarray: Data converted into volts (V)

interval_to_timebase(interval, unit=TIME_UNIT.S)

Converts a time interval (between samples) into a PicoScope timebase value based on the attached PicoScope.

This function will return the closest possible timebase. Use get_nearest_sample_interval(interval_s) to get the full timebase and actual interval achieved.

Parameters:
  • interval (float) –

    Desired time interval between samples

  • unit (TIME_UNIT, default: S ) –

    Time unit of interval.

mv_to_adc(mv, channel_range, channel=None)

Converts a millivolt (mV) value to an ADC value based on the device's maximum ADC range.

Parameters:
  • mv (float) –

    Voltage in millivolts to be converted.

  • channel_range (int) –

    Range of channel in millivolts i.e. 500 mV.

  • channel (CHANNEL, default: None ) –

    Channel associated with mv. The probe scaling for the channel will be applied if provided.

Returns:
  • int( int ) –

    ADC value corresponding to the input millivolt value.

sample_rate_to_timebase(sample_rate, unit=SAMPLE_RATE.MSPS)

Converts sample rate to a PicoScope timebase value based on the attached PicoScope.

This function will return the closest possible timebase. Use get_nearest_sample_interval(interval_s) to get the full timebase and actual interval achieved.

Parameters:
  • sample_rate (int) –

    Desired sample rate

  • unit (SAMPLE_RATE, default: MSPS ) –

    unit of sample rate.