Jump to content

cirocastro

Members
  • Posts

    2
  • Joined

  • Last visited

cirocastro's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. Hi Joe and Flex! Thanks a lot for sharing some of your knowledge! I want the machine to do 3 operations, i thought of doing something like: if input 1, call subroutine A; if input 2, call subroutine B, etc etc. In college we did something just like that, if HMI button 1 pressed, call this routine; if HMI button 2 pressed, call other subroutine... i thought it was a good way of keeping things organized it didn't worked though, i wrote on my final report i needed more time to debug and the teacher let me go with that So that's a bad idea then? So now i am thinking maybe subroutines should be used to make repetitive tasks easier to program, then? Now regarding Joe's reply: "a bit or a timer must be scanned one more time with a Logical FALSE statement in front if it in order to turn it back off" and: "If the the subroutine is not being called, everything in it is frozen in the state it was in when you left. Which means bits are left on and timers are not reset. " I am failing to see why my timer does not resets when the input toggles. Once the subroutine is called, the program is scanned inside the subroutine only, right? Then it will do a scan with my input active and timer decreasing, then a scan with my input inactive and stop decreasing the timer, then a scan again with the input active again; isn't this enough to reset it? Actually this is not really relevant to my application since i won't have timer conditions shifting so quickly, its just curiosity ? Is there any good books, or something like it, where i can learn all this tricks without disturbing the most experienced ones? I had PLC classes both in high school and in college and these kind of stuff never was told me before... thanks a lot again! Regards,
  2. Hi everyone! Need a little enlightenment in here... my project works fine if i write it in the "main routine," but then when i try to organize it and break into subroutines it stops working, so i am doing one step at a time to see where i'm messing thing up. What i found out is the following: if i am in the "main routine" and have T0 as a 5s timer, connected to an input, it behaves as expected: input on -> timer decreases from 5s -> timer reaches 0 -> T0 value=1 after it finishes counting: T0 value=1-> input off, then on again-> T0=0, current timer value resets to 5s-> timer decreases from 5s etc etc if i open the input before countdown finishes: input on-> timer decreases ->input off, then on again->current value resets to 5s and restarts countdown But then, when i have my input calling a subroutine, and the subroutine having the same input connected to the same 5s timer, what happens is: input on -> timer decreases from 5s -> timer reaches 0 -> T0 value=1 after it finishes counting: T0 value=1-> input off, then on again-> T0=1, current timer value DOES NOT resets to 5s-> timer gets stuck with T0=1 if i open the input before countdown finishes: input on-> timer decreases ->input off, then on again->current value DOES NOT resets to 5s and countdown resumes from where it stopped before input was turned off the return to main routine function is activated by the T0=1 condition, and the *&%#$#%@ part is that when it finishes counting and returns to main, and then my input calls the subroutine again, my timer is already set at 1, and the program bugs. Is this expected? Am i doing something wrong? Do i have to work differently when using subroutines? Hope someone can understand my issue description and can help me =P Thanks!
×
×
  • Create New...