<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/</id><updated>2026-08-30T19:00:00.815000Z</updated><subtitle>Recent posts to Advice on OOP hardware I/O code structure </subtitle><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=25#1364" rel="alternate"/><published>2026-08-30T19:00:00.815000Z</published><updated>2026-08-30T19:00:00.815000Z</updated><author><name>alicecastle0003</name><uri>https://forge.codesys.com/u/alicecastle0003/</uri></author><id>https://forge.codesys.com69feca8a5fb48e5670cd8516249763111c3bab61</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;This is a helpful and informative post. The points shared are practical and easy to understand, especially for students who are trying to manage their studies and deadlines. For those who need additional academic guidance, &lt;a class="" href="https://www.myassignments-pro.com/assignment-help-melbourne/" rel="nofollow"&gt;assignment help Melbourne&lt;/a&gt; can also be a useful option for staying organized and understanding difficult topics.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=25#96ec" rel="alternate"/><published>2026-08-29T11:29:02.141000Z</published><updated>2026-08-29T11:29:02.141000Z</updated><author><name>marksmith27779</name><uri>https://forge.codesys.com/u/marksmith27779/</uri></author><id>https://forge.codesys.com9152f0fe8c28447870983ec7671e49a2453a7588</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I found this discussion quite useful, especially the points about planning, risk management, and meeting project deadlines. Students working on complex coursework can also benefit from reliable &lt;a class="" href="https://www.allassignmentspro.com/project-management-assignment-help/" rel="nofollow"&gt;Project Management Assignment Help&lt;/a&gt; when they need additional guidance with research, structure, or understanding challenging concepts.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=25#f672" rel="alternate"/><published>2026-08-27T13:19:03.932000Z</published><updated>2026-08-27T13:19:03.932000Z</updated><author><name>carolynjanet747</name><uri>https://forge.codesys.com/u/carolynjanet747/</uri></author><id>https://forge.codesys.com89fd903c582342f065fecd850ac2f669c23fd693</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;This was a very engaging and well-written blog post, and I really appreciated how clearly the ideas were explained. The content is informative and easy to follow, making it valuable for readers from different backgrounds. Students facing urgent deadlines can explore &lt;a href="https://www.myassignments-pro.com/last-minute-assignment-help/" rel="nofollow"&gt;Last Minute Assignment Help&lt;/a&gt; for guidance with research, structure, referencing, proofreading, and final checks while maintaining the quality of their academic work. Keep up the great work and continue sharing such helpful content!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=25#0fbd" rel="alternate"/><published>2025-10-31T03:00:14.318000Z</published><updated>2025-10-31T03:00:14.318000Z</updated><author><name>salmawis</name><uri>https://forge.codesys.com/u/salmawis/</uri></author><id>https://forge.codesys.com67b9181edcc899e62afb62f1930f697588580cc2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Call 10 FB instances. Connect Motor_1_Fault to the i_xHW_FaultDetected pin of FB 1, Motor_2_Fault to FB 2...&lt;/p&gt;
&lt;p&gt;By doing this, your FB will be flexible. The programming will be smooth like a perfect  &lt;a class="" href="https://drift-boss.pro" rel="nofollow"&gt;Drift Boss&lt;/a&gt;, instead of "hitting the wall" because it can't be reused!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=25#5120" rel="alternate"/><published>2024-09-30T12:10:32.956000Z</published><updated>2024-09-30T12:10:32.956000Z</updated><author><name>david3278</name><uri>https://forge.codesys.com/u/david3278/</uri></author><id>https://forge.codesys.comc38f0ad681a5bdaa17b05dc79771833c64141c61</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;For anyone struggling with &lt;a href="https://www.myassignment-services.com/electrical-engineering-assignment-help.html" rel="nofollow"&gt;electrical engineering assignment help&lt;/a&gt;, I highly recommend seeking professional assignment help. These services offer expert guidance on complex topics like circuit analysis, power systems, and electronics. They can save you time, improve your understanding, and help you meet tight deadlines. Great option for ensuring high-quality work and better grades.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=50#e50e" rel="alternate"/><published>2023-04-18T17:54:30.037000Z</published><updated>2023-04-18T17:54:30.037000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com6a841732411147c8095cd00cdf7c02d06e28bb8e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;There's also this method of declaring a function block instance for each I/O channel, seems like it would accomplish what you're trying to do quite nicely:  &lt;a href="https://help.codesys.com/api-content/2/codesys/3.5.13.0/en/_cds_configuring_devices_mapping_ios/#mapping-a-device-input-to-a-function-block-instance" rel="nofollow"&gt;https://help.codesys.com/api-content/2/codesys/3.5.13.0/en/_cds_configuring_devices_mapping_ios/#mapping-a-device-input-to-a-function-block-instance&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=25#e479" rel="alternate"/><published>2023-04-11T03:12:28.194000Z</published><updated>2023-04-11T03:12:28.194000Z</updated><author><name>fajean</name><uri>https://forge.codesys.com/u/fajean/</uri></author><id>https://forge.codesys.com0be5f2a77c45592550446315a171ac29b086a002</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I am the guy from the Stackoverflow answer. Let me attempt to give you a few more breadcrumbs.&lt;/p&gt;
&lt;p&gt;You are likely to want to achieve any combination of these goals.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make your control logic independent from your hardware&lt;/li&gt;
&lt;li&gt;Avoid hard-coded hardware addressing.&lt;/li&gt;
&lt;li&gt;Allow several instances of whichever device you control (e.g. motor)&lt;/li&gt;
&lt;li&gt;Make your code portable (for me, this means CODESYS and TwinCAT).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I have found only one sane way to check all these boxes.  This way involves not trying to achieve all these goals within the same function block.  I have roughly four layers (that each correspond to separate libraries/projects):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Function blocks that represent actual hardware devices (such as individual I/O cards). They define inputs/outputs as incomplete addresses (%I&lt;em&gt; or %Q&lt;/em&gt;). The incomplete addresses can be coded against even though they are only to be mapped in the final project that uses the library.&lt;/li&gt;
&lt;li&gt;Function blocks that represent the control logic.  They have their own input/output structures, which are normal variables. They use no I/O addresses, and no hardware device function blocks.&lt;/li&gt;
&lt;li&gt;"Electrical design" function blocks, that inherit from control logic function blocks, but also declare hardware function blocks as well as methods that copy the hardware inputs to control inputs, and control outputs to hardware outputs. Each function block matches a specific electric drawing. Only in this function block is there a relationship between the hardware and the control logic, which makes sense because the electrical design is not hardware-independent (the coupling happens at the "right place").&lt;/li&gt;
&lt;li&gt;Projects, that use these (reusable) hardware-dependent function blocks, and map the incomplete addresses.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can see how each layer has a precise role to play in abstracting away different things, which allows different kinds of reuse (control logic reuse, hardware device reuse, full subsystem reuse) to happen independently.&lt;/p&gt;
&lt;p&gt;We can have several hardware implementations (electrical designs) for the same control logic. We can have inputs and outputs that have different formats in the control logic vs. hardware (think analog scaling, reading/writing ENUM values as bit groups, etc.).&lt;/p&gt;
&lt;p&gt;I/O function blocks can be as simple as this :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;FUNCTION_BLOCK BECKHOFF_EL1002&lt;/span&gt;
&lt;span class="err"&gt;VAR_INPUT&lt;/span&gt;
&lt;span class="err"&gt;  in AT %I* : IO_2CH1_BIT;&lt;/span&gt;
&lt;span class="err"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The IO_2CH1_BIT structure is just this :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;TYPE IO_2CH1_BIT :&lt;/span&gt;
&lt;span class="err"&gt;STRUCT&lt;/span&gt;
&lt;span class="err"&gt;  ch1 : BIT;&lt;/span&gt;
&lt;span class="err"&gt;  ch2 : BIT;&lt;/span&gt;
&lt;span class="err"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="err"&gt;END_TYPE&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Per-project mapping is super-easy, because you are mapping an I/O card's memory to a function block that represents the same I/O card (and can have the same instance name as the I/O card in your project tree). The relationship between hardware and control logic variables is implemented at a reusable layer, so we only have to test and debug once for each hardware design. Any technician with a rough understanding of the IDE can create a project and map the I/O without any knowledge of the control logic.&lt;/p&gt;
&lt;p&gt;In other words, we achieve hardware-independence of the control logic, control-logic independence of the project, while retaining reusable, programmatic use of hardware-dependent features neither the project nor the control logic know anything about.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=250#b02b" rel="alternate"/><published>2023-04-06T01:43:13.728000Z</published><updated>2023-04-06T01:43:13.728000Z</updated><author><name>h-hermsen</name><uri>https://forge.codesys.com/u/hermsen/</uri></author><id>https://forge.codesys.comfb34cb7c0a6859a5d0bbd34747acd11404cbc8e1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I'd prefer programming individual signals over BYTE or WORD/ DWORD assigned boolean channels. Usually individual channel assignment makes your code read way easier both at the hardware IO mapping and in the FB or PRG itself. The slight cost of declaring more channels usually adds tremendous added value for well readable code. The adagio in modern days is readability over compact programming. PS read up on PLCOPen programming style guidelines, they forbid you from using of direct adressing.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=25#81f9" rel="alternate"/><published>2023-04-05T21:18:28.918000Z</published><updated>2023-04-05T21:18:28.918000Z</updated><author><name>sturmghost</name><uri>https://forge.codesys.com/u/sturmghost/</uri></author><id>https://forge.codesys.com8bc363868a50a859d05fd3de7cfecb4588204e6e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;With 5) you mean using the I/O mapping tab and mapping the full path name to a hardware channel/address?&lt;/p&gt;
&lt;p&gt;Im doing this right now but using the AT command for mapping the full Input or Output module, not just a single channel.&lt;/p&gt;
&lt;p&gt;So I habe an IO Struct, which contains for example&lt;/p&gt;
&lt;p&gt;Value : Bool&lt;br/&gt;
Unit : String(80);&lt;/p&gt;
&lt;p&gt;And another struct for the module, with:&lt;/p&gt;
&lt;p&gt;Channel : Array&lt;span&gt;[0..13]&lt;/span&gt; Of IO_DUT&lt;br/&gt;
Input At %IW0 : Word;&lt;/p&gt;
&lt;p&gt;Im instancing the module struct as a Var_in_out in a program. With that I didn't touched the I/O mapping tab. &lt;/p&gt;
&lt;p&gt;In order to avoid the at command I need to define&lt;/p&gt;
&lt;p&gt;Input_1 : Bool;&lt;br/&gt;
Input_2 : Bool;&lt;br/&gt;
...&lt;/p&gt;
&lt;p&gt;and map each variable to one input channel via the I/O mapping tab, right? Or do you have a different procedure in mind? &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Advice on OOP hardware I/O code structure </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/31a9d7c889/?limit=250#fc02/4cfa" rel="alternate"/><published>2023-04-05T18:03:00.074000Z</published><updated>2023-04-05T18:03:00.074000Z</updated><author><name>h-hermsen</name><uri>https://forge.codesys.com/u/hermsen/</uri></author><id>https://forge.codesys.com8c7c607e87847f7834a3bd573009ed4bc78f87d6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;VAR_IN_OUT is technically a pointer so yes it is absolutely the way to go&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>