Electronics > Projects, Designs, and Technical Stuff
CAN-bus msg validate, how?
Chriss:
Hi!
I'm planning to make a device or PC software which can listen to a CAN device like a car diagnostic tool or flasher tool also for cars
over CAN-bus.
The theory how the project should work is this:
- the diag/flasher tool sends starts to do the job ( accessing an ecu or sending data out to try to connect to an ecu... )
- the gadget I should make is listening on the CAN bus and identifying if any CAN msg is present on the CAN bus
- if a msg is detected a green LED will blink otherwise a red LDV will blink.
Actually, ,y gadget should validate if a valid CAN msg is present on the CAN network.
I never played with CAN network but I have a beginner level knowledge about CAN network.
I would use an Atmel 8bit uC with an UART and I have a CJMCU-230 CAN transceiver.
The Atmel uC should be connected to the Rx/Tx on the CJMCU-230 Tx/Rx and the CJMCU-230 CAN-H and CAN-L should be connected to the diag/flasher tool I assume.
Is this the basic schematic how all this should be set up?
If I understand correctly the use of the CJMCU-230 or any other CAN transreceiver, they are actually like the MAX 232 ic's or the FTDI ft232 ic's just for CAN-bus and not for USB to RS232, but RS232 to CAN...
If somebody could give me a direction with a schematic or some documents/info which are related to my task I would really
appreciate that.
I think this is a really basic task to start to playing with CAN-bus and I have all this tools already on my desk, so I assume I can
build for me a small CAN-playground for startup... :-DD
Thank you.
My best regards.
zzattack:
Ideally you use a microcontroller with built-in CAN peripheral and external transceiver. If your microcontroller lacks CAN you can use something like a MCP2515 instead, but that seems like needless effort.
Syntax Error:
For starters there is an Indestructable on this subject:
https://www.instructables.com/id/Yes-We-CAN-BUS-With-Arduino-in-30-Seconds/
Plus there is a good tutorial on interfacing the MCP2515 with an Arduino:
https://circuitdigest.com/microcontroller-projects/arduino-can-tutorial-interfacing-mcp2515-can-bus-module-with-arduino
Rerouter:
a large number of microcontrollers from every brand have built in CAN trancievers, go with one of these if you can, and pick one your compfortable with, e.g. there are arduino models that have CAN libraries.
This way the micro has built in hardware that rejects invalid messages (every message has a CRC) and can also filter only certain values if you want to reduce what your searching for
Now with the heavy lifting out of the way, its just up to sending it out to the PC, as the messages get queued to a FIFO in most of these micros, it would be not much more than a loop of code that checks if the FIFO has any contents, and then sends it via serial,
Speed wise, you would be using the serial buffer or similar, just so you dont have to wait for things to happen. normal canbus is up to 250 kbps (assuming your recovering the identifier) so you should plan your serial speeds to be close to that, equally modern vehicles can be 500Kbps, with some very new european cars starting to have 1mbps CAN
Chriss:
Thanks for the fast replay, I summarized what I have at the moment at home and how can I build something for start.
I have:
- vehicle diag and flashing tools with CAN-bus communication ( this would be my CAN transmitter )
- Atmel uC's Attiny2313, ATMEGA16 ( this could maybe be the receiver side or I put a PC as a receiver )
- the CJMCU-230 Bus Transceiver ( this would be my transreceiver between the uC or PC and diag/flasher tool )
Is it possible to build the connection between my transmitter and PC like this:
The PC RS232 port to the Rx/Tx line to the CJMCU-230 Bus Transceiver Tx/Rx line
The CAN-L/CAN-H line from the CJMCU-230 Bus Transceiver to the CAN-L/CAN-H on my diag/flasher tool
And now to write the software on the PC so the PC receives directly the CAN messages from the transmitter?
Will this concept of my idea about the hardware setup working on a primitive level of PC to CAN network interface?
I could also check with my logic analyzer the package from my transmitter so I could be sure does my PC software really works?
Earlier I made many projects interacting between PC and uC's through USB and RS232 and I'm familiar with that but CAN is
something new for me...
I'm trying to build up something from what I already have...
Navigation
[0] Message Index
[#] Next page
Go to full version