arduino用modbus与rs485通讯出现的问题
#include <SimpleModbusMaster.h>
/*
The example will use packet1 to read a register from address 0 (the adc ch0 value)
from the arduino slave (id=1). It will then use this value to adjust the brightness
of an led on pin 9 using PWM.
It will then use packet2 to write a register (its own adc ch0 value) to address 1
on the arduino slave (id=1) adjusting the brightness of an led on pin 9 using PWM.
*/
//////////////////// Port information ///////////////////
#define baud 9600
#define timeout 2000
#define polling 200
#define retry_count 20
#define TxEnablePin 2
#define TOTAL_NO_OF_REGISTERS 2
enum
{
PACKET1,
TOTAL_NO_OF_PACKETS
};
Packet packets;
unsigned int regs;
void setup()
{Serial.begin(9600);
modbus_construct(&packets, 02, READ_INPUT_REGISTERS, 257, 02, 0);
modbus_configure(&Serial, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
}
void loop()
{
modbus_update();
}
这是程序arduino与rs485之间用max485转接载入程序之后arduino的tx闪 max485的tx也闪 但是rs485没反应请问我是发送的数据包不对吗?? 有人 跟我说是 max流控制的原因应该换一个自动流的ttl转接卡 可是对流控制不了解 求各位大神解答是不是流控制的问题呢 也正在研究 acdc0616 发表于 2016-2-27 01:00 static/image/common/back.gif
也正在研究
我弄出来了 是流控制的问题 换了一个自动流的就好了 weige 发表于 2016-3-1 09:38 static/image/common/back.gif
我弄出来了 是流控制的问题 换了一个自动流的就好了
用modbus测试软件发送什么样的命令,能分享一下吗。 看到 enum命令, 感觉好高大上
页:
[1]