calculator progam

parky100

Member
Join Date
May 2008
Location
california
Posts
2
Hi, I need some help PLEASE. I need to get a calculator program. It needs to be a 4 digit basic calculator. Add, subtract, multiply and division. It needs to be in ladder logic & I'm using a Allen & Bradly 500 PLC. Thank you for your help. Mike
 
Greetings Parky and welcome to the forum. Here you will find that we do not do your homework for you - that's because someday you are going to be our coworker and we want you to be competent, not an imbecile. However you will find many posters are willing to help you learn. So I suggest you describe step by step what you want to do and how you think you might program it, then we'll help you learn where your mistakes are.
 
Third Hint: We will not do your homework for you. We will help once you have shown some effort to at least start it. Show us what you have first, then we can (and will!) offer suggestions.

Fourth Hint: The hardest part of any automation project is DEFINITION. Define what you want your system to do first before you ever start writing code. One great way to document this system would be a flow chart. How are you loading your registers? How will you trigger the math function? Where will you store the result? What will you do with the input data when you're done? What happens when you have an error (e.g. division by zero, out of range)? etc.....
 
5th hint multiply and devide can be done via add, subtract devide by two can be done by a bit shift left and vice versa for multiply. May help to explain why you need a calculator program when the SLC lanquage already has those functions programmed in the logic set
 
I take it you assignment is to program a basic calculator using ladder logic rather than the SLC instructions if so start with addition, subtraction is the reverse once you have those two figured out the multiply and devide is easier as your just adding the same value x times

ie 4*4 is the same as 4+4+4+4 reverse for devide
this is how the original processors used to multiply and devide before the math coprocessor in the 386dx PC.

If you have an electronics book look up flip flop adders
 
Last edited:
Another hint:

When you finish this course, write a letter to whoever establishes the course content and ask them to revise it so that it uses real-world applications.

The only practical knowledge that will come out this foolish exercise is to teach about the limits of integer arithmetic. That same lesson could be taught by means of more realistic applications of PLC math capabilities.

Parky100, please know that I'm not criticizing you for your instructor's shortcomings.
 
Actually Steve I had a similar project during my electronics course not sure how it applies using a PLC but in the electronics end it was used to explain the usage of flip flops, (helps explain what a register location is), Also the lesson teaches how an Algorithmic logic unit works and one of the older limitations of processor mathematics prior to the co-processor. The bit shift comes from this as a means of speeding up the calculations and is one of the reasons why many programs take more and more processor power as its one idea that is largely forgotten by programmers as processing power has so much better many programmers no longer spend the time tweaking speeds out of their programs
 
I just don't think it is a smart exercise for a basic ladder logic course using a SLC 500 PLC. There are very few SLCs that are used as four-function calculators. You can buy a better calculator at Rite-Aid for a lot less money. To demonstrate the capabilities and limitations of PLC arithmetic the instructor ought to be able to come up with automation-related examples that require calculations. What's the point of teaching an application for which the PLC is particularly ill-suited?

If the course was in IEC61131 languages on a platform that supported program blocks in multiple languages, it might be a good exercise in matching the language to the task.
 
One of the first exercises in many digital electronics classes is to create a binary adder. I suspect that a digital electronics instructor has a PLC dumped in his lap and is told to make a course about it. So he approaches it the same way and students end up with a lame assignemnet to make a calculator.

That said, Parky, you have nevertheless received the assignment, so lets make the best of it.
parky100 said:
I have only been in this PLC class for a month. This is my 1st PLC class. Thank you all for your help!!!
How you proceed now is entirely up to you. I suggest you describe the problem in detail to us, tell us how you think you might approach it (even if its wrong, at least try), and what instructions you think you might need. Then we'll work from there. No one here is going to give you the answer (because we all know from bad experience that there is nothing worse than a coworker who squeaked through school coasting on the work of others because you end up doing his job and yours) but we will help you work your own way through it.

How are you inputting the numbers?
How are you getting the result back out?
 
Last edited:
Well, it seems I have ended up also having to make a calculator program for work. Normally, I would say that it is a dumb idea to use a PLC for this; however, we have to build one that its life size for a childrens' museum. This means I can't hack into a calculator and it has to run for years on end. However, if anyone knows of a calculator circuit (something like the keyboard emulators) I would much prefer to use that.

In the meantime, I have to figure out how to do a calculator on a PLC06. So, please keep responding to this forum, its the only help i've gotten in the past month.

Thank you. :)
 
I am inputting my numbers and math functions with buttons and they are supposed to display on a c-more micro display. This is the first time I've ever used a PLC, but boss says I have to figure this out. (talk about sink or swim)
 
do a search for a flip flop adder circuit essentially its a set of flip flop cicuits in series when one flip flop changes state from 1 back to zero it moves that one to the second flip flop keep in mind that the computers before the math co processor all used this method rather than an actual multiply\devide instruction you can simulate this using any 16 bit data register (A register is essentially the same circuit). Also multiply and devide by 2 is the same as bit shift left and bit shift right. (useful in speeding up the calculations).

http://www.play-hookey.com/digital/adder.html this shows how to build a flip flop with gates
 
Last edited:

Similar Topics

Dear PLCtalk Forum, I developed a generator for time-optimal trajectories with jerk limitation. You can access it online to calculate, display...
Replies
38
Views
16,586
I am currently working on a project to built a fully functional calculator through Ladder Logic Programming and could perform all forms of...
Replies
8
Views
5,094
while using PLC to control servo motors,it's necessary to find the e-gear ratio ... share an => Calculator for servo's E-gear ratio of screw...
Replies
0
Views
1,244
Hi everybody! I found alot of help in this forum, thanks very much about that. Now i have a problem about calculator average value but i dont know...
Replies
0
Views
1,838
Hi; We have an HMI designed in RS View32 Build 6.30.16 in one of our machine. Operators want to have a calculator option in it just to ADD, SUB...
Replies
5
Views
2,000
Back
Top Bottom