marcellatwin
Posts: 17
Joined: Sat Jan 27, 2018 6:41 pm

Honda CAN bus Pi Project

Fri Aug 10, 2018 5:27 pm

Hello everyone. I'm fairly new to the Raspberry Pi, my first small electronics project. I'm also an engineering student. This project is mostly centered around Canbus. And hopefully putting my project up here will help others and help me when I hit a road block.

So first a quick overview of my project. To help get experience for fun and also to help with a future job, I'm doing this project. I have a RaspberryPi 3 with a PiCan2 board hooked up to my 2015 Honda Civic Si thru the OBDII port to access the Fast Can. Eventually I'll get the PiCanDuo board to access both the Fast Can and the Body Can, but that's later. I want to access some things like when Vtec is on, RPM is in a certain range, load of the engine is above a certain amount, etc. I want to then run my own program that will actuate an exhaust cutout. So when "vtec just kicked in yo" lol the exhaust will become a straight thru exhaust, but only during high load, high rpm situations. There's a product out there that already does this. I think it's called Vtec Climax but it's several hundred dollars and I want to do it myself, as I'm sure you all can understand.

So here is the progress I've made. I got a Pi 3 and the PiCan2 board hooked up. I'm waiting on a Mini Black Hat Hack3r to split the GPIOs so I can use the unused ones on a breadboard for prototyping (additional switches I have planned, LEDs for when the system is working, etc.). I setup the Pi and finally connected it to the internet to update it. To give context to why that last part was difficult for me, I'm running the Pi entirely thru command line issues from my Macbook connected thru an ethernet cable. The reason is because that how this project will run, without a screen or keyboard. Once the project is done, it will sit inside the car and operate all by itself, only needing to connect to my laptop for occasional update. At least this is my hope, lol. So after that I found out the PiCan2 board has an LED circuit. I downloaded wiringPi's code for GPIO use and got the LED to work via command lines. I then wrote a program that did the same thing, turn on and off the LED. Some of this may seem simple to you, but it is my first time doing something like this and is huge steps for me. But trying to mimic what I've learning in school and my internship of taking a big software project and breaking it down to little projects.

The stage I'm at is now the Canbus part. I am using the linux-can-utils software (from Volkswagen I think, haha). I have started to decode some of the Can packets, but it is difficult. The problem I have right now is with the cansniffer.c program. I noticed several other characters after the 8 bits of each can packet. Sometimes they are just "........" sometimes they change rapidly and with no perceivable pattern. What is this data???? or is it just garbage to be ignored???? Does anybody know?

Thanks for all your help in advanced. I hope this project is of interest to some people.
Last edited by marcellatwin on Sun Aug 26, 2018 6:11 pm, edited 1 time in total.

marcellatwin
Posts: 17
Joined: Sat Jan 27, 2018 6:41 pm

Re: Honda CAN bus Pi Project

Wed Aug 15, 2018 4:53 am

Hello again. So there's been some updates. First I answered the question from my last post about the random characters after the CanBus data. I emailed Craig Smith, a "CanBus hacker" who has a YouTube channel and a book about CanBus hacking where I learned how to use the cansniffer program a little bit more. He replied that it was ASCII data and not really of much use unless you are looking for a VIN or something.

So with his advice and other research I've done 2 decoding sessions with my car. One just sitting in the garage by myself trying to figure the program out. Key thing was I wasn't moving. The other was about 2 hours on the highway with someone else driving. This helped a lot as I could say, "go to 5th, now floor it, now 6th, left off the throttle, clutch in, clutch out, etc." We could only do some much with traffic. The plan is the do another session at night or early morning on Saturday where there won't be any traffic on desolate county roads. But I'm also going to try to find if there is anybody that has already decoded my particular car's CanBus, cause this might take a while to decode everything I need.

In the mean time, I've combed thru the candump and cansniffer programs to try to write my own program to take each Can data packet and try to at least display what I've decoded so far, like throttle position and speed. I'll post that code later once I've added a little more structure to it.

If anyone has suggustions as to decoding or know where CanBus data has already been decoded please let me know.

Below is the data I've decoded so far.
Screen Shot 2018-08-14 at 21.44.28.png
Screen Shot 2018-08-14 at 21.44.28.png (217.43 KiB) Viewed 512 times
Last edited by marcellatwin on Sun Aug 26, 2018 6:11 pm, edited 1 time in total.

marcellatwin
Posts: 17
Joined: Sat Jan 27, 2018 6:41 pm

Re: Honda CAN bus Pi Project

Wed Aug 15, 2018 7:30 pm

For those of you who are car people, this is my motivation:

https://www.youtube.com/watch?v=cMGyUm-4v8E

That video was the review of the Vtec Climax that I'm replicating with some differences. As stated before, this item is too expensive (over $350) and I want the experience of coding and building this myself.

I've fine tune the code for the displaying of certain canbus data (translated) onto the terminal, like my own primitive dashboard. But I still can't figure out how to get the address off the socket for the canbus data coming in. Anybody have any ideas?

Here is the forum post on that specific issue: viewtopic.php?f=91&t=220451&p=1352963#p1352963

Soon I should get my switches and Mini Black Hat Hack3r so I can split the GPIOs and have a prototyping breadboard AND PiCan2 board hooked up at the same time. They are shipping from England to the USA so it might take a few more days (shipped a week ago). Pictures will definitely follow.
Last edited by marcellatwin on Sun Aug 26, 2018 6:11 pm, edited 1 time in total.

marcellatwin
Posts: 17
Joined: Sat Jan 27, 2018 6:41 pm

Re: Honda CAN bus Pi Project

Thu Aug 16, 2018 4:27 pm

It finally arrived! The Mini Black Hat Hack3r. Now I can finally connect the breadboard AND the PiCan2 board to the same GPIO on the Pi. Here is some pics showing my new set up:
39294986_1665401383588389_2110536913390665728_n.jpg
39294986_1665401383588389_2110536913390665728_n.jpg (236.29 KiB) Viewed 448 times
This is the whole setup. It went from being just 2 boards screwed together, nice and compact, but now... This will be interesting to test with in a moving car haha.
39248909_243361189839962_8584667969957658624_n.jpg
39248909_243361189839962_8584667969957658624_n.jpg (185.84 KiB) Viewed 448 times
This is the PiCan2 board on top of the Black Hat. The holes didn't line up so I could only put in the screws right over the pin connections to keep them in. I'll need to figure something out for when it goes in the car more permanently.
39287205_465000094000187_3433186334305419264_n.jpg
39287205_465000094000187_3433186334305419264_n.jpg (247.45 KiB) Viewed 448 times
This is the breadboard and the 3 LEDs I'm testing that will eventually go in the car. Yellow for powered on but not ready. Essentially the Pi's boot up time and initialization of my program. Green for system active, program running correctly. Red for exhaust active, cutout valve open. Yes I know it is not the prettiest breadboard set up, but I'm new to this and I only have 10k resistors or 220, so I had to stack them. But the good thing is I was able to turn on and off all the LEDs on the first try, which is a victory for me, lol.
Last edited by marcellatwin on Sun Aug 26, 2018 6:11 pm, edited 1 time in total.

marcellatwin
Posts: 17
Joined: Sat Jan 27, 2018 6:41 pm

Re: Honda CAN bus Pi Project

Sun Aug 26, 2018 6:10 pm

So for an update. I finally got my own program to connect to the CAN bus and started reading in just the CAN IDs that I know, convert them to decimals by combining the bytes together, scale them to numbers we understand, and output them to the screen to see if I decoded them correctly. For the most part it is working. I'm having some issues with my "dash" program (cause it is like my own dashboard) flickering as it is running in a while loop. I'm working on trying to figure out the "curses" library to see if that can help me by printing out the stuff that doesn't change first (like "Throttle: ", "RPM: ") and only refresh the numbers from the CAN packets. I'll let you know once that is working and show the code.

As for the CANs I decoded. Most of them were not spot on. The throttle was a completely different scaling than I thought. When at FULL throttle, the bytes read FF CB. So that is 65,483 and if that is 100% throttle, I divide by 654 or 655 to get 100. But when we tested it, FULL throttle only read out as 74ish. Only once I changed the scaling to 492 did I get FULL throttle to read 100. Weird and will require further looking into. RPMs is another story. I think I had the wrong bytes, but once I decided to try different bytes and it suddenly worked, without scaling. Again have to look into. Same thing with speed. I might not be shifting the byte right when combining them, but as of right now, I do have Throttle, RPMs, and Speedo read out, all working. I've decoded a lot more since last time: water/oil temp (not sure which one is which), fuel mileage (MPG), fuel tank level, etc. I'll post those IDs once I verify them again on another driving session. With school starting tomorrow it might be a while before the next update, but the first weeks of school are usually pretty laxed so I'll try to keep on it.

marcellatwin
Posts: 17
Joined: Sat Jan 27, 2018 6:41 pm

Re: Honda CAN bus Pi Project

Fri Aug 31, 2018 3:31 pm

Another update. Made a ton of progress, at least in my opinion. I finally got rid of the flickering issue. I really researched the curses.h library and found what I needed. Now the program displays more than twice the data and doesn't flickers a smidge. I've also found what was wrong with my scaling. Really studpid mistake. I was referencing the CAN packet's data array with (1-8) rather than (0-7). Idiot mistake lol. So I was looking at the byte to the right of EVERYTHING. Once I fixed that it the data looked a lot cleaner and scaling made sense. I've also decoded a lot more. Things like the AC compressor, turn signals, seat belt, etc. Here is everything I've decoded so far and some of the questions that are still unanswered.
Capture.JPG
Capture.JPG (226.22 KiB) Viewed 340 times
Capture2.JPG
Capture2.JPG (150.25 KiB) Viewed 339 times
Vtec is one of the last CAN IDs I need to start making the mechanical part of this project.

Return to “Other projects”