Sign in to follow this  
Followers 0
Jeremiah

ADD Function

26 posts in this topic

Read up on the FFL/FFU instructions. Then you will need to use your imagination to look at this a bit differently. There are other ways to write queue algorithms (I've mentioned ring buffers many times if you search the forum) but the basic FFL/FFU instructions work just fine as long as the queue lengths are not excessively long and you can live with simple (not UDT) objects in the queue. Each table will have 3 possible states, which you can represent in 2 bits. Those states are "idle", "queued", and "running". Initially all tables start out as idled (set this using the first scan bit). Second step. Go through each table. If it is in the "idle" state, then put it in "queued" and load the table number into the queue with an FFL instruction. Third step. If there are less than 4 tables running, pop the last entry off the queue (FFU), and change it from "queued" to "running". Increment the number of tables running. Fourth step. For each table that is "running", do what it is supposed to do. If the table is done running, then change the state back to "idle" and decrement the number of tables running. What this does is that every table that is ready to spray (idle) will get scheduled into a FIFO (first come, first served) queue. The next step runs the scheduler to start tables running. The next step actually runs the table logic. Here is where the code you've been writing all along goes. When this code is done doing what it is supposed to do, it kicks the table back to the scheduler to be called again at a later time. You can of course put startup state conditions in at the "idle->queue" code, or you could simplify by eliminating idle and leaving only two states (running or queued). It all depends on how aggressive you like your code to be. Keep in mind that in this form, the simplest way to do things in the queue/unqueue part of the logic is to make heavy use indirect addressing. This is also generally true of what you are trying to do in general. For instance represent the states for each table as a word or DINT of bits. If B3:10.X (in RS-Logix 5 or 500 parlance) is "idle", or idle_state.X (in Logix 5000 parlance), then when you get an integer out of the queue, you can set the bit with OTL B3:10.[X] or OTL idle_state.[X], depending on the processor in use.

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