Sign in to follow this  
Followers 0
Guest hinero

Using "for" and "next"

4 posts in this topic

I am new to plc programming and have a fx1s plc and what I am trying to do is to have the plc repeat a sequence of valves energizing on/off The number of times it repeats will be dependent on what position a selector switch is turmed to. I have multiple timings established by switch position already figured out but cannot get the cycle to repeat. I belive I need to use "for" and "next" but cannot get those to work Can anyone help

Share this post


Link to post
Share on other sites
Well coming, good attitude in ask in this forum. I expect that acquire the habit that think and question before of do, is the necessary quality to all programmer, like this will trust in itself even. The function FOR/NEXT, is not advised utilize in the control, private I utilize for handling of facts, information, comparison of facts and ordering, rarely in the command of actions. Because!? It can freeze the program, if pass from the team of WatchDog and does not accept timers internal. I understood: That several set in motion valves, by a interval and duration defined by a selector. . Adequate solutions: 01-It utilize a sequenciator, where a Timer 1 triger a counter, and the acumulator of the counter will be the index of the sequenciator. Before of reset the Timer 1, is able to set in motion the Timer 2 that defined a pause. In the Mitsubishi, the instruction sequenciator is Master Control (MC and MCR) metod binary: Utilize timers that trigger/ command the instrution main, cited to short. 02-Mathematical operations: Utilize intrutions of sum or multiplication. And move the result for the start of a Byte in the area of memory of contacts (M0,M8...) And it utilize associate or combine the M respective, to command the outputs. 03-Operations of movement: Utilize the functions of Shift (FNC-34-35)ou rotate (FNC 32-33) and associate or combine the M respective for commads the outputs. As it utilize the FX0, only the 01 is applied, the too they are you applied in complex or flexible situations that have configurations, or dynamic with change of sequence. Good results and practical .

Share this post


Link to post
Share on other sites
What Macgyver BR is saying is that you won't always see any affect from a For/Next loop in your external outputs. The loop operates internally but the outputs only get updated at the end of the scan. So, no matter how many times you loop through some logic inside your program, its the final condition when the END statement is reached that is passed to your outputs. If you wanted to, for example, increment something repeatedly in a For/Next loop, your final value would be there at the end of the scan, just like you'd expect. On the other hand, turning an output on and off a thousand times, inside of a single scan, makes no difference since only the final condition matters. The other problem, as Macgyver BR mentioned, is that the watchdog timer will time out if your scan lasts too long. This can happen if you spend too much time in things like For/Next loops but you really have to go nuts before its a problem. However, if you are expecting other types of timers to change values while inside of a loop, you'll wait forever since they are only updated at the end of the scan (like most things). The point he was making was that you don't try and complete a process in one scan. You monitor it over the course of many scans (usually thousands). A single scan should only last a few milliseconds. Myself, I only rarely find any use of For/Next loops in plc programming. Perhaps you could describe the project in more detail. Jim Rowell

Share this post


Link to post
Share on other sites
Thank you for your response. I did use the counter function, what I did was assign "mov"a number for "D1" dependent upon the selector switch location. This value stood for the number of times a counter would be hit, when the counter reached its value a reset was issued and the program stopped. Thank you very much, I couldn't have done it without your help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0