1. Attachments are working again! Check out this thread for more details and to report any other bugs.

ARDRUINO Basic BMS control system

Discussion in 'Prius PHEV Plug-In Modifications' started by Flying White Dutchman, Sep 5, 2012.

  1. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    WANING : one wrong part in the code and your charger wil not be stopt charging and may turn your car into a blazing fire.
    use at your own risk.

    ---------------------------------------------------------------------------------------

    Hey.

    well i wanted to start a thread about using a arduino UNO to control the charger for my plugin

    I have a elcon 1500 with analog curren control and no canbus

    have 9 cellogs that monitor the cell voltages and trip a relay when one is to high and 70 bleedingboards for top balancing.

    A little history:

    Lopez started a project with a duinomite mega and DMbasic programming.
    because of this i also got a mega and made my first steps in programming that board.

    Lopez and others where already way in front of me programming stuff for it and so i desided to try a simple relay control
    using a 4 relay from ebay i was able to control those with switches connected to the duinmite.

    then a light bulb turned on.. i can use this to control my charger.

    so i did... but during that time i also read about the arduino again and got reintressed in trying that board as a controller.

    and because the arduino is smaller and a lot cheaper then the duinomite mega i got one of those for about 15 euro or at this time 17 dollars.
    compared to the 30 euro for the duinomite mega.
    ofcourse the UNO that i use does not come with canbus and other stuff so that compared its not cheaper but i dont need that for my charger control.

    The board i got was a arduino UNO clone from dealextreme and i just got it 2 days and it seems to work good.
    [​IMG]

    i have no clue how to program these things so i started of using sample sketches as they call it.

    here is my first code that i adjusted from a button press example code.

    ---



    //BASIC ANOLOG BMS CONTROL 1.0( no CANBUS )
    //created 5 sept 2012
    //by Flying White dutchman
    //modified 5 sept 2012
    //by Flying White dutchman

    //This example code is in the public domain.

    // constants won't change. They're used here to
    // set pin numbers:
    const int buttonPin = 3; // the number of the pushbutton pin
    const int ledPin = 13; // the number of the LED pin
    const int ledPin2 = 14; // the number of the LED pin
    // variables will change:
    int buttonState = 0; // variable for reading the pushbutton status

    void setup() {
    // initialize the LED pin as an output:
    pinMode(ledPin, OUTPUT);
    // initialize the pushbutton pin as an input:
    pinMode(buttonPin, INPUT);
    }

    void loop(){
    // read the state of the pushbutton value:
    buttonState = digitalRead(buttonPin);
    unsigned long starttime = 0;
    unsigned long endtime = 0;
    starttime = millis(); // set current time of system what is about 1 second or zero seconds because of unsigned long starttime = 0
    endtime = 10000; // timer in miliseconds

    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
    if (millis() > endtime) { //over time
    digitalWrite(ledPin, LOW); //relais off
    delay(5000);
    }
    else {
    // turn LED off:
    digitalWrite(ledPin2, LOW);
    }
    if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
    }
    else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
    }
    }


    ----
    the onboard LED wil turn off when the digital pin 3 is grounded with a resistor.
    when 5volts is connected to pin 3 the led will turn on.

    The led is a simulated relay what will turn on and off.
    after ( in this code just 10 sec ) 10 seconds the led wil stay off .


    this part i wil use for the balancing ,
    i know it wil take 30 min and will set it to 40 min from the moment the first cellog will trip a relay based on a high cell and when the last cell is also high.
    during that time the charger wil be turned on and off for balancing and after 40 min a compleet shutdown until mains power is cycled on and off and the board is started again.

    next step will be the real relays connected and things to do are
    - temp sensor to stop charging and fan control
    -relay based on temp sensor control fan connected to battery pack
    - relay to flash external LED at window so i can see car is charging or finished and fast flash wil mean warning to high temp.

    [​IMG]
     
  2. mrbigh

    mrbigh Prius Absolutum Dominium

    Joined:
    Sep 6, 2005
    3,686
    699
    2
    Location:
    Long Island, NY
    Vehicle:
    Other Electric Vehicle
    keep us informed of your progress
     
  3. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    yhea going to be some time
    need to learn how to program these things and also looking into a ethernet attached relay control where i can power of disconnect the main in the building where my car is parked.
    by using my android phone ;-)
    AND stil want to look at the duinomite canview stuff AND have ethernet shield for my arduino AND still have to life :p
     
  4. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    currently waiting for a dedicated relay board for this project.
    when i get that and get this to work then i can get my duinomite free again for the canview.bas project.
    i geuss it will be a week or so ( china takes some time ;-) )
     
  5. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    Well still waiting
    China is not always that fast...

    I did recieve me lcd screen for the Duinomite.
    But i need my 2e relay board

    -Tapatalk
     
  6. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    Well i still have not recieved the relay board for this setup.

    So i got a refund now pfff.

    But also no progress... Because of that.

    I desided that a second Duinomite would be best.
    1 for the bms control and ( hopefully not for nothing now lopez is going to use a different board )a second Duinomite as canview.

    Using a open collector output with 5 bootsen to the 5 volts input of the charger to go from full charge 5 volts to 1,7 volts stop charge voltages on the enable sure of the elcon tc charger.

    That way i do not need a relay board and can use the one i have for ev and phev relay on the lopez Duinomite canview.


    -Tapatalk
     
  7. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    Have recieved several china packages but still no relays board that i am trying to get one off again....


    Also al china packages are now being opent by china customs for some reason....


    -Tapatalk
     
  8. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    Why not get the FET shield board from EBay instead of the relays board. I am sure that Norm is using FETs on the BMS2 instead of relays. I guess the relays were cheaper.
     
  9. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    Canview uses read relays.. not sure about the bms2
    .

    Yes the relays rust you also have is cheaper.
    I got it from the dame place you got it from

    And so i got a second one.

    But that one never got here..


    But i have a,update.. i got one today from a other seller..

    So Maybe sometime soon i will start with this ...

    Just this week i started a new journey ij me life where i will have less time for this i am afraid.


    I did already du some code for the ardruino but i am having trouble with the timer setting.

    Ita not as simple as with the basic coding.

    -Tapatalk
     
  10. ericbecky

    ericbecky Hybrid Battery Hero

    Joined:
    Mar 12, 2004
    4,379
    3,238
    1
    Location:
    Madison, Wisconsin
    Vehicle:
    2005 Prius
    Model:
    Two
    Just wanted to say that there is a thread about making an Open Source Arduino based lithium BMS over at ecomodder.com
    DIY open source lithium BMS (battery management system) - Fuel Economy, Hypermiling, EcoModding News and Forum - EcoModder.com
    It was a project the member , Daox, started quite a while ago, posted ~February, and sporadically has updated since then.

    The most recent iteration from August 2012 is pretty nice.
    DIY open source lithium BMS (battery management system) - Page 4 - Fuel Economy, Hypermiling, EcoModding News and Forum - EcoModder.com
     
    z704w40 likes this.
  11. NortTexSalv04Prius

    NortTexSalv04Prius Active Member

    Joined:
    Nov 14, 2009
    915
    115
    0
    Location:
    Texas
    Vehicle:
    2004 Prius
    Model:
    N/A
    yea
    I look at his open source bms and did not understand but that is just maybe me
     
  12. NortTexSalv04Prius

    NortTexSalv04Prius Active Member

    Joined:
    Nov 14, 2009
    915
    115
    0
    Location:
    Texas
    Vehicle:
    2004 Prius
    Model:
    N/A
    I am less and less impressed with bms and top balance of Lifepo4 the more I read ...... bottom balance seems much better method and process to go with...