is 100% duty PWM output on a pic effectively 5V out ? - Page 1
Forum section: electronics / general

author: Simon
author_rank: Unknown
timestamp: October 13, 2012, 05:44:41 pm
content: well as title. If I set the PWM duty at 100% is that effectively continuous output ?

author: Baliszoft
author_rank: Frequent Contributor
timestamp: October 13, 2012, 06:30:07 pm
content: It is, yes. Such as 0%.

author: Yaksaredabomb
author_rank: Regular Contributor
timestamp: October 18, 2012, 08:12:37 pm
content: 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.htmThe 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

author: Simon
author_rank: Unknown
timestamp: October 18, 2012, 08:14:19 pm
content: except I'm driving a mosfet that will run a fan

author: Yaksaredabomb
author_rank: Regular Contributor
timestamp: October 18, 2012, 10:21:28 pm
content: Okay nvm then haha. Sounds like fun.

author: exp1
author_rank: Contributor
timestamp: October 24, 2012, 02:05:24 am
content: Effectively, this little animation shows it pretty clear:

author: Simon
author_rank: Unknown
timestamp: October 24, 2012, 06:10:39 am
content: 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

author: Psi
author_rank: Super Contributor
timestamp: October 24, 2012, 06:26:21 am
content: I think that's because they cannot stop switching or bad things happen.So the PWM freq is always present.

author: Simon
author_rank: Unknown
timestamp: October 24, 2012, 06:53:04 am
content: 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

author: Psi
author_rank: Super Contributor
timestamp: October 24, 2012, 10:22:31 am
content: 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%

author: Simon
author_rank: Unknown
timestamp: October 24, 2012, 10:32:22 am
content: 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

author: Kremmen
author_rank: Super Contributor
timestamp: October 24, 2012, 10:45:59 am
content: 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?

author: Simon
author_rank: Unknown
timestamp: October 24, 2012, 11:34:13 am
content: Quote from: Kremmen on October 24, 2012, 10:45:59 amits 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

author: Kremmen
author_rank: Super Contributor
timestamp: October 24, 2012, 11:43:42 am
content: 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.

author: Simon
author_rank: Unknown
timestamp: October 24, 2012, 11:46:25 am
content: no circuit complication, just a small addition to the software

author: Kremmen
author_rank: Super Contributor
timestamp: October 25, 2012, 05:45:24 am
content: I wouldn't bother but then it is your boat. Whatever floats it, as they say.

author: Simon
author_rank: Unknown
timestamp: October 25, 2012, 06:47:36 am
content: 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.

author: Kremmen
author_rank: Super Contributor
timestamp: October 25, 2012, 07:45:30 am
content: Quote from: Simon on October 25, 2012, 06:47:36 amOK, that may be a valid reason. Defensive implementation is often a smart strategy.

author: Simon
author_rank: Unknown
timestamp: October 25, 2012, 07:47:26 am
content: 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.

author: Kremmen
author_rank: Super Contributor
timestamp: October 25, 2012, 07:50:58 am
content: So the guy needs a 101 primer on concepts of control theory

author: Simon
author_rank: Unknown
timestamp: October 25, 2012, 07:54:32 am
content: Quote from: Kremmen on October 25, 2012, 07:50:58 amGOD 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)

author: Psi
author_rank: Super Contributor
timestamp: October 25, 2012, 08:10:50 am
content: I think Bored@Work would explode if he met someone like that

author: Simon
author_rank: Unknown
timestamp: October 25, 2012, 09:03:57 am
content: Quote from: Psi on October 25, 2012, 08:10:50 amTo put it mildly yes

author: Thomas
author_rank: Regular Contributor
timestamp: October 27, 2012, 10:20:11 am
content: 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.

author: Simon
author_rank: Unknown
timestamp: October 27, 2012, 12:58:33 pm
content: 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 ?

author: Thomas
author_rank: Regular Contributor
timestamp: October 27, 2012, 02:26:27 pm
content: 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.

author: Simon
author_rank: Unknown
timestamp: October 27, 2012, 02:51:54 pm
content: 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

author: shebu18
author_rank: Frequent Contributor
timestamp: October 27, 2012, 03:12:54 pm
content: 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

author: Simon
author_rank: Unknown
timestamp: October 27, 2012, 03:32:05 pm
content: 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

author: hlavac
author_rank: Frequent Contributor
timestamp: October 28, 2012, 06:18:54 pm
content: 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%!

author: Simon
author_rank: Unknown
timestamp: October 28, 2012, 06:21:23 pm
content: 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

author: Kremmen
author_rank: Super Contributor
timestamp: October 29, 2012, 09:29:18 am
content: 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.

author: Simon
author_rank: Unknown
timestamp: October 29, 2012, 11:58:25 am
content: 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.

author: Kremmen
author_rank: Super Contributor
timestamp: October 29, 2012, 01:18:56 pm
content: 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 ...

author: Simon
author_rank: Unknown
timestamp: October 29, 2012, 01:23:17 pm
content: 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, the question was originally meant more generically academically.