Square wave triggers shorter square wave

Discussion in 'The Projects Forum' started by shaqywacky, Jan 6, 2011.

  1. shaqywacky

    Thread Starter Active Member

    Apr 1, 2009
    48
    0
    I working on a little electronics project and I've hit a little problem. There will be a square wave being generated with about a 50% duty cycle. What I need is something that will go High when the square wave goes high, but then go low before the High part of the wave ends. The ratio of square wave high to the circuits High doesn't matter that much, just that it's high long enough to allow a relay to switch but not so long that it's high most the time the square wave is high.

    I first thought about using a astable 555 timer but realized that it would stay high the whole time it's input is high.

    I don't have a whole lot of room left on my breadboard, and I'd really like to not have to buy another, so the simpler the better. I've tried a few things with capacitors but I can't get them to work.

    Any Ideas appreciated.

    Also, the picture is basically what I want to do.
     
  2. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    656
    You need to tell us what your square wave high and low times are.
     
  3. shaqywacky

    Thread Starter Active Member

    Apr 1, 2009
    48
    0
    On time (t1) is 1.79 seconds.
    Off time (t2) is 1.39 seconds.
    Duty cycle is 56.3%.
    Frequency is 0.315 Hz.


    Although if it's easier those can easily change, just as long as it's generally the same. And thanks for the quick response!
     
  4. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    You haven't told us what the operating voltage of the relay is or how long the positive pulse should be. You can shorten the high cycle with a single NPN but it wont be a square wave. Since your feeding a relay it won't matter much though, as at the contacts it will be.
     
  5. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    Odds are, Alberto's suggestion would be superior to this because you'll be utilizing much smaller values of 'C'. On the other hand, this NPN can be changed to a logic level FET; thus enabling much smaller values of 'C'. I used a 2N2222 because they're common as dirt.

    Note: Since I didn't know what voltages you are working with I used 12V but this should work with 5V too.

    EDIT: See post 27 for an updated version of this circuit.
     
    Last edited: Jan 9, 2011
    shaqywacky likes this.
  6. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    Here's a logic level Fet version. Note the Cap is much smaller.;)
     
    shaqywacky likes this.
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You seem to be using a 555 timer already, right?

    Adding a single diode will allow you to have a wide-range PWM output.

    Have a look at the attached; the left-hand 555 circuit allows a wide PWM range, the right-hand can only output greater than 50% duty cycle even if R4 were a pot.

    Note that R1 should be at least 1.2k Ohms for a 12 supply.


    I did not show bypass capacitors across the 555's supply pins, which are required; 0.1uF and 1uF are the minimums.
     
    Last edited: Jan 7, 2011
  8. shaqywacky

    Thread Starter Active Member

    Apr 1, 2009
    48
    0
    Thank you, that worked perfectly, I'm going to use the first one you uploaded because I don't have any mosfets but do have a 1000uf capacitor.

    And thanks to everyone else who suggested something.
     
  9. shaqywacky

    Thread Starter Active Member

    Apr 1, 2009
    48
    0
    One little problem I've noticed is that the capacitor doesn't discharge fast enough. At least this is what I think the problem is.

    What happens is that it works perfectly the first high pulse but then the second it doesn't go high again until another pulse or more later. And the next time it does go high, the time it stays high is much shorter than normal.

    I tried taking the output of the relay and using it to trigger a transistor to connect the ground directly, thus discharging the capacitor. But I couldn't get it to work.
     
  10. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    You're welcome, but before you go this rout, I confess that I didn't give a thought to how you were generating your original square wave. Are you generating the square wave with a 555, as Sgt.Wookie believes? If so, his suggestion makes much more sense; especially since my simulation should be considered best conditions. Having to use a 1000uF Cap is a bit clunky too!;)
     
  11. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    That's odd, I would expect your frequency to be much higher than stated for that to happen. Try reducing the value of C1. You can also reduce the value of R2 down to 1K. You haven't stated how long you need the contacts closed for but I suspect you just want a brief pulse. Are you sure you need a relay for what you're doing?
     
  12. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    Just thought of something! Are you sure you have C1 polarized correctly?
     
  13. shaqywacky

    Thread Starter Active Member

    Apr 1, 2009
    48
    0
    Yes, I am using a 555 timer as the square wave(although in the testing I just used a push to make switch and roughly generated the square wave that way).

    I have to capacitor correct, and just to make sure I switched it and it didn't work.

    I put a 10uf cap in, I would have used bigger If I had one, and made both R1 and R2 10 K and it seems like it might work. It's much shorter but I don't think it needs to be very long for what I need it for. I'll test it tomorrow to see if it'll work.

    Here's what I'm trying to do(basically). I'd always wondered how values were stored in circuits, then I got some relays(for fun) and messed around and realized I could store and clear a value with them. So I got the idea to create like a extremely simple computer. It would be a two bit adder which stores the output with the relays, then uses that answer for it's next calculation. I'd use a 555 timer as the clock(for controlling whether the relays were being written to or read from(never at the same time). That's where the square wave comes in. Then I had to clear each relay at the start of each write. If I just used the clock, nothing would be written because it would just write to it, then be cleared. That's where you guys come in, if it's only high at the start of the high then it could be written to afterward. I attached a diagram of the relay circuit. The switches simulate being cleared or set. Basically a positive charge as to applied to one of the transistors.

    I think that storing values may be easier with transistors but with my circuit testing software it's hard because it makes a lot of mistakes(EG Your first example, the one with the NPN, didn't work in it, but when I tried it in real life, it worked.), but also because I like the clicking sound they make.

    Hopefully that gives you a little better Idea of what's going on here.
     
  14. shaqywacky

    Thread Starter Active Member

    Apr 1, 2009
    48
    0
    And here's that relay diagram I promised. Forgot it.
     
  15. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    Well, I wish I could say that I understand your schematic, but I don't. For one thing, there don't appear to be any base resistors.

    FYI: To the best of my knowledge the evolution of electronic computers looks something like this....

    (1) Banks of latching and none latching relays, switches and indicator lamps. They filled a large room and were deafening. Relays and switches bounce, so capacitors and resistors were employed for debouncing and time delays.
    (2) Vacuum Tubes. They were much faster but took up about the same amount of real estate. They also generated much more heat.
    (3) Discrete solid state Transistors, Diodes and passive components.
    (4) Integrated Circuits; Gates, Counters, Inverters, Flip-Flops, Decoders, Encoders, Adders, etc, etc.
    (5) Microprocessors.

    In order to store data, some sort of memory must be employed. In your case 'Latching Relays',.. I would think.

    Anyway, since you're signal source is a 555, and regardless of the rest of your circuit plans, I see no reason for you not to use Sgt.Wookies approach to generate your pulses.
     
  16. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    10uF is very small (in this instance) and I'd be very surprised if the relay closes at all. If you were using a FET, that would be a much different situation and C1 could made very small, as shown in the FET schematic I posted. Do you understand RC Time Constants?
     
  17. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Since you've now stated that you have a 10uF cap available, here's how you could get your 555 timer circuit to have about 100mS ON time (high output) with a pulse repetition time of around 1.3 seconds.

    See the attached. Your mileage will vary, primarily due to the tolerances in capacitors.
     
  18. CDRIVE

    Senior Member

    Jul 1, 2008
    2,223
    99
    This is definitely the way to go. ;)
     
  19. shaqywacky

    Thread Starter Active Member

    Apr 1, 2009
    48
    0
    @CDRIVE I knew it wasn't a very good way to store values but It seemed to work when I tested it. I just woke up, so I'll test it to see whether it works all put together. I looked up RC Time Constants and I definitely do not understand it/them.

    @SgtWookie I'm a little confused about yours. Do I use two 555 timers? One for the original square wave and one for the second shorter square wave? Also, sorry for not responding to your first post, I meant to but somehow forgot.
     
  20. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Just one 555 timer. This replaces your original timer circuit. Why use two when one will do just fine? :)

    There's another option that I didn't go into - instead of having the output of the 555 timer sourcing current to your relay's coil, use it to sink current from the coil. That changes the PWM ratio that you'd need to ~87% high and ~13% low instead of 13% high and 87% low, so the R1/R2 values would need to change - but you wouldn't need the diode.

    555 timers are better at sinking current than sourcing it; CMOS versions in particular.

    Don't forget that you need to have a diode connected across each relay coil, cathode (end with stripe/ring) towards positive. Otherwise, the relay coil will zap whatever is the weakest link, trying to keep the current flow going.
     
Loading...