485 communication with two atmega8

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

Hello guyz, I need help with a project, I have two AVRs some 500+ meters apart and I have to develop communication between them, one of them is the sender and the other one is reciever .. I just want one way communication uptil now.. i am using two max485 chips ... the message that I have to convey is very simple it contains information as low as 5 bytes... Uptil now I am sure I will be able to do it by simply making my own data packet and this is exactly what my boss wants me to do.. but I want to seize this opportunity to learn a little bit more about MODBUS protocol ... I know some basics about MODBUS protocol like it is an application layer protocol while 485 is physical layer protocol .. my question is .. Is it possible to use Modbus protocol in this scenario ?? and is it possible if some one can provide a general C implementation of MODBUS protocol (I am not asking for complete code I just want a direction to start with)  Thanks in Advance 

Attachment(s): 

This topic has a solution.
Last Edited: Sat. Oct 26, 2019 - 04:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mega8 is enough as hardware capability. Even MODBUS-RTU.

Unfortunately, I wrote all the code myself, so I don't know which library I can introduce.

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


For the benefit of others - a rescaled version of the attachment in #1:

 

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

Can you share some of your code if its not meant for any commercial product. 

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

SufyanRaza26 wrote:
I just want one way communication uptil now
When will you answer my question?

 

Ross McKenzie ValuSoft Melbourne Australia

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

what question? I am sorry i didnt get it? 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Modbus would have to be one of the simplest protocols to implement. Modbus views the world as bits and 16 bit words.
Google freemodus.
Also read the docs at modbus.org

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

SufyanRaza26 wrote:

what question? I am sorry i didnt get it? 

  Yep. Exactly the same if you only have one way communications. How will you know that your 5 bytes were received/understood and actioned? It is all about two way communications!

Ross McKenzie ValuSoft Melbourne Australia

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

I know you said modbus, but you may want to consider using S.N.A.P as a simple robust protocol in this app.  Info here: http://www.hth.com/snap/

I've used this for several projects, but I don't have access to the code anymore, but the manual for snap which you can download from the link is clear and makes it easy to implement. 

There some AVR examples, but if IIRC, they are mostly in assembler.

 

Good luck with your project.

Jim

 

 

 

 

 

 

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

Jim,

 

There are a couple of Arduino libraries now for S.N.A.P.

Ross McKenzie ValuSoft Melbourne Australia

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

Found it, thanks for the heads up.

jim

 

 

 

 

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

MODBUS-RTU is old and somewhat ambiguous. Please understand and code it yourself.
My code has its own interpretations and improvements based on experience and cannot be published.