Symbols, Buffering I/O, Marks vs DB, doubts

Hernan_e

Member
Join Date
Sep 2008
Location
Rosario
Posts
9
Hello

I want to map every input/outputs to memory
First approach I did was a list copying every bit
but the code was too big.. Then I decide to use Marks

Code:
    real input  TO memory  (for example E0.0 to M0.0)
   real output TO memory  (for example A0.0 to M200.0)

   ..work within memory (no I/O reference)

   memory TO real output (for example M200.0 to A0.0)
An idea for doing this is using marks in same Order than memory
(and simbols names similars in memory as i/o)

Code:
OUT_MOTOR_A    A 0.0
OUT_MOTOR_B    A 0.1

as

BUFF_MOTOR_A    M 200.0
BUFF_MOTOR_B    M 200.1

etc..
So it can be achieve with a very short code

Code:
    //real input to memory input    
    L   ED     0                  
    T   MD     0
//real output to buffer output 
    L   AD   0
    T   MD   200

    //...
    //...    PLC CODE
    //...


    //buffer output to real output
    L     MD   200               
    T     AD     0
But, it requires to define memory bits symbols in exact same order than i/o that's difficult to mantain.

Then I got some question about all this,

1. I know mapping I/O to memory would seem unnecesary because scan cycle ensure to do that anyway, but to knowexactly where real I/O are used(in a unique place) that can have in a single block"general" condition for every I/O really worth for me, what do you think?

2. Marks let do that kind of things, if I couldn't move by 4 bytes at a time, the screen would be filled with

Code:
U buffer_var
= out_var
   ...
(the advantage of this approachs is that I haven't to keep the order) and can even use DB.. Can it be done with DB?

3. Could this be done in STL? The most "flexible" approach I have in mind is to do it with metaprogramming, to make a software (c++/java/etc..) so I would give it the list of I/O, and it will generate the code in STL or AWL for doing the buffer asignation. (It's a weird solution, but will work till siemens do something better.. )

4. What are other advantages of using Marks instead of DB? is there any speed/volatileness issue? what about instance or global DB, have any performance difference?

Thank you for your opinion.
 
Last edited:
I've done similar on my current project, I needed to manage IO to use in machine control blocks and to transfer all IO to a master PLC.

I created a UDT that listed all IO in byte order, such as the single byte sample below:

Code:
TYPE "UDT IC INPUTS"
VERSION : 0.1
  STRUCT     
   CB717 : BOOL ;    // 24VDC Control Healthy
   ESL_975 : BOOL ;    // Local Emergency Stop Healthy
   I_124_2_SP : BOOL ;    // SPARE
   ESM_939 : BOOL ;    // Master Emergency Stop Tripped
   MCB759 : BOOL ;    // Car Conveyor Circuit Breaker Healthy
   M883_FB : BOOL ;    // Car Conveyor Contactor Feedback
   MCB763 : BOOL ;    // VFD Supply Circuit Breaker Healthy
   M884_FB : BOOL ;    // VFD Enable Contactor Feedback
  END_STRUCT ;    
END_TYPE
This was used in a FB STAT area where I wanted to move the IO.

I then created UDT's, one indicating the IO start address and length in bytes and the other the destination DB and start address for a block transfer.

Code:
TYPE "UDT IO CONFIG"
VERSION : 0.1
  STRUCT     
   ADDRESS : INT ;    //IO Address
   LENGTH : INT ;    //Block Length
  END_STRUCT ;    
END_TYPE

TYPE "UDT IO DB CONFIG"
VERSION : 0.1
  STRUCT     
   DB_ADDRESS : INT ;    //Data Block Address
   DBX_ADDRESS : INT ;    //Data Bit Start Address
  END_STRUCT ;    
END_TYPE
I then created 2 DB's (one for inputs and one for outputs), which each started with an integer (to indicate the number of blocks to move, used in a loop). After the integer two arrays made up of the above UDT's.

I then created a block which looped around the number of times indicated in the integer, each loop getting the data in the arrays, create ANY pointers from these and call SFB20 (Block move).

For example

BLOCKS = 3
IN ARRAY[1.1] 100
IN ARRAY[1.2] 4
IN ARRAY[2.1] 120
IN ARRAY[2.2] 2
IN ARRAY[3.1] 250
IN ARRAY[3.2] 8
DB ARRAY[1.1] 80
DB ARRAY[1.2] 10
DB ARRAY[2.1] 80
DB ARRAY[2.2] 14
DB ARRAY[3.1] 80
DB ARRAY[3.2] 16

So I would do 3 loops, first loop block transfer 4 bytes of data starting from IB100 into DB80 starting at data byte 10.

Second loop block transfer 2 bytes of data starting from IB120 into DB80 starting at data byte 14.

Third loop block transfer 8 bytes of data starting from IB250 into DB80 starting at data byte 16.



The above could be done by moving into marker flag areas just as easy, the inky difference being you could not control the IO structure via a UDT.

Using flags is faster but I don't believe significantly.
 
Last edited:
@peterW I am seeking for a simpler solution, yours seems need to write a lot of code and has a little danger about putting incorrect index number (you know that could be a mess if the loop go wrong), anyway taking it into account when building a code generator, thanks


See my item 1, some reasons are

.Debugging: You can set/get those memory values from Scada, so you can simulate the entire project

.General conditions- You can put some "sine qua non" condition for a whole set of I/O (for example range validation, emergency stop) in a single place

.Safety - You can use same trusted/proved functions over different I/O sources (local, remote, profibus, etc..) without special care about direction, general protections could be defined directly for output in a single place.
In case of trouble you can be sure "who is setting this output" and easily rebuild the whole logic with a new memory direction being sure no other block will set the output.
 
Last edited:

Similar Topics

Hello to all, Is it possible to export Codesys symbols to .txt, .csv or .xml in a similar manner like exporting symbol table in STEP 7? For...
Replies
0
Views
125
I'm a bit confused about how symbols and UDTs work... As far as I know, in offline mode FB gets symbols from the UDT declared in the "state"...
Replies
4
Views
419
I have a machine that was powered off for repairs, when powered back on the Panelview fails to upload the tag database from the PLC. Its a...
Replies
1
Views
1,533
Looking for some explanation/history between North American electrical symbols standards (how they relate, what are the latest, what is the...
Replies
3
Views
1,701
Does anyone have a library of the ISA standard process symbols in PNG, BMP or something that is importable into an HMI screen? I'm about to sit...
Replies
1
Views
1,000
Back
Top Bottom