RS-485 protocol in ATMEGA168-15AD

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Hello, 

I am using ATMEGA168 Microcontroller and trying to get the hardware and pinout right for RS485 protocol. Is there a specific transceiver i have to choose so that there wont be any compatibility issue? 

I have a sensor that uses RS485 so for that reason i need to use this protocol. Since RS485 is compatible with upto 32 devices i can just use 485 to intergrate with the pc and the sensor. 

This is a rough sketch :

 

 

Can someone please let me know if this look correct? and those pins RO,/RE,DE and DI which ports should they connect to in microcontroller side?

 

Thanks.

 

 

- Sharan

Last Edited: Tue. Apr 6, 2021 - 04:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to AVRFreaks!

 

This looks like normal half duplex serial comms, so the R0 pin connects to the USART pin rxd, the DI pin connects to USART pin txd, and the two direction pins (/RE and DE) are tied together and connects to any spare port pin and you control it so it is low for receiving data, and high when transmitting data.   You will want to set TX direction,  and then call your usart transmit function (usually putc() or puts()) wait for the TXC flag is set, saying all data has been transmitted, then and only then set the direction pin low to receive replies.

 

Jim

 

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are there any compatibility issue with transceiver or can i use any ttl to 485 module with any microcontroller?

- Sharan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

they all work!

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well the usual electronics caveat applies - check the voltage levels. Some RS485 transceivers only work from 5v, and some can work from 3v to 5v. Also, when working from 5v some won’t accept 3V3 signals. And if the transceiver is working from 5v it will spit out 5v on the receive line which a 3v3 micro might not like. If everything is TTL level voltages ie 5v then you will be fine.

There are already a million monkeys in front of a million keyboards, and the internet is nothing like Shakespeare!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

a question: which device are You using.

I've orderd this:  Industrial TTL To RS485 Module RS485 To TTL Serial UART With Isolation 3V-5.5V

Im waiting for delivery. 

 

 

 

Senior Electric Engineer
--------------------------
I use Atmega128, AS7, GNU GCC, Atmel ICE

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller