New to Electronics, Need Help with Splitter Circuit

Thread Starter

Muhmmbles

Joined Feb 26, 2017
11
Hello guys,

I would like to build a circuit that follows the attached Logic.png; however, I am not sure how to do it.
So what we have are 3 control signals that route my digital input to ONE OR MANY digital outputs.

I have considered using a Demux but from what I understand, it can only send the input to one output? It can't ever send to more than one output at a time?

I believe one can do it using simple discrete logic (AND, OR, etc), but would like some help building the logic as I am new to this.

I'd like to stick to discrete/specialized logic aka no mcu. It'd be great if someone can help me out.
Logic.png
 

danadak

Joined Mar 10, 2018
4,057
You said no MCU, so ignore the fact PSOC does have an MCU
on it, just don't use it.

PSOC has a GUI capture schematic capability where you can draw logic
elements, interconnect internally and to external pins. Write no code, but
you have to hit the build button as it generates startup code that "normally"
one simply accepts. Think small FPGA.

The approach would be to use either the LUT component (a component is
an onchip resource) which is a state machine when clocked version is used.
Or use the state machine wizard, a tad more involved, to create function.
In this case you would not use it clocked, just as combinatorial lookup table.

See attached.

Your design can all be done in this chip. There are lots of videos on youtube
and Cypress website, "PSOC Creator 101" series, 16 videos I think, most
10 - 15 min in length. Just first 6 or 7 probably enough.

Design tool is free, PSOC Creator - http://www.cypress.com/products/psoc-creator-integrated-design-environment-ide

Board to use - http://www.cypress.com/documentation/development-kitsboards/psoc-4-cy8ckit-049-4xxx-prototyping-kits

At a later time you can think about using all its other capabilities,. like analog,
(A/D, OpAmp, DAC, Comparators), COM, LCD, timer, counter, PWM.....on
other projects.

If you need this to be a synchronous design that's easy to use LUT in a clocked
mode. Also at a later time, if of interest, you can create your own components
using verilog or as shown in attachment via schematic capture.


Regards, Dana.
 

Attachments

Last edited:
You can "cheat" and use a 1 of 8 data selector for each output. The address lines become the control lines and the selected output is set. Look at the function table on the first page here http://www.ti.com.cn/cn/lit/ds/sdfs023a/sdfs023a.pdf

The select lines are your input and for each value of A,B and C, you tie D* (the input) to the output you want. (a 1 or zero) for the output Y.

You know know the type of part, so you have to select the logic family and find a part within the family.

The "real way" is to do a "Karnaugh map" or a bunch of boolean logic math.
 

AnalogKid

Joined Aug 1, 2013
10,986
There are three control inputs and one data input, and four data outputs. The most basic approach would be four 4-input AND gates (one for each output signal) and three inverters (one for each control line), but there is a more simple way. Start with the output conditions that follow a standard binary address pattern, then add logic for the exception cases.

ak
 

Thread Starter

Muhmmbles

Joined Feb 26, 2017
11
I do not think I explained myself correctly. I have provided two image examples.

I have one input and three control inputs.These control inputs tell my input which output to go to; the trick is, it could be ONE output or MULTI outputs (as such, the AND solutions do not work from what I understand).

Now I was able to create a solution using an MCU (which is why I'd like it to be disregarded), but I feel there could be a cheaper solution if I can figure out how one can do this using discrete/specialized logic components. The reason I pointed out demux is because of it's ability to take one signal and have many possible outputs, unfortunately, you can still only have ONE output. Is there a way to have a demux that can send to multiple outputs at once? If so, a link would be great since my Google searches come out empty.

The goal is to have a circuit that would be cheaper than an mcu. P.S FPGAs and Asics are too expensive for such a simple task.
example.png
 

AnalogKid

Joined Aug 1, 2013
10,986
The table in post #1 refers to *four* possible outputs, 0, 1, 2, and 3. Please correct the table so we have a good starting point.

ak
 

Thread Starter

Muhmmbles

Joined Feb 26, 2017
11
Thanks for pointing that out ak, I made a mistake in my logic table. I'm very sorry for that! Here is the uploaded logic table without typos (hopefully).
Logic.png
 

Thread Starter

Muhmmbles

Joined Feb 26, 2017
11
Oh I see it now, thank you Kjeldgaard and ak.

While I have this post though, I am curious about three things:

1. Demux that can send to two outputs at once? Is this possible without having to create my own demux with an FPGA?
2. The frequency of my input if 500kHz. Now my MCU has an internal oscillator of 1MHz in my original design. Would I be able to say that with a few lines of code to direct the input, the MCU's timer is sufficient to capture the signal or am I missing out on a few factors?
3. An MCU @ 1MHz vs 3 AND gates, which one would be faster? Is there a way to calculate that using datasheets?
 

AnalogKid

Joined Aug 1, 2013
10,986
A uC is a serial state machine. To do anything it has to step through a series of instructions. This can happen only as fast as the uC clock and its instruction decoder allow. With a 1 MHz clock it will take several microseconds to do even a simple task like add 1 + 2.

A NAND gate is 1000 times faster. It has a propagation delay of a few nanoseconds, depending on the technology used (CMOS, faster CMOS, TTL, Shottky, ECL, etc.). That's as fast as it gets.

ak
 

WBahn

Joined Mar 31, 2012
29,976
1. Demux that can send to two outputs at once? Is this possible without having to create my own demux with an FPGA?
Generally no. A typical demultiplexer takes a single input signal and routes it to one of a set of output lines. This is not to say that some specialty demux circuit doesn't exist that does exactly what you want.

You could take a 3:8 decoder, such as the 74xx138, and then selectively OR those outputs that you want active under a particular set of input conditions. This provides a general solution to your problem. But because your specific problem is so well structured, the three AND gate solution is much simpler.

2. The frequency of my input if 500kHz. Now my MCU has an internal oscillator of 1MHz in my original design. Would I be able to say that with a few lines of code to direct the input, the MCU's timer is sufficient to capture the signal or am I missing out on a few factors?
Is the input signal synchronous with the MCU clock? Doesn't sound like it. If not, you have a number of issues that you need to deal with.

What is the instruction clock rate? Some MCU's execute one instruction per clock cycle while others require multiple clock cycles per instruction (four is a pretty common factor). Even at one instruction per clock cycle, "a few lines of code" translates into a loop that is a lot slower than 500 kHz.

3. An MCU @ 1MHz vs 3 AND gates, which one would be faster? Is there a way to calculate that using datasheets?
The three AND gate solution will almost certainly be faster. The key parameter you are looking for in the datasheet is the propagation delay. Even for the slow families this is likely to be on the order of 10 ns. So you are looking at being able to route signals that are changing in the 10 MHz to perhaps 50 MHz range without too much difficulty.

Also, you indicated that you wanted a discrete design instead of an MCU-based design because of cost. Don't assume that there's much of a cost difference; low-end MCU's are very price-competitive with discrete logic chips. Even in single-quantities, DigiKey sells MCUs in the 30 to 50 cent range. PLD's, FPGA's and CPLD's can be had for the 90 cent to $1 range. By comparison, their cheapest quad AND gate chip available in single units right now is 35 cents. Now, if you want to by 2500 of them at a time, that's a whole different story as the price breaks on the discrete logic chips tend to be a lot steeper than the more complex chips.
 

Thread Starter

Muhmmbles

Joined Feb 26, 2017
11
Wow that's great information! Thank you.

@WBhan, so if my input signals comes in at 500kHz and my MCU executes one instruction per clock cycle with 10 lines of instructions (just as an example), would I need a 50MHz clock MCU at minimum? Or basically, what's a good way to estimate the clock cycle required for my MCU?
 

WBahn

Joined Mar 31, 2012
29,976
Wow that's great information! Thank you.

@WBhan, so if my input signals comes in at 500kHz and my MCU executes one instruction per clock cycle with 10 lines of instructions (just as an example), would I need a 50MHz clock MCU at minimum? Or basically, what's a good way to estimate the clock cycle required for my MCU?
I think you meant 5 MHz, didn't you?

That's in the ballpark, but there's a number of details that can trip you up.

If you are polling the inputs (as opposed to servicing interrupts) and your inputs are asynchronous to your MCU instruction clock, then you have to allow for the possibility that an input transitions just before or just after your MCU's clock. With multiple input, this can lead to disastrous consequences because one input might change just before the instruction clock and the other might change just after and, as a result, your program reads a completely wrong input value. One way to deal with this is to have an instruction clock that is much faster than the input data rate and then test for a new input by requiring that you read the same overall input on multiple successive passes. This is roughly akin to software switch debouncing.

The first think you need to do is look at your system and ask yourself what happens if the inputs (both the data and the channel selects) are read in the middle of a transition when some have changed and others have not. Unless they are synchronized, this WILL happen, so then you have to decide what your MCU needs to do in response. If it is okay for the data to be sent out on the wrong channels briefly, then the question is how briefly is brief enough. That will be a big determining factor in how fast your loop has to be.
 

AnalogKid

Joined Aug 1, 2013
10,986
so if my input signals comes in at 500kHz and my MCU executes one instruction per clock cycle with 10 lines of instructions (just as an example), would I need a 50MHz clock MCU at minimum?
It is a bit more complex than that. Many microprocessors take more than one clock cycle to execute an instruction. Also, we're talking assembly language instructions here, not C++ or any other high level language. Some of those instructions can take dozens of processor clocks.

ak
 

Thread Starter

Muhmmbles

Joined Feb 26, 2017
11
All I'm doing is a bunch of IF statements,
If (!config0, !config1, !config2(
{ ...;
}

Sorry if I sound ignorant, but that does not seem like it would take much? In the case that it does, I retract my thought haha.

Moreover, is there a reason I'd be using assembly language over C++? Is this to simplify?

If you were to recommend a mcu for me to use for this specific application (500kHz input signal w/ a few IF statements to reroute, which one would you recommend? I think it would give me a great baseline to work from. Thanks in advance
 

AnalogKid

Joined Aug 1, 2013
10,986
I would not use a computer of any kind. To capture the input changes you have to either poll them continuously or have four interrrupt inputs. Polling has to be done so fast that you can capture an edge within a certain period of time. For example, 500 kHz waveform has two edges, so that is 1 million edges per second to be captured, processed, and acted upon. If you want the output edge to be within 10% of the timing of the input edge, then you have to sample the inputs at least 20 million times per second so that the quantizing error is less than 100 ns. This quickly becomes undoable with a MCU.

Interrupts start out easier because you just sit and wait for something to happen; but an interrupt service routine is not a simple piece of writing. The complied code will be hundreds of cpu instructions, again very difficult to execute in time to catch the next event.

And that is the crux of the problem - the timing unpredictability of the inputs. If the control lines can change at any time, then no matter how you do it there will be a timing error induced into the output signals by the CPU processing time.

ak
 

WBahn

Joined Mar 31, 2012
29,976
If you are using a high level language, then you are likely chewing up LOTS of clock cycles.

Are you sure that that is your if() statement test? Unless there's some special syntax for your MCU, that's a comma-separated expression in which the value of the expression is simply the value of the last expression in the list. I don't think that's what you want.
 
Top