Welcome to PriusChat

We'd love to have you join our community and participate in the conversation! Sign up for FREE today.

Sign Up

Arduino Automatic Coolant Temp Hack for Better MPG's

Discussion in 'Gen II Prius Accessories & Modifications' started by TheForce, Feb 23, 2011.

Social Buttons

  1. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    This is the next version I'm working on for the automatic coolant temperature hack. This version is based on Bob Wilson's MSP430 micro controller hack. NHW11 Prius Temperature Hack I took Bob's code and schematic ( with his permission ) and translated it to the Arduino. I was just going to use Bob's design but I was unable to get it to work. Since I understand the Arduino code more than the MSP430 I decided to just port everything over.

    What makes this different than the hardware based hack is that this hack will have both hot and cold protection. It will also keep the correct fake and start temperature no matter what the ambient temperature is since the logic is based on software and not hardware.

    All the connections I'm using are pretty much the same as my previous ACTH as seen here. http://priuschat.com/forums/gen-ii-...-automatic-coolant-temp-hack-better-mpgs.html

    The only thing I'm using different is the voltage source. Instead of taking 5v from the ECU I'm taking the switched 12v from the 12v socket.

    I started out using a resistor/cap like Bob's design to smooth out the PWM but decided to go with a digital pot. I have removed my original design and replaced it with this current one. If you read down through the thread and some things dont make since just skip to post 18. Post 18 is where I start with this current design.

    Here is the schematic for this hack. This schematic can change at any time. You can use a DPDT or DPST switch. I just had a DPDT laying around and included it in the schematic.
    [​IMG]

    Here it is working on the bench. The blue LED means its too cold to fake the temp.
    [​IMG]

    I'm currently using an Arduino Nano on the bread board just for ease of use. When I get it fully working I will be using a regular Arduino in a Arduino project box.


    Here is the source code for the Arduino. Version 0.11.03.30 The source code includes some serial output for diagnostics.
    http://stuff.jaygroh.com/priuschat/acth/aacth.zip


    If you have any ideas or input please feel free to post.

    This design and source code is completely open source. Feel free to make modifications. If you do make any changes please post about it.
  2. nerfer

    nerfer A young senior member

    Joined:
    Mar 1, 2006
    Messages:
    2,442
    Likes Received:
    179
    Location:
    Chicagoland, IL USA, Earth
    Your Vehicle Year:
    2006 Prius
    When you say it doesn't "work right", what do you mean? The temperature doesn't get substituted, or the substituted temperature is too high or too low, or is substituted when it shouldn't be?

    I assume the PWM controls the voltage that is read by the car as the current temperature. What units are those (I'm wondering why the cold temperature is higher than the target temp). Finally, I'm not familiar with the Arduino, how many bits is an int?
  3. macmaster05

    macmaster05 Senor Member

    Joined:
    Sep 27, 2009
    Messages:
    3,918
    Likes Received:
    568
    Location:
    USA
    Your Vehicle Year:
    2009 Prius
    Model:
    N/A
    This is a very cool mod but it is just completely over my head. I have no idea what you're doing. LOL.
  4. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    The temperature does not stabilize which is a result of the average not stabilizing and jumping around. Its kind of hard to explain without seeing the debug output live while in the car. As if right now I don't understand why it works perfect on the bench but not in the car.

    The PWM of the Arduino is 8 bit. The ADC is 10 bit. The voltage range for the temperature is we want is somewhere between 1.5v cold and .5v hot. In the Arduino the ADC is 0-5v and translates to 0-1023. Thats why the cold number is higher than the hot number. Its kind of confusing at first.
  5. nerfer

    nerfer A young senior member

    Joined:
    Mar 1, 2006
    Messages:
    2,442
    Likes Received:
    179
    Location:
    Chicagoland, IL USA, Earth
    Your Vehicle Year:
    2006 Prius


    I looked it up, an int is two bytes, so 8 ADC values (8*1023) will fit (< 65536), I was thinking at first maybe you were losing bits off the top when summing your samples. Then I noticed you only read into ADC_value[7], which gets copied down one slot on each loop, so only after 6 times thru the averaging loop you'll be getting valid entries, but you check for that, so it's okay.

    I don't see a problem in the averaging function, but you might want to print out the current ADC value and make sure it's not going over 1023. The code doesn't change between the bench and the car (I assume) and the problem is before your output, so I would bet the ADC input is different somehow.
  6. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    The ADC value on the bench and in the car should be the same 0-5v range. The car I dont think ever sees 5v because thats damn cold. Somehow when its in the car I think the resistor capacitor is not smoothing out the PWM like it is on the bench. I have not touched this since December so I cant really comment on what its really doing.

    I'll start working on this as soon as I can sit in the car and debug with out freezing.
  7. PhazonPhobe

    PhazonPhobe His name is Sora

    Joined:
    Oct 13, 2010
    Messages:
    217
    Likes Received:
    22
    Location:
    Fontana, CA
    Your Vehicle Year:
    2004 Prius
    Model:
    N/A
  8. seilerts

    seilerts Battery Curmudgeon

    Joined:
    Mar 7, 2010
    Messages:
    3,326
    Likes Received:
    1,438
    Location:
    Santa Fe, NM
    Your Vehicle Year:
    2005 Prius
    Model:
    N/A


    I wonder if putting an LM317 between the Arduino and the car 12V would help. The car 12V is not stable, especially at startup.

    Cool project, thanks for the info.
    1 person likes this.
  9. nerfer

    nerfer A young senior member

    Joined:
    Mar 1, 2006
    Messages:
    2,442
    Likes Received:
    179
    Location:
    Chicagoland, IL USA, Earth
    Your Vehicle Year:
    2006 Prius


    I only knew what the purpose was because I had read some of the previous threads on this before. Follow the links in the first post for more info, but basically you're fooling the car into thinking it can go into stage 3 (and thus glide) before the engine fully warms to 157'F.
  10. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    Voltage should not be an issue. The Arduino has its own voltage regulator built into the board.
  11. nerfer

    nerfer A young senior member

    Joined:
    Mar 1, 2006
    Messages:
    2,442
    Likes Received:
    179
    Location:
    Chicagoland, IL USA, Earth
    Your Vehicle Year:
    2006 Prius


    I'm not an EE so I can't really comment on that part.
    But the PWM is the output and I thought you said the source code couldn't get a stable average on the input? Did I miss something?
  12. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    If you look at the schematic you will see that the Arduino monitors the voltage of the thermistor and the circuit. Since the Arduino is using PWM on the circuit it can see that PWM on its input when it samples to get an average. The resistor cap combo is there to try to smooth out the PWM and get the correct average voltage to the car. The averaging part of the software is there to try to again get an average of the PWM pulses so the software knows about where the fake temp is in relation to the real temp and adjust.

    Try to think of this project as a computer controlled one of these.
    [​IMG]

    With the above circuit you have to continuously adjust the pot as the car warms up or cools down to keep the correct fake temp.

    Instead of having a human adjust the pot in the above circuit I want the Arduino to adjust it automatically.
  13. pEEf

    pEEf Engineer - EV nut

    Joined:
    Sep 23, 2010
    Messages:
    721
    Likes Received:
    523
    Location:
    Berkeley, CA
    Your Vehicle Year:
    2008 Prius
    Model:
    N/A
    You are only getting +12 from the outlet, correct? You are getting your ground from pin A-28 on the ECM, right? If you also ground the arduino elsewhere this will cause excessive noise on your input. As it is, the +12 could also be introducing noise. I'd get my power from pin A-18, that is properly referenced to the ECM ground, and what they use to power all analog sensors.
    2 people like this.
  14. jdenenberg

    jdenenberg EE Professor

    Joined:
    Nov 21, 2005
    Messages:
    2,390
    Likes Received:
    646
    Location:
    Trumbull, CT
    Your Vehicle Year:
    2004 Prius
    Model:
    N/A
    Peef is pointing you in the right direction. A Prius has some hefty current pulses moving around which can (and does) put noise on various ground points. find a good ground reference, use a few capacitors and it should have a better chance to work.

    JeffD
  15. 2009Prius

    2009Prius A Wimpy DIYer

    Joined:
    Mar 25, 2009
    Messages:
    2,642
    Likes Received:
    433
    Location:
    USA
    Your Vehicle Year:
    2009 Prius
    This is far-fetched but could the faking be done by sending some bogus messages to the OBD port?
  16. 2009Prius

    2009Prius A Wimpy DIYer

    Joined:
    Mar 25, 2009
    Messages:
    2,642
    Likes Received:
    433
    Location:
    USA
    Your Vehicle Year:
    2009 Prius
  17. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    I did not see that thread. I might put my project on hold depending on what ccdisce decides to do with his project.

    Personally mine is going to be all open source and would have eventually gotten to the point of a screen with real time adjustable values like ccdisce's.
  18. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    I think I'm going to start working on this again here in the next week or two.

    I decided to try a digital potentiometer so I bought 10 of the mcp4251-502e/p from digikey. Total cost for 10 of them was $9.95.

    This is a dual 5k digital pot with 256 taps. I figure that 5k should be enough and if not I could put them in series for a 512 tap 10k pot. I'm not to sure how I will implement this in the circuit yet. I'm guessing I can use this digital pot exactly like I would an analog pot since its not going to handle a lot of current. I'll have to read up on it. If I cant use it directly I think I will use it to drive a transistor like in the original circuit.

    If anyone has any input on digital pots and this project I'm listening.
    1 person likes this.
  19. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    Getting this digital pot to work was easier than I thought. I have not got it to work controlling the temperature but I did get it to fade and flash an LED.

    This digital pot has a small problem with it in that it defaults to 127 taps on start up. To combat this I put a 10k resistor to its shutdown pin and ground. Doing this puts the wiper in a "disconnected state". In order to get the chip to function again I had to use one of the arduino's digital out pins to bring the shutdown pin back to 5v which connects the pot again.

    Doing it this way will allow me to turn the digital pot on or off like if it was on a manual switch kind of like that no wire cut schematic. If I were to set the digital pot to 0 it would still output about 0.06v which might cause some issues. Using the shutdown pin drops this to 0.00v which I think would be better than just telling it 0. While in this shutdown state I can still tell it to go to what ever tap number I want and when I turn it back on the pot will be at the assigned level.

    From the spec sheet it does not look like it can handle much current so I think I will use the digital pot to control the transistor. I just need to figure out what base resistor I will need to do the job and I think I can start banging out some code.
    1 person likes this.
  20. TheForce

    TheForce Ron Paul 2012

    Joined:
    May 30, 2005
    Messages:
    3,430
    Likes Received:
    439
    Location:
    Wheelersburg, Ohio
    Your Vehicle Year:
    2006 Prius
    Model:
    N/A
    Here is an update on my progress.

    I finished merging the digital pot code into the current source code logic. Its not pretty and I have to recalculate some values for the ADC and the digital pot but it kind of works on the bench. One thing I noticed is that the ADC value and the average are a lot smoother now. Probably to the point where I could all most get rid of the average.

    Hopefully I will have time to debug it on the bench this weekend and maybe get try it in the car. If I dont get to try it in the car this weekend I should be able to try it the next weekend.
Similar Threads: Arduino Automatic
Forum Title Date
Fred's House of Pancakes Arduino captures MSP-430 Mar 21, 2014
Gen II Prius Accessories & Modifications Arduino/Raspberry Pie Idea Jul 25, 2013
Gen II Prius Accessories & Modifications HSI for Gen II with Arduino and CAN-BUS Shield Apr 15, 2011
Gen III 2010+ Prius Care, Maintenance and Troubles 2011 Prius II automatic transmission change... Today at 3:07 PM
Toyota Prius Plug-in PlP advance not opening doors automatically Aug 21, 2014