PWM signal from 555 timer - Page 1
Forum section: electronics / projects

author: fsleeman
author_rank: Regular Contributor
timestamp: September 25, 2010, 02:14:05 pm
content: I have been trying to make a PWM generator from a 555 to control a fan and started with this circuit:http://www.kpsec.freeuk.com/555timer.htm#astable.I have been able to make an LED flash at the specified frequency but haven't had luck correctly setting the duty cycle.The formula is:Duty cycle = (R1 + R2)/(R1 + 2R2)which I have seen in other places as well. When I try to make that circuit, I seem only get a duty cycle close to 50% when I inspect it with an oscilloscope. When I change the R1 and R2 resistors in the shown circuit, I seem to get a lot closer to the duty cycle I am trying to get.Can anybody verify if this formula or circuit is correct? If I am trying to get a 75% duty cycle, what values should actually work? If I solve the equation, it seems that if R2 is 10k then R1 should be 20K. Is that correct or am I doing this wrong?

author: Mechatrommer
author_rank: Super Contributor
timestamp: September 25, 2010, 02:21:06 pm
content: i strongly believe 555 only produce 50-100% duty cycle, thats the reason i abandoned it. you will sometime have to cope with resistor inaccuracy (5%? 10%?) so my advice is to use potentiometer to adjust to desired PWM.

author: Zero999
author_rank: Super Contributor
timestamp: September 25, 2010, 02:33:54 pm
content: It's possible to go down to near 0% by adding a diode, see the datasheet.Add a couple of diodes, a potentiometer and you can get PWM from 1% to 99%.

author: Mechatrommer
author_rank: Super Contributor
timestamp: September 25, 2010, 02:41:55 pm
content: great!

author: qno
author_rank: Frequent Contributor
timestamp: September 25, 2010, 03:01:54 pm
content: Hi,If you want a simple 0 to 100% pwm with an 8 pin dil look at this circuit.http://www.extremecircuits.net/2010/07/luxury-car-interior-light.htmlReplace the switch with a potmeter on pin 6 of opamp B and you are in business.

author: Mechatrommer
author_rank: Super Contributor
timestamp: September 25, 2010, 03:07:53 pm
content: great!

author: Zero999
author_rank: Super Contributor
timestamp: September 25, 2010, 03:35:35 pm
content: Quote from: qno on September 25, 2010, 03:01:54 pmYes, that circuit's a classic, much better than the 555 since it will go from 0% to 100% and not much more complicated either.I'd probably replace the op-amp with a comparator IC (e.g. LM393) which will have a faster rise/fall time so will switch the MOSFET faster, although you'll need a couple of extra pull-up resistors as the ouput is open collector. Even better, choose a comparator with a push-pull output (I can't remember one of the top of my head) and get rid of the pull-up resistors.EDIT:Some more PWM oscillators based on CMOS logic gates (4000 series or HC, not TTL/LS). The simplest is a Schmitt trigger but you might not have a 74xC14 IC handy, the others use plain inverters so NAND/NOR gates can be used, the one with three gates has the advantage of requiring less external components than the one with only two gates.

author: fsleeman
author_rank: Regular Contributor
timestamp: September 25, 2010, 07:27:15 pm
content: I will look at the op amp circuit but I am only looking for a very simple, static pwm signal. Since this fan is going to be enclosed in another device, I dont want to use a pot. If these 555 circuits work, I would like to know how to set a specific duty cycle.

author: Zero999
author_rank: Super Contributor
timestamp: September 25, 2010, 08:58:16 pm
content: It's pretty easy to figure that out.The pot can be split into two halves, because the diodes ensure the current takes a different path when charring than it does discharging.When the pot is at 50% of its setting the duty cycle will be 50% because the charge and discharge times will be the same.When the part of the pot connected to the diode pointing down is highest (say 90k) and the part connected to the diode pointing up is lowest (say 10k), the duty cycle will be high (about 90%) because it will take longer for the capacitor to charge than it does to discharge.It works the other way round too, if the part of the pot connected to the diode pointing up is 90k and the part of the pot connected to the diode pointing down is 10k, the duty cycle will be about 10%.The resistor above the pot should be very small compared to the pot (too high and the minimum duty cycle will be limited) but not too small otherwise the 555 will overheat, 1k is 1% of 100k which is fine.The frequency is equal to the normal 555 timer formula listed on the datasheet but the value of the pot is halved or if it's two resistors, it's equal to the mean.The same applies to all the circuits with the logic gates.The comparator circuit is a little more complicated but it's probably not worth it for a fixed duty cycle.

author: tecman
author_rank: Frequent Contributor
timestamp: September 27, 2010, 03:19:22 pm
content: Here is a great little circuit we have used for years. It uses a 556 (or 2 555 chips). The upper 555 is an oscillator running at a constant frequency. The frequency is set by Ton and Toff. Ton is R2-C1 and Toff is R3.2 and C1. In this case it is a 50:1 ratio, or 98% max on time. The lower 555 is triggered and cleared by the first 555, but by modulating the control voltage you can control the duty cycle from 0% to 98% The output is comprised of the two open collector transistors wired-or'ed. This is nice since it gives you a constant frequency which is required in some circuits. Voltage is shown as 12 but can be anything in the usable range of the 555. Also watch using this at high frequencies as the 555 gets a little unpredictable over about 20 KHz.Paul

author: Rhythmtech
author_rank: Regular Contributor
timestamp: September 27, 2010, 05:43:30 pm
content: Wow, I am impressed nobody suggested to "just use a micro" Nice pwm circuits, will definitely keep this thread handy for future use.

author: Bored@Work
author_rank: Super Contributor
timestamp: September 27, 2010, 08:45:35 pm
content: Quote from: Rhythmtech on September 27, 2010, 05:43:30 pmWhile this is a valid suggestion, I have learned in the past that people just don't want to here that suggestion. Low-end 6 pin or 8 pin micros are cheap, have better oscillator stability, are more flexible, require less additional components than a 555, but people want a 555.

author: DavidDLC
author_rank: Frequent Contributor
timestamp: September 27, 2010, 09:22:39 pm
content: Yes, but you need to:1.- Create a program2.- Have a programmer3.- Who knows.....And with the 555 just make the calculation, plug the components and it works !!! Oh wait, sometimes is not that simple....I don't mind to implement either solution, it is just a matter how I feel doing things that day....

author: Zero999
author_rank: Super Contributor
timestamp: September 27, 2010, 11:22:46 pm
content: Quote from: BoredAtWork on September 27, 2010, 08:45:35 pmMCUs (especially the cheap ones) also have many disadvantages compared to a simple 555 or logic even if one ignores the learning curve or requiring a programmer:The cheapest MCU is still more expensive than a single 555 or logic IC, even when external components are accounted for.A MCU is more picky about the power supply voltage: 2V to 5.5V at best, a typical 555 can operate from 4.5V to 18V (TTL), CMOS 555s operate over 3V to 18V, HC logic works from 2V to 6V and some LV logic can work below 1V. Yes, I know that some MCUs have built-in voltage regulators but they're more expensive and the output high voltage is the regulated voltage, not the supply voltage.A 555 has a high current output capable of sourcing or sinking up to 200mA which is enough to drive a tiny motor directly, switch a MOSFET very quickly or give a power BJT plenty of base drive. MCUs are limited to a maximum current of 25mA per I/O pin and even if several I/O are paralleled (assuming this can be done) the limit for a port is 75mA.MCUs are more sensitive to noise than simple logic gates or a 555.Using a MCU would need the variable resistor to be replaced with a couple of push-buttons which isn't as ergonomic as a pot and the value isn't saved unless you use an MCU with data flash memory which costs more. The solution of course is to use an MCU with an ADC but, again, that increases the cost.In my opinion, there's no point in using an MCU for this, unless it's already doing something else, it's purely for educational purposes or your project needs to use push-buttons because there isn't room for a pot.Another thing: did you know that the whole 555 can be connected with a MOSFET in a bootstrapping configuration so the whole circuit can be just connected in series with the load?As well as simplifying wiring, it has the advantage of being able to do high side drive with an N-channel device which will be cheaper and have a lower on resistance.It's better to use a CMOS 7555 because the lower current requirement means the capacitor is discharged less.The disadvantage is that there's a minimum load requirement and the duty cycle can't be 100% as the capacitor charges when the switching transistor is off. The circuit attached gives calculations which can be used to calculate the minimum load current and the maximum duty cycle. The minimum ripple valley (VC1 - one diode drop - Vripple) should be above the voltage required by MOSFET gate to allow it to pass the required current for the load, otherwise it will get hot.Another option is to use a logic IC circuit shown above, configured in a similar way but I chose the 555 timer because it's more on topic.

author: Bored@Work
author_rank: Super Contributor
timestamp: September 28, 2010, 05:56:32 am
content: As I wrote, people just don't want to hear it. E.g. a low-end micro is in the 0.50 USD range in quantity. So much forQuoteIt could go on, but as I have learned in the past, people just love their 555, deal with its power supply glitches, its temperature drift and instability and all its other nastinesses.

author: Simon
author_rank: Unknown
timestamp: September 28, 2010, 11:45:25 am
content: Quote from: Hero999 on September 25, 2010, 02:33:54 pmyou can get yet closer to 0/100% by powering the RC circuit from output and no using the discharge pin, in this way you don't need the minimum resistor as during discharge there is no supply to protect from and it discharges through the output whilst low (totem pole output)

author: Zero999
author_rank: Super Contributor
timestamp: September 28, 2010, 02:53:09 pm
content: Quote from: BoredAtWork on September 28, 2010, 05:56:32 amI've heard that many times before but never seen any evidence that MCUs are really cheaper, care to post some links?So what the cheapest MCU might only be $0.50 in large volumes but the 555 or logic ICs are still much less when bought in the same quantities.The cheapest MCU I can find in RS is the PIC10F204 at £0.25 each, in quantities of 100.http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=7047627The cheapest 555 is only £0.088 each, in quantities of 75.http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0785818AWhat about logic gates?A quad NAND IC can be bought for just £0.064 in quantities of just 10, even less than the 555. I found some cheaper single gate packages but you can't make an oscillator with one gate unless it's a Schmitt trigger.http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=6631887Then what about using a Schmitt trigger? Good idea (even though I do say so myself) a single Schmitt trigger IC can be bought in quantities of 50 for just £0.047http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=0510352Go on tell me I'm wrong again, show me where you can buy genuine MCUs for £0.047 (just 7.44 US cents) each in quantities of 50 from? All right maybe that's not fair, a Schmitt trigger IC will require a extra resistor (or a couple of diodes in this case) so as add on 0.5p (0.8 cents) assuming you buy your resistors in 100s not 1000s or a little more for a dual diode.Don't get me wrong, you raised some valid points regarding flexibility, oscillator stability and accuracy but cost is not one of them, sorry it's bullshit.I like MCUs myself and are just getting into them but would never use one to just flash a couple of LEDs alternately. I'd opt for a logic IC every time, especially if it's run from a higher voltage than 5V: no need for a separate regulator and the old CD4000 series has current low outputs which are handy for directly driving LEDs: no series resistor required.Quote from: Simon on September 28, 2010, 11:45:25 amYou mean as per my previous circuit using the 7555, so it's being used as a Schmitt trigger?Yes, that will work very well, as long as you're aware that with the NE555 (not the CMOS versions) there's slightly more output saturation loss when sourcing (1.4V) than when sinking (<100mV) which will make the frequency and duty cycle more dependant on the power supply voltage, the load connected to pin 3 and that when the resistor is in the centre position the duty cycle will be higher 50%, especially at low supply voltages.I'd recommend that sort of configuration for CMOS versions (TS555, TLS555 ICM7555 etc.) rather than the TTL because it doesn't suffer from and of the issues described above, as long as the output isn't loaded too much.

author: TheWelly888
author_rank: Frequent Contributor
timestamp: September 28, 2010, 06:42:10 pm
content: It takes longer to program an MCU especially if you are not familiar with the MCU, development software and programming language used.A 555 circuit is a hell of a lot easier to implement and more fun to learn how it works too!

author: fsleeman
author_rank: Regular Contributor
timestamp: September 28, 2010, 07:32:41 pm
content: Quote from: BoredAtWork on September 28, 2010, 05:56:32 amI wanted to used a 555 because it would less work for me and I wanted to try something other than a micro. Also, since the VCC is already going to be 12V and the PWM is driving a 12V fan, I don't have to deal with input voltage. There are very few technical issues with this trivial project so mostly I wanted to learn something and keep it simple.Hero999, thanks for the circuit and description it worked without problems. You said that the resistances should be the average of each side of the pot. Does that mean that changing the position will change the frequency as calculated with this formula?f = 1.44 /((Ra + 2Rb)*C)

author: Zero999
author_rank: Super Contributor
timestamp: September 28, 2010, 08:02:14 pm
content: QuoteThe frequency won't change as the pot's setting is adjusted because when the duty cycle is set high, the capacitor takes longer to charge than it does discharge and when it's low it takes longer to discharge than charge.In the circuit I posted, Ra = 1k and Rb = 50k, remember it's split into two halves by the diodes and 50k is the average value, regardless of whether the wiper is high or low. Of course with a pot, the formula can be simplified to f = 1.44/((Ra + Rpot)*C)If two resistors are used instead of the pot, the formula you posted can be used with Rb being equal to the average of the two resistor values.

author: fsleeman
author_rank: Regular Contributor
timestamp: October 04, 2010, 03:23:02 pm
content: Thanks again for the suggestions. This may be a dumb questions, but why are MOSFETs the preferred transistor type for these sorts of applications? Is it max power, heat dissipation, leakage current or something else? Also, is there a reason to use the IRL540 instead of another MOSFET?

author: Zero999
author_rank: Super Contributor
timestamp: October 04, 2010, 05:27:47 pm
content: A MOSFET is faster, requires less current from the 555 IC to drive the same load as a BJT and has lower conduction losses than a BJT.I suggested an IRL540 because it is a logic level MOSFET so has a lower threshold voltage. Unfortunately, I didn't read the datasheet properly, the maximum gate voltage is only 10V so if you want to run it off higher voltages you should either run the 555 off 5V to 10V (use an LM317, LM7805, LM78L08 etc.) or use a non-logic level MOSFET such as the IRF540 who's gate voltage rated to 20V - more than the 555.Oh I think I know where I went wrong now. I was confused, the IRL540Nhas a gate voltage rated to 16V and a is a logic level MOSFET, meaning it can be driven from a 5V logic IC output.http://www.irf.com/product-info/datasheets/data/irl540n.pdfWhat voltage are you running this from? I briefly read the thread again but I could've missed it.

author: fsleeman
author_rank: Regular Contributor
timestamp: October 04, 2010, 06:18:25 pm
content: I am tapping off a 12V source and would run at that voltage if possible. The LM555 data sheet from National Semiconductor rates the chip at max VCC at 16V so I am assuming 12V would be OK.

author: Simon
author_rank: Unknown
timestamp: October 04, 2010, 06:22:00 pm
content: an IRF540 will be fine then

author: qno
author_rank: Frequent Contributor
timestamp: October 04, 2010, 06:43:39 pm
content: One reason to implement the PWM controller in Analog is that you can debug the circuit with your oscilloscope.Its a great learing experience and it brushes up your knowledge of Opamps, Comparators, Mosfets, Ohm's law etc.

author: fsleeman
author_rank: Regular Contributor
timestamp: October 24, 2010, 07:56:56 pm
content: I finally got a power fet (IRL510 is that I could easily get) and realized that what I have is not actually a PWM fan. Use the amplified PWM signal as the input power works but has a slight hum from repetitively low PWM frequency. I had to use a frequency much lower than 25kHz because the short bursts were not enough to overcome the rotational inertia of the fan. Frequencies in the 1kHz seem to work fine.I was able to use a simple low pass RC filter to make the PWM signal to nice DC voltage when driving an LED, but when I tried to use the filter with MOSFET output it didn't seem to work correctly. I am obviously missing something so does anybody know how I would filter an amplified PWM signal through a transistor to get an amplified DC voltage?

author: Zero999
author_rank: Super Contributor
timestamp: October 24, 2010, 09:38:22 pm
content: Don't try to filter the output to power a fan, it will reduce the efficiency and defeat the whole purpose of using PWM.

author: fsleeman
author_rank: Regular Contributor
timestamp: October 24, 2010, 11:17:32 pm
content: Just to be clear the fan is NOT a PWM controlled fan, its a normal 12V DC fan with a tachometer feedback line. My two options are to rectify the PWM to get a clean DC signal OR pulse the DC fan with the PWM signal. Assuming Hero999 understood me correctly, then the preferred method is to simply amplify the PWM signal to pulse the fan?

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 25, 2010, 12:21:40 am
content: i'm thinking whats the point of filtering PWM? better with DAC in the first place. but reading back @fsleeman post, maybe its the availability issue.Quote from: fsleeman on October 24, 2010, 07:56:56 pmthe point is not the short burst is not enough for inertia. a pwm is a pwm regardless of freq, its more regarding duty cycle. a 50% duty cycle of 1KHz PWM is the same effective power/rate as 50% 25KHz PWM. you cannot state that... for higher freq PWM, it is a "short burst". maybe in your case, there is some other factor that prohibit higher freq PWM driving your fan, internal circuitry and filtering maybe.in order to filter or smooth out the PWM, i think you'll need to put proper capacitance value on the mosfet/transistor output. for higher freq pwm, lower C value is needed, not remember the formulation, gotta open back my thick book to know.

author: .o:0|O|0:o.
author_rank: Regular Contributor
timestamp: October 25, 2010, 01:48:20 am
content: Quote from: fsleeman on October 24, 2010, 11:17:32 pmHero666 is right, "Don't try to filter the output to power a fan, it will reduce the efficiency and defeat the whole purpose of using PWM."Since you have chosen PWM to select a particular speed (not the most efficient use of your supply, but you wanted to experiment with the 555...), the purpose of PWM is to deliver controlled amounts of current to your motor. Having from 0V to 12V (supply) provides you with the maximum range of currents available to you (which is the whole point of the MOSFET, in this case).The problem with inertia is overcome through a gradual increase in the PWM rate before fixing on to a final value (ideally, you would like the current RMS gradient to ramp up initially). The problem with hum is overcome by selecting a frequency low enough to make the energy transfer to the motor as efficient as possible (your DC motor is most efficient at 0 Hz and resonates at certain frequencies depending on its physics) or selecting a frequency above the audible range (or at any frequency that suits the particular physics of your motor).As Shafri said, you seem to be confusing duty cycle with switching frequency. You can have whatever duty cycle you like at whatever switching frequency suits your motor. It is just a case of switching the MOSFET on for n cycles and off for m cycles (though I am not sure how this is being achieved with the single 555 so far).My first instinct would have been to use an MCU, especially since you mentioned PWM and tacho-feedback, but if you can do it for less money and complexity with a 555 then I would be interested to know how it turns out!.o:0|O|0:o.

author: fsleeman
author_rank: Regular Contributor
timestamp: October 25, 2010, 01:42:23 pm
content: Quote from: .o:0|O|0:o. on October 25, 2010, 01:48:20 amI understand the difference between duty cycle and switching frequency. I agree that a 50% duty cycle at 1Hz delivers the same total power as a 50% duty cycle at 1MHz (assuming no rise/fall time), but that has nothing to do with the inertia of the fan. Lets say you need to push a broken-down car. If you push the car in quick short shoves will it move the car as well as long sustained pushes? Obviously the answer depends on a number of factors but static friction is always greater than kinetic friction. If I start the fan with a high switching frequency, nothing happens unless I manually turn the fan. Once the static friction is overcome the fan runs normally. Since I am going to put this into a overheating piece of electronics manually starting the fan is not a viable solution.The unfiltered PWM signal will be sufficient solution to the problem. I have another fan with the tach output which I might experiment with a micro, its not needed for this project. I just want a fan that runs at a speed lower than 100% I figured I'd use the circuit I already built. Thanks again for everybody's suggestions, it was an educational thread.

author: Zero999
author_rank: Super Contributor
timestamp: October 25, 2010, 05:17:24 pm
content: It's not that simple.Higher frequencies won't work because of the inductance of the motor or in this case, the drive electronics inside the DC brushless motor won't like a power supply switching at 1MHz.

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 25, 2010, 05:21:18 pm
content: Quote from: fsleeman on October 25, 2010, 01:42:23 pmmaybe you can ramp at 100% during start for a while, say half a second, just to get the motor moving, and later the PWM reduced back to normal/required operating level. just an opinion, you know your stuff

author: fsleeman
author_rank: Regular Contributor
timestamp: October 25, 2010, 05:36:19 pm
content: Quote from: Hero999 on October 25, 2010, 05:17:24 pmI am not sure if you were disagreeing with me or someone else on the thread, but I agree with your statement. That was the point I was trying to make, sorry if I weren't clear.

author: .o:0|O|0:o.
author_rank: Regular Contributor
timestamp: October 25, 2010, 08:46:03 pm
content: If the inertia is overcome at 0 Hz directly from the 12V power supply then I don't see why correct selection of PWM rate and start-up duty cycle wouldn't approximate a similar rms current. 1 MHz switching rate is too high. You should keep it below 30 kHz probably (consult the motor datasheet if you can find the part number). Also note that most people cannot hear sound beyond 19 kHz, let alone 22 kHz or 24 kHz. Here is a PIC appnote; a MOSFET is used and there is a discussion about common issues with PWM:http://www.jimfranklin.info/microchipdatasheets/00847a.pdf.o:0|O|0:o.