logix
Joined: 25 Jan 2011 Posts: 1
|
MODBUS SLAVE and RS485 |
Posted: Tue Feb 01, 2011 3:36 am |
|
|
Below is my rs485 connection diagram. I am using ex_modbus_slave.c from CCS C compiler. What changes should I implement in the code below in order to work the following circuit properly. I have tested this circuit and it is working fine.
https://docs.google.com/leaf?id=0B9HtKSm70IhSZjI1M2NlYWQtZGE3MC00ZjVjLTk5YWEtNjhlNTNlZjkyZTg5&hl=en
Code: |
#include <16f877a.h>
#device *=16
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock=20M)
#define MODBUS_TYPE MODBUS_TYPE_SLAVE
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
#define MODBUS_SERIAL_BAUD 9600
#ifndef USE_WITH_PC
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_EXT
#define MODBUS_SERIAL_TX_PIN PIN_B1 // Data transmit pin
#define MODBUS_SERIAL_RX_PIN PIN_B0 // Data receive pin
//The following should be defined for RS485 communication
//#define MODBUS_SERIAL_ENABLE_PIN 0 // Controls DE pin for RS485
//#define MODBUS_SERIAL_RX_ENABLE 0 // Controls RE pin for RS485
#else
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#endif |
_________________ Amir Rashid
(Engr. Electronics) |
|