Post by smeitink on Timeout Error in Modbus Communication with WAGO PFC200 and iEM2050 Meter using 750-652 Module
CODESYS Forge
talk
(Post)
Hi all, I'm looking for help with an issue I've come across while trying to facilitate Modbus communication between a WAGO PFC200 PLC using a 750-652 communication module and an iEM2050 Series Single Phase Energy Meter. I believe to have everything wired and setup correcty, but I keep running into a "Error time out" message, and by now I don't really know what else to try. My setup is as follows: A PFC200 Wago PLC, which has 2 750-652 Serial Interfaces extension modules connected to its field bus. I'm using one of these to talk to a Schneider iEM2050 - kWh-meter over modbus. I have connected terminal 23 (A) of the iEM2050 to connector 6 (A) on the 750-652. I have connected terminal 24 (B) of the iEM2050 to connector 2 (B) of the 750-652. I'm using 200mm of twisted together wires to connected them both, and I have placed a 120 ohm resistor between A and B at both ends. I've attached relevant pinout images to this post. I then wrote a simple program that configures the Mobus port, as per the datasheet of the iEM2050. You can find an image of the relavent page attached to this post too. This is my program: PROGRAM PLC_PRG VAR Master: FbMbMasterSerial; xIsConnected: BOOL; xError: BOOL; iIndex: INT := 1; xTrigger: BOOL; utQuery : typMbQuery := ( bUnitId := 1, // The Modbus unit or slave address bFunctionCode := 4, // Function code for reading input registers uiReadAddress := 1829, // adress for the Power on off counter uiReadQuantity := 1 // Quantity of registers to read ); iStep: INT; oStatusModbus: WagoSysErrorBase.FbResult; utResponseModbus: typMbResponse; xConnect: BOOL := FALSE; delayTimer: TON; END_VAR Master( xConnect:= xConnect, I_Port:= _750_652_24_1, udiBaudrate:= 9600, usiDataBits:= 8, eParity:= WagoTypesCom.eTTYParity.Even, eStopBits:= WagoTypesCom.eTTYStopBits.One, eHandshake:= WagoTypesCom.eTTYHandshake.None, ePhysical:= WagoTypesCom.eTTYPhysicalLayer.RS485_HalfDuplex, xIsConnected=> xIsConnected, xError=> xError, oStatus=> oStatusModbus, eFrameType:= WagoAppPlcModbus.eMbFrameType.RTU, tTimeOut:= T#5S, utQuery:= utQuery, xTrigger:= xTrigger, utResponse:= utResponseModbus); delayTimer(IN := TRUE, PT := T#3S); // Use the Q output of the timer to set xConnect after the delay IF delayTimer.Q THEN xConnect := TRUE; END_IF CASE iStep OF 0: //Wacht totdat de master de poort geopend heeft IF xIsConnected THEN iStep := 1; END_IF 1: //Stuur request naar de slave xTrigger := TRUE; iStep := 2; 2: //Wacht totdat de master klaar is met het afhandelen van de request IF NOT xTrigger THEN iStep := 3; END_IF END_CASE The TON delay before opening the port is due to a an error I encountered when opening it straight away. This seems to be a bug, as described here. However, the TON solved that particular issue. I tried reading multiple registers, but like I said, I still always end up with the "Error time out". What else can I test or try at this point?
Last updated: 2024-02-24
Post by jackbrady on Function Blocks and arrays of function blocks
CODESYS Forge
talk
(Post)
Hello, I am new to Codesys and PLC programming in general (please go easy ha!) I'm not looking for code to be written for me just some help and pointing in the right direction. I am writing some code to send commands to a relay based on input values (to put it simply). Quite basic stuff. I have wrote a function block that takes a global variable (Open_command:BOOL) and outputs to another global variable (Opened : BOOL). The function block is simulating a device so I'll eventually get the globals from that. I now need to create multiple versions of this function block/ device (lets say 100) but I need each iteration of that function block to reference it's own relevant global variable. I think that the best way of doing this would be to use arrays, although I could be wrong. I am aware that for up to 100 instances I could very well manually assign everything but that seems rather time consuming and I want a fancier way of doing it. Here is a very basic example of what I am looking to do, please note I have not written this in proper code it's just to show what I mean. Global Variables V[0-100] int Open_command [0-100] Bool Opened [0-100] Bool Function Block var input x : BOOL Var output y : BOOL if x then y = TRUE ELSE y = FALSE The input to my function block will be Open_command, output will be Opened Example code. If V[x] > 10 then Open_command [x] = TRUE ELSE Open_command [x] = FALSE (So when V1 goes above 10 I need Open_command1 = TRUE therefore initiating FB1 output. V2 > 10, open_command2 = True > FB2 output V3 > 10, open_command3 = True > FB3 output ... ... ) What I can't seem to figure out is how to tie all this together, I have read through the codesys documentation and if anything it has confused me more! ha. Apologies for the poorly written post but hopefully you understand what I am trying to get at. Thanks, Jack
Last updated: 2024-02-14
Post by jst69 on Python script: Launch Codesys, Execute Script, Exit Codesys
CODESYS Forge
talk
(Post)
Dear all: Question about scripting: I am creating a .NET program that is supposed to Open codesys, open template project, export a bunch of pou, then exit codesys. Launch works, Open project works, Export works, But how do i tell codesys to close itself? I can tell windows to terminate codesys, but i would prefer to do it properly. from __future__ import print_function import sys import System proj = projects.primary # We're interested in POU nodes: POUGuid = Guid("6f9dac99-8de1-4efc-8465-68ac443b7d08") # We collect all POU nodes in that list. pous = [] # From the parent node on, we recursively add POU nodes: def CollectPous(node): if node.type == POUGuid: pous.append(node) else: for child in node.get_children(): CollectPous(child) # Now we collect all the leaf nodes. for node in proj.get_children(): CollectPous(node) # We print everything just to know what's going on. for i in pous: print("found: ", i.type, i.guid, i.get_name()) # And now we export the files. for candidate in pous: # We create a list of objects to export: # The object itsself objects = [candidate] # And sub-objects (POUs can have actions, properties, ...) objects.extend(candidate.get_children()) # And the parent folders. parent = candidate.parent while ((not parent.is_root) and parent.is_folder): objects.append(parent) parent = parent.parent # Create an unique file name: if len(sys.argv) == 1: filename = "parent\\%s.export" % (candidate.get_name()) else: filename = "%s\\%s.export" % (sys.argv[1],candidate.get_name()) # print some user information print("exporting ", len(objects), " objects to: ", filename) # and actually export the project. proj.export_xml(objects, filename) proj.close() print ("script finished.") System.exit(0) // Dont work .NET: public static void Export(string path,string proj) { if (checkSettings()) { var p = new System.Diagnostics.Process(); p.StartInfo.FileName = Properties.Settings.Default.CSVersion +"\\CODESYS\\Common\\CODESYS.exe"; p.StartInfo.Arguments = " --Profile=" + qoute(Properties.Settings.Default.CSProfile) + " --culture=en" + " --project=" + qoute(path + "\\" + proj) + " --runscript=" + Properties.Settings.Default.LastOpenProjectPath + "\\INPUT_DATA\\SCRIPT\\Export.py" + " --scriptargs:" + qoute(path) ; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = false; p.Start(); p.StandardOutput.ReadToEnd(); p.CloseMainWindow(); p.Close(); } }
Last updated: 2024-01-16
Post by r-niedermayer on C0564 Warning Message
CODESYS Forge
talk
(Post)
Please see or Online Help on how to initialize variable before using them: https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_global_init_slot.html Regarding the Attribute global_init_slot: You can use this pragma to influence the order in which signatures are processed during global initialization. It can only be applied to signatures. By default, the initialization sequence for variables from global variable lists is undefined! However, if, for example, variables from one list depend on variables from another list, it is necessary to initialize one before the other. (Aee OLH and Syntax) The placeholder <slot> must be replaced by an integer value that defines the position in the initialization sequence.</slot> The default value is 50000. A lower value causes an earlier initialization! If several signatures have the same value for the 'global_init_slot' attribute, the order of their initialization remains undefined! Cautious application should therefore be considered! Example: The project contains f.e. two global variable lists GVL_1 and GVL_2. The global variable "A" is part of the global variable list GVL_1: {attribute 'global_init_slot' := '300'} VAR_GLOBAL A : INT:=1000; END_VAR The initialization values of the variables "B" and "C" of GVL_2 are dependent on the variable "A". {attribute 'global_init_slot' := '350'} VAR_GLOBAL B : INT:=A+1; C : INT:=A-1; END_VAR So if you set the 'global_init_slot' attribute of the global variable list GVL_1 to 300, i.e. to the lowest initialization value in the example, then it is ensured that the expression "A+1" is well-defined at the time of initialization of "B".
Last updated: 2024-01-30
Post by gerdkoch on Dynamic I/Os Mapping
CODESYS Forge
talk
(Post)
Hi, I assume that you have a Pfc200 G2 or something and work with the original WAGO runtime. Then I would recommend the WagoSysDynamicIoMapping. Here in the example projects there is a PDF file for the library: https://downloadcenter.wago.com/learning-material/details/ll0w3pmdunzvem83g1 There is a global functional component in a GVL of the library. I think it's called DynKbusIoManager or something. The active terminals are registered there. Then there are filter Fb's for e.g. the first clamp with a specific article number. Everything is in the PDF.
Last updated: 2023-08-18
Post by timvh on IFM CR711S Version Mismatch
CODESYS Forge
talk
(Post)
You should ask IFM to provide you with the correct version of their controller packages. Then after you have installed this, you can select the correct version of the controller by right clicking on it in the device tree, update device, enable the option "Display all versions" and then select the version which matches your controller. Alternatively you can ask IFM to provide an update package which can update the runtime version on your controller to 3.2.0.0.
Last updated: 2024-03-05
Post by timvh on JSON
CODESYS Forge
talk
(Post)
I don't know the details of jsonArrayWriter, but the common behaviour for an xExecute input is that the FB starts on the trigger that it gets TRUE. In your case xExecute is never FALSE, so it is never triggered again to start the jsonArrayWriter. So change the condition from TRUE to a variable which you set to TRUE with the "xFirst". Then when the jsonArrayWriter is done (xDone), or has an error (xError), then set this variable to FALSE.
Last updated: 2024-05-01
Post by gregor on PFC 200 - codesys V3.5
CODESYS Forge
talk
(Post)
As far as I know, only if someone downloaded sourcecode to the PLC.
Last updated: 2023-08-25
Post by eschwellinger on Project compiling error in Simulation mode
CODESYS Forge
talk
(Post)
I fear you need to update if you need a solution for this.
Last updated: 2023-09-08
Post by eschwellinger on EtherCat-Rexroth Drive lost connection or no?
CODESYS Forge
talk
(Post)
check on EthercatMaster status page if you loose Ethercat frames - and check how the jitter is on Ethercat Master task
Last updated: 2023-10-25
Post by imdatatas on Detecting if a client is connected to webvisu server
CODESYS Forge
talk
(Post)
Thank you @dgirard Your idea and above description helped me what i was looking for.
Last updated: 2023-11-08
Post by simotion on Property
CODESYS Forge
talk
(Post)
Why can't a property be of type REFERENCE TO? Plc goes to stop if I try that.
Last updated: 2023-12-14
Post by ton on How to create a stopwatch?
CODESYS Forge
talk
(Post)
If you use LTIME() you will be very accurate and be able to have a normal task cycle time.
Last updated: 2023-12-16
Post by eschwellinger on Raspberry Pi 4 with Legacy Drivers and Codesys 3.5.19 Patch 4
CODESYS Forge
talk
(Post)
what if you use all packages in latest version? pi Runtime 4.10.0.0 ?
Last updated: 2023-12-19
Post by eschwellinger on Access to the path *** is denied
CODESYS Forge
talk
(Post)
it is textlist related as far as I remember, let me check if the is a workaround.
Last updated: 2024-02-02
Post by eschwellinger on Access to the path *** is denied
CODESYS Forge
talk
(Post)
the workaround is: start CODESYS admin if this message occure
Last updated: 2024-02-05
Post by hasangenc on DI4 USB - Transfer Data
CODESYS Forge
talk
(Post)
Well, Hi again. I solve the problem, if anyone having the same problem, I might help. You can reach me through this platform.
Last updated: 2024-02-22
Post by nmcc on Viewing PDF in WebBrowser Visual Element
CODESYS Forge
talk
(Post)
You can change which browser you use in a webbrowser visual element? if so how do I do that?
Last updated: 2024-03-01
Post by eschwellinger on Only single ehternet ip drive is communicating
CODESYS Forge
talk
(Post)
which versions EIP & Runtime and which plc is this? Does it work if they are connected to one network interface?
Last updated: 2024-03-09
Post by markl on Using wildcards with SysLibFile.lib
CODESYS Forge
talk
(Post)
I don't have an answer but I was wondering if you have found out more about using wildcards in Codesys?
Last updated: 2024-03-13
Post by eschwellinger on Raspberry PI4 Serial Port
CODESYS Forge
talk
(Post)
no parameter seems ok but RS485 does only work with CODESYS if the send/receive is determined by hardware as I remember correct
Last updated: 2024-03-18
Post by rajshaswat on OPC-UA and other communication questions
CODESYS Forge
talk
(Post)
check this if it helps : https://youtu.be/Hdpbsp2jG3Q?si=NTwK13c_YOSZXM3v
Last updated: 2024-04-06
Post by felipemsgarcia on Generic EtherCAT slave
CODESYS Forge
talk
(Post)
Hello, I'd like to know if it's possible to add a servo drive as a generic EtherCAT slave (non-Motion). Thank you in advance!
Last updated: 2024-05-14
Post by mos89p on Check if Codesys runtime is on 'Running' or 'Stopped' state?
CODESYS Forge
talk
(Post)
why not put it on windows startup ? to start at each start
Last updated: 2024-07-02
Post by pazderai on CanOpen write issue
CODESYS Forge
talk
(Post)
Anyway, any idea how to get command byte 0x22 for sdo write if I use codesys cia405 canopen library?
Last updated: 2024-07-16
To search for an exact phrase, put it in quotes. Example: "getting started docs"
To exclude a word or phrase, put a dash in front of it. Example: docs -help
To search on specific fields, use these field names instead of a general text search. You can group with AND
or OR
.