View previous topic :: View next topic |
Author |
Message |
huynhhai
Joined: 04 Apr 2015 Posts: 39
|
|
Posted: Wed May 05, 2021 2:36 am |
|
|
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: 19538
|
|
Posted: Wed May 05, 2021 6:12 am |
|
|
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...
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
|
|
Posted: Sat May 08, 2021 9:59 am |
|
|
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
Last edited by huynhhai on Sat May 08, 2021 10:22 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sat May 08, 2021 10:15 am |
|
|
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: 19538
|
|
Posted: Sun May 09, 2021 10:32 am |
|
|
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
|
|
Posted: Thu May 20, 2021 10:17 am |
|
|
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: 19538
|
|
Posted: Thu May 20, 2021 10:34 am |
|
|
That makes sense, since the master has to generate the TX break, while
a slave does not. |
|
|
|