{"id":1057,"date":"2017-06-09T08:40:47","date_gmt":"2017-06-09T12:40:47","guid":{"rendered":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/?p=1057"},"modified":"2023-08-05T15:58:39","modified_gmt":"2023-08-05T19:58:39","slug":"labview-programs-to-control-a-peristaltic-pump","status":"publish","type":"post","link":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/labview-programs-to-control-a-peristaltic-pump\/","title":{"rendered":"Labview programs to control a peristaltic pump"},"content":{"rendered":"<p>The Ladner group (Joe Batts, Weiming Qi, and Matt McKinney) has been hard at work building a field-deployable membrane unit. One key step in this process was creating Labview programs to control our peristaltic pumps. This is a common enough endeavor (especially for Masterflex pumps that are often used) that we thought there would be great examples available online. But we didn&#8217;t find any that clearly explained what to do. So here is what we came up with. Hopefully it will be useful for others. We\u2019ve done this on a few pumps, but the most recently purchased was Masterflex EW-07551-20. (Or just 07551-20; not sure if the EW is necessary).<\/p>\n<p>Our approach was to write two Labview programs (what Labview calls &#8220;virtual instruments&#8221; [VIs]); one to initialize the pump and one to control it. These are meant to be embedded in&nbsp;an umbrella program that controls and reads signals from all the other components in the system (flow meters, pressure gauges, etc.).<\/p>\n<p><a href=\"https:\/\/cecas.clemson.edu\/ladnergroup\/labview\/Masterflex_initialize.vi\">Masterflex_initialize.vi<\/a><\/p>\n<p><a href=\"https:\/\/cecas.clemson.edu\/ladnergroup\/labview\/Masterflex_simple_control.vi\">Masterflex_simple_control.vi<\/a><\/p>\n<p>And here is a YouTube video where I explain the nuts and bolts of the programs.<\/p>\n<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/6CEV6eVOuEw?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><em><strong>Update, August 2018<\/strong><\/em><\/p>\n<p>Someone who was trying to use this method sent some feedback and we had an email exchange. The programs weren&#8217;t working for him until he did several things:<\/p>\n<ol>\n<li>He hadn&#8217;t had NI-VISA installed, so he did that to be able to setup the COM1 (RS232) port.<\/li>\n<li>In the Masterflex initialize program there was a breakpoint defined, which he removed.<\/li>\n<li>He had an error of &#8220;Type Definition &#8216;Boolean&#8217;: Type definition not found or contains errors.&#8221; It seems that the in the Masterflex control program the (forward\/reverse) direction toggle switch is not forward compatible with LabVIEW 2018. He right-clicked it and replaced it with a horizontal toggle switch from the menu. In other words, he replaced the &#8220;old&#8221; switch with a &#8220;new&#8221; one.<\/li>\n<li>His particular pump could not go 300 rpm, so it did not respond to his commands. Any value &lt;= 100 worked with his pump.<\/li>\n<\/ol>\n<p>After those fixes (and perhaps other little things he didn&#8217;t tell me about!) the programs worked for him on his system.<\/p>\n<p>Then he had the problem of licensing: he only had a one-week trial of Labview! So he did some digging and figured out how to send commands to COM1 using the command line. Now he is sending them via system calls from the R programming language. No LabVIEW required. Pretty good work!<\/p>\n<p>Here is the R script:<\/p>\n<pre># set up the serial port\nsystem(\"mode COM1 baud=4800 parity=o data=7 stop=1\", intern=T)\n\n# initialize the pump\nzzz &lt;- system(\"cmd.exe\", input=\"echo \\x05 &gt; COM1\", intern=TRUE)\n# this command will cause the pump to be P00 for some reason\nzzz &lt;- system(\"cmd.exe\", input=\"echo \\x02P01 &gt; COM1\", intern=TRUE)\n# for some reason need to run a command to initialize the pump to P01\nzzz &lt;- system(\"cmd.exe\", input=\"echo P01S+20G0 &gt; COM1\", intern=TRUE)\n\n# send commands to the pump\nzzz &lt;- system(\"cmd.exe\", input=\"echo P01S+20G0 &gt; COM1\", intern=TRUE)\nzzz &lt;- system(\"cmd.exe\", input=\"echo P01S+80G0 &gt; COM1\", intern=TRUE)\n\n# halt the pump\nzzz &lt;- system(\"cmd.exe\", input=\"echo P01H &gt; COM1\", intern=TRUE)<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Ladner group (Joe Batts, Weiming Qi, and Matt McKinney) has been hard at work building a field-deployable membrane unit.[&#8230;]<\/p>\n","protected":false},"author":5,"featured_media":1210,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[23,28],"tags":[],"class_list":["post-1057","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lab-techniques","category-videos"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/cecas.clemson.edu\/ladnergroup\/blog\/wp-content\/uploads\/2017\/12\/IMG_5272.jpg?fit=4032%2C3024&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p4FV6M-h3","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/posts\/1057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/comments?post=1057"}],"version-history":[{"count":6,"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/posts\/1057\/revisions"}],"predecessor-version":[{"id":2218,"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/posts\/1057\/revisions\/2218"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/media\/1210"}],"wp:attachment":[{"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/media?parent=1057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/categories?post=1057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cecas.clemson.edu\/ladnergroup\/blog\/wp-json\/wp\/v2\/tags?post=1057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}