S7 fb to read in inputs and set outputs

JDCROCKETT724

Member
Join Date
Jun 2010
Location
Michigan
Posts
249
Greetings,

I am trying to write a FB where I can simply dictate a start address of an input as an IN parameter and a start address of an output as an OUT parameter. Then, inside the FB, copy the necessary block of input data starting at the input address to my static variables for use as the FB code. Finally write the data to the outputs starting at the output address.

If I were to use my AB know how with S7 terminology I would have code that looks like this:
IN: start_input_address INT
OUT: start_output_address INT

copy: Source- I[start_input_address]
Dest- DIB0
Length- 16

-----------FB code here------------

copy: Source- DIB16
Dest- DIB0Q[start_output_address]
Length- 16

Certainly, this is not how S7 works, but how would you pros approach this problem. I would like to assume this is a common FB task in S7.

My background is as an AB programmer and I have been handed a Step 7 V5.5 Project to write. I am trying to grasp how to do some things in S7 that seem a lot easier in AB. I know I have to try and separate the two, but this can be real frustrating :sick:. I have spent all morning reading and searching how to do this.
 
Is it supposed to be dynamic, or is it that fixed addresses that has to be transferred ?
And are you talking about physical inputs and outputs, or is it memory internal data transfer ?
 
Trusty Jesper. I have been learning a lot from your posts. Thanks for helping us all out.

My inputs and outputs are static.
For instance I want to use 8 words starting at 316 for inputs and 300 for outputs.
Then do this again with another function block with addresses 332 and 316. How do I use these numbers as an IN and OUT of my FB?

Thanks
-Jason
 
I could do it the hard way where I bring in every word or double one at a time as IN's, but this just wouldn't look professional. Plus it would be good to know how to do this in the event I have to bring in large blocks of input data.
 
What do the words contain - analogue signals or 16 bits of boolean or what? Given that you will have to access the variables by name from the stat section I don't see the advantage of copying them into stats over using 8 named inputs and outputs
 
The words contain a mix of bools, ints, and dints for control of a positioner. Position is a DINT, Speed is a Dint, Position width is an INT, and then there are several words that need to be broken down into bools.
 
.. so the named variables in the STAT section match the layout of inputs/outputs to/from the positioner.
 
Yes they do, and are broken down further into bools with symbolic meaning. Are you thinking I am making this more difficult than it should be?
 
I thought about making the function block and then copying with a blkmov all the inputs to into the a place holder in the static variables that I could then decode. Then after the FB copy a prepared block of static variables to my outputs, but this seems like rookie work.
 
What you are describing is correct - the block copy parameters require some processing to generate them.
 
Could I create two pointers as IN's for input_start_address and output_start_address, and then place the block copy instruction in the FB at the beginning an end?

I tried doing this but my pointer variable would not accept "P#I 316.0 BYTE 16"
 
Here's an example implementation for you to examine. I've used a UDT for the positioner structure and passed this to an FC to determine the size of it.
 
Is there document outlining the components of the any pointer and what they mean? Your code is helpful, but I am just trying to better understand it.
 

Similar Topics

Hello, I am trying to write a program to simulate an ISSC IPC90. The IPC90 has some internal variables, I think the correct name is 'internal...
Replies
7
Views
1,838
Hello I need to message read the entire 16 channel raw analog inputs from a 1769-L33ER Compact Logic controller to another 1769-L33ER Compact...
Replies
8
Views
258
I am working with a Siemens 1500 in portal, and I want to know if my Profinet inputs can change during the scan of the PLC code. When do local...
Replies
8
Views
2,799
Hi everybody Does anybody have experience with the Analog input card 1746-N18? Cannot get the last 4 inputs (4-7) to work like the first 4 (0-3)...
Replies
4
Views
2,984
Trying to read analog inputs from 1746-NI8 card, but values show 0 and channel status LEDs never come on. Details: - SLC 5/05, 1747-L551...
Replies
6
Views
2,948
Back
Top Bottom