Modbus RS-485 - Example of code

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
captdans
Posts: 4
Joined: 20 Dec 2011 21:54

Modbus RS-485 - Example of code

#1 Post by captdans » 06 Mar 2012 16:13

Hello,

I’m building now a small MikroC program that reads (via I²C bus) data from an accelerometer --- this part is OK, works fine---, and I want to complete my program by allowing a PLC programmer to read those accelerometer data via Modbus RS-485.

My data (from accelero.) array is 7-bytes long, so I know I cannot use the standard MikroC RS-485 library.

**Would you have an example of MikroC code (or even MikroBasic) that could help me in this small application?

I suppose we have to build our array according to the Modbus protocol, but at this point, I’m quite confused (w/ CRC frame, etc.). Feel free for any help,

NOTA: I' using a Pic18F258. I already have a MAX485 driver. I certainly need to set a 485 address to this MCU, and by this address, I want the PLC user get access to the 7 data (ex: X-axis value, Y-axis-Value, Status byte …).

Thank you,
CaptDans

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Modbus RS-485 - Example of code

#2 Post by filip » 07 Mar 2012 10:26

Hi,

I would like to help you, but our support team is very busy trying to get to every single support request on forum, as well as on our support tickets.
I recommend you to read your chip's datasheet and see how to manage your issue and try writing the code by yourself.
Also, try searching throughout the forum topics, there may be a piece of code you are looking for.

Thank you for the understanding.

Regards,
Filip.

Frank_team52
Posts: 1
Joined: 27 Feb 2014 19:23

Re: Modbus RS-485 - Example of code

#3 Post by Frank_team52 » 14 Mar 2014 16:23

Hello Captdans,
we wait you are doing well.

Please, would you send us your MikroC code for us to build a small MikroC program that reads (via I²C bus) data from the type of accelerometer that you are using :D ?

Many thanks for advance.

NuMcA
Posts: 37
Joined: 24 Dec 2009 17:08
Location: Athens, Greece
Contact:

Re: Modbus RS-485 - Example of code

#4 Post by NuMcA » 12 Dec 2014 11:44

Any news??
My simulation cockpit and other projects: www.numca.grImage

Sy
Posts: 708
Joined: 10 Dec 2009 13:41
Location: UK

Re: Modbus RS-485 - Example of code

#5 Post by Sy » 13 Dec 2014 15:12

Visit libstock, there are a bunch of modbus implementations already, including my modbusSlave and modbusMaster implementations, which should give you a good headstart.
Kind Regards,
Sy

NuMcA
Posts: 37
Joined: 24 Dec 2009 17:08
Location: Athens, Greece
Contact:

Re: Modbus RS-485 - Example of code

#6 Post by NuMcA » 13 Dec 2014 23:47

Sy wrote:Visit libstock, there are a bunch of modbus implementations already, including my modbusSlave and modbusMaster implementations, which should give you a good headstart.
Thank you very much Sy, I will look into it immediately!
My simulation cockpit and other projects: www.numca.grImage

Post Reply

Return to “mikroC PRO for PIC General”