PLC Sample Code

Sign in to follow this  
Followers 0

Simatic, Step 7, ATS-S5, etc...

18 files

  1. FC3 Counter Demo

    This logic demonstrates the construction and cascading of counters that count from 0 to 9. This logic also illustrates the construction of counters that count from 1 to 10 (not useful for cascading). The difference is mainly in the comparators used to reset the counters. There is one small additional detail. Can you find it?

    135 downloads

    Submitted

  2. FC2 Toggle a bit

    This logic demonstrates how to use a condition to toggle a bit. Any bit-level condition may be used such as I, O, M, C, T, DB. Only two rungs of logic are required.

    114 downloads

    Submitted

  3. FC1 Two hand anti tie down

    Logic takes two inputs (I0.0, I0.1), debounces each (T0, T1), looks for actuation during a timed period (T2), and provides validation (M20.0). This logic is not designed, nor intended, to replace the use of any OSHA required two-hand safety control relay. It is provided for the sole purpose of it's educational value.

    91 downloads

    Submitted

  4. Range_Fnc

    I sometimes need to scale an analog value, so I had to do a function to better suit my needs than Siemes "Scale" function.
    It has 5 inputs, all in integer format.
    _In - The value to be scaled
    _In_Min - Lowest value of the "_In" signal.
    _In_Max - Highest value of the "_In" signal.
    _Out_Min - Lowest allowed value of the scaled output.
    _Out_Max - Highest allowed value of the scaled output.
    The output "_Out" is the calculated value in integer format.
    Edit.
    It's saved as a global library.
    TIA Portal V13 SP1 Upd. 4

    225 downloads

    Updated

  5. Solve system whit Gauss-Jordan

    In the matrix A [ i , j ] put the System of N-Equation.
    In the vector b put the solutions
    §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
    Example 1: Linear System 3 equation (X,Y,Z)
    3 X + 2 Y - Z = 10
    - X + Y + Z = -2
    2 X - Y + 2 Z = -6
    | 3 | | 2 | | -1 | | 10 |
    X | -1 | + Y | 1 | + Z | 1 | = | -2 |
    | 2 | | -1 | | 2 | | -6 |
    Matrix A :=
    Matrix[1,1]= 3 ; Matrix[1,2]= 2 ; Matrix[1,3]= -1
    Matrix[2,1]= -1 ; Matrix[2,2]= 1 ; Matrix[2,3]= -2
    Matrix[3,1]= 2 ; Matrix[3,2]= -1 ; Matrix[3,3]= -6
    Vector b:=
    Vector[1] =10 ; Vector[2] = -2 ; Vector[3] = -6 ;
    Solution :=
    Solution [1] := 1.0 ; Solution [2] := 2.0 ; Solution [3] := -3.0 ;
    X = 1 ; Y = 2 ; Z = -3
    §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
    Example 2: Linear System 5 equation for resolve Polynomial 4th grade
    exampl. Polynomial whit 5 points:
    P0(-1,-1) ;
    P1( 1, 3) ;
    P2( 5, 3.5) ;
    P3( 6, 4.5) ;
    P4( 7, 7) ;
    Write in the Matrix A [ i, j ]
    Matrix A :=
    Matrix[1,1]= (-1)^4 ; Matrix[1,2]= (-1)^3 ; Matrix[1,3]= (-1)^2 ; Matrix[1,4]= (-1) ; Matrix[1,5]=1;
    Matrix[2,1]= (1)^4 ; Matrix[2,2]= (1)^3 ; Matrix[2,3]= (1)^2 ; Matrix[2,4]= (1) ; Matrix[2,5]=1;
    Matrix[3,1]= (5)^4 ; Matrix[3,2]= (5)^3 ; Matrix[3,3]= (5)^2 ; Matrix[3,4]= (5) ; Matrix[3,5]=1;
    Matrix[4,1]= (6)^4 ; Matrix[4,2]= (6)^3 ; Matrix[4,3]= (6)^2 ; Matrix[4,4]= (6) ; Matrix[4,5]=1;
    Matrix[5,1]= (7)^4 ; Matrix[5,2]= (7)^3 ; Matrix[5,3]= (7)^2 ; Matrix[5,4]= (7) ; Matrix[5,5]=1;
    Write in the Vector [ ]
    Vector b:=
    Vector[1] = -1 ; Vector[2] = 3 ; Vector[3] = 3.5 ; Vector[4] = 4.5 ; Vector[5] = 7
    Solutions :=
    Solution [1] := 3.27380234e-003 ; Solution [2] := 0.03363105;
    Solution [3] := -0.56577414 ; Solution [4] := 1.966369 ;
    Solution [5] := 1.5625005
    §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
    Example 3: Linear System 6 equation for resolve Polynomial 5th grade
    example. Mototion Interpolation whit Polynomial
    whit 2 Points :
    P0 (Time0, Position 0) Start point whit (Velocity 0, Acceleration 0)
    P1 (Time1, Position 1) End point whit (Velocity 1, Acceleration 1)
    Write in the Matrix A [ i, j ]
    Matrix A :=
    X0 = time0 ; X1 = time1
    Row1 X0 ^5 + X0 ^4 + X0 ^3 + X0 ^2 + X0 + 1 (Position P0)
    Row2 5 * X0 ^4 + 4 * X0 ^3 + 3 * X0 ^2 + 2 * X0 + 1 + 0 (Velocity P0)
    Row3 20 * X0 ^3 + 12 * X0 ^2 + 6 * X0 + 2 + 0 + 0 (Acceleration P0)
    Row4 X1 ^5 + X1 ^4 + X1 ^3 + X1 ^2 + X1 + 1 (Position P1)
    Row5 5 * X1 ^4 + 4 * X1 ^3 + 3 * X1 ^2 + 2 * X1 + 1 + 0 (Velocity P1)
    Row6 20 * X1 ^3 + 12 * X1 ^2 + 6 * X1 + 2 + 0 + 0 (Acceleration P1)
    Vector b:=
    Vector[1] = Position P0 ; Vector[2] = Velocity P0 ; Vector[3] = Acceleration P0 ;
    Vector[4] = Position P1 ; Vector[5] = Velocity P1 ; Vector[6] = Acceleration P1 ;
    Interpolation Polynomial Position :=
    Position := s1* t^5 + s2* t^4 +s3* t^3 + s4* t^2 + s5* t + s6;

    3242 downloads

    Updated

  6. counters and Accumulators

    Counter/Accumulator examples

    6633 downloads

    Updated

  7. S7-200 Tips & Tricks Complete 8/2003

    Complete archive of Tips and Tricks for S7-200

    34928 downloads

    Updated

  8. PDF: String Parsing

    Sample code for Parsing Strings - in this case taking incoming comma separated variable strings and breaking them apart.

    4499 downloads

    Updated

  9. PDF: Traffic light.

    Traffic light.
    No usage of "reusable code".
    Just plain classical PLC programming printed in LAD (ladder)

    13825 downloads

    Updated

  10. PDF: Reusable code with FBs.

    Example of how to create reusable code by means of Function Blocks and the associated Instance DBs.<br /><br />Note that it has been printed in LAD (ladder). <br />Some code cannot be viewed in LAD which is why it defaults to STL (statement list).

    5708 downloads

    Updated

  11. modified traffic lights

    This program is a little modified version of the earlier traffic code. This program also has the comments added which was missing in the earlier version.

    6427 downloads

    Updated

  12. Dip paint

    This is a simple program to paint an object while the object is transferred from Station A to station C. The painting occurs in station B where the object to be painted is stopped and dipped in paint and the moves further to C. From C the transport system comes back to A without stopping on its return path at B.
    If you have any doubts or suggestions please feel free to contact me .

    3089 downloads

    Updated

  13. drill machine

    This is a simple program where the drill arm moves down for the drill and the Drill motor starts as well. The drill arm stops after reaching the bottom level but the drill motor continues for a few seconds to ensure a good drill and then stops. Now the Drill arm moves up again and then reaches the top position and starts the cycle again.It is aslo ensured that the Drill arm is always at the top before the operation starts or if the drill operation is stopped in midway.
    If you have any doubts or suggestions please feel free to comment.

    6995 downloads

    Updated

  14. Remanent On-delayTimer for S7-300/400

    Remanent On-delay Timer for Siemens S7 300/400
    -The attached FC makes standard PLC timers
    remanent.
    -The timers are started stopped and reset via
    digital inputs.
    -The the remaining time can be monitored in the
    program.

    5956 downloads

    Updated

  15. Daylight Savings Time for S7-200

    This is a quick sample program to demonstrate how to make the PLC adjust the clock for daylight savings time automatically. It's done with an S7-200 but the logic sould be similar for any PLC from any vendor.
    Written with Step 7-MicroWIN/32

    5082 downloads

    Updated

  16. Analog Average

    This file for Siemens 200 PLCs will create a rolling average of the last 100 scans worth of an analog input.

    7385 downloads

    Updated

  17. Splicer Example Program

    Control program for a web splicer.

    9811 downloads

    Updated

  18. Knife Example Program

    Cut off knife example program. Uses Profibus communication and indirect addressing examples.

    11479 downloads

    Updated

Sign in to follow this  
Followers 0