1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Duty cycle detection

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by earckens, Oct 11, 2017 at 11:36 AM.

  1. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,247
    Likes:
    961
    Location:
    Loveland, CO USA
    ONLINE
    You can right click on the LM339 and pick another part. Something like it.
    Many comparitors do not work well then their inputs are near VCC. Check the data sheet for input range. Most work from -0.4V to VCC-1.5V. So we might have to change things a little. At 80% duty cycle the input will probably be too high. Do you a supply other than +5V?
     
    • Like Like x 1
  2. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,242
    Likes:
    1,218
    Location:
    Cardiff, Wales
    Suppose the TTL levels at the input are 0.5V and 4V and you want an upper trip point at 80% duty cycle. That corresponds to a required 3.3V trip voltage.
    If the 555 runs from a 5V supply its nominal trip voltages are at 5V/3 =1.66V and 2*5V/3 =3.33V, so you might get away with that. But you can connect a resistor from pin 5 to ground or the 5V supply, thus adjusting both trip points simultaneously, so the upper trip point can be adjusted as required. However, the lower trip point will be half the upper one. This means the hysteresis is not independently adjustable.
    I got it from the Yahoo LTspice User Group. They have a big free library of various models.
     
    • Like Like x 1
  3. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    The duty cycle voltage is 4.5V to 55V, the same as the 555 supply voltage (same rail); so that will be a problem. I think I may forget the 555 unless Ronsimpson shows I may have done something wrong in the simulation.

    Thàt is being a steep learning curve today :nailbiting:

    Should I get the 339 from theit library?

    I tried using Eagle to connect to Spice (there is a shortcut), does not work, I checked all boards, forums etc, .. after 2 or 3 years Autocad still has managed to get that working, what a bunch of amateurs in that section.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,883
    Likes:
    498
    Location:
    Cleveland, OH, USA

    Forget about the Eagle link. I have been an Eagle user for many years and still am. The LTSpice link was poorly implemented and didn't work for me either for anything other than a simple design. I just use LT Spice as a standalone.
     
    • Like Like x 1
  6. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    You hit the final nail in that coffin. What a bunch of amateurs working in that section, I hope Autocad will go through that ratsnest with a rough brush; this is supposedly a big selling point and after all these years not a single user I found on internet about this topic has been helped by their own paid employees. Moronic situation.
     
  7. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    Hi ronsimpson, the whole circuit (duty cycle generation, detection, buffer, comparator,.. function on the same 5V supply.
     
  8. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    Hi ronsimpson, just a thought: can't I use a 555 in a buffer function?
    They sell less than half the cost of a CD4049 or CD4093.
     
  9. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,242
    Likes:
    1,218
    Location:
    Cardiff, Wales
    I don't understand (even assuming '55V' is meant to be 5V). If you low-pass filter (R1C1) a TTL rectangular-wave signal the result should be a voltage varying from about 0V to 5V (I used the range 0.5V to 4V, allowing for circuit losses) as the duty cycle varies from 0% to 100%.
     
    • Like Like x 1
  10. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,247
    Likes:
    961
    Location:
    Loveland, CO USA
    ONLINE
    A TTL signal does not go to 5 volts.
     
    • Like Like x 1
  11. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,247
    Likes:
    961
    Location:
    Loveland, CO USA
    ONLINE
    Red at 2V and green at 3V are the voltage levels to compare. (could be set by a POT)
    Green Vrc is the filtered digital signal. 0% at time 0, then high %, middle %, low %, middle %, high %, 0%.
    Vout in blue is the output. Set high if high % and set low if % is low. Will hold id % is in the middle.
    upload_2017-10-12_20-52-52.png
    V2 through V6 makes the signal. A2 ORs then together. A2 pulls down to 0V and up to 3.6V like a TTL gate.
    Nodes highIN and lowIN can be made by POTs.
    upload_2017-10-12_20-59-11.png
    RonS
     

    Attached Files:

    • Like Like x 1
  12. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    Hi, I am sorry, I had misunderstood your question.
    The actual duty cycle does not go lower than about 45% (the actual circuit producing this duty cycle is still in test phase too, I might get it too go lower in the future). I use an inverting buffer (currently 1x NAND gate from CD4093), but if needed that can be made non-inverting. When the duty cycle is 100%, then the inverter output is 0V, LP filter too. At the lowest duty cycle (currently about 45%) I measure 2.96V after the LP filter at pin 2 of the LM339.
     
  13. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    You are absolutely amazing!
    I will need some time to study this, thank you for taking the time for this.

    Why would A2 pull up to 3.6V only?

    Is there provision for hysteresis?
     
  14. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    I misexpressed myself, sorry. The system supply voltage is 5V. The signals ie duty cycle amplitude, buffer input and output, go between 0 and 5V.
     
  15. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    This is the circuit producing the duty cycle output to be monitored. I am experiencing a bit of instability when trying to increase the duty cycle variation range and would like to simulate it in LTspice but I need to get started with a component library (I will subscribe to the Yahoo user group alex_t referred to).
    The CD74HC132 I used a SN74HC132 as I had it lying around. C3 is changed to 10nF.

    Edit: I tap the duty cycle signal from pin 11.
     

    Attached Files:

    Last edited: Oct 12, 2017 at 11:39 PM
  16. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,242
    Likes:
    1,218
    Location:
    Cardiff, Wales
    Agreed. I was 'idealising' the levels.
     
  17. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,247
    Likes:
    961
    Location:
    Loveland, CO USA
    ONLINE
    Post #50.
    If your output is 0V/5V then at 100% the voltage at "RC" will be very close to 5 volts. The voltage comparitors input will be in the 2.5V to 4.8V range. Most voltage comparitors will not work when both inputs are too close to the VCC supply. With a 5V supply the input will only work from -0.4 to + 3.5V. (It is OK to have one input at 3.5V and the other at 5V) Some SPICE components do not work like real parts.
    Two fixes:
    1) Invert the signal so 100% = 0V and 0%=5V. Then the "RC" voltage be below 2.5V for 100% through 50%.
    2) Add a resistor across C2 to pull down the voltage. (voltage divider) Set the max voltage to no more than 3.5V.

    The picture is too small to read.
     
  18. earckens

    earckens Member

    Joined:
    Aug 25, 2016
    Messages:
    414
    Likes:
    5
    Location:
    Ghent, Belgium
    ______
    Quick reply from smartphone: the RC filter is fed with inverted signal. 100% duty cycle is 0V.
     
  19. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,247
    Likes:
    961
    Location:
    Loveland, CO USA
    ONLINE
    OK good.
    You are most interested in 100% through 50% which is 0 volts through 2.5 volts. I think this is good for 100% through 30%.
     
    • Like Like x 1
  20. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,242
    Likes:
    1,218
    Location:
    Cardiff, Wales
    If you were thinking of using a CD4093 (or other Schmitt gate) as a buffer anyway, it would be a simple matter to use another gate in the same package to do the thresholding/comparison function too, like this :-
    DutyCycleDetector2.PNG
    How much hysteresis do you actually need?
     
    • Like Like x 1
  21. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,247
    Likes:
    961
    Location:
    Loveland, CO USA
    ONLINE
    There are a number of these on the market. Set the frequency by Rset and DIV. Set the duty cycle by a 0 to 1V signal on MOD.

    upload_2017-10-13_10-58-2.png
     
    • Like Like x 1

Share This Page