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

0 Members and 1 Guest are viewing this topic.

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
is 100% duty PWM output on a pic effectively 5V out ?
« on: October 13, 2012, 05:44:41 pm »
well as title. If I set the PWM duty at 100% is that effectively continuous output ?
 

Offline Baliszoft

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: hu
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #1 on: October 13, 2012, 06:30:07 pm »
It is, yes. Such as 0%.
 

Offline Yaksaredabomb

  • Regular Contributor
  • *
  • Posts: 124
  • Country: us
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #2 on: October 18, 2012, 08:12:37 pm »
One thing to keep in mind is that some circuits will not behave as expected at 0% or 100% pwm.  For instance, see the second chart on page 3:
http://www.meanwell.com/search/eln-60/default.htm

The LED driver never reaches 100% output even with 100% pwm, and it goes to 0% output as soon as you drop below 11% pwm.

Good luck!

Jacob
My display name changed June 6th from "jneumann" to "Yaksaredabomb"
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #3 on: October 18, 2012, 08:14:19 pm »
except I'm driving a mosfet that will run a fan
 

Offline Yaksaredabomb

  • Regular Contributor
  • *
  • Posts: 124
  • Country: us
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #4 on: October 18, 2012, 10:21:28 pm »
Okay nvm then haha.  Sounds like fun.
My display name changed June 6th from "jneumann" to "Yaksaredabomb"
 

Offline exp1

  • Contributor
  • Posts: 16
  • Country: ar
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #5 on: October 24, 2012, 02:05:24 am »
Effectively, this little animation shows it pretty clear:
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #6 on: October 24, 2012, 06:10:39 am »
Thank you, i feel like I'm in preschool now  ;), my concern was born out of the fact that some PWM drivers cannot achieve 100% duty but something like 99.9
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 7513
  • Country: nz
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #7 on: October 24, 2012, 06:26:21 am »
I think that's because they cannot stop switching or bad things happen.
So the PWM freq is always present.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #8 on: October 24, 2012, 06:53:04 am »
I guess the advanbtage of the pic is that it's pretty flexible hardware and being a programmable device does not have and circuit constraints
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 7513
  • Country: nz
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #9 on: October 24, 2012, 10:22:31 am »
Yeah, mcu's are designed to be as flexible as possible where as dedicated ICs like pwm drivers have their transistor counts cut down to reduce cost as much as possible. It isn't really an issue in most applications if the scale is 0.1% to 99.9%
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #10 on: October 24, 2012, 10:32:22 am »
well for my purpose i need to be able to stop the mosfet switching should the circuit start up and find that it is warm so that I can run the fan full blast to cool things down and then go back to PWM
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #11 on: October 24, 2012, 10:45:59 am »
If you can modulate between 0.1 and 99.9% then that is a good as full range. You certainly canot see any difference in he fan. I promise you it will not turn with 0.1 % modulation and if it should, it won't produce any air movement. Also, 99.9 % is as close to full speed as makes no difference. So why worry.
Why would you switch between PWM and full on when you can get the same result with PWM only?
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #12 on: October 24, 2012, 11:34:13 am »
If you can modulate between 0.1 and 99.9% then that is a good as full range. You certainly canot see any difference in he fan. I promise you it will not turn with 0.1 % modulation and if it should, it won't produce any air movement. Also, 99.9 % is as close to full speed as makes no difference. So why worry.
Why would you switch between PWM and full on when you can get the same result with PWM only?

its an air con unit and in the event the ecu is hot (because it was in the sun maybe before being started) I want the fan full on for as much air as possible and no mosfet switching so it don't get any hotter
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #13 on: October 24, 2012, 11:43:42 am »
For DC motor control you need a switching frequency in the hundreds of Hz or at most some kHz, anything more is useless. At those frequencies any decent MOSFET won't have any appreciable switching losses. If you pick a low Rds_on component, you can get an on-resistance comparable or lower than a regular relay - in the low milliohms range. So again: why bother to complicate the circuit when you can get all you need using the simple alternative? The fan will be full on at 99.9% modulation for all practical purposes. You won't gain anything at all from adding the last 0.1% with a relay.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #14 on: October 24, 2012, 11:46:25 am »
no circuit complication, just a small addition to the software
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #15 on: October 25, 2012, 05:45:24 am »
I wouldn't bother but then it is your boat. Whatever floats it, as they say.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #16 on: October 25, 2012, 06:47:36 am »
I have to keep a person who has no clue about these things happy and as I'm getting limited information about the final use I'm building in any safeguards I can for nothing.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #17 on: October 25, 2012, 07:45:30 am »
I have to keep a person who has no clue about these things happy and as I'm getting limited information about the final use I'm building in any safeguards I can for nothing.
OK, that may be a valid reason. Defensive implementation is often a smart strategy.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #18 on: October 25, 2012, 07:47:26 am »
Put it this way, it took me half an hour to get across to him that this is a feedback system and that he is not controlling a valve with a pot but that the pot is telling the system the desired temp and the system control the valve.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #19 on: October 25, 2012, 07:50:58 am »
So the guy needs a 101 primer on concepts of control theory  ;)
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #20 on: October 25, 2012, 07:54:32 am »
So the guy needs a 101 primer on concepts of control theory  ;)

GOD don't go there, he retires in under a year and as much as I like him I'll almost be relieved, to him everything is an input or an output, or it has a "switching action". The classic was when I tried to explain the feedback mechanism of a position potentiometer in the water valve, I had to explain each pin, the worrying bit was when he asked if the pot ground was an input or an output, I just wanted to run.

He also thinks that if i put spike suppression on the positive line, i need on on the negative (vehicle chassis too)
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 7513
  • Country: nz
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #21 on: October 25, 2012, 08:10:50 am »
I think Bored@Work would explode if he met someone like that :D
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #22 on: October 25, 2012, 09:03:57 am »
I think Bored@Work would explode if he met someone like that :D

To put it mildly yes  :)
 

Offline Thomas

  • Regular Contributor
  • *
  • Posts: 83
  • Country: no
Re: is 100% duty PWM output on a pic effectively 5V out ?
« Reply #23 on: October 27, 2012, 10:20:11 am »
Back on topic:
I don't know about Microchip timers, but I do know that AVR timers can achieve full 0-100% PWM depending on the PWM mode. Some modes can do it, some don't.

You should be able to find this information in the Microchip datasheet for the part you're using. Find a formula for the output duty cycle and work the numbers.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 #24 on: October 27, 2012, 12:58:33 pm »
well using mikroC (which i'm gradually weaning off of) setting the PWM value to 255 which they say in 100% produces a non 100% duty with a 250nS off time @ 20 KHz and 4 MHz clock, maybe something to do with the clock being too low to achieve resolution ?
 

Offline Thomas

  • Regular Contributor
  • *
  • Posts: 83
  • 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 Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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 Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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: 534
  • 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 Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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: 1283
  • 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 Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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: 1283
  • 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 Simon

  • Global Moderator
  • *****
  • Posts: 14449
  • 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