Author Topic: change pulse width of a signal  (Read 9551 times)

0 Members and 1 Guest are viewing this topic.

Offline EteslaTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: us
change pulse width of a signal
« on: February 04, 2017, 10:57:55 pm »
I was wondering if anyone knew of a way to take a square wave of 'any' frequency (200 - 20000 hz range) with a 50% duty cycle and change the duty cycle to something like 2 -7%. This lower duty cycle should hold for any of the frequency's within the range, and the input frequency would be variable within the range (its an audio signal).

My first thoughts were to feed the audio signal which should have a maximum magnitude of about 7V peak to peak into something like a ucc37322 to get a square wave of consistent magnitude out at the same frequency with a 50% duty cycle I think. Then I thought I should run that through an op amp configured as an integrator to get a triangle wave of the same frequency out. Then run the triangle wave through a schmitt trigger with pots where the resistors would be so I could have a variable cutoff values to cut the triangle wave off at different voltages resulting in a square wave output of the same frequency as the sin wave audio input at a variable duty cycle.

Some things to note:

I am relatively new to electronics and am not sure on all of my logic and terminology.

The audio input to the circuit would be from a guitar fed through an op amp (lm386 probably), so the audio I am trying to represent is "simple". Not voices or a whole band or anything like that.

Thanks!
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 6919
  • Country: nl
Re: change pulse width of a signal
« Reply #1 on: February 04, 2017, 11:17:04 pm »
Would be easiest to just do it with a micro :p

The triangle wave would have variable amplitude based on frequency, so you wouldn't get a consistent duty cycle. You could have a peak detector to detect the amplitude of the triangle wave and then divide that with a pot to set the trigger level for the triangle wave. Although the frequency range and thus the amplitude range and noise/offset errors might become a limitation.
 
The following users thanked this post: Etesla

Offline timb

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
change pulse width of a signal
« Reply #2 on: February 04, 2017, 11:25:54 pm »
You could convert the square wave to a triangle wave, then run it into the inverting input of an op-amp or comparator. Let's say your square (now triangle) wave is 0-5V; if you apply 2.5VDC to the non-inverting input of the comparator it will output a 50% duty cycle square wave at whatever frequency the input triangle wave is. Now if you raise the voltage on the inverting input the duty cycle will increase (up to 100% at 5V); or it go down (0% at 0V) if the voltage is lowered.







That's how I'd do it, anyway. :)
« Last Edit: February 04, 2017, 11:27:37 pm by timb »
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 
The following users thanked this post: Etesla

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: change pulse width of a signal
« Reply #3 on: February 04, 2017, 11:29:04 pm »
First link both a generator and a scope.

Here is a sound card oscilloscope, freebee. You need to protect
sound card inputs, so google "sound card input protection", a number
of hits. Its is also a function generator, you might need to use OpAmp
scaling on sound card output so you can offset it for use in digital
circuit work.

https://www.zeitnitz.eu/scope_en

http://www.zelscope.com/



Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 
The following users thanked this post: Etesla

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: change pulse width of a signal
« Reply #4 on: February 04, 2017, 11:38:36 pm »
I was trying to do similar some time ago, a 556 looked OK, I was getting up to 2Mhz out of it and pulse widths down to 350ns at the higher frequencies, 20Khz should be no problem. The values of R3 and the MS pot are the values for the CMOS versions with 100k x3 inside them.
.  That took much longer than I thought it would.
 
The following users thanked this post: Etesla

Offline EteslaTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: us
Re: change pulse width of a signal
« Reply #5 on: February 05, 2017, 12:18:23 am »
WOW! I had no idea I would get responses so quickly! Thank you all!

Marco, I thought about trying to use a micro controller, but my experience with micro's is pretty limited. Just some arduino stuff here and there. I have tried making a frequency counter with arduino before, but to no avail as my code only seemed to work at very low frequency's.... Thanks for the warning about the amplitude being dependent of frequency. That would have been a nasty surprise when the time came to breadboard this.

StillTrying, I really like the idea of trying to do this with two 555's since I have like a million of them lying around. I will definitely try out the circuit you posted. It looks easy enough to test out.

Timb, I think I understand you method but am unsure if what Macro was saying about the square wave having a variable amplitude with frequency will make it unusable....

Thanks again!
 

Online tautech

  • Super Contributor
  • ***
  • Posts: 29329
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: change pulse width of a signal
« Reply #6 on: February 05, 2017, 12:28:27 am »
Seems like nobody remembers how to use a 4047 monostable.  :scared:
Avid Rabid Hobbyist.
Some stuff seen @ Siglent HQ cannot be shared.
 
The following users thanked this post: Etesla

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: gb
Re: change pulse width of a signal
« Reply #7 on: February 05, 2017, 12:59:59 am »
Seems like nobody remembers how to use a 4047 monostable.  :scared:

Woh, I never know a monostable can produce constant duty cycle output with varying output frequencies.

Care to show us how it can be done?
 
The following users thanked this post: Etesla

Offline Paul Moir

  • Frequent Contributor
  • **
  • Posts: 926
  • Country: ca
Re: change pulse width of a signal
« Reply #8 on: February 05, 2017, 01:06:41 am »
If the input range were not so great, say 10:1 or less then a PLL (phase locked loop) frequency multiplier could work. Digitally divide your input signal by 2 to get a true 50% input duty cycle to the PLL, then multiply it by 20.  Take the 20x oscillator output from the PLL and generate one pulse in twenty with say a pair of 4017.  I think that should give you a fixed 5% duty cycle?
PLLs are kind of neat but they take some time to lock which might be a problem for you, and would really only work in the 200Hz to 2KHz range.  That said, you suggested that the input signal might be a guitar?  If so why would it need to go over 2KHz?  In fact, you'll likely need do do some pretty heavy filtering on it to get the "note" you're looking for.  The output of an electric guitar has a lot of harmonics; check youtube for "guitar oscilloscope" to see what I mean.  Otherwise it would sound like a tuning fork.

A micro is probably easier.  I can't help but think compensating your triangle wave generator would be easier too.  :)

(tautech - I think he's looking for something that will put out a fixed duty cycle but variable frequency with the input dependant on frequency)
 
The following users thanked this post: Etesla

Online tautech

  • Super Contributor
  • ***
  • Posts: 29329
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: change pulse width of a signal
« Reply #9 on: February 05, 2017, 01:12:20 am »
Seems like nobody remembers how to use a 4047 monostable.  :scared:

Woh, I never know a monostable can produce constant duty cycle output with varying output frequencies.

Care to show us how it can be done?
http://www.ti.com/lit/ds/symlink/cd4047b.pdf
Table P2.
Avid Rabid Hobbyist.
Some stuff seen @ Siglent HQ cannot be shared.
 
The following users thanked this post: Etesla

Online tautech

  • Super Contributor
  • ***
  • Posts: 29329
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: change pulse width of a signal
« Reply #10 on: February 05, 2017, 01:18:25 am »

(tautech - I think he's looking for something that will put out a fixed duty cycle but variable frequency with the input dependant on frequency)
Maybe then a 4046 would be better.
Avid Rabid Hobbyist.
Some stuff seen @ Siglent HQ cannot be shared.
 
The following users thanked this post: Etesla

Offline EteslaTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: us
Re: change pulse width of a signal
« Reply #11 on: February 05, 2017, 01:24:48 am »
Tautech, I think you nailed it. The 4047 in monostable mode with my input square wave does look extremely promising as limiting the on time of each pulse is really what I'm aiming for (I just thought adjusting the duty cycle would be an easier approximate way to do this). If I understand correctly from the data sheet, connecting a cap and resistor of correct values to pins 1,2,&3 and putting my square wave to pin 8 with pin 9 pulled low and 4 pulled high will result in output pulses of my on time determined by the cap and resistor at the frequency of my input square wave? Sounds exactly like what I need. Does anyone have any actual experience with this chip in monostable mode?

Paul Moir, You are completely right about not needing to go over say 2 khz. Im relatively new to audio and my scope of frequency is not as attuned as yours perhaps is :) I just took some scope shots of my guitars output and the harmonics didn't appear visually to be that large a part of the waveform, but I'm sure your right and I will hear the difference.
« Last Edit: February 05, 2017, 01:41:07 am by Etesla »
 

Offline Paul Moir

  • Frequent Contributor
  • **
  • Posts: 926
  • Country: ca
Re: change pulse width of a signal
« Reply #12 on: February 05, 2017, 01:33:18 am »
(tautech - I think he's looking for something that will put out a fixed duty cycle but variable frequency with the input dependant on frequency)
Maybe then a 4046 would be better.
Then again, maybe not!  Looks like you've got superior situational awareness.  :)
 

Offline EteslaTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: us
Re: change pulse width of a signal
« Reply #13 on: February 05, 2017, 01:44:09 am »
LOL I didn't see that comment until paul pointed it out. Very impressive.
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: change pulse width of a signal
« Reply #14 on: February 05, 2017, 01:49:40 am »
StillTrying, I really like the idea of trying to do this with two 555's since I have like a million of them lying around. I will definitely try out the circuit you posted. It looks easy enough to test out.

Well I know it worked in practice almost exactly as in the simulation because I did it! - I'll find a pic in a minute.

If you're wanting to get the whole 200:20khz, 100:1 on the one pot range I think you'd need a reverse log pot to get a smooth increase in freq with clockwise rotation.

If you're using bipolar 555s with internal 5ks you'll need to lower R3 to about 2k and the M/S pot to about 1k.

Ed: Even at the curved flattening top of the charge curve I could still set quite a large MS ratio, until about 2Mhz.
« Last Edit: February 05, 2017, 02:01:16 am by StillTrying »
.  That took much longer than I thought it would.
 

Offline EteslaTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: us
Re: change pulse width of a signal
« Reply #15 on: February 05, 2017, 01:55:06 am »
Still trying, I think I may have misunderstood your original post... What I was aiming for was to be able to change the duty cycle / on time of a square wave input while maintaining the frequency, not creating a square wave of a specific frequency with a variable duty cycle, although this sort of diy function generator was a thing of interest to me just a few weeks ago before I bought one. Still gonna build it out though!
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: change pulse width of a signal
« Reply #16 on: February 05, 2017, 02:12:17 am »
What I was aiming for was to be able to change the duty cycle / on time of a square wave input while maintaining the frequency, not creating a square wave of a specific frequency with a variable duty cycle,

I've had the HC4046's data sheet open for 2 days, and currently going through this
CMOS Phase-Locked-Loop Applications (Rev. B) - Texas Instruments
www.ti.com/lit/an/scha003b/scha003b.pdf

But I still don't think it's going to be easy if, you don't have control of the frequency of the incoming signal.
.  That took much longer than I thought it would.
 
The following users thanked this post: Etesla

Offline Brumby

  • Supporter
  • ****
  • Posts: 12379
  • Country: au
Re: change pulse width of a signal
« Reply #17 on: February 05, 2017, 02:12:57 am »
I am truly impressed with the variety of approaches offered here.

MCUs... comparators... PLLs...  Lots of effort when the hard work has already been done.  We have the operational frequency reference with a choice of some nice positive or negative going edges for triggering.  Just create a new pulse of whatever width you want from the trigger.  Simple.

4047 in monostable mode could not have been better designed for this application; the 555/556 solution is a classic - and you could probably put together a 2 transistor monostable flip flop to do the job.
 
The following users thanked this post: Etesla

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: gb
Re: change pulse width of a signal
« Reply #18 on: February 05, 2017, 02:37:53 am »
I wonder why some people have trouble understand the difference between constant pulse width and constant duty cycle of a varying frequency signal?

The suggestion of converting the square wave into a triangular wave would work if there are active AGC control about the amplitute of the triangular wave, like in the following circuit. However, it would take quite many cycles for the AGC to work its magic which might be too long for the original poster.

An some comments about the PLL approach. I like the idea but one does not need to obtain a 50/50 duty cycle wave in order to feed into the PLL. The multiplication ratio needed is x40 as a binary division is done first. By the way, one can only get divide-by-seventeen using two 4017s, but the resultant 5.9% duty cycle fits the OP requirement.

 
 

Offline Paul Moir

  • Frequent Contributor
  • **
  • Posts: 926
  • Country: ca
Re: change pulse width of a signal
« Reply #19 on: February 05, 2017, 02:43:22 am »
Because Post #11 sentence 2 redefines the acceptable solution to include a fixed pulse width.
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: gb
Re: change pulse width of a signal
« Reply #20 on: February 05, 2017, 03:06:14 am »
Because Post #11 sentence 2 redefines the acceptable solution to include a fixed pulse width.

Totally missed that vital point. My apology to the forum.
 

Online tautech

  • Super Contributor
  • ***
  • Posts: 29329
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: change pulse width of a signal
« Reply #21 on: February 05, 2017, 03:11:48 am »
The VCO portion or a 4046 is a neat bit of kit too when needed.
I did think a 4013 as a resetting oneshot might work too for the OP but sometimes you need to gang a few of these various logic IC's together to get the result you seek.

Plain good old Glue Logic.  :)

Old logic IC's these may be, but sometimes the simplest and easiest for someone that can't program yet like me.  :palm:

Stock upon them before they're no longer available.  |O
Avid Rabid Hobbyist.
Some stuff seen @ Siglent HQ cannot be shared.
 

Online tautech

  • Super Contributor
  • ***
  • Posts: 29329
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: change pulse width of a signal
« Reply #22 on: February 05, 2017, 03:18:27 am »
Does anyone have any actual experience with this chip in monostable mode?
Got a breadboard, a frequency source and a scope ?

This site can be handy for checking the functionality of many logic blocks but maybe not this time for the OP.
https://tams.informatik.uni-hamburg.de/applets/hades/webdemos/index.html
Avid Rabid Hobbyist.
Some stuff seen @ Siglent HQ cannot be shared.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17098
  • Country: us
  • DavidH
Re: change pulse width of a signal
« Reply #23 on: February 05, 2017, 04:26:17 am »
Start from the output and work back.  If the output precision duty cycle square wave has a constant peak-to-peak amplitude, then its average is proportional to its duty cycle.  So integrate the output to provide a feedback signal to control the slope of a ramp generator which is triggered and reset by the source frequency.  A fixed comparator provides the precision duty cycle output.  Easy peasy.

Triggered Ramp Generator to (current source driven ramp generator with reset)
Fixed Level Comparator to (comparator)
Precision Output Generator to (analog switch or CMOS gate)
Integrator back to (operational integrator)
Triggered Ramp Generator

If the frequency operates over a limited range, then just convert the input to a triangle wave and have the feedback go to the comparator instead.  In this case the wide frequency range will cause problems because at the high end, the triangle amplitude would be small increasing noise.
« Last Edit: February 05, 2017, 01:42:37 pm by David Hess »
 
The following users thanked this post: Etesla

Offline Marco

  • Super Contributor
  • ***
  • Posts: 6919
  • Country: nl
Re: change pulse width of a signal
« Reply #24 on: February 05, 2017, 08:22:35 am »
How about charging a capacitor with current x while the input is high and then discharging it with a variably current y>x when the input is low. Output is high while discharging, goes low when it meets a threshold and the discharging is stopped. Circuit shouldn't be too hard.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf