Jump to content

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
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?

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.





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.

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.

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. 






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/

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...