HELP_MODBUS
hello i'm trying make sense of modbus programming , can't seem grasp,
i'm trying make arduino mega2650 talk trough rs-232 morning star mppt-25m, of right trying data back, can't seem make happen. i'm using basic example on library. i'm using usb print statements can see values, copiling don't real values, slave address 1. help
i'm trying make arduino mega2650 talk trough rs-232 morning star mppt-25m, of right trying data back, can't seem make happen. i'm using basic example on library. i'm using usb print statements can see values, copiling don't real values, slave address 1. help
code: [select]
void setup()
{
// initialize modbus communication baud rate
node.begin(9600);
serial.begin(9600);
serial.println("start program");
}
void loop()
{
static uint32_t i;
uint8_t j, result;
uint16_t data[6];
i++;
// set word 0 of tx buffer least-significant word of counter (bits 15..0)
node.settransmitbuffer(0, lowword(i));
serial.println(node.settransmitbuffer(0, lowword(i)));
// set word 1 of tx buffer most-significant word of counter (bits 31..16)
node.settransmitbuffer(1, highword(i));
serial.println(node.settransmitbuffer(1, highword(i)));
// slave: write tx buffer (2) 16-bit registers starting @ register 0
result = node.writemultipleregisters(0, 1);
serial.println(result);
// slave: read (6) 16-bit registers starting @ register 2 rx buffer
result = node.readholdingregisters(1, 6);
serial.println(result);
serial.print("este es el node.ku = ");
serial.println(node.ku8mbsuccess);
// data if read successful
if (result == node.ku8mbsuccess)
{
serial.println("llegue aqui");
(j = 0; j < 6; j++)
{
data[j] = node.getresponsebuffer(j);
}
}
}
the code posted won't compile. type of node undefined, among other things.
personally, have no idea "morning star mppt-25m" is. sounds quilting pattern me.
if want print return value function, far better save in variable, , print variable's value.
personally, have no idea "morning star mppt-25m" is. sounds quilting pattern me.
code: [select]
node.settransmitbuffer(0, lowword(i));
serial.println(node.settransmitbuffer(0, lowword(i)));
if want print return value function, far better save in variable, , print variable's value.
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > HELP_MODBUS
arduino
Comments
Post a Comment