News:

;) This forum is the property of Proton software developers

Main Menu

Suggestion on RS485 chip?

Started by TimB, Jun 22, 2023, 09:47 PM

Previous topic - Next topic

TimB


I have a project that has TTL coms at this time and I need to talk to the outside world

I can get TTL to RS485 modules for control cabinets but not TTL to Ethernet. I can get RS485 to Ethernet though

Thinking that just running my TTL signals out to the big old wide world is not going to be good for my pic's health I have decided to do TTL to RS485 on board.

My question is what chip? Preferably TX and RX

Any recommendations?

SCV

RS485 does RX and TX, but not at the same time. It takes three TTL lines, RX DIRection and TX to interface to RS485. I use the MAX3082 (5v) or SP3072 (3v3). These chips are fail-safe idle high during short or open line.
Add a holdup resistor for the TTL RX line - 10k will do fine.

Worth looking at the Wiznet serial-ethernet modules. Easy to set up through a web gui (no need to change sub-nets) and they interface with RS422 instead or RS485. I use a SP3071 (3v3).

Tim.

TimB


Thanks

It need to learn more about RS485. Most of the traffic will be out but once in a while data will come back in. My board will not have any control over when the data will come in.

Perhaps as the data is TXed at 1hz in between it can be listening. One issues is I'm short on spare pins I have 2 left and have allocated both to new features




John Lawton

RS485 can be either half-duplex as described or full duplex. For full duplex two data pairs are required plus common. For ethernet I've used the Lantronix Xport units with success. They can handle very fast serial data to your PIC.
https://cdn.lantronix.com/wp-content/uploads/pdf/XPort_PB.pdf

Gamboa

Hi Tim,
The concept of choosing Ethernet or RS485 depends on speed and distance.
Ethernet 10MB and 100m. More expensive. More speed. €45/piece
RS485, 1km to 9600. Cheaper. You can increase speed but shorten distance. €0.7/piece.
Ethenet already handles packet checking for collisions etc. In RS485 half duplex you are always receiving and when you need it you can transmit. You must control packet collision with your software.
I use Xport for Ethernet, it works great.
For RS485 I use a cheap one that works fine for me: ST485ECDR.

Regards,
Gamboa
Long live for you

TimB


Thanks Gamboa

Reading up on RS485 I see its is 2 parts the hardware and the software. Unless I implement 2 pairs of twisted cables it will not be easy to implement TX and RX without a lot of work.

RS485 seems to be a address system and used with say Modbus. That is it will send a request for a set of regs from an address. If it does not get a response it could be there was a clash on the line, so it times out and retries. WAY to much work for what I need

My system has
4 x 0-5 Outputs that can be converted to 4-20ma
It also has 2 no volt alarm outputs

I have 2 usarts running on the pic. 1 is to the display, 2 is just a general set of vars sent every 1 hz as a broad cast. I can implement command RX on that USART as well. its just cut and paste the existing RX stuff from the display code.

The reason to look at RS485 was to make using coms to Ethernet easier.

The unit is in a din rail case and any coms eg Ethernet will be using a din rail package as well so  board modules are not an option I'm interested in or would ever consider.

I see you can get units like this
https://thepihut.com/products/rs232-485-422-to-rj45-ethernet-module

But its not TTL serial and it requires a 9pin Din to input the RS232.

All I really want is ttl serial to Ethernet in a din rail box. Perhaps I will need to build my own. But really the product has so much feature creep I should stop messing around with it.

If the company I will sell this to demands Ethernet then I will redesign the case PCB and stuff a module in.
 







John Lawton

RS-485 is just a bidirectional multipoint interface, which allows for multiple drivers to be connected to the same bus. To avoid bus contention, bus access is controlled with driver enable pins. Only one TX driver can access the bus at a time.

The is no fixed bus protocol, it's down to you, (don't go down the Modbus rabbit hole). If you use full-duplex RS485, i.e. separate TX and TX lines and no other modules on the bus, then contention isn't an issue, so it's more like RS232 but with much greater range capability if you actually need it.

The Lantronix module accepts TTL levels serial data so that would be okay over a short distance or you could use RS485 hardware to talk over balanced pair(s).





RGV250

Hi Tim,
You beat me to it with the Waveshare one, we used Lantronix at work which I am sure it will be a lot more than the Waveshare but I think it is more industrial. I don't think I have ever seen a TTL one at least for industry.
https://www.lantronix.com/products/uds2100/
If you wanted to try one PM me and I can send you one to test.

Bob

Gamboa

#8
Tim,

Regarding Ethernet there are other modules, for example those of Wiznet. They are cheaper but the same philosophy as Xport. Wiznet also has a chip with a 232 serial (TTL) to Ethernet conversion, but you have to add some externals.( https://www.wiznet.io/ )

As for RS485, the protocol is defined by you, it does not have to be MODBUS. I have used RS485 several times and I have always defined my protocols, I do not use Modbus. There is an easy way to arbitrate the bus, which is by polling the rest of the devices continuously from one point. This is easy to implement, but not efficient if you have a lot of slaves. In this mode there are no collisions. One device acts as a master and the rest as slaves. The master sequentially asks the address of each slave and it is simple.
Then another way is total anarchy: each team transmits when it needs to. In this mode each device is in reception and when it wants to transmit it checks the channel and if it is free it transmits. It is more complicated but also more efficient, because the channel is only occupied when it is necessary.

If ThPitHut finds it attractive, you can disassemble it and find the TTL side of the RS232 driver and use TX and RX to communicate in TTL mode. You will lose the guarantee.

Regards,
Gamboa
Long live for you

Oskar-svr

#9
Hello friend, I use these modules, you just have to connect the rx and tx at TTL levels in the microcontroller or Ethernet modules, it does not require flow control because the device does it automatically, the device is always listening to the RS485 network and when you want transmitting the device is activated only for sending data, and it is very economical I hope it works for you regards

MODULO RS485
https://es.aliexpress.com/item/32705625990.html?spm=a2g0o.order_list.order_list_main.5.792e194dfQhWUQ&gatewayAdapt=glo2esp 

MODULO ETHERNET
https://es.aliexpress.com/item/1005004776134730.html?spm=a2g0o.order_list.order_list_main.61.792e194dfQhWUQ&gatewayAdapt=glo2esp 

TimB

Thanks Oskar-svr

I think if I need them I will build into a Din rail case for them

In the mean time I will have a TTL to USB serial cable and demo it with a PC app


Oskar-svr

Friend, if you need help configuring the Ethernet modules, count on it