Keyboard input to Flip Flop memory conversion

Good afternoon everyone, I'm building a rudimentary summing calculator with fulladders.
But I'm having trouble taking the sequence of numeric inputs from the keyboard (3x3 + 1 matrix of buttons) and converting them to hundreds, tens and units;
For example, if I type 3 - 2 - 5, how can I electronically perform 3 x 100 + 2 x 10 + 5 and save it in my flipflop memory as 12-bit binary without using Arduino or similar?

Thanks

Edit:

I thank everyone for the excellent ideas; given the complexity of the project I think that, also to have something in hand for the end of the semester in December, now I will develop the keyboard, the display and the case of the calculator relying on an Arduino Mega for the computational part, subsequently I will reduce the functions in charge of the Arduino replacing them with traditional electronics.

A good day to everyone.

Suggest you find some OLD reference books, like
Don Lancaster's "TTL Cookbook", among the many he produced, or
anything by Forest M Mims III. I preferred Lancaster's writing style, but that's a personal 'thing'.

Both were masters at explaining things similar, or identical, to what you're asking.

3 Likes

You might want to look at this How to get the best out of this forum before you proceed any further.
We only know what you tell us, and without knowing what you have, we don't stand a chance.

So you might know what Your Flip flop memory is, and I know what a flip flop memory is, but I don't know what Your flip flop memory is.

It is odd that you ask a question here about not using an Arduino on an Arduino forum.

Anyway you chose the totally wrong category, so I have put this post to where it belongs.

Shift registers come to mind. Start with the suggestion from @camsysca, which should get you in the right direction.

1 Like

I once ordered this book for the Physics department of my University. And I got a memo from the Dean of Factual asking me why the physics department wanted a "cookery book".

Considering how much money the Dean was on, it would have cost the University many times the price of the book for the Dean effort.

2 Likes

Faculty, maybe; and as for what he was 'on', well...
But yes, I worked for physicists-turned-beancounters too. Worst sort of conversion, from useful to....

1 Like

Sorry for the wrong category. I didn't give any more details because I haven't decided exactly what to use and therefore I haven't bought anything yet; as an exercise with the use of Arduino it's "simple" I would like to do it with old-style electronics as a study guide for the computer science course I'm following.

Which makes it doubly hard to answer your question.
There are many types of flip flop.

  1. JK Flip Flop
  2. D-Type Flip Flop
  3. Master / Slave D-Type Flip Flop.

All do slightly different things. The first thing is for you to research those three types and see exactly what they do. So you know what sort of thing is available for your design.

You need to know how to suspend calculations until you get an operator. That is why you often see Reverse Polish calculators because they are much simpler to implement.

Heh. They actually showed up as "textbooks" at my University bookstore, aimed at a chemistry class on building lab equipment. I was a bit impressed.

The Lancaster books are mostly downloadable for free these days (very consistent with his general philosophy against patents. What would eventually be labeled "open source." Don Lancaster's Guru's Lair Free eBook Downloads
They're highly recommended. Even the obsolete books ("RTL" !?) will probably teach you things that modern education skips in favor of "this is how you install Python and/or Java" (Sigh.)

To convert individual digits to binary numbers, you'll need to be able multiply by 10. If you've got adders and flip-flops, that's probably easiest to do by adding the number 10 times. (Thus all the chunka-chunka-chunk noises as you entered digits on the old mechanical calculators.)

   with (new_digit)
     number = (number * 10) + new_digit);

Using TTL type logic, every step requires the correct logic configuration. Unless you find an IC that reads the keyboard matrix, using it will be complicated. Data input to TTL logic is frequently done with switches to set the byte(s) and a momentary button to clock the data into the receiver logic. For decimal input, binary coded decimal (BCD) switches (one per digit) is the method I am familiar using.

If using BCD switches for input, each switch will have 4 parallel output data lines. These must be connected to a receiving circuit that will have a binary bit input for each switch output and will store the input values upon receiving the register clock pulse.

BCD and binary are not directly cross-compatible. So, the BCD must be converted to binary before routing into the adder. I am not familiar with such a thing. The systems using BCD switches I have used simply kept the input as BCD and counted in BCD for timing purposes (clock or simple count-down timer). For systems functioning with standard binary values, I have only seen binary number inputs with a switch per bit. Not saying the conversions were never done in systems but rather pointing out that doing so would require additional research and circuitry.

Once you have completed the input circuits, it will probably be easy enough to wire those to the flip-flop memory for your full-adder. Best of luck with your project.

Nah. Keyboard scanning isn't too hard. The aforementioned "CMOS Cookbook" has schematics for a full ASCII keyboard that uses about 6 chips (two 4-bit counters for row and column, two 8-way multiplexers (for an 8x8 keyboard array) and some glue logic. (pg 412)
A smaller (calculator-sized) keypad outputting binary would be even easier.

1 Like

Not necessarily.
You can read a matrix of switches by using a clock signal say a NE555 driving a binary counter whose output pins address the matrix. Every time a switch on the matrix is detected as closed the binary counter is stopped using its inhibit pin and a strobe pulse generated to latch the counter's value into memory.

If you make that counter into a BCD counter then you will get a BCD value from the switch matrix.

However, the biggest problem I foresee with this projects is getting hold of the actual chips you need. Most of the more esoteric chips you need have been made obsolete by the world wide drive for lead free components, foisted upon us by the stupid bureaucrats of the EU. It has been deemed that there is no market for them any more.

For example

  1. 7489 - a 64 bit read / write memory. Organised as 16 4 bit words
  2. 7442 - BCD to decimal decoder.
  3. 74121 - Retriggerable monostable - I used to use a lot of these in my TTL designs.
  4. 74170 - 4 by 4 register file.
  5. 74181 - Arithmetic units / Function generators.
  6. 74482 - 4 bit slice expandable control elements

Then have you thought about a display? Most displays you can get are designed to be used by micro controller.

One option is to used a cold cathode display with chips like the UCC1972/3. Or the Nixi Tube type of display.

There is one hell of a lot to think about with this project.

1 Like

Among these I had already thought of the Flip Flop D

Similarly to the assembly code; however, the operation I tought to insert via a toggle switch.

No.
Have you ever seen / used a reverse Polish calculator?

Not at all sure what you mean by this.

In the project I have in mind I was not thinking of decimal numbers, the limits of the calculator would be, Operations: +,- Range: 0 =< x =< 999 or at most 9999. I had thought that each button gives a signal (on both input pins of the D flipflop) writing the binary equivalent, this would however require 3 keyboards, one of the units, one of the tens, one of the hundreds and possibly of the thousands, as well as a register that keeps track of the previous input and adds it to the one being inserted. Now I try to look better at the BCD buttons that perhaps simplify the circuit

Thanks

Great, but I wonder, in this case, should I subtract 48 from the binary number (because the 0 in ASCII encoding is in the 48th position)?

As soon as I have a moment I will look at the precise specifications of all the integrated circuits you have written.

I'm lost in this step, does the NE555 generate a square wave that increases the value of the binary counter? How does it distinguish which button I pressed?

For the display I was thinking of a 7 segment LED with 3 or maximum 4 digits, if I am not mistaken there are already encoders from binary to display

Thanks a lot

Unfortunately not, I just looked it up on Wikipedia

I imagined a switch that in position 1 means addition, position 2 subtraction; which appropriately directs the current to activate the adding or subtracting circuit.

Yes. Also a lot to purchase and connect as well. I am still amazed by working electronics made with discrete CMOS and TTL logic IC parts. The complexity and knowledge involved impresses me. Looking forward to seeing what fer314 builds.

1 Like

Yes square wave or indeed a pulse.

The same way as any scanning matrix does. This is a typical circuit of a scanning matrix used with a Pico, but you just replace the row inputs with a data selector that you enable in turn by the two least significant bits of your binary counter. When you see a low on the select input you stop scanning and generate your strobe pulse.

The walking zero pattern can be made by using a ring counter.

1 Like