Speed controlling 12V fan with PWM breaks Photon

Hi,

I’m speed-controlling a 12 V brushless DC Fan from the Photon. With PWM.

It works at first, but then the Photon gets damaged.

The PWM output breaks on the PIN used.

The PWM signal starts to look like a sawtooth

broken%20saw%20wave

before it breaks, on a brand new Photon, it looks like it should:

healthy%20PWM%20wave

I connect the fan like this

The fan datasheet is here, page 551 describes the PWM method.

From what I read, I should be able to connect the fan PWM directly to the Photon RX pin?

This is my code

analogWrite(FAN_SPEED_PIN,fanSpeed, 25000);  //fan wants a 25khz signal

Does somebody know why this breaks the Photon?

I believe you should have used a bus buffer/level shifter IC - like SN74HCT125N (note this is a 5V output so should be suitable for your FAN). The output from the Photon is 3V3 and 5V tolerant on INPUT.

Why are you externally powering the Photon with 3V3? That should be 5V to Vin pin.

2 Likes

I wonder how the Vcc/GND signal looks with the spinning fan attached without filtering.

1 Like

thanks for pointing out that the fan wants a 5V signal, I did not realise it.

I will check out that chip.

I’m powering the photon via the 3V3 pin because I would eventually use a P1, which runs on 3V3.

The Photon can be powered via 3V3 Pin as long as Vin & USB are not connected .

@volker, you will still need 5v for the PWM fan control regardless of how you power the P1. Besides the SN74HCT125N, you could also use a MOSFET transistor. Either way, you need to shift the PWM output to 5V to drive the fan.

Agreed about being possible to power Photon with 3V3 but would be better for your test rig to use 5V IMO. In any case I think you will need a 5V supply for the level shifter and to drive the fan PWM control. On your final board you will need 3V3 and 5V!

You can’t drive (most anything) mechanical directly from a pin on Photon (Electron, Xenon…)
The small currents that the particle chips can source or sink are insufficient. For a fan (or relay, etc.) a NPN transistor with sufficient gain and collector current will do the trick. The Photon drives the friendly Base pin of the transistor and the emiiter-collector junction does the heavy lifting!

image

2 Likes

All of these schematics are missing a reverse current protection diode to prevent damage from the inductive load of the fan.

From the oscilloscope: looks like you got some capacity on the pin, it can charge quickly but is slower to discharge. Is the pin mode set to output?

Your fan has an internal transistor, so no external one should be needed like suggested above.

@holobox, the specs for the fan clearly indicate a max 1ma sink or source on the PWM pin at 5.25V. A Gen2 or 3 device can easily handle this (max 20ma). The issue is the voltage on a Particle device GPIO pin is only 3.3v and thus the need for the level shifting. Your solution, however would work just fine with a 2N3904 NPN transistor and a 470-1K ohm or so current limiting resistor between the GPIO pin and the base of the transistor.

@Elco, the fan is controlled via a PWM input which is isolated from any inductive kickback. Furthermore, the fan itself is powered from a separate 12V supply. The reason for the suggested transistors or SN74HCT125N is in regards to voltage and not current. The fan control needs 5V!

5 Likes

yessir - I missed that important detail!

1 Like

Its dirty

IMG_004

the image is from when the fan speeds up.

It gets a bit cleaner when its spinning.

But I need to filter that.

Thanks, Its working now.

First I did this:

That bumped my PWM level to 4.75 Volt (reference photo only).

Everything was well.

IMG_007

But then I increased the PWM frequency to 25KHZ (as the fan wants).

Now my BC337 Transistor was too slow:

IMG_006

I could now have tried a Mosfet, but I killed my fan.

I connected +12VDC to PWM which broke it.

I then tried another fan.

That fan needs only 2.8 Volt PWM.

So far its running well, with PWM connected straight to PHOTON RX.

Thanks a lot for the help!

The BJT is plenty fast at pulling down.
Try lowering the 10k to 4.7k or even 1k.

1 Like

I agree, the 10k is way to high.

Ok, it works fine with a 1K resistor. Thank you.