{"id":3381,"date":"2021-08-25T08:00:10","date_gmt":"2021-08-25T15:00:10","guid":{"rendered":"https:\/\/www.rbdinstruments.com\/blog\/?p=3381"},"modified":"2021-11-09T15:10:55","modified_gmt":"2021-11-09T23:10:55","slug":"programming-the-9103-with-python-part-3-high-speed","status":"publish","type":"post","link":"https:\/\/www.rbdinstruments.com\/blog\/programming-the-9103-with-python-part-3-high-speed\/","title":{"rendered":"Programming the 9103 With Python \u2013 Part 3: High Speed"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">For Part 3 of our series on programming the 9103 with Python, we&#8217;ve written an application that controls the 9103 in High-speed mode (which can sample as quickly as 500 samples\/second) and parses the high-speed messages so they are output to a text file using the same format as standard speed. (<a rel=\"noreferrer noopener\" aria-label=\"All Python samples for the 9103 can be found here (opens in a new tab)\" href=\"https:\/\/rbdinstruments.com\/products\/picoammeter\/tech.html#resources\" target=\"_blank\">All Python samples for the 9103 can be found here<\/a>.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em> (The <a rel=\"noreferrer noopener\" aria-label=\"high-speed option for the 9103 (opens in a new tab)\" href=\"https:\/\/rbdinstruments.com\/products\/picoammeter.html\" target=\"_blank\">High-speed option for the 9103<\/a> is available as an option when purchasing. The 9103 is also available with a High-voltage option and 90 V fixed or external bias)<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3331\" data-permalink=\"https:\/\/www.rbdinstruments.com\/blog\/programming-the-9103-with-python-part-1-standard-speed\/9103-python-1\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?fit=2200%2C1400&amp;ssl=1\" data-orig-size=\"2200,1400\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"9103-python-1\" data-image-description=\"&lt;p&gt;RBD 9103 usb picoammeter&lt;\/p&gt;\n\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?fit=584%2C372&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/plugins\/jquery-image-lazy-loading\/images\/grey.gif?w=584&#038;ssl=1\" data-original=\"https:\/\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1-1024x652.png\" alt=\"\" class=\"lazy wp-image-3331\"\/><noscript><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"584\" height=\"372\" data-attachment-id=\"3331\" data-permalink=\"https:\/\/www.rbdinstruments.com\/blog\/programming-the-9103-with-python-part-1-standard-speed\/9103-python-1\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?fit=2200%2C1400&amp;ssl=1\" data-orig-size=\"2200,1400\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"9103-python-1\" data-image-description=\"&lt;p&gt;RBD 9103 usb picoammeter&lt;\/p&gt;\n\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?fit=584%2C372&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?resize=584%2C372&#038;ssl=1\" alt=\"\" class=\"wp-image-3331\" srcset=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?resize=1024%2C652&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?resize=300%2C191&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?resize=768%2C489&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?resize=471%2C300&amp;ssl=1 471w, https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?w=1168&amp;ssl=1 1168w, https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?w=1752&amp;ssl=1 1752w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/noscript><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Setup the 9103 for High-Speed Sampling<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The 9103 has two different modes of operation &#8211; high-speed and standard-speed. These run the serial COM ports at different baud rates, so the port needs to be opened at the appropriate rate (the 9103 recalls the last baud rate used). This application does not detect \/ switch modes, but in our last post we programmed a utility to do just that &#8211;  it&#8217;s part of the set of python scripts included in the download.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The only difference between the code to open the port in standard speed or high speed is the baud rate (57.6k for standard, 230.4k for high) . All oher parameters are the same.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">High vs. Standard Speed Interval Sampling<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When interval sampling in Standard-speed mode, only the &#8216;I&#8217; command is available, which provides one sample per message. High-speed mode adds an additional command &#8211; &#8216;i&#8217; &#8211; which passes 10 samples per message, thereby reducing the round-trip overhead per sample. You would typlically only use this command for speeds faster than 40 samples \/ sec., however if can be used at slower speeds. We run a slower speed in our sample application to make it easier to observe the sample messages in the terminal.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(You would probably not choose to use the &#8216;i&#8217; command for slower sampling rates, because it can only provide one stability warning and range for every 10 samples<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parsing the High Speed Sample Messages<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The format for a High-speed sample includes the range and units, along with 10 samples:<\/p>\n\n\n\n<p class=\"has-small-font-size wp-block-paragraph\"><code>&amp;s=,Range=002nA,+0.0013,+0.0012,+0.0012,+0.0012,+0.0013,+0.0012,+0.0012,+0.0011,+0.0012,+0.0012,nA<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For this application, we write to a data-logging file just as we do in the Standard-speed Python application. However, we need to parse the 10 sample data to produce a similar, one-sample-per-line output if we want to be able to use the data interchangeably.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The only difference between the samples is that the High-speed samples are prefaced with a lower-case &#8216;s&#8217; (which could be easily replaced if necessary):<\/p>\n\n\n\n<p class=\"has-small-font-size wp-block-paragraph\"><code>s=,Range=002nA,+0.0013,nA<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">.<img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3384\" data-permalink=\"https:\/\/www.rbdinstruments.com\/blog\/programming-the-9103-with-python-part-3-high-speed\/9103-high-speed-python-output\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?fit=956%2C540&amp;ssl=1\" data-orig-size=\"956,540\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"9103 high-speed-python-output\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?fit=584%2C330&amp;ssl=1\" class=\"lazy wp-image-3384\" style=\"width: 600px;\" src=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/plugins\/jquery-image-lazy-loading\/images\/grey.gif?w=584&#038;ssl=1\" data-original=\"https:\/\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png\" alt=\"\"><noscript><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"584\" height=\"330\" data-attachment-id=\"3384\" data-permalink=\"https:\/\/www.rbdinstruments.com\/blog\/programming-the-9103-with-python-part-3-high-speed\/9103-high-speed-python-output\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?fit=956%2C540&amp;ssl=1\" data-orig-size=\"956,540\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"9103 high-speed-python-output\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?fit=584%2C330&amp;ssl=1\" class=\"wp-image-3384\" style=\"width: 600px;\" src=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?resize=584%2C330&#038;ssl=1\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?w=956&amp;ssl=1 956w, https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?resize=768%2C434&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/08\/9103-high-speed-python-output.png?resize=500%2C282&amp;ssl=1 500w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/noscript><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s the code for parsing the high-speed sample message:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>def parse_message_for_high_speed_sample( msg):<br>    if '&amp;s' in msg:<br>         msg = msg.strip('\\0')<br>         msg = msg.strip('&amp;')<br>         list = msg.split(',')<br>         i = 0<br>         stability = ''<br>         range  = ''<br>         new_msg = ''<br>         units = list[-1]  # gets last item<br>         list.pop()  # remove last item which is  units<br>         for value in list:<br>             if i==0:<br>                 stability = value<br>             elif i==1:<br>                 range = value<br>             else:<br>                 new_msg = new_msg + stability + ',' + range + ',' + value + units + '\\n'<br>             i=i+1<br>         return new_msg<br>     else:<br>         return ''<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s about all that&#8217;s necessary to create a compatible message, allowing you to mix High-speed and Standard-speed messaging in a compatible data-logging format<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part 3 of programing the 9103 USB picoammeter with Python &#8211; High Speed <a href=\"https:\/\/www.rbdinstruments.com\/blog\/programming-the-9103-with-python-part-3-high-speed\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":11,"featured_media":3331,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[159,163],"tags":[116,123,371],"class_list":["post-3381","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-9103-usb-picoammeter","category-software-for-surface-analysis","tag-116","tag-programming","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.rbdinstruments.com\/blog\/wp-content\/uploads\/2021\/06\/9103-python-1.png?fit=2200%2C1400&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p2DEXo-Sx","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/posts\/3381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/comments?post=3381"}],"version-history":[{"count":2,"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/posts\/3381\/revisions"}],"predecessor-version":[{"id":3411,"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/posts\/3381\/revisions\/3411"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/media\/3331"}],"wp:attachment":[{"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/media?parent=3381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/categories?post=3381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rbdinstruments.com\/blog\/wp-json\/wp\/v2\/tags?post=3381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}