Sonsivri

Electronics => Projects => Topic started by: Ljmnunes on November 11, 2020, 02:39:25 02:39



Title: Little PIC Modbus project + code
Post by: Ljmnunes on November 11, 2020, 02:39:25 02:39
Hello!

First I wanted to clarify: When I registered for the forum, I wanted to share my knowledge by sharing my projects that I worked on for many years, but my boss warned me not to do this for legal reasons. He showed me the company rules and how I will be stuck with them for a few more years. Today I am retired, but still trapped by those rules. (I hope you understand me despite my poor English)

But I found my first project that I thought was lost and as this project has nothing to do with the company I worked for. So, I'm pleased to share it.

This is my first electronic project with PIC that I did many years ago to learn the C language. I know it's a very basic code, but I hope it helps someone to understand or get started with the Modbus protocol. It was written in C for PIC with the CCS compiler, but can be ported to another microcontroller easily.

Inside the zip file there are a schematic file for P-CAD 2006 and a pdf too. Sorry, there is no pcb file for the project because it is corrupted, But you see it is very simple.

Thanks!


Title: Re: Little PIC Modbus project + code
Post by: pickit2 on November 12, 2020, 09:32:51 09:32
May I say first 'you joined a forum, we don't want anything that you can't share' yes we sometimes bypass payment for software.
But that is not the idea behind a forum, the main rule is you must be active, it dont mean you must be active share stolen software.
you most like you joined to ask questions, or inteact with people having problems, with projects, or help with your projects.

there are some members who have been members (loose term as some think it's ok to spend 10, 15 years in a forum with zero postings)




Title: Re: Little PIC Modbus project + code
Post by: Ljmnunes on November 13, 2020, 01:02:56 01:02

pickit2,

I keep looking for an opportunity to help someone. But I don't spend a lot of time reading on the forum.

On a large forum like this, with many active users, I think it will take me a long time to be a useful member.

Thanks!


Title: Re: Little PIC Modbus project + code
Post by: sphinx on November 13, 2020, 04:24:03 04:24
Hi.

Could you add some info/documentation for the project and how to use it, and what is intended use is for.

regards.


Title: Re: Little PIC Modbus project + code
Post by: Fab66 on November 13, 2020, 02:14:22 14:14
pickit2,

I keep looking for an opportunity to help someone. But I don't spend a lot of time reading on the forum.

On a large forum like this, with many active users, I think it will take me a long time to be a useful member.

Thanks!

You are very modest :) honnestly in my experience, every sharing can be usefull for some of us.
Anyway thank for you initiative.


Title: Re: Little PIC Modbus project + code
Post by: metal on November 13, 2020, 03:04:19 15:04
The code is well designed, thank you.


Title: Re: Little PIC Modbus project + code
Post by: sadman on November 13, 2020, 03:21:31 15:21
It is great project and nice sharing Modbus is two wire communication protocol for industry and PLC control, it is a protocol that control multiple hardware like this on same line and you can monitor them from PC and every hardware have unique ID to identify them.

Sadman


Title: Re: Little PIC Modbus project + code
Post by: Gallymimu on November 14, 2020, 03:47:39 15:47
Thanks for this.  I'm a huge fan of MODBUS for multidevice communication.  It is so trim and simple (especially if you only implement multiword read/write functions).

We often talk customers out of using CAN, Ethernet/IP and other protocols that are pretty heavy from a microcontroller standpoint.


Title: Re: Little PIC Modbus project + code
Post by: Ljmnunes on November 14, 2020, 04:44:59 16:44
Hi.

Could you add some info/documentation for the project and how to use it, and what is intended use is for.

regards.

documentation but this I give.

If you are interessed, I can explain it better later. Do you know about Modbus?

This project is resumed below:
It is a simple remote I/O with 5 digital inputs and 5 digital outputs.
The inputs are transfered to Modbus in the input status register.
The Modbus protocol can read the outputs (coils) and force its values too.
The slave address is changed in the first Hold Register - Address default == 0xFF

The implemented functions and it limits are:
Function 1 Read Coil Status - 5 outputs
Function 2 Read Input Status - 5 inputs
Function 3 Read Holding Register - 1 HR -> Slave address
Function 5 Force single coil - 5 coils
Function 6 Preset Single Register - 1 HR -> slave address

There is no error checking like functiona address, data size. there are only function exist checking.


Anyting else? Please, let me know

Best Regards.

Posted on: November 14, 2020, 04:36:59 16:36 - Automerged

Thanks for this.  I'm a huge fan of MODBUS for multidevice communication.  It is so trim and simple (especially if you only implement multiword read/write functions).

We often talk customers out of using CAN, Ethernet/IP and other protocols that are pretty heavy from a microcontroller standpoint.

I think that we must use the better solution for each problem.

I've used Modbus in the most project I've made. I think is insane to use heavy protocol for little devices without a good reason.

Best Regards.