如何编译LabVIEW代码并烧录到Arduino上?
点击Shania最近想实现“4位数码管显示Arduino模拟端口读取到的电压值”的效果,发现用LINX工具包写的程序实现效果并不好,虽然可以显示出数值来,但是它是一位一位显示的;不加延时以最快的速度运行还是闪得脑阔疼……还是不够快啊!(得快到肉眼看不出闪烁效果)
后面经同事提醒,才意识到一个问题:LabVIEW与Arduino使用LINX工具包是基于串口通信的,通讯一来一回程序运行速度快不起来!无法满足“同时”显示4位数字的效果。那这个效果怎么实现呢?
既然串口通信太慢,那要是直接把LabVIEW程序编译并下载到Arduino开发板上呢?这样就可以避免通信的延时,还可以脱离PC!
这里就要用到LabVIEW另外一个工具包——Arduino Compatible Compiler For LabVIEW(后面简称为编译器),通过它我们可以编译LabVIEW代码并下载到Arduino开发板中,使VI脱离PC机,嵌入到Arduino硬件中独立运行!
在使用这款编译器之前,PC端必须下载安装Arduino IDE 1.5.7以上版本(最好是下个最新版本)。
Arduino IDE 启动页面
Arduino IDE下载地址:
https://www.arduino.cc/en/Main/Software?setlang=cn
1
打开JKI VI Package Manager,选择“Arduino Compatible Compiler For LabVIEW Home/Student”(第一个:家庭/学生版)。
PS:因为这个工具包不免费啊!家庭/学生版的可以免费试用。
安装成功后,打开LabVIEW,在“Tools”菜单中就可以找到“Arduino Compatible Compiler For LabVIEW”选板,打开之后可以看到以下页面:
2
下载LabVIEW VI到Arduino硬件
打开编译器主页面后,在“Tools”里先选择对应的Arduino开发板,再选择对应的连接端口;
如果没有找到对应的连接端口,在“Tools”菜单下选择“Detect Ports”刷新一下连接的端口,再选择相应Arduino硬件板的连接端口。(跟Arduino IDE的操作是一样)
3
随便打开一个范例,点击编译器主页面第四个图标“Compile and Download”,没问题的话范例就会下载到Arduino开发板上!
这个时候拔掉数据线,用电池单独给Arduino开发板供电,你就会发现:程序已经跑起来啦!完全脱离了PC端!很神奇有木有?
4
在VI已经编写完成的情况下编译代码并下载到Arduino开发板上。
单击“File”菜单,选择”Load VI”,加载要编译下载到硬件版上的VI,然后选择工具栏中第四个图标“Compile and Download”,出现以下页面说明编译已经完成!
常用的Arduino开发板
Arduino Yun
Arduino Uno
Arduino Due
Arduino Mega
Arduino Leonardo
Arduino Nano






1
“Arduino Compatible Compiler For LabVIEW”选板
编译器实际上是以C语言的编程方式来进行代码部署的,有一些功能函数在该编译器中并不支持,所以尽量使用程序框图“Arduino Compatible Compiler For LabVIEW”选板下的VIs来进行嵌入式编程,否则编译可能出错。
2
非英文LabVIEW版本将功能函数翻译成本地语言后,编译器有可能无法识别到该功能函数,导致编译出错,所以使用该编译器,尽量使用2014以上版本的英文版LabVIEW!
3
控件和显示控件禁止使用字符!斜杆“/”和反斜杠“”,还有“:”、“;”、“#”和“&”,这些字符是编译器的特殊字符,如果使用也将导致编译出错。
--end--
声明:本文章由网友投稿作为教育分享用途,如有侵权原作者可通过邮件及时和我们联系删除:freemanzk@qq.com