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. lopezjm2001

    lopezjm2001 Senior Member

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

    If you wanted to you could order the UBW32-MCC-PCB in kit form and build it yourself and any basic program I write for the CGcoloumax1 should work but I have been informed that the CAN is untested. It should be cheaper I guess. So you or anybody else who reads this thread could be the first to test the CAN.
     
  2. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    I have just uploaded the latest version of my BASIC program for the Duinomite Mega Canview V4.0 BMS+. It is located in the first post of this thread. It includes amendments and improvements by [email protected] | PriusChat.

    Below is my readme.txt file.

    DISCLAIMER - USE AT OWN RISK
    WARNING: Watching the CANVIEW v4.0 screen whilst driving is dangerous and any subsequent accident due to not watching the road is entirely your fault. The police can charge you with negligent driving as a result of doing so. So be warned.....do not watch the CANview V4.0 LCD screen whilst driving!!
    CANVIEW V4 - WWW.HYBRIDINTERFACES.CA

    Based on the original Canview V4 by Norm Dick
    This version by [email protected]
    This BASIC program is intended for a Duinomite Mega using a keyboard and a VGA monitor.
    At a later date it will be updated for a touch screen as shown here
    The Back Shed: Small VGA monitor
    Setup for BMSplus end voltage range 195v - 235v in 5v steps (default value is now 235volts).
    When R1-R4 = 0 relay is energised.
    The HV battery fan speed runs in either:-

    auto - controlled by HV battery temperature limit i.e. 25degC or
    Manual - set speed by pressing number 1 to 6 on keyboard to change speed
    In manual it will run at a speed lower than 6 for a fixed period of time and then
    automatically change to 6 being maximum speed.

    The files i.e. autorun.bas and logo.bmp are available for free @ WWW.Priuschat.com at
    My Duinomite Mega Canview V4 equivalent Project | PriusChat
    This basic program autorun.bas is compatible with using mmbasic V4.2 with
    John Harding's CAN COMMAND implementation available for free at
    http://priuschat.com/attachments/duinomite-canb2-zip.42794/
    or
    http://geoffg.net/Downloads/Maximite/MMBasic%20with%20CAN.zip
    Both files (autorun.bas and logo.bmp) must be stored in the root directory of the microSD card of your Duinomite Mega.
    The program is saved as "AUTORUN.BAS" as it will be loaded and will run automatically
    from the micro SD card and must be saved into the root directory on the micro SD card. Any other
    file name has to manually loaded and executed.
    If you press the "t" key on your keyboard at bootup you can run the program without
    the Duinomite Mega board having to be hooked up to a live CANbus port. It will skip the intro and
    will not wait for CANbus data.
    Canview V4.0 Basic Program Pages
    Keyboard button - page description
    F1 - EV man/auto
    F2 - Enginer Converter 1 button AUTO/OFF
    F3 - Enginer Converter 2 button AUTO/OFF
    F4 - PHEV/ORIG
    F5 - OEM Nimh cell voltages
    F6 - OEM NIMH cell resistances
    F7 - Plot a graph, press F7 again to select two variables to plot.
    F8 - Data analysis page.
    F9 - Data logging page. Press ESC to finish logging. Data is saved to DATA1.CSV, DATA2.CSV,DATA3.CSV,DATA4.CSV and DATA5.CSV.
    You can navigate between pages whilst data logging but you can only END logging on F9 page by pressing the ESC key.
    Data logging is now appended to data files. A date$ and time$ stamp is included at start of each data logging session.
    The date$ and time$ value will be lost when Duinomite Mega is powered down and will change to default values (Year 2000, time 00:00:00)when powered up unless a Lipo battery is plugged into the Duinomite Mega JST connector.
    The LiPo battery with 3.7V 1400mA capacity and JST connector for DuinoMite-Mega is available from Olimex. At maximum frequency with a VGA monitor connected the consumption is 125mA which will allow the DuinoMite-Mega to run about 10 hours on battery.
    A asterix will blink on every page when data logging is active.

    F10 - HV battery fan AUTO/MANUAL speed button. Press 1 to 6 on keyboard when in manual mode.
    to adjust speed when in MANUAL.
    F11 - get DTC codes.
    F12 - clear DTCs
    s - BMSplus H555 canbus message
    p - PSD page - Power Split Device.
    t - Temperature page
    q - quit
    z - Test pages showing values of unsolicited PIDs.
    ESC - Goes back to main page, If on F9 - "Data Logging page" pressing the ESC key will END plotting.
    DISCLAIMER - USE AT OWN RISK
     
  3. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    Thanks :)
    I had changed the logging and few bits and pieces already on mine but now can revert back to your code...
    pretty much same changes except you added extra log 5 file ( i shifted the "data log active" msg to lower right below ECT temp but the asterisk achieves the same.. :)
    Now all we need is touch screen :) ...
     
  4. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    PS can you confirm where your RELAYS physically attach to your Duino Mega ? the Mapping from MMbasic PIN numbers to Duinomite physical connector pin is very confusing to say the least ..

    SynECO
     
  5. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    JHD,
    Does CAN code for MMbasic support the dual CAN interfaces of the PIC32 795 in the latest MMbasic release?
    Thanks.
    SynECO
     
  6. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    Would this help ..
    USB non-HID Touchscreen (eGalax) on PIC32 USB HOST
    ???
     
  7. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    It is a bit confusing. There are software pin numbers which corresponds with actual GPIO pin numbers.
    There is a GPIO mapping table.

    Relay 1 is actually on pin 12 (software pin 15).
    Relay 2 is actually on pin 14 (software pin 16).
    Relay 3 is actually on pin 16 (software pin 17).
    Relay 4 is actually on pin 18 (software pin 18).

    So my basic program refers to software pin number. The actual GPIO pin number is different except for pin 18 they are the same pin number. Clear as mud?
     
  8. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    So for our touch screen program we need four analogue inputs, one digital output and a digital interrupt input.

    Say we use

    Software pin 1, external pin 21 as analogue input
    Software pin 2, external pin 19 as analogue input
    Software pin 3, external pin 17 as analogue input
    Software pin 4, external pin 15 as analogue input

    Software pin 5, external pin 13 as interrupt input

    Software pin 11, external pin 4 as digital output

    Code:
    ' touch display demo
    ' by TassyJim
    ' 16 Nov 2012
    ' see the XPT2046 or ADS7843 data sheets for a description
    ' of how the resistive touch screen works
    cls
    TouchY1=37		  ' 4 analogue input pins for the resistors
    TouchY2=35
    TouchX1=38
    TouchX2=36
    TouchIntEnable=34  ' any digital output pin
    TouchInt=28		' digital interupt pin
     
    gosub _touchEnable
    
    We change the code below to:

    Code:
    ' touch display demo
    ' by TassyJim
    ' 16 Nov 2012
    ' see the XPT2046 or ADS7843 data sheets for a description
    ' of how the resistive touch screen works
    cls
    TouchY1=1		  ' 4 analogue input pins for the resistors
    TouchY2=2
    TouchX1=3
    TouchX2=4
    TouchIntEnable=11  ' any digital output pin
    TouchInt=5		' digital interupt pin
     
    gosub _touchEnable
    
    1. Use a multimeter on ohms selection to identify the resistances between X1 and X2 / Y1 and Y2.

    2. Wire the touch panel as shown below.

    Y1 connects to software pin 1, actual pin 21
    Y2 connects to software pin 2, actual pin 19
    X1 connects to software pin 3, actual pin 17
    X2 connects to software pin 4, actual pin 15

    All power comes from the digital output.

    touch_screen_wiring_diagram.JPG

    3. Test TassyJims program to verify it all works.

    4. Add TassyJim's program to my basic program. Leave out the "main loop" main program as shown below. Just need to use the two subroutines.

    Code:
    ' touch display demo
    ' by TassyJim
    ' 16 Nov 2012
    ' see the XPT2046 or ADS7843 data sheets for a description
    ' of how the resistive touch screen works
    cls
    TouchY1=37		  ' 4 analogue input pins for the resistors
    TouchY2=35
    TouchX1=38
    TouchX2=36
    TouchIntEnable=34  ' any digital output pin
    TouchInt=28		' digital interupt pin
     
    gosub _touchEnable
     
    [S][S]_mainLoop: [/S][/S]
    [S][S]'do stuff while waiting for a touch [/S][/S]
    [S][S]if t=1 then  [/S][/S]
    [S][S]font 1, 4 [/S][/S]
    [S][S]print @(100, 40)"X ";Xhit;"  ";@(100, 90)"Y ";Yhit;"  " [/S][/S]
    [S][S]pause 100 [/S][/S]
    [S][S]gosub _touchEnable [/S][/S]
    [S][S]endif [/S][/S]
    [S][S]goto _mainLoop [/S][/S]
     
     
    _touchEnable:
    setpin TouchY1, 1
    setpin TouchY2, 1
    setpin TouchX1, 1
    setpin TouchX2, 8
    Pin(TouchX2)=0
    setpin TouchIntEnable, 8
    pin(TouchIntEnable)=1
    pause 100
    setpin TouchInt, 7, _Touched
    t=0
    return
     
    _Touched:
    pause 5				' debounce time
    if pin(TouchInt)=0 then ' touch still there
    setpin TouchInt, 0	  ' disable the interupt
    setpin TouchIntEnable,0 ' disable the interupt resistor
    setpin TouchX1, 8	  '
    Pin(TouchX1)=1		  ' X1 is now high and X2 low
    pause 5
    Xvolt=pin(TouchY1)	  ' read the X position using Y1
    setpin TouchX1, 1
    setpin TouchX2, 1	  ' set the X as input
    setpin TouchY1, 8	  ' and the Y as potential divider
    setpin TouchY2, 8
    Pin(TouchY1)=1
    Pin(TouchY2)=0
    pause 5
    Yvolt=pin(TouchX1)	  ' read the Y position using X1
    Xhit=int(mm.hres*Xvolt/3.3)	' you can scale to any value here
    Yhit=int(mm.vres*Yvolt/3.3)
    if Xhit >470 or Yhit < 5 then  'reading is suspect
    Xhit=0						  ' so set the results to zero
    Yhit=0
    endif
    t=1					' flag to indicate a touch decoded
    endif
    ireturn
     
    
     
  9. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    OR a PIC32 USB host driver for Touch ...... :) :p
     
  10. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    One minor bug still in this release that we had fixed
    F11 always show DTC display ( of Zero) for Cruise ECU

    prob:


    If rxId = (rxData(0) = &H4) And (rxData(1) = &H53) Then
    Font 2 : Print @(10,190) "Cruise ECU: ";

    FIX :


    If (rxData(0) = &H4) And (rxData(1) = &H53) Then
    Font 2 : Print @(10,190) "Cruise ECU: ";


    sorry didnt mention this one before cause only minor.

    SynECO
     
  11. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    Good observation. I will include it in my next update. Will try to make an update at least once monthly.
     
  12. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    Good luck with that one.:D
     
  13. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Nope. Only 1 CAN channel is supported


    DROID RAZR ? 2
     
  14. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    Would it take much to support both CAN Interfaces ?
     
  15. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    It would be "non-trivial"

    DROID RAZR ? 2
     
  16. SynEco@eVehicle.co.nz

    Joined:
    Jan 9, 2007
    139
    19
    0
    Vehicle:
    2004 Prius
    Model:
    II
    So it'll take a few days ? ;)
     
  17. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    I think that what JDH2550 might be saying is that mmbasic is too slow to keep up with the transfer of CAN messages from one CAN port to the other. Programming in C or assembly language would be a lot faster. So if this is the case then even if having two CAN ports would be trivial if mmbasic was too slow.
     
  18. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Adding two CAN ports to MMBasic would take more than a few days to implement and be of questionable use when done. As such it's pretty low on my to-do list.

    1) To do this I first need a UBW32 or similar that's been updated to expose both CAN ports. It's possible that I could try using the Duinomite eMega. But I'm not convinced that's a good idea.

    2) Then I need to update the code and test

    3) As jlo mentions using mmbasic to bridge information between two ports would probably be too slow if all the work is done in the BASIC interpreter. One could still make a BASIC command which is somehow initialized with a callback that determines the routing. That may be faster. But that would be a lot of work.

    Personally I don't intend to use mmbasic for anything other than display, logging and non-critical monitoring. The performance and safety critical parts I'll do in C.

    However, if someone else out there wants to give it a whirl my code is available in the MMBasic release and I'd be happy to answer a few questions.
     
  19. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    Today was another scorcher in Sydney Australia. My outside temperature reached 48 Deg.C (118.4 F) which for me is an all time record. I drove to work in OOG mode with the A/C running for 40 mins (A/C set at 25deg.C). See photo below. "IT1-??:16DEg.C" is B/S which has never changed and will be removed in the next update.

    P.S. The ICE never ran today and the ECT is 52 deg.C, if the ICE started it would skip warm up as it is already at 52 deg.C, wow!

    scorcher.jpg
     
    [email protected] and epa5epa like this.
  20. Flying White Dutchman

    Flying White Dutchman Senior Member

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

    And over here temp a well below freezing and lots of snow..

    Can not go without ice but thats ok , battery pack is out of car still anyway..

    -Tapatalk