PDA

View Full Version : Discussion PIC Hardware PWM


rocky79
Jul 26, 2007, 01:35 AM
Hello,

I managed to get the hardware PWM working on the pic12f683 but the resulting waveform at low duty cycle is shown in the pic. It is not a clean square wave. Why is the rising and falling edge have a noticeable charge/discharge time?

Had I not used the hardware PWM and tried raising a pin high and low continuously it would look as if it's perfect square wave with this time base.

Thanks

xtal
Jul 26, 2007, 04:59 AM
Could just be due to the loading induced by the scope probe.......

Try using a high imp. probe that can be compensated....and check the the
probe with a calibrator before using..... If you have access to a Tektronic scope
and probe or equivilent use that..

Acetronics
Jul 26, 2007, 05:50 AM
Hi, Rocky

Did you place the decoupling cap between VDD and VSS pins close to those pins ??? :rolleyes:

I generally use a .22µF CMS chip between the pins ... no problems then.

Alain

vintage1
Jul 26, 2007, 05:56 AM
Looks like a classic case of a mismatched probe to me..

Rise time is fine..its just the tops ain't flat!

Neil Stainton
Jul 26, 2007, 07:23 AM
Vintage (or anyone else), can you please explain about oscilloscope probes, or point me to a helpful web page? I got my oscilloscope second hand and have never studied electronics and don't understand why I can't directly wire the BNC input to the circuit being measured (using co-ax cable of course).

TIA,

Neil.

Acetronics
Jul 26, 2007, 07:32 AM
Vintage (or anyone else), can you please explain about oscilloscope probes, or point me to a helpful web page? I got my oscilloscope second hand and have never studied electronics and don't understand why I can't directly wire the BNC input to the circuit being measured (using co-ax cable of course).

TIA,

Neil.

Hi, Neil

You can :rolleyes: link the BNC input directly to your circuit ... note "clamp" to BNC adapters and Banana plugs to BNC adapters exist ...

just respect max input voltage specs ...

and remember your osc. input places a 1MOhm resistor between signal and ground. ( 1/10 probe places ... 10 MOhms ! )
PIC oscillators are then disturbed ...


Alain

rocky79
Jul 26, 2007, 10:51 AM
It wasn't shown in the scope previous picture but when i increase the duty cycle the whole wave shifts up by about 20mv. the peak pulse value will then be 5.20v. How can this happen and why when the pic micro supply is only 5v?

AND BTW REGARDING THE SCOPE NOTE:
I have another pic that generates PWM but it's a software PWM using the pic12675.I hooked it up to the same scope but it doesn't have that problem. As soon as it rises it flatens out to 5v.

YES I also used a 0.1UF bypass cap from VDD to ground.

:confused:

JimDrew
Jul 26, 2007, 12:20 PM
It could be that the PWM output pin is too heavily loaded. The output drive of the PWM pin is not much while in PWM mode.

John Pilot
Jul 26, 2007, 01:24 PM
I don't know what the circuit around your PIC looks like, but you either are putting too much capacitive loading on the outputs, OR your scope probe is not adjusted right.

Scope probes have little built-in electronic circuit consisting of one or a few resistors and one or a few very small capacitors.
One of the resistors is trimmable and can be adjusted to calibrate the scope.
The way you do that is by hooking the probe up to a square wave generator that generates a calibrated square wave. You then turn the trim pot until the signal you see on you scope is also a perfect square wave.
I have a digital scope and the square wave generator used to calibrate the probe is built-in. Your scope manual should have this information in it.

rocky79
Jul 26, 2007, 01:29 PM
I calibrate the probe and the signal looks now a perfect square wave.

The reason i hooked the pin up to a a scope is because the pwm signal connected to a mosfet seems to be drawing 100ma more at 65% duty cycle than full duty cycle.

Looking at the scope i saw that as i increase the PWM duty cycle the WAve shifts up by 20mv. peak value is 5.20.

I am not sure what's happening here. It's a major source of headache at work.

Thank you for your replies

JimDrew
Jul 26, 2007, 02:41 PM
Disconnect the PWM pin from anything on your PCB (including any caps) and see if the voltage stays the same. You could be boosting with the external circuitry.

rocky79
Jul 26, 2007, 05:19 PM
Ok, This is what happens after i calibrated the probe and connected the PWM channel directly to the scope probe.
The Wave looks square now but there is one problem that is presistant.
The problem is when the duty cycle is between 95 to 99.9% the high voltage becomes 5.20v instead of 5v.It goes down to 5v at 100% duty cycle.Why is that?
Picture on:
the left shows the normal 5v high signal --to the Right the high is 5.16v