I am using Arduino Mega as a slave to communicate via Modbus Rs485 to Master PLC (Brand Name:FATEK).
I am sharing picture of PLC Modbus Table for understanding.

My PLC Does not accept address less than Six Digits.
I have read the datasheet of ATmega and used UCSR and build a program (with 8 bit data, None Parity bit and one stop bit.)
I am using TTL to Rs485 Module. and after that i used RS485 to USB adopter to communication with PC on Tera Term software.
// 8 bit data, None Parity bit and one stop bit BAUD rate 9600 output at UDR0 register.
#include <avr/io.h>
#define Freq 16000000 //My Arduino has 16MHZ frequency
#define BAUD 9600
#define BRC ((Freq/16/BAUD)-1)
void setup()
{
pinMode(2, OUTPUT); // TTL to Rs485 DE and RE pin to transmit data
UBRR0H=(BRC>>8);
UBRR0L=BRC;
UCSR0B=(1<<TXEN0);
UCSR0C=(1<<UCSZ01)|(1<<UCSZ00);
}
void loop ()
{
digitalWrite(2, HIGH); // TTL to Rs485 DE and RE pin to transmit data
UDR0='1'; // UDR0 register, it output '1' on screen after 2 seconds with hardware connection
// (Via TTL to RS485 and Rs485 to USB converter.)
delay(2000);
}
This Program Worked fine with PC and it give value of UDR0 register on software tera team.
But to work with PLC which only accept six digit address, i dont know how to give station number and UDR register an address of six digits to be accessed by PLC.
i can not use library they allow only 5 digit address of Register bank.
Please Help me i am new to programming.


