Andrea Ascani

MrPLC Member
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Andrea Ascani

  • Rank
    Hi, I am New!

Profile Information

  • Country Italy
  1. sequences programming in ladder

    Thanks a lot guys, I probably found a good compromise beetween your suggestion and my needing. I created an enumerated structured, naming the steps as "start(0)", "verifyingConditions(10)", "preparingOperations(20)", and so on. Then I created a structure where I move a variable of this enumerated type from a state to another according to the specific conditions. In this way I can use the name of the enumrated structure to keep the code, and change just the enumerated definition if I want to add some intermediate steps (adding the name and shifting the enum values (ie add prePreparingOperations(20) and shift the others of 10 -> preparingOperations(30)). With this solution I can also create some FB to verify if the step is > or < of a state of the enumerated list (calling by name). That was for me the fundamental part. I just found that is not possible to use comparison functions (except for = and "<>") for enum variables (even if they are INT, after all), but I solved it using EnumToNum function.
  2. sequences programming in ladder

    Good morning guys, thanks a lot for your replies.   All those methods are interesting, but have a look at the simple state machine here represented from panic mode: If somewhere else I have a check on the state variable to identify the actual state of this logical part of the program, I will have something like IF STEP = 2 THEN, or IF STEP > 3 THEN... etc etc. How can I manage if I have to modify the state machine inserting a new state beetween step 1 and 2? the new step will become the number 2, and I have to shift all the others (2 to 3, and so on) and most of all SEARCH for all the references in the program to the old 2 state and replace with the new.. terrible to mantain. At the same time if I add the new state to an high value, I can't use anymore any control regarding the state > or < of a specific reference. I can define the status as 100, 200, etc and insert eventual middle states as 110, 120, 121, 122... but in long terms it could be always a problem. At the same time I could set some variable to identify a logical state indipendently of the state (ie, if I need to check if the state is <5, I can set a variable = 1 at the first state and = 0 at state 5, and then check the variable instead of the state. this solution is not bad, but basically why I have to introduce new variable (or variables, is possible that I have to introduce al lot of them) when I can use the state?  
  3. sequences programming in ladder

    Thanks a lot. ST as possible, but especially in this first months I have to integrate existing code, that is mostly in ladder (actually this functionality is purely in ladder, that's my question to restructure this trying to keep the other part of the software).    The state is a good idea. Another question : in my previous job, in C, I used to use defines to name the steps: #DEFINE RETRACTED 0 #DEFINE EXTENDED 10 #DEFINE RESET 20 In this way, I can keep the code more readable and most of all insert new phases just changing the defines.  And other things, I can create functions to understand where I am looking if the state is > or < of the "name" of the define.    There is something similar that I can use for? I found the Enum, but don't know if is the best option 
  4. Hi guys, I'm new in the forum and I'm quite new also in Sysmac programming, in ladder programming at all, to be honest.   I have some years of experience in programming CNC machines using C, on a owner platform. most of the functions I was using there were developed using "step sequences order". I mean, I had functions continuosly running where I was able to control the steps,  using the switch/case contstruct, and pass to a step to another just changing the reference variable. To be more clear, something like this:   functionStep = 0; switch (functionStep)   case 0:        if !(somethingToDoHereIsDone())                      break;       functionStep = 10;   case 10: .... and so on.   In the Sysmac programs I was able to see, something like this is possible to perform using register and AryShiftReg function. but I find it's quite complicated to manage if I want to insert intermediate steps in a second moment and most of all let an external part of the program to know in which "logical step" I am in my function.   Can you suggest me, in your experience, how can a sequencial function can be defined in Sysmac?   thanks a lot for your help.