<jupyter_start><jupyter_text>Using Rigol Class to control oscilloscope<jupyter_code>from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
import rigol
# initialize and set backend to usbtmc
r = rigol.Rigol("usbtmc")<jupyter_output>1: Rigol Technologies - DS1000 SERIES 
Enter the number of the device you want to connect to: 1
Asking *IDN? returns: Rigol Technologies,DS1102E,DS1EB142004074,00.03.01.00.00<jupyter_text>Query the waveform intensity  Let's take a look at some of the methods in the Rigol class<jupyter_code>help(r)<jupyter_output>Help on instance of Rigol in module rigol:

class Rigol
 |  Methods defined here:
 |  
 |  __init__(self, backend, idProduct=None, idVendor=None)
 |  
 |  acquireAverages(self, count)
 |      The commands set the average numbers in Average mode. <count>
 |      could be and integer of 2 times the power of N within 2 and 256.
 |  
 |  acquireMemDepth(self, depth)
 |      The commands set and query the memory depth of the oscilloscope. <depth>
 |      could be LONG (long memory) or NORMal (normal memory)
 |  
 |  acquireMode(self, mode)
 |      The commands set the current acquire mode of the oscilloscope.
 |      <mode> could be RTIM (Real time Sampling) or ETIM (Equivalent Sampling).
 |  
 |  acquireType(self, typ)
 |      The commands set the current acquire type of the oscilloscope.
 |      <type> could be NORM, AVER or PEAK.
 |  
 |  askAcquireAverages(self)
 |      The query returns 2, 4, 8, 16, 32, 64, 128 or 256.
 |  
 |  askAcquireMemDepth(self)
 |      The query returns LONG or[...]<jupyter_text>Do note that I'm writing all of these methods so that the oscilloscope can be controlled without looking at the programmers manual at all, but you can always write in your own commands (in case I have not implemented them) by using the Rigol.dev.write() or Rigol.dev.ask() methods.  Basic Methods<jupyter_code>r.stop()
r.auto()
r.run()<jupyter_output><empty_output><jupyter_text>Display Methods<jupyter_code>r.askIntensity()<jupyter_output><empty_output><jupyter_text>Set intensity to 32.<jupyter_code>r.intensity(32)<jupyter_output><empty_output><jupyter_text>Trigger Methods Set trigger source for CHAN1 to EDGE<jupyter_code>r.triggerSource("EDGE", "CHAN1")<jupyter_output><empty_output><jupyter_text>Query trigger source for edge<jupyter_code>r.askTriggerSource("EDGE")<jupyter_output><empty_output><jupyter_text>Channel Methods Turn on channel 2 and then turn it off<jupyter_code>r.channelDisplay(2)
r.channelDisplay(2, on=False)<jupyter_output><empty_output><jupyter_text>Turn on channel 1<jupyter_code>r.channelDisplay(1)<jupyter_output><empty_output><jupyter_text>Set channel scale<jupyter_code>r.channelScale(1, 1)
r.askChannelScale(1)<jupyter_output><empty_output><jupyter_text>You can also access the volt1_scale attribute (Updated everytime you send the channelScale() method)<jupyter_code>r.volt1_scale<jupyter_output><empty_output><jupyter_text>Measure Methods Measure peak to peak voltage<jupyter_code>r.measureVpp(1)<jupyter_output><empty_output><jupyter_text>Key Methods Unlock the buttons on the oscilloscopeNote:  The next time you send a usb command or query, the keys will relock<jupyter_code>r.keyLock(enable=False)<jupyter_output><empty_output><jupyter_text>TimeBase Methods Set a time scale in sec/division<jupyter_code>r.timebaseScale(5e-3)<jupyter_output><empty_output><jupyter_text>Ask for the time scale in sec/division<jupyter_code>r.askTimebaseScale()<jupyter_output><empty_output><jupyter_text>There is also an attribute you can look up without querying the oscilloscope.  (Potentially faster)This attribute will update every time you send the timebaseScale() method to the oscilloscope.<jupyter_code>r.time_scale<jupyter_output><empty_output><jupyter_text>Waveform Methods plot something<jupyter_code>% matplotlib inline
r.run()
r.waveformPointsMode("NORM")
x = r.getTimebase()
y = r.getWaveform("CHAN1")
plt.plot(x, y)
plt.xlabel("TIME (SECONDS)")
plt.ylabel("VOLTAGE (V)")
plt.title("Oscilloscope Reading")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09855710442651015, 'fraction_numerical': 0.017119100024455856, 'mean_word_length': 6.25177304964539, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '17', 'dir': 'jupyter-structured-clean-dedup', 'id': '260637', 'license': 'MIT', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1386, 'n_words': 376, 'path': 'Usage and Examples.ipynb', 'repo_name': 'aplstudent/Rigol-DS1000DE', 'size': '4089'}