Connect with us

Need help with a circuit

Discussion in 'Electronic Basics' started by Dark Alchemist, Dec 28, 2004.

Scroll to continue with content
  1. I need a circuit that can perform the following

    if (x < -1)
    x = 0
    else if (x < 1)
    x = sqrt(1 - (x^2))
    x = 0

    Now what I have done so far is the comparisons and have three
    comparators so at a given x the appropiate values are given (1, -1, 0).
    I have taken care of the square root, minus, and the square part as

    So, does anyone know what I use and how to do the if then else parts?
    3 outputs and only one is needed at the input to the rest of the
    circuit. I don't want a specialized ic for this so its just or, not,
    and, xor, etc...

    Thank you. :)
  2. Bob

    Bob Guest

    It seems like your equations should use a different variable name for the
    output of the function. For example:
    if (x<-1)
    where x is the input and y is the output, right?

    Also, if you look at your possible values for x then you'll see what the
    "else" part really is. You're on the right track by realizing that you need
    comparitors. Now, you just need to write out the truth table (for the
    comparitor outputs as the input to your logic function) and then just reduce
    the logic to drive your math (zero or sqrt(1-x^2)) function.

  3. Well, the posibilities of x would be a sine wave (for this test but
    could be anything in reality).

    If x <= 0 then y = 0 else if x <1 then y = sqrt(1 - x^2) is as far as I
    was able to simplify it.

    So, comparator A compares against 0 and comparator B compares <1 but we
    do not want the compare at B if A is true.
    This is as far as I got before my eyes started to glaze over, heheheh.
  4. Bob

    Bob Guest

    Suppose you had two comparators.

    One would would output a high (or low if you prefer) when X<-1.
    The second one's output would go true when X<1.

    Do you think that this would be enough comparators to cover all input (X)

  5. John Fields

    John Fields Guest

    If we assume that x is a voltage which varies over some range and that
    you want to know when the voltage is less than or equal to 0 volts and
    also when it's less than 1 volt, then you can set up two voltage
    comparators like this:

    | Vcc
    [10.0K] |
    | [10K]
    +----|+\ |
    | | >--+-->B
    | | Vcc
    | [10.0K] |
    | | [10K]
    +---------|+\ |
    | | >--+-->A

    and your truth table will look like this:

    x A B
    <=0V 0 1

    0<x<1 1 1

    So the logic to control your function machine would look like this:

    | Vcc
    [10.0K] |
    | [10K]
    +----|+\ |
    | | >--+----+
    x>---+--[10K]--------|-/ |
    | | Vcc |
    | [10.0K] | |
    | | [10K] +--B
    +--[10k]--------|+\ | and Y---+
    | | | >--+-------A |
    | +----|-/ |
    | | |
    | GND +---------E--------+
    | | |
    +------------------------>x| y = sqrt(1-x²) |-->y
    | |

    Where the line coming down from the AND would be an enable. When x was
    less than 0V it would go low, disabling the function machine, then
    when x was between 0V and 1V it would go high to enable the function
    machine, and when x rose to higher than 1V it would disable it again
    for as long as x remained higher than 1V.
  6. Hmmm, I was able to get all the way to the last part on my own but even
    looking at what you did (where I see an and gate) I am lost.

    So, I have two ouputs (A, B) and your logic table works. Now all I
    need to do is take the A AND B = 0 or 1 in this instance. I noticed
    that 0<x<1 1 1 . 1 and 1 is 1 while 0 and 1 or 1 and 0 = 0
    so would it not be simpler to (A AND B) * sqrt(1-x^2)? The product of
    that would be 0 or the sqrt part.
  7. Active8

    Active8 Guest

    That's very good! But you'd need an analog multiplier that works at
    DC if you go there. John simply used A && B as an enable, a much
    better approach.
  8. Hmmm, I am not grasping beyond the and part from what he was telling
    me. :(
    We have A && B then what? From this point on is where I got lost.
  9. John Fields

    John Fields Guest

    Yes, that's essentially what I've done by ANDing the comparator
    outputs and giving you that AND as an enable. Not knowing what your
    square-rooter-subtractor circuitry looks like, that was as far as I
    could go. If you can perform the ANDing in your computational
    circuitry, go for it!
  10. I am tinkering with a strictly opamp solution but I need some idea of
    the DC accuracy you need, and the settling time or maximum frequency
    you intend ot pass through this function. Keep in mind that at +-1
    volt in, the gain is infinite.
  11. So, was my simplification still holding the same as the original?
    Btw, thank you everyone for you help. :)
  12. Active8

    Active8 Guest

    They turn the sqrt circuit on or off. Off would be x < 0 OR x > 1.
    So when the sqrt is off, it should output zero.

    My point was that if you try to do (A && B) * sqrt, the * implies
    analog multiplication wheras && or AND is digital multiplication.

    Now you can analog multiply sqrt with 1 or 0, the circuitry won't be
    as simple, however. So use A && B as a control, i.e., an enable.

    I still think that you coming up with (A AND B) * sqrt(1-x^2) was
    very good. It's true.
  13. John Fields

    John Fields Guest

    Dunno, for sure...

    Modifying the circuit a little and looking at the circuit and the
    truth table, we have:

    | Vcc
    [10.0K] |
    | [10K]
    +----|+\ |
    | | >--+----+
    x>---+--[10K]--------|-/ |
    | | Vcc | +-------+
    | [10.0K] | | 0V---|b |
    | | [10K] +--B | _ |
    +--[10k]--------|+\ | and AB------|a/b y|---y
    | | | >--+-------A | |
    | +----|-/ +----|a |
    | | | +-------+
    | GND | S1
    | |
    | |
    | +-------+ +-------+
    | 1V--|1 | +----------------+ |
    | +------+ | 1-x²|--|1-x² sqrt(1-x²)|--+
    +--|x x²|--|x² | +----------------+
    +------+ +-------+

    The blocks on the bottom are your circuits, and sqrt(1-x²) is shown as
    being routed through a switch where the output (y)is either sqrt(1-x²)
    or 0, depending on whether is x is <=0V, between 0V and 1V, or >1V.

    The AND gate only goes true when 0V<x<1V, with the result that the
    switch will be turned off when x is outside the limits, and at those
    times y will be equal to 0V, like this:

    x A B y
    <=0V 0 1 0

    0V<x<1V 1 1 sqrt(1-x²)
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day