{"id":12567,"date":"2016-02-24T20:00:52","date_gmt":"2016-02-25T04:00:52","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=12567"},"modified":"2021-06-16T14:23:47","modified_gmt":"2021-06-16T21:23:47","slug":"how-to-use-linx-custom-commands","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/how-to-use-linx-custom-commands\/","title":{"rendered":"How to Use LINX Custom Commands"},"content":{"rendered":"<p>For those of you using <a href=\"https:\/\/www.labviewmakerhub.com\/doku.php?id=libraries:linx:start\">LabVIEW MakerHub LINX<\/a> to control your microcontroller with <a href=\"http:\/\/ni.com\/labview\/\">LabVIEW<\/a>, there is a way to implement some Arduino code and libraries and add extra functionality to your project. LINX supports &#8220;<a href=\"https:\/\/www.labviewmakerhub.com\/doku.php?id=learn:tutorials:libraries:linx:misc:adding_custom_command\">custom commands<\/a>&#8221; where you can implement a custom function to do pretty much anything you want that isn&#8217;t supported directly in LINX. In <a href=\"http:\/\/www.instructables.com\/id\/LCD-Control-with-LabVIEW\/\">my Instructable<\/a>, I go over an example of writing a custom command for the <a href=\"https:\/\/digilent.com\/shop\/pmodclp-character-lcd-with-parallel-interface\/\">PmodCLP<\/a>\u00a0which\u00a0uses <a href=\"https:\/\/en.wikipedia.org\/wiki\/Parallel_communication\">parallel data interface<\/a> (basically writes digital channels high or low quickly). Because LINX only has a loop rate of about 200Hz, it is too slow to directly control the PmodCLP. Thus the need for a custom command!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12568 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_121254-600x592.jpg\" alt=\"20150629_121254\" width=\"600\" height=\"592\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_121254-600x592.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_121254-768x758.jpg 768w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_121254-1024x1011.jpg 1024w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br \/>\nTo add a custom command, you&#8217;ll need the <a href=\"https:\/\/www.arduino.cc\/en\/Main\/Software\">Arduino IDE<\/a> or <a href=\"http:\/\/chipkit.net\/tag\/mpide\/\">MPIDE <\/a>so that you can edit the LINX firmware to add your custom command. This involves creating a function that passes in an input array from LabVIEW, the number of bytes of the input, a response array, and the number of bytes the response is. The response will contain the information that you send back to LabVIEW. For more information on how exactly to write the custom command, check out the instructable linked above. Once you&#8217;re done editing the code, upload the firmware to your board.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12572 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/mpide-600x520.png\" alt=\"mpide\" width=\"600\" height=\"520\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/mpide-600x520.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/mpide-110x96.png 110w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/mpide.png 691w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>In LabVIEW, you can access the custom command VI by going to Functions Palette-&gt;MakerHub-&gt;LINX-&gt;Utilities-&gt;Custom Command to call the custom function. In the custom command VI, you will have the input which is a byte array containing the information that you are sending to the custom command (the input array mentioned earlier). \u00a0You&#8217;ll also need to feed in the number you assigned your custom command (you can \u00a0have up to 16). A picture of how to use the custom command VI is below. The VI executes the custom command that you wrote and returns the information that you told it to.<\/p>\n<p><span style=\"font-size: 14px; line-height: 1.857;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12570 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/customblockclp.png\" alt=\"customblockclp\" width=\"508\" height=\"194\" \/>Custom commands can be used for Arduino libraries as well! I wrote a custom command for the DHT11 humidity and temperature sensor using an existing Arduino library that reads information from the sensor each time the custom command is called. Try using custom commands for anything that can&#8217;t be done natively in LINX.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-12569 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_151955-600x338.jpg\" alt=\"20150629_151955\" width=\"600\" height=\"338\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_151955-600x338.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_151955-768x432.jpg 768w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_151955-1024x576.jpg 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_151955-800x450.jpg 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/20150629_151955-1200x675-cropped.jpg 1200w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-12567 jlk' data-task='like' data-post_id='12567' data-nonce='3c15ebf169' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-12567 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-12567 jlk' data-task='unlike' data-post_id='12567' data-nonce='3c15ebf169' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-12567 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-12567 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>How to run custom commands on LINX.<\/p>\n","protected":false},"author":33,"featured_media":12573,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4323,1563],"tags":[],"ppma_author":[4481],"class_list":["post-12567","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","category-guide"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/PmodCLP-obl-400.jpg","authors":[{"term_id":4481,"user_id":33,"is_guest":0,"slug":"sudharsan-sukumar","display_name":"Sudharsan Sukumar","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/ade8dccd0e229a47c849e77c724cb3a6?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Sukumar","last_name_2":"","first_name":"Sudharsan","first_name_2":"","job_title":"","description":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/12567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=12567"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/12567\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/12573"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=12567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=12567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=12567"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=12567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}