镭射激光器EzLaze3的二次开发




通信:RS232接口


命令语法

 <前缀><地址><命令串><参数><终止符> 

Field

Description

Prefix

一个分号字符“;”(59),必须放在所有命令的前面,当设备接收到前缀符后会重置命令输入缓存区。

Address

两个ASCII 字符,激光使用“LA” 作为其地址

Command String

Commands are specific to each device -- see the following sections for the commands that each device supports.

Parameters

Some commands may have parameters which immediately follow the command string. Multiple parameters are separated by commas(逗号). You must supply the correct number of characters for all parameters under all circumstances. For example, if a command expects a three-digit value, then the parameter must in the form “000”, “001”… “100” etc.

Terminator

ASCII 回车字符(13),接受设备在终端没有收到终止符时不会处理任何命令。


基本命令:

  • 能量          ;LAAT###   000-255
  •  频率           ;LARR###   000-255
  •  激发模式     ;LAMO#     0连续 1单枪 2爆发
  • 镭射指示灯   亮度 ;LASP###    000-255   是否闪烁  ;LASB#  0不闪 1闪烁  闪频 ;LABR###  000-255  
  • 波长选择     IR高低   ;LAHS#       1 低 2高     Green高低   ;LAHS#   3 低 5高   
  • 爆发次数    ;LABU####     0000-0050
  • 形状(SlitX、SlitY):     ;LAXS###   ;LAYS###        000-255
  •  能量高 ;LAENH  能量低 ;LAENL
  •  镭射开枪      ;LAGO   
  •  停止开枪      ;LAST  
  •  开启激光      ;LAON  
  • 关闭激光       ;LAOF  
  • 计数   ;LASC  统计激光到当前时间为止一共激发了多少次
控制流程
  初始化激光

打开串口

Send “;LASM1” 打开激光控制串口。激光会返回一个消息“ok”

 Send “;LASS” 检查联动装置和电机的安全状态,在处理前应等待电机移动位被清零

 若安全联锁装置可靠, send “;LAON” 将激光置为待机模式。

  保持通讯
当激光被打开后发送了“;LAON”命令必须定时(至少两秒一次)发送命令给激光,否则激光会自动关闭。 使用了“;LASS”来定时间检查激光状态。
   发射激光

设定激光的能量、频率、激发模式、波长、光圈 

Send “;LAGO” 发射激光 

Send “;LAST” 停止 发射激光 

Send “:LAOF”将激光置为停止模式

程序实现

  1)  打开串口
      串口底层通讯调用的是开源的RS232控制源rs232.h与rs232.c,它所提供的函数
      int RS232_OpenComport(int comport_number, int baudrate, const char *mode)
     可以用来打开某个指定串口,三个参数分别代表串口号、波特率、通信协议。
    使用时设置 baudrate=9600,char mode[]={'8','N','1',0},当函数返回0时表示已成功打开串口
 2) 向串口发送信息
void RS232_cputs(int comport_number, const char *text)  /* sends a string to serial port */
{
  while(*text != 0)   RS232_SendByte(comport_number, *(text++));
}
        调用方法:RS232_cputs(cport_nr, ";LASS\n");   //发送 ";LASS\n" //检查安全连锁状态
  3) 定时间检查激光状态
       采用多线程编程,为查询事件新建了一个线程。
          #include <pthread.h>
    int res; 
    pthread_t a_thread,b_thread; 
    res = pthread_create(&a_thread, NULL,thread_function,NULL); 
    if (res!=0) 
    { 
        printf("Create pthread error!/n"); 
        return 1; 
    }
交互界面

使用QT编写gui界面



 




















评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值