RSLogix 5000 – Structured Text Programming Examples

Hi,

I am Shane Welcher and I have put together a few helpful videos to show anyone willing to learn how to program using structured text an easy way to get a base foundation of how things work. I have over 10 years working with Rockwell Automation software which I have seen many different processes of when Rockwell changes their control platform in which I have found that is important to understand the core features of programming to give you the cutting edge of any change that happens.

If you have never done any structured text programming before, maybe you have the base understanding of how the different methods work such as a For Do, While Do, If, Else, Then, Case, or calling a JSR from a structured text program or routine. Understanding this language of RSLogix 5000 is only one of the four ways of programming of what Rockwell Automation offers of their software. RSLogix 5000 structured text is not like standard RSLogix 5000 instruction sets such as ladder logic or function blocks but can be used with any of the other programming types to make a system work better.

Also, a good resource to go to for is from the software developers for Rockwell but I will add that it is a lot of reading just to get the value that I show here but here is the link to Rockwell Automation Structured Text programming.

To cut straight to the chase, let’s get to the videos that I have made for you about structured text programming.

 


RSLogix 5000 Structured Text Example for…If..Then…Else..

In the video below shows one of the five structured text programming, this will be the using the If, Else, Then construct to give the foundation of how to get a base understanding. At the end of the video, I will give you a detailed reason of why I showed the system the way I did and believe me when I say if you want to see more then I will be glad to show you a more advanced method but this video is designed to give a base foundation.

In this video, I show the system being written on a Rslogix 5000 software with an emulation of the process. I chose to use a simple state transition to limit the confusion of the logic theory vs the actual If, Then, Else process which is the major point of the video. When it comes to logical theory, the sky s the limit…..If you can think it logically then you can program it.

I show the use of the watch feature of structured text programming to give you a troubleshooting tool in which to see the tags updating in real time as you are programming it or even if you have an existing machine using structured text.

An Example of this is:

If zzzSubstitute_Me Then zzzInstance_of:= 0;

If zzzSubstitute_Me Then zzzInstance_of:= 1;

If zzzSubstitute_Me Then zzzInstance_of:= 2;

If zzzSubstitute_Me Then zzzInstance_of:= 3;

If zzzSubstitute_Me Then zzzInstance_of:= 4;

If zzzSubstitute_Me Then zzzInstance_of:= 5;

If zzzSubstitute_Me Then zzzInstance_of:= 6;

End_If;

In this example, whatever the value of the zzzSubstitute_Me tag is then the value of the zzzInstance_of tag will change to the corresponding value of the statement.This is again, a very basic example of how this works to give you a base understanding of how the If, Then, Else construct works.


RSLogix 5000 Structured Text Example for a Case Construct

In the video below shows the Case construct, the effort is to give a solid foundation of how to get a base understanding. At the end of the video, there will be a description of what the common uses of a Case construct are done and as always….any question or concerns then please let me know.

After watching the video I want to break down what are some of the common reasons for using a Case construct of a structured text programming in RSlogix 5000. The Case construct is most commonly used for a simple and quick transition between state machine logic functions so with that being said if you have a case of an instance then the routine will quickly shift to whatever the case function is indicating to.

An example of this is:

Case zzzSubstitute_Me of

0: zzzInstance_of:=0;

1: zzzInstance_of:=10;

2: zzzInstance_of:=20;

3: zzzInstance_of:=30;

4: zzzInstance_of:=40;

5: zzzInstance_of:=50;

6: zzzInstance_of:=60;

7: zzzInstance_of:=70;

End_Case;

In this example, if the zzzSubstitute_Me has a value of 2 then the zzzInstance_of would be 20 but at any given time the zzzSubstitute_Me tag changes then the value of the zzzInstance_of tag. This is again, a very basic logic example of how a Case constructs and is meant to give you a base without causing confusion by adding complex logic added to the Case Logic example.


RSLogix 5000 Structured Text – While…Do Function

In the video below shows, the While Do construct, the video breaks down the structure of how a While Do construct should be logically laid out from what is accepted for the RSLogix 5000 software. At the end of the video, there will be a description of what I used for this example of a While Do construct….any question or concerns then please let me know.

After watching the video I want to break down the use of a While Do construct of a structured text programming in RSlogix 5000. The While Do construct can be used for many different applications and really depends on the preference of who is programming on what they are trying to accomplish so with that being said if you have a While Do instance then the routine will quickly shift to whatever the Do function that is indicating.

An example of this is:

While zzzSubstitute_Me_0 And Not zzzSubstitute_Me_1 Do
zzzInstance_of:=0:
Exit;
End_While;

While zzzSubstitute_Me_1 And Not zzzSubstitute_Me_2 Do
zzzInstance_of:=1:
Exit;
End_While;
While zzzSubstitute_Me_2 And Not zzzSubstitute_Me_3 Do
zzzInstance_of:=2:
Exit;
End_While;
While zzzSubstitute_Me_3 And Not zzzSubstitute_Me_4 Do
zzzInstance_of:=3:
Exit;
End_While;
While zzzSubstitute_Me_4 And Not zzzSubstitute_Me_5 Do
zzzInstance_of:=4:
Exit;
End_While;
While zzzSubstitute_Me_5 And Not zzzSubstitute_Me_6 Do
zzzInstance_of:=5:
Exit;
End_While;
While zzzSubstitute_Me_6 And Not zzzSubstitute_Me_0 Do
zzzInstance_of:=6:
Exit;
End_While;

In the example above, if the value of the tag zzzSubstitute_Me_3 transitions from 0 to 1 meaning it is made and the value of tag zzzSubstitute_Me_4 is a value of 0 and not a value of 1 then the value of the tag zzzInstance_of will equal a value of 3. In a While…Do function it is important to use the Exit command so that you do not eat up your processor time and bog down the system scan rate. This is again, a very basic example of how this works to give you a base understanding of how the While…Do construct works.

If you were to use this same code but replace the tags starting in zzz with your tags then you could run this simple model yourself.

Further explained down to the data type:

While Bool And Not Bool Do
Dint:=0:
Exit;
End_While;

While Bool And Not Bool Do
Dint:=1:
Exit;
End_While;

While Bool And Not Bool Do
Dint:=2:
Exit;
End_While;
While Bool And Not Bool Do
Dint:=3:
Exit;
End_While;
While Bool And Not Bool Do
Dint:=4:
Exit;
End_While;
While BoolAnd Not Bool Do
Dint:=5:
Exit;
End_While;
While Bool And Not Bool Do
Dint:=6:
Exit;
End_While;

Basically, I wanted to show what data types that can be used but not limited to so that you see what data types that are commonly used.


RSLogix 5000 Structured Text Array Use- For…Do…Example

Here is a video that I made to give a small example of a For…Do construct, this construct of structured text is more commonly used with an array with an indirect addressing scheme to solve system values in a very short piece of code. While this is not the most direct way to allow someone to troubleshoot, it does give the programmer a short and sweet way to get straight to the point with having to write a lot of structured text and in reference to RSLogix 5000 Structured Text array uses.

Plus learning indirect addressing is a very helpful piece, as it is used in a much different application of PLC programming.

So now that you have watched the video, I would like to address the simple but complex way of using the For…Do construct. Using this process has helped me make a cookie cutter system with a variability of a complex array indexed method of having an outcome very quickly and efficiently without having to write a lot of code.

 An example of this is:

If zzzStart Then
For zzzInstance_of:= 0 to 6 Do
zzzSubstitute_Me[zzzInstance_of]:= zzzSubstitute_Me[zzzInstance_of] + 1;
End_For;

If zzzSubstitute_Me[zzzInstance_of]> 6 Then
For zzzInstance_of:=0 to 6 Do
zzzSubstitute_Me[zzzInstance_of]:=0;
End_For;
End_If;

In this example, if the zzzStart value is equal to 1 then the array zzzInstance_of will index from 0 to 6 until it is greater than 6 then it will reset to a value of zero.

Further explained down to the data types:

If bool Then
For Array:= 0 to 6 Do
Array[Dint]:= Array[Dint] + 1;
End_For;

If Array[Dint]> 6 Then
For Dint:=0 to 6 Do
Array[Dint]:=0;
End_For;
End_If;

So if the bool is a value of 1 then the process starts. For array index 0 through 6 add a value of 1 to the array but if greater than 6 then set to a value of zero and continue the progress.


RSLogix 5000 Structured Text ST…JSR…ST…Timer Uses

This section shows the use of structured text for a JSR or jump to subroutine and a standard timer feature. This is a bonus to show several different methods that can be used in structured text programming so you do not feel limited to just using the natural constructs. You can also program a servo from not running to a fully running system which I can show if you would like but for this video, I have shown the basics of a JSR and a timer to save time.

 An example of this is:

JSR(zzzSubRoutine);
zzzTimer.Pre:=5000;
zzzTimer.TimerEnable:=zzzTimer_Control;
TONR(zzzTimer);
zzzTimer.Reset:= zzzTimer.dn;

In this example, the JSR is calling for zzzSubRoutine to be active or start scanning then set the zzzTimer preset to 5000 ms and if the zzzTimer_Control value is set to a 1 then free run the timer. Upon the timer timing, out then reset the timer and start the process over and continue running.


Summary of what has been used so far is a baseline of what can be used to be successful in using each of these constructs in RSLogix 5000 structured text programming.

I will be putting together more programming videos and article upon request, I already have several ideas and will be starting to add more videos to my YouTube channel which is Shane Welcher RSlogix 5000 Programming

 

Try my completely free Udemy course on structured text programming

I would love to hear what you guys think so far as I am trying to get this website whipped into shape.

Drop me a comment here or on my YouTube channel.

Thanks,

Shane

Copyrighted.com Registered & Protected NMM4-RR3R-ZMC7-17XE

RSLogix 5000 – Structured Text Programming Examples

Hi,

I am Shane Welcher and I have put together a few helpful videos to show anyone willing to learn how to program using structured text an easy way to get a base foundation of how things work. I have over 10 years working with Rockwell Automation software which I have seen many different processes of when Rockwell changes their control platform in which I have found that is important to understand the core features of programming to give you the cutting edge of any change that happens.

If you have never done any structured text programming before, maybe you have the base understanding of how the different methods work such as a For Do, While Do, If, Else, Then, Case, or calling a JSR from a structured text program or routine. Understanding this language of RSLogix 5000 is only one of the four ways of programming of what Rockwell Automation offers of their software. RSLogix 5000 structured text is not like standard RSLogix 5000 instruction sets such as ladder logic or function blocks but can be used with any of the other programming types to make a system work better.

Also, a good resource to go to for is from the software developers for Rockwell but I will add that it is a lot of reading just to get the value that I show here but here is the link to Rockwell Automation Structured Text programming.

To cut straight to the chase, let’s get to the videos that I have made for you about structured text programming.


RSLogix 5000 Structured Text Example for…If..Then…Else..

In the video below shows one of the five structured text programming, this will be the using the If, Else, Then construct to give the foundation of how to get a base understanding. At the end of the video, I will give you a detailed reason of why I showed the system the way I did and believe me when I say if you want to see more then I will be glad to show you a more advanced method but this video is designed to give a base foundation.

In this video, I show the system being written on a Rslogix 5000 software with an emulation of the process. I chose to use a simple state transition to limit the confusion of the logic theory vs the actual If, Then, Else  process which is the major point of the video. When it comes to logical theory, the sky s the limit…..If you can think it logically then you can program it.

I show the use of the watch feature of structured text programming to give you a troubleshooting tool in which to see the tags updating in real time as you are programming it or even if you have an existing machine using structured text.

An Example of this is:

If zzzSubstitute_Me Then zzzInstance_of:= 0;

If zzzSubstitute_Me Then zzzInstance_of:= 1;

If zzzSubstitute_Me Then zzzInstance_of:= 2;

If zzzSubstitute_Me Then zzzInstance_of:= 3;

If zzzSubstitute_Me Then zzzInstance_of:= 4;

If zzzSubstitute_Me Then zzzInstance_of:= 5;

If zzzSubstitute_Me Then zzzInstance_of:= 6;

End_If;

In this example, whatever the value of the zzzSubstitute_Me tag is then the value of the zzzInstance_of tag will change to the corresponding value of the statement.This is again, a very basic example of how this works to give you a base understanding of how the If, Then, Else construct works.


RSLogix 5000 Structured Text Example for a Case Construct

In the video below shows the Case construct, the effort is to give a solid foundation of how to get a base understanding. At the end of the video, there will be a description of what the common uses of a Case construct are done and as always….any question or concerns then please let me know.

After watching the video I want to break down what are some of the common reasons for using a Case construct of a structured text programming in RSlogix 5000. The Case construct is most commonly used for a simple and quick transition between state machine logic functions so with that being said if you have a case of an instance then the routine will quickly shift to whatever the case function is indicating to.

An example of this is:

Case zzzSubstitute_Me of

0: zzzInstance_of:=0;

1: zzzInstance_of:=10;

2: zzzInstance_of:=20;

3: zzzInstance_of:=30;

4: zzzInstance_of:=40;

5: zzzInstance_of:=50;

6: zzzInstance_of:=60;

7: zzzInstance_of:=70;

End_Case;

In this example, if the zzzSubstitute_Me has a value of 2 then the zzzInstance_of would be 20 but at any given time the zzzSubstitute_Me tag changes then the value of the zzzInstance_of tag. This is again, a very basic logic example of how a Case constructs and is meant to give you a base without causing confusion by adding complex logic added to the Case Logic example.


RSLogix 5000 Structured Text – While…Do Function

In the video below shows, the While Do construct, the video breaks down the structure of how a While Do construct should be logically laid out from what is accepted for the RSLogix 5000 software. At the end of the video, there will be a description of what I used for this example of a While Do construct….any question or concerns then please let me know.

After watching the video I want to break down the use of a While Do construct of a structured text programming in RSlogix 5000. The While Do construct can be used for many different applications and really depends on the preference of who is programming on what they are trying to accomplish so with that being said if you have a While Do instance then the routine will quickly shift to whatever the Do function that is indicating.

An example of this is:

While zzzSubstitute_Me_0 And Not zzzSubstitute_Me_1 Do
zzzInstance_of:=0:
Exit;
End_While;

While zzzSubstitute_Me_1 And Not zzzSubstitute_Me_2 Do
zzzInstance_of:=1:
Exit;
End_While;
While zzzSubstitute_Me_2 And Not zzzSubstitute_Me_3 Do
zzzInstance_of:=2:
Exit;
End_While;
While zzzSubstitute_Me_3 And Not zzzSubstitute_Me_4 Do
zzzInstance_of:=3:
Exit;
End_While;
While zzzSubstitute_Me_4 And Not zzzSubstitute_Me_5 Do
zzzInstance_of:=4:
Exit;
End_While;
While zzzSubstitute_Me_5 And Not zzzSubstitute_Me_6 Do
zzzInstance_of:=5:
Exit;
End_While;
While zzzSubstitute_Me_6 And Not zzzSubstitute_Me_0 Do
zzzInstance_of:=6:
Exit;
End_While;

In the example above, if the value of the tag zzzSubstitute_Me_3 transitions from 0 to 1 meaning it is made and the value of tag zzzSubstitute_Me_4 is a value of 0 and not a value of 1 then the value of the tag zzzInstance_of will equal a value of 3. In a While…Do function it is important to use the Exit command so that you do not eat up your processor time and bog down the system scan rate. This is again, a very basic example of how this works to give you a base understanding of how the While…Do construct works.

If you were to use this same code but replace the tags starting in zzz with your tags then you could run this simple model yourself.

Further explained down to the data type:

While Bool And Not Bool Do
Dint:=0:
Exit;
End_While;

While Bool And Not Bool Do
Dint:=1:
Exit;
End_While;

While Bool And Not Bool Do
Dint:=2:
Exit;
End_While;
While Bool And Not Bool Do
Dint:=3:
Exit;
End_While;
While Bool And Not Bool Do
Dint:=4:
Exit;
End_While;
While BoolAnd Not Bool Do
Dint:=5:
Exit;
End_While;
While Bool And Not Bool Do
Dint:=6:
Exit;
End_While;

Basically, I wanted to show what data types that can be used but not limited to so that you see what data types that are commonly used.


RSLogix 5000 Structured Text Array Use- For…Do…Example

Here is a video that I made to give a small example of a For…Do construct, this construct of structured text is more commonly used with an array with an indirect addressing scheme to solve system values in a very short piece of code. While this is not the most direct way to allow someone to troubleshoot, it does give the programmer a short and sweet way to get straight to the point with having to write a lot of structured text and in reference to RSLogix 5000 Structured Text array uses.

Plus learning indirect addressing is a very helpful piece, as it is used in a much different application of PLC programming.

So now that you have watched the video, I would like to address the simple but complex way of using the For…Do construct. Using this process has helped me make a cookie cutter system with a variability of a complex array indexed method of having an outcome very quickly and efficiently without having to write a lot of code.

 An example of this is:

If zzzStart Then
For zzzInstance_of:= 0 to 6 Do
zzzSubstitute_Me[zzzInstance_of]:= zzzSubstitute_Me[zzzInstance_of] + 1;
End_For;

If zzzSubstitute_Me[zzzInstance_of]> 6 Then
For zzzInstance_of:=0 to 6 Do
zzzSubstitute_Me[zzzInstance_of]:=0;
End_For;
End_If;

In this example, if the zzzStart value is equal to 1 then the array zzzInstance_of will index from 0 to 6 until it is greater than 6 then it will reset to a value of zero.

Further explained down to the data types:

If bool Then
For Array:= 0 to 6 Do
Array[Dint]:= Array[Dint] + 1;
End_For;

If Array[Dint]> 6 Then
For Dint:=0 to 6 Do
Array[Dint]:=0;
End_For;
End_If;

So if the bool is a value of 1 then the process starts. For array index 0 through 6 add a value of 1 to the array but if greater than 6 then set to a value of zero and continue the progress.


RSLogix 5000 Structured Text ST…JSR…ST…Timer Uses

This section shows the use of structured text for a JSR or jump to subroutine and a standard timer feature. This is a bonus to show several different methods that can be used in structured text programming so you do not feel limited to just using the natural constructs. You can also program a servo from not running to a fully running system which I can show if you would like but for this video, I have shown the basics of a JSR and a timer to save time.

 An example of this is:

JSR(zzzSubRoutine);
zzzTimer.Pre:=5000;
zzzTimer.TimerEnable:=zzzTimer_Control;
TONR(zzzTimer);
zzzTimer.Reset:= zzzTimer.dn;

In this example, the JSR is calling for zzzSubRoutine to be active or start scanning then set the zzzTimer preset to 5000 ms and if the zzzTimer_Control value is set to a 1 then free run the timer. Upon the timer timing, out then reset the timer and start the process over and continue running.


Summary of what has been used so far is a baseline of what can be used to be successful in using each of these constructs in RSLogix 5000 structured text programming.

I will be putting together more programming videos and article upon request, I already have several ideas and will be starting to add more videos to my YouTube channel which is Shane Welcher RSlogix 5000 Programming

Try my completely free Udemy course on structured text programming

I would love to hear what you guys think so far as I am trying to get this website whipped into shape.

Drop me a comment here or on my YouTube channel.

Thanks,

Shane

Copyrighted.com Registered & Protected NMM4-RR3R-ZMC7-17XE

Working with

Structured Text Contructs

Let OnlinePLCSupport.com

be Your Secret Weapon to Keeping up with Technology