RSlogix program

tafenegus

Member
Join Date
Nov 2006
Location
oregon
Posts
8
Help

I need PLC program that do or act like calculator, ADD, Sub, Div, Multiply and Clear all values from the PLC. All values are entered in RSview and I know how to do that. Just the PLC or Rslogix is I am having problem. So if you can give me hint or e-mail me the file I will appreciate.



Thanks
 
Homework?

We don't usually do homework for you here on the forum unless you show some personal effort first. What makes me most supsect that this is homework is that you know how to get the numbers from RSView into the PLC but can't do such a simple plc program, so I suspect that the RSView app is already set up for you in the lab.

We are more than willing to help, but you do have to put forth some effort. Here is a hint:
AL110106a.JPG


Lets see what you can make of it and we'll be happy to provide some additonal pointers.
 
thanks You guessed right it is home-work however you didn’t answer my question. I already know how to do the Sub, Add……. What I am having problem is storing numeric data after every arithmetic is don.

2 (Enter button) + 3 (Enter Button ) – 4 ………….. = ?

Thanks
 
Is this to emulate a basic calculator or an RPN style calculator?

If its a basic calculator then you need a register to function as an accumulator and a register to hold the number on which an operation is pending with the accumulator, IOW, REG_A would be the accumulator and REG_P would be the pending number. After you perform the operation, the result is put back into REG_A where it is ready for the next operation or for display as the result. How do you think that you might take care of a pending operation?
 
It's not too bad if there are only four operations and a CLR key; then, you never have to remember the last operation pressed on the screen (assuming that the screen PBs are momentary like they should be, according to the other thread <lol!>).

It is a little more interesting if there is an EQUAL key on screen too; then, you have to remember the last operation selected and use it to branch when EQUAL is pressed. After doing the desired operation (using the EQUAL key) you have to clear that last operation register as well as the 2nd word register. At least, that's how my TI seems to do it.

Of course, the error handling would be longer than the code to do the requested operations- is that part of the homework too? Next month's assignment maybe!
 
Thanks Paul!
On the screen there are 6 buttons ADD, SUB, MULT, DIV, EQUAL and CLEAR. All are momentary button. Also there are two displays that show TOTAL NUMBER and INPUT NUMBER where numbers to be calculated.
The trick is using one input number. Every time the number is typed and entered in RSVIEW the number has to be stored until the EQUAL button pressed. this part is the one I am having problem.
 
When using the EQUAL button to get a result you have to have stored two things- the first input number, and the operation. So the thing you've gotta think about is "How do I store something?" and "When do I store it?"

OK... so at time zero, there is nothing in the PLC. You put a number into RSView and press the "Enter" on the RSView keypad. That downloads that value to the PLC, to let's say N7:0. Now what?

Well, what can happen next? You're going to press one of "+", "-", "x" or "/". Those are linked to, say, B3:0/0, B3:0/1, B3:0/2, B3:0/3. When you press the screen button in RSView, one of those bits goes high in the PLC for the time that the screen button is down. And when you let go, the bit goes away, right?

So maybe we have to capture that button press. There are at least a couple of ways to do that, but one easy one is to use another N7: register- say, N7:3- and if B3:0/0 goes high, load N7:3 with "1"; if B3:0/1 goes high, with "2"; etc. Now we know what the operation will be.

But what about N7:0? You know that it is going to be overwritten by the next entry after the "+" or "-" or... etc. So maybe we should do something about that while we're seeing the operation bit go high.

OK... you know that to ADD you need to have something like N7:0 and N7:1, and the result is going into a register of your choice- could be anything, right? Well, in your problem it's going into this TOTAL NUMBER box in RSView (a complete waste of space, BTW! <g!>) and let's say that's N7:2. So if I need an N7:0 and an N7:1 to add or subtract or whatever, then maybe when the "+" button is pressed I should write whatever is on the screen in N7:0 to N7:1, 'cause I know that the next thing that happens is N7:0 is going to be overwritten by a new number from the screen. That's ok, though, because when that happens I'll have the original number safe in N7:1 ready to be used in the calculation.

So when the "+" button is released, I've got N7:0 saved in N7:1 for later use, and I've got the "+" (or whatever) itself saved in N7:3 as a number.

OK... so now you put a new number on the screen and download it to N7:0. Now I've got two numbers and I'm waiting for EQUALS. So when the EQUALS bit lights up (let's say it's B3:0/4) I want to have a rung that looks at the value of N7:3, then for each value does the appropriate ADD, SUB, MUL, or DIV with N7:0 and N7:1, and puts the result into N7:2 for display in the TOTAL NUMBER box.

Not too bad, right?

If you want to have this work like a real calculator, then you have to get fancier by doing a string of operations without benefit of the EQUALS to break things up-

like 3 + 5 - 7 x 14 - ...

and you have to think more about what happens when you press the "+", "-", "x" and "/". We said before that pressing, say, "+" would copy N7:0 to N7:1. That works fine the first time and readies for the next value into N7:0.

But suppose that I do the 3 + 5 - 7... and just hit "-", not EQUALS, after entering 3 + 5. Well, in that case... when the "-" bit goes high, I can't just copy N7:0 to N7:1. So maybe instead of simply copying N7:0 to N7:1 each time an operation button is pressed, I immediately perform the operation saved in N7:3 (the "+") on N7:0 and N7:1; and then save the new operation (the "-") in N7:3. That's trickier, because I need to use the "-" to kick off the saved "+" using what's in N7:1 and N7:0, and also to save the result in N7:1 after it's calculated... because I know that another number is coming...

OK... I'm out of time on my lunch break <g>. Try playing with these ideas and see how you make out. A hint for the chained calculation is to clear N7:1 whenever EQUALS is pressed, then look at it when "+" "-" "x" and "/" are pressed. If it's zero, then you copy N7:0 to N7:1 and wait for the next number. If it's not zero, then you have to do the *last* operation and store that result to N7:1 as described above to be ready for the next number in the chain. There is more than one way to do it, but you need to keep track of where you are in a chain- on the first two numbers, or somewhere downstream- and modify the program a little to not lose track of the correct result.

One thing that might help is to define the N7 and B3 words and bits before you start, so that you can just use them in the ladder without being slowed down naming them. You are going to have to write the ladder to figure out where you are in the sequence- each time an operation is pressed- and do the last requested operation and save the current requested operation to wait for the next number. It's not really that bad... just sit down with a pencil and a sheet of paper and sketch it out, then code it and see what happens.

Good luck!
 
Last edited:

Similar Topics

I am completely stuck on building a ladder program that requires a start button to be pressed 3 times to turn on motor 1. Then motor 2 starts...
Replies
20
Views
529
Hi. I came into a problem that was buried in my memory. I had a list of modifications to do on 2 RSLogix programs. So I tapped in the IP...
Replies
7
Views
1,057
Hello all, I am working on a project on a CompactLogix L16ER-BB1B plc, and I was given a program that is on version 20.019, while my plc is on...
Replies
3
Views
1,816
I have been tasked to upgrade some SquareD PLCs at our plant. I have done several of these upgrades without any issues. However, I have now met my...
Replies
4
Views
2,440
Back
Top Bottom