Hey guys,
If you want to learn more, please visit our website.
Currently I´m working on a circuit board for controlling a fan depending on temperature (in my case for a car or bike etc.).
The design and code derives from a project I have done in the past, which is working flawlessly until now.
For the new design I just added a pin header to switch between different modes and changed to a different MOSFET, because the availability of the old one became terrible.
I´m using an Atmega328P with internal clock at 8MHz, programmed by an Arduino Uno as ISP, which I use for debugging (reading data from the Atmega and sending it to my PC via Serial).
So in theory everything should work fine if you started from a known, working design... but it doesn´t.
I encountered two problems:
The first problem is that the pulldown resistor (R3) is not working. By that I mean no matter how big the value is, the Atmega is not able to pull the pin of the bridge driver high to enable it.
I tried values from 4.7k to 47k, but no difference. So I started to look after errors in my code regarding the logic and inversed it. Still no difference. I´m really scratching my head now, because this part of the pcb/code was working in the old design.
The second problem that the MOSFETs and the capacitor (C9) are getting really really hot after a short time. I run an old, small fan of a 3D-printer hot end for testing. My old design is capable of around 20A and is running very cool under these conditions.
Sadly, I can´t find the code of the old Arduino project....
Here is my code (still under construction ) and I attached pictures of my schematic/PCB)
//Defining Pins
#define TPin PC0
#define TLowPin PC1
#define THighPin PC2
#define PWMMinPin PC3
#define PWMOutPin PD5
#define Mode1Pin PD6
#define Mode2Pin PD7
#define EnablePin PB0
//Constants
const int ntc_nom = ;
const int PWMMax = 255;
//Variables for temp measurement
float TRaw = 0;
float TU = 0;
float TR = 0;
float T = 0;
//Variables for parameters
int TLow = 0;
int THigh = 0;
int PWMMin = 0;
int PWMOut = 0;
int Mode1 = false;
int Mode2 = false;
int FanState = 0;
//This makes printing values much easier (for debugging)
void printValue(String text, float value, String text2 = "");
void setup() {
//Pin setup
pinMode(TPin, INPUT);
pinMode(TLowPin, INPUT);
pinMode(THighPin, INPUT);
pinMode(PWMMinPin, INPUT);
pinMode(PWMOutPin, OUTPUT);
pinMode(Mode1Pin, INPUT_PULLUP);
pinMode(Mode2Pin, INPUT_PULLUP);
pinMode(EnablePin, OUTPUT);
Serial.begin();
//Reading the potentiometers to get the parameters and mapping them to fixed values
TLow = analogRead(TLowPin);
TLow = map(TLow, 0, , 0, 120);
THigh = analogRead(THighPin);
THigh = map(THigh, 0, , 0, 120);
PWMMin = analogRead(PWMMinPin);
PWMMin = map(PWMMin, 0, , 0, 255);
//Turning off the mosfet driver at startup
digitalWrite(EnablePin, LOW);
}
void loop() {
//Reading the mode pins to choose the mode
Mode1 = digitalRead(Mode1Pin);
Mode2 = digitalRead(Mode2Pin);
//Mode 1
if(Mode1 == 0 && Mode2 == 1) {
//Getting the temperature
TRaw = analogRead(TPin);
TU = TRaw * 5 / ;
TR = ntc_nom * (5 / TU - 1);
T = -28.42 * log(TR) + 234.33;
//Turning fan on when TLow is reached and setting PWM signal according to the parameters
if(T >= TLow){
PWMOut = map(T, TLow, THigh, PWMMin, 255);
PWMOut = constrain(PWMOut, PWMMin, 255);
analogWrite(PWMOutPin, PWMOut);
digitalWrite(EnablePin, HIGH);
FanState = 1;
}
//If temperature drops below TLow the fan is switched off
else{
analogWrite(PWMOutPin, 0);
digitalWrite(EnablePin, LOW);
FanState = 0;
}
//Debugging
Serial.println("MODE 1");
printValue("T: ", T);
printValue("TLow: ", TLow);
printValue("THigh: ", THigh);
printValue("PWMMin: ", PWMMin);
printValue("Mode1: ", Mode1);
printValue("Mode2: ", Mode2);
printValue("PWMOut: ", PWMOut);
printValue("FanState: ", FanState);
Serial.println();
delay();
}
//Mode 2
if(Mode1 == 1 && Mode2 == 0){
analogWrite(PWMOutPin, 200);
digitalWrite(EnablePin, HIGH);
FanState = 1;
//Debugging
Serial.println("MODE 2");
printValue("T: ", T);
printValue("TLow: ", TLow);
printValue("THigh: ", THigh);
printValue("PWMMin: ", PWMMin);
printValue("Mode1: ", Mode1);
printValue("Mode2: ", Mode2);
printValue("PWMOut: ", PWMOut);
printValue("FanState", FanState);
Serial.println();
delay();
}
//Mode 3
if(Mode1 == 1 && Mode2 == 1){
//coming soon
}
}
void printValue(String text, float value, String text2 = "") {
Serial.print(text);
Serial.print(value);
Serial.println(text2);
}
Which ones? Q2 and Q4 by any chance, more so than Q1 and Q3?
I'm wondering about this, which is the typical application of the bridge driver you're using:
Vs. your implementation, which seems to deviate from this.
Also, out of curiosity - given the ratings of the MOSFETs you're using here (HSCE), why are you using two each for the high and low side? They appear pretty capable; what kind of gigantic fan are you trying to drive given that you need four of them?
Edit: thinking about this some more, I'd really recommend going back to the datasheet of the IR bridge driver and analyzing your own implementation against the typical connection and the functional block diagram in the datasheet.
For instance, when LO goes high, you're discharging C7 directly into GND. That's about all that Q2 and Q4 seem to be doing there; they don't affect the load (fan) because it seems you've got the fan- tied to GND anyway. At a low PWM frequency, this doesn't hurt much, but if you go up into the kHz range, you'll start dissipating significant power there.
I'm also puzzled why you're running the driver at 5V.
I feel like I should tell you a little more about my application and what led me to my approach.
The circuit is meant to control the speed of a radiator fan in a car depending on engine temperature.
In big engines a radiator fan can reach up to 30A.
The fan can be spun backwards if you drive fast enough (with the car, not the fan).
In one of my first tries I used a single mosfet with a flyback diode, but the induced currents while the mosfet was switched off but still running (so at like 50% duty cycle) where too high for a diode. Both leads of the fan were connected to my circuit.
After talking to a buddy who does more tinkering with electronics than me, he suggested a half bridge instead of a flyback diode.
That's why I am where I am with my design. Derivations of the typical application suggestion of the driver not intended.
choig Product Page
Heat is the enemy. And lately, almost anywhere you live, you’ve probably noticed its real and everpresent effects. Regardless of whether we’re talking intake air, coolant, tires, or gearbox and drive train temperatures, we need to control heat. One of the best ways to handle that in terms of engine temperatures is taking advantage of electric cooling fans. Assuming you have already addressed radiator or heat exchanger capacity, and have adequate coolant flow. Using our MegaSquirt ECU or MSPNP to control our fans is going to be crucial in completing your ride’s cooling system performance.
Few adversaries pose a more significant threat to your vehicle’s longevity and performance than overheating. While the exterior of a car may shimmer with glossy perfection and the engine may roar with unbridled power, lurking beneath the surface is a potential enemy that can silently wreak havoc on your prized possession. In this article, we delve into the insidious nature of overheating and why it stands as the arch-nemesis of your engine’s well-being.
Engines are intricate marvels that operate within a delicate balance of heat and power. While controlled combustion generates the force that propels your car forward, it also produces immense heat as a byproduct. This heat must be managed efficiently to prevent irreversible damage. Overheating occurs when the engine’s cooling system is unable to dissipate this excess heat, pushing the temperature gauge into the red danger zone.
At the heart of your engine lies an assembly of metal components, from pistons and cylinders to valves and bearings. These metal parts are designed to operate within specific temperature ranges. When overheating strikes, the delicate equilibrium is disrupted, causing metal components to expand beyond their designed limits. This expansion can lead to warping, distortion, and even irreversible damage, rendering your engine’s performance compromised.
Preventing overheating is not just a matter of convenience; it’s a crucial step in safeguarding your engine’s longevity and performance. Regular maintenance, including checking coolant levels, inspecting hoses, and ensuring proper radiator function, can go a long way in preventing overheating. Timely replacements of worn-out components and routine flushes of the cooling system can help maintain the delicate balance required for optimal engine operation.
Driving conditions play a significant role in your engine’s susceptibility to overheating. Idling in traffic, towing heavy loads, or pushing your car to its limits on a scorching track day can all elevate engine temperatures. Be mindful of these scenarios and take proactive steps to prevent overheating, such as turning off the air conditioning or pulling over to let your engine cool down.
All of that is all well and good you might think, but what does this have to do with my ECU? Well, not only can we gain all of the benefits of using electric fans in terms of reliability and performance, but we can take total control of those fans easily with our standalone engine management systems.
Gone are the days of mechanical fans driven by engine belts, where power was diverted from the engine’s performance. Electric cooling fans provide a more efficient solution by drawing power directly from the vehicle’s electrical system. This means that horsepower is no longer sacrificed to keep the engine cool, allowing you to harness the full potential of your engine’s output for speed and acceleration.
Maintaining precise temperature control is paramount. Electric cooling fans offer a level of accuracy that traditional fans simply can’t match. Equipped with sensors and advanced control systems, electric fans engage and disengage based on real-time temperature data. This not only prevents overheating but also ensures that the engine operates within its optimal temperature range, maximizing performance and prolonging component life.
Traditional mechanical fans also often dictated the layout of the engine bay, limiting the options for other components and modifications. Electric cooling fans, on the other hand, offer greater flexibility in terms of placement. This newfound freedom allows for more creative and efficient engine bay designs, enabling you to optimize airflow and overall performance.
Every project is unique, and electric cooling fans cater to this individuality by offering customization options. From fan size and blade design to control strategies, you can tailor the electric fan system to perfectly complement your racecar’s specific needs and characteristics. This level of customization empowers you to fine-tune your cooling solution for maximum efficiency and performance gains.
Going back to what we learned about relays in a previous article, we know that we can easily have the ECU decide when to run the electric cooling fans. There are quite a few advantages of using ECU control other than just keeping the engine cool. Maybe we want to raise the idle a bit to compensate for the added electrical load. Maybe we like the fans to shut off at wide-open throttle to reduce load. Or, maybe we need to let the fans run in an engine-off situation to cool the car down after a pass. All of these things and more are easily accomplished with just a handful of keystrokes in TunerStudio.
Having the ability to finely tune at what temperature to come on, and what temperature to cut off gives us precise control over our engine’s coolant temp. We no longer have to rely on third-party “fan controllers” or manual switches inside the cockpit that get forgotten ( believe me I know ). This also means we no longer need to add multiple coolant temp sensors. One temperature sensor input into the ECU can be used for any temperature-related decision the ECU needs to make. This significantly cuts down the risk of wiring mistakes, or unnecessary coolant leaks, as we’re not searching for another place to add a sensor.
As we mentioned before, you will DEFINITELY want to use a relay for your fan control and any other high-current devices controlled by the ECU. This includes fuel pumps, ignition coils, coolant or oil pumps, etc. This is actually pretty straightforward, and the flexibility of the MegaSquirt line of ECUs means that you will almost always have spare outputs. If for some reason you do not, there are still options for I/O expanding dashboards or MicroSquirt as an I/O expansion device. Either way, all we need to do is choose our spare medium current output pin, assign it in TunerStudio, and wire our relay control wire ( the wire that is grounded to turn the relay on ) to our board and let her rip!
A few things to ALWAYS keep in mind. Be sure and use appropriately sized wiring from the power feed to the control relay and from the relay to the fan. This includes ground-side wiring as well, as this will need to carry just as many amps as the power side. Always used fused power for both the control and load side of your relay as well. Never wire anything directly to the MegaSquirt unprotected. Be mindful of your mounting and wire routing locations. It goes without saying that running wires near belts, pulleys, exhaust pipes, or sharp components should be avoided at all costs.
Overheating isn’t just an inconvenience; it’s a formidable adversary that can silently compromise your engine’s performance and longevity. When your ride demands speed, power, and precision, remember that the enemy within – overheating – poses a real threat. By understanding its insidious nature and taking proactive measures to prevent it, you can ensure that your engine remains intact and on track for as long as possible.
If you are looking for more details, kindly visit cooling fan control board desing.