Notifications
Clear all

Using a esp32 & a FZ44n MOSFET to control a 4 pin 12V fan

11 Posts
5 Users
1 Reactions
103 Views
Christine86
(@christine86)
Member
Joined: 4 years ago
Posts: 51
Topic starter  
Both purifiers
140mm purifier

I've designed & 3D printed 2 air purifiers, 1 a 140mm Noctua 4 pin 12V, & the other a 200mm Noctua 4 pin.

Schematic

This is the schematic I have designed so far. I've written (in C++), a program that can read the 3 sensors, & control a 1.8" TFT display.

Breadboard with 1.8%22 SPI display

This is my breadboard I've set up to test all this. This is the display I want, showing "Off", "Low", "Medium", "Med/Hi" & "High". I also have a FZ44ns MOSFET, if this is necessary?

What I want to do, is to 'set' the fan speed using a PWM signal from pin 2 on the esp32, then read the 'TACHO' on pin 4, & adjust the fan speed(PWM signal) to suit.

I've seen ppl adjusting the speed using the 'fan ground', but I'd really like to properly use the 4 pins of the fan to get this to work. I think I'll need to adjust the frequency of the PWM signal, but that's where I'm now stuck!! DO I need to adjust the PWM frequency, & how do I go on from there.

Rear of Rotary Encoder

Can anyone please tell me how to achieve this? I also have the rotary encoder (shown in the above image), which I want to use to select the various fan speeds, but the page I used to buy this, shows it using TWO grounds, but no VCC? Do I have to scrap this for another, or does someone know which pin is supposed to be VCC??

Hope someone can help me,
Christine


   
Quote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2230
 

@christine86

I also have the rotary encoder (shown in the above image), which I want to use to select the various fan speeds, but the page I used to buy this, shows it using TWO grounds, but no VCC? Do I have to scrap this for another, or does someone know which pin is supposed to be VCC??

Can you give a link to the page used to buy it?

https://howtomechatronics.com/tutorials/arduino/rotary-encoder-works-use-arduino/

 


   
ReplyQuote
Christine86
(@christine86)
Member
Joined: 4 years ago
Posts: 51

   
ReplyQuote
Christine86
(@christine86)
Member
Joined: 4 years ago
Posts: 51
Topic starter  

@robotbuilder Sorry, that didn't seem to work. I hope this is better?

https://www.amazon.com/Degree-Encoder-Modules-Digital-Potentiometer/dp/B092Z2GVX2/ref


   
ReplyQuote
Christine86
(@christine86)
Member
Joined: 4 years ago
Posts: 51
Topic starter  

@robotbuilder This is from Amazon. I have no idea why it's not working. You should be able to search for it using the first bit of the description?


   
ReplyQuote
Christine86
(@christine86)
Member
Joined: 4 years ago
Posts: 51
Topic starter  
Amazon pade for rotary encoder.

This is from Amazon. I have no idea why it's not working. You should be able to search for it using the first bit of the description


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7714
 

@christine86 The forum has a well known bug re Amazon links. Either us a URL shortener or enclose in quotes.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Christine86 reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2585
 

Posted by: @christine86

[snipped]

What I want to do, is to 'set' the fan speed using a PWM signal from pin 2 on the esp32, then read the 'TACHO' on pin 4, & adjust the fan speed(PWM signal) to suit.

I've seen ppl adjusting the speed using the 'fan ground', but I'd really like to properly use the 4 pins of the fan to get this to work. I think I'll need to adjust the frequency of the PWM signal, but that's where I'm now stuck!! DO I need to adjust the PWM frequency, & how do I go on from there.

-- attachment is not available --

Can anyone please tell me how to achieve this? I also have the rotary encoder (shown in the above image), which I want to use to select the various fan speeds, but the page I used to buy this, shows it using TWO grounds, but no VCC? Do I have to scrap this for another, or does someone know which pin is supposed to be VCC??

I'm not sure I completely understand what you're trying to do, but maybe this will post you in the right direction as far as PWM control of your fan.

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1871
 

Hi Christine  @christine86,

  With respect to your rotary encoder question, I think you are asking about the difference between the 'naked' rotary encoder, which is shown in your photo, and the same type of encoder, soldered to a small PCB, and often referenced with names like HW-040 or KY-040, making it easy to connect to an Arduino with push-on leads.

The short answer is the PCB version typically includes two extra resistors, with provision to solder on a third one. The two resistors are required for the rotary position sensing, and the 'optional' third resistor to sense whether the spindle is pushed down or not.

I could go into more detail, but there are some articles on the web which at least attempt to explain the situation, and hopefully will be sufficient for your needs. e.g. https://www.handsontec.com/dataspecs/module/Rotary%20Encoder.pdf

If you already have the 'naked' encoder, then you just need to add 2 or 3 resistors, as part of the interconnect between the encoder and the microcontroller.

----------

Please note, the connection term 'GND' on your photo, merely refers to 1 of the two terminals of a single pole switch. I think you will find the two 'GNDs' are isolated from each other (check your switches with a meter), with one 'GND' associated with the 'Switch' terminal; and the other with the Out A and Out B terminals, each of which is a single pole switch terminal. Hopefully, if you look at the pdf file I just referenced, you will be able to visualise the situation.

The same reference shows a schematic with the two resistors you need to convert the 'naked' switches to the same functionality as the PCB module. If you also want to use the 'push switch' functionality, add a third resistor between the + and SW terminals of the schematic shown in the reference.

The value of these resistors is not critical ... maybe look for something between about 4.7 kOhms and 22kOhms in your spare's box.

Some people will suggest you can omit the resistors, and merely set the GPIO pin to 'Input with pullup' in software. They will probably work on a test, but I would not recommend it, as the processor's internal resistors tend to be quite high in value (e.g. circa 70kOhm), which makes them susceptible to noise, etc.

Also note that the reference to 5V applies when connecting to boards with 5V processors, like the 'original' Arduinos (UNO, NANO, MEGA, etc.). Many other popular choices, including the newer Arduino designs, ESP32 and ESP8266 have 3.3V processors. For the latter, simply connect the "+5" input on the encoder schematic to a 3.3V supply instead of 5V. All the common development boards using 3.3V processors have a 3.3V output pin, which can be used for this purpose. (eg Pin 1 on your schematic.)

----------

I recommend you initially wire up the encoder, and use a small test programme that simply prints numbers to the serial monitor, according to the operation of the encoder ... e.g. a 'counter' that starts at zero, increments on clockwise operation, decrements on anticlockwise. When you have that working, it should be easy to integrate the functionality into your main programme.

-----------

I hope this helps. If you would like some further explanation, then please say so.

Best wishes, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7714
 

@christine86 These are what I purchased to use in a scale adjust application. Very simple to use with a push button as well. Output is simply + or - signal per pulse.

https://amz.run/9p7X

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Christine86
(@christine86)
Member
Joined: 4 years ago
Posts: 51
Topic starter  

@davee Thank you so much Dave, your response is really helpful. I've ordered a batch of 5 "Cylewet 5Pcs KY040 Rotary Encoder Module" and I'll try your suggestions when they come in. Again, thnx for your help


   
ReplyQuote