Kiiza

S7 200 SEG INSTRUCTION

11 posts in this topic

Hello guys.

We are trying to replace a S7 200 PLC at our station with S7 1200.  We are reading the program on the S7 200 and recreating the same on the S7 1200. However, we have encountered the SEG  instruction used several times in the S7 200 (microwin) program. And the SEG instruction is not available in TIA Portal (we are using TIA 11) for the S7 1200. We have tried to read the s7 200 system manual but the explanation of the instruction is not sufficient to help recreate it.

Could anyone know how we can create our own equivalent of the SEG instruction?

If anyone has the SEG instruction already created as a program, it would be very helpful.

Thank you.

 

SEG1.PNG

Share this post


Link to post
Share on other sites

Hi guys,

I managed to get the instruction in STL; I have attached it in the Screenshot down. However, now the challenge is, I need to implement it in SCL since the later versions of TIA do not support STL any more.  If any one knows SCL and may help us to convert it, it would help us a lot.

Thank you.

CaptureSEG.PNG

Share this post


Link to post
Share on other sites

Analysis: the integer value stored in VB50 (decimal "1") is sent to the 7-segment display (QB5) when bits M0.3 AND M17.1 are both true (high, ON, 1). The 7-segment display must see segments b and c both equal 1; all other segments must equal 0.

The S7-200 manual (p325) shows the relationship between the integer value to be displayed and the corresponding segments that must be ON for the correct value to be seen on the 7-segment display. The 7 segments are ordered from "a" to "-", with segment "a" being the LSB of the byte and "-" being the MSB of the byte.

In the network example you provided, only integers 1, 2, 3, 4, and 0 are displayed on the 7-segment display. These integer values can be directly converted to a decimal value that will turn on the corresponding segments of the 7-segment display. The resulting code is shown below. It is a direct replacement of your network 76 without inventing a module to act as the "SEG" instruction. Nice, quick, simple, and easy. Just what the doctor ordered! :)

Edit 18 June 2019: The absence of the "SEG" instruction for the 12## series CPUs is not due to the TIA Portal programming software. Rather it is because of the CPU (hardware) you are working with. The "SEG" instruction is available in TIA Portal when working with 15## and 3## series CPUs. I suspect the instruction is also available for the 4## series CPUs but I cannot confirm this because I don't have any current projects in TIA Portal that use this series of hardware.  The TIA Portal software only allows access to instructions compatible with the hardware you are programming.

 

MrPLC FC001.png

Edited by pop29684
Additional information about TIA Portal instructions

Share this post


Link to post
Share on other sites
On 6/17/2019 at 0:59 AM, pop29684 said:

Analysis: the integer value stored in VB50 (decimal "1") is sent to the 7-segment display (QB5) when bits M0.3 AND M17.1 are both true (high, ON, 1). The 7-segment display must see segments b and c both equal 1; all other segments must equal 0.

The S7-200 manual (p325) shows the relationship between the integer value to be displayed and the corresponding segments that must be ON for the correct value to be seen on the 7-segment display. The 7 segments are ordered from "a" to "-", with segment "a" being the LSB of the byte and "-" being the MSB of the byte.

In the network example you provided, only integers 1, 2, 3, 4, and 0 are displayed on the 7-segment display. These integer values can be directly converted to a decimal value that will turn on the corresponding segments of the 7-segment display. The resulting code is shown below. It is a direct replacement of your network 76 without inventing a module to act as the "SEG" instruction. Nice, quick, simple, and easy. Just what the doctor ordered! :)

Edit 18 June 2019: The absence of the "SEG" instruction for the 12## series CPUs is not due to the TIA Portal programming software. Rather it is because of the CPU (hardware) you are working with. The "SEG" instruction is available in TIA Portal when working with 15## and 3## series CPUs. I suspect the instruction is also available for the 4## series CPUs but I cannot confirm this because I don't have any current projects in TIA Portal that use this series of hardware.  The TIA Portal software only allows access to instructions compatible with the hardware you are programming.

 

MrPLC FC001.png

This is really easy and very helpful.

Thank you very much.

Share this post


Link to post
Share on other sites

Hi pop29684,

Moving those figures into the bytes worked well. However, it worked for me when I knew what digit I wanted to display on the 7-segment. In instances where I can't be sure which digit will be displayed at a particular time, I am still struggling. The STL code I had shared earlier, I got help to convert it into SCL code and it worked. The only problem is it gives me a double word output but that is a lot more bits than I need since my display areas are only bytes. And I can't easily tell which byte to extract from the double word. If you may know another way, please advise.

Thank you.

Share this post


Link to post
Share on other sites

Thank you.

I will read the Easy Book and see what I can find in there. 

The problem with converting from DWord to Byte is you lose the data contained in the other three Bytes. And you may not be sure if the correct information needed stays in the remaining Byte or is lost in the other three.

Share this post


Link to post
Share on other sites

Why would there be any data in the other three bytes? The logic only requires one byte to hold the necessary segment map, correct? Is your calculated result being expressed as a signed integer in a DWord?

Share this post


Link to post
Share on other sites

The calculated result is just a DWord. The Dword has 4 bytes (2 words). When I check the DWord, I see all the 4 bytes contain information. And the information in the 4 bytes is not necessarily the same.

Share this post


Link to post
Share on other sites
On 12/9/2020 at 0:14 AM, Kiiza said:

The calculated result is just a DWord. The Dword has 4 bytes (2 words). When I check the DWord, I see all the 4 bytes contain information. And the information in the 4 bytes is not necessarily the same.

I understand the structure of the DWord very well. What I don't understand is why the SCL code (which has not been posted) is generating data in all four bytes of the DWord. A single integer converted to a 7-segment map by the SEG instruction only requires one byte of data - not four. I am suspicious of the SCL code.

Your STL and SCL conversions are not necessary. I explained that in my very first reply:

On 6/17/2019 at 5:59 PM, pop29684 said:

The S7-200 manual (p325) shows the relationship between the integer value to be displayed and the corresponding segments that must be ON for the correct value to be seen on the 7-segment display. The 7 segments are ordered from "a" to "-", with segment "a" being the LSB of the byte and "-" being the MSB of the byte.

If you study the S7-200 manual (p325) you will be able to see how the 7-segment display is mapped into a byte value. I gave you the 7-segment map values (6, 91, 79, 54) for the digits (1, 2, 3, 4, 0 respectively) from the code you posted. If you need to map other digits (5, 6, 7, 8, 9) then use the information provided in the manual to do this. You will also need to develop logic that will turn those additional integers on and off. That is the function of the markers M17.0 - M17.4. Additional digits will require additional markers.

There is no problem using the STL/SCL code other than it reduces the efficiency of your code because it introduces something that is entirely unnecessary.

Compare this:

On 6/10/2019 at 2:08 AM, Kiiza said:

 

SEG1.PNG

with this:

On 6/17/2019 at 5:59 PM, pop29684 said:

MrPLC FC001.png

The efficiency is immediately obvious. The need for VB50 - VB54 is eliminated. The need for the repetitive call of the SEG instruction is eliminated.

True, the SEG instruction will conveniently convert a digit on the fly to a segment map but at the expense of, arguably insignificant, longer scan times and more memory usage. Manually mapping the segment values will reap the benefit of using less code, having less module calls - all of which translates to saving a little scan time and memory. But perhaps this is not important in the project with which you are working. Or perhaps you are determined to understand the operation of the STL/SCL code. Or maybe you want to build your own SEG module that, when called, takes the single digit integer and gives the appropriate 7-segment map value.

As far as the DWord contents, if you know the 7-segment map value that you expect in the byte, then it is a simple matter to compare that value to the values in the four bytes of the DWord. Then you know exactly which byte contains the data you need.

Good luck, my friend!

Share this post


Link to post
Share on other sites

Thank you. You have been very helpful.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now