Cyclic program operation in s7-300

mhmtfthnl

Member
Join Date
Nov 2003
Location
everywhere I can go
Posts
42
Hi all.I have a question about s7-300 programming.I have written a program in s7-300.But I want to execute the same program again and again when I push to any button that I defined beforehand (program will be started by pushing a button).I am wondering how I can program this function.Namely what program material must I add. (for example label,jump...)In addition, can I do that in the ladder logic.
thank you
best regards
 
You can of course do this in ladder logic. for a pre-defined small sequence perhaps you wish to use a function/fuction block for a particular event to occur. either way your "Logic" will dictate what occurs when the button is pressed via sets/resets/outputs/bit logic.

Define your process,
have a crack at it yourself,
post your problems here !!!!!!!
 
I have written a simple sample program and sent it that is attached for you.How can I execute this program again and again when I push to I0.0

Thanks for help
Best regards :cool:
 
I believe you have your program in a function then in that case just go to OB1 and call the function from there as follows.
call FC1 //this is for a function called FC1
The program would be as follows
A IB 0 // this would only be for the first input byte
// do whatever you want in the program for example output it to byte 0
=QB 4.0
 
Put this in OB1

NETWORK 1

A I 0.0 // Here is your START button
AN M 0.0 // If you want to make a 1 shot, ADD this
JC FC 1 // Your Program


NETWORK 2

A I 0.0 // If you use the 1 shot, ADD this
= M 0.0 // If you use the 1 shot, ADD this
 
Hi. I have tried both of ways that you suggested me.But I could not manage it.Therefore I am sending my sample program in attached file.
In addition ,is specified fc1 function or label.If it is a label,where should I define it.

program.jpg
 
I think there has been a misunderstanding.

What I think is wanted is a means of keeping track of state. This means latching the input and clearing the previous latched input.


Code:
      A I0.0      // Check input for program 1
      S M0.0      // Set the State bit
      R M0.1      // Clear the previous states.
      R M0.2
      R M0.3

      A I0.1      // Check input for program 2
      R M0.0
      S M0.1
      R M0.2
      R M0.3

      A I0.2      // Check input for program 3
      R M0.0
      R M0.1
      S M0.2
      R M0.3

      A IO.3      // Check input for program 4
      R M0.0
      R M0.1
      R M0.2
      S M0.3

// Program one

PRG1: A M0.0         // PROGRAM ONE
      JNC END1
                     // PROGRAM ONE GOES HERE
END1:

PRG2: A M0.1         // PROGRAM TWO
      JNC END2


END2:

PRG3: A M0.2         // PROGRAM THREE
      JNC3

END3:

PRG4: A M0.3         // PROGAM FOUR
      JNC END4
      
END4:

      END

This is a brute force way of doing this.

I would use the inputs to set a byte value called State. State can only hold value from 0 to 255 and should not be allowed to change unless a new buttons is pressed. I would then use the JL instruction to jump directly to the correct part of the program rather than scan the whole program to see if it is run.


Code:
        A   I0.0
        JNC E0
        L   0
        T   State
E0:

        A   I0.1
        JNC E1
        L   1
        T   State
E1:

        A   I0.2
        JNC E2
        L   2
        T   State
E2:

        A   I0.3
        JNC E3
        L   3
        T   State
E3:

        L   State         // LOAD THHE PROGRAM NUMBER
        JL  LAST          // JUMP DISTRIBUTOR
        JU  PRG1          // LIST OF DESTINATIONS
        JU  PRG2
        JU  PRG3
        JU  PRG4
LAST:   JU  END4

PRG1:                    // PROGRAM ONE
        JU  END4         // JUMP PAST THE PROGRAMS

PRG2:                    // PROGRAM TWO
        JU  END4         // JUMP PAST THE PROGRAMS

PRG3:                    // PROGRAM THREE
        JU  END4         // JUMP PAST THE PROGRAMS

PRG4:                    // PROGAM FOUR


END4:

See the example in the STL on-line help.

To get a set of inputs converted to a number that the JL instruction could use I woud use my ENC FC described in a previous thread.
 

Similar Topics

We are to develop a first application in Codesys. It will contain motion (Softmotion) with drives on Ethercat (CSP mode). Off course there will be...
Replies
2
Views
897
Hello to all, I know there are a few people here very experienced with Codesys. I wonder does Codesys have something similar to OB35 in STEP7...
Replies
3
Views
610
Hi, When I use an interrupt OB (let's say OB38 which is processed every 10ms), does it read the state of the inputs at the time it is called, or...
Replies
18
Views
2,357
Hi all, I converted a project from MW+ Express to MW+ Pro, for the benefit of more percise control over the performance of different parts in...
Replies
5
Views
1,861
I'm working with Beckoff Twincat 3 or in Codesys with ABB PLC. My cyclic time inside task configuration is always fixed. M question is can it be...
Replies
0
Views
1,028
Back
Top Bottom