STM32F051C8U6 MODBUS communications (RS 485) using LTC1480

Thread Starter

zazas321

Joined Nov 29, 2015
433
Hey. I am working with STM32 microcontroller and I need to design a modbus communications using RS485 interface. The microcontroller will need to communicate to another device using modbus which I havent got details about.

I have found few relevant chips (LTC485 and LTC1480) that provide RS485 capabilities. Considering that the STM32 microcontroller that I am using operates on 3.3V logic, I would use LTC1480. I have found few examples of wiring the LTC485 but I am struggling to find some helpful example circuitries for LTC1480. I assume LTC485 would be very simmilar, is that a good example to look at? What would be PD5 pin going into __RE?

 

dendad

Joined Feb 20, 2016
3,251
The connection to _RE and DE are used for the data direction control. The processor switches thr driver to transmit then sends ths packet and then switches back to receive using that pin.
 

Thread Starter

zazas321

Joined Nov 29, 2015
433
So Re and DE logic high when transmitting, logic low when receiving. What happend when its neither receiving or transmitting?
 

dendad

Joined Feb 20, 2016
3,251
So Re and DE logic high when transmitting, logic low when receiving. What happend when its neither receiving or transmitting?
Usually, it is either one or the other.
When listening, the processor does not have to actually be listening, just the RS485 driver is in the listen mode so it does not hold the network in an active state. If you really want to, you can drive both enable lines from separate port pins so the RS485 driver can be completely disabled but that is unnecessary.

And when you run the cable, use twin shielded and connect the shield both ends so the GNDs are connected. Often this is left out and can lead to troubles with the GNDs getting too far apart in voltage so locking the drivers up.
If you want isolation, and that is well worth while in many cases, look at the Mornsun isolated drivers...
https://www.mornsun-power.com/html/product/RS-485-Transceiver-Module.html
 
Last edited:

Sensacell

Joined Jun 19, 2012
2,543
Controlling the timing of the transmit enable is tricky.

Consider leaving the receiver permanently enabled so you can use the reception of the characters being sent to control the timing.
When the RX UART gets the last character, it's then safe to shut down the transmitter.

This problem is often trivialized- until you try to get it working - on some UARTS, there are no flags that reliably indicate that the character has completely finished.
 

Thread Starter

zazas321

Joined Nov 29, 2015
433
I would like to note that I will be using MODBUS communications using 1.5 - 2m cable length. Also, there will be only 2 communcating devices. Is safe biasing necessary for communicating between 2 devices instead of multiple?
 

Sensacell

Joined Jun 19, 2012
2,543
Idle line "failsafe" bias is a trivial matter of 3 resistors.
It's required for any half-duplex RS-485 Link, at least at one end.

You can get away without terminating both ends if the cable is short
 

Thread Starter

zazas321

Joined Nov 29, 2015
433
What I am getting confused, is If i pull the A high and B low, doesnt that mean that the output on the receiving end will be always 1 (RO) because A will be always > than B. (refer to the picture I have added)

upload_2019-6-12_11-38-31.png
 

Sensacell

Joined Jun 19, 2012
2,543
Use a combo of 560 ohm, 120 ohm and another 560 ohm in series.

Tie one end to +3.3 and the other to ground.

Connect A and B to the 120 ohm and the line, so A is nominally higher voltage than B.

What you want is basically a 120 ohm termination that has a couple hundred mV bias on it, to ensure that the idle state is defined.

The RO output will then be idle HIGH - that's the correct idle state.
 

Thread Starter

zazas321

Joined Nov 29, 2015
433
But lets say I need to receive some information, wouldnt my A still remain > than B even when receiving? if thats the case, RO will never would be able to reach 0 state because A-B will always be positive due to pulling A high
 

dendad

Joined Feb 20, 2016
3,251
But lets say I need to receive some information, wouldnt my A still remain > than B even when receiving? if thats the case, RO will never would be able to reach 0 state because A-B will always be positive due to pulling A high
No. The driver overrides the resistors. The 560Rs keep a bias on the line at an idle state when both ends are listening so to stop noise generating signals.
Without the pull up/pull down resistors, the receive data pins to the processors will be hammering away and the processors will be spending a lot of time looking for data in the noise signal.
If you are only having 2 units, and that are only a couple of meters apart, why not try direct TX of each unit to the RX of the other?
No drivers. You may find you can get away with it.
 

Thread Starter

zazas321

Joined Nov 29, 2015
433
I am working on the master side of the circuitry. The other end of modbus communications will be solar panel circuit that has a modbus link already installed snd ready to be connected. That is why I require to build a Modbus. Thank you for the information sir. Was helpful
 

Thread Starter

zazas321

Joined Nov 29, 2015
433
For now, I have built this circuit:
upload_2019-6-13_9-21-47.png

I assume the rest is up to coding there is not much more in terms of hardware. Im using 3 pin terminal block ( A, B and GND) which will be connected to another device using a USB to RS485 cable
 
Top