best practices

best practices

this is my favorite programming structure in programming small applications ( it would increase the flexibility and the readability of the code )

note : since we all in quarantine lets share our best programming structures and best practices

lets start :

- first i usually create a function called i/o to acquire all i/os

if i have many i/os i would make another function for analog i/os ( i assign each hardware of input address to a memory space and each memory space to an output hardware address )

No alt text provided for this image
No alt text provided for this image


i created a datablock containing all output and input memory spaces

No alt text provided for this image


- i would divide my program into Functions blocks based on the functionality if its complex enough or sections

and then if i needed an fc inside that FB i would call it

i never assign FCs to parts that would not be called again

so i make sure always to make my FCs reusable and generic

( so i could use it in other applications and programs utilizing libraries in tia protal , also before editing any fc i usually make versions of it using types in tia portal )

- i never use any global memories i always make use of the variable table above

No alt text provided for this image


No alt text provided for this image


-- i never make the time of the timers Fixed even if its fixed on the application

i prefer to make it changeable even in the programming environment so i would put the timer datablock and time as inputs of the functions

-- i never use global memory bits in FCs or addresses of the hardware i/o ( see the first point ) in the my programs i only use the assigned memory space to each

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image


#automation #siemens #smartindustry #automationsolutions #programming #industrialcontrol

#controlpanel #controlsystem #industrialautomation #plc #plcprogramming

要查看或添加评论,请登录

Ali Ibrahim的更多文章

社区洞察

其他会员也浏览了