When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission. Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network.
Hey Carl, I am in need of some help setting up code on my Arduino nano for a brushless BMW fan. I have been trying to compile and upload the previous code for it that you posted and can't figure out what the errors mean. (First time with Arduino). I know how to disassemble, but this is over my head. I've uploaded the error message if you have time to take a glance. Thanks man
Oh man, I have no idea what that means. gotta think about it. It's looks to be more of an arduino setup issue on your PC to me but I don't know.
I forgot about this thread. On my 2005 Rainier, the E40 VCM (flashed with HP Tuners and using Corvette fan settings) operates the Mercedes PWM fan that replaced the mechanical one perfectly based on coolant temp, but it won't do anything based upon AC pressure. I sent the problem up the chain at HP Tuners and they can't find anything wrong.
I've been learning about Arduino to try and make a standalone using the Nano.
I'll attach the code I have written as a PDF and also my schematic (updated with PWM output frequency mod). I bought the simulator program, but keep getting errors such as "Unknown command" when it reads other same-name commands OK. I think it is a simulator issue and am getting ready to field test the Nano. In summary, I'm using a voltage divider setup to read the OEM coolant temp sensor (I found a datasheet for it and made some calcs), and also reading the OEM AC pressure sensor since it is a 0-5V sensor. These each have an analog pin input, and output PWM to a digital pin. I am learning about using the IF statement to establish which sensor has priority as well as several fan speeds based upon either temp or pressure. It's a lot to learn. There is no monitor out setting here, as I plan to monitor the readings in HP Tuners scanner software (which is where I got a lot of the pressure sensor data).
Vin should not be 5V. Vin has it's own converter built in and thereby needs to be over 7ish. I've been connecting mine direct to 12 V in applications where there is little power draw from the arduino. If you still want to supply 5V then do it on the 5V pin.
Vin should not be 5V. Vin has it's own converter built in and thereby needs to be over 7ish. I've been connecting mine direct to 12 V in applications where there is little power draw from the arduino. If you still want to supply 5V then do it on the 5V pin.
Which fan controller are you supplying from D5?
Thanks, I didn't know the Nano could take 12V (or 13-14V with engine running) directly. I can use the 5V out for the voltage divider.
EDIT: I read this thread on the Arduino forum and apparently some have had problems with the Nano if the voltage goes over the specified max of 12. I have a 12V-9V converter leftover I can use.
The Mercedes fan has a built-in controller. The specs on it seem to be very similar to the Volvo one you tested. It also needs reversed settings for PWM, e.g. 90=10 and 75-25.
Since you are the Arduino guy here:
I found the unknown error in my code was using a comma where I needed an equal sign:
Error: pwmOut, 30;
Correct: pwmOut = 30;
I'm now using a downloaded simulator called UnoArduSim. It is based on the Uno and the Nano is not available, but it is helping me to sort the code. I'll update if I get this to work.
UPDATE- Initial test with a PWM generator showed the Mercedes fan will run @ 490 Hz if necessary. Initial test run with the Uno was not successful, still working on the code.
Last edited by V8 Supra Builder; Jul 18, 2021 at 06:53 AM.
That Volvo brushless fan with the builtin controller is installed in my Vette now. Temps are down about 10 Degrees. Did a test drive on a really hot day.
Thanks, I didn't know the Nano could take 12V (or 13-14V with engine running) directly.
Yup on projects where there is more load on any arduino, you don't want the internal regulator overheating with the big drop from 14V to 5 V. In those cases, I also use an external power module to offload the internal nano regulator. I supply it with about 8V to the Vin pin. This is a very low power application.
Got it compiled and uploaded. Arduino has a very picky file structure. Hopefully get it going tomorrow.
What would need to be changed to use the factory 2 wire ECT sensor in the BMW code? I figured I'll try to tap into that first.
Partial success this afternoon. I reduced the scope of the sketch to just AC pressure and I got the fan to run using a generic Uno with a breadboard, 12V-9V converter, and potentiometer. It accepted the frequency Hz mod, so it should be operating at 122.55 Hz. I have a PDF of the sketch attached.
I'm going to attach a spreadsheet that I wrote to calculate settings. This will work for a 0-5V sensor so long as you know the maximum output pressure. In my case, I found this on Dorman's website. I think my OEM sensor may be slightly different, so it will ultimately have to be calibrated in HP Tuners (or any other software that can read AC pressure & volts) while monitoring the AC pressure and fan duty cycle. I'm also unsure if these sensors are linear, they likely are not.
I'll continue to work on integrating the coolant temp sensor and will post once I have that working and tested.
Needs to be said: Keep in mind this is not my job, and computer coding is a foreign language to me. There is always at least one in the crowd that wants to tear down vs build up. I'm here to solve my problem and in the course of doing so help others by sharing what I have learned. I'm likewise trying to make this a solution that can be repeated and used by others. I also like to write & post in as simple a language as possible to minimize confusion.
EDIT- see later post for updated schematic:
Last edited by V8 Supra Builder; Jul 22, 2021 at 12:46 PM.
Reason: Deleted old diagram
While the AC sensor portion was relatively easy, the coolant temp portion is anything but. There are many examples of using a thermistor with Arduino, but I can't find one that works on my simulator to where I can get the 0-1023 scale to correlate to my sensor's values.
I found a Steinhart-Hart spreadsheet and was able to input some data into it with good results, but where I need help is getting a number I can use to activate the fan at certain temp ranges, or turn it off if below minimum.
Seems like it may be easier to find a 3-wire sensor that runs on 0-5V and put it in my upper radiator hose.
On my Win7 box, they are in (user account)\my documents\arduino\libraries
May be easier to look for files named *.h to find where they are on your machine.
Thanks, I ended up figuring it out, got it compiled and uploaded. I'm working on the GM 2 wire ECT code now. Kinda in the same boat as you, trying to figure out where on the scale I need to be then test it.
Yup, that's how it runs in my car for 4 out of 5 of my fans.
Did yours spiral out of control too? Runs my boost controller, nitrous, meth injection, water pump now...wired up like a christmas tree. Lol the flexibility is great though
Thanks, I ended up figuring it out, got it compiled and uploaded. I'm working on the GM 2 wire ECT code now. Kinda in the same boat as you, trying to figure out where on the scale I need to be then test it.
I don't have Excel on this computer, but I do have a Libre Office calc spreadsheet on it with some numbers I calculated using some formulas. Scroll down, and you'll see I got the ADC value for the Arduino based upon the data sheet for a GM sensor. I used a Steinhart calculator spreadsheet to get the values down to 1 degree so I could set up my fan to greater certainty. This example uses 2100 ohms for the R1 setting and 10K for R2. I'm still working on writing code.
I'll attach it as a zip file since ods files can't be uploaded here. You can download it and rename it to open it, should work with Excel or Open Office.
EDIT- File removed since I had made an error in the calcs. I'll fix it and update later.
Last edited by V8 Supra Builder; Jul 23, 2021 at 01:11 PM.
I don't have Excel on this computer, but I do have a Libre Office calc spreadsheet on it with some numbers I calculated using some formulas. Scroll down, and you'll see I got the ADC value for the Arduino based upon the data sheet for a GM sensor. I used a Steinhart calculator spreadsheet to get the values down to 1 degree so I could set up my fan to greater certainty. This example uses 2100 ohms for the R1 setting and 10K for R2. I'm still working on writing code.
I'll attach it as a zip file since ods files can't be uploaded here. You can download it and rename it to open it, should work with Excel or Open Office.
That's awesome, just what I was trying to do. I am using open office, but apparently suck at it. I'll have some time tomorrow night to mess with it. Your fan uses 12v pwm correct? How are you converting 5v to 12v?
I figured out the coding and have now tested both inputs (via a potentiometer) on my truck. The fan cycles on & off as it should.
What I ended up doing is writing "IF" statements for each fan speed and instead of lumping temp and press together, I made a new statement for each. I'll attach the Arduino ino file as a zip file if anyone wants to look it over.
This file skips all of the complex temp calcs since the Arduino doesn't need them to figure out how hot the coolant is or how high the AC pressure is to turn the fan on or off. In simulator testing, each input operated OK against the other- e.g. if the temp was too low and the AC pressure too high, the fan came on based on AC pressure. When the temp came up and surpassed the demand from the AC side, the fan sped up.
I used a spreadsheet (attached) to calculate all of this. I placed highlights on some fields where you enter data, and comments to help explain what to do. You'll need 3x temp/ohm values for your sensor to enter them on the first sheet. It does all the magic, and then you can copy/paste as text onto the 2nd page to get the Arduino values.
The directions for setting up the AC pressure linear sensor are in the Arduino file text.
Disclaimer: Other than the short test on the truck using simulated inputs, I have not real-world tested this. I have to build a harness to get it connected to my truck. I am positive it will need to be tweaked for each vehicle to get the best results, but at least this is a foot in the door.
EDIT- I have updated the Arduino file here. I had the ECT values reversed and I've added an averaging function to the reading of the inputs for smoother operation.
Last edited by V8 Supra Builder; Jul 26, 2021 at 07:01 AM.
That's awesome, just what I was trying to do. I am using open office, but apparently suck at it. I'll have some time tomorrow night to mess with it. Your fan uses 12v pwm correct? How are you converting 5v to 12v?
Look at what I just posted and try that spreasdsheet.
It's a 12V fan, not sure about PWM voltage, and apparently it doesn't matter (my fan operated from the Arduino, see above). I'm using a 12V-9V converter to power the Arduino, and planning on using the 5V pin on it to power the voltage divider for the coolant temp sensor.
I got it wired in to the truck today & made a bracket to mount it by the coolant tank- I wanted a cooler spot underhood if possible. I decided to fire the truck up and see what happened. I turned on the AC and within about 60 seconds the fan came on. I then let it run with the AC on for about a minute and it sounded like the fan was running around 25%. I then cut off the AC and I heard the fan slowing down. It eventually stopped (this is normal, it takes a while), so the AC side looks good.
The next step is to hook up the laptop and check the reading in HP Tuners.
I took some assembly and installed pics as well and will attach them. I also updated the wiring diagram- the female connector for the coolant sensor is too difficult to solder to, so I just tapped the wire instead. Nano PWM fan controller wiring diagram