iannicholson Posted April 8, 2016 Share Posted April 8, 2016 I'm using a range of P-variables to store positions (P800..899). I can issue the following online command to zero out all of the P-variables in the range: P800..899=0 This doesn't seem to work in PLC or motion programs, however (it gives a syntax error in PEWIN32Pro). I have tried the following instead: CMD"P800..899=0" This does not give a syntax error, but I'm not confident that it is having the intended effect (I have a customer running the code, so I don't have direct access to PMAC from my shop currently). Is this valid? I assume that I could write a While loop and incrementally write 0 to each variable, but this seems inefficient. What is the recommended method to write a single value to a large range of variables when in a PLC or motion program? Link to comment Share on other sites More sharing options...
steve.milici Posted April 11, 2016 Share Posted April 11, 2016 This is valid. You will need a one-time while loop to force the execution at that point as in the following: Cmd”P800..899=0” P900=1 While(P900=1) P900=0 Endwhile A Cmd”” is not executed until the end of this PLC’s current scan. The while loop acts as a “current scan”. Link to comment Share on other sites More sharing options...
bradp Posted April 11, 2016 Share Posted April 11, 2016 I would change this to be Cmd”P800..899=0” P899=1 While(P899=1) P899=0 Endwhile Link to comment Share on other sites More sharing options...
steve.milici Posted April 11, 2016 Share Posted April 11, 2016 Save a P-variable, save some electrons and promote global power reduction. Good work. Link to comment Share on other sites More sharing options...
iannicholson Posted April 11, 2016 Author Share Posted April 11, 2016 Great suggestion. And sarcasm ;) I was aware that some functions don't process until the next scan of the PLC, but I wasn't really sure which ones they were. This explains what might be going on here. Link to comment Share on other sites More sharing options...
Recommended Posts