Jump to content
calin

Spikes on PWM output

Recommended Posts

I am doing a fan controller using PWM. All nice, things work good etc. but I noticed something really odd on PWM output the transition has an super nasty ringing happening which is almost 5V peak to peak. It overshoots really nasty in both directions/transitions. I used the sample code from TI with just the launchpad nothing else connected except the scope. Tried different pins instead of 1.6 also .. same.

 

Normally the output should swing smoother - a ring from 3.6V to 5V is huge. Did you guys ever noticed something like that ? pretty nasty.

 

BTW ... with a simple 1uF cap to ground i reduced the spike/ring to 4.12 and it settles very fast but still I find this annoying. Especially when you switch transistors the spike does not very nice things down the line.

 

#include  <msp430g2231.h>

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P1DIR |= BIT6;                            // P1.6
  P1SEL |= BIT6;                            // P1.6 TA1/2 options
  CCR0 = 512-1;                             // PWM Period
  CCTL1 = OUTMOD_7;                         // CCR1 reset/set
  CCR1 = 384;                               // CCR1 PWM duty cycle
  TACTL = TASSEL_2 + MC_1;                  // SMCLK, up mode

  _BIS_SR(CPUOFF);                          // Enter LPM0
}

Share this post


Link to post
Share on other sites

I am using nearly the exact same code for PWM, I have yet to have any issues with it.
One thing I did notice, my o-scope does over shoot and under shoot, I was also using a very simple transistor(2222) switch with 5v 

 

 

A few questions for you?

are you measuring teh PWM with a motor attached?

Do you have a diode attached to the inductive load?

 

what is the circuit you are using? and where are you measuring the PWM from?

Share this post


Link to post
Share on other sites

Circuit is literally just the launchpad with nothing attached. PWM output on P1.6. Hooked up to my computer USB (so powered by USB). So no motor no load no nothing. And I am 100% my scope does not overshoot :smile:

 

BTW, I did tested with the motor and the 2222 attached also .. exactly same ringing. Yeah I have the fly-back diode etc on. The annoying thing is that this ringing cause really weird things on the transistor switching. 

 

Attached are some data captures from my scope.  Scale is 2V/Div . Time base is 20uS - not matching the code above because I was playing with duty cycles.

post-5531-0-99197900-1356331120_thumb.png

post-5531-0-51888100-1356331132_thumb.png

post-5531-0-93877100-1356331141_thumb.png

post-5531-0-76792700-1356331149_thumb.png

Share this post


Link to post
Share on other sites

On my scope, I get similar readings as well, And I know for a fact that my readings is caused by my scope(old school analog scope).

 

 

do you have a function generator to veryify that it is not your scope? or another PWM source?

 

Have you tried using a pulldown/pullup on the base of the transistor or are you using the built in pullup/pulldowns?

have you tried a different chip to see if its just one chip?

 

for me it still looks like a scope issue, but I could be wrong.

Share this post


Link to post
Share on other sites

I have 3 scopes, signal generator also ... unless everything has gone crazy and all 3 overshoot.

 

I tried 5-6 chips, MSP430G2231 and an 2553 - two different Launchpads ... same all of them. Each transition is one nasty spike. 

I am starting to regret I took MSP430 for this tiny project :smile:.  But it is the right pick for this kind of job (a simple temperature controlled fan with PID) and I want to use new stuff also.

Share this post


Link to post
Share on other sites

You got me then, lol

 

have you tried a different power supply, other then usb, or the voltage regulator on the launchpad?

does the issue happen at 3V? how about min volatage? what about max voltage?

 

maybe try to opto isolator chip could if unable to find the source of the spike.

Share this post


Link to post
Share on other sites

Weird, I guess it does overshoot .. but I find it indeed odd. I guess may be the a very sharp rise that cause the scope overshoot. But heck all of 3 scopes ... one scope is an 1Ghz capable Agilent scope (I am sampling a lousy few kz signal .. how fast can it rise :) The sample shots are from a 100Mhz Owon SDS7102 I have @ home. 

 

I find it odd still because as you can see attached a 1MHZ 3v Pk to Pk  from sig gen. and not even a hint of overshoot - so probe is pretty well calibrated. 

 

Anyways, the PWM works so I will move into putting this one on a final board ad call it done. 

 

 

 

 

post-5531-0-48137800-1356416045_thumb.png

Share this post


Link to post
Share on other sites

Outputs do ring somewhat as far as I know / can tell. It's a function of the MOSFETs among other things. My analog scope shows ringing on MSP430 outputs as well as ATTINY85 and Atmega328 outputs. A resistor (100ohm) in line with whatever I'm switching removes it.

I get extremely similar ringing on MOSFETs that are switched too hard, a resistor between gate pin and MCU gets rid of it.

Jeelabs did a thing on it, too:  http://jeelabs.org/2012/12/05/ringing-mosfets/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×