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

My Duinomite Mega Canview V4 equivalent Project

Discussion in 'Prius PHEV Plug-In Modifications' started by lopezjm2001, Jul 19, 2012.

?
  1. Yes

    11 vote(s)
    100.0%
  2. Prefer to use Android Torque device

    0 vote(s)
    0.0%
  3. Prefer to use Scangauge

    0 vote(s)
    0.0%
  1. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Yes, I think it's supposed to be that data. I don't think you need to send it as a 29-bit ID (extended frame). Just a regular 11-bit ID (standard frame).

    So, I think the BASIC should look like this
    Code:
    dim txOK
    dim data(8)
    data(0) = &H21
    data(1) = &HCE
    cansend &H7E2, 0, 2, data(0), txOK
    
    After sending that I'd expect to see a message with ID &H7EA on the bus (the response ID is the request ID + 8).

    Trouble is I tried that and it didn't work. :(

    I've also ordered a Y-cable so that I can hook an ELM device and my DM to the bus at the same time (I'm not ready to dive into the CAN wiring harnesses yet!)
     
    dave77 likes this.
  2. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    My torq app is also set to 11 bit
    And it can request battery cell voltages etc

    -Htc Tapatalk ( sorry for auto spell correct )
     
  3. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    I received my OBD2 splitter today and the results are in:

    The PID request 7E2 02 21 C3 according to what my Canview V4 is saying is:

    Header = &H7E2
    Data(0) = &H02
    Data(1) = &H21
    Data(2) = &HC3
    Data(3) - Data(7) = &H00

    So data length = 3

    So, I think the BASIC should look like this
    Code:
    dim txOK
    dim data(3)
    data(0) = &H02
    data(1) = &H21
    data(2) = &HC3
    cansend &H7E2, 0, 3, data(0), txOK
    
    or maybe like this
    Code:
    dim txOK
    dim data(8)
    data(0) = &H02
    data(1) = &H21
    data(2) = &HC3
    data(3) = &H00
    data(4) = &H00
    data(5) = &H00
    data(6) = &H00
    data(7) = &H00
    cansend &H7E2, 0, 8, data(0), txOK
    
    Or maybe both codes will work.

    The mistery is solved, I hope. See photos.
     

    Attached Files:

    dave77 likes this.
  4. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    I think you need the second one but I think the cansend should be:

    cansend &H7E2,0,3,data(0),txOK
     
  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:
    1) My DM refuses to go into bootloader mode so I can't flash the V4 beta build to test. I've sent it to JLo so that he can test it.
    2) Good work by JLo on the PID requests. I thought I'd tried that variant before - but I'll try again tonight to be sure. Hopefully JLo will beat me to it :)
    3) Still debugging my HSI code (jlo I've made several bug fixes to what I sent you - but the CAN message retrieval pattern is the same)
    4) I looked at CANVIEW file and made some suggestions on how to speed it up. However, I'm seeing similar issues with HSI and so I suspect my first attempt to speed things up still isn't fast enough. Which got me thinking about adding some more CAN commands to [MM|DM]Basic (see next)
     
  6. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Both my code and JLo's code seem to be operating too slowly to reliably retrieve the CAN messages. I'm sure there are a lot of other approaches we could try within our BASIC code and one of them might work. I'll try some of 'em.

    However, I think I may also try to enhance the existing CAN implementation. I'll leave all the existing commands as is. But I'll add some additional ones:

    Code:
     
    CanOpenWithHWFilter(speed, msgType, hwFilter, openOK)
     
    speed = bits per second 10,000 to 1,000,000 (500,000 for Toyota Prius)
    msgType = 0 for 11 bit only, 1 for 29 bit only, 2 for both types
    hwfilter = bit mask to apply to incoming messages
    openOK = returned value: 1 for successful completion, 0 otherwise
     
    e.g. CanOpenWithHWFilter 500000, 0, &B01010101010101, openOK
     
    This command will use the low level message filtering built in to the CAN hardware. 
    Only messages of msgType that match the bit mask hwFilter will be placed into the
    internal CAN message buffer.
     
    
    However, I'm not sure if the HW filtering at this level is flexible enough for our purposes because we want a wide range of different messages. That means we'd need to set a wide filter and that, in turn, means we'll still catch a lot of other messages we don't want.

    These next three commands push the monitoring of the CAN messages down into the C code. If you're familiar with the Torque application then these commands are equivalent to how you add PIDs.

    Code:
     
    CanMapAttribute(attributeName$, msgId, translation$, addOK)
     
    attributeName$ = unique name used to retrieve the value
    msgId = message Id for an unsolicited message (i.e. not a PID request) that contains the attribute
    translation$ = formula to take raw bits and turn into attribute value
    addOK = returned value: 1 for successful completion, 0 otherwise
     
    e.g. CanMapAttribute("rpm", &H3C8, "2:U16:v/8", addOK)
     
    This command will add attributeName$ to an internally stored map of attributes
    of interest.  Each time msgId is received the internal map will be updated with
    the new value.  The value is calculated according to the translation string.
    The translation string is made up of 3 parts each seperated by a colon (:).
    Part 1 = starting byte within the 8 byte payload, zero based
    Part 2 = data type of raw data e.g. U16 = unsigned 16 bit, S12 = signed 12 bit
    Part 3 = formula to convert the raw value (denoted by v) into a value
     
    ---
     
    CanMapAttributeFromPID(attributeName$, ecuId, mode, pid, translation$, period, addOK)
     
    attributeName$ = unique name used to retrieve the value
    ecuId = id that should be placed in the PID request
    mode = PID request mode
    pid = pid requested
    translation$ = formula to take raw bits and turn into attribute value
    period = time between requests in milliseconds
    addOK = returned value: 1 for successful completion, 0 otherwise
     
    e.g. CanMapAttributeFromPID("MG2 Power", &H7E2, &H21, &HC3, "(256*A + B - 16383) * ((32*C + 0.125*D - 500)*0.7376) / 5252", 500, addOK)
     
    This command will add attributeName$ to an internally stored map of attributes
    of interest.  Once every period a PID request will be sent and the system will
    retrieve all parts of a multi-frame response.  Once all data has been retrieved
    the value is calculated according to the translation string.  The translation
    string represents a formula to apply with A = first byte, B = second byte
    etc.
     
    ---
     
    CanGetAttribute(attributeName$, val, getOK)
     
    attributeName$ = name of previously added attribute (can be a PID or an unsolicited value)
    val = returned value: most recently calculated value of the attribute
    getOK = returned value: 1 for successful, 0 otherwise
     
    This command retrieves the latest attribute values from the map
     
    
    Let me know what you think.
     
    lopezjm2001 likes this.
  7. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    I overlooked that bit. Thanks. It has been edited.
     
  8. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    Hi JDH2550,

    Due to having two Enginer kits I get a lot of noise. The Canbus data going to my Duinomite is sometimes corrupted by the converter noise and because there is no CRC error checking I am getting bad values. Do we need to write a CRC error checking function in our basic code or is this already done by hardware?
     
  9. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    I have taken on the program style of HSI.BAS and adopted it to my latest CanviewV4_BMS+.BAS. I have found a few bugs. Still working on it. This HSI.BAS file was a real eye opener and taught me a few things.
     
  10. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    Sounds good as long as it speeds up the updating.
     
  11. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    It looks like we might only need to do the "CanOpenWithFilter" approach initially. The other approach would be nice to add at some point.

    Looking at this picture:
    PICCAN.PNG

    1) I'm confusing "Filters" with "Masks". A filter is for a specific ID a mask is for a range of ids.
    2) We can have 32 filters per CAN module and we can have up to 32 message buffers.

    The way things are configured at the moment all messages are getting through (a Mask of 7FF) and are all flowing into one channel buffer.

    I'm changing my naming convention to CANOPENEX (EX standing for EXtended functionality) - you'll be able to set filters and masks and you'll also be able to assign message buffers. I'll also create a new CANRECEIVEEX command that will allow you to specify which message buffer to read from.

    More info later...
     
  12. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    For some unknown reason my Duinomite Mega is causing my Prius to go to what I would call safe mode (no acceleration) whilst driving. Accelation is really erratic before it goes to safe mode. No DTC. Eventually just goes to a safe mode and I have to pull over as I cannot accelerate. When it goes to safe mode the green ready light indicator turns red and when the Prius comes to a complete stop the indicator goes out. I have no option but to cycle the power to go back to normal. Only happens when my Duinomite Mega is running my program. Only happens whilst Prius is driving and not when in park. I suspect that it may be caused by the Can commands. I am not using any Cansend commands, only Canrcv commands. As there is no DTC I can only speculate. It was also doing it when I was using mmbasic3.2C.


    EDITED: It does not happen when Enginer kits are switched off. Need to make my Duinomite mega more noise immune. Once again the Enginer converters have bitten me on the arse.
    Problem fixed. I have fitted a braided metal sock over the OBD2 cable going to my Duinomite Mega.
     
    dave77 likes this.
  13. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    can this board also be used to make a 70+ cells BMS to control the charger CANBUS or just analog current control?
    whats the max analog voltage sensors that can be used?
     
  14. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    It only has 4 analogue inputs 0 to 3.3v with +/-10% accuracy. Not enough to do voltage protection for 70 cells.
     
  15. NortTexSalv04Prius

    NortTexSalv04Prius Active Member

    Joined:
    Nov 14, 2009
    915
    115
    0
    Location:
    Texas
    Vehicle:
    2004 Prius
    Model:
    N/A
    I doubt this is helpful however a little reflective. Recently, while driving low speeds with Enginer4kwV6 (On) and MFD full green I had the similiar experience you have described only without Canbus . I lost throttle/accel/pedal control and forced into neutral. I flipped(turned off) enginer. I attribute my issue to high temps and have only used my Enginer 4kw V6 when outside temps is below 100 degree F so basically 99 and below.............
     
  16. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    My two converters are inside a grounded box so noise is kept lower than compared to having the converter with no box. So the open architecture of the Versipn 6 Enginer kit probably radiates more noise than the old version 5 which uses a box. Fail to see why temperance would make a difference.
     
  17. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    I was just thinking on the issue of PID updating. Some PIDs are sent every 10ms and others are sent every 100ms. Maybe if we programmed a subroutine to canrcv the 10ms PIDs and a separate subroutine to to canrcv the 100ms PIDs. Then use the timer function to synchronize the two subroutines with the Canbus. Allowing more time for the Duinomite processor to run the program. Would this work?

    My latest program updating speed is pretty good using Alexmol's getcandata function. I only do looping of the canrcv command until HV battery volts, amps and speed are received. It works well. I have also included a blank i.e. Print ". " before every PId update so the updating speed is visual to the user.
     
  18. Flying White Dutchman

    Flying White Dutchman Senior Member

    Joined:
    Dec 29, 2007
    4,374
    313
    0
    Vehicle:
    Other Non-Hybrid
    Model:
    N/A
    Updated video?

    -Htc Tapatalk ( sorry for auto spell correct )
     
  19. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A




    If you can play the YouTube videos in slow motion you can see each value go blank just before being updated and you can see screen values being updated from top ot bottom of screen. Hard to hold the camera still whilst driving.
     
  20. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    Does anybody know of a PiD that is broadcasted (not requested) on the Canbus that shows the ready signal. A remember pEEF was talking about it.