Discussion in "8051 Discussion Forum" started by    dstarke    Oct 22, 2007.
Mon Oct 22 2007, 07:10 AM
Thanks for the forum!

I have never implemented PWM before, and as such have no idea of what values for on/off times are a good starting point. I am trying to vasy the speed of a 12VDC fan using a MOSFET (IR540N) via a 7406 level shifter driven by an ATM89C55WD port pin. I think I would like to drive a counter externally with a 500 uSec pulse, and use it as the quanta for the interrupt to create on/off pulses. Is this too fine grain? What would be a reasonable nominal cycle time? 20mSec? Like I said, I have no real handle on the basic cycle time or what would be a reasonable minimum on time.

I can't figure out the formula for #levels vs min on-pulse vs cycle time vs Fan V+. Unless I am mistaken the fan speed is directly related to the fan-v+ and the integral of the on-pulses. Is it advantageous to use a larger fan V+ (like 15V for example) to provide more control?

I am writing the code in C (Keil) but can just as well use assembly (a small learning curve there).

Thank you in advance for yout kind input, and RTM is greatfully received if you can direct me to the relevant manuals.


Mon Oct 22 2007, 08:45 AM
well i never took PWM this serious

Lets just discuss the factors one by one.
first Fan V+ - It will increase the speed of motor and if its higher than the maximum rating of fan then it can ultimately burn the coil. So i Whatever voltage you use keep it <= max rating.
the more important is the current being supplied to the coil. That should be enough to generate sufficient torque. here also.. keep the current less than the max rating.

Now talking about the minimum pulse time.. i say.. there is no specific, it depends on the motor how fast it reacts to the change in polarity of the voltage. So all you can do is experimenting..
What i did was.. used timer in Mode 0 and varied the value to be loaded in THx of the timer..
lets say..
if THx is loaded with a value X when Pulse is ON or high, then THx should be loaded with value 255-X when Pulse is OFF or how.

I found that there is no directly proportional change in the speed vs the loaded value, rather there is a parabolic change in the speed.. i mean.. variation in o/p at higher values are pretty close to each other than the lower values.

So you might need to do experimentation according to the components you use and value you load. PWM seems difficult but its not so difficult.. its just need some experimentation thats all... So give it a try..

I cannot see your circuit too clear but as per the parts you mentioned the circuit seems to be ok. you have connected all the things necessary. As you are just sinking the current so just a normal NPN can also be used in place of that MOSFET. but make sure of the current and voltage that can be handled also heat sink if necessary.

regarding the code.. you can try working on it but there is also an assembly code posted by me in the forum "Project Doubt" with topic name temperature controlled fan.. if you want to see it then you can take it as a reference.

Get Social


Powered by e107 Forum System


Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.
Thu Jul 11 2019, 07:55 PM
@ramos https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html
Thu Jul 11 2019, 07:44 PM
@praveen123. Can you give a link to the project ?



Tue Nov 19 2019, 03:13 PM
Mon Nov 18 2019, 11:00 AM
Wed Nov 13 2019, 06:25 AM
Mon Nov 11 2019, 01:31 PM
Sun Nov 10 2019, 04:42 AM
Sat Nov 09 2019, 03:41 PM
Fri Nov 08 2019, 10:06 AM
Fri Nov 08 2019, 07:28 AM


Guests: 29, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38105
Newest member: auwal
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 19 2019, 10:44 PM
The 8051 has too little memory to do anything us...
ilylily07 Avatar
Posted By ilylily07
Mon Nov 18 2019, 09:54 AM
0v7670 camera interfacing with stc 8051.using asse...
Jeanbusatta Avatar
Posted By Jeanbusatta
Sun Nov 10 2019, 04:43 AM
ty, really needed it
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Oct 22 2019, 05:18 AM
wimac Avatar
Posted By wimac
Mon Oct 21 2019, 09:18 AM
I’ve been following this thread and looking at the...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 03:09 PM
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 03:02 PM
sir, when i on display ,sometime 3rd display is no...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sun Oct 20 2019, 02:53 PM
sir, when i on display ,sometime 3rd display is no...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 20 2019, 12:21 AM
Your code seems okay on my simulationTry my code o...
s_dinesh40@yahoo.com Avatar
Posted By [email protected]
Sat Oct 19 2019, 07:13 PM
please find video attachment. 3rd & 4th displa...