Continue to Site

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.

  • 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.

problem with PWM signal

Status
Not open for further replies.
lets assume the pc scope is DC-coupled
No.
A sound card is not DC-coupled. It cuts off very low frequencies and does not pass DC.
The PWM waveform has an average DC voltage that changes. If it is DC-coupled then the top and bottom parts of the waveform will be straight lines (the supply voltage and almost 0V if a REAL comparator is used) but will move up and down (like you show) if AC-coupled.[/quote][/quote]
 
Hi,

I have to agree that because of the up and down modulation of the PWM wave itself it is probably caused by the poor response of the 'audio scope', or poor ground connection, or simply power line frequency getting into the signal too because of the signal lines going to the scope.

We might remember that an audio signal has to be shielded or else we get lots of line frequency hum mixed in with it. The signal going to the sound card has to be treated just like any other audio signal, which is subject to noise if not done right.

So i sort of ignore that wavy part of the signal for now until a better piece of equipment can be obtained. At least it does look like it is working now though. I also think the OP has a much better understanding of what is involved with a circuit like this now too. Congrats to you Maicael!
 
ok guys here the thing,i have been going around to look for an real oscilloscope i could purchase but my goodness the prices are damn to high i mean i just kept staring at the prices.This piece of equipment is on the high side and right now am scratching my head on what to do.am still a student and the semester will be starting soon am i going to spend all that money on one piece of equipment as i ahve lots of things to do with money.
Any way am wondering is there any peice of external circuit i could construct that would make me measure true dc signals so that the limitations of using a sound card and a pc scope software dont mess up wave forms.i hope you guys get what am trying to say.
i have seen some circuits but maybe you guys have any.
 
In "the good old days" we added a DC-restorer to a cheap TV video amp so that the black stayed black when the average brightness of scenes changed.
A DC-restorer might work on an AC-coupled scope.

Also in the good old days fairly high quality but inexpensive scope kits were sold by Heathkit.
 
Hi again,

Since an AC scope can display voltage differences another possibility is to build an input chopper. That's a pretty simple circuit that chops two inputs and creates only one output, and that output goes to the 'scope'. So what you see on the scope is two waveforms but they are both chopped up, with channel 1 showing only half of the time and channel 2 showing the other half of the time.

The idea would be to put the unknown waveform on channel 1, and on channel 2 put a known DC voltage. Thus on the scope display you see the actual waveform for say 1ms and then you see the DC voltage for the next 1ms, then it switches back to the actual waveform again for another 1ms then the DC voltage again for the next 1ms, and that keeps repeating. So by viewing the display you can see the DC voltage displayed with the actual waveform and that way you see the waveform as compared to whatever DC voltage you input to channel 2, and you can input any DC voltage into channel 2 with a pot and meter to measure the DC voltage. So you should get a pretty good comparison of your waveform to a DC voltage. If you input 0v DC then you would see the waveform go above and below a 'straight' line if the input wave went both positive and negative, or just above the line if it only goes positive.

For the simplest of circuits, the two inputs of the chopper would be limited to maybe plus and minus 5 volts. That's not too much of a problem though because you can always scale the inputs with some resistors and/or a pot.

If you are interested i'll post a schematic. The basic parts are a CMOS analog switch IC and a 555 timer IC, and a plus and minus 5 to 15v power supply.

This works pretty well with a real scope, but with a sound card scope you'll have to limit the input frequencies as well as the chop frequency to some pretty lowish values unfortunately.

Alternately, you can use a single comparator and pot to see roughly where the peak is on a waveform. That takes one comparator like the LM339 and a potentiometer maybe 10k, and a few small resistors.
 
Hi again,

Since an AC scope can display voltage differences another possibility is to build an input chopper. That's a pretty simple circuit that chops two inputs and creates only one output, and that output goes to the 'scope'. So what you see on the scope is two waveforms but they are both chopped up, with channel 1 showing only half of the time and channel 2 showing the other half of the time.

The idea would be to put the unknown waveform on channel 1, and on channel 2 put a known DC voltage. Thus on the scope display you see the actual waveform for say 1ms and then you see the DC voltage for the next 1ms, then it switches back to the actual waveform again for another 1ms then the DC voltage again for the next 1ms, and that keeps repeating. So by viewing the display you can see the DC voltage displayed with the actual waveform and that way you see the waveform as compared to whatever DC voltage you input to channel 2, and you can input any DC voltage into channel 2 with a pot and meter to measure the DC voltage. So you should get a pretty good comparison of your waveform to a DC voltage. If you input 0v DC then you would see the waveform go above and below a 'straight' line if the input wave went both positive and negative, or just above the line if it only goes positive.

For the simplest of circuits, the two inputs of the chopper would be limited to maybe plus and minus 5 volts. That's not too much of a problem though because you can always scale the inputs with some resistors and/or a pot.

If you are interested i'll post a schematic. The basic parts are a CMOS analog switch IC and a 555 timer IC, and a plus and minus 5 to 15v power supply.

This works pretty well with a real scope, but with a sound card scope you'll have to limit the input frequencies as well as the chop frequency to some pretty lowish values unfortunately.

Alternately, you can use a single comparator and pot to see roughly where the peak is on a waveform. That takes one comparator like the LM339 and a potentiometer maybe 10k, and a few small resistors.
are you kidding me.please post the schematic or schematics for both CMOS analog with 555 timer and the one using LM339.
one more thing what maximum frequency can we input due to limitations of a sound card.
 
In "the good old days" we added a DC-restorer to a cheap TV video amp so that the black stayed black when the average brightness of scenes changed.
A DC-restorer might work on an AC-coupled scope.

Also in the good old days fairly high quality but inexpensive scope kits were sold by Heathkit.
do you have a circuit?
i will try to check one online though.
 
are you kidding me.please post the schematic or schematics for both CMOS analog with 555 timer and the one using LM339.
one more thing what maximum frequency can we input due to limitations of a sound card.


Hello again,

Here is the circuit for the dual channel scope chopper. Note the details of the 555 are not fully shown, it's just a 50 percent duty cycle oscillator, and you want to make it have an adjustable output frequency.
The input voltage range for both channels is -10v to +10v with the power supplies shown.
The two input channels are common to ground, so they both have to have a common ground, but we could build a differential input chopper too. I dont think you need that right now though so this is the simplest possible.

The LM339 peak checker would just be a comparator with power supplies of say +10 and -10 volts. One input goes to a pot arm, say 10k, and the other two terminals of the pot go to +10 and -10 volts. The signal to be measured goes to the other input of the comparator. The comparator output gets a pullup resistor maybe 4.7k. You look at the output of the comparator with the 'scope'. You adjust the pot until you get a voltage like +2v, then check the output of the comparator with the scope. If you see a pulse out of the comparator, then you know +2v is lower than the peak. If you see a wide pulse then +2v is much lower than the peak, but if you see a short pulse then +2v is close to the peak. If it is close to the peak you adjust the pot up a little, to say 2.1v, then look at the output again. If you still see a pulse then +2.1v is still lower than the peak, so you adjust to +2.2v, then if you dont see a pulse anymore then that means that +2.2v is higher than the peak and because you did see a pulse at +2.1v the peak is higher than 2.1v, so the peak is between +2.1v and +2.2v. If the pulse was wider then you could turn up the pot more to start with, like say to +3v. The idea is to find two levels that are close to each other where the lower one still causes a pulse to appear but the slightly higher setting makes the pulse go away. Then you know the peak is between the two levels.
For the negative peak you could do the same thing, the only difference is the setting of the voltage on the arm of the pot and the output pulse will be of opposite polarity.
For this version, if the scope is too slow to catch the pulses then you can connect a pulse detector to the output instead which would be pretty fast. For a simple pulse detector you can use a flip flop, or if you have a logic probe you can set it to detect a pulse signal.
Using either of these methods you should be able to find the peak to within a reasonable degree of accuracy.

Note the LM339 peak detector with pulse catcher would be much faster than when using a sound card scope for the scope for the chopper.
 

Attachments

  • ScopeChopperPrelim1.gif
    ScopeChopperPrelim1.gif
    14.5 KB · Views: 174
Hello again,

Here is the circuit for the dual channel scope chopper. Note the details of the 555 are not fully shown, it's just a 50 percent duty cycle oscillator, and you want to make it have an adjustable output frequency.
The input voltage range for both channels is -10v to +10v with the power supplies shown.
The two input channels are common to ground, so they both have to have a common ground, but we could build a differential input chopper too. I dont think you need that right now though so this is the simplest possible.

The LM339 peak checker would just be a comparator with power supplies of say +10 and -10 volts. One input goes to a pot arm, say 10k, and the other two terminals of the pot go to +10 and -10 volts. The signal to be measured goes to the other input of the comparator. The comparator output gets a pullup resistor maybe 4.7k. You look at the output of the comparator with the 'scope'. You adjust the pot until you get a voltage like +2v, then check the output of the comparator with the scope. If you see a pulse out of the comparator, then you know +2v is lower than the peak. If you see a wide pulse then +2v is much lower than the peak, but if you see a short pulse then +2v is close to the peak. If it is close to the peak you adjust the pot up a little, to say 2.1v, then look at the output again. If you still see a pulse then +2.1v is still lower than the peak, so you adjust to +2.2v, then if you dont see a pulse anymore then that means that +2.2v is higher than the peak and because you did see a pulse at +2.1v the peak is higher than 2.1v, so the peak is between +2.1v and +2.2v. If the pulse was wider then you could turn up the pot more to start with, like say to +3v. The idea is to find two levels that are close to each other where the lower one still causes a pulse to appear but the slightly higher setting makes the pulse go away. Then you know the peak is between the two levels.
For the negative peak you could do the same thing, the only difference is the setting of the voltage on the arm of the pot and the output pulse will be of opposite polarity.

For this version, if the scope is too slow to catch the pulses then you can connect a pulse detector to the output instead which would be pretty fast. For a simple pulse detector you can use a flip flop, or if you have a logic probe you can set it to detect a pulse signal.
Using either of these methods you should be able to find the peak to within a reasonable degree of accuracy.

Note the LM339 peak detector with pulse catcher would be much faster than when using a sound card scope for the scope for the chopper.
hello Sir,quick questions
1)for the 555 astable are you saying that no matter the frequency its duty cycle must always be 50% in that case i must find a way to make it 50% at every frequency i adjust it too.am asking because i do know that adjuting frequency by adjusting resistor causes duty cycle to change unless i force the 555 to 50% but how?
a idea just popped in now what if i were to replace the 555 with a CD4047 whose output is always fixed at 50% duty cycle no matter the frequency adjusted to so that way i only need to worry about setting the pot to whatever frequency knowing that i will always get 50% duty.make sense?
2)for the power supply of the CD4051 can i use a single power supply source like +12V and 0V which means that the input voltage range for both channels will be limited to 0 to +12V since thats what i will be using?
3)i understand clearly the LM339 peak checker explanation but the pulse detector part is em a bit not understood but i am checking online anyway.
Any comparator would do right?
4)
than when using a sound card scope for the scope for the chopper.
what do you mean here cause am a bit lost?
5)the part where it says To scope means that it will be connected to something like a probe right and i connect cahnnel 2 to a pot and set it what ever voltage i want and channel 1 takes the actual wave form in?
6)in your eariler post you said something about input and chop frequency.i know that input frequency is the frequency from the cirucit in question like a triangle oscillator for example right while the chop frequency is controlled by the 555 right?
so what does the chop frequency do?
for some strange reason i prefer this CMOS and 555 method and am so sorry for asking too many questions
 
Hello again,

Here is the circuit for the dual channel scope chopper. Note the details of the 555 are not fully shown, it's just a 50 percent duty cycle oscillator, and you want to make it have an adjustable output frequency.
The input voltage range for both channels is -10v to +10v with the power supplies shown.
The two input channels are common to ground, so they both have to have a common ground, but we could build a differential input chopper too. I dont think you need that right now though so this is the simplest possible.

The LM339 peak checker would just be a comparator with power supplies of say +10 and -10 volts. One input goes to a pot arm, say 10k, and the other two terminals of the pot go to +10 and -10 volts. The signal to be measured goes to the other input of the comparator. The comparator output gets a pullup resistor maybe 4.7k. You look at the output of the comparator with the 'scope'. You adjust the pot until you get a voltage like +2v, then check the output of the comparator with the scope. If you see a pulse out of the comparator, then you know +2v is lower than the peak. If you see a wide pulse then +2v is much lower than the peak, but if you see a short pulse then +2v is close to the peak. If it is close to the peak you adjust the pot up a little, to say 2.1v, then look at the output again. If you still see a pulse then +2.1v is still lower than the peak, so you adjust to +2.2v, then if you dont see a pulse anymore then that means that +2.2v is higher than the peak and because you did see a pulse at +2.1v the peak is higher than 2.1v, so the peak is between +2.1v and +2.2v. If the pulse was wider then you could turn up the pot more to start with, like say to +3v. The idea is to find two levels that are close to each other where the lower one still causes a pulse to appear but the slightly higher setting makes the pulse go away. Then you know the peak is between the two levels.
For the negative peak you could do the same thing, the only difference is the setting of the voltage on the arm of the pot and the output pulse will be of opposite polarity.

For this version, if the scope is too slow to catch the pulses then you can connect a pulse detector to the output instead which would be pretty fast. For a simple pulse detector you can use a flip flop, or if you have a logic probe you can set it to detect a pulse signal.
Using either of these methods you should be able to find the peak to within a reasonable degree of accuracy.

Note the LM339 peak detector with pulse catcher would be much faster than when using a sound card scope for the scope for the chopper.
hello Sir,quick questions
1)for the 555 astable are you saying that no matter the frequency its duty cycle must always be 50% in that case i must find a way to make it 50% at every frequency i adjust it too.am asking because i do know that adjuting frequency by adjusting resistor causes duty cycle to change unless i force the 555 to 50% but how?
a idea just popped in now what if i were to replace the 555 with a CD4047 whose output is always fixed at 50% duty cycle no matter the frequency adjusted to so that way i only need to worry about setting the pot to whatever frequency knowing that i will always get 50% duty.make sense?
2)for the power supply of the CD4051 can i use a single power supply source like +12V and 0V which means that the input voltage range for both channels will be limited to 0 to +12V since thats what i will be using?
3)i understand clearly the LM339 peak checker explanation but the pulse detector part is em a bit not understood but i am checking online anyway.
Any comparator would do right?
4)
than when using a sound card scope for the scope for the chopper.
what do you mean here cause am a bit lost?
5)the part where it says To scope means that it will be connected to something like a probe right and i connect cahnnel 2 to a pot and set it what ever voltage i want and channel 1 takes the actual wave form in?
6)in your eariler post you said something about input and chop frequency.i know that input frequency is the frequency from the cirucit in question like a triangle oscillator for example right while the chop frequency is controlled by the 555 right?
so what does the chop frequency do?
for some strange reason i prefer this CMOS and 555 method and am so sorry for asking too many questions
 
Hi,

1) Yes, 50 percent. There are 50 percent duty cycle oscillators on the web using 555, but yes the required IC can be whatever can put out the logic signal needed for the 4051 so you can use chips other than the 555.
2) Yes, +12 and 0v for an input signal range of 0 to +12v should be fine.
3) There are various pulse catcher circuits out there on the web. A flip flop should work too.
4) Just that the pulse catcher will be faster than a sound card scope so it should be better.
5) Yes, "To Scope" means to the input of the actual sound card scope you have, or to the pulse catcher.
6) Yes the chop frequency is controlled by the 555. The chop frequency should be at least 10 times higher than the highest frequency to be observed.

The chop frequency simply breaks up the two input waveforms which allows showing both on the scope. First one appears and then the other appears, so it's a sort of 'time share' of the scope display reasource.

Here's a snap shot of the idealized waveform seen on the scope. For this sample the sine wave is 50Hz and peaks on channel 1 are =5v and +5v and the DC voltage on channel 2 is adjusted to +4v. You can see that during the time the sine is being sampled only the sine appears on the scope, and otehr times the DC voltage is being shown on the scope. The chop frequency here is 2500Hz so each wave has a 200us time slot so you can see the sine wave for 200us followed by the 4v DC voltage for the next 200us and then it just keeps alternating like that, so you can see the outline of both waves.
If you have a pot on channel 2 you can adjust the DC voltage, measure it with a meter, and that will allow you to determine the peak of the sine wave when the DC voltage is adjusted to the same level as the sine peak.

Often the chop frequency is not synced to the waveform being displayed so you dont always see the up and down vertical lines you see in this pic you just see the two waveforms. If it does sync, you can adjust it so that it does not sync.

Note this works pretty well on a real scope, im not sure how well it will work on a sound card scope because the bandwidth is so extremely limited. Maybe for low frequency waves and low chop frequency too. Keep in mind that the chop frequency must be higher than the two waveform frequencies or else it will go in to 'alternating' mode, which is not as good for comparing two waves. That means the chop frequency should be at least 10 times higher than either waveform frequency.

Also note that the chop frequency doesnt have to be exactly 50 percent duty cycle but it should be close to that. If it was say 25/75 then you'd see one waveform for only 100us and the other waveform for 300us so they would not share the scope display time equally, so 50/50 is the best.
 

Attachments

  • Chopper_Scope_Waveform-1.gif
    Chopper_Scope_Waveform-1.gif
    15.8 KB · Views: 200
Last edited:
Hi,

1) Yes, 50 percent. There are 50 percent duty cycle oscillators on the web using 555, but yes the required IC can be whatever can put out the logic signal needed for the 4051 so you can use chips other than the 555.
2) Yes, +12 and 0v for an input signal range of 0 to +12v should be fine.
3) There are various pulse catcher circuits out there on the web. A flip flop should work too.
4) Just that the pulse catcher will be faster than a sound card scope so it should be better.
5) Yes, "To Scope" means to the input of the actual sound card scope you have, or to the pulse catcher.
6) Yes the chop frequency is controlled by the 555. The chop frequency should be at least 10 times higher than the highest frequency to be observed.

The chop frequency simply breaks up the two input waveforms which allows showing both on the scope. First one appears and then the other appears, so it's a sort of 'time share' of the scope display reasource.

Here's a snap shot of the idealized waveform seen on the scope. For this sample the sine wave is 50Hz and peaks on channel 1 are =5v and +5v and the DC voltage on channel 2 is adjusted to +4v. You can see that during the time the sine is being sampled only the sine appears on the scope, and otehr times the DC voltage is being shown on the scope. The chop frequency here is 2500Hz so each wave has a 200us time slot so you can see the sine wave for 200us followed by the 4v DC voltage for the next 200us and then it just keeps alternating like that, so you can see the outline of both waves.
If you have a pot on channel 2 you can adjust the DC voltage, measure it with a meter, and that will allow you to determine the peak of the sine wave when the DC voltage is adjusted to the same level as the sine peak.

Often the chop frequency is not synced to the waveform being displayed so you dont always see the up and down vertical lines you see in this pic you just see the two waveforms. If it does sync, you can adjust it so that it does not sync.

Note this works pretty well on a real scope, im not sure how well it will work on a sound card scope because the bandwidth is so extremely limited. Maybe for low frequency waves and low chop frequency too. Keep in mind that the chop frequency must be higher than the two waveform frequencies or else it will go in to 'alternating' mode, which is not as good for comparing two waves. That means the chop frequency should be at least 10 times higher than either waveform frequency.

Also note that the chop frequency doesnt have to be exactly 50 percent duty cycle but it should be close to that. If it was say 25/75 then you'd see one waveform for only 100us and the other waveform for 300us so they would not share the scope display time equally, so 50/50 is the best.
thanks for the explanation i get it now but i want to ask if for channel 1 and channel 2 i can pass say a sine wave from a circuit to channel 1 and then a triangle wave to channel 2 instead of a DC voltage and then view both waves on the scope?
am only asking because for channel 2 i want to have the option of not only being able to pass a DC voltage into channel 2 but i can pass another wave form aside a DC voltage if i want to by using something like a switch where if i want a DC voltage through a pot i just press the switch and the DC voltage goes in through the channel or i press the switch and instead of a DC voltage i can pass any other wave form.
 
Hello again,

Yes you can put any waveform on channel 2 as long as the voltage level meets the requirements of being between the two power supply levels. So for a power supply of 0v ground and +12v the wave would have to be between 0v and +12v.

You'll note that the chip used for the switching is a CMOS switch with not just 2 but with 8 channels. This means if you were to use a counter you could squeeze three or four channels onto the scope display. It may be much more difficult to view however so i did not suggest that option previously. It's better to start with 2 first anyway and see how that goes with your scope.
If you plan to use just 2 channels (probably better than 3 or 4) then there are other CMOS switch type IC's available too, with just single pole switches on them. The proper switching may require an extra inverter with some packages though. A single pole double throw version should work just as well though without an extra inverter.

The 8 channel device works well without an inverter as well and allows for other options. You can add a channel later if it seems like the display is working ok, or you could switch which pin you use to 'clock' the device. Right now we are using the 'A' input which means the channels selected are either channel 0 or channel 1. But if we used the 'B' input for example (grounding 'A'), then the channels selected would be instead channel 0 and channel 2.
So if you switch between using input A or input B (grounding the unused one) you can cause the wave at input channel 1 or input channel 2 to be displayed as well as whatever is on channel 0. That's one way to switch waves on the second channel.
 
Hello again,

Yes you can put any waveform on channel 2 as long as the voltage level meets the requirements of being between the two power supply levels. So for a power supply of 0v ground and +12v the wave would have to be between 0v and +12v.

You'll note that the chip used for the switching is a CMOS switch with not just 2 but with 8 channels. This means if you were to use a counter you could squeeze three or four channels onto the scope display. It may be much more difficult to view however so i did not suggest that option previously. It's better to start with 2 first anyway and see how that goes with your scope.
If you plan to use just 2 channels (probably better than 3 or 4) then there are other CMOS switch type IC's available too, with just single pole switches on them. The proper switching may require an extra inverter with some packages though. A single pole double throw version should work just as well though without an extra inverter.

The 8 channel device works well without an inverter as well and allows for other options. You can add a channel later if it seems like the display is working ok, or you could switch which pin you use to 'clock' the device. Right now we are using the 'A' input which means the channels selected are either channel 0 or channel 1. But if we used the 'B' input for example (grounding 'A'), then the channels selected would be instead channel 0 and channel 2.
So if you switch between using input A or input B (grounding the unused one) you can cause the wave at input channel 1 or input channel 2 to be displayed as well as whatever is on channel 0. That's one way to switch waves on the second channel.
i want to ask a question about PWM.Now if we have a sine wave with say peak to peak amplitude 5V and a triangle wave with peak to peak amplitude say 7V and we pass it into a comparator like the LM393 and i remember audioguru saying that the amplitudes of both waves dont need to be that high since the comparator has a very high voltage gain about say 200 times or something like that.
1)Well if all circuits are it from a 12V source and passed into the comparator would the resulting PWM output go from 0V to as high as near the supply voltage even if the amplitude of the two waves being compared are not that high since the voltage gain of the comaprator is very high?
2)if we were to filter this PWM wave to get back the sine wave would the sine wave gotten back have peak to peak amplitude 5V since that is the oroginal wave used in the actual comparing?
 
The output swing of an LM393 dual comparator is always from almost 0V to the supply voltage. It has a voltage gain of typically 200,000 (TWO HUNDRED THOUSAND) so a tiny input signal causes a full output swing. The maximum allowed input is from 0V to 1.5V less than the supply voltage.

If the triangle frequency is much higher than the sine frequency then the PWM can be filtered so that the sinewave is as pure as the input. The filtered sinewave can have a maximum peak-to-peak voltage swing almost the entire supply voltage and is not limited to the voltage swing of the input which can be a few millivolts.
 
i want to ask a question about PWM.Now if we have a sine wave with say peak to peak amplitude 5V and a triangle wave with peak to peak amplitude say 7V and we pass it into a comparator like the LM393 and i remember audioguru saying that the amplitudes of both waves dont need to be that high since the comparator has a very high voltage gain about say 200 times or something like that.
1)Well if all circuits are it from a 12V source and passed into the comparator would the resulting PWM output go from 0V to as high as near the supply voltage even if the amplitude of the two waves being compared are not that high since the voltage gain of the comaprator is very high?
2)if we were to filter this PWM wave to get back the sine wave would the sine wave gotten back have peak to peak amplitude 5V since that is the oroginal wave used in the actual comparing?


Hello again,

I think this is a very good question. The best answer i think shows the difference between how we perceive comparators and how a real life comparator really works.

In theory, if we have a non inverting (+) input of 10 volts and an inverting (-) input of 5 volts, the output will be go high immediately. In practice with a real comparator IC, the same thing happens except there is a delay while the output STARTS to ramp high, then another delay while the output actually ramps high. The first delay is caused by the internal gain and input signal, and the second delay is caused by the slew rate. The second delay is 'usually' the most important, but we can not totally forget about the first delay in all applications.

There we looked at signals that are quite different, 10v and 5v, but what about signals that are much closer?
It just so happens that many comparator applications have signals that are much closer to each other because one or both signals do not change very fast themselves. For example, with 5v on the inverting terminal and a charging capacitor that charges slowly on the non inverting terminal, the voltage on the cap starts at 0v and rises slowly past 5v, so just how long does it take for the comparator to respond when the voltage gets 'near' 5v.
It just so happens that it takes a little bit longer because when the voltage of the cap reaches 5.000000 volts with a reference of 5.000000 volts on the other input the comparator gain of 100000 still does not produce any output change because the difference in input voltages is zero, and zero times any gain is still zero.
So lets say the cap voltage rises to 5.000001 volts next. That means the difference is 1uv, and with an internal gain of 100000 that means the output should rise to 0.1 volts, with a small delay. But since the input is changing so slow (large cap and resistor) it could have taking 60 seconds for that change to occur.

So we have a delay that is based partly on the rate of change of the two inputs as well as other built in factors, and this is why we often see tests of comparators done with voltage steps. The step is usually around 0.1 volt as a min i think, but you could check your data sheets to see what they use for their test for that particular device.

What this means is that the input amplitudes do have an effect on the output of the comparator, in that the amplitudes tend to delay the point in time where the comparator starts to switch states. The delay after that depends mostly on the output slew rate.

So for two signals one a sine and one a triangle, we see two inputs changing at different rates most of the time. That means the initial response delay for the slowest change points in time will be double for signals that are half as high in amplitude. The slew rate however will still be the same for any amplitude, but it could appear to be much longer if the two inputs dwell near the same amplitude level for long periods of time.
For example, for very slow sine and triangle waves, the sine rises fastest near 0 degrees and 180 degrees, so those times will produce the fastest output change. Neat the peaks however, the triangle rate will dominate and that's usually fast enough to produce a good output providing the initial delay is much faster than the slew rate.

So the short answer is, the voltage levels do affect the output delay, but if the initial delay is much faster than the slew rate it should not matter too much. If the voltages are very low the initial delay can be long though.

What will not be affected however is the amplitude after all of the delays have been considered. Using a +12v supply with a pullup resistor for the comparator, the output will rise eventually near to +12v, and will fall down very close to 0v. One thing to note however is that because the comparator depends on a pullup resistor, any load resistor from the output to ground could greatly reduce the output voltage for a logic high level. With a 10k pullup and a 10k load resistor, that would mean that with a +12v supply we would only see +6v output across the 10k load resistor.
It will however pull all the way to ground, except for the small internal transistor drop would could be anywhere from near 0 to around 0.5 volts and depends on the value of the pullup resistor and if there is any load resistor from the output to the +12v line.

Finally, for most comparator apps there is usually a small amount of hysteresis added to the comparator in the form of an extra resistor or two. One thing this does is it improves that initial delay time to help keep it short. That way even with slowly changing input signals we can see fast output rise times.
 
Hello again,

I think this is a very good question. The best answer i think shows the difference between how we perceive comparators and how a real life comparator really works.

In theory, if we have a non inverting (+) input of 10 volts and an inverting (-) input of 5 volts, the output will be go high immediately. In practice with a real comparator IC, the same thing happens except there is a delay while the output STARTS to ramp high, then another delay while the output actually ramps high. The first delay is caused by the internal gain and input signal, and the second delay is caused by the slew rate. The second delay is 'usually' the most important, but we can not totally forget about the first delay in all applications.

There we looked at signals that are quite different, 10v and 5v, but what about signals that are much closer?
It just so happens that many comparator applications have signals that are much closer to each other because one or both signals do not change very fast themselves. For example, with 5v on the inverting terminal and a charging capacitor that charges slowly on the non inverting terminal, the voltage on the cap starts at 0v and rises slowly past 5v, so just how long does it take for the comparator to respond when the voltage gets 'near' 5v.
It just so happens that it takes a little bit longer because when the voltage of the cap reaches 5.000000 volts with a reference of 5.000000 volts on the other input the comparator gain of 100000 still does not produce any output change because the difference in input voltages is zero, and zero times any gain is still zero.
So lets say the cap voltage rises to 5.000001 volts next. That means the difference is 1uv, and with an internal gain of 100000 that means the output should rise to 0.1 volts, with a small delay. But since the input is changing so slow (large cap and resistor) it could have taking 60 seconds for that change to occur.

So we have a delay that is based partly on the rate of change of the two inputs as well as other built in factors, and this is why we often see tests of comparators done with voltage steps. The step is usually around 0.1 volt as a min i think, but you could check your data sheets to see what they use for their test for that particular device.

What this means is that the input amplitudes do have an effect on the output of the comparator, in that the amplitudes tend to delay the point in time where the comparator starts to switch states. The delay after that depends mostly on the output slew rate.

So for two signals one a sine and one a triangle, we see two inputs changing at different rates most of the time. That means the initial response delay for the slowest change points in time will be double for signals that are half as high in amplitude. The slew rate however will still be the same for any amplitude, but it could appear to be much longer if the two inputs dwell near the same amplitude level for long periods of time.
For example, for very slow sine and triangle waves, the sine rises fastest near 0 degrees and 180 degrees, so those times will produce the fastest output change. Neat the peaks however, the triangle rate will dominate and that's usually fast enough to produce a good output providing the initial delay is much faster than the slew rate.

So the short answer is, the voltage levels do affect the output delay, but if the initial delay is much faster than the slew rate it should not matter too much. If the voltages are very low the initial delay can be long though.

What will not be affected however is the amplitude after all of the delays have been considered. Using a +12v supply with a pullup resistor for the comparator, the output will rise eventually near to +12v, and will fall down very close to 0v. One thing to note however is that because the comparator depends on a pullup resistor, any load resistor from the output to ground could greatly reduce the output voltage for a logic high level. With a 10k pullup and a 10k load resistor, that would mean that with a +12v supply we would only see +6v output across the 10k load resistor.
It will however pull all the way to ground, except for the small internal transistor drop would could be anywhere from near 0 to around 0.5 volts and depends on the value of the pullup resistor and if there is any load resistor from the output to the +12v line.

Finally, for most comparator apps there is usually a small amount of hysteresis added to the comparator in the form of an extra resistor or two. One thing this does is it improves that initial delay time to help keep it short. That way even with slowly changing input signals we can see fast output rise times.
hello Sir remember me,well since my PWM circuits works well now i would like to add hysterisis to the comparator.
if i may ask what does it do interms if helping the comparator work in a noisy enviroment.thanks
 
Hi,

When the noise isnt too bad a little DC hysteresis helps the comparator by not allowing it to trip repeatedly due to the noise when it should only be tripping due to the signal.

For a signal that rises slowly it will look almost like a DC signal, and that DC signal will always have some noise riding on it and that noise appears to look like an AC signal. So we have a DC signal that varies a tiny amount. Say the DC signal is 10 volts. With 0.100 volts peak AC riding on that, we have a signal that varies from 9.9 to 10.1 volts. Now if the comparator trips at 10.0 volts then the output goes high at 10.0 volts, but then the signal goes back down to 9.9 volts and so the comparator output goes low again. But then the signal goes back up again through 10.0 volts so the output goes high again, and this repeats over and over again at the frequency of the noise. So the output jumps up and down very quickly when it should just go to one level and stay there.

Hysteresis helps by adding a small bias to the input that helps to keep the comparator in one state even though there is a small amount of noise present in the signal. The idea is to use a very small amount of positive feedback. When the output goes high, it boosts the input a little to make sure it stays high. When the output goes low, it decreases the input a little to make sure it stays low.

The simplest form of hysteresis is created with two resistors. One resistor RS goes in series with the non inverting terminal of the comparator, and the other resistor RF goes from the output of the comparator back to the non inverting terminal of the comparator. So when the output goes high the non inverting terminal gets a tiny boost, and when the output goes low the non inverting terminal gets a small cut in voltage. This action keeps the output at one state even with the presence of some small amount of noise.

The resistor RS is usually made small, typically 1k to 10k, while the resistor RF is typically made large like 100k to 1 Meg. The amount of hysteresis is estimated by the ratio of RS/RF, so for RS=1k and RF=100k the percent hysteresis is roughly 1000/100000 or 1 percent.
For a test signal of 5v and an output that goes from 0 to 10v, when the output goes to 10v the non inverting input now sees 5v plus one percent of 10v minus 5v times 0.01, which comes out to 0.05v, so there is 50mv of hysteresis with the output high, but when the output goes low the hysteresis is -50mv so the total hysteresis is 100mv which is one percent of 10 volts.

So without the hysteresis the input was 5v with a little noise and the output would switch up and down. With the added hysteresis, assuming it was enough to overcome the noise, the output goes high at around 5.05 volts input with the non inverting terminal at around 5.00v, then the feedback resistor pulls the non inverting terminal up to 5.10 volts (50mv higher than the input roughly) and that keeps the comparator output state stable at a logical high level. Now the input signal has to decrease to 4.95v to get the comparator output to trip low again.
The difference is now it takes 5.05 volts to make it go high and 4.95v to make it go low, so there is a 0.1v allowable noise voltage band when before there was a zero volt band which is usually unacceptable in most applications.

If in that example application 0.1 volts was not enough, we would have to increase the hysteresis. The idea here is to increase the hysteresis enough to stop unwanted switching but not too much so that we seriously impair the normal operation of the circuit. Occasionally we'd have to employ a little AC hysteresis too, but that's another story.

A secondary factor is the effect of the introduction of the two resistors themselves. The input resistor is sometimes not needed if the input already has significant DC resistance, and then the feedback resistor can be adjusted accordingly. The feedback resistor on the other hand loads the output a little so that sometimes had to be taken into account.

Attached is a drawing showing the addition of the two resistors RS and RF.
 

Attachments

  • Hysteresis-1.gif
    Hysteresis-1.gif
    25 KB · Views: 152
Last edited:
does anyone know the best core to use for a centre tap transformer being switched at high frequencies in the range of say 8Khz-25Khz.
normally i am used to iron core but i read that it has a lot of losses and is only suitable at low frequencies.How true is this?
 
Hi,

A ferrite pot core comes to mind here. They are easier to wind too. But what are you going to use this for and how much power?

BTW 20kHz isnt that high but yes steel laminations are not a good idea.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top