| @@ 859-924 (lines=66) @@ | ||
| 856 | time.sleep(0.25) |
|
| 857 | return self.get_analog_level() |
|
| 858 | ||
| 859 | def get_digital_level(self, low=None, high=None): |
|
| 860 | """ Retrieve the digital low and high level of the provided channels. |
|
| 861 | ||
| 862 | @param list low: optional, if a specific low value (in Volt) of a |
|
| 863 | channel is desired. |
|
| 864 | @param list high: optional, if a specific high value (in Volt) of a |
|
| 865 | channel is desired. |
|
| 866 | ||
| 867 | @return: (dict, dict): tuple of two dicts, with keys being the channel |
|
| 868 | number and items being the values for those |
|
| 869 | channels. Both low and high value of a channel is |
|
| 870 | denoted in (absolute) Voltage. |
|
| 871 | ||
| 872 | Note: Do not return a saved low and/or high value but instead retrieve |
|
| 873 | the current low and/or high value directly from the device. |
|
| 874 | ||
| 875 | If no entries provided then the levels of all channels where simply |
|
| 876 | returned. If no digital channels provided, return just an empty dict. |
|
| 877 | ||
| 878 | Example of a possible input: |
|
| 879 | low = ['d_ch1', 'd_ch4'] |
|
| 880 | to obtain the low voltage values of digital channel 1 an 4. A possible |
|
| 881 | answer might be |
|
| 882 | {'d_ch1': -0.5, 'd_ch4': 2.0} {} |
|
| 883 | since no high request was performed. |
|
| 884 | ||
| 885 | The major difference to analog signals is that digital signals are |
|
| 886 | either ON or OFF, whereas analog channels have a varying amplitude |
|
| 887 | range. In contrast to analog output levels, digital output levels are |
|
| 888 | defined by a voltage, which corresponds to the ON status and a voltage |
|
| 889 | which corresponds to the OFF status (both denoted in (absolute) voltage) |
|
| 890 | ||
| 891 | In general there is no bijective correspondence between |
|
| 892 | (amplitude, offset) and (value high, value low)! |
|
| 893 | """ |
|
| 894 | # TODO: Test with multiple channel AWG |
|
| 895 | low_val = {} |
|
| 896 | high_val = {} |
|
| 897 | ||
| 898 | digital_channels = self._get_all_digital_channels() |
|
| 899 | ||
| 900 | if low is None: |
|
| 901 | low = digital_channels |
|
| 902 | if high is None: |
|
| 903 | high = digital_channels |
|
| 904 | ||
| 905 | # get low marker levels |
|
| 906 | for chnl in low: |
|
| 907 | if chnl not in digital_channels: |
|
| 908 | continue |
|
| 909 | d_ch_number = int(chnl.rsplit('_ch', 1)[1]) |
|
| 910 | a_ch_number = (1 + d_ch_number) // 2 |
|
| 911 | marker_index = 2 - (d_ch_number % 2) |
|
| 912 | low_val[chnl] = float( |
|
| 913 | self.query('SOUR{0:d}:MARK{1:d}:VOLT:LOW?'.format(a_ch_number, marker_index))) |
|
| 914 | # get high marker levels |
|
| 915 | for chnl in high: |
|
| 916 | if chnl not in digital_channels: |
|
| 917 | continue |
|
| 918 | d_ch_number = int(chnl.rsplit('_ch', 1)[1]) |
|
| 919 | a_ch_number = (1 + d_ch_number) // 2 |
|
| 920 | marker_index = 2 - (d_ch_number % 2) |
|
| 921 | high_val[chnl] = float( |
|
| 922 | self.query('SOUR{0:d}:MARK{1:d}:VOLT:HIGH?'.format(a_ch_number, marker_index))) |
|
| 923 | ||
| 924 | return low_val, high_val |
|
| 925 | ||
| 926 | def set_digital_level(self, low=None, high=None): |
|
| 927 | """ Set low and/or high value of the provided digital channel. |
|
| @@ 701-752 (lines=52) @@ | ||
| 698 | time.sleep(0.1) |
|
| 699 | return self.get_analog_level() |
|
| 700 | ||
| 701 | def get_digital_level(self, low=None, high=None): |
|
| 702 | """ Retrieve the digital low and high level of the provided/all channels. |
|
| 703 | ||
| 704 | @param list low: optional, if the low value (in Volt) of a specific channel is desired. |
|
| 705 | @param list high: optional, if the high value (in Volt) of a specific channel is desired. |
|
| 706 | ||
| 707 | @return: (dict, dict): tuple of two dicts, with keys being the channel descriptor strings |
|
| 708 | (i.e. 'd_ch1', 'd_ch2') and items being the values for those |
|
| 709 | channels. Both low and high value of a channel is denoted in volts. |
|
| 710 | ||
| 711 | Note: Do not return a saved low and/or high value but instead retrieve |
|
| 712 | the current low and/or high value directly from the device. |
|
| 713 | ||
| 714 | If nothing (or None) is passed then the levels of all channels are being returned. |
|
| 715 | If no digital channels are present, return just an empty dict. |
|
| 716 | ||
| 717 | Example of a possible input: |
|
| 718 | low = ['d_ch1', 'd_ch4'] |
|
| 719 | to obtain the low voltage values of digital channel 1 an 4. A possible answer might be |
|
| 720 | {'d_ch1': -0.5, 'd_ch4': 2.0} {'d_ch1': 1.0, 'd_ch2': 1.0, 'd_ch3': 1.0, 'd_ch4': 4.0} |
|
| 721 | Since no high request was performed, the high values for ALL channels are returned (here 4). |
|
| 722 | """ |
|
| 723 | low_val = {} |
|
| 724 | high_val = {} |
|
| 725 | ||
| 726 | digital_channels = self._get_all_digital_channels() |
|
| 727 | ||
| 728 | if low is None: |
|
| 729 | low = digital_channels |
|
| 730 | if high is None: |
|
| 731 | high = digital_channels |
|
| 732 | ||
| 733 | # get low marker levels |
|
| 734 | for chnl in low: |
|
| 735 | if chnl not in digital_channels: |
|
| 736 | continue |
|
| 737 | d_ch_number = int(chnl.rsplit('_ch', 1)[1]) |
|
| 738 | a_ch_number = (1 + d_ch_number) // 2 |
|
| 739 | marker_index = 2 - (d_ch_number % 2) |
|
| 740 | low_val[chnl] = float( |
|
| 741 | self.query('SOUR{0:d}:MARK{1:d}:VOLT:LOW?'.format(a_ch_number, marker_index))) |
|
| 742 | # get high marker levels |
|
| 743 | for chnl in high: |
|
| 744 | if chnl not in digital_channels: |
|
| 745 | continue |
|
| 746 | d_ch_number = int(chnl.rsplit('_ch', 1)[1]) |
|
| 747 | a_ch_number = (1 + d_ch_number) // 2 |
|
| 748 | marker_index = 2 - (d_ch_number % 2) |
|
| 749 | high_val[chnl] = float( |
|
| 750 | self.query('SOUR{0:d}:MARK{1:d}:VOLT:HIGH?'.format(a_ch_number, marker_index))) |
|
| 751 | ||
| 752 | return low_val, high_val |
|
| 753 | ||
| 754 | def set_digital_level(self, low=None, high=None): |
|
| 755 | """ Set low and/or high value of the provided digital channel. |
|