[其他MCU] LPC810 与 Labview 快递设计控制

[复制链接]
 楼主| 舒斯特尔 发表于 2015-12-23 17:10 | 显示全部楼层 |阅读模式
大多情况下Labview 与单片机间的通信大多数都是通过串口通信,但是要注意Labview 的串口通信是属于VISA模块,可惜LabView 默认情况下是不安装VISA驱动的,所以要手动安装驱动在官网的 资源与服务->NI Drivers -> NI VISA。


    开始接触NI的时候,很多概念都比较低触,只能边学边用。
先做个控制灯的来练练先。

    串口首先就是要做一个串口通信的调试


当能够正常接发数据的时间才开始修改成自己想要的内容,例如图上LED灯时就是有布尔开关转换来数组

程序柜架图如下:

 楼主| 舒斯特尔 发表于 2015-12-23 17:11 | 显示全部楼层
LPC810 的关键代码如下
  1. int main(void)
  2. {
  3.         SystemCoreClockUpdate();
  4.         Board_Init();

  5.         Init_UART_PinMux();
  6.         Chip_UART_Init(LPC_USART0);
  7.         Board_LED_Set(0, false);

  8.         /* Allocate UART handle, setup UART parameters, and initialize UART
  9.            clocking */
  10.         setupUART();
  11.       
  12.         #if 0
  13.         /* Transmit the welcome message and instructions using the
  14.            putline function */
  15.         putLineUART("LPC8XX USART API ROM polling Example\r\n");
  16.         putLineUART("Enter a string, press enter (CR+LF) to echo it back:\r\n");

 楼主| 舒斯特尔 发表于 2015-12-23 17:11 | 显示全部楼层
  1.         /* Get a string for the UART and echo it back to the caller. Data is NOT
  2.            echoed back via the UART using this function. */
  3.         getLineUART(recv_buf, sizeof(recv_buf));
  4.         recv_buf[sizeof(recv_buf) - 1] = '\0';        /* Safety */
  5.         if (strlen(recv_buf) == (sizeof(recv_buf) - 1)) {
  6.                 putLineUART("**String was truncated, input data longer than "
  7.                                         "receive buffer***\r\n");
  8.         }
  9.         putLineUART(recv_buf);

  10.         /* Transmit the message for byte/character part of the exampel */
  11.         putLineUART("\r\nByte receive with echo: "
  12.                                 "Press a key to echo it back. Press ESC to exit\r");
  13.         #endif
  14.         putLineUART("Labview control LPC8XX  Example\r\n");
 楼主| 舒斯特尔 发表于 2015-12-23 17:12 | 显示全部楼层
  1.      /* Endless loop until ESC key is pressed */
  2.         recv_buf[0] = '\n';
  3.         //while (recv_buf[0] != ESCKEY) {
  4.         while (recv_buf[0] != ESCKEY) {
  5.                 /* Echo it back */
  6.                 LPC_UARTD_API->uart_put_char(uartHandle, recv_buf[0]);

  7.                 /* uart_get_char will block until a character is received */
  8.                 recv_buf[0] = LPC_UARTD_API->uart_get_char(uartHandle);
  9.                 switch (recv_buf[0])
  10.                 {
  11.                         case '0':
  12.                           Board_LED_Set(0, false);
  13.                           Board_LED_Set(1, false);
  14.                           break;
  15.                         case '1':
  16.                           Board_LED_Set(0, true);
  17.                           Board_LED_Set(1, false);
  18.                           break;
  19.                         case '2':
  20.                           Board_LED_Set(0, false);
  21.                           Board_LED_Set(1, true);
  22.                           break;
 楼主| 舒斯特尔 发表于 2015-12-23 17:12 | 显示全部楼层
  1.                         case '3':
  2.                           Board_LED_Set(0, true);
  3.                           Board_LED_Set(1, true);
  4.                           break;
  5.                         default:
  6.                           break;
  7.                 }
  8.         }
  9.       
  10.       
  11.       

  12.         /* Transmit the message for byte/character part of the exampel */
  13.         putLineUART("\r\nESC key received, exiting\r\n");

  14.         return 0;
  15. }
您需要登录后才可以回帖 登录 | 注册

本版积分规则

25

主题

277

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部