CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Fri Apr 20, 2018 5:35 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Fri Mar 28, 2014 10:22 am 
Offline

Joined: Wed Mar 19, 2014 4:28 am
Posts: 15
Dear all,
I am working on Codesys V3.5. I am using WIN V3 as my device.I want to communicate with a Modbus slave connected to my Workstation on the COM port.
So I have successfully added IODrvModbus library to my project. I am able to view all the files in the library.
I have added a MASTER COM port in my codesys project. Now as I have iodrvmodbus library added to my project,
I have the following function blocks available

a) IoDrvModbuscomport
b) Modbus request
c) Modbusrequest2
d) ModbusSlavecomport

Which one should I use in my PLC_PRG page ?Do I have to use all the blocks together
2) Also, as a Modbus master, where do I mention Function Code, Slave id, no of bytes to read etc.



Kindly guide

Praveena


Top
   
PostPosted: Sat Mar 29, 2014 8:59 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2623
Hi,

you do not need to call anything manually from the library all is done implicit by the config/ iodriver
just generate the device configuration in the device tree, then add the mapping to your slave
- use the IO variables that't it.
BR
E. Schwellinger


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Wed Sep 30, 2015 4:16 pm 
Offline

Joined: Wed Sep 02, 2015 1:41 pm
Posts: 1
Hi all,

Ok for Implicit configuration IODrv, but i have to access to 2000 registers with one register by channel. So, there isn't enough channels. I would like to set with a variable the offset shield. Or maybe use ModbusRequest FB from iodrvmodbus library. But i don't know how to find the hComPort (RTS_IEC_HANDLE)???? for this FB...


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Mon Jan 09, 2017 12:22 pm 
Offline

Joined: Fri Oct 10, 2014 9:01 am
Posts: 7
Hi all,
I'm on codesys 3.5 sp7 patch5 and I'm trying to use the ModbusRequest FB from iodrvmodbus library. But i don't know how to find the hComPort, me too like the user Moun72.

I suppose my serial port is number 1 but if i try to put 1 directly to input of FB when i launch the command execute the system crash.

Can someone help me ?
thanks in advance


Top
   
PostPosted: Tue Jan 10, 2017 2:16 pm 
Offline

Joined: Fri Oct 10, 2014 9:01 am
Posts: 7
hello, i'm here again,
After some days of search on google and here in this forum i don't find nothing about this function block.
I can not believe no one has ever used this.
And I can not believe that there is no information on this.
No manual, no examples, nothing.
Why ?


Top
   
PostPosted: Tue Mar 06, 2018 10:39 pm 
Offline

Joined: Thu Jul 27, 2017 7:54 pm
Posts: 5
I am also in need of some information on how to give the handle for my serial port to an instance of IoDrvModbus.ModbusRequest2.

My Modbus device is set up poorly and as such I would need to create a channel for almost every word I need to write to. I've created a function block to pass in an offset and value and it will write to the modbus register. With ModbusTCP I have used ModbusRequest and it is working great but I now need to use the serial port for a different device with the same I/O layout.


Top
   
PostPosted: Thu Mar 08, 2018 9:15 pm 
Offline

Joined: Sat Dec 31, 2016 3:18 pm
Posts: 18
Since we had the same problems, we decided to develop our own Modbus library. This will be available in the CODESYS store in March. Hold on


Top
   
PostPosted: Mon Mar 19, 2018 3:11 pm 
Offline

Joined: Thu Jul 27, 2017 7:54 pm
Posts: 5
I got this working... copying my reply from https://forum.codesys.com/viewtopic.php?f=11&t=8568&p=20894#p20894

Mirasoft, I am very much looking forward to your library!

I had to open the COM port first using the SysCom library - this returns the RTS_IEC_HANDLE for the port to pass into the ModbusRequest block.

There is very, very little documentation on this...

Code:
VAR
   modbusRequestSerial: IoDrvModbus.ModbusRequest2;
   modbusCommandSerial : IoDrvModbus.ModbusCommand;
   comm : IoDrvModbus.RTS_IEC_HANDLE;
   commSettings : SysCom.COM_Settings;
   pntResult : POINTER TO SysCom.RTS_IEC_RESULT;
END_VAR

                  comm := SysCom.SysComOpen2(pSettings := ADR(commSettings),0, pResult:=pntResult);
                  modbusRequestSerial(
                     xExecute:= xExecute,
                     xAbort:= ,
                     hComPort:= comm,
                     usiSlaveAddr:= 32,
                     modbusCommand:= modbusCommandSerial,
                     tResponseTimeout:= ,
                     uiSendTimeout:= ,
                     pSendData:= ADR(servoOpcode),
                     pRecvData:= ,
                     transmission:= ,
                     xDone=> xDone,
                     xBusy=> ,
                     xError=> xError,
                     xAborted=> ,
                     uiDataLength=> ,
                     byModbusError=> );


Top
   
PostPosted: Mon Mar 26, 2018 1:06 pm 
Offline

Joined: Sat Dec 31, 2016 3:18 pm
Posts: 18
bjh wrote:
Mirasoft, I am very much looking forward to your library!

It's done. Have a look at Universal Modbus Client/Master


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 9 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited