Giter Site home page Giter Site logo

dexterbg / twizy-virtual-bms Goto Github PK

View Code? Open in Web Editor NEW
76.0 26.0 18.0 29.75 MB

This is an Arduino library providing an emulation of the CAN communication protocol of the BMS (battery management system) on a Renault Twizy.

License: Other

C++ 95.66% C 4.34%
renault twizy battery-management-system battery can-bus interface arduino-library protocol-library replacement bms

twizy-virtual-bms's Introduction

Twizy Virtual BMS

This is an Arduino library providing an emulation of the CAN communication protocol of the BMS (battery management system) on a Renault Twizy.

By reproducing the system interface of the original BMS, the Virtual BMS enables replacing the original by a custom battery without changing anything else on the Twizy.

Twizy Virtual BMS

The library provides an API to control power limits and charge current, so a wide range of batteries can be used. Even lead-acid is an option.

In the most simple case this can be used without any customization. The provided "SimpleBMS" example shows how to create a very basic battery monitoring by using the Arduino analog ports to measure the battery pack voltage and temperature.

If you'd like to contribute a specific BMS adaptation, please fork and add your code in the examples folder.

Installation

To download, click the DOWNLOADS button in the top right corner, download the ZIP file. Start the Arduino IDE, select menu Sketch → Include Library → Add .ZIP library, select the ZIP file and click OK. Try out the examples included.

You will also need these libraries:

To get the smallest possible ROM & RAM footprint, set TWIZY_DEBUG_LEVEL to 0 and DEBUG_MODE of the MCP_CAN library to 0. This reduces the core memory usage of the VirtualBMS library to (currently) 8338 bytes ROM and 403 bytes RAM.

Documentation

Hardware requirements

  • Battery: you will need battery cells capable of producing enough voltage and current for the Twizy. You don't need to exactly match the original voltage and power range. The SEVCON G48 series can operate with input voltages from 19.3 to 69.6 V. The Twizy SEVCON is by default configured for a range of 39 to 65 V, but that can be modified (see SEVCON configuration). In standard configuration, the Twizy will draw up to ~330 A or 16 kW from the battery, and recuperate at up to ~70 A or 3.5 kW. If your battery cannot cope with this, you can either use the Virtual BMS to lower the limits or modify the SEVCON configuration.

    Pascal is using Nissan Leaf cells, which offer a very good combination of capacity, availability and price. Błażej is using cheap 120 Ah lead acid batteries (price ~400 Euro for a complete set). Klaus will use chinese prismatic cells adding up to ~12 kWh.

    Note: Klaus offers to organize a bulk order of high capacity prismatic 3.2V LiFePO4 cells in the range of 330€ down to 260€/kWh. For a high performance large capacity setup with 48V 240 Ah (double of the standard battery capacity) a total price only for the battery pack between 2800 and 3200€ seems possible. Each buyer would have the risk in case of failures and should add some spare cells. For details please contact Klaus at [email protected].

  • BMS: using a BMS is optional for lead acid batteries but strongly recommended for lithium based batteries. You may pick any BMS, but you should focus on those that can be connected to the Arduino to query the battery state. Our recommendation is picking a good BMS capable of early balancing, monitoring the coulomb (Ah) consumption and calculating the real SOC.

    Note: Pascal is developing a fully integrated BMS solution supporting various cell & chemistry configurations and containing the complete Twizy interface. The BMS should be available by the end of 2017. Pricing is expected to be around 350 Euro. Using this BMS will both simplify custom battery integration and reduce points of failure. You won't need an Arduino when using this BMS. For details please contact him at [email protected].

  • Arduino: to run the Twizy Virtual BMS you will need some Arduino and some MCP CAN interface. A wide range of hardware options is available. The code perfectly fits into an Arduino Nano leaving enough memory to implement quite complex custom logics. You should pick an MCP 2515 SPI CAN module with at least 16 MHz clock rate. IRQ connection is optional.

    Note: Michael offers to customize the Virtual BMS for individual applications and BMS integration. For details please contact him at [email protected].

  • Connection: see the part list for relais and connectors needed.

  • Battery case: you can use the original Twizy battery case, available as a replacement part from Renault (see part list).

    Note: Lutz Schäfer offers to build individual custom battery cases offering more space. For details please contact him at [email protected].

Compliance

As the Virtual BMS (as well as the OVMS and other Twizy tools) is based on re-engineering of the CAN protocol, a 100% compliance cannot be reached. There are still unknown fields and codes, look for question marks in the CAN object dictionary for details. Unknown parts may have an effect under special conditions that could not be produced during analysis.

Having said that, the BMS protocol emulation has successfully been tested and is actually being used in real Twizys, enabling the full standard operation using custom batteries.

If you encounter any kind of issue, please send us all details including a full CAN trace for analysis.

Projects using this library

Authors

This library has been created and is maintained by Michael Balzer ([email protected] / https://dexters-web.de/).

The CAN & hardware protocol decoding and reengineering has been done by a joint effort of (in reverse alphabetical order):

Special thanks to Klaus Zinser [email protected] for support and to Błażej Błaszczyk [email protected] for prototype implementation and testing!

Btw: we're all available for consulting, integration and customization jobs.

Donations

paypal

Donations to support our efforts and further development are very welcome.
Please send donations via Paypal to: [email protected]
Thanks! :-)

Donors will be honored in our Hall of Eternal Fame, please add a comment to your donation if you'd rather stay anonymous.

License

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110- 1301 USA

Have fun!

twizy-virtual-bms's People

Contributors

dexterbg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twizy-virtual-bms's Issues

Caricatore twizy

Hi a little question is possible that the chargers won't work on difrent twizys ?I mean if I take a new charger will work on my twizy? Because I u buy a new one and it doesn't work

Start signal fault

Hello!
Thanks to your code we got super far with our twizy! most fault codes are gone, but some annoying ones stick.

The first one is like the title: Start signal Fault P0412.
Along that code we also got: Power supply relay Fault P0218. We got a relay connected to the Sevcon relay wires on the plug coming from the Twizy.
The red STOP light is on and and the battery logo with ! on it, no ERROR though.

For now we are just connecting the bare minimum to test if it still works but to no success yet.
I was wondering if you might know a fox for this issue?

Hope to hear from you soon!
Greetings Kenneth

Twizy battery

Hi all im im new in this and I have some questions about twizy battery first in /if I take a battery from other twizy will work? Second is were I find the code? Becouse I buy all the staff to build my self one Thanks you all sorry for my bad English

Hi Dexter again i have problem with SimpleBMS ...

Hi friend, i need help a little bit, Twizy driving fine but my charger sometimes randomly shutdown ... solution is to just unplug and plug again, but this force to babysit your car, is there any possible solution via code ? Someting like loop to start charging again if SOC below value ? Im not scripter or coder sadly.
SimpleBMS.zip

Need help. Twizy charger issue

Hi, my twizy is stuck charging at max 5A, tried a lot off settings and a lot of BMS (Blazej BMS, KlausBMS, SimpleBMS). Unfortunely im still not so advanced in coding on Arduino, but i changed setChargeCurrent() value to 10 A min in code to make sure but no success. Charging percentage are not updated, i need to switch off->on. Any sugestions ?

Charger compatibility

Blazej has reworked a handfull Twizys using the VirtualBMS and has found an issue: the current VirtualBMS implementation does only work with chargers up to generation 5 (charger label: "Ind …"). Generation 8 and newer do not work, generations 6 & 7 have not yet been tested.

The effect is the charger being stuck in the first protocol init step (F0-A2 in 597h) for both driving and charging. We've found no differences yet on the CAN side. We also tried some variations on the 3MW timing, but without success.

Please reply if you can share some insight or information on this problem or can help solving this issue.

Hi Dexter after long time

After using Twizy for 1.5 year and doing 19 500 km, i did improved Arduino project still based on SimpleBMS, with very precise voltage meter (0.03 voltage accuracy), because used way is way to unprecise to use (0.3-1v accuracy) based on voltage delivered to Arduino and temperature. I expanded project with multiple security option like 3 temperature sensors, various temperature alerts and limitations, with use of ads1115 to have precise voltage based on project: https://www.youtube.com/watch?v=10QtHh6UNBs, merged toggeder. I want send you soon my project to use :)
223516274_174752581261186_7056948960566995612_n
225749656_588908008771150_4310304726786172767_n

I want to ask you, did its possible to control range showed in Twizy by battery ?! If yes tell me how pls :D

Twizy sevcon voltage limit

Source: https://github.com/dexterbg/Twizy-Virtual-BMS/blob/master/extras/SEVCON-Configuration.md
obraz
I tried doing this via Ovms, no success still cutsoff after 39 V

Patient:
Twizy, 2012 ,custom 8.7 kwh battery,

What i tried already:
Setting Twizy same as for applying tuning (no switching to GO)
In shell:

  1. enable
  2. xrt cfg pre
  3. xrt cfg write 2c02 01 592
  4. xrt cfg write 2c02 02 560
  5. says --> OK, value edited is same as we set
  6. xrt cfg op
  7. But still cutsoff, with STOP light and SEVCON low voltage error

Tried also standalone
xrt cfg write 2c02 01 592
xrt cfg write 2c02 02 560
but no clue how to get this to work

Battery charge level

Hi friend
I did simple bms (lead acid battery)
Problem that the charge level not showing nothing
Any suggestions what I did wrong
Thanks

Charger compatibility

Hi, i found a problem with new charger lnd14? 2018 year, problem with "enterstate Init" and "enterstate off" in old charger you see on frame id423[0] and see does first bit changing 03h to 00h but new charger all time send a 03h so after switching twizy off bms still think that twizy still turned on because state in debug - "driving"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.