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

"De"-nginer

Discussion in 'Gen 2 Prius Technical Discussion' started by Bruce Meacham, Jul 3, 2012.

?
  1. Sure, why not

    87.5%
  2. You are high

    0 vote(s)
    0.0%
  3. Did you think about...

    12.5%
  1. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    That was interesting - one of the things I lack is much experience with normal Prius operation. I bought a high-mileage car and jumped straight into things. I think I've fixed the battery pack - but at the moment I have no real way of knowing how well my car is performing in normal operation.
     
  2. 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'm going to be out for a few days, back on Sunday.

    I just posted a PHEVCU.BAS, which if possible, I'd like to help become the primary source file for the code.

    Just to do something, I took CANVIEW.BAS and filtered anything not 0x348. Feel free to blast away on this.

    I can't wait to see where this is going next!
     
  3. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    So, I finally got around to looking at the eMega documentation and board layout and guess what? The eMega gets the prize for "most creative CAN plug"

    They've actually wired can lo & gnd to a 3.5mm stereo jack. Hey, it's actually a nice compact solution and easy to "hack" a cable - I mean I'm sure my son won't miss his ear buds... (just kidding, but I do have a load of cheap ear buds that have somehow collected in one of my junk draws).

    BTW, where did you find the CAN basic documentation? I can't find a link to that doc on their website. I'm curious what other "goodies" they're "hiding" from us :)

    My lilliput should come this weekend and I think a good display will help me learn about Prius operation. I might try and recreate the display that nortTex posted (the HSI display). I'll be sure to share the source code of anything I do.
     
  4. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Here's what I was referring to (snipped from the user's manual):

    4.2. PINGUINO IDE
    The Pinguino Project is a complete integrated IDE and C compiler. It works with the boot-loader so
    there is no need for programmers etc. when you program using the Pinguino IDE. The project page is at
    Pinguino, open source hardware electronics prototyping platform based on 8- and 32-bit PIC from Microchip.
    Pinguino implements the ARDUINO like language which is generally C++ libraries to allow easy
    programming of the hardware.
    The DuinoMite boards are based on our PIC32-PINGUINO-OTG project hardware and evolved from
    there, so they can use the existing Pinguino programming environment, the only difference is that a
    different boot-loader should be programmed into the DuinoMite to support Pinguino IDE.
    The Pinguino IDE allows you to program the DuinoMite in ARDUINO language or pure C/C++ and
    load the code with a single mouse click.​

    I haven't actually downloaded or programmed anything for my board yet though...
     
    dave77 likes this.
  5. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    I dug up the thread for that HSI display, and sure enough the author, alexmol, has made it open-source. So, my first DuinoMite project is going to be porting this and converting it to MMBasic and using VGA (along with the help of Google Translate ;) )

    Here's my post on the original HSI thread: HSI for Gen II with Arduino and CAN-BUS Shield | Page 2 | PriusChat
     
  6. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Bruce - it's not letting me push to your Git repository... (I just fixed the name of my project :) )
     
  7. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    I cannot quite figure out how Github works. Need some time to learn how to use it. So for the time being I will just attach my latest Canview.bas for a 7" LCD screen.
     

    Attached Files:

  8. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Hi Lopez,

    Yeah it can take a little while to get your head around Git and distributed version control! Github has some good tutorials though.

    I just had a quick peek at your code - congrats on starting to expand it. I have a couple of suggestions. I realize that you may already have been thinking of these updates - so I hope you don't mind if I've jumped the gun:

    1) Both you and Bruce are using HEX$(rxId) and then comparing to a string. It would be more efficient to do a straight numeric comparison. Instead of this:
    Code:
    450 IF HEX$(rxId) = "348" THEN GOTO 470
    this
    Code:
    450 IF rxId = H348 THEN GOTO 470
    In the first version you're converting rxId to a string with the HEX$() function and then you're comparing it to the string "348". In the second version you're comparing rxId to the hex number 348. In the second version not only are you not calling any functions but you're comparing numbers not strings which is far more efficient.

    2) A classic goal in programming is to keep things DRY. Where DRY stands for Don't Repeat Yourself. I'm not sure if there's a concept of a code block in MMBasic or of passing parameters? If so then you could skinny down the code (it won't be any more efficient but will just be neater and easier to maintain) by doing something like this
    Code:
    445 x = 20
    450 IF rxID = H348 THEN y = 60 : GOSUB 2000
    460 IF rxID = H3C8 THEN y = 80 : GOSUB 2000
    etc.
     
    2000 LOCATE x, y
    2010 PRINT id$;len$;d0$;d1$;d2$;d3$;d4$;d5$;d6$;d7$
    2020 RETURN
     
    
    p.s. I'm not sure if the above will work because I don't know exactly how the IF statement works in conjunction with many instructions on one line (the : is the instruction separator). When I start writing some MMBasic I'll find out for sure...

    Again, kudos to you for adding and sharing. These are just some tips and I figure suggesting them early might help as we all move forward. Efficiency (the first suggestion) will be key as we try and ensure that the BASIC interpreter can keep up and the second suggestion will help as the programs begin to grow bigger...

    All the best! JH.
     
  9. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    I am thinking of using the RUN [file$] command within each program to navigate between pages (or .BAS files) stored on b: (micro SD memory card). This way you can link many files together and navigate between them using the inkey$. Each time RUN [files] is used in a program it clears the current program and loads the new one. Also use the AUTORUN.BAS which is automatically loaded and run on every startup. This way you never have to type the RUN command to start the PHEV. This is my idea of structured programming and keeping a: flash memory use to a minimum and PHEV ECU at optimum speed.
     
  10. 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
    Man, i cant believe were doing this in old school basic
     
  11. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    I know it's cool isn't it :) I first started programming on a ZX-81 in 1981... A friend found one who knows where and gave it to me the other day. I'll have to turn him on to the DuinoMite (and MaxiMite).
     
  12. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Bummer - I can't get my DuinoMite eMega to receive (or send) CAN messages :cry:

    My Atmel dev board still works so I know it's not the cable. I've also checked for continuity between the CANH & CANL signals on the DMeM and the cable. So I don't think it's the wiring.

    J-lo - how are you hooking yours up? Are you going into the Data Link Connector under the dash? Did you have to solder in a termination resistor?
     
  13. lopezjm2001

    lopezjm2001 Senior Member

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

    I am using a OBD2 plug which plugs into the data connector under the dash.

    I have a existing ObD2 plug to DB9 female adapter which came with a ELM327 device which I no longer use. The adapter cable has a bridge between the signal ground pin and the chassi ground pin inside the ObD2 plug which might be needed. I soldered three wires to a DB9 male plug and wired it to my Duinomite Mega CANbus port terminal block/plug. The CanH, CanL and signal ground are a direct connection. No need for a resistor. However you do need a specific DMbasic driver for CAN commands - 2012-04-12-DMBasic-CAN_hex. it has to be downloaded using HIDbootloader.exe. http://www.kenseglerdesigns.com/cms/forums/download/file.php?id=74&sid=c9b8535c77862bf9094040758a89060e

    I also soldered two wires 12v supply to a power jack female plug from the DB9 male plug. It is 12v permanent.

    I have ordered a OBD2 splitter - one male OBd2 plug to two DB9 female plugs. This will allow me to use my Canview V4 at the same time as my Duinomite Canview. This will help to unlock some of the secrets of the Canview V4.

    Good luck.
     
  14. 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
    Some git basics... I think we're all used to traditional source control; svn, tfs, csv.. git isn't exactly like them. It's a little different, because it wasn't designed to organize a team. It was built for crowds to losely colaboriate on the same repository.

    If you don't like reading blah blah, here's a video training course.

    It works on forking and pulling. I started the public source repository, if you like my thread, you can create your own branch and either use it or make changes. You can commit your changes to your own branch and others can see those as well.

    Now let's say you think something you've commit is worth bringing back into my main branch, then you send me a "pull request" and I will review your changes. If I like them, I will merge them into the main branch. I can tell you now I will almost always take most reasonable pull requests.

    So let's say I don't have much to add or I'm not being responsive withpull requests... then naturally, you all can start making pull requests to other branches and that will become the "authoritative" branch.

    I think this is great way for us to share our learnings and collaborate. Good luck and let's keep at it.
     
  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
    Bummer on the eMega! Sounds like you can still run space invaders though, so not a total loss.

    I want to encourage you to make an Atmel folder in the repo, I'll take the pull request. That Atmel board still looks like a solid contender. Price isn't off the charts and professional tooling is a critical factor.
     
  16. jdh2550

    jdh2550 Co-Founder, Current Motor Company

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


    In your prior firmware did the BASIC interpreter just say "unknown command" (or similar) for the CAN commands? If so then I think I probably already have the right version on my board because the commands are recognized - they just don't work.

    Oh and I confirmed that I have an electrical connection all the way between car and board because when I unplugged the CAN connection from the board I immediately got an error reported on the vehicle CAN bus. Oops. I guess this is the disadvantage of having the signals coming in on a stereo jack - it persuaded me that this is hot pluggable. Things are in fact hot pluggable into CAN - but not if you confuse things by incorrectly connecting signals along the way (which is what happens when you slide a stereo plug in or our of it's jack).

    I'll try various combos of vehicle ground and signal ground connections and see if that helps. BTW - For the Atmel board I'm only connecting the hi/lo lines not vehicle or signal ground.

    Where does you power come from? The OBD port, or a cigarette lighter socket, or? Currently I'm powering my board from the lighter socket which isn't permanent.
     
  17. jdh2550

    jdh2550 Co-Founder, Current Motor Company

    Joined:
    Nov 16, 2010
    317
    249
    0
    Location:
    Ann Arbor
    Vehicle:
    2005 Prius
    Model:
    N/A
    Err, yeah - and PacMan too! I was thinking of implementing Lunar Lander (a personal retro fave) or how about Asteroids? (easily distracted? who, me??? ;) ).

    I'm waiting to get a login for the forum - when I have that I'll ask about the issue. I may also just go get a DuinoMite Mega. I wish I'd just done that in the first place. (easily sold on extra features I won't use? who, me???).

    Ah, yeah, I forgot about that whole "it's so easy to branch" thingy... I'm a git newbie and mostly just using it like any other VCS.

    However, before I do, I have to think about how I want to share. No question that I want to share with you and the others here. The question is longer term. What if we do create something that then someone turns around makes a single line change, calls their own and sells commercially? Maybe the answer is "that's fine". Did you read the stuff on GeoffG's MaxiMite site? I'm not too worried about this - but I'm also wondering about some form of "free for non-commercial use" license. I do not know - probably just over-thinking the whole darn thing (over-thinking? wh0, me???)
     
  18. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    My 12v power comes from the OBD2 port which is permanent.
     
  19. 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 slapped the GPLv3 license on it, that's basically what you said.
     
    jdh2550 likes this.
  20. lopezjm2001

    lopezjm2001 Senior Member

    Joined:
    Apr 14, 2009
    1,146
    407
    5
    Location:
    Sydney Australia
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    Correction......
    Code:
    445 x = 20
    450 IF rxID = &H348 THEN y = 60 : GOSUB 2000
    460 IF rxID = &H3C8 THEN y = 80 : GOSUB 2000
    
    DMbasic does not recognize H348 as it would with other basic. It is &H for hex, &O for Octal and &B for binary otherwise it is decimal. DMbasic sees H348 as a variable (not a hex number).
     
    jdh2550 likes this.