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

YAPiP - recreating pEEf's approach

Discussion in 'Prius PHEV Plug-In Modifications' started by jdh2550, May 23, 2012.

  1. Flaninacupboard

    Flaninacupboard Senior Member

    Joined:
    Apr 25, 2010
    1,297
    213
    0
    Location:
    Midlands - UK
    Vehicle:
    2010 Prius
    Model:
    N/A
    Ah well I do a lot of coding for work, so I prefer to do something different for a hobby!

    It's from an old Eddie Izzard joke about the slow and unnoticed collapse of the Austro-Hungarian empire, it was "like a flan in a cupboard". Maybe I should update, I must have been using that nick since '99!

    Somewhere I have a different data sheet which describes "Optimal charge" as 0.2C, and "Maximal charge" as 0.5C. Regen events are of course quite short (except heading down a mountain) but temperature monitoring will allow you to reduce CCL if required (if you have cold weather it should also be reduced).
     
  2. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    And I call this installment "Flags Ahoy!"...

    I've been working on graphing the data that I've collected. The app is "hackish" (you have to re-compile to add attributes to the charts) - but it's starting to resemble something that I'm starting to find useful for trying to figure out the meanings of some of the data flags (and also confirming for myself that I see what other folks have already discovered).

    Attached is a screen capture of the display for a log file that represents my 8.5 minute commute (that will be pure EV when I'm finished with this project!). For some reason I don't seem to have the last few seconds. I'll have to fix that (don't know yet whether it's an issue with the data collection or the data interpretation).

    The top graph shows a bunch of the analog signals and should be fairly obvious. Y axis gives the signal value (for RPM I've divided by 10). X axis is time in seconds.

    The bottom graph shows the state of individual bits within data bytes of CAN IDs where those data bytes have been identified as flags by either Vaas or Kinetic (both those sites are required reading!). My naming convention for these traces is <CAN ID>.<BYTE NUMBER>.<BIT NUMBER>, both byte and bit number are zero based. So 038.B0.b3 (which is the bottom most trace) represents a trace of bit 3 from byte 0 from the CAN message with an ID of 0x0038. X axis is again time in seconds (and lines up with the top graph) but Y axis doesn't mean anything (I just use different offsets so as to be able to put all my flags on one graph).

    I think that there are three CAN messages that contain flags that we're interested in: 038 is the hybrid ECU and contains two bytes that have been identified as flags. 348 is also the hybrid ECU and contains two bytes of flags. Finally we have 3C8 the engine ECU and containing one byte of flags.

    With me so far? If you are then here's what I've noted about the traces so far.

    CAN ID = 038
    SOURCE = Hybrid ECU

    038.B0.b3 = start engine request
    038.B0.b5 = only seen two brief occurences (one message each) in one data file so far
    038.B0.b6 = READY (is this the actual one and only READY signal or something else that is high all the time?)

    038.B2.b0 = seems somewhat related to b2 & b4
    038.B2.b1 = no obvious pattern and seems to have its own unique activity pattern
    038.B2.b2 = seems somewhat related to b0 & b4
    038.B2.b4 = seems somewhat related to b2 & b0

    Should PHEV ECU not pass engine start requests through to Engine ECU? Or, will other changes mean that Hybrid ECU will no longer send engine start requests? This is one of the major conundrums I expect to face with a bunch of message - what's cause and what's effect? what's a request and what's a response?

    CAN ID = 348
    SOURCE = Hybrid ECU

    348.B0.b2 = engine spinning (inverse of 348.B1.b0)

    348.B1.b0 = engine not spinning (inverse of 348.B0.b2)
    348.B1.b1 = no obvious pattern except that it's only ever active when engine spinning
    348.B1.b3 = follows 3C8.B1.b4
    348.B1.b5 = follows 348.B0.b2 but with different timing on hight->low transition
    348.B1.b6 = follows 348.B0.b2 with very similar timing


    CAN ID = 3C8
    SOURCE = Engine ECU

    3C8.B1.b0 = only 3 brief (one message?) occurrences, two of which occur close to transition from spin to no spin (and one that doesn't!)
    3C8.B1.b1 = is this engine warm up request? it transitions high matching first engine on and transitions low when ECT > 50C
    3C8.B1.b2 = follows 348.B0.b2 but with different timing
    3C8.B1.b4 = follows 348.B1.b3

    --

    Sorry to disappoint - there's not really much new in any of the above. About the only thing that is new (well, to me anyway) is that I'm pretty confident that 3C8.B1.b1 appears to be the engine warm up request.

    The above analysis was done at a high level by looking at the entire 8.5 minutes of data (as shown in the attached screen shot). Next I'm going to dive into some of those transitions in detail (zooming in to see some exact ordering of messages).

    If anyone see's anything in these traces that seems to make sense to them, or if anyone already knows a more detailed break down of these flags then please let me know. BTW you should also read Decoding CAN messages 0x348 &amp; 0x3C8 as described by pEEF | PriusChat by lopezjm2001...
     

    Attached Files:

    lopezjm2001 likes this.
  3. Bruce Meacham

    Bruce Meacham 2005 Prius/Enginer 4kwh and BMW EV conversion

    Joined:
    Jun 17, 2012
    45
    8
    0
    Location:
    Kansas
    Vehicle:
    2005 Prius
    Model:
    N/A
    I wonder... Here's an experiment... you need to disable your engine in a way that doesn't make it go into "check-engine". Perhaps disconnect all the spark plugs or remove the spark plugs? This will simulate what the HEV does when the engine doesn't respond with "I'm running".

    AWESOME data!
     
  4. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Re-reading my notes from pEEf's thread and looking at the data collected and identified I think I might already know enough specifics to do "high speed EV mode" (and I'm more confident I know enough to do "large plug-in pack"). I've also refined my thinking on overall project plan, the modes of operation and the stages in which I'll implement this stuff.

    Three modes:
    1. Normal - this is the minimum of work required for the Prius to work with a larger than normal battery pack that is externally charged. It only requires replacing the battery ECU on the main CAN bus (no bridging, and hence only a device with one CAN port is required). In normal mode the new battery ECU will keep track of real SoC but send a spoofed value. The code consists of building and sending 3CB and 3CD messages. 3CB for the data and 3CD to send zero DTCs. The spoofed SOC will remain high (>74%?) until real SOC falls to 10% and then spoofed SOC will aim to keep real SOC at around 10% by spoofing with values around the Prius target of 60%(?) SOC. CCL and CDL will be set appropriately to support this. I'll also create and send my own CAN message with real SoC so that a device listening on the OBD 2 port can display real & spoofed values.
    2. EV Only / Manual Warmup- Same spoofing as normal, plus spoof the ECT, inhibit ECM warmup requests and alter Hybrid ECU power/rpm requests to be zero-power/rpm requests (to spin the ICE to keep the MG's in operating range). This level of spoofing requires that the new battery ECU now have two CAN ports and that it separates the ECM onto it's own secondary bus. Warmup will only occur if I command it to (not sure how to rig that up - pEEf uses a map button on the steering wheel - but my Prius has NAV (but it won't work!)). Taking each of the required spoofs in turn:
      • ECT can be spoofed by intercepting 0x039 and substituting whatever value we want
      • Warmup can be inhibited by masking out 3c8.B1.b1
      • Hybrid ECU power/rpm requests are split between 038 (power) and 348 (rpm). I'm not sure if RPM can go straight through and simply zero out the power request in 038. Or, it might be that I need to choose a different RPM for a more optimal strategy.
    3. Blended / Automatic Warmup - Entirely automatic with the goal of leaving warmup of the engine as late as possible but also allowing the ICE to kick-in for hard accel at higher speeds (i.e. when the EV accel response starts to feel inadequate). This interacts with all the same messages as 1 & 2 - just the algorithms are different. I'm not exactly sure how I'll implement this yet.
    I also want to allow easy switching between the operational modes at any point in time. The ideal is that my wife (and Bruce's) will leave it in automatic and never have to be fussed with any changes to her driving routine! ;) Whereas those of us who want to play can switch modes and ponder possible improvements and look at little gauges go up and down etc. etc. :)

    Updated Project Plan:
    1) Continue to gather data and improving the analysis software. More knowledge is always good.
    2) Implement Normal mode (Atmel board; using one CAN port plugged into OBD port; battery EMS removed)
    3) Implement Duinomite based monitor (plugged into OBD port)
    4) Implement EV Only mode (Atmel board creating a bridge between main bus and secondary bus)
    5) Implement Blended mode (no hardware changes - "just" software)

    So, as #1 is ongoing, next up is implementing normal mode. Woo hoo! :cool:

    Implementing Normal Mode:

    A) Battery pack is ordered - it should be ready for pick up later this week.

    B) I need to choose a charger - TC is probably less expensive but is less proven and furthter away. So the ElCon is the current front runner.

    C) BMS - I'll have to see if there are three R&D worthy BMS's available, if not I'll have to arrange to get some extras made (and I'll have to pay for 'em!)

    D) Battery Installation and Cabling - seeing as the cells are already packaged in sturdy boxes I'm hoping installation will be pretty straightforward. I'll need to do some Cabling - so I'll check with Jack to see if he has extra connectors I can buy. I plan to use the preexisting SMR and fused isolation plug. Question: will I need a bigger fuse?

    E) Instrumentation - my original plan is to use the preexisting current sensor and a new voltage sensor. I'll also have to send the ready signals for each of the three relays in the SMR to the Hybrid ECU (BTW, it seems strange to me that the Hybrid ECU controls this and not the battery ECU). I'm now starting to think about keeping the original battery ECU and have it on the secondary bus and use it's pre-existing circuitry for current, voltage and SMR to Hybrid ECU interface. That means that even normal mode will need a secondary bus connection. Depending on the SMR stuff I think I'll start with my original option - so I need to ask Erik about a suitable voltage sensing circuit.

    F) New battery ECU hardware - to ease development I'll unplug the old battery ECU in the back but I'll plug the new battery ECU into the OBD port at the front so that I have easy access to its display, SD card etc. - this will mean I'll have to (temporarily) run the instrumentation signals up to the front of the car - I hope that won't be a problem.

    G) New battery ECU software - I have some pseudo code that I'll post later. Seems pretty straightforward (famous last words!).

    So, important tasks:
    1. order charger
    2. check on BMS availability
    3. ask jack about single pole connectors and cabling supplies
    4. answer fuse question
    5. ask Erik about voltage sensing circuit and acquire parts
     
  5. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Update as of 7/9...

    1. order charger: ordered an ElCon PFC 2500W with CAN - shipped 7/11
    2. check on BMS availability: this may be the gating item
    3. ask jack about single pole connectors and cabling supplies - done, will buy extra two pole connectors when I pick up the pack and will do cabling myself (to allow more flexibility in choosing a layout) - ready for pick up on 7/13
    4. answer fuse question: will start researching today
    5. ask Erik about voltage sensing circuit and acquire parts: done - see below
     
  6. Bruce Meacham

    Bruce Meacham 2005 Prius/Enginer 4kwh and BMW EV conversion

    Joined:
    Jun 17, 2012
    45
    8
    0
    Location:
    Kansas
    Vehicle:
    2005 Prius
    Model:
    N/A
    She thanks you.

    Batteries ordered! You're now committing.

    On cabling, sustained 200A loads over 20'. I think Toyota is using something around 8-gauge. It was way smaller than I thought is should be at the time, but now that I know sustained loads are under 30A, it's well within spec. If you have a good/big hand crimper, that will probably suffice. Double check my assumptions on the size, do your own googling/math. If that's too much, the local battery shop is a good source for making custom wire harnesses.

    On the instrumentation, I'm entirely replacing the BAT ECU, it's going to be more trouble than it's worth reverse engineer it to handle 10x capacity. Just figure out the basic messages that keep the HEV happy, and go from there. I bet most of those BAT ECU messages are "informational" and nobody is listening... hum ho.

    What where your thoughts for voltage sense? Just a resistor or op-amp? I found this app note, but it's complicated.

    On the current sense, I am unsure, shunt or hall effect. Do you have an opinion there?

    Good luck!

    -Bruce
     
  7. Bruce Meacham

    Bruce Meacham 2005 Prius/Enginer 4kwh and BMW EV conversion

    Joined:
    Jun 17, 2012
    45
    8
    0
    Location:
    Kansas
    Vehicle:
    2005 Prius
    Model:
    N/A
    What did you go with?
     
  8. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    I've plenty of resources for making the cables. I just want some single pole Anderson connectors to string my packs together. I'll go with overkill on the cable - no one ever complains of having too big cables (well, within reason).

    Yes, I'll most likely replace the BAT ECU - even if I use the BAT ECU I'll just be using it to read current and voltage for me - which is overkill. But it might be simpler.

    Probably an appropriate single IC solution. Don't know yet - will check in with Erik (EE and co-founder of Current Motor) tomorrow.

    I'll be re-using the hall effect sensor that's already there.

    Thanks.

    BTW, I ordered an ElCon PFC2500 w/ CAN interface. $770 from these guys: EVolve Electrics, Electric Vehicle Parts, EV Kits, Thunder Sky, Lithium Ion Batteries, Netgain, ADC, Sinopoly, CALB, GBS, Curtis, Zivan, Quick Charge, IOTA, Elcon
     
  9. Bruce Meacham

    Bruce Meacham 2005 Prius/Enginer 4kwh and BMW EV conversion

    Joined:
    Jun 17, 2012
    45
    8
    0
    Location:
    Kansas
    Vehicle:
    2005 Prius
    Model:
    N/A
    The charger selection was exactly what I was going for... I'm thinking about controlling the charger voltage and or current near end of charge. The LiFePO4 chemistry has a particularly abrupt charging voltage "elbow"...

    So let's say I'm charging my BMW, I have 44 100Ah cells, 144v nominal. Let's say I start charging with 30Ah capacity (70% to charge) and I'm charging at 20Ah, I see 145v. It gains about 1v/half-hour until you get to 99A (1% left), abruptly everything changes... As the cell reaches fully charged voltage rises quickly ~1v/minute. I set my charger at 162v. My miniBMS balancers start to light up at 158v (3.59v/cell) and about five cells go first, then the rest come on within 3 minutes and the current drops within a minute to 5A... then slowly drops over 10 minutes to 1A.

    The miniBMS system is connected to my charger if any cell is over-volting (3.8v), it shuts down the charger. Early on I set the voltage too high and occasionally it turned off. For my Prius system; I'd like to drive that from my batt bridge. Once I sense an imbalance, I'd drop the charging amps to 1.2, then keep it on for an hour to give it time to balance.
     
  10. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    OK, so the measurement is a little more complex than I had first thought because of the fact that the battery pack is isolated and has it's own ground (which of course is a very good thing!) However, it means that I need to take into account that some functions need to be on the "battery pack side" and some functions need to be on the "vehicle side" and others don't care. After Erik (patiently!) explained all this I've come up with a couple of different possible designs. The first will work with the dev board that I have regardless of it's implementation of the CAN ports. However, it introduces a second processor. The second design utilizes the I/O of the dev board but requires that we can modify the dev board to put isolation between the CAN chips and the transceiver chips. Hopefully a diagram will make sense...

    First option 1:
    SystemDiagram.png

    The voltage is measured by a simple resistor divider arrangement and I will continue to use the current sensor that Toyota so thoughtfully provided. To make sure I'm measuring voltage with the same ground I'll use a small switching power supply that will convert my 230V pack voltage down to 12V. This will power an Arduino that will be used to measure the 5V signals that will represent current and voltage. Also feeding into this processor will be the temperature readings from the thermistors installed in the battery boxes and the digital control values from the BMSs. The BMSs are also powered from the 12V power supply and are attached to the pack with one wire from positive terminal for each cell plus ground from the most negative cell. The Arduino will collect this data and send it out as a serial message stream that will go through an isolation IC to the Battery ECU. The Replacement Battery ECU is the Atmel Dev board. This is powered from the vehicle's 12V supply that shares a common ground with the chassis. This board then hooks up to the CAN bus (and that architecture has been described before).

    The downside of this approach is that it introduces another processor and leaves the I/O of the dev board underutilized. However, the plus is that it's more modular and allows an easy replacement of the dev board with a different board without having to worry about isolation issues.

    Next up option 2:
    SystemDiagram-v2.png

    This version is functionally equivalent to option 1 - the difference is that I utilize the processor on the dev board for the measurement. To do this I switch to powering this board from the battery pack (via the step down power supply). Because we need to connect the dev board to the CAN bus we need to place the isolation between the CAN transceivers and the CAN message processing. The CAN message processing is on the chip - we're hoping that the transceivers are external so that we can reroute the data from the chip through the isolation circuitry to the transceiver.

    Bonus: When I first showed Erik my option 2 I had the isolation external to the dev board (i.e. between the transceiver and the CAN lines). It looked logically similar to me. However, the type of isolation Erik is suggesting works for uni-directional signals the CAN signals are bi-directional (there's two lines but the signal is differential vs. the two lines of the serial where one is Rx and the other Tx). So, I learned a bunch of practical stuff about isolation today. Yay for me! :)

    BTW - if any of this sounds goofy please let me know - I may well have described it wrong. I ain't no EE! (This is what happens when you give a SW engineer (me) too much caffeine and a little bit of knowledge...)

    Onwards and upwards!
     
  11. Bruce Meacham

    Bruce Meacham 2005 Prius/Enginer 4kwh and BMW EV conversion

    Joined:
    Jun 17, 2012
    45
    8
    0
    Location:
    Kansas
    Vehicle:
    2005 Prius
    Model:
    N/A
    :confused: Anyway!?

    Nice work!

    I would say go with option 2. You have to line isolate somewhere, CAN bus can do this, simpler is always easier. The trick is getting 12vdc from that 240vdc line. I think you want something like this, just a guess. There are larger ones but the price goes up quickly.

    Check the transceiver specs with the dev-board, many have built in opto-isolation. I thought it was required at the physical level for CAN.

    -Bruce
     
  12. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
  13. 2009Prius

    2009Prius A Wimpy DIYer

    Joined:
    Mar 25, 2009
    2,705
    509
    63
    Location:
    USA
    Vehicle:
    2009 Prius
  14. mrbigh

    mrbigh Prius Absolutum Dominium

    Joined:
    Sep 6, 2005
    3,686
    699
    2
    Location:
    Long Island, NY
    Vehicle:
    Other Electric Vehicle
    Isn't an overkill? For common testing and/or experimenting will be OK but You can build an isolated power supply with a very few components.
     
  15. Bruce Meacham

    Bruce Meacham 2005 Prius/Enginer 4kwh and BMW EV conversion

    Joined:
    Jun 17, 2012
    45
    8
    0
    Location:
    Kansas
    Vehicle:
    2005 Prius
    Model:
    N/A
  16. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    I believe it depends on the implementation - some are "too smart".
     
  17. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    For $12 + s/h it's a bargain. My time is worth more than that. Not sure I can source all the one-off parts for that price either. Then you've got reliability etc.

    Don't get me wrong - some people will approach this wanting to build their own wherever possible (back to my old favorite climbing Everest analogy) - and I can understand that. It's just not where I want to spend my time.

    Oh yeah, and remember that I'm a SW engineer - so I try and avoid as much EE stuff as possible! I'm dangerous enough as it is... Just ask Erik... ;)
     
  18. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    I picked up my batteries from Jack on Friday (thanks Jack!!) They're beautiful :) Compact, well packaged, well cabled and ready to fit in so many different ways into my Prius. I'll be sure to keep the group posted on how they perform.

    The downside of my determination to replace the NiMH pack entirely is that I don't want to loose the use of my car while I make things work. So, I think I'll do a temporary installation concentrating on making the system easy to access and debug and easy to switch between NiMH and LiFe. Obviously, I want to make the final installation as compact and user-friendly as possible. But for now I just need something that works.

    I've ordered my charger - unfortunately the shipping number they gave me says it was delivered to an address in California. Hopefully they just gave me the wrong shipping number????
     
    dave77 likes this.
  19. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Update on the charger: Nope, someone at either the vendor or their supplier moved a little too quickly and shipped to a different John Harding c/o someone else in CA. Hopefully I should be getting my charger soon...

    The charger snafu, the non-functioning of my eMega Duino and the need for making some isolation circuitry has given me some time to think about the realities of how long it might take to get this all working properly. As I mentioned above I'll do a temporary installation - however, I think I need to do a high quality temporary installation. Something that won't introduce problems because it's "slapped together quickly". So, I think I'm going to make a trunk insert out of plywood and mount everything to that - I'll sacrifice trunk space during the conversion process. The goal being easy swap over between standard and PHEV hardware. When it's all working I'll then do a more compact final installation and replace the NiMH at that point.
     
    dave77 and NortTexSalv04Prius like this.
  20. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    It took over a month to get my Elcon charger from EVassemble.com. Same with Mr Plugin and others. They gave some lame BS excuse after another but the fact was that they probably started making the charger when it is ordered. So don't be surprised if it takes over a month. This is how Chinese companies operate. I know you ordered yours from EVevolve.com but you never know.