View previous topic :: View next topic |
Author |
Message |
pic_MD
Joined: 16 Sep 2011 Posts: 3 Location: INDIA
|
EC2 Illegal Data Address |
Posted: Fri Sep 16, 2011 2:07 am |
|
|
Hi Everybody!
I got CCS complier couple of weeks back and was trying to implement the sample code provided along with the complier. I tried using ex_modbus_slave.c with following configuration:
Code: |
#define USE_WITH_PC 1
#include <18F4520.h>
#fuses HS, NOWDT, NOPROTECT
#use delay(clock=4M)
#define MODBUS_TYPE MODBUS_TYPE_SLAVE
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
#define MODBUS_SERIAL_BAUD 9600
#define MODBUS_SERIAL_RX_PIN PIN_C7 // Data receive pin
#define MODBUS_SERIAL_TX_PIN PIN_C6 // Data transmit pin
#define MODBUS_SERIAL_ENABLE_PIN Pin_C5
#define MODBUS_SERIAL_RX_ENABLE Pin_C5
#include <modbus.c>
#define MODBUS_ADDRESS 01
|
and configured modbus viewer with following configurations:
Master/Slave : Master
Binary/RTU : RTU
Adress : 1
comp port : Active
with these configuration I'm not getting proper feedback from slave:
My transmit data is [01][03][00][00][00][64][44][21]
received data is [01][83][02][C0][F1]
and status displays EC2 Illegal Data Address
what should be done??
the complier version is 4.124
thank you:
MD |
|
|
pic_MD
Joined: 16 Sep 2011 Posts: 3 Location: INDIA
|
|
Posted: Fri Sep 16, 2011 10:03 pm |
|
|
No replies yet?? :( |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Sep 17, 2011 4:00 am |
|
|
Quote: | what should be done?? |
Consider the address range provided by ex_modbus_slave. Holding registers have addresses 0 - 7, your test accesses 0 - 99 (register numbers 1 -100).
More generally:
- Get the MODBUS Application Protocol Specification from modbus.org and learn how the protocol works.
- Analyze the ex_modbus_slave code to understand what it's doing and how the exception is brought up |
|
|
pic_MD
Joined: 16 Sep 2011 Posts: 3 Location: INDIA
|
|
Posted: Mon Oct 10, 2011 2:54 am |
|
|
Hi,
I got modbus working! however when I try to put more data through holding register I get a garbage value.
I did increase the length from 8 to 32.
My data is as follows:
Code: |
hold_regs[i]=f; ///pow(10,dec[i]);
hold_regs[8]=20;
hold_regs[9]=40;
hold_regs[10]=20;
hold_regs[11]=40;
hold_regs[12]=20;
hold_regs[13]=40;
hold_regs[14]=20;
hold_regs[15]=40;
hold_regs[16]=20;
hold_regs[17]=40;
hold_regs[18]=20;
hold_regs[19]=40;
hold_regs[20]=20;
hold_regs[21]=40;
hold_regs[22]=20;
hold_regs[23]=40; |
My first 8 values are process values, but I don't get all the above values on holding resister! What should be done! Please help. |
|
|
|