Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to configure both axis #9

Open
ediordna opened this issue Apr 25, 2024 · 0 comments
Open

Add functions to configure both axis #9

ediordna opened this issue Apr 25, 2024 · 0 comments

Comments

@ediordna
Copy link

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!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant