Do you have a machine that you need to get data from? And do you need to send that data to another device but the machine lacks networking capabilities?

In this article I'll show how to get data a your machine into a Siemens S7-1214C PLC by using the machine's existing outputs to select which data the PLC will make available over your network.

Step 1)

In this example we have four outputs on our machine that tells us which product is being made.

These will be wired into our PLC as inputs, and therefore we need to add them to our PLC's tag table:

Image By Chris Wright

Step 2)

Now that we've added our Input Tags, we'll next add a new Function Block to the program named “Part Reference”:

Image By Chris Wright

Step 3)

In this step we will add the data to the FB that will be used to “select” the part number of the product being made.

‘Programs' in the static section needs “Retain” to be “Set in IDB.” “Programs” is an Array 0…15 with a max string length of 15:

Image By Chris Wright

Step 4)

Now we will add the first Logic to the FB. The Inputs will write to the first 4 Bits of the Byte “Input Code,” and are addressed as #”Input Code”.%X0  thru %X3 as shown below:

Image By Chris Wright

Step 5)

Next, we'll add an “SCL Network” to the Function Block.

This logic will convert the Byte to Int, and then select the part number based on the inputs.

It will also display the Part Number that was selected, and if no part is selected the output will display ‘No Part':

Image By Chris Wright

Step 6)

Now we need to add the “Part Reference” FB1 to the OB1 Main Routine. This will create an “Instance Data Block” (IDB).

Add “Part Number” to “Temp” in OB1, then add the four Inputs from the Tag Table to the Input side of Function Block, and finally add “Part Number” to the Output side of the Function Block:

Image By Chris Wright

Step 7)

Now create a watch table and name it ‘Part Numbers'. This table will have 1 to 15 part numbers, and the data will be written to it by “Programs” in the Function Block:

Image By Chris Wright

Step 8)

Compile and load program to PLC, then go online and add the “Part Numbers” to table and write to DB:

Image By Chris Wright

Testing:

Now let's test the logic to make sure it is working correctly.

You can see that with no input the Part Reference output is displaying ‘No Part:

Image By Chris Wright

And with Input 1 on (aka high, binary 0001,) the Output is now displaying the first part number in our Part Number table:

Image By Chris Wright

With all Inputs on (aka all high, binary 1111,) the output is now displaying Program Fifteen from the Part Number table:

Image By Chris Wright

Here we can see the Inputs and how the correlate with the byte ‘Input Code’:

Image By Chris Wright

Conclusion

The above method is a good way to get part number or other information from a machine where you must use the PLC inputs to select the information using binary.

This can be used to interface with machines that do not have any industrial networking (Ethernet/Profinet/Profibus) capabilities.

Written by Chris Wright
Process/Controls Engineer and Freelance Writer

Have a news tip? Share it with us here.
Have a question on this topic? Click here to scroll down to the comment link
Enjoy the benifits of membership! Insider news, rewards, & more: Patreon.com/automation

Chris Wright


Click HERE to scroll down to view or leave comments


Leave A Blog Reply Here

Please enter your blog comment!
Please enter your name here