Skip to content

Add functions to configure both axis #9

Description

@ediordna

Consider adding functions for configuring x- and y-axis:

    def configure_x_axis(self, position: float = 4.9, horizontal_time: int = 10):
        '''Configures the horizontal x-axis to the correct range and position.
        It is only possible to configure it in this order, otherwise an error is raised.

        :param position: interval between trigger and reference point in seconds, defaults to 4.9
        :type position: int, optional
        :param horizontal_time: full-scale horizontal time in seconds, defaults to 10
        :type horizontal_time: int, optional
        :raises ValueError: If writing of Position wasn't successful
        :raises ValueError: If writing of Range wasn't successful
        '''
        # sets the full-scale horizontal time range in seconds for the main window
        self.write_raw(f':TIMebase:RANGe {horizontal_time}')
        if float(self.query_raw(':TIMebase:RANGe?')) != float(horizontal_time):
            raise ValueError('Osci: Timebase:RANGe not set successful!')
        # sets the time interval between trigger event and display reference point on the screen
        self.write_raw(f':TIMebase:POSition {position}')
        if float(self.query_raw(':TIMebase:POSition?')) != float(position):
            raise ValueError('Osci: TIMebase:POSition not set successful!')

    def configure_y_axis(self, channel: int, v_range: int, v_offset: int=0):
        '''Defines the full-scale vertical axis (8 parts) of the selected channel.

        :param channel: choose a channel from 1 to 4
        :type channel: int
        :param v_range: defines the vertical range, e.g. 8 for 1A/
        :type v_range: int
        :param v_offset: defines the vertical offset from the center screen to the bottom,
                         defaults to 0
        :type v_offset: int
        '''
        self.write_raw(f':CHANnel{channel}:RANGe {v_range}')
        if float(self.query_raw(f':CHANnel{channel}:RANGe?')) != float(v_range):
            raise ValueError('Osci: CHANnel:RANGe not set successful!')
        self.write_raw(f':CHANnel{channel}:OFFSet {v_offset}')
        if float(self.query_raw(f':CHANnel{channel}:OFFSet?')) != float(v_offset):
            raise ValueError('Osci: CHANnel:OFFSet not set successful!')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions