Modbus

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

tello
Posts: 94
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 16 times
Contact:

Re: Modbus

Post by tello »

Good afternoon Benj and the others guys.

I would like to know how is the progress of the creation of block Modbus RTU master and slave.
Benj, I also I have a Modbus RTU slave devices if you need to do some test run, I can lend it to you if needed.

A greeting and thanks

tello
Posts: 94
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 16 times
Contact:

Re: Modbus

Post by tello »

Hello Benj.
You made some more progress with Modbus, thanks.

zadah
Posts: 31
Joined: Wed May 02, 2012 5:49 pm
Has thanked: 3 times
Been thanked: 7 times
Contact:

Re: Modbus

Post by zadah »

Hello

Here is code for working MODBUS slave. This program works well with industrial touchpanel and MODBUS RTU protocol. Touchpanel is sending commands as Master and PIC answer as a slave. The Command 16(write multiple int) is not so finished yet (because i haveny needed that so far.) The MODBUS part starts on MAIN routine after RS232 receives string (MODBUS commands)

I hope this helps:)

Modbus slave address = 1

Coils are stored on array COIL[] unfortunately Coils must be set to byte datatype to have data array.
and integer are stored on byte array Databyte[] where high byte of integer is Databyte[n] and low byte Databyte[n+1]
Attachments
Working Modbus slave.fcf
(123.2 KiB) Downloaded 914 times

Jellyfish
Posts: 4
Joined: Fri Sep 27, 2013 2:06 am
Has thanked: 1 time
Contact:

Re: Modbus

Post by Jellyfish »

May i know how about the write function so that we able to change the slave address? How do i search a reference on how to program a modbus tcp server&client or modbus rtu master&client ?

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Modbus

Post by Steve001 »

Afternoon guys,

is there any news on a V6 Modbus slave component ?

regards

Steve

Edit

sorry forgot about the post above :oops:
Success always occurs in private and failure in full view.

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Modbus

Post by Steve001 »

Hello Zadah

do you have a copy of the code without the motor control and other bits ? I.E down to basic grass roots level
I am trying to work out what you have done any why with the code

regards

steve
Success always occurs in private and failure in full view.

zadah
Posts: 31
Joined: Wed May 02, 2012 5:49 pm
Has thanked: 3 times
Been thanked: 7 times
Contact:

Re: Modbus

Post by zadah »

Hello Steve

I tried to keed to MODBUS code quite simple... First the RSR232 component resceives the MASTER command starting with slave adress (1), which after comes the command 1,3,5,6 or 16. After that the program checks if the crc is ok and if it is OK program executes command + calculates reply CRC.

RTJNair
Posts: 12
Joined: Sun Nov 09, 2014 5:53 pm
Location: Oman/India
Has thanked: 5 times
Been thanked: 2 times
Contact:

Re: Modbus

Post by RTJNair »

Hello Zadah,

Thanks for the work you have done to develop the modbus slave. I am quite interested since I am doing a project that will need one like this. I need to capture few input registers starting from 30100 to 30120 on an RS485 interface. I will have to build this from scratch. The flowcode program when opened was in Finnish and couldn't follow the flowchart much since I can understand only english.

I was not able to find a similar topic elsewhere in the forum and there is no modbus slave component available yet.

How can I contact you to further discuss ?

Thanks in advance

RTJNair

tello
Posts: 94
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 16 times
Contact:

Re: Modbus

Post by tello »

Hi guys.
I resumed my project modbus slave and I want to know if a Modbus Slave component is possible.
I tried the Modbus master and I am making progress but my team should be a slave.

Someone has made new test with these components ??

Thank you very much.

tello
Posts: 94
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 16 times
Contact:

Re: Modbus

Post by tello »

Good afternoon guys.
I still do modbus slave component and need to do the CRC calculation, I'm looking information and I can not find anyone explain it to me simply for my little brain :lol: :lol: :lol: .
Can anyone help me and tell me how to do it ??

Thank you very much.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Modbus

Post by Benj »

This shows how to do the RTU CRC in code.

http://www.ccontrolsys.com/w/How_to_Com ... essage_CRC

I have also sent you a PM with the source of our Modbus master component so you can see how it's been done there.

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Modbus

Post by Steve001 »

this may be of help too

Steve
Attachments
guide to crc16 calculations.pdf
(70.8 KiB) Downloaded 350 times
Success always occurs in private and failure in full view.

tello
Posts: 94
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 16 times
Contact:

Re: Modbus

Post by tello »

thank you very much Steve001, your help has been very important.
I made a managed to work a block for calculating CRC16.
The next step is the programming of a block modbus slave to respond with some simple functions.
I will report on progress.
Thanks again

User avatar
Mantas
Posts: 221
Joined: Tue May 15, 2012 10:32 pm
Location: Klaipeda, Lithuania - North sea, UK
Has thanked: 57 times
Been thanked: 27 times
Contact:

Re: Modbus

Post by Mantas »

Hello, guys,

I would suggest you to stop inventing a wheel. Download the source for freeMODBUS which supports RTU/ASCII modes from here: http://sourceforge.net/projects/freemod ... ios/files/, porting the app is easy the documentation is here http://www.freemodbus.org/api/index.html. Port your files for serial like UART and Timers for your chip and get over it (If your not afraid of getting your hands dirty with a bit of C code). Worked like a charm form me, and I only spent one evening getting familiar with the library and porting instructions and vuolia! If you want to use it inside flowcode with flowcode macros just write abstraction layer for calling C code functions. Goodluck!

Best regards,
Mantas
Science is my true religion.

Post Reply