Recent

Author Topic: Need help with Modbus  (Read 12537 times)

Sage

  • New Member
  • *
  • Posts: 13
Need help with Modbus
« on: February 01, 2017, 02:11:59 am »
Greetings all,

I'm completely new to this forum and I was really hoping that someone could help me with Modbus.

I have written a UI that needs to communicate with a Bosch Rexroth PLC. I have testing the Modbus server on the PLC using a test app that I have downloaded from http://www.modbustools.com/. Using this I have confirmed that the Modbus server is working correctly.

Now my intention was to use PascalSCADA for the communication in the UI I'm building in Lazarus. The problem is that I can't seem to get any connection (Well I don't know if I have connection of not as there is not property that I can find that confirms this).
There is very little documentation on line explaining how to use the tags and how to set the Tag properties for a specific address in the register.
I've tried using the Logo8 example as my base but without success.

I have also tried to use mbulibs but I'm totally lost with this, especially that the example contained in the downloaded files actually doesn't work so I can't get me head around what the correct syntax is for doing simple send and receive.

I'm using TCP/IP if that helps.

Any help would be appreciated as my entire project has come to a halt at this point.

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Re: Need help with Modbus
« Reply #1 on: February 01, 2017, 06:43:20 am »
Dear Sage,

PascalSCADA is good enough for modbus communication between pc software and your/any modbus slave.
Unfortunately there aren't a lot of documantation for this project.

I finished 2 project with by Delta PLC.

1- At first you should create a comm point like as rs232/485 or tcp/udp.
(http://www.pascalscada.com/communication-ports/)

2- You should use you protocol container as RTU Modbus/Tcp Modbus component.

3- Modbus has got several data type like as 1~0 (true false) or analog input etc. You should select your data type with by Tags.

4- You can use pascalscada indicator or you can use directly this tags in you code.

In attach I added a project form for giving idea to using pascalscada.

I am used this for as datamodule.

Have a nice coding.

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Re: Need help with Modbus
« Reply #2 on: February 01, 2017, 01:58:37 pm »

Any help would be appreciated as my entire project has come to a halt at this point.

Did you solve your problem with PascalScada?

Sage

  • New Member
  • *
  • Posts: 13
Re: Need help with Modbus
« Reply #3 on: February 01, 2017, 06:42:45 pm »

Any help would be appreciated as my entire project has come to a halt at this point.

Did you solve your problem with PascalScada?

Yes actually I did resolve it yesterday. I found out that I had a ISOTCPDriver selected instead of the ModbusTCPDriver on the TAG I was testing. A silly mistake which I kept overlooking which has cost me more than 8 hours. So I feel like an absolute idiot.

Anyway so I have connection and are able to read and write to the server.

I do have some other questions regarding tag properties, could someone explain what the following tag properties actually do?

LongAddress
MemFile_DB
MemSubElement
PLCRack
PLCStation
PLCSlot

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Re: Need help with Modbus
« Reply #4 on: February 02, 2017, 06:31:17 am »

Any help would be appreciated as my entire project has come to a halt at this point.

Did you solve your problem with PascalScada?

Yes actually I did resolve it yesterday. I found out that I had a ISOTCPDriver selected instead of the ModbusTCPDriver on the TAG I was testing. A silly mistake which I kept overlooking which has cost me more than 8 hours. So I feel like an absolute idiot.

Anyway so I have connection and are able to read and write to the server.

I do have some other questions regarding tag properties, could someone explain what the following tag properties actually do?

LongAddress
MemFile_DB
MemSubElement
PLCRack
PLCStation
PLCSlot

I think you are using S7 300 PLC and ISO Tcp diffrent than native TCP/IP protocol:

https://support.industry.siemens.com/tf/WW/en/posts/difference-between-tcp-ip-and-tcp-ip-native-and-iso-on-tcp-ip/34756?page=0&pageSize=10


Actually I didn't work s7 300 plc series over ethernet but some properties comes as generic I think modbus is base model.

Also you can ask author of pascal scada:
https://sourceforge.net/p/pascalscada/discussion/help/





avra

  • Hero Member
  • *****
  • Posts: 2569
    • Additional info
Re: Need help with Modbus
« Reply #5 on: February 02, 2017, 08:23:12 am »
PLCRack
PLCSlot
These are used for addressing cards in Siemens Simatic S7 PLC hardware configuration.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Sage

  • New Member
  • *
  • Posts: 13
Re: Need help with Modbus
« Reply #6 on: February 02, 2017, 08:56:46 am »

Any help would be appreciated as my entire project has come to a halt at this point.

Did you solve your problem with PascalScada?

Yes actually I did resolve it yesterday. I found out that I had a ISOTCPDriver selected instead of the ModbusTCPDriver on the TAG I was testing. A silly mistake which I kept overlooking which has cost me more than 8 hours. So I feel like an absolute idiot.

Anyway so I have connection and are able to read and write to the server.

I do have some other questions regarding tag properties, could someone explain what the following tag properties actually do?

LongAddress
MemFile_DB
MemSubElement
PLCRack
PLCStation
PLCSlot

I think you are using S7 300 PLC and ISO Tcp diffrent than native TCP/IP protocol:

https://support.industry.siemens.com/tf/WW/en/posts/difference-between-tcp-ip-and-tcp-ip-native-and-iso-on-tcp-ip/34756?page=0&pageSize=10


Actually I didn't work s7 300 plc series over ethernet but some properties comes as generic I think modbus is base model.

Also you can ask author of pascal scada:
https://sourceforge.net/p/pascalscada/discussion/help/


Thanks everyone for you input. After many hours of frustration I have managed to send Floats and string values back to the server.
For future users that are looking for information on how to use PascalScada I have learned the following things about sending data types with a size bigger than one WORD (Multiple addresses)

Set MemWriteFunction := 16 (Function code 16 is write to multiple registers otherwise it only send the first WORD)

For strings I have found that for some reason when I select a TCP driver it sets the string length to 6 WORDS (12 Bytes or 11 Chars) and can not be changed. Even though the String size in the Register is actually 19 Characters (10 WORDS or 20 Bytes). Someone might have an explanation for this one.

One way I have found around this is to send each WORD separately one after the other by looping through the string and sending using Function code 6 (Write Single Register). To read it would be the opposite method as it cannot receive a string larger than 11 Chars else it raises and exception in PLCString Unit. There may be a simpler solution to this so if you know of it please post it up here.


avra

  • Hero Member
  • *****
  • Posts: 2569
    • Additional info
Re: Need help with Modbus
« Reply #7 on: February 02, 2017, 11:51:22 am »
For future users that are looking for information on how to use PascalScada I have learned the following things about sending data types with a size bigger than one WORD...
This is the limitation of original MODBUS protocol. It's registers have just 16 bits. In case you want to exchange single float number you have to exchange 2 following 16bit registers. If endian settings are not the same on both sides (protocol it self does not force or define anything on this matter) then one more conversion is needed (with SwapBytes, SwapWords or SwapDWords set to true).

PascalSCADA addressed matter of needing tags greater then 16 bits with PLCBlock component. Also, if all your tags are following one another then it's much faster to read them all with just one MODBUS message. Study provided examples for PLCBlock usage.

p.s.: If you have control on PLC side code then it would be much better to exchange just some string ID instead of transmitting the whole string, and then simply show string message based on that string ID.
« Last Edit: February 02, 2017, 11:59:54 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

mig-31

  • Sr. Member
  • ****
  • Posts: 307
Re: Need help with Modbus
« Reply #8 on: February 02, 2017, 08:13:40 pm »
Throught MODBUS TCP and RTU, you can only send 16-bit (register) and 1-bit values(coil).

If you want to send float (32-bit) or double(64-bit) value, you should use an appropriate number of registers 2 and 4. Remember that usually PLC have opposite byte order (Motorolla order). But some PLC supported both, for example ABB PLC. For strings it better to use direct TCP/IP.

I use PascalScada with ABB PLC AC500, AC500eCo, ABB HMI CP400, 600, 600eCO and Siemens PLC without any troubles with MODBUS TCP.

I think PascalScada automatically send all tags in one message with the same MODBUS connection. It depends on message size, because MODBUS TCP message is limited.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

Sage

  • New Member
  • *
  • Posts: 13
Re: Need help with Modbus
« Reply #9 on: February 03, 2017, 01:20:57 am »
For future users that are looking for information on how to use PascalScada I have learned the following things about sending data types with a size bigger than one WORD...
This is the limitation of original MODBUS protocol. It's registers have just 16 bits. In case you want to exchange single float number you have to exchange 2 following 16bit registers. If endian settings are not the same on both sides (protocol it self does not force or define anything on this matter) then one more conversion is needed (with SwapBytes, SwapWords or SwapDWords set to true).

PascalSCADA addressed matter of needing tags greater then 16 bits with PLCBlock component. Also, if all your tags are following one another then it's much faster to read them all with just one MODBUS message. Study provided examples for PLCBlock usage.

p.s.: If you have control on PLC side code then it would be much better to exchange just some string ID instead of transmitting the whole string, and then simply show string message based on that string ID.

Sorry but I'm not sure if we are on the same page here. I understand that the addresses only hold 16 bits but that's not my issue. PascalSCADA seems to be limiting the number of registers that can be read/written in one go to 12 Bytes. I don't have any issue with Floats because they are only 4 bytes and they work fine using Function Code 16. The issue I ran into was with strings as the string on the PLC are 19 Byte length, but I can only send 11 Byte strings at one go.

avra

  • Hero Member
  • *****
  • Posts: 2569
    • Additional info
Re: Need help with Modbus
« Reply #10 on: February 03, 2017, 09:47:08 am »
The issue I ran into was with strings as the string on the PLC are 19 Byte length, but I can only send 11 Byte strings at one go.
Did you use PLCBlock as I mentioned? If not - try it, if yes - report an issue on PascalSCADA forum. Author was very helpful in several ocassions.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Sage

  • New Member
  • *
  • Posts: 13
Re: Need help with Modbus
« Reply #11 on: February 03, 2017, 09:56:06 am »
The issue I ran into was with strings as the string on the PLC are 19 Byte length, but I can only send 11 Byte strings at one go.
Did you use PLCBlock as I mentioned? If not - try it, if yes - report an issue on PascalSCADA forum. Author was very helpful in several ocassions.

Yea, I did try using the PLCBlock but I don't think it made any difference. Do you think that it's a PascalSCADA issue of an inherent limitation of TCP?

avra

  • Hero Member
  • *****
  • Posts: 2569
    • Additional info
Re: Need help with Modbus
« Reply #12 on: February 03, 2017, 03:37:25 pm »
Yea, I did try using the PLCBlock but I don't think it made any difference. Do you think that it's a PascalSCADA issue of an inherent limitation of TCP?
It's not a TCP limit. At work my non PascalSCADA software reads more then that. KepWare also. You should make a minimal demo demonstrating the problem and report in PascalSCADA forum.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

mig-31

  • Sr. Member
  • ****
  • Posts: 307
Re: Need help with Modbus
« Reply #13 on: February 03, 2017, 04:21:07 pm »
Set properties of TTCPUDPPort:

logFile = filename
LogIOActions = True.

Open the log text file and check what PascalScada sends/receives.

Or use Wireshark.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Re: Need help with Modbus
« Reply #14 on: May 22, 2023, 10:43:04 am »
tr_escape  Sir,
can you contact me?
I have a problem that I can't solve somehow
As far as I understand, you are well-versed in pascalsca.
Please write privately
respects

Dear Sadık,

Did you solve your problem ? If not I can try to help as possible as I can do.

 

TinyPortal © 2005-2018