1
\$\begingroup\$

So im designing a electronic dice with a 74HC163 and the 74HC4511.

My problem is that the counter counts 0-7 everytime (using only the 3 flip flop outputs, Q0-Q2)

I would want the counter to count only from 1-6 and go back to 1. I know this can be done by "Presetting" the 74HC163 somehow but i dont know how. Anyone have ideas on how the cables should be connected on them to count from 1 to 6 and return to 1 after the 6? Thanks. And the arduino is only giving a +5v and a blinking high- low singnal using the basic program "Blink"

\$\endgroup\$
12
  • \$\begingroup\$ Do you have a question that you cannot answer yourself by reading the the device data sheet? \$\endgroup\$
    – Andy aka
    Sep 23 '20 at 9:19
  • \$\begingroup\$ I have read the datasheet multiple times, and tried to connect everything by trying to understand it but just cant quite get what is missing from me or how to connect them. \$\endgroup\$
    – Nicoo
    Sep 23 '20 at 9:22
  • \$\begingroup\$ Trouble is, nobody can tell from what you write above, what the problem is that you are experiencing. Have you considered that actually posting a schematic circuit diagram of what you have tried might be a way forward? \$\endgroup\$
    – Andy aka
    Sep 23 '20 at 9:24
  • \$\begingroup\$ Yeah sorry im kinda new on the site and just posted this in a hurry to see if id get a quick answer but yeah need to do a diagram of it. Thanks \$\endgroup\$
    – Nicoo
    Sep 23 '20 at 9:32
  • 1
    \$\begingroup\$ Why on earth you even have those 74HC chips while the Arduino can use simply program to generate a pseudorandom number and display it on 7-segment display directly? \$\endgroup\$
    – Justme
    Sep 23 '20 at 10:12
5
\$\begingroup\$

Overview

Essentially, you want a 1-6 counter -- either up or down. So let's go with up.

Excitation Table

Excitation tables often used to work out the combinatorial logic needed to transition a set of FFs holding the current state into the next desired state for some arbitrary (usually circular) sequential series of states. They aren't hard to make, though they may take a little persistence. Once produced, they are usually turned into k-maps for minimization purposes.

Most often, these tables are meant to help when using JK-type (JKFF), toggle-type (TFF), or D-type (DFF) flip flops. The JK-type has two inputs and the others have just one input. Their transitions are represented in the following table:

$$\begin{array}{c|c|c} \text{Transition} & \text{JK FF} & \text{T FF} & \text{D FF}\\\hline {\begin{smallmatrix}\begin{array}{c} \text{start }\to\text{ end}\\\\ 0 \quad \to \quad 0\\ 1 \quad \to \quad 1\\ 0 \quad \to \quad 1\\ 1 \quad \to \quad 0 \end{array}\end{smallmatrix}} & {\begin{smallmatrix}\begin{array}{cc} J & K \\\\ 0&x\\ x&0\\ 1&x\\ x&1 \end{array}\end{smallmatrix}} & {\begin{smallmatrix}\begin{array}{c} T\\\\ 0\\ 0\\ 1\\ 1 \end{array}\end{smallmatrix}} & {\begin{smallmatrix}\begin{array}{c} D\\\\ 0\\ 1\\ 1\\ 0 \end{array}\end{smallmatrix}} \end{array}$$

(Obviously, the DFF just wants the next state fed to its input.)

For now, we don't choose. We just analyze all possibilities and see what's easier to implement.

$$\begin{array}{c|c} \text{States} & \text{Excitations}\\\hline\\ {\begin{smallmatrix}\begin{array}{cccc} Q_C & Q_B & Q_A\\ \vphantom{\left.\overbrace{\begin{array}{ccc}J & K & T & D\end{array} } \right.}\\ 0&0&1\\ 0&1&0\\ 0&1&1\\ 1&0&0\\ 1&0&1\\ 1&1&0\\\\ 0&0&0\\ 1&1&1 \end{array}\end{smallmatrix}} & {\begin{smallmatrix}\begin{array}{cccc} Q_C & Q_B & Q_A\\ \left.\overbrace{\begin{array}{cccc}J & K & T & D\\ 0&x&0&0\\ 0&x&0&0\\ 1&x&1&1\\ x&0&0&1\\ x&0&0&1\\ x&1&1&0\\\\ x&x&x&x\\ x&x&x&x \end{array} } \right. & \left.\overbrace{\begin{array}{cccc}J & K & T & D\\ 1&x&1&1\\ x&0&0&1\\ x&1&1&0\\ 0&x&0&0\\ 1&x&1&1\\ x&1&1&0\\\\ x&x&x&x\\ x&x&x&x \end{array} } \right. & \left.\overbrace{\begin{array}{cccc}J & K & T & D\\ x&1&1&0\\ 1&x&1&1\\ x&1&1&0\\ 1&x&1&1\\ x&1&1&0\\ 1&x&1&1\\\\ x&x&x&x\\ x&x&x&x \end{array} } \right. \end{array}\end{smallmatrix}} \end{array}$$

K-Maps

Next, you turn the above excitation table columns into k-maps. (It's often easier to minimize the required logic when in this form.)

Again, for completeness, I'm providing all of them. We'll decide which is better, later.

$$\begin{array}{rl} \begin{smallmatrix}\begin{array}{r|cccc} Q_C\text{ }J&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&0&1&0\\ Q_C&x&x&x&x \end{array}\end{smallmatrix} & \begin{smallmatrix}\begin{array}{r|cccc} Q_C\text{ }K&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&x&x&x\\ Q_C&0&0&x&1 \end{array}\end{smallmatrix}\\\\ \begin{smallmatrix}\begin{array}{r|cccc} Q_C\text{ }T&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&0&1&0\\ Q_C&0&0&x&1 \end{array}\end{smallmatrix} & \begin{smallmatrix}\begin{array}{r|cccc} Q_C\text{ }D&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&0&1&0\\ Q_C&1&1&x&0 \end{array}\end{smallmatrix} \\\\ \begin{smallmatrix}\begin{array}{r|cccc} Q_B\text{ }J&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&1&x&x\\ Q_C&0&1&x&x \end{array}\end{smallmatrix} & \begin{smallmatrix}\begin{array}{r|cccc} Q_B\text{ }K&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&x&1&0\\ Q_C&x&x&x&1 \end{array}\end{smallmatrix}\\\\ \begin{smallmatrix}\begin{array}{r|cccc} Q_B\text{ }T&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&1&1&0\\ Q_C&0&1&x&1 \end{array}\end{smallmatrix} & \begin{smallmatrix}\begin{array}{r|cccc} Q_B\text{ }D&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&1&0&1\\ Q_C&0&1&x&0 \end{array}\end{smallmatrix} \\\\ \begin{smallmatrix}\begin{array}{r|cccc} Q_A\text{ }J&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&x&x&1\\ Q_C&1&x&x&1 \end{array}\end{smallmatrix} & \begin{smallmatrix}\begin{array}{r|cccc} Q_A\text{ }K&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&1&1&x\\ Q_C&x&1&x&x \end{array}\end{smallmatrix}\\\\ \begin{smallmatrix}\begin{array}{r|cccc} Q_A\text{ }T&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&1&1&1\\ Q_C&1&1&x&1 \end{array}\end{smallmatrix} & \begin{smallmatrix}\begin{array}{r|cccc} Q_A\text{ }D&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_C}&x&0&0&1\\ Q_C&1&0&x&1 \end{array}\end{smallmatrix} \end{array}$$

From the above, there are a number of options to consider. But I like the J-K option. So here's the result of that:

$$\begin{array}{c|c} \text{JK FF} & \text{Expression}\\\hline {\begin{smallmatrix}\begin{array}{r} Q_A \left\{\begin{array}{c} \vphantom{1} J\\ \vphantom{1} K\end{array} \right.\\ Q_B \left\{\begin{array}{c} \vphantom{Q_A} J\\ \vphantom{Q_A+ Q_C} K\end{array} \right.\\ Q_C \left\{\begin{array}{c} \vphantom{Q_A\:Q_B} J\\ \vphantom{Q_B} K\end{array} \right. \end{array}\end{smallmatrix}} & {\begin{smallmatrix}\begin{array}{c} \left.\begin{array}{c}1\\1\end{array}\right.\\ \left.\begin{array}{c}Q_A\\Q_A + Q_C\end{array}\right.\\ \left.\begin{array}{c}Q_A\:Q_B\\Q_B\end{array}\right. \end{array}\end{smallmatrix}} \end{array}$$

Assuming only 2-input devices, this can be done with one OR and one AND using J-K FF devices to hold the state:

enter image description here

Note that I've chosen \$\overline{Q_A}\$ instead of \$Q_A\$ for the output bit because of the usual power-on reset state of the JK FF.

(You can completely avoid the Arduino and use a 555 or other form of fast clock to feed the above, enabled by gating the 555 output to the above clock input using a manual pushbutton. It will appear to be randomly changing as the human touch interacting with the pushbutton is essentially unpredictable.)

\$\endgroup\$
1
  • \$\begingroup\$ Thank you so much! That will help me do it \$\endgroup\$
    – Nicoo
    Sep 24 '20 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.