Best programming practices

I have many small snippets of code from one of our integrator projects that contains multiple bits called "do_not_forget". I guess he forgot!

lol, I'm looking at a program right now where the comment on the contact is labeled "MUST DEAL WITH THIS LOGIC!!!".
 
one example:



--| |---|---------|\|------- ons---------( )
--| |---|
--| |---|

versus

--| |--ons-|---------|\|------- ---------( )
--| |--ons-|
--| |--ons-|




That example makes sense when you should use multiple one shots, but what about this:


---| |-----| |-----[ons]----------------------( )



It could be a case where you only want to deal with something when the machine is running and a sensor turns on. If the sensor turns on and the machine is already running then this creates an edge, or if the sensor is already on when the machine is running this creates an edge (the may be a desired effect). Why would this be an incorrect use of a ONS?

Regards
Ian
 
That example makes sense when you should use multiple one shots, but what about this:


---| |-----| |-----[ons]----------------------( )



It could be a case where you only want to deal with something when the machine is running and a sensor turns on. If the sensor turns on and the machine is already running then this creates an edge, or if the sensor is already on when the machine is running this creates an edge (the may be a desired effect). Why would this be an incorrect use of a ONS?

Regards
Ian

Yes, this could be fine. Just remember to think of the off state.
If the sensor is on and the machine stops running and then starts running, then make sure you also want that edge as well.
 
Latch/unlatch - with great power comes great responsibility. Don't use it as as a lazy way of doing state machine or sequence then you end up with a very confused program where one can be in multiple conflicting states. <yes, I'm in the middle of of fixing one>
 
Never download some final changes 5 minutes before you have to leave...
 
for sequencers use integer number for step state instead of several flipflop bits, it is easier to read and troubleshoot.
 

Similar Topics

I've been doing PLC programming for about 15 years now but all of my experience has been with Allen-Bradley PLC's. A few months ago I started a...
Replies
5
Views
3,203
Hi All - I have a system that I am setting up with about 50 axes of motion. There are 10 stations total where 9 of them are exactly the same. I...
Replies
0
Views
1,388
If I have a program that requires 10 different PID loops should I 10 different period tasks (using RSLogix5000)?
Replies
4
Views
2,358
I am looking for Ladder programming Best Practices and Tips. My Background is mostly AB and AD some Omron. Just looking for things to use in...
Replies
28
Views
15,424
and go! I'll start. Always comment the Boolean instruction for their TRUE state. For example. It is much easier to read a normally closed contact...
Replies
65
Views
21,650
Back
Top Bottom