PWM Problems

ewug89

New Member
I'm using 18x chip with the CH1030 project board, and cannot get the pwmout pulses to work! Depending on period, mark/space ratios all I get is narrow pulses that rise in amplitude rather than width, or arising voltage with triangular waveform on top.

Simple high/low on an output pin works perfectly on scope display.

for evaluation purposes I use

init: let b0=0
start:let b0=b0+1
pwmout 3 , 255, b0
if b0>1022 then init
pause 100
goto start

Later I just used the pwmout insruction as a static one line statement , so there would be no other 'timing' conflicts still same problems. All other aspects work perfectly. I've even used another 18x chip still same result. I'm slowly gonig mad! Hope someone can come up with solution
 

Taniwha

Senior Member
I'm using 18x chip with the CH1030 project board, and cannot get the pwmout pulses to work! Depending on period, mark/space ratios all I get is narrow pulses that rise in amplitude rather than width, or arising voltage with triangular waveform on top.

Simple high/low on an output pin works perfectly on scope display.

for evaluation purposes I use

init: let b0=0
start:let b0=b0+1
pwmout 3 , 255, b0
if b0>1022 then init
pause 100
goto start

Later I just used the pwmout insruction as a static one line statement , so there would be no other 'timing' conflicts still same problems. All other aspects work perfectly. I've even used another 18x chip still same result. I'm slowly gonig mad! Hope someone can come up with solution
I tested my CHI030 board with the PWM driving an LED with no problem, it dimmed the LED smoothly (once i took the "debug" command out!!). Instead of using the b0= b0+1 string i used a pot across pin 0 and a "readadc 0, b0" then a "readadc10 0, w0" both worked remarkably well. However in thinking about it don't bytes only go to 255? it will never reach 1022. I would try changing the "b0' for "w0" as a byte will only give a duty cycle range of 0 - 25% (according to the Wizard at least)
 

ewug89

New Member
Further to PWM problems

Thanks for adivice. I've tried every combo of period, mark/space ratio there is on two 18X, and a 08M to still get the same result. As the mark ratio to the period increases the base voltage increases, there is a point where the high/low ratio is equal, but it's a 'curved' triangle wave, there is never any clearly defined vertical pulses to increase in width.

If you only needed to dim leds this still works, but I need the pulses to drive a mosfet H bridge which needs fast on/off pulses to prevent over heating.

Can any one out there verify on a scope the 'pulse shapes' they are getting?
 

MartinM57

Moderator
Every time I look at any PWM signal from any PICAXE on a scope, directly on the output pin, I see text-book PWM signals - near vertical edges (*), and with a mark:space ratio pretty much spot on with the programmed values.

Try disconnecting the PICAXE output pin from whatever it's driving and then measure.

Weird scope displays of what should be rectangular pulses is usually a earthing problem - the scope isn't earthed to the thing you are measuring.

(and you are DC coupled on the scope aren't you?)

EDIT: (*) well my fancy scope measures:
- an otherwise open circuit pin2 on an 08M (at setfreq m8) PWM out rise time (10% to 90%) of 17.32nS (yep, nanoseconds)
- a frequency of 20.046Khz (programmed as 20kHz)
- a duty cycle of 25.01% (programmed as 25%)
:)
 
Last edited:

Dippy

Moderator
I agree with Martin.

I get proper square wave, usually with the 'MOS' spike - which, by the way, can upset a few i.c. types when driving (rare, but take note! and it is curable).

As Martin says; check your input coupling to 'scope and your ground.

What sort of scope? A £5k Tek like Martin's or a 5 pence PC scope?

There is scope for error here .... haha.:)

If more than one PIC is giving this funny wave then it is your connections or your scope.

PS. If you are driving POWER MOSFETs you will NEED a proper MOSFET driver. The output stages of a PIC are NOT butch enough for fast PWM switching. Search on MOSFET drivers or phone Manie ;)
 

Dippy

Moderator
Martin, you Poser! :)
That looks good.
BTW: Have you made a decision yet...?
(If I was spending your dosh I'd say yes)
 

BeanieBots

Moderator
ewug89,
This might sound daft, but where on the board are you looking for these pulses?
Are you looking directly at the 18X (leg9) or the PCB output?
What do you have on output 3 and how have you connected it?
Do you have ANYTHING at all on the output?
 

manie

Senior Member
PS. If you are driving POWER MOSFETs you will NEED a proper MOSFET driver. The output stages of a PIC are NOT butch enough for fast PWM switching. Search on MOSFET drivers or phone Manie
Dippy I'm touched !

I get VERY SIMILAR waveforms on my (much cheaper) 'scope as Martin shows above. This led me to realise that ALL components have some form of Silicon and/or Tantalum and/or di-electric and/or SMOKE in them.... if the seals goes and the smoke leaks out they stop working !
 
Top