How do I add code in this prog? S7, STL

PontEL

Member
Join Date
Mar 2006
Location
Sthlm
Posts
13
Hello,

I have a code like in the picture below. I want to view the value that is sent to the output PQW512 on my SCADA. To do this I want to copy/send it to a data block address. But the value I want to view is actually whats in #Y_output_MP, that is 26.89 in the picture (means 26.9%). At least thats what I think, I don't know why there is a *R before the output, but the value 26.89 is about what it should be in the process.

How do I do this? I can't just copy #Y_output_MP to a DB because sometimes the value to PQW512 is from #Y_OUTPUT_SR (I think, don't understand whats behind the logic).

How should I do this the best way?

http://www.mediafire.com/view/?cuywo4qkg4t0alf



In text version of someone wants to copy and edit...

AN #Modus_35bar_activ
O "H1"
JC WEIT
L #Y_OUTPUT_SR
JU END

WEIT: L #Y_output_MP
END: L 2.764800e+002
*R
RND+
T "PAW 512"

floating_2.jpg
 
Last edited:
I think you should be able to change
END: L 2.764800e+002

to

END: T "Your DB WORD"
L 2.764800e+002

I'm not an expert on STL but I think that will work
 
I tested in PLCsim and it seems to work! So I guess it's OK, but... I just want to make sure about this:

The manual says
"*R Multiply ACCU 1 and ACCU 2 as Floating-Point Numbers"

Then I guess it means that either #Y_OUTPUT_SR or #Y_output_MP is loaded to ACCU 1, and then 2.764800e+002 is loaded to ACCU 2? And this doesn't change as long as I don't load anything else between? And only use Transfer to my Datablock between shouldn't change anything??

It is a S7-400 (my test was on a s7-300 simulated)
 
nearly right, when you load the floating point constant, ACCU 1 (your SR or MP value) gets moved to ACCU 2 and the last value loaded gets put in ACCU 1. That's why you have to do the transfer before you load the constant
 
First of I'm not expert and my knowledge of S7-family stl is very limited.

AN #Modus_35bar_activ // AND Not?? ..yes checked from manual
O "H1" /// Is OR ? // What these two lines do to next JC??
JC WEIT // So if above Bit logic is true (Jump Conditional?) jump WEIT
L #Y_OUTPUT_SR // Load value to ACCUmulator1
JU END // Jump (unconditional?) to END

WEIT: L #Y_output_MP / WEIT Label (comes here from JC) and load value in #Y_output_MP to ACCUmulator 1
END: L 2.764800e+002 // Load 2.7... to accu1 and move previous accu1 value (#Y_output_XXX)to accu2
*R // Multiply real values Accu1*Accu2 and save the result to accu1
RND+ // out of my knowledge this command (Round value to bigger or something??)
T "PAW 512" // Send value in accu1 to "PAW 512"

This is how I see it, notice the JU and JC and how they effect things.

edit in red
 
Last edited:
PS. Add these two commands as a first commands in this network. It should work better than the another solution as cottagewoods solution wont work all the time as the first jump in code is conditional and sometimes skips the MP value what you were after.

I erased notice of accu 1&2 in next networks.. Don't matter (see edit)


L
#Y_output_MP // Load you wanted measurement value to accu1 (accu2 is now previous accu1)
T "Your DB WORD" // Save your wanted measurement value to your DB Address

Edit. I first wrote that put these as last commands, but it's better to put these as first/above all else. They don't chance the way this network work if they are at first because accu1 and accu2 doesn't contain any usefull information when processor enters to this network.
 
Last edited:
I want to view the value that is sent to the output PQW512 on my SCADA. To do this I want to copy/send it to a data block address. But the value I want to view is actually whats in #Y_output_MP, that is 26.89 in the picture (means 26.9%).

Which value do you want - please clarify.
 
If you want the value that's sent to the PQW, then you would need to add a transfer AFTER or BEFORE the transfer to the PQW.

i.e

*R
RND+
T "PAW 512"
T YOURDB."YOUR DW"

or

*R
RND+
T YOURDB."YOUR DW"
T "PAW 512"


The other thing to look out for, is if you change the DB to a DB of your choice for storing the value, does the logic further down require the original DB to be recalled.
 
Sorry If I was not clear enough. I will try to tell you again:

I want to know (log in the SCADA) what set point we send to a valve that is controlled by PQW512.

But the set point from the process is in 0-100% (not sure about the range but it's in %) and I think that value comes from either #Y_OUTPUT_SR or #Y_output_MP because it matches what the set point was at the moment I took the print screen (26.9%).

So I guess I want to log the value that is multiplied with 2.764800e+002 without interrupting anything in the code (obviously). I say "guess" because I don't know why they multiply with 2.764800e+002. Do you have any idea of why? Is this a way to scale from % to a PQW?

It looks like cottagewoods code work, do you agree?


PeterW:
The code in the next network starts like this:
A #automatik_on
= "DB_STATUS_DRIVER".AUTO_ON_96
A "M 15.4"
= "DB_STATUS_DRIVER".SELECTET_96_2

So I don't think it will change anything to write to my new DB, because it writes to a specified DB with the symbolic name "DB_STATUS_DRIVER". Do you agree?
 
So I guess I want to log the value that is multiplied with 2.764800e+002 without interrupting anything in the code (obviously). I say "guess" because I don't know why they multiply with 2.764800e+002. Do you have any idea of why? Is this a way to scale from % to a PQW?
100 * 2.768e2 = 27680 -> 27680(=20mA/10V) is biggest integer value to analog output in S7-300/400 if my memory doesn't fool me.. I'm not sure, but this came to my mind and would explain the mathematics (there was some odd 25k+ limit IIRC).

If value to output PAW512is what you are after then PeterWs solution is right one and won't disturp any further processing ..IF your new DB address is in same DB as those #Y_OUTPUT_SR etc. IF NOT you need to open your new DB send the value to address you chose and open the old DB again.

If you are after the value in #Y_OUTPUT_SR or #Y_output_MP and it doesn't matter which address the value came from. Then cottagewoods solution work.

If you want the value from #Y_OUTPUT_SR or #Y_output_MP and you need to know which one is the source then use:

L #Y_OUTPUT_SR
T (Your address1 to save value)
JU END

WEIT: L #Y_output_MP
T (Your address2 to save value)
END: L 2.764800e+002
*R

My knowledge doesn't allow me to solve the problem any further, but I give you some questions if they help you to get grib to the subject.

Why is there that IF-true functionality XX_MP/XX_SP I don't know this. Atleast I would need more information of the process and program etc. to give even a good quess.

What does that 17.8.2004 made comment mean. My swedish ain't good enought or is that german?

What does Network13 do? Is there the key to solve what that IF-true functionality is doing in network14?

Do you understand how the DBXX system is working?

PS. Is the #automatik_on a DB address? If so then you need to be sure that the currently open DB is the original DB where the #automatik_on is bit address?? Again my knowledge is limited use manual. Link to manual :D
 
Last edited:
If you are after the value in #Y_OUTPUT_SR or #Y_output_MP and it doesn't matter which address the value came from. Then cottagewoods solution work.
This is the alternative that I want to do because I just want to know what set point we send to the output. But if you think adressing to DBs could destroy the rest of the code, then maybe I just should transfer to a Memory, like "MD 200" (the #SR and #MP is in REAL-format). I THINK it's possible to access the "Memory-bytes" from the SCADA and then I can skip the DB. And if that's not possible, then maybe i can just create a new FC and call on it somewhere and copy the MD 200 to a DB there instead.

But actually I don't see the problem addressing to different DBs. In this FB that this code is written in they are addressing to different DBs all the time, so why can't I do so?

An a little copy of the code before and after my network:

Code:
End of Network 12
M113: T     #Y_output_MP

      L     #Y_output_MP
      T     [B]DB95[/B].DBD    2

Network 13
      A     M      2.1
      JNB   _001
      CALL  FC    55
       DBPO:=DB168
       X   :=#Y_output_MP
       Y   :=#Y_OUTPUT_SR
_001: NOP   0


Network 14
      AN    #Modus_35bar_activ
      O     M      2.7
      JC    WEIT
      L     #Y_OUTPUT_SR
      JU    END

WEIT: L     #Y_output_MP
END:  L     2.764800e+002
      *R    
      RND+  
      T     PQW  512

Beginning of Network 15
 A     #automatik_on
      =     DB86.DBX   96.0
      A     M     15.4
      =     DB86.DBX   96.2
      A     #Y_MANUAL_activ
      O(    
      A     M     15.4
      AN    [B]DB86[/B].DBX   96.5
      AN    DB86.DBX   96.7
      )     
      =     DB86.DBX   96.3
      A     #PRESS_control_select
      =     DB86.DBX   96.4
      A     #PRESS_control_activ
      =     DB86.DBX   96.5
      A     #KW_control_select
      =     DB86.DBX   96.6
      A     #KW_control_activ
      =     DB86.DBX   96.7
      A     #EX_LIM_control_activ
      =     DB86.DBX   97.0
      A     M      5.0
      =     DB86.DBX   97.1
      A     M      5.1
      =     DB86.DBX   97.2
      A     #control_off
      =     DB86.DBX   97.3

// externer Controller

      A     M     15.0
      =     [B]DB95[/B].DBX    1.0
      =     [B]DB86[/B].DBX   97.4

      A     #Y_extern_activ
      =     DB95.DBX    1.1
      =     DB86.DBX   97.5
This was getting complicated now, I thought I had a clear solution at the first answer :)

Vartile:
The comment is in German and the same comment is in a lot of places in the program.

The #MP is a STAT and the #SR is TEMP in the Function Block program.
 
It's not complicated, the 1st answer was a clear solution, you said yourself you tested it and it worked, with respect, most of the followup post's haven't understood what your trying to do.
 
But actually I don't see the problem addressing to different DBs. In this FB that this code is written in they are addressing to different DBs all the time, so why can't I do so?
Text below next quote is valid if the S7 family uses the DB at same way than S5 family uses it (Edit. see picture) where you need to open each DB "file" before using byte/word/dword addresses inside it. (It have been years now when I last time really programmed S7 and cant remember for sure how it went in S7.)

edit PS. In S5 the opened DB (file/page how you want to call it) stays open even if you leave FB or network or jump to subroutine. Thats why it's critical to know which DB is open and when. This might have chanced in S7 to something more rational/easier to use, your FB seems like hebrew to me at this time of night and it seems I need to read the manual to get hold of the S7 addressing once again.

This is the alternative that I want to do because I just want to know what set point we send to the output. But if you think adressing to DBs could destroy the rest of the code
Nonono, I just tried to say that don't leave "new" DB open if you use different DB than the original in that program. It's easier to make sure that the original DB is open when programcycle leaves the network 14 than try to troubleshoot the PLC when it doesn't work just because "you left new DB open". It seems that the original program isn't calling the DB in the beginning of every networks so you need to be carefull when tinkering/tweaking to not leave "new" DBs open and that way crash the program. (this was the S7 vs. S5 part)



My second concern was that there is IF-THEN functionality on the network14 made with those jump commands and the two lines of bit-logic on the first two lines (which would need a bit simulation to get hold what they actually are doing). They might effect the result of PAW512 output as they chose the input address. This wasn't a big deal after all as If I have understood right it doesn't matter which one of those inputs are saved to another DB-address and later moved to HMI/SCADA.

Third was that it did look like you didn't know what you were after. :)

Sry if I have been misleading you.

S5_DB_handling_example.PNG
 
Last edited:
I don't know how it was in S5, but in S7 when a new DB is opened (used) either implicitly or explicitly, then the previous DB is automatically closed. So, as you've already noticed in the existing program, you can "jump" from one DB to another as much as you like - as long as you're using fully qualified addresses.

Where it gets a bit messier is if you use the "OPN DBxy" as in the S5 example above and then proceed to access Bits, Bytes etc. in this DB just using the "DBX1.2", "DBB22" addresses and somewhere in the middle access another DB, then the original DB "xy" is no longer open.
 

Similar Topics

Is it possible to Encode the data in 2D barcode and scan with the scanner to add in the stations? I need to write the logic in the RSlogix 5000...
Replies
8
Views
2,275
Hello everyone, First time posting here. I'm working on a CompactLogix (RSLogix 5000) program for a machine that inspects bottles. There is an...
Replies
5
Views
6,100
Hi, I have questions. I have Analog Input that need to put into Ignition Designer. But I don't know how to put?
Replies
1
Views
107
I have just installed Studio 5000 V30.11 on my Windows 11 Pro machine. First I had an "Invalid Pointer" error that required me to update Factory...
Replies
2
Views
113
Im trying to create a level indicator for water Tank i have used the ADD function while the pump is on and level increasing everything works...
Replies
33
Views
1,014
Back
Top Bottom