Maker Pro
Maker Pro

Need to build a simple PWM generator

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
Hello everyone,
I recently had to replace the heater core in my car and while I had the fender off, I decided to replace the blower motor too. I'm going to ditch the old resistor speed control system and replace it with a modern PWM speed control. I am going to use a Toyota blower control module and need to build a PWM generator to interface the control module with the 4 position switch in the dash. The blower control module has 5 terminals (+12vdc input / - gnd input / + blower output / - blower output / control input). The control input has a +5v pullup on it and the vehicle's climate control system grounds this input to control the blower speed. I put my scope on this input while in operation and found it's controlled with approximately 100hz PWM. I got another blower motor controller and a little PWM generator and tested it out on my blower motor. Everything worked as expected and I found that the motor started spinning at 98% PWM (extremely slow) and reached maximum speed at approximately 17% PWM. You can see a brief video of the experiment here:

.

I ran the test with 50hz - 500hz and it operated exactly the same, so the frequency is not critical at all. I did some research and found that it appears that a 555 timer would be the easiest way to build what I need. It only takes a few ma's to sink the controller input, so the 555 is plenty. I've seen many schematics and while they all look relatively simple, the math required to select the proper resistor and capacitor values is wearing me out. I could really use some help here. What I need to build is 100hz PWM generator that is powered from 12-14 vdc and has 4 selectible duty cycles, controlled by a 4 position switch (all 4 positions have the same common). I would like to start with the duty cycles as follows: 100% (off) / 70% (low) / 50% (med) / 20% (high). I can fine tune from here. I would appreciate any help you could offer and am open to another solution that may be easier than using a 555. Sorry for the long post. I wanted to give as much detail as possible, to make this as easy as possible for you to help. Thanks!
 
Last edited:

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
My original plan was to buy a pre-built module and replace the duty cycle potentiometer with the switch and resistors. I bought these: https://www.amazon.com/gp/product/B07FBZLD3W, but they turned out to be junk. These cannot be adjusted below 50% duty cycle and the duty cycle and freq pots react with each other on a large scale.
 

Minder

Apr 24, 2015
3,478
Joined
Apr 24, 2015
Messages
3,478
I put together the one I linked to, as I was in need of a bench version with variable frequency as well as pulse width to test motor driver boards.
With this one, the width control does not affect the frequency.
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,878
Joined
Jun 21, 2012
Messages
4,878
Wow, Jeff! Welcome back to the forums. Looks like you are taking up electronics as a hobby too. I hope your precision machining business is also doing okay.

I am totally confused by your duty cycle description. A PWM (pulse width modulated) speed controller for DC motors should produce maximum speed when the duty cycle is 100% or "on" all the time and zero output when the duty cycle is 0% or "off" all the time.

Could you please explain what that little doobie in your video is, the one that has push-buttons for frequency and duty cycle, because it appears to behave exactly as you describe: lower duty cycle causes higher motor speed? Exactly how does this happen?

I am sure someone will post a link to a page with a schematic of a 555 producing variable duty cycle 100 Hz output pulses by selecting one of four resistors with a rotary switch having a common terminal. That seems to be the problem you are trying to solve. However, this resistor selection may need to be accomplished with small DPDT relays to allow an isolated "floating" resistor to be inserted in the 555 timing circuit.

If you look at the schematic of a typical free-running 555 oscillator, there are two resistors in series with the "timing" capacitor. The capacitor initially charges through both resistors until it reaches a voltage that causes the output to change state, whereupon the capacitor discharges through just one of the resistors until its voltage drops low enough to trigger a transition to the other output state. The transitions occur at 2/3 Vcc when charging and at 1/3 Vcc when discharging.

The process of charging through two resistors and then discharging through one of them continues as long as power is applied to the 555 timer. The duty cycle this produces is influenced by the values of the two resistors, as is the frequency. Here is link to a page that shows a variable duty-cycle, constant frequency, 555 oscillator. Note the two diodes that are used to steer the charge and discharge paths for the timing capacitor. Unfortunately, this circuit uses a potentiometer, not a single switchable resistor, to select the ratio of charge and discharge resistance. Of course you could double up on the number of relays to allow substitution of two resistors in place of the potentiometer. Or find small relays with 4PDT contacts instead of using two relays with SPDT contacts. The latter are very easy to find, but 4PDT relays are as scarce as hen's teeth. Anyhoo, relays solve a lot a problems and will get you up an running the fastest way possible.

Of course, the simplest solution is just to use a PIC microprocessor to generate your variable duty-cycle pulse. Set the speed by selecting taps at one of four series-connected resistors using your rotary switch. One end of the resistor string is connected to Vcc and the other end is connected to ground. Read the selected tap voltage using the built-in analog-to-digital converter on one of the analog input ports. Use that reading to select the duty cycle from one of four routines. each of which produces predetermined pulse-width-modulated (PWM) output. Easy peasy. If you build it, I will program it for you.
 

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
I put together the one I linked to, as I was in need of a bench version with variable frequency as well as pulse width to test motor driver boards.
With this one, the width control does not affect the frequency.
The controller you linked to seems to be perfect for the job, but I'm back to square one, trying to figure out the resistor and capacitor combination (would only need C1 in my case) needed to lock the 555 at 100hz and the resistor values needed to lock the LM393 at 100%, 70%, 50% and 20% duty cycle.
 
Last edited:

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
Wow, Jeff! Welcome back to the forums. Looks like you are taking up electronics as a hobby too. I hope your precision machining business is also doing okay.
I am totally confused by your duty cycle description. A PWM (pulse width modulated) speed controller for DC motors should produce maximum speed when the duty cycle is 100% or "on" all the time and zero output when the duty cycle is 0% or "off" all the time.
Hey Hop! Hope you are doing well. The machining business is going great. Trying to finish up my hobby now. The PWM I need does not drive the blower motor, it sinks the 5v input on the blower motor controller (seen sitting on the tire) to ground to turn on the motor. The more PWM "off" time drives the motor controller input low, resulting in faster blower speeds.
Oh my God! Do you really want me to get started on another PIC project? You guys almost killed me on the last one... :eek:

The pulse generator shown in the video is here: https://www.amazon.com/gp/product/B07DFXFRN3
 
Last edited:

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
At this point, I am considering using the pulse controller tested in the video and modifying the switch in the dash so it operates as a momentary 2 throw (mom/off/mom) and wiring it up in parallel with the push buttons on that little pulse controller. That would be simple to do and give me variable speed instead of just low, med and high. I have been trying to finish up this car for a year now. Right now, the quickest solutions are probably best.
 
Last edited:

Minder

Apr 24, 2015
3,478
Joined
Apr 24, 2015
Messages
3,478
The controller you linked to seems to be perfect for the job, but I'm back to square one, trying to figure out the resistor and capacitor combination (would only need C1 in my case) needed to lock the 555 at 100hz and the resistor values needed to lock the LM393 at 100%, 70%, 50% and 20% duty cycle.
As mentioned the way to supply the PWM exactly what you need, but it requires knowledge of picmicro's!
A small 8 pin can be programmed to supply the Exact frequency.
No caps or resistors.
Even a PGM to do the calc, https://www.micro-examples.com//public/microex-navig/doc/097-pwm-calculator.html
 

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143

hevans1944

Hop - AC8NS
Jun 21, 2012
4,878
Joined
Jun 21, 2012
Messages
4,878
At this point, I am considering using the pulse controller tested in the video and modifying the switch in the dash so it operates as a momentary 2 throw (mom/off/mom) and wiring it up in parallel with the push buttons on that little pulse controller. That would be simple to do and give me variable speed instead of just low, med and high. I have been trying to finish up this car for a year now. Right now, the quickest solutions are probably best.
Outstanding idea! Plus, you already know it will work, too! Is this a vintage vehicle that you are trying to restore to its former glory?

As for suggesting a PIC solution... that would be the simplest but not the easiest or quickest solution. You can always substitute a PIC solution later, if it would restore authenticity to your automobile. Don't throw away that four-position fan switch just yet!

Maybe I can find some time to prototype something for you. Sort of pay-back for all the time we wasted trying to get that flashlight to work.

I, too, have a few PICs left over from the flashlight project. I haven't set up a "proper" electronics lab since moving here to Venice, Florida, but it won't take much effort to get a PIC project up and running again. If you would like to have a continuously adjustable fan speed control, that can be easily arranged, with either a plain old potentiometer or with a cheap rotary encoder... clockwise turn to increase fan speed, counter-clockwise to decrease fan speed. At some point on the low-speed end, the output reverts to 100% "on" duty cycle, which according to your explanation will stop the motor. There also needs to be some "minimum" duty cycle, like maybe 98% or so, that will just get the fan moving after a slight clockwise movement of the "fan speed" control. And perhaps a "maximum" duty cycle, like maybe 17%, that represents maximum fan speed when the control is rotated towards maximum speed. All this through the magic of software, re-written until it works.

Of course, with the PIC solution, you lose the spiffy digital readout of pulse frequency and pulse duty cycle... but maybe just hearing the fan speed up and slow down at the twist of your fingers would be "gud enuf" for this project...:D
 

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
Outstanding idea! Plus, you already know it will work, too! Is this a vintage vehicle that you are trying to restore to its former glory? Of course, with the PIC solution, you lose the spiffy digital readout of pulse frequency and pulse duty cycle... but maybe just hearing the fan speed up and slow down at the twist of your fingers would be "gud enuf" for this project...:D

Yes, this a completely restored 1968 Firebird. It's not a concours restoration, so upgrading to some modern systems won't hurt its value. I would like to keep the original 3 speed operation though, instead of the variable speed. I did some brief research into arduino controllers and have to say it looks like it has a very fast and simple learning curve. I ordered a couple micro's instead of the promini, as it has the usb interface built in. It looks like it will be simple to wire up and simple to program. The switch common will go to vcc and the 3 speed taps will each go into a separate input. Whichever input goes high will determine the duty cycle of the PWM output. I will just have to figure out how to program it to output 100% duty cycle when no inputs are high. No resistors or caps needed and would be simple to tweek. I cannot see a easier solution. Here's the car the day it was delivered....

 
Last edited:

Bluejets

Oct 5, 2014
6,901
Joined
Oct 5, 2014
Messages
6,901
As with any micro, they mostly operate at 5v or less and the voltage in an auto can go to at least 14.8v and it's a noisy environment.

Best to use a small buck converter and set down to 5v output and feed the Arduino through the Vcc pin rather than the RAW or Vin.

Nice wheels.
Had a '65 4 door Pontiac for many years, replaced by my new "78 Celica when fuel prices went sky here in Aus.
 

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
As with any micro, they mostly operate at 5v or less and the voltage in an auto can go to at least 14.8v and it's a noisy environment.

Best to use a small buck converter and set down to 5v output and feed the Arduino through the Vcc pin rather than the RAW or Vin.

Nice wheels.
Had a '65 4 door Pontiac for many years, replaced by my new "78 Celica when fuel prices went sky here in Aus.
Thanks. Yeah, I ordered this micro USB convertor too: https://www.amazon.com/gp/product/B08DD49XKX

The Arduino micro and the converter will be here tomorrow. Hopefully I'll have it up and running by the end of the night....
 

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
Well, the Arduino micro's arrived today and I installed the IDE software. I started reading the tutorials and quickly realized that I am in way over my head. I seriously overestimated my abilities. I just don't have the time to learn this, nor the interest. I'm just going to wire up the pulse generator I tested in the video and modify the switch. At least I know it will work and I can spend my time finishing the car.
 

TenderTendon

Dec 20, 2014
143
Joined
Dec 20, 2014
Messages
143
One last thing... If anyone in the forum is capable of writing a sketch for the Micro to work exactly as I need, I will gladly pay for your time...
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,878
Joined
Jun 21, 2012
Messages
4,878
I will write it for you without charge. See private conversation I started today.

Best of luck on finishing the '68 Firebird restoration. I had a brand-new, driven off the showroom floor, 1968 Mercury Cougar that I couldn't afford to keep up. It finally rusted out, parked outside next to my former home at 168 Medford St, Dayton, OH 45410. I gave it away to some kid who wanted it for parts. It wasn't a real "muscle car" like the Ford Mustang or your Pontiac Firebird, but it got me "around town" and to work.

There is a indoor classic-car retail establishment about a mile from where I live. I plan to visit it "real soon now" but have been avoiding it because of anticipated "sticker shock."

Jeff, you might be interested in this on-line magazine.
 
Last edited:
Top