Sign in to follow this  
Followers 0
professor_jonny

multi paralell word stack and fifo issue cj2m

8 posts in this topic

I there i have a cj2m plc and an ns screen and im wondering on a way to store asci into a stack and a few other details, or maybe a better way of doing it. i have set up a ascii thermal printer on a serial port for printing out dockets for trade use. basically i have a silo sitting out in the field that a tanker driver will turn up at and unload into his tanker with milk. i wish for the tanker driver to input his name and at this time store the date time month and the total literage in his truck and print out on a docket with a crypt key hashed serial number. i would like the system to store the last 100 picpups and all the above values in the stack so it is acessable via the printer and screen for remote acess via the net. i have set up a date and time stack using bit shifting the ar area but for the tanker driver name i need to store a name and there is no multi word stack. the other problem i have is the stack does not roll over and push out the first entry on becomming fill so i have used a compair command with the stack pointer to a direct adress of the stack pointer and fifo the first entry ready for a new value to be pushed on. im not really shure how to use an indirect adress method from the start of the stack to do the compair as if im creating many stacks i have to manually figure out the stack pointer and direct adress it and as you can imagine if im storing 100 words and 30 words wide it is going to be a complicated mess, it would be nice to just dupilicate the code in a different area than having to work out where the stack pointer is all the time. i have never messed with indirect adressing and in the compair command i put in a value of h0@100 expecting it to adress 100 words down the stack starting from h0 but it is abviously wrong. may someone shed some light or maybe another method of acheiving the same result.

Share this post


Link to post
Share on other sites
As with many PLC coding tasks, there are many ways to accomplish what you have described. There are a lot of very smart guys on these forums that may answer your question with a clean and concise solution. It sounds like you know what you are doing, you just need to know the methods. Here is a nice write up on Indirect Addressing using Omron PLCs.

Share this post


Link to post
Share on other sites
If I am understanding you correctly, the SSET and PUSH commands will do exactly what you are trying to do. Please investigate them.

Share this post


Link to post
Share on other sites
thats what i have done but the problem it is only one word wide and does not automatically clear i was wondering if there is a better solution i may not be aware of ? I have sample code as below with a fault code stack with automatic purge on the stack becomming fill. but as you will see im using direct adressing for the compair command to fifo out the first entry is there a way to do this with out direct adressing the memory location at the end of the stack? maybe an indirect way to reference from the start of the stack or a better method to my madness? i'm trying to save my self from having to work out 100 different locations for these adresses fault push.cxp

Share this post


Link to post
Share on other sites
Sorry, I have read it a bit more closely this time and I believe that I understand what you are wanting to do. Try this code below, it is simple, no indirect addressing required. From the sounds of it, you do not need to extract the info, except to view or print the whole stack. If you need to extract records 1 by 1, let me know and I can provide additional examples.

Share this post


Link to post
Share on other sites
I did not even think of doing it like that defining a data are as my own independant stack. i have worked out i need at a minimum of 16 words and i have had to define 16 stacks of 104 words (first for is not part of the data set) using the sset and fifo to purge them but i have thaught of compairing 104 words down the stack with #0 so that if any thing is in the stack at that position it will purge. but i have the problem if the stack if filled with zero as data it will fail so i compair all the different stacks in paralell as it is very unlikeley that the dates and times will all be zero at the same time they press the go button. no i dont need to read it but it is there for the benifit of scrolling the last 100 driver details from the web via the ns screen or direct from the screen it is just for reference it may be extended to store alot more in future as i have 20000 available to use should future proof it a bit. doing it the way you define will mean i can fit more as 4 words on every stack are not lost from the start end and stack pointer, but it will not zero fill on power up but i can do that using bset.

Share this post


Link to post
Share on other sites
Do you want it to zero at power on? I would think that you would NOT want it to zero...either way, you are correct, use BSET to zero it if you want.

Share this post


Link to post
Share on other sites
Wow Michael, you have even used the original method of Indirect addressing! Personally, I almost always use Indirect addressing for this sort of thing, just makes it easier to maintain for me, & to fully customise what you need to do.

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