Author Topic: is 100% duty PWM output on a pic effectively 5V out ?  (Read 9936 times)

0 Members and 1 Guest are viewing this topic.

Offline Thomas

  • Regular Contributor
  • *
  • Posts: 117
  • Country: no
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #25 on: October 27, 2012, 02:26:27 pm »
Hm, that sounds strange.
On the AVR, it will be off for one timer tick at 100% and on for one timer tick at 0%. Almost like the range is 1-254 instead of 0-255 with 8 bit resolution.
It has been a while since I looked into these things (a few years), but I remember having to choose another PWM mode than planned to get full range.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #26 on: October 27, 2012, 02:51:54 pm »
it could be the stupid PWM library in mikroC or the fact that the clock is not fast enough full resolution, I should maybe try 8 mhz clock
 

Offline shebu18

  • Frequent Contributor
  • **
  • Posts: 309
  • Country: ro
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #27 on: October 27, 2012, 03:12:54 pm »
As far as I know there should be 3 modes of generating pwm. Did you try all 3?

Sent from my GT-I5800 using Tapatalk
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #28 on: October 27, 2012, 03:32:05 pm »
nope, just used the microC library, I'm using 4MHz clock so at 20KHz PWM frequency and 8 bit resolution that needs just over 20MHz clock but i'm on 4 MHz that gives about 7 bit accuracy but a fractional value
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #29 on: October 28, 2012, 06:18:54 pm »
It is very common for PWM peripherals to have a 1 cycle spike at one of the extreme ends.
If you think about it, they have N bit counter and N bit match register that can have values from 0 to 2^N-1.
These specify duty cycles of 0/2^N to (2^N-1)/2^N. Adding the one missing value (2^N) would be expensive and wasteful (adding extra bit to counter and match reg and not using all the new possible values).

Don't worry though, you can easily turn off the PWM and smack a hard H on the pin using GPIO if you want 100%.
I would not bother personally, the difference is just 1/256 or 0.39%!

Good enough is the enemy of the best.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #30 on: October 28, 2012, 06:21:23 pm »
yes quite, although if you read my explanation mid way through the thread the idea was to stop the mosfet from switching, and yes as you say safest bet is to just switch off PWM and do a "write1" to the port pin
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #31 on: October 29, 2012, 09:29:18 am »
OK, you can do this and you have said you want to do it and it is OK.
Still at the risk of laboring the point, can i ask, why exactly do you want to do it this way? I don't see a benefit in bypassing the pwm logic for what i see as no gain in the functionality. You only create the burden of controlling one extra element in the program logic. Admittedly it may be no big deal to do so, but the requirement demanding it escapes me.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #32 on: October 29, 2012, 11:58:25 am »
the switching mosfet will control a fan, this fan keeps the case the mosfet is in cool. In the event the case got hot due to being in a hot vehicle the circuit could switch automatically to full blast and not switch the already how mosfet to save making it hotter. I probably won't have this requirement but it was a thought and a promise to a senile old engineer to keep him happy and shut him up.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #33 on: October 29, 2012, 01:18:56 pm »
And you have already calculated that the MOSFET will actually heat up? Since the current would anyway flow through the MOSFET, whether switched or not, the channel on-resistance will make no difference. So the only effect heating the FET would be switching losses. For a DC motor (the fan motor is DC?) the switching frequency can be quite low, resulting in negligible switching losses. Honestly. For argument's sake say you have a 100V 10A motor (~1 kW) and you hard-switch the MOSFET. Say your FET switches in a leisurely 500 ns. The worst case instantaneous dissipation during the hard part of the switching sequence would be 1 kW. Simplistically calculating that over the 500 ns duration that would mean 500 nJ of dissipated energy. Say your pwm frequency is 500 Hz so you dissipate that 500 times a second for a total of 250 mW. This while switching a 1 kW load. For 100 W load the dissipation would be ~25 mW and so on. If you manage to switch briskly so that the state changes in ~100ns which is maybe a more typical value for a well tuned circuit, your dissipations fall to 50/5 mW, the latter being truly insignificant already.

But of course, if you made promises then there is no helping it ...
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #34 on: October 29, 2012, 01:23:17 pm »
well like you say it's no big deal but I can say that it can be done if needed, whether I do or not is another matter  8), the question was originally meant more generically academically.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf