Three frequencies PWM required

manie

Senior Member
I need to produce three PWM frequencies with variable duties. Frequencies are +- 14/28/42 KHz each with variable duty cycle. Can I use 08M's and/or 28x1's ?

Would I require external crystal for higher frequencies ? Would I require one of the x2's maybe ?

Manie
 

hippy

Ex-Staff (retired)
If you need them simultaneously then three 08M's would be my choice, but any PICAXE's with PWMOUT will do.

Whether you need a crystal depends upon what sort of accuracy you want with respect to frequency and the amount of duty cycle resolution you want. The higher the frequency, the shoter the period, the lower the duty resolution. Increase the PICAXE operating speed and you can reduce the period for the equivalent frequency out which increases the duty resolution.

An 08M can do 42kHz with 190 step resolution, a 28X2 at 40MHz has nearly 1000 step resolution. Have a play with the Programming Editor PWMOUT Wizard with duty set to 100%.
 

manie

Senior Member
I knew I bought the 5-pack of 08M's for some reason a while back. Now I know for what it was..... Good stuff and thanks.

Hippy: Why at 100% duty ?
 

manie

Senior Member
Are these commands correct ?

freq reqd: +- 42KHz at 50% duty
pwmout 2, 24, 46

freq reqd: +- 28KHz at 50% duty
pwmout 2, 36, 70

freq reqd: +- 14KHz at 50% duty
pwmout 2, 72, 142
 

eclectic

Moderator
Manie.

I was just about to send you the following:

Code:
While Hippy is flying round the Universe,
in his part-time job, 
here is a [i]possible[/i] reason for the "100%"

#picaxe 08m
REM  pwmout 100%  @14kHz, 28kHz, 42kHz

setfreq m4 

pwmout 2 , 70, 286 ;14
pwmout 2 , 35, 143 ;28
pwmout 2 , 23, 95  ;42

setfreq m8

pwmout 2 , 142, 571 ;14
pwmout 2 , 70, 286  ;28
pwmout 2 , 47, 190  ;42
e

How did you obtain your figures from post #5?
 
Last edited:

manie

Senior Member
EC: Thanks. I have drawn up an Excel sheet to do the calc's from basics, like the manual explains. The wizzard is OK if you're in a hurry but I need to understand where the figures come from (masochistic ??). I start from the required frequency, say 14KHz. Then 1/14000 = period in SECONDS etc. From there is plain sailing eg. (period+1)*4/(1/4000000) etc. That helps ?

You need to know the period etc to get to the Duty figure. At least I do....
 
Last edited:

manie

Senior Member
Dippy: Its so obvious once mentioned it makes me feel stupid, thanks.

This is the circuit I'm thinking of using. The 08M will drive a Mosfet, this time via a Tc4420. There will be three of course for the3 freq's. The Mosfet will pulse 12V into a step-up transformer, a custom wound Torroidal. Your insights and wisdom appreciated (while I wait for my BB form the East.......)

Edit: sorry here is the schematic. Explanation:

The 4-way DIP switch will enable selection of different frequencies on inputs 3/4. The third switch will enable selection of 50% or 80% duty. The fourth switch will enable "high's" and "low's" by switching the +5V "in/out", if all is low then PWM will be at preset freq. and 50% duty. The rest is standard PWM output on output 2. The application notes I got for the TC4420 Mosfet driver seems to stress that de-coupling is important so I have included all the suggested 100nF caps.

I think I have all the pull-down resistors etc. in place but please check me....
Thanks
Manie
 

Attachments

Last edited:

Dippy

Moderator
Oi! Leave me out of it :)

When checking PWM / Duty capabilities i always use the PICMulitCalc from Mister_E.

Not directly appropriate for PICAXE but miles quicker to see precisions / resolutions / step-size etc at particular PWM frequencies and crystal Fs.
 

manie

Senior Member
Having taken a lesson from Mowman's excellent question presentation I must add:

Both the 5V and 12V supplies are from 7805 and 7812 regulators with my favourite "PNP pass transistor" circuit for additional current capability. Both these supplies are adequately de-coupled and the raw main supply is also de-coupled with a 63V 4700uF plus 100nf caps. So the small caps shown in the schematic are additional to those "main" smoothing caps.
Manie
 
Top