MrPLC Member
  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About sdarella

  • Rank
    Hi, I am New!

Profile Information

  • Country United States
  1. Micrologix 1400 Timer

    I like your idea of using a main routine to call subroutines very much and I will try to apply that. Thank you so much for the example. I have been a little busy fixing a plethora of mistakes in my program (I was finally forced to properly reset DN bits). Thank you very much, Michael, the forums have been my main source of information regarding PLC programming.
  2. Micrologix 1400 Timer

    Many thanks, Michael :) When you say I'm forcing my program to be linear by jumping through hoops, you mean the fact that I'm using JSR, right? So I could for example use an OTE and toggle the input for next ladder from it? The reason why I did it this way is because I read some examples in a book and the author used JSR when going to another ladder, so I thought that was how we were supposed to do it.
  3. Micrologix 1400 Timer

    Hi, everyone, I started learning very recently, and I have been writing this little program in which I communicate through RS-232 with a machine. Every time I send a command from the PLC I wait a couple milliseconds for the machine to send a response (a response must always exist, even if it's a mere acknowledgement response), then I save the response that the machine has sent. I organized my ladder logic by the commands that the PLC has to send to the machine (4 commands total, for example: execute this, give me status on that, etc). I started every ladder with an OSR and an AWA instruction, and when AWA is done I have a timer in the next rung to wait for the machine response, and after timer I have a ABL activated when TON is done. The Ladders are related in the sense that the end of each LAD contains a JSR instruction to the next command/ladder. So the commands/ladder always execute in a predefined sequence (LAD2 -> LAD3 -> LAD4 -> LAD5). The logic inside each ladder is like this (the last rung is a little different for the others, this is LAD2): ] start [ ----------------------------------------- [ OSR ] ] OSR OUTPUT BIT [ -------------------- [ AWA ] ] AWA/DN [ ---------------------------------- [ TON ] ] TON/DN [ ----------------------------------- [ ABL ] ] ABL/FD [ ------------------------------------ [ ARL ] ] test if ARL string is 0 [ ----------------[ JSR ] 1) Since I have to use timers so often in my program (they all last for the same period of time) I wonder if I could use the same timer every time (same Control File R6). But I'm quite lost on WHEN I would have to reset the timer, or if this would not be recommended at all, since the timer is still counting for more than one scan. Although I want to believe that the timer for that Ladder would never be counting after the JSR instruction, I think this is true only for the first time since the next time I turn "start" ON the ARL is not zero, so JSR would occur while the timer is still counting. I tried resetting my timer parallel to JSR and using the same timer in the next ladder, but then the timer only counted up for the first time "start" goes ON (I believe because the timer was constantly being reset at every scan). 2) Also using OSR with AWA was the only way I found of making AWA and TON to "behave" (that is, to make AWA only go ON once per start and the timer to go ON every time AWA is DONE). Would there be a better way to do this or is this acceptable? When I tried connecting "start" to AWA directly the program just didn't behave the way I expected at all, I believe because AWA would always be enabled for more than one scan, although I cannot explain why this would be a problem since AWA should only execute from the transition false to true, no? 3) I never clear my buffers or reset my ASCII instructions... when I try to clear in parallel with JSR some of the ASCII instructions' bit ER goes ON, and when resetting my ASCII instructions sometimes I don't see any before/after difference, but oftentimes I just see an undesirable behavior, and to be honest I'm not even sure where in the code I should do it, so I wonder if I should bother. More specifically, in which situations should I care about doing it when writing a program, and where in the program is it recommended to do it? So far I don't seem to have a problem, so I'm being willingly ignorant about it Any suggestion regarding my code/logic is much appreciated! Thank you!