+ Post New Thread
Results 1 to 12 of 12
  1. #1
    Advanced Member level 5
    Points: 8,445, Level: 21
    d123's Avatar
    Join Date
    Jun 2015
    Posts
    1,505
    Helped
    343 / 343
    Points
    8,445
    Level
    21

    discrete sr latch not matching simulation version

    Hi,

    The schematic of the discrete SR latch works in the simulator correctly without the diodes from the NOR outputs back to the cross-coupled inputs. On the breadboard, it needs those two diodes from the NOR outputs to function the same as in the simulation, i.e. correctly/as will be needed in the circuit it will be used in.

    Expected functionality is:
    Power-up = Not Q high (triggered by cd1 to cd4 high blip at power-up)
    When cd4 goes high and coincides with timer b going high = Q high

    It does this in the simulation without those diodes and on the breadboard only with the diodes.

    It makes no sense to me as the diodes are backwards to how I would have expected to need to place them but the sr latch doesn't work a) without those diodes and b) with those diodes the right way round.

    Is there any (obvious) reason for this that someone else understands?

    Click image for larger version. 

Name:	discrete sr latch.JPG 
Views:	17 
Size:	67.4 KB 
ID:	150359

    Click image for larger version. 

Name:	sr latch closeup photo.jpg 
Views:	2 
Size:	220.0 KB 
ID:	150360

    I know a discrete sr latch is not an ideal method but beggars can't be choosers, as they say...

    Thanks.

  2. #2
    Super Moderator
    Points: 75,064, Level: 66
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,295
    Helped
    4082 / 4082
    Points
    75,064
    Level
    66

    Re: discrete sr latch not matching simulation version

    CMOS inputs are floating - you need pull-up/pull-down resistors at the gate inputs or they will try to use the leakage current or capacitance of the diode junctions to set the logic levels.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  3. #3
    Advanced Member level 3
    Points: 6,497, Level: 19
    Achievements:
    7 years registered

    Join Date
    Jul 2010
    Location
    Sweden
    Posts
    834
    Helped
    342 / 342
    Points
    6,497
    Level
    19

    Re: discrete sr latch not matching simulation version

    None of the 4 diodes makes any sense.
    The left diodes and the middle 4082 gates have no effect. The result is the same if you connect the left 4082 gates directly to the 4001 gates.
    What are you trying to achieve?

    As already mentioned, the CMOS logic inputs in the 4000 series must not "float". A defined logic level is needed.


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  4. #4
    Advanced Member level 5
    Points: 8,445, Level: 21
    d123's Avatar
    Join Date
    Jun 2015
    Posts
    1,505
    Helped
    343 / 343
    Points
    8,445
    Level
    21

    Re: discrete sr latch not matching simulation version

    Hi,

    Appreciate the input but have to differ on a couple of points...

    Quote Originally Posted by std_match View Post
    None of the 4 diodes makes any sense.
    Not so - the right-hand diodes make no sense but are making the breadboard version functionally identical to the simulation version.


    Quote Originally Posted by std_match View Post
    The left diodes and the middle 4082 gates have no effect.
    Not so - the middle 4082s are part of the sr latch, the left diodes are because I do not have any other "enable" signal to use so have had to stitch it together like that. Those diodes stop the different timed "enable" signals from going into the left-hand AND outputs.

    Quote Originally Posted by std_match View Post
    The result is the same if you connect the left 4082 gates directly to the 4001 gates.
    You appear to have a valid point there, I'll look at that later, and thanks.

    Quote Originally Posted by std_match View Post
    What are you trying to achieve?
    Prove what an absolute fool I am who continues with an idea long after it's apparent that it will be unreliable as a clock.

    Sometimes I am out for too many hours and in no way anywhere near enough remuneration for the hours worked and my goldfish are suffering excessively long "lights on" time as a consequence. That's bad for them and the tank environment in the long term.
    I wondered what I could do with whatever components I have to hand and so have cobbled together a poor-man's analog clock + LDR as an experiment to turn on the tank lights/LED strip every 12 hours. Two 555s and four CD4017s are the "clock", It's pathetic but not a joke and the best I have to hand that I can think of. CD4060 was a nuisance for creating long time delays as its outputs are all high...
    By now the circuit is more a case of seeing just how bad it is when finished r.e. timekeeping, I'm just enjoying the learning experience more than anything else. It's a super "clock", at ~20ºC with no exact resistors or capacitors it does 6 hours in 6 hours 12 minutes, I haven't sat through the 12-hour test yet and anyway, I need to finalise RC values.
    The poor-boy sr latch is to ensure the lights are off for 12 hours during the night and on for 12 hours during the day. The LED strip control circuitry triggered on, or off, at power-up and then every 12 hours is supposed to toggle.
    I've only been working on this for a week so I know I have a long way to go (before I give up and buy a plug-in timer) before it's as good as can be hoped for.

    Quote Originally Posted by std_match View Post
    As already mentioned, the CMOS logic inputs in the 4000 series must not "float". A defined logic level is needed.
    That's what I can't understand, when I tie the gates inputs with pull-down resistors, the sr latch doesn't work but it does only without them and with the silly backwards diodes to the right.

    A long way to go...

    Thanks!



    •   AltAdvertisment

        
       

  5. #5
    Advanced Member level 5
    Points: 37,575, Level: 47

    Join Date
    Mar 2008
    Location
    USA
    Posts
    6,071
    Helped
    1758 / 1758
    Points
    37,575
    Level
    47

    Re: discrete sr latch not matching simulation version

    Why all of the 4082 & diode complexity, when you could do the
    same with a 4011 NAND2 (using two of them as inverter so
    NAND -> AND)?

    The power-up behavior may just want an asymmetric burden
    on one of the SR core legs (or, a NOR3 w/ a RC network perhaps;
    you could use the "spare" two CD4001 channels to expand one
    side).

    All unused inputs should be grounded on all CMOS logic unless
    they have internal pullups (these, do not).


    1 members found this post helpful.

  6. #6
    Super Moderator
    Points: 75,064, Level: 66
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,295
    Helped
    4082 / 4082
    Points
    75,064
    Level
    66

    Re: discrete sr latch not matching simulation version

    Not for Goldfish (the cat would soon finish them off) but for something similar I made a £5 (~$7 US) timed light switch recently. Accurate within about 1 second and it tracks the daylight based on the date, latitude and longitude. So it basically turns on at sunset and off at sunrise every day of the year. Timing is from NTP over WiFi.

    I appreciate you are using 'bits from the junk box' but it does seem overkill for such a simple task.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  7. #7
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,846
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: discrete sr latch not matching simulation version

    Hi,

    Not so - the right-hand diodes make no sense but are making the breadboard version functionally identical to the simulation version.
    Without pullup/pulldown this is just "by accident", because without the diodes you don't have reliable, valid voltage levels.

    Don't rely on the "luck" of some "trial and error", better rely on specifications.

    Your "solution" may work with a simulatiin, but this does not mean it wil work with a real circuit.
    And even if it works on a real circuit, it does not mean it works with identical devices from the same production batch, different batches, different temperature, different supply voltage, different time....

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

  8. #8
    Advanced Member level 5
    Points: 8,445, Level: 21
    d123's Avatar
    Join Date
    Jun 2015
    Posts
    1,505
    Helped
    343 / 343
    Points
    8,445
    Level
    21

    Re: discrete sr latch not matching simulation version

    Hi,

    Quote Originally Posted by betwixt View Post
    Not for Goldfish (the cat would soon finish them off) but for something similar I made a £5 (~$7 US) timed light switch recently. Accurate within about 1 second and it tracks the daylight based on the date, latitude and longitude. So it basically turns on at sunset and off at sunrise every day of the year. Timing is from NTP over WiFi.

    I appreciate you are using 'bits from the junk box' but it does seem overkill for such a simple task.

    Brian.
    I have a Raspberry Pi type of device...bringing shame on the UK by not using it and stubbornly insisting on the learning experience of this analog attempt. I really love analog circuits, they're like jigsaws or something. It helps appreciate how hard it must have been to make far more accurate circuits in the days before MCUs and Arduinos and so on. I'm continuing with this as a prototype as I see this as yet another part of my learning about how devices work and how things can (or can't) work together.

    I like the sound of your circuit, sounds really great/smart, a bit beyond my make an LED blink programming "skills". I couldn't do that as sometimes/rarely the WiFi cuts out or depending on where I'm living, there are power cuts in bad weather. Still sounds like a super solution and nice you mentioned it.

    Thanks.

    - - - Updated - - -

    Quote Originally Posted by dick_freebird View Post
    Why all of the 4082 & diode complexity, when you could do the
    same with a 4011 NAND2 (using two of them as inverter so
    NAND -> AND)?

    The power-up behavior may just want an asymmetric burden
    on one of the SR core legs (or, a NOR3 w/ a RC network perhaps;
    you could use the "spare" two CD4001 channels to expand one
    side).

    All unused inputs should be grounded on all CMOS logic unless
    they have internal pullups (these, do not).
    Great, thank you. I have limited LOGIC design reasoning skills (over and over see a mistake I make is using too many components to achieve something in all manner of circuits, hopefully with experience I'll get better/less amateurish at that), so I really appreciate the advice and suggestion of the alternate 4011 version.

    The power-up part is seemingly very reliable by the Lord knows how many times I've tested it on a breadboard. My concern is (suffering a few 12-hour tests) to ensure the toggle needed at the end of the 12 hours doesn't occur due to random coincidence of all four CD4017s being on output 1 (pin 3) at the same time e.g. midway through the cycle; in theory it shouldn't but I'll make sure anyway. Reality is always the best way of seeing what the simulator predicts will happen. I have grounded all the unused inputs.

    Thank you very much for your advice, greatly appreciated.

    - - - Updated - - -

    Hi Klaus,

    Quote Originally Posted by KlausST View Post
    Hi,


    Without pullup/pulldown this is just "by accident", because without the diodes you don't have reliable, valid voltage levels.

    Don't rely on the "luck" of some "trial and error", better rely on specifications.

    Your "solution" may work with a simulatiin, but this does not mean it wil work with a real circuit.
    And even if it works on a real circuit, it does not mean it works with identical devices from the same production batch, different batches, different temperature, different supply voltage, different time....

    Klaus
    I got rid of the diodes last night and now it's working correctly. What's annoying me is that when I add pull-downs it doesn't toggle, without them it starts as desired and toggles when two inputs coincide in time. I'm testing all this on a breadboard, over and over and over again (unfortunately for me, as they say "like watching paint dry"). I share your observation that from device to device and especially things like going from breadboard to PCB there may/will be some unwanted changes to functionality and relying on luck is no design method. If I ever make this, it's only a one-off homebrew circuit anyway.

    You who understand hysterisis and comparators well, if I may ask you here - is having a fan turn on at 26ºC (3V) and off at 20ºC (2.936V) exaggerated/too small a window of operation and in practice the comparator will be turning on and off every two minutes? I want the "clock" circuitry to stay within this temperature range but I don't want the fan to be clicking on and off all the time. I don't get the hysterisis thing too much regarding what is desired and what is realistic/sensible.

    Anyway, many thanks for your valuable input, I do agree with you and appreciate your commenting these aspects.



    •   AltAdvertisment

        
       

  9. #9
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,846
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: discrete sr latch not matching simulation version

    Hi,

    You who understand hysterisis and comparators well, if I may ask you here - is having a fan turn on at 26ºC (3V) and off at 20ºC (2.936V) exaggerated/too small a window of operation and in practice the comparator will be turning on and off every two minutes?
    I miss your circuit for this.
    3.000V vs 2.936V:
    For an experienced analog circuit developer it should be no problem. For a hobbyist it will be difficult.
    Can't you choose a more suitable sensor?
    What about a digital sensor and a microcontroller?

    Switch ON/OFF timing:
    This depends on a lot of things: Temperatures, stored thermal energy, mass flow...

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

  10. #10
    Advanced Member level 5
    Points: 8,445, Level: 21
    d123's Avatar
    Join Date
    Jun 2015
    Posts
    1,505
    Helped
    343 / 343
    Points
    8,445
    Level
    21

    Re: discrete sr latch not matching simulation version

    Hi,

    Quote Originally Posted by KlausST View Post
    I miss your circuit for this.
    Oops, sorry about that ("Help! My circuit doesn't work. Guess what it looks like and give me a solution." syndrome caught me out this morning)...

    The resistor and inductor + parallel capacitor are supposed to very roughly/loosely emulate a motor (the fan). Vtemp is a substitute for an LM335 as there is no Spice model that I am aware of for this part nor for the LM35:

    Attachment 150366


    Quote Originally Posted by KlausST View Post
    3.000V vs 2.936V:
    For an experienced analog circuit developer it should be no problem. For a hobbyist it will be difficult.
    Why do you say it will be difficult? Is it related to all the variables of each component and the pcb design or the limited voltage range?

    Quote Originally Posted by KlausST View Post
    Can't you choose a more suitable sensor?
    Unfortunately, not. I have a spare LM35 somewhere or other that I can't find and three LM335s that I have found so I'll be working based on the LM335. I set the comparator voltage reference to 19ºC (2.924V/2.926V according to the simulator). With the hysterisis resistor values I chose it moves Vth high to 3V and Vth low to 2.936V. I understand that these are very approximate and would be a little different on a pcb, even measuring resistor values before selecting the most appropriate ones.

    I wish trimpots weren't so drifty with temperature (or so I have read), it would make a lot of things easier.

    Quote Originally Posted by KlausST View Post
    What about a digital sensor and a microcontroller?
    That's out of the question at present due to finances and I would like to at least finish the analog prototype version just to see how it turns out compared to the theory part of the design. I'm not expecting a precise circuit - that would be insane using 555s and 4017s, I'm more expecting something that would need re-setting every few days due to clock drift or other unexpected side-effects like using an LDR as a rough daylight gauge, I suppose. Also, I'm taking the design part seriously (otherwise what's the point...) but am very aware of my limitations and I couldn't even begin to know how different to initial start-up it would be with seasonal temperature and daylight length fluctuations, and ...it's called burn-in, isn't it?..., and component aging and so on after a few weeks or months.

    Quote Originally Posted by KlausST View Post
    Switch ON/OFF timing:
    This depends on a lot of things: Temperatures, stored thermal energy, mass flow...
    Fair point to make, crystal balls not included in advice...



  11. #11
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,846
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: discrete sr latch not matching simulation version

    Hi,

    on schematics or better say on simulation each connection (wire) has zero impedance and is free from capacitive or inductive influence.
    In reality each wire wire has impedance and will be influenced (capacitively and inductively) be voltage filed and magnetic field around.

    This means you have to care about that: Use a star point connection for GND. Especially: U2_GND, R2_GND, sensor_GND and maybe U1_GND.
    This clean analog start point should be free from power_current (R6, C3, C2), wire them separately.

    Additionally I recommend to use an RC lowpass for the "analog, low power section" R3, R9, U1, sensor

    If the wire to the sensor is long (causing voltage drop and introduced noise) then there is a benefit to put the U2 circuit to the sensor and wire both signals (V_ref and temp) within the same shielded (or twisted) cable). Thus the voltage drop and noise is introduced in both signals with about the same magnitude (best if both have matched source impedance) and thus the errors cancel out.

    *****

    Use low pass filters (or capacitors only) in the signal.
    * V_REF (U2 pin1)
    * and a RC froom sensor.
    Both need to be referenced to the analog star point.
    Mind: The low pass filters need to be installed close to the comparator (and they should be made with identical parts).

    *****
    Feedback / hysteresis check:
    See R8 and R10 as a voltage divider for the hysteresis.
    22k and 4M on a switching voltage (U1, pin 1) of about 12V. This gives a voltage hysteresis of 65.6mV
    --> your values seem to be correct.

    ******
    From your post I assume you don´t want "swtiching every two minutes". But what switching times do you expect?

    With some effort you may "force" it to the desired switching frequency.
    * either by generating a (small) triangle signal that is added to V_Ref or Temp.
    * or by adding a series capacitor to R10. tau = R10 x C. As a raw estimation. But will be influenced by other factors like noise, and thermal behaviour of the complete thermal system.

    Why do you say it will be difficult?
    See above. This is only a window of about 65mV. Without correct signal routing, stable references .. the errors may be larger than the window...

    You already relized thermal and aging drifts. Here a digital system has benefits. Also with introduced erros in the signal line (drift, DC, noise...) 10mV wil make your system unprecise, 60mV may cause a complete fail.

    The same value (60mV) of error on a digital signal line will not cause any change in function.

    *****
    You say "finance". It depends.

    Because of cost I personally will tend to a digital solution. But I have microcontroller boards as well as digital sensors laying around. Soldering effort of a digital system is less than on your analog solution. The risk for malfunction is less, too.
    And if you take any problems, errors, search for the cause of error, correcting the error, adjusting thresholds, adjusting timing into account....then I see a benefit in the digital solution, too.
    And if you take the time (development, soldering, error handling, calibration, part selection...) into account then the cost of the parts are ignorable.

    But I know that it depends on: personal taste, country, hobby/professional, parts delivery time, and so on....

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

  12. #12
    Advanced Member level 5
    Points: 37,575, Level: 47

    Join Date
    Mar 2008
    Location
    USA
    Posts
    6,071
    Helped
    1758 / 1758
    Points
    37,575
    Level
    47

    Re: discrete sr latch not matching simulation version

    You know, you could make that S/R latch with only one CD4011?
    The combo logic is another story.


    1 members found this post helpful.

--[[ ]]--