Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Calculator Project

Status
Not open for further replies.

matthewwren

New Member
I am building a very simple calculator, but need help with one small area.

I have 4x4013 chips to represent a 4 bit number. When I press, for example, 3 on the number pad I want to set the 4013 chips to the correct values. That is to say:

FF...... 1 2 4 8
============
Value.. 1 1 0 0

To start with I tried to set a 4013's Q to high by wiring both the D and Clock to the switch, imagining that when I hold down the button Q will go high, but that doesn't work. I'm not sure why. Anyone got any ideas on how to achieve the setting of flip flips according to which value button i press?
 
I do not know what type of number pad you have so answering is a little hard.

If I wanted to get from a keypad to 4 bit number I would look at using the MM74C922 ic.
https://www.fairchildsemi.com/ds/MM/MM74C922.pdf
It has 4 outputs A,B,C,D which are Q0,1,2,3. Then the DA pin indicates that a key is pressed and data is available.

Hope this helps.
 
If you are using switches, you need a separate switch for each D input, and one clock switch that connects to all 4 clock inputs. I hope you learned about switch debouncing and pullup/pulldown resistors on the other thread on this subject.
You don't need to debounce the D input switches, just the clock.
 
Thanks for your help guys. Just a couple of questions:

Roff - I want to make a keyboard input, so numbers 0-9, rather than separate switches for clock and bits. Is there no way of using the same output to pulse clock and D? Why doesn't this work?

Ronsimpson - This looks interesting. Am I right in assuming that the DA pin can act as my clock in on the 4013?
 
matthewwren said:
Thanks for your help guys. Just a couple of questions:

Roff - I want to make a keyboard input, so numbers 0-9, rather than separate switches for clock and bits. Is there no way of using the same output to pulse clock and D? Why doesn't this work?

Ronsimpson - This looks interesting. Am I right in assuming that the DA pin can act as my clock in on the 4013?
SInce data can be either a one or a zero, you would have to generate a debounced rising clock edge on either transition of the data (0-1 or 1-0). This can be done, but it requires an Exclusive OR (XOR) gate to generate the pulse, plus you still need debouncing in front of it.
The 74C922 is your best bet, and DA can, as you surmised, be used as your clock to the 4013's.
You need to know that the D input must be settled (no bouncing), plus there is a small delay required between data and clock (called setup time), in order to be able to capture data on a flipflop such as the 4013. The 74C922 takes care of this for you, as does any properly designed debounce circuit, if you were to try to do it the other way (which I don't advise).
As you can see from the 74C922 datasheet, a keypad is a matrix of switches, not 10 or 16 individual SPST switches. I wouldn't try to implement a decoder in discrete logic chips - a microcontroller could do it.
 
Last edited:
There's no point in designing a calculator these days, unless it's purely for educational purposes.

Also implementing functions like multiply, divide and square root is pretty impractical without using a microcontroller.

If I were you, I'd not just design a simple calculator or even a scientific/graphical calculator but one with handy functions and can't be bought cheaply - a calculator with a clock calander, time and date functions, plus a currency converter as well as some scientific features like operator precedence and brackets would be very handy.
 
On a slightly off topic note:
How do you calculate the square root of something, in pseudo code or anything ? Just something I've always wanted to know !
 
calculator

i want asembly code and peroteus design for a simple calculator with micro AT89c51.(+,*,/,-)
thanks.
 
You don't seem to understand.

NO, WE WILL NOT GIVE YOU THE SOURCE CODE!

DO IT YOURSELF!
 
Ah thank you, isn't quite as simple as I thought it would be. Looks like it would be a pain to do on a normal calculator. :eek:
 
Status
Not open for further replies.

Latest threads

Back
Top