1
\$\begingroup\$

I am redesigning the control panel for a project I have been working on. I am using a rotary encoder to replace a set of 3 rotary dials, but I cannot use any microcontrollers or programming.

I plan on using the method here to decode the encoder. Then I will use two cascaded 4-bit binary counters to create an 8-bit counter. This will then be fed into a multiplexer to control the parts of the circuit that I want.

This panel will control a heater, so I want to user to see what they are setting the temperature to. My problem is that when the counter outputs 00000000 I want the display to show 25.0. Each tick on the dial will increase the counter by 1, but the display should go up by 0.1 until it reaches its maximum value of 39.0.

I created 'latches' (for lack of a better term) so that the counter doesn't loop when you decrease when at 0 or increase when at maximum. I need to make sure these 'latches' are in place for the display too.

How can I control a 7-segment display that can count up and down when I turn the dial right and left?

Most LED driver ICs that I found either don't count up or only take 4-bit inputs. I would like to avoid creating my own web of logic gates from scratch, but if need be I'll do it. I included the schematic of my counter, as this is where I believe I need to interface with the display .

Counter Schematic

\$\endgroup\$
30
  • 1
    \$\begingroup\$ Do you have to use 74 series logic ICs, or would a CPLD be suitable? Only mentioning it since a CPLD could be easier to wire-up, albeit it would need programming. \$\endgroup\$ Commented Aug 7 at 19:30
  • 1
    \$\begingroup\$ The article you reference uses a CPLD. You will have to create your own web of logic gates from scratch. Seems very painful. 00000000 + 250 (converted to binary) through 3 digit bcd to seven segments. \$\endgroup\$ Commented Aug 7 at 19:52
  • 1
    \$\begingroup\$ @Engineer1 One of the problems with a quadrature encoder, more so one without a HOME pulse -- which must be somehow observed before the absolute position can be worked out -- is there's no memory. It's all relative. With your current rotary dial situation, the setting is known on power-on. With a quadrature encoder, the prior setting is not known on power-on. You will need some kind of non-volatile memory for that. If you need someone to program this on an MCU, there are services for that. Both local and global. And if you lived in my area, I'd do the work for free. \$\endgroup\$ Commented Aug 7 at 20:13
  • 1
    \$\begingroup\$ @MarcusMüller, I'd edited the OP's question and put their no microcontrollers statement in bold (a rarity for me) in anticipation of this: a sea of voices trying to change the question. Microcontrollers were not invented exactly for this or for loads of other things, they really weren't. Really :-) As it happens here, CPLDs/FPGAs were invented for it. Besides that, no-one will learn decent logic design unless they go through this cycle of designing without. Stretch out with your feelings, Marcus... :-D \$\endgroup\$ Commented Aug 7 at 20:25
  • 2
    \$\begingroup\$ @Engineer1, look up CPLD on internet, and FPGA. They're chips that can be configured to act (pretty much) as any logic circuit you want - within max size and speed limits for the particular CPLD/FPGA chip you choose. So rather than putting ICs on a board and connecting them with tracks/wires, you configure the CPLD to acts as that same logic circuit. And you can then change it. You can also simulate it first so you can get it right, necessary with any circuit but essential for large circuits. Software's free, just teach yourself VHDL off the internet. Later, get a well-paid job doing it :-) \$\endgroup\$ Commented Aug 7 at 20:31

1 Answer 1

5
\$\begingroup\$

There is a bit of a substantial learning process needed to get to the end-point of functional and fully programmed CPLDs and FPGAs on a board that you can use for your project. Starting from where you appear to be that path is already long enough, let alone further learning barriers some packages may make manifest as you get closer to building something.

You are also toying with the idea of using existing binary (or decade, as has been recommended in comments) counters and possibly an adder. I'd like to help make you more aware of another approach, so that you can compare it with what you are currently considering.

The following is only an answer in so far as it may expose an approach that may fit within the limits you've discussed. But it's not a complete answer.


Suppose you had 9 control wires that needed to be sequenced in 4 steps, like this:

$$\begin{matrix} 8&7&6&5&4&3&2&1&0 \\\hline 0&1&1&1&1&1&0&1&1 \\ 0&0&0&0&1&0&1&1&0 \\ 0&0&0&0&1&0&0&0&1 \\ 1&1&0&0&0&0&1&0&1 \end{matrix}$$

That can be achieved in a number of ways. But there is a long-since standardized way of using AND/OR and JK FFs, which I'd like to show using the above simple state machine that moves through four states and starts over again.

(The process is very general and was partially achieved using PAL and PLA devices in the 1980s, and after.)

The idea is so simple that I took only 90 minutes to write up the following program to demonstrate it. (I took the time as I have a different use in another project. For now, its output isn't very polished.)

enter image description here

The binary for the control wires (and their decimal equivalents) are on the left side. But as FFs can often be more readily power-on reset to a state of zero, these values are modified and compressed into the four states shown under States. It always starts with 0 as the first state!

Underneath FF Outputs is listed all of the output wires and how they are taken from the JK FFs, showing whether to use the \$Q\$ or \$\overline{Q}\$, as well.

Implementing this in logic creates the following synchronous state machine:

enter image description here

(I used Neemann's DIGITAL program for the above image and to process the output table that my program produced on the right-hand side in CSV format.)

And that's it.

Here are the four states, in operation:

enter image description here

You can see that the outputs at each state are exactly as expected from the initial table. (On the next clock, after State 3 above, it will return to State 0.)

The idea can be used to also make up an arbitrary state machine that would directly drive the 7-segment displays, for example, without actually involving any binary or BCD formatting. It would directly control the individual LED segments in a stepped sequence.

It could not only do that, but it could also simultaneously generate any arbitrary set of control wires for any purpose you wanted. Including a special control wire to block the count-down when at 250 and block the count-up when at 390, for example.

Although I don't show it in the above example, the 90 minutes I spent coding the above program also can handle states that have the same value but exist elsewhere in the state machine sequence. It knows how to generate JK FFs when needed for such cases.


If you provide more details about how all this gets used and if I can see my way clear to writing more, I may try. But I have to stop here, given the limits of what I think I understand.

(Also feel free to ask questions about how one moves from a set of desired sequential states to a synchronous system implementing those states. It's not complicated and easy to explain, if you are interested in the process. What I've provided is more Moore than Mealy. But Mealy is also very interesting and not much different except in one specific detail. I can provide references to papers I believe may help, if desired.)

appendix

Here's a process that might be followed to develop the above state machine device:

enter image description here

The table in the lower-left corner identifies which of the JK FFs may be used to drive any specific J or K. This machine only had a few states, so it was much more likely than not to find outputs that would work as inputs. So no logic was required in this case.

For longer state sequences, it is much more likely that some logic will have to be added to the state outputs to get specific J and K sequencies. There are handy tools that can help find the right logic for these cases.

But the upshot is that if you use AND gates with as many inputs as there are JK FFs and if you follow that with OR gates, then you can implement any SOP expression needed. This is a very general approach that always works and was the basis for the importance of PALs and PLAs back in the day.

addendum

The number of JK FFs can be further reduced to just two. Since there are only four states, intuition might suggest further investigation into this idea.

As it turns out you can find that \$Q_0=\overline{Q_1} \wedge Q_2\$, \$Q_3=Q_1\vee Q_2\$, \$Q_4=Q_1\wedge Q_2\$, and \$Q_5=Q_1 \oplus Q_2\$. Since in all these cases only two JK FFs are required for the equations, four of the JK FFs can indeed be removed in exchange for some logic:

enter image description here

I've re-arranged the FFs in both of the above cases so that the right-most two JK FFs are arranged as a simple binary counter pair -- identical to each other in that respect. What the remaining four JK FFs do in the top case is handle the otherwise-required logic gates. There's four states, either way, of course.

What I used to do in the 1970's is look at the excess gates I had available (because I was using 7400 series logic packages) and make choices based on what required the fewer packages in total. In the 1980's and later, there were PALs, PLAs, CPLDs, FPGAs or ASICs (when working with a team having access to such things) and considerations would of course be different for those cases.

Hopefully, this expands your thoughts on the topic and that you can find an optimal arrangement for your specific case. Or stick with your own prior approach, if that works better for you.

\$\endgroup\$
4
  • \$\begingroup\$ So I understand what you are saying, conceptually. That I can use the combinational logic to directly convert my counter to the screen inputs. The part I don't understand is HOW you build that web of logic. Did you plug the inputs into some algorithm to find the least number of parts? Did you do the Boolean algebra by hand and then convert that equation into a program? I know I need to learn most of how to do this, but I'm not sure where to start. \$\endgroup\$ Commented Aug 12 at 12:30
  • \$\begingroup\$ @Engineer1 I also just edited the images to show you that the AND/OR logic isn't even required in this case. I'd used them because I wanted to illustrate the general approach and because I hadn't yet written the code to optimize them away. I have added that bit, now. So these newer diagrams are the result. \$\endgroup\$ Commented Aug 12 at 21:29
  • \$\begingroup\$ With the new pictures this makes a lot of sense. Thank you so much for your help! \$\endgroup\$ Commented Aug 13 at 12:12
  • 1
    \$\begingroup\$ @Engineer1 You can see why it is so easy to write software for this. And if this were just a display (it's not, I know) then the upper digit can only be a 2 or a 3. There's only two segments involved. So that digit only requires one FF. The other two digits require more, of course. You could also include still more FFs that would provide all needed direct control lines, without a mux. That would allow more than one line driven, if that were ever a desire (using parallel combinations of resistors to reduce their count?) \$\endgroup\$ Commented Aug 13 at 19:02

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.