Ladder Logic 206: Scanning
In last week’s post I mentioned that there was a mistake in the organization chart I have been using in my ladder logic posts. My friend Gordon mentioned it at lunch a couple of weeks ago and when I checked it out, he sure was right.
As most people who work with PLCs know, the program is scanned from beginning to end, updating the status of bits as logic for each rung and routine is solved. At the end of the scan the outputs are updated so they reflect their new status, energizing devices, etc.
The way I had set up the scanlist, the inputs and outputs came before the auto sequence. The inputs states are buffered as described here, the auto sequence then uses those results to determine the status of the steps as shown here, and then the auto sequence command bits are used as shown here. It is important from a speed standpoint to be sure to determine the states of all of your bits in order before updating the physical outputs. The end result if using the first (left) scan order is that the outputs would not be updated until the auto sequence had run, a full scan later than the inputs were updated. Would the program still work? Probably so, and since scans are usually on the order of 30 milliseconds or less it might not even be noticed, but it is still bad programming form. As I said last week, I normally would catch such an error if writing a real program, especially since I generally use the same template for most programs, but when I made this sample I guess I was thinking of the order I was presenting the material in the posts.
This was a good catch by Gordon, I thought it was cool that he actually checks out my posts, even though this is pretty basic stuff. I offered a prize last week for anyone who wanted to guess at the problem with the list, but no one commented so I guess I’ll just have to keep the Maserati for myself. Its interesting; as I have mentioned before I can track the number of people who read this blog and as of today there were over 25 separate readers of that post. I can only guess that either people weren’t particularly interested in guessing, they didn’t read the post all the way, or they didn’t know. Of course there was also an invitation to download Mastering The Machine also on that post, there were only two downloads last week, and one was Gordon! He was probably trying to make me feel better so I don’t get all suicidal and stuff.
Anyway, I do appreciate the people that stop by and check out my blog. And I really don’t have any self-esteem problems even though when I was a kid they had to tie a pork chop around my neck to get the dog to play with me!