Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to detect the start and end of a CAN frame?

Status
Not open for further replies.

frdm90

Member level 1
Joined
Jul 21, 2017
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
255
How to detect start and end of CAN frame?

Hello, I have a (probably easy) problem. I have two CAN transivers TR1 and TR2 and I need a logic whics detect a start and end of CAN frame - I mean, when e.g TX1 starts sending, the RX2 recives, TX2 sending frame to RX1, and RX1 is blocked as long as end of rame will be detect. And vice verca. Any ideas? Flip flops, or something?

Regards
 

Re: How to detect start and end of CAN frame?

I believe CAN uses a specific byte to indicate the start and end of a frame. Detect two of those in a row, and that's the start.
 

Re: How to detect start and end of CAN frame?

But if frames are transive with delay, they will be not detected.
 

Re: How to detect start and end of CAN frame?

But if frames are transive with delay, they will be not detected.

I don't know that that means.

- - - Updated - - -

No, I was wrong. CAN does not use specific start/stop byte values. I was confusing this with a different system I had worked on that was CAN-like.
 

Re: How to detect start and end of CAN frame?

Hi,

Did you look at wikipedia? https://en.wikipedia.org/wiki/CAN_bus

there is an SOF = 1 x "0"
and there is an EOF = 7 x "1"
and ther is an inter frame space = 3 x "1"

Klaus
 

Re: How to detect start and end of CAN frame?

Hi,

Did you look at wikipedia? https://en.wikipedia.org/wiki/CAN_bus

there is an SOF = 1 x "0"
and there is an EOF = 7 x "1"
and ther is an inter frame space = 3 x "1"

Klaus
The problem is, how do you know whether a "0" is the SOF, or a bit in the middle of the message? You have to know that there is no active message. And if you know that, then you know the answer to the OP's originally question. I think.

On further review, I'm not really sure what the OP wants. It SOUNDS like they want some hardware to detect the frames, without any software. That sounds nearly impossible. I think OP needs to explain this better.
 

Re: How to detect start and end of CAN frame?

Hi,

To me it looks like:
[frameSync]
Wait for (at least) 11 x "1" at the end of the frame...
Then wait for a "0" as start bit.
Then sample the complete frame
then check if CRC is correct
--> If NO, then re-start with frameSync
--> If YES, then the received Frame should be valid.

Klaus
 

Re: How to detect start and end of CAN frame?

EOF and IFS are used to detect bus idle, there is no other time when the bus is in a recessive state for that long when a frame is being transferred due to bit stuffing. Start of frame is signified by a dominant bit being sent. If two CAN transmitters start at about the same time they will both output a dominant sync bit and then start sending their message IDs, the message id with the smallest value wins arbitration, so the transmitter who loses has to go off bus. and wait until the next EOF IFS period and try again.

And to further answer you question both receivers need to always monitor the bus (even when transmitting) to detect that the bits sent are not being dominated by another transmitter. So the logic needs to monitor what you transmit and compare to what you receive, so if your transmit outputs a recessive bit and you receive a dominant bit you go off bus during the arbitration phase.

You really need to get the spec from Bosch if you want to design a CAN system, the wiki page isn't enough.
 

Re: How to detect start and end of CAN frame?

tran.png

Well, iI neet to eliminate the echo between transceiver A and transceiver B. When tx1 broadcast to rx2, the rx1 is 'blocked'. RX receives this frame when tx1 stops brodcast.
 

Re: How to detect start and end of CAN frame?

Hi,

Well, iI neet to eliminate the echo between transceiver A and transceiver B. When tx1 broadcast to rx2, the rx1 is 'blocked'. RX receives this frame when tx1 stops brodcast.

Afaik: CAN bus is half duplex. It doesn´t have independent Tx and Rx paths.
You need the "echo" for bus arbitration ... like ads-ee explained.

I´m not very experienced in CAN...
If you want to work with CAN, then I recommend to read CAN bus specificaton first. Urgently.

Klaus
 

Re: How to detect start and end of CAN frame?

Hi,

Afaik: CAN bus is half duplex. It doesn´t have independent Tx and Rx paths.

Klaus

Yes, but I mean tx and rx signals at CAN transceivers, e.g. TJA1042 - > there are rx and tx signals.
 

Re: How to detect start and end of CAN frame?

Hi,

Again: Read specification!

I only can repeat:
For sure the transceiver has Rx and Tx at the microcontroller side. And you need both - at the same time - for collision detect / arbitration. You must not eliminate the "echo".

The CAN bus is half duplex.

Klaus
 

Re: How to detect start and end of CAN frame?

Well, I have read about CAN something more. So it is my idea, could You help me with that? I would like to connect TJA1055 and TJA1042. when TJA1055 is transmiting data with any speed (from 50kBs to 1 MBs). So if CAN is half-duplex, its mean then when TX1 is transmiting, RX1 is in iddle state, yes? When TX1 is transmiting to RX2, (red line), then TX2 is not transmiting to RX1 (blue line).
So there is no logic needed to properly work?

Regards
 

Re: How to detect start and end of CAN frame?

Hi,

So if CAN is half-duplex, its mean then when TX1 is transmiting, RX1 is in iddle state, yes?
No.

1) Please show the source of information where it is said that TJA1055 (or any other CAN transceiver) will switch RXD to idle during transmitting?

2) Show how you can do bus arbitration when RXD is idle during transmitting.

Klaus
 

Re: How to detect start and end of CAN frame?

Your picture in post #9 doesn't correctly show the connection of a CAN bus.

This is how a CAN bus is implemented...
Capture.PNG
Notice the TXD and RXD are NOT connected together between transceiver devices. The bus is connected using the CANL and CANH signals.

I don't think you've read and understood the datasheet for the PHY device if you plan on hooking up the TXD and RXD like you've shown. The TXD and RXD are the side that interfaces to some other device (usually a microcontroller) and is not part of the CAN bus it is the user interface to communicate with the PHY device. The CANL and CANH are the signals that make up the CAN bus.

Anything sent on the TXD line will show up on the RXD line of a PHY with some delay and may have a recessive or dominant bit returned depending on the bit arbitration. e.g. if device 1 TXD1 sends a recessive bit but the RXD1 has a dominant bit then the arbitration of that bit is lost and the device 1 should go off bus.

Because of the monitoring of the received data from the most distant device connected to CANL/CANH there are requirements for the delay/distance between PHY devices that must be met to meet the CAN spec. CAN can be (and is regularly) run at less than the 1 Mbps rate.
 

Re: How to detect start and end of CAN frame?

Thanks for explanation @ads-ee. Well, maybe I has not exactly say what I need. I need connect two transceivers, beacuse one is sending with low speed, and second is transmiting the same frame but with high speed. I was thinking about connection not directly, but a some logic between them (uC is probably the best option), to buffer this frame, and send it with high speed.

MXRecord.png
 
Last edited by a moderator:

Re: How to detect start and end of CAN frame?

Mixing the two (CAN and CAN-FD) isn't possible on the same bus unless you add something to intercept the CAN-FD frame from reaching the CAN devices.

You might want to look at this white paper on the subject.
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0ahUKEwjNqJHv55TcAhVIGDQIHQNsAcUQFggvMAE&url=https%3A%2F%2Fcan-newsletter.org%2Fuploads%2Fmedia%2Fraw%2F35a48f1d88ddf2a198638c0a5be51761.pdf&usg=AOvVaw1b9SpJYWNary4x2kN3kKXo
and/or this one.
https://www.can-cia.org/fileadmin/resources/documents/proceedings/2013_monroe.pdf
 

Re: How to detect start and end of CAN frame?

Thanks, but i need only mixed CANH with CANL, it is not the same what mixed CAN and CAN-FD, is not?
 

Re: How to detect start and end of CAN frame?

Thanks, but i need only mixed CANH with CANL, it is not the same what mixed CAN and CAN-FD, is not?
There is no such thing as mixed CANH and CANL this post makes no sense whatsoever.

Apparently you're using edaboard to learn about CAN and haven't made any effort to read the spec or read any of the online tutorials.
 

Re: How to detect start and end of CAN frame?

Hehe, yes i had to read about CAN :p. I nearly understood, but i dont know yet, what will be if we cross CANH wit CANL (CAN FD blanking transceiver). How it can works?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top