CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Aug 20, 2019 8:07 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun May 26, 2019 3:21 pm 
Offline

Joined: Mon Aug 13, 2018 4:59 pm
Posts: 4
Hi all

I've been agonizing over the most appropriate structure for my programs structure / architecture. I'm pretty new to this arena.

I'm using a Wago PFC and their associated Modbus TCP master library (not the GUI) in eCockpit - Codesys V3.5.

This provides a Modbus master function block. I have created a PGM which calls this MB master function block perfectly. I can connect to an ancillary device via TCP and read / write data without fault.

What I'm concerned about is my program structure.

The PGM I have created calls the Modbus Master cyclically and has the ability to process multiple requests. They are all timed perfectly, and I can adjust the algorithm to perform 10 requests, 50 requests, perform a write, etc - no overlap.

The master returns an array 'awData' with the respective Mb register data, which could be populated with say 80 variables of interest.

The same PGM is then used to map individual device parameters from the awData array to variables.

ParamA := awData[1];
ParmaB := awData[5];
ParamC := awData[77]; , etc

These parameters are then manipulated to produce useful data (scaling, type conversion, etc) and then mapped to global variables.

This seems a little messy.

First Question:
Should I be using another FB to do the mapping and data manipulation, rather than using the same PGM?

Second Question:
What if I wanted to query 10 different TCP ancillary devices? Under my current model, I'd just create another 10 x PGMs and allow each of these to call another instantiation of the Mb master cyclically also.

Is this accepted / normal practice? Or would you normally have ONE solitary PGM calling a TCP Modbus Master FB to process all requests for ALL devices, then export the data to their respective FB's for processing?

To me, having a single PGM dedicated to one ancillary device makes sense (at least for TCP connections, probably not serial). I'm not sure what is accepted best practice in industry.

At present, everything I have works. That's not to say it's as good as it could be. I'm dying to learn a little more, I've searched everywhere but can't find any definitive guidance.

Any help or examples would be greatly appreciated.

Thanks!


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

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