CANbus / OBDII plank?

I recently ordered a MCP2515 + TJA1050 and SN65HVD230 CANbus controller and transceiver, and have been looking at some projects using esp32.

A good introduction to CANbus

Differences between TJA1050 and SN65HVD230

The main difference between TJA1050 and SN65HVD230 is the operating voltage. TJA1050 operates in a 5V environment, while SN65HVD230 operates in a 3.3V environment.

Common considerations:

  • When routing the CAN signal lines on the PCB, use differential lines.
  • Termination resistors are generally only required at the starting and ending points of the CAN lines, not in the middle.
  • If it is necessary to filter and stabilize the common mode voltage of the bus, split termination resistors can also be used (as shown above, divided into two 60Ω resistors with a capacitor connected to ground in the middle).

Is this something that has been discussed before?

EDIT: i think the setup would be a plank connecting MCP2515 via SPI to the buspirate, and then either the TJA1050 or SN65HVD230.
Other than using a bluetooth OBD-II module to check fault codes on my car (which coincidentally i just had to use because my old crown vic has a misfire on cylinder 6), i am very new to learning about CAN.
Please forgive any ignorance.

But it is a very interesting protocol, and not only used in car ECU’s. controller area networks are used in industrial, aerospace, marine settings.

I know it uses differential signals on a twisted pair. Thats why you see 2 screw terminals on the transceiver modules.

A setup with a microcontroller may look something like:

Microcontroller to CAN Controller (e.g., MCP2515):

SPI connections (MISO, MOSI, SCK, CS)
Power (VCC and GND)
-->
CAN Controller to CAN Transceiver (e.g., TJA1050 or SN65HVD230):

TXD (Transmit Data) to TXD pin of the transceiver
RXD (Receive Data) to RXD pin of the transceiver
Power (VCC and GND)
-->
CAN Transceiver to CANbus:

CANH to CAN High line
CANL to CAN Low line
2 Likes

CAN with RP2040
CAN pio code for that lecture (no license, sigh)
Another project (GPL3)

Doing CAN fully in the RP2040 would make adapter boards dead simple. Not sure I want to bite off a project that complex though.

MCP2515 seems to be the ticket. It seems to have some easy to port driver libraries.

It looks like adafruit uses a MCP25625, which is a MCP2515 with integrated transceiver in their dev boards. From a glance at the datasheet I think this is a 5 volt transceiver.

CAN would be fun to learn. Years ago I built some CAN adapter stuff (LIN too?) for the old Bus Pirate, but there wasn’t enough code space to implement anything proper. More recently I messed with the Neoden4 which uses some oddball UART over CAN or something.

image
image

It looks like the transceivers are pin compatible, so maybe a single PCB design will work. I did not check the supporting circuit. (The “Not to scale” inspires a need to properly scale it).

It looks like MCP2515 + TJA1050 or SN65HVD230 is a good suggestion.

1 Like


one of the ones i got (and seems to be popular) has the CANbus controller and the transceiver in one.

esp32 has a can controller built in, but we would simply use the MCP2515 connected SPI to the BP?

Due to my lack of knowledge, Im trying to just ask myself “what gap would BP need to fill”

It seems pretty straightforward hardware wise, but something like esp32 has extensive libs already written to deal with CAN protocol. i think thats where our complexity comes in obviously… porting existing MCP25625 driver libraries?

2 Likes

Apparently heavy machinery uses a slightly different CAN protocol
SAEJ1939 - J1939 Explained - A Simple Intro [2023] – CSS Electronics

2 Likes

Ideally the bus pirate has a simple text interface to probe, listen, and send/receive packets. At the very least a platform for me personally to learn more about it :slight_smile:

I envision needing the drivers side arm rest from a car door to debug with :slight_smile:

1 Like

I invited a few colleagues to join this chat if they are interested. I think we could potentially benificial to this particular accessory (plank).

1 Like

I get what you mean by keeping it simple btw. I think you could technically just send data to the MCP2515 controller over SPI like we do with other stuff…, but, im pretty sure init sequences, setting configuration registers, sending CAN messages, and even receiving responses might be a little more complex. than just a couple of bytes.

nice datasheet yay

Im just talking off the top, but as you’ve probably realized a lot of people are interested in this. making the plank is the first step, but i definitely think we could have a basic canbus mode with some of those library functions ported over. and maybe even allow loading of DBC files someday DBC Introduction — Open Vehicles documentation

I need to get one of these simulators:

1 Like

When you find a decent one at a reasonable price, please share.

this is the one im looking at right now:
https://www.aliexpress.us/item/3256805440455960.html

The type 2 supports J1939 and is still <100$ . The more expensive ones have larger screens.

I think most cars use canbus 2.0A ? and J1939 is built on canbus 2.0B

The CAN 2.0 B specification can only transmit single-frame messages, while the J1939 protocol can transmit single- and multiple-frame messages, including dialogue and broadcast .
from: Understanding CAN Bus: A Comprehensive Guide

J1939 info.
The J1939 Protocol, Explained – CalAmp.

Long story short, i am still trying to understand the different protocols, but i know 2.0A , 2.0B, and J1939 (usually heavy machinery) are the most common
and j1939 is built on 2.0B

So it makes sense we get the one that supports J1939 for $15 more.
as far as a larger screen, i will probably opt to save 50$ and use the smaller screen.

I’ll wait to hear other peoples opinions before buying, but will def buy one once its closer to time to get prototype planks from ian

1 Like

I imagine that is were an app (command) or two come in. Some larger way to automate common bus stuff. Read profiles from the nand flash and such.

I’ll get a board sent out this week.

What should I test against? Do I need to get part of a car? I do have a car in the US but it’s from 1975…

I had insomnia a few weeks ago and I fell into a YouTube hole and the algorithm decided I needed to see car repair stuff. There is a Bluetooth (?) ODBC tool that works with a phone app that back alley British mechanics swear by…

So I tried to find that and spent an hour watching Adam savage, a skydiver almost kill a hot air balloon pilot, and then coffeezilla dissecting that rabbit thing. If I come across it again I’ll let you know.

SUPPORT J1939! 250 and 500 baud at absolute minimum or theres a lot less value.

Ok let me make a few important points, and again this is coming from someone who is just as new to canbus as anyone, but did do a little research before ordering some modules the other day.

1.) Being that the buspirate is a swiss army knife, and people may do things with canbus other than cars, we probably dont want to put the OBD2 port on the buspirate.

when I ordered by MCP2515 + TJA1050 , i also ordered one of these:
image


But heres the thing, you only have to connect 2 wires from the TJA1050 transceiver in a lot of cases, as seen in this setup:
image
but i think you use more wires for other protocols. IE more evidence we shouldnt have this built in.

we will probably want to interface the MCP or whatever with the buspirate, along with a transceiver, and you can just get some of these cables for cheap in china to send along with it.

2.) Im not hooking the buspirate up to my car to experiment! no friggin way. That’s why we are talking about getting a simulator like the thing i showed. this will allow us to simulate a car ECU and test without actually hooking up stuff to our vehicles before we know exactly what we are doing.

3.) i have one of those bluetooth things btw. they are super handy, but that + the app is doing what we want the buspirate to do (on a more basic level). may be good to RE tho.

im going to take one for the team and order the one i showed right now
type 2 on https://www.aliexpress.us/item/3256805440455960.html

EDIT: done. i should have it … someday

Ahhh, thank you for the clarification. I’ll get the same one or something similar. I believe this is it, but I’m curious of there’s something that supports multiple protocols.

if it was open source and you could change the pin arrangement of the OBB-II port i think it could be.

SOmething i just thought of. I will be using my cheapo bluetooth OBD-II thing to verify the simulator works, using the Torque Pro (lite) app.

Couldnt you hypothetically sniff what was going from the output pins of that? if you had a passthru/sidechannel like we are doing on RS232…

I assume you just tap into the receivers output (the normal 3.3 or 5 volt logic side).

1 Like

This is my main tool for CAN work.

I was able to finally acess one of a main archive repos that has a lot of CAN bus dev work from past projects. I will look through and see what refereces I can find.

I also have thousands of transceivers and other related components and tools for the job, but as long as you have can low and high (auto or selectable 250Kbps-1Mbps) and a way to measure and decode the signals, alot of the extras aren’t necessary. If you want to flash an ecu or tune, this takes different hardware.

1 Like


Image was found online and is for reference only. This is not my original work.

1 Like


Image was found online and is for reference only. This is not my original work.

1 Like

Totally not related. But I bought a Nissan XiaoKe (rouge? Sport? I don’t know the western branding) and I didn’t realize it didn’t come with cruise control! So I bought after market cruise control on TaoBao. Went to some literally back alley shop somewhere in North West shenzhen and an uncle installed it for me. Then he spent like three hours programming the ECU with a copy of the cruise control version.

It sketched me out so much I rarely used cruise control. I sold the car on an app after 1000km at a minor loss. :man_shrugging:

1 Like

I will make a longer post tomorrow, but hold off on getting the Type2 simulator i linked to(the ones with the smaller screens). I think this is an older board, and i am not impressed. I have messaged the seller on Aliexpress, but it seems like “supports J1939” means thats all it does. I am trying to find a manual.

Either way, i think i messed up by not spending the extra 40$ on the newer model.

2 Likes