Posted Wed, 17 May 2023 23:23:47 GMT by Bolles, David
<span style="font-size:11pt;"><span style="font-family:Calibri,sans-serif;"><span style="font-size:12.0pt;"><span style="font-family:&quot;Verdana&quot;,sans-serif;">Hello,<br> <br> We are using a MSO44 scope and we are trying to capture the time delay between channels 1 and 2.<br> We are trying to get the average delay from 100 samples.<br> What we found is that if we do not put in a Thread.Sleep <strong>(highlighted)&#160;</strong>of at least 300ms, a number of samples in the beginning are 9.91E37 and the rest of the samples are good. Also when reading the ESR register, we are seeing a 0x32 or command error. We don't know why.<br> Our code snippet to get the time delay is shown below:&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160;<br> <br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160;_device.Write(&quot;:STOP&quot;);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; _device.Write(_s.SR_CLEAR_MEASURE);<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //_device.Write(_s.SR_READ_EVENT_STATUS_REG);<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //temp = _device.ReadString();<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //tmp = Convert.ToUInt32(temp);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //Logger.ToSystem(&quot;ESR Stat: 0x&quot; + tmp.ToString(&quot;X2&quot;));<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; _device.Write(&quot;:RUN&quot;);<br> <br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; _device.Write(&quot;MEASUREMENT:DELETE \&quot;MEAS1\&quot;&quot;);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; _device.Write(&quot;MEASUrement:MEAS1:TYPE DELAY&quot;);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; _device.Write(&quot;MEASUrement:MEAS1:SOUrce1 CH1&quot;);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; _device.Write(&quot;MEASUrement:MEAS1:SOUrce2 CH2&quot;);<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <strong>Thread.Sleep(1000); //1 sec delay bad data, 3 sec delay good data&#160;</strong><br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //_device.Write(_s.SR_READ_EVENT_STATUS_REG);<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //temp = _device.ReadString();<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //tmp = Convert.ToUInt32(temp);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; //Logger.ToSystem(&quot;ESR Stat: 0x&quot; + tmp.ToString(&quot;X2&quot;));<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; _device.Write(&quot;MEASUrement:MEAS1:RESUlts:CURRentacq:MEAN?&quot;);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; temp = RemoveCommonEscapeSequences(_device.ReadString());<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; int numavg = 100;<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; for (int i = 0; i &lt; numavg; i++)<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; {<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; _device.Write(&quot;MEASUrement:MEAS1:RESUlts:CURRentacq:MEAN?&quot;);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; temp = RemoveCommonEscapeSequences(_device.ReadString());<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; Logger.ToSystem(&quot;Delay #&quot; + (i+1).ToString() + &quot;: &quot; + temp);<br> <br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; double delay = Convert.ToDouble(temp);<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; // total += delay * 1e+9; // Convert to ns<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; total += delay; // Convert to ns<br> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; }</span></span></span></span><br> &#160;
Posted Thu, 18 May 2023 21:38:50 GMT by Teles, Afonso
Hi David,<br> <br> After querying the event status register, you can see the warning message that generated that error by doing <code>ALLEV?</code> .<br> That should give you more information on which command is giving you trouble. You could also query <code>*ESR?</code> after every write command, which is what I do in my own scripts with a <code>write_safer()</code> function I create for that purpose.<br> &#160;

You must be signed in to post in this forum.