Using fan PWM signal to control motor driver
-
We're building a new printer that will use a stationary air pump through a hose to a duct at the hot end for part cooling. The fan itself is a 5v air mattress pump, so we got a high-amp motor driver dedicated to driving that. We are using an ATX power supply that has some pretty high-current 5v lines to feed it, so all it needs is a positive PWM signal. The control board is a Duet 2 Ethernet.
I found some other discussions here regarding laser PWM control with this board and found that it was exactly what we needed. I got a NOR gate chip and installed it on a perf board with some terminal blocks and we were actually able to control the fan with the fan slider on the web interface with great range of available powers. However, there are some quirks that I wanted to know if there are solutions for that may indicate we're doing something wrong.
The motor controller is an IBT-4 (amazon link). I'm actually having a lot of trouble finding schematics for it to verify I'm using it correctly. There are only 3 input pins for control: GND, IN_1, and IN_2. The two inputs are for reversing the motor best I can understand. I'm not sure if GND is shared directly with the negative side of the driver's input ground or not, so I'll test that tomorrow myself I think. Based on our test I'm using it mostly correctly I think.
For the NOR gate, I'm just using one of NOR channels in the chip. The chip is a Texas Instruments CD74HCT27E (digikey link) It has 3 NOR circuits each with 3 inputs so I tied the "ground" side of the fan pin (fan2-) to all 3 inputs of one circuit. It's getting 5v from the Duet as its VIN and ground is coming from the motor controller's ground pin next to the control pins. (As I write this I realize maybe that should be more directly grounded, but I'll test that tomorrow). The output of the NOR gate is fed to the IN_2 pin just to get the motor spinning the way we want.
When we first tried this configuration, the PWM signal seemed reversed. At 0% and 100% on the fan slider, the fan was off. 1% was pretty much full-boar and 99% was very slow. To fix this, I inverted the pin by switching the definition to "!fan2" or something like that in the config line for the fan. Not sure if this is relevant at all, but we're using fan pin 2 as fan0 because I'm pretty sure I fried the actual fan0 pin a few years ago. We ran with that for a while without issue so I don't think it matters.
Inverting the fan pin's PWM signal seemed to do the trick and get it working as expected, except setting the slider to 100% still turned the fan OFF. We don't plan on going anywhere near even 50% for actual printing, so it's a pretty minor issue but the whole thing leaves me with some questions. Also jostling our janky jumper cable daisy chain made the fan go full throttle again for some reason, so I may add that safety circuit to 3.3v I see on the laser circuit diagram if that would prevent that.
My main inquiries are:
- Is the fact that setting the slider to 100% turns the motor OFF indicating a potential floating input for the NOR gate? Since the PWM signal is inverted, 100% should translate to the fan- pin on the Duet being essentially ground, right? Can I fix this with a pulldown resistor somewhere? I'm suspecting the motor controller might not "like" the input it's getting from my circuit at 100% for some reason.
- Is there a way to cap the PWM range of the fan in firmware? For example to make it so a commanded 100% is actually a 50% duty cycle PWM coming out?
- Are these issues unique to using the fan2 pin somehow? I see that the laser control discussions revolve around using heater3 instead, but my understanding is that the control scheme for each is essentially the same. I know RRF3 allows for re-mapping fans to heater outputs, but part of me really likes keeping it on the fan pin.
Thanks in advance for looking at this! I am more than happy to supply more information if needed.
-
@jandcando said in Using fan PWM signal to control motor driver:
Can I fix this with a pulldown resistor somewhere?
I would think that the duet's fan output is an open collector (drain) output with no pull-up, so you may want to pull it up to the + supply of your NOT gate. An oscilloscope, even a cheap one, would give you more insight what is going on.
-
@zapta Yeahh this is one of those times I wish I had an oscilloscope. I have access to one at school so I may bring it in. Also, your comment about pulling the signal up makes a TON of sense now that I think about it. I think I'll try that next.
-
@zapta Just got back from trying that: it works! I used a ~260kOhm resistor between the Duet's fan0- pin and the 5v supply to the NOR gate to get the voltages to drop low enough for the logic of the chip while the pwm was being sent from the Duet. Another side effect is that I no longer need to invert the fan pin in my config.g - it works completely as intended.
Thank you very much for your help
-
@jandcando, I haven't tried it myself, but I believe that for 3D printer purposes, even this $20 oscilloscope would more adequate.