Sign in to follow this  
Followers 0
ASForrest

Queueing and FFL's

5 posts in this topic

Hi guys, I'm trying do do something I haven't done before in a PLC program and wondering if it can be done simply. I'm basically creating a queue of recipes for the system to run. So I've used an FFL to add recipes to my queue, and then when the next recipe is loaded into the batching sequence, an FFU removes that recipe from the top of the queue and shifts everything else up. (Side note: As far as I'm aware, I use the same Control for the FFL and FFU instructions, can someone confirm or deny that rumour? ) But what if I want to add a new recipe in to the START of my queue, rather than the end? Is there an easy way to shift everything in my queue down one place, and add a new recipe into position 0 in the array? In my mind, it's similar to a BSL (Bit Shift Left), except I'm using INT's not BOOL's. Thanks!

Share this post


Link to post
Share on other sites
hey mate, Well, yeah you should use the same control for it contains your stack informations such as length and the stack pointer. Now that you mention it, I realize it's kind of weird, I thougth they would have considered having a PUSH to the bottom, I mean, as there are a FIFO load and a LIFO load we could have expected having one to push to the bottom of the stack, though it would have been weird too, but they're obviously both top-loaders... And I can't find any fonction doing it... That's the problem with these so said "high level" programming PLC, when it comes to easy basics, it is just not here... Well, my guess is you're gonna have to do it by yourself, it's not much a difficulty, can be done with a single loop. Don't forget to increase/decrcrease the stack pointer whenever you add/remove something in your stack, that is, if not using the built-in functions of course. The control.POS value should be the stack pointer. Good luck.

Share this post


Link to post
Share on other sites
You'll have to test it, but I think you should be able to just shift the new value into the array and increase the LEN value of the control. I've done things sort of like that when manipulating strings. Another approach would be to have a second array, and when you need to add a value, pop everything into it, pop the new value into the first array (into the first position), then pop everything from the second array back into the first array. That seems needlessly complex. If all that fails, just use an array and shift instructions for everything, but you shouldn't need to do that. Which processor are you using?

Share this post


Link to post
Share on other sites
and if you're actually interested....you can do what 'data' programmers do and simply use a pointer to the first recipe (data value).....simply move the index without actually moving all that data......you don't see much of an improvement if you're only keeping track of a relatively small quantity of items.....keep track of 1000, 5000, or 10,000 (or more) and it makes a difference..... in your case lets say you have the data in registers N7:0 - N7:99....pointer is N7:255......think of the data as a big circle.....the pointer is an index so that you always address the current data as N7:[N7:255]......each time you use a value increment N7:255 so it points to the next data in the list....N7:254 is the last data....each time you add (queue) new data increment N7:254....if it gets >99 loop it back to zero......if N7:255 = N7:254 there is no more data......using this method you simply grab N7:255, decrement it and then place the new value at that location to put something at the 'top' of the stack. Thats rough....you need some small amount of coding to make sure you don't overlap and to handle rollovers....... this does not however address placing a value in the middle of the data...but thats a problem for some other post........ bob

Share this post


Link to post
Share on other sites
On 10/25/2013 at 7:21 AM, drx said:

hey mate, Well, yeah you should use the same control for it contains your stack informations such as length and the stack pointer. Now that you mention it, I realize it's kind of weird, I thougth they would have considered having a PUSH to the bottom, I mean, as there are a FIFO load and a LIFO load we could have expected having one to push to the bottom of the stack, though it would have been weird too, but they're obviously both top-loaders... And I can't find any fonction doing it... That's the problem with these so said "high level" programming PLC, when it comes to easy basics, it is just not here... Well, my guess is you're gonna have to do it by yourself, it's not much a difficulty, can be done with a single loop. Don't forget to increase/decrcrease the stack pointer whenever you add/remove something in your stack, that is, if not using the built-in functions of course. The control.POS value should be the stack pointer. Good luck.

i want to create queue for my elevator to tore call requests and release one by one...how can i make this by using mitsubishi plc? 

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