Multiple DB addresses for a Block_DB

phoenixcmb

Member
Join Date
Jan 2016
Location
Eindhoven
Posts
3
I have the following situation

CALL FC71
Read_in_DBno: DB100 // Input is a Block_DB

I want this to turn this to something like this:
(i know that this software cannot be given but it gives a figure off what i would like to establish)

L #Sensornumber
L 1
== I
spbn rd1
L DB100
T #t_Read_in_DBno
spa rn
rd1:nop 0

L #Sensornumber
L 2
== I
spbn rd2
L DB200
T #t_Read_in_DBno
spa rn
rd2:nop 0
rn:nop 0

CALL FC71
Read_in_DBno: #t_Read_in_DBno

This way I don't have to recall the FC everytime over and over again. I have over a 100 sensors but will read only one sensor at a time. On a panel I choose which sensor i would like to read out.
What syntax do I need to use to make such a function?
 
If you can modify the interface to the FC71, then you have to change the parameter "Read_in_DBno" to integer. Some code inside the FC71 must also be altered.

Then you can calcluate the DB-number with sensornumber+100. The parametertype BLOCK_DB is nothing more than a 16 Bit integer of the DB number.

The disadvantage is that you don't see the access of the datablocks in the reference data, as it does when you use the BLOCK_DB parameter.
 
L 1
+I
T MW100 /increment pointer

L MW100
L 2
*I
T MW102 // pointer to analog input 0, 2, 4, 6...
L MW102
ITD
T MD104

L MD104
L 8 // change double integer to pointer format
*I
T MD108 // Pointer P#0.0, P#2.0...


L MW100
L 0
<I // pointer < 0 -> init
JCN: _001
L0
T MW100
_001: NOP 0

L MW100
L #sensor_max // pointer > max sensor numb -> init
>I
JCN: _002
L0
T MW100
_002: NOP 0

L #sensornumber
L MW100
==I
JCN: _003

L IW [DB108] // read analog input
T MW120 // save analog input value

L MW120
OPN [MW100] // open DB-block (DB0, DB1, DB2...)
T #t_read_in_DBno

_003: NOP 0


Not tested

?
 
Last edited:
Thomas_V2: Your method is a method i used before but the main reasson for going to use a Block_DB variable is that I really would like to see is the access of datablock in the reference list.

Lare: I tried your solution. Beside I program in german several lines turn red when adjusting your program into german. for example: OPN [MW100] = AUF [MW100]. After changing this into AUF DB[MW100] it gets black but this way i get the same solution as Thomas_V2 gives me and is the access of the datablocks not listed in the reference data.



Basically the question is "What is the data type of the TEMP variable #t_read_in_DBno"
 
It is difficult to say without knowing what is inside FC71.

But if it is reference to db block, then data type is probably INT.
 
You can't see indirect access on cross reference. You need to create source files of FC and FB blocks. Then you can search indirect formats from source files (txt)
 
If you want to show the DB's you are using in the xref then they must be explicitly referenced in the code.

Another example implementation to be added to your FC71:

Code:
      L     #iSensorNo
      +     -1
      JL    sens

S001: OPN   DB     1
      JU    doit

S002: OPN   DB     2
      JU    doit

S003: OPN   DB     3
      JU    doit

//etc...

doit: NOP   0
 
In Fc71:

- an input "Read_in_DBno" data type "Block_DB".

OPN #Read_in_DBno
L DBW202

In OB1

CALL FC71
Read_in_DBno: DB100 // Input is a Block_DB

I can repeat FC71 everytime for each sensor and change the DB for each call but what I prefer is that I call FC71 once and make the DB indirect but in the format DB100 or DB101 instead of an integervalue "100" or "101".
 
Copy a cut down version of your project that uses FC71 to a library, archive the library and post as an attachment.

If you access a db indirectly then it will not appear in the xref, hence post #7
 

Similar Topics

Hi guys, so I'm using BOOTP/DHCP tool in my virtual machine for setting up an IP addresses for basically everything. My only issue is always with...
Replies
3
Views
365
When machine has only 1 IP, we hook up a wireless client and set a static IP. Works Fine Alot of our newer machines have multiple IPs for PLC...
Replies
12
Views
6,153
Has anyone ever tried to send email to multiple addresses with a CompactLogix. Manual examples affect sending to only one address (...
Replies
4
Views
4,057
We have several PLCs with static ethernet conections. I have to change the IP address on my laptop to match the target PLC. Is there a way I...
Replies
7
Views
3,000
Is it possible to have two addresses that monitor the same tag on a HMI screen? For example, let's say a user inputs the number 10, is it posible...
Replies
2
Views
1,836
Back
Top Bottom