EEVblog Electronics Community Forum
Electronics => Microcontrollers => Topic started by: Simon on October 13, 2012, 05:44:41 pm
-
well as title. If I set the PWM duty at 100% is that effectively continuous output ?
-
It is, yes. Such as 0%.
-
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 (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
-
except I'm driving a mosfet that will run a fan
-
Okay nvm then haha. Sounds like fun.
-
Effectively, this little animation shows it pretty clear:
(https://upload.wikimedia.org/wikipedia/commons/0/02/PWM_duty_cycle_with_label.gif)
-
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
-
I think that's because they cannot stop switching or bad things happen.
So the PWM freq is always present.
-
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
-
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%
-
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
-
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?
-
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
-
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.
-
no circuit complication, just a small addition to the software
-
I wouldn't bother but then it is your boat. Whatever floats it, as they say.
-
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.
-
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.
-
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.
-
So the guy needs a 101 primer on concepts of control theory ;)
-
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)
-
I think Bored@Work would explode if he met someone like that :D
-
I think Bored@Work would explode if he met someone like that :D
To put it mildly yes :)
-
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.
-
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 ?
-
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.
-
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
-
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
-
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
-
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%!
-
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
-
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.
-
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.
-
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 ...
-
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.