0

情况 我有一个东方电机 LSD-KD 步进电机驱动器,我通过 PC -> USB -> RS232 -> RS485 -> 驱动程序连接。驱动采用RS485 Modbus RTU,传输速度38400,数据位8,停止位1,奇偶校验,从机数2。

我正在发送试图发送 0x02,0x06,0x02,0x4b,0x00,0x50,0xf8,0x6b 应该正确的寄存器。我没有得到任何回应,C-DAT/C-ERR 变红。

我有这段 Javascript 代码

var crc = require('crc');
var SerialPort = require("serialport").SerialPort
var serialPort = new SerialPort("/dev/cu.usbserial", {
  baudrate: 38400,
  databits: 8,
  stopbits: 1,
  parity: 'even'
});

var buff = new Buffer([0x02,0x06,0x02,0x4b,0x00,0x50,0xf8,0x6b]);

console.assert(crc.crc16modbus(buff) == 0);

serialPort.open(function () {

   serialPort.on('data', function(data) {
      console.log("recieving:", data);
    });

  setInterval(function() {
    console.log("writing", buff)
   serialPort.write(buff);
  },1000);

});

运行代码时,我看到:

writing <Buffer 02 06 02 4b 00 50 f8 6b>
recieving: <Buffer 02>
recieving: <Buffer 06>
recieving: <Buffer 02>
recieving: <Buffer 4b>
recieving: <Buffer 00>
recieving: <Buffer 50>
recieving: <Buffer f8>
recieving: <Buffer 6b>

RS485 有回声时除外。但我没有从奴隶那里收到任何东西。

编辑:更多关于配置。在 RS232 <-> RS485 转换器上,它设置为“T.ON R.ON”和“DCE”,它就是这个设备。设备页面

在驱动程序上它是这样设置的:

SW1设置为2,SW1对应从机号

SW2设置为2,SW2取值为2表示传输速率为38400

SW3 设置为“1:关闭,2:打开,3:关闭,4:打开”

 No.1: Set the address number, this causes the slave address to be 16 values higher
 No.2: Set the protocol, this sets it to use the ModBus Protocol
 No.3: Not used 
 No.4: Set the termination resistor (120 Ω)

RS232 <-> RS485 转换器的输出端口连接到驱动器。输出端口也连接到转换器的输入端口。因此回声。

4

0 回答 0