1

Topic: Proper gcode fan driver (schematic)

Hi all,

There are some problems with the common MOSFET approach for driving fan directly from PWM:
1) 1KHz AC voltage on DC motor
- Causes audible noise
- Imprecise speed control
- Possibly damaging to motor
2) Not protected from inductive back-EMF
- Could damage MOSFET (or Solidoodle)
3) No under-drive protection
- Possibly damaging to motor  (unless min. fan speed is configured in software)


I want to share a driver for extruder fan.
It converts the PWM duty cycle % into a proper voltage supply so the motor is driven from real DC.
The fan runs completely silent and the design also protects against inductive spikes and prevents under-driving the motor.

All the components could be found at a local electronics store such as Radioshack.
I suggest you try building one up!  Let me know if you like any youtube video tutorial or walk-through of the circuit


http://bahproductions.com/fan_driver2.png


http://bahproductions.com/fan_driver3.jpg

2

Re: Proper gcode fan driver (schematic)

I was just saying I needed a G-Code Fan. Which pin-outs did you use from the sang board?

3 (edited by bahstrike 2013-02-14 04:53:49)

Re: Proper gcode fan driver (schematic)

I remember not long ago, there was a lot of discussion about extruder fan and how many could not get proper speed control.

This is especially problematic if you add capacitance to the output, to try and smooth the PWM signal-  if you don't precalculate the farads "exactly"  (taking into account even fairly miniscule transients)  then too much will cause the fan to run full strength no matter what level you wanted it.  Plus it doesn't scale-  so AC->DC smoothing is only effective at a specific driving %.  Hence the more complicated design that does what you hoped for

Donno, I'm just surprised this thread hasn't gotten hardly any attention-  because this solution DOES WORK and it's stable-  and I'm (unshamefully) a little proud that this is my first opamp design. It took 3 redesigns and a couple prototypes to make work as proposed.  Wouldn't have gone through the trouble except I didn't find a circuit online that solved the issue ahead of time.

I'm remaking mine to include an LED bargraph to display speed %. if anyone wants the one pictured above for free send me a message.
also i priced out professionally fabricated boards + all component costs and i could ship preassembled units for $10 (minus shipping)  but i dont see any interest to make that reality

4

Re: Proper gcode fan driver (schematic)

The thread is interesting and in general I'm a big fan of electronics projects and your design is very neat. For example I would choose your solution over carbonfrog's MOSFET driver kit.

However, I have the feeling that not too many people require that level of control, and your circuit design seems a bit daunting. For example I'm quite satisfied with just a single MOSFET, even if I cannot fine-tune the fan speed.

Plus if you throw in a dollar more and use a self-protected MOSFET you don't have any EMF problem on the transistor or the electronics.

Do you have an example that clearly shows the benefit of your approach? Maybe in terms of final print quality?

5

Re: Proper gcode fan driver (schematic)

I think what would get a lot of interest here is if you offered not just the boards, but a plug and play add-on for those who are intimidated by the thought of soldering anything (though they would still need to solder headers).  I think a lot of people would like to order something that is ready to plug into the board at one end, and plug into a fan at the other.  Maybe include the headers and a 40mm fan for a complete kit.

6

Re: Proper gcode fan driver (schematic)

IanJohnson wrote:

I think what would get a lot of interest here is if you offered not just the boards, but a plug and play add-on for those who are intimidated by the thought of soldering anything (though they would still need to solder headers).  I think a lot of people would like to order something that is ready to plug into the board at one end, and plug into a fan at the other.  Maybe include the headers and a 40mm fan for a complete kit.

+1

7

Re: Proper gcode fan driver (schematic)

BTW that pool of potential buyers isn't just Solidoodle users, but everyone who has a Sanguinololu on their printer.

8

Re: Proper gcode fan driver (schematic)

This guy runs a PCB company:

http://www.soliforum.com/user/695/

He might be able to help. I don't think he comes by SF much, so it might be better to email him.

9

Re: Proper gcode fan driver (schematic)

So....do capacitors on the output of a buck step-down charge to full voltage if you aren't pulling them down with the load? If that's what you're saying, then could you solve the problem by using an inductor instead of a capacitor (to smooth the pwm so the fans get a smoother input voltage?)

10

Re: Proper gcode fan driver (schematic)

cmetzel wrote:
IanJohnson wrote:

I think what would get a lot of interest here is if you offered not just the boards, but a plug and play add-on for those who are intimidated by the thought of soldering anything (though they would still need to solder headers).  I think a lot of people would like to order something that is ready to plug into the board at one end, and plug into a fan at the other.  Maybe include the headers and a 40mm fan for a complete kit.

+1

+1

11

Re: Proper gcode fan driver (schematic)

jgarder wrote:
cmetzel wrote:
IanJohnson wrote:

I think what would get a lot of interest here is if you offered not just the boards, but a plug and play add-on for those who are intimidated by the thought of soldering anything (though they would still need to solder headers).  I think a lot of people would like to order something that is ready to plug into the board at one end, and plug into a fan at the other.  Maybe include the headers and a 40mm fan for a complete kit.

+1

+1

The $10 cost is a populated & soldered circuit board, complete with screw terminals for wiring up.
It would be $7 for a kit w/ identical parts, just to solder yourself.

You're right about the soldering headers  (and programming firmware).


Rincewind wrote:

Do you have an example that clearly shows the benefit of your approach? Maybe in terms of final print quality?

I don't  .. and you raise a valid point.  Only speed control could benefit print quality. The rest is for protecting hardware and satisfying EE OCD.  I didn't finish "air blade" nozzle design yet but perhaps this weekend we can find whether there is a measurable difference


Tomek wrote:

So....do capacitors on the output of a buck step-down charge to full voltage if you aren't pulling them down with the load? If that's what you're saying, then could you solve the problem by using an inductor instead of a capacitor (to smooth the pwm so the fans get a smoother input voltage?)

Pretty much you need some kind of feedback loop if you want to ensure a proper driving voltage regardless of load. Even assuming the fan can be modeled as a simple resistor, simple formulas will break down at min/max drive range using passive components.. and motors have all the joy of inductive reactance which further obsolesces the already-defunct simple formulas.  Unless you are really good at math (I'm not)  or have a lot of EE experience  (I don't)  then using a feedback loop changes the design from needing tarot cards to asking the simple question  "need more power now?".   If you can get a smooth buck with MOSFET and reasonable LC then let me know.. I tried.. the only SPICE simulation I got working to expectation apparently requires an inductor with 30lb of copper winding tongue  smile

12

Re: Proper gcode fan driver (schematic)

Few questions:

What pins does this use?
Is it compatible with the panelolu mod? (Can I have both at once)

Assuming I can make use of it...
How much are you selling it for?
Where are you selling it from?

13

Re: Proper gcode fan driver (schematic)

As the Fan uses pin4 and so does the Panelulo you currently can't use them together, which I only found out after I had purchased the Panelulo kit whilst I was making a very cheap and nasty PWM converter for the fan (fan has control but it sounds terrible at low speeds)

Since then though I have been looking to make use of the I2C comms. If I can get this right it would make the use of a whole host of things easier to implement. Initially just to get the fan and panelulo working off of the I2C bus but then get other controls added, but that might take a bit of tweaking as there isn't a lot of gcode commands that I can borrow. So I can see myself build some extra codes and running scripts on the gcode to make it work. That is in the future though.

A simple one I want to add is the on/off control of the extruder fan. Just making it shut up before and after a print would make life a bit more pleasant. I have just thought of tying extruder and nozzle fan together so they come on after the first layer, but haven't got round to try it yet.

14

Re: Proper gcode fan driver (schematic)

Zarni I agree-  I think as the community expands, more people are going to be looking to add peripherals that they would like to control via common interface  (gcode, naturally).

I²C would be a prime candidate to allow commands&data to cross from PC through printer to any number* of slave devices.  If so-inclined, SD could capitalize on this idea by just soldering in a jack to the I²C pins and modifying firmware to support a custom gcode command to send data to node ID, and another gcode command to receive data from a node ID.  This would allow designers to share or sell  all sorts of custom sensors and/or drivers  that anyone can just plug-in  (as if it were a USB device). Fantastic!

* standard I²C is limited to 128 device addresses.  you probably wouldn't connect 128 peripherals to your printer, but designers would have to be cautious not to reuse the same address someone else did-  otherwise you couldn't attach both even if they were the only 2 peripherals you wanted to use




To clear up some questions for those wanting to order a board  (thanks for the messages):

1) If you want one now, you can make it yourself-  that was the goal of the original post!

2) The  $10 preassembled  (or $7 kit)  does not include shipping

3) There is no store set up to order one right now.  I need to see something like 20 people interested before I'm willing to swing the $350 to get supplies to make 50 units  (and if you do the math out, you will find I make no profit selling $7 kits).  I could aim for fewer units but the price will go up considerably because I can't take advantage of bulk pricing (crucial for electronic components-  it's often cheaper to order 2000 resistors than it is to order just 500 of the SAME resistor)

4) There will be approx.  3-week lead-time for me to receive bare circuitboards from my usual PCB fab in Malaysia  (or I could go quick-turn U.S. and be shipping next week for triple the price)

5) Anyone wanting preassembled:  remember you still have to solder pins or wires to the SD motherboard AND update the firmware to enable the fan pin

6) If this does all happen, there will be an extra $4 optional upgrade to get a LED bargraph for speed level indicator http://bahproductions.com/bar.png

15 (edited by newq 2013-02-16 03:35:27)

Re: Proper gcode fan driver (schematic)

I'm looking into adding a fan to my setup at the moment, so this sounds very interesting. Thanks for your work on this!

I'd like to buy a preassembled fan driver when you have them ready.

I think that updating the firmware is easy and soldering just the headers is doable as well. It would be cool though if the fan driver came complete with cables and everything else needed / precrimped / whatever to install it. I already have headers but I have trouble finding connectors for example. But I see that this adds to your workload and it seems you just want to help the community and not enter the electronics kit market. (Or do you?) smile

16

Re: Proper gcode fan driver (schematic)

Any chance you would be willing to combine an inverter with your driver?  I have been experimenting with an air pump for an aquarium and have got great results due to the highly directed nature of the airline tube, however the only reasonably priced air pumps with enough cfm are the AC ones. I'd love to have that gcode controlled if there is a way... I've come up with quite a few examples online, but it seems like it would take a pretty bulky board to combine an inverter and driver.

17 (edited by jefferysanders 2013-02-16 20:51:35)

Re: Proper gcode fan driver (schematic)

I have all the parts except in house expect 1 mosfet, and a protoboard. 80).  I think this will be a fine learning experience.  Any suggestions?  Are there 2 input wires or 3?  I think I have the schematic mostly worked onto a breadboard, but I can't really tell with the shadows from the pic. (could you upload a closeup for those wanting to learn and attempt this on their own).  Thanks for doing all of this!

18

Re: Proper gcode fan driver (schematic)

bahstrike wrote:

I'm just surprised this thread hasn't gotten hardly any attention

I check SoliForum every day, and I KNOW that this thread was not visible as "new post" yesterday.  This has happened quite a bit recently.  Puzzling

19

Re: Proper gcode fan driver (schematic)

Pretty sure I saw the above posts yesterday...strange

20

Re: Proper gcode fan driver (schematic)

jooshs wrote:

Any chance you would be willing to combine an inverter with your driver?  I have been experimenting with an air pump for an aquarium and have got great results due to the highly directed nature of the airline tube, however the only reasonably priced air pumps with enough cfm are the AC ones. I'd love to have that gcode controlled if there is a way... I've come up with quite a few examples online, but it seems like it would take a pretty bulky board to combine an inverter and driver.

No inverter-  wattage too high for the SD.  And with external supply-  why bother stepping down only to step-up..
I DO want to experiment with aquarium pump & airline tubing, since it should be easier to use tubing rather than mount a fan directly. I already experimented with using a fan + tubing but alas there is zilch-balls for air pressure.  Instead, I would employ a TRIAC to chop up the 60hz mains voltage to dampen the aquarium pump (google for zero-cross dimmer circuit)-  but this is still speculative whether or not it will work according to the pump's design  (tho it should, if timed properly upon the zero-cross).  As well, the cost for such a kit would be higher-  not only do you need to buy an aquarium pump but the AC chopping framework will require some optoisolation, an MCU, and extra connectors/protection for dealing with mains AC.  Long story short-  maybe in the future big_smile



jefferysanders wrote:

Are there 2 input wires or 3?  I think I have the schematic mostly worked onto a breadboard, but I can't really tell with the shadows from the pic.

Technically there is only 1 signal wire (PWM)-  but to make the story complete you need a common reference (GND).  Further, since the circuit doesn't supply it's own power so you need +12V, as well.  So there are 3 inputs  (+12v, Gnd, PWM),  and 2 outputs  (Fan+, Fan-).

I have not tested the circuit using MOSFETs.  It would probably work fine, but there is some legitimate reason for choosing oldschool trannys. The design for under-volt protection assumes the ~0.7v saturation voltage present with an an NPN transistor.  Second, you'll get better output regulation if you use the suggested PNP transistor for the buck supply-  it might be discomforting because the PNP transistor can get rather warm during operation at 40-60% fan speeds, but this is simply because the transistor is being largely driven in "active amplification mode"  rather than the pure on/off you might get with a MOSFET-  the output is smoother. It's not warm enough to require a heatsink.  In any case, a typical 12v 40mm fan can draw upwards of 2 watts so do NOT use typical 3906 and 3904 NPN/PNP transistors  (the tiny half-circle shaped ones)-  get power transistors in the TO-220 package, like seen in the picture.  Regardless, though, it should still work fine with MOSFETs  (just make sure you use an N-channel type in place of the NPN,  and a P-channel type in place of the PNP)

4-pin input jack only has 3 pins used
http://bahproductions.com/board.jpg

21 (edited by bahstrike 2013-02-17 01:29:08)

Re: Proper gcode fan driver (schematic)

Also I did not make mention previously, so sorry to crush expectations, but this circuit DOES NOT WORK at fan speeds below ~45%.    At about 5.5v,  your typical 12v fan ceases to spin  (but the coils can still short-out).  Hence the 'under-voltage' protection so it prevents sending power at low speeds.  To accomplish lower than 45% speed, a complex timing circuit  (or easier, an MCU)  would be needed to pulse the fan at full power at a low duty-cycle, low Hertz  PWM..      in other words, the fan would get full juice to make a couple spins, then wait..  get a pulse to make a couple spins, then wait.. etc.   Might be the next step in the design.  A true 0% - 100% would be nice wouldn't it

22

Re: Proper gcode fan driver (schematic)

Slic3r's cool settings let you specifiy a minimum % for the fan, so you can keep it over 45% in the gcode.  It doesn't protect from turning the slider in Repetier too low however.

23

Re: Proper gcode fan driver (schematic)

So, part of me thinks what makes the most sense is to find a supplier of a 40mm fan that has a third PWM speed signal that controls the % speed that the fan runs, so the speed control is done on the fan's tiny BLDC controller.

24

Re: Proper gcode fan driver (schematic)

bahstrike wrote:

Zarni I agree-  I think as the community expands, more people are going to be looking to add peripherals that they would like to control via common interface  (gcode, naturally).

I²C would be a prime candidate to allow commands&data to cross from PC through printer to any number* of slave devices.  If so-inclined, SD could capitalize on this idea by just soldering in a jack to the I²C pins and modifying firmware to support a custom gcode command to send data to node ID, and another gcode command to receive data from a node ID.  This would allow designers to share or sell  all sorts of custom sensors and/or drivers  that anyone can just plug-in  (as if it were a USB device). Fantastic!

* standard I²C is limited to 128 device addresses.  you probably wouldn't connect 128 peripherals to your printer, but designers would have to be cautious not to reuse the same address someone else did-  otherwise you couldn't attach both even if they were the only 2 peripherals you wanted to use

there's a good side and a bad side to the idea that you treat printer parts as peripherals and give them addresses...

to start with, so long as you agree an addressing scheme, then you don't really have an issue with things having the same address. (split the 128 addresses up into device classes, (e.g. actuators, limit devices, cooling devices, temperature sensing devices etc))

eventually your imagination takes you to a place where everything is just plugging into a machine.
so when your machine turns on it does a basic systems test and goes to a discovery mode, and you have parts that reply with information.
for example on a standard solidoodle, you'd get replies from xyz and e motors. xyz end stops, perhaps they'd be more clever and have a learned idea of how big the axis etc were...
so when a printer turns on it knows it has 3 axis, 150mm long and a single colour print head.
(like how when my PC turns on it knows it's got a 3 button scroll mouse connected, or if I put a different mouse on (say 5 button) then new functions are opened up)
When you stick an SD card in your panelolu that's 180mm square in two colours, the printer can just tell you that it can't print that.

basically, if you start hanging things off a proper bus and putting addressable devices in like they were peripherals then the possibilities are pretty endless.

In addition, if you were going to use a 1 wire bi-directional bus.
it's make sense that whilst you were throwing away all the conventional printer wisdom that you also threw away the conventional controller boards and made one with a CAN bus.

The reason for this is that this bus rather than being master/slave oriented is multi-master with a way of giving preference to devices based on address that aids conflict resolution.


so (for example) in your car,
You may use stalk controls to increase the stereo volume.
if your car wants to tell you that the brakes are faulty then the brakes win because they are addressed lower.

To put that in a printer setting, control messages from the panelolu, saying that you want to increase/decrease speed would outrank (and be given preference to) messages regarding cooling.



But the trouble is, when you start sticking Uc's into everything you suddenly increase the cost.



As for this being the future of 3d printing.
Personally, I think that the ease brought by embedding chips in everything, and adding loads of user easy. (so just add or takeaway a fan etc) far outweighs the few pence spend on doing it.

However as free as the Rep-Rap movement (that most commercial makers are taking their direction from) goes, Adrian Bowman said that he did not like the idea of adding chips to everything. and given that RepRap (as a brand) is controlled by him, it seems unlikely that any standard could ever be endorsed...

25

Re: Proper gcode fan driver (schematic)

Has anyone tried using a 4pin PWM based fan?  (No link privileges yet or I would link, google 40mm PWM fan)  What might be the advantages/ disadvantages of using a PWM based fan other than low speed control?  Could it be used with the simple transistor control circuit but effectively have the same result as this more complex solution?

K