CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Modbus master RTU issue with long distance
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
huynhhai



Joined: 04 Apr 2015
Posts: 39

View user's profile Send private message

PostPosted: Wed May 05, 2021 2:36 am     Reply with quote

Dear Ttelmah, alan

I removed resistor already but unsuccessful.
I will change my module with DE and RE module to test again.
When the master sent data to slave, i observed led TX signal blinking on master and on slave RX led blinking, but slave no response.
I thought two reasons:

1. Data ID no correct therefore slave no identify ID itself,
2. Baudrate not in 9600bps due to noise on line cable therefore slave didn't understand ID

The first time i used library modbus.c, i don't know the library working ok or no? Are you using this library before?
Ttelmah



Joined: 11 Mar 2010
Posts: 19218

View user's profile Send private message

PostPosted: Wed May 05, 2021 6:12 am     Reply with quote

Yes, the Modbus library works fine.
The problem is a specific one to Modbus. Modbus requires the transmit
device to be able to send specific length 'breaks' in the transmission, with
the bus still driven. The automatic RS485 transceiver will turn off when this
happens, leaving the bus undriven. Result the break will not be properly
received. Disaster... Sad
It's a problem with trying to use an 'automatic' RS485 buffer, to handle
Modbus transmissions. The buffer you have is designed for simple RS485
half-duplex transmissions only.
huynhhai



Joined: 04 Apr 2015
Posts: 39

View user's profile Send private message

PostPosted: Sat May 08, 2021 9:59 am     Reply with quote

Thanks for your help,

I found out the reason for master can not transceiver to slave due to opto isolate, from master PIC board have used Opto EL817 ( this is photo transistor NOT IS A LOGIC PHOTO OPTO) therefore the signal after OPTO is slower than original signal and sometime this signal width pulse not same, this is a reason baudrate incorrect speed,

About TTL to RS485 my module is working fine, if i didn't use OPTO for this module ( only 2 PINs TX and RX). no used DE and RE pins

I still don't understand what is difference between define "0" vs "PIN_X", they are not affect for my programs if i no use them?
#define MODBUS_SERIAL_ENABLE_PIN 0
with
#define MODBUS_SERIAL_ENABLE_PIN PIN_C0 Rolling Eyes Rolling Eyes


Last edited by huynhhai on Sat May 08, 2021 10:22 am; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9101
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat May 08, 2021 10:15 am     Reply with quote

re: opto el817....
Has a max freq of 80KHz.
Using 'rough' math 80KHz / 10 bits = 8K baud
So it 'should' work with BAUD = 4800.

re: PIN_X...
#define requires a PIC PIN, like PIN_A2, PIN_C0, PIN_D1.

'0' is not a valid pin designation.
Ttelmah



Joined: 11 Mar 2010
Posts: 19218

View user's profile Send private message

PostPosted: Sun May 09, 2021 10:32 am     Reply with quote

Understand that the Modbus master _must_ control the transmit enable
line. It needs this to allow it to hold transmission on while data is not
sent, to give the timing breaks required by Modbus. That your setup
happens to apparently work without this is pure luck. It will depend on
what state the undriven bus is biased to.
The driver needs to control this line.
You seem determined not to use the right wiring for this, but doing
so is a recipe for unreliable behaviour.
huynhhai



Joined: 04 Apr 2015
Posts: 39

View user's profile Send private message

PostPosted: Thu May 20, 2021 10:17 am     Reply with quote

Thanks Ttelmah,

Now, my system with modbus are running good and no error, i checked all issue after my project as below:
1. If Slave board, i can use TTL to RS485 module (only two pin TX and RX) but Master board can not.
2. Require using DE, RE module RS485 only on Master board,
3. Need two resistors 120 ohm at First and the end of cable line.
4. If using Isolate Opto, should choose 6N137 Opto logic output.
Ttelmah



Joined: 11 Mar 2010
Posts: 19218

View user's profile Send private message

PostPosted: Thu May 20, 2021 10:34 am     Reply with quote

That makes sense, since the master has to generate the TX break, while
a slave does not.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group