PWM, not working properly, need advice!

Thread Starter

bytraper

Joined Sep 28, 2010
127
Hi People.

I've got a problem with a PWM circuit that just refuses to work properly. First, let me add the circuit (see below)

It works perfectly in a simulator, but in reality it doesn't work so well, but I'm pulling my hair out as to why! I'm sure it’s something in the PWM circuit itself, but I don't understand enough about it to work out exactly what. The resistors I am using are all 1%

The problem with it is that at the very beginning when it changes the duty cycle between about 1-3%, the PWM output goes haywire (see the scope shot). At 0% its ok, at 4% to 96% it works fine and is stable, at 97-100% it goes crazy again.

I've tried to catch the scope images do you can see.

Changing the frequency doesn't make any difference, I've tried different filtering with caps and diodes which helped smooth the signal, but didn't fix the problem. The trimpot marked TSS in the schematic is for adjusting the end position of the input pots (because some of the 10k pots I have start and finish in different positions depending on the brand).

The sawtooth output into the negative of the second comparator (pin 6) of the lm2903 is dead steady. The scope readings were taken from Pin 7 (the second comparator output).

The PWM square wave output from Pin 1 is stable; however I have noticed that at the problem points in the potentiometer travel (1-3% and 97-100%) it grows the smallest margin wider (time) until you cross past these problem spots.

The diode D3 on the output helped clean the signal, and so did a capacitor, but again not fixing the problem.

I've tried external 5v power sources, but it still bugs out. I've tried taking all other circuits out of the design and leaving just the PWM and the 5v reg, but it still bugs out. I can cheat by adjusting the maximum start and end positions, but this is more of a hack and not really fixing the problem.

I'm just stumped and would appreciate any help I can get!



The circuit:


0% duty cycle, stable (no picture)


1-3% Duty Cycle, Crazed, you can’t see it but its shifting horizontally across the screen


~50% duty cycle, stable


97% Crazed!


99% crazed


The PWM is based on Sarges design.


I'm stuck!
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Looks like you're having noise problems. Metal film resistors will help that.
Put a 10nF/0.01uF cap from U3 pin5 to GND
Put a 100pF cap from U3 pin 3 to GND
Do you have an 0.1uF/100nF cap across u3's power pins?
I'm going to be mighty busy for the next couple of weeks, attending seminars and travelling. Don't expect any quick replies.
 

Thread Starter

bytraper

Joined Sep 28, 2010
127
Hey Sarge,
I tried the capacitors you mentioned,
the 10nf between pin 5 and ground, this made no difference to the output.
the 100pf between pin 3 to ground, completely shut everything down, no pwm output at all.
Also, across the VCC/GND I have both a 0.1uf and a 2,2uf pair.

Bill, here's the sawtooth at Pin 6
 

Wendy

Joined Mar 24, 2008
23,415
The next question is are the voltages at the comparator exceeding the peaks of the triangle wave?

Something that is important to note, you are not going to get a nice repetitious waveform unless you are dealing with a pure DC, and any AC at all is going to cause jitter.

Something that has occurred to me, how pure is the 5V? If you are using a SMPS from a phone charger or some such it will feed noise into the system.
 

Thread Starter

bytraper

Joined Sep 28, 2010
127
The supply is pretty clean, its a regulated DC lab supply. The line does have noise on it possibly from the regulation stage, but the filters off the 7805 fix this to a degree. The voltage coming in from the pot is 0.556v-4.42V.

I notice also, that when I touch the dial of the pot, I get a lot more noise on the pin7 output, I've insulated the pot, but the crazy pwm still happens, but could this be part of the problem?

Sarge initially designed it to work with a Hall Effect Throttle, but it does the same thing (crazy pwm) as the pot.
 
Last edited:

Wendy

Joined Mar 24, 2008
23,415
Just free wheeling here (thinking out loud).

I was a metrology tech for Alcatel for just over a year. I had a problem with noise on a power supply. I fought it for a while, then I noticed the noise matched a transistor radio I was hearing across the lab. Turned out it was RF (the local AM radio station) riding on the DC.

When you touch anything in a circuit you are an antenna. No way around it. This can go for DVM probes, and maybe even oscope probes.

There are ways to fight it though. Make sure the power supply is as clean as you can get it. Use a capacitor on the pot wiper. That sort of thing. Look for areas you can quieten without affecting what you are working on.
 

shortbus

Joined Sep 30, 2009
10,045
According to what I've read in various places including data sheets for PWM chips, its hard to get a PWM that works over the complete range. Most of them only work effectively from ~ 10% to 90% of the 0-100% range.
 

Wendy

Joined Mar 24, 2008
23,415
According to what I've read in various places including data sheets for PWM chips, its hard to get a PWM that works over the complete range. Most of them only work effectively from ~ 10% to 90% of the 0-100% range.
The OPs circuit should be able to. It was loosely based off one I published in my LEDs, 555s, Flashers, and Light Chasers, though Wookie may have had this out before then. I seem to remember he published it as a way to get it down to one chip instead of two. When he frees up he can answer that question.

The schematic in question looks like this....



.................................................. ........................Figure 5.3


If you look close you will find the hysteretic oscillator has the same 1/3 Vcc and 2/3 Vcc set points as mine, though mine was based of the 555 characteristics. I was quite disconcerted when I found this to be the case.

I notice there is a pot in his design, so it may not be the case as it was in the other design of Wookie's I saw.

It is easy to calculate, maybe the OP can pin down the value of VR1 in his design. R1 in my design is frequency of the PWM, which should be stable.

The 200KΩ trim pot should be 100KΩ, this is pretty critical for the set points I mentioned. It sets the max and min voltages of the triangle wave, which is core to where 0% and 100% to DC voltage in is on the design.
 
Last edited:

Thread Starter

bytraper

Joined Sep 28, 2010
127
Bill,
I Put the 200k trimpot there to adjust the triangle wave, because I also use this for hall effect throttles and pots that have different endpoints. Trimpot VR1 lets me adjust the endpoint so the pwm can still reach 100% duty cycle.

Like sarge said, its a noise issue, I don't think its the PWM, I think there may be noise coming from the main 5V or 12V rail, but I cant seem to get rid of it.

I can see it, but nothing I do seems to isolate it
 

Wendy

Joined Mar 24, 2008
23,415
The problem is, that will move your endpoints, but not in a controlled manner. What are they now? (assuming you have measured them).



Side comment, please use the local albums on AAC or attach your documents locally, it creates problems for other people otherwise.

It is the ratio of R1||R2 and R3 that adjusts the endpoints, if you look at Wookie's schematic he has labeled it as such.

Let me know what the current value of R2 and I'll calculate your end points. I suspect you will see your problem there.
 
Last edited:

Thread Starter

bytraper

Joined Sep 28, 2010
127
What do you mean by setpoint ? the voltage range on the input device?

I tried the 100k, in theory, this should have fixed the problem as the circuit is now identical to the one sarge posted, but the issues are still the same. I don't think the problem is with the PWM... I'm now sure its a noise issue, but I'm damned if I can find the source of the noise, but it's making both the 12v and 5v regulators quite hot.
 

Thread Starter

bytraper

Joined Sep 28, 2010
127
Ok... this sucks, now we are back to the PWM.. I had a friend look it over and said the problem isn't the power, its the pwm. He isolated the PWM circuit, took a signal generator and voila, the rest of the circuit worked perfectly.
 

Wendy

Joined Mar 24, 2008
23,415
Have you taken the time to bread board the PWM circuit separately? I've never used that make of comparators. I've only used the LM339 (and the LM393).

For U1a I used a 555 as I showed, but you want to make adjustable set points.

What are you wanting these trigger points to be anyhow? I asked this earlier. I know you are using a hall effect sensor to feed this somehow.

I'll look up the datasheet of the LM2903, since I am not directly familiar with them.
 

Thread Starter

bytraper

Joined Sep 28, 2010
127
It's pretty frustrating, I've been pulling my hair out.
C5 is a 1nf. Its only at the top and bottom 3% of the PWM, the rest of the time its stable. And what you said about the voltage input exceeding the triangle wave makes perfect sense, but no matter what I do, I can't change it or get rid of the effect.

I don't understand what you mean by trigger points? Can you tell me what you mean ? Are you referring to the voltage input from the hall effect? The hall effect takes 5V, it outputs a range from 0.9V to 4.2V

If you want me to send you the complete boarded unit I'll be happy to.
 

Wendy

Joined Mar 24, 2008
23,415
No unit needed. I have a pretty complete workshop, though it comes out on the kitchen table.

I'm wondering is some kind of loading is going on the rest of the circuit?

You have to understand, this circuit is based off the hysteretic oscillator, the set points of the Schmitt Trigger also set where the peaks of the triangle wave are, which in turn sets the max and minimum voltages for the PWM (the 1% and 99% points).

Thing is, if you have a 2 channel scope (which I think you do) overlay the triangle wave with the digital pulses. They should be very consistent.
 
Top