CAN bus communication issues

General support questions and announcements for MS3. See also MS3 manuals.

Moderators: jsmcortina, muythaibxr

RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

CAN bus communication issues

Post by RyersonFSAE »

Hi all,

I am having trouble getting a Freescale KEA128 microcontroller board to communicate with the Megasquirt 3 PRO.

Not going to get into the fine details just yet as I will be writing an essay here but am just looking for some clues as of what I should try.

I have a CAN diagnostics tool, called PCAN, and it can send and receive anything on the CAN line, really handy tool.

In any case, the trouble I am having is communicating between the KEA128 and the MS3PRO.

I can successfully communicate (Transmit and Receive):

- PCAN & MS3PRO
- PCAN & KEA128

But I cannot get any communication between the KEA128 and the MS3PRO. As in, I send a request, but never get a reply from the MS3PRO. If I force a broadcast from the MS3PRO, I am able to receive on the KEA128.

**ALL messages i send from any device are the same. That means, it cannot be an issue with the structure of the message as I send the SAME thing from the PCAN as I am from the KEA128. But only the PCAN works.

Finally, time segments are set identical to that of the ECU and the baud rate is at 500kb/s.

Once again, I am just looking for hints at this point as my application is too specific to get direct help.

Thank you,

Phil.
racingmini_mtl
Super MS/Extra'er
Posts: 9128
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada
Contact:

Re: CAN bus communication issues

Post by racingmini_mtl »

Please elaborate on exactly what the message header and content are. There may some conflicts.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

Re: CAN bus communication issues

Post by RyersonFSAE »

Thanks for the quick reply.

Let me clarify what I am doing.

I am using the microcontroller and requesting frames from the MS3. I am sending a MSG_REQ for a variable in table 7 and set everything up according to the megasquirt CAN technical specifications. And sure enough, if I do this with my diagnostics tool (PCAN), I get a reply from the ECU.
racingmini_mtl
Super MS/Extra'er
Posts: 9128
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada
Contact:

Re: CAN bus communication issues

Post by racingmini_mtl »

Can you use your PCAN as a sniffer and connect all 3 devices to the bus and check the the MSG_REQ message is actually sent from your device and if there is a response from the MS3? From what you say, it sounds as if your device is not configured correctly for receiving the messages; check that you are not setting masks that will reject the MS3 messages.

If you can sniff the data, make sure that the format of your message is correct for all bits in the header and the data section. And if you need more help, you will also need to provide much more detail about what you're seeing and doing.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus communication issues

Post by jsmcortina »

This is a difficult area to diagnose through the forum, as Jean says please provide a lot more detail - including CAN trace snippets.

If you are trying to collect realtime data from the MS3-Pro, consider enabling the CAN broadcast feature instead and then just listen for the standard messages.
http://www.msextra.com/doc/pdf/Megasqui ... -10-27.pdf

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

Re: CAN bus communication issues

Post by RyersonFSAE »

Haha, From experience, if I post a wall of text, I usually get no replies, its discouraging to look at.

I completely agree that i need to provide a load more details, I was just looking at my last resorts for some "Common mistakes" that I may have missed before I start breaking down my program, especially because a lot of these things are specific to the MCU we are using.

I will put together a succinct message to make your life easier in understand what I have.

That broadcasting table document is invaluable to us, THANK YOU VERY MUCH! I thought that the broadcasting was limited to what was in the tunerstudio CAN pop up.

Furthermore, I heard that when using the broadcasting feature, the ECU uses the traditional CAN bus protocol?
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus communication issues

Post by jsmcortina »

You need to be using the 1.4 development firmware to utilise the full broadcasting feature. (It's a free update.) Yes the broadcasting uses regular 11bit headers and 500k speed also.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

Re: CAN bus communication issues

Post by RyersonFSAE »

Thanks for the replies.

If I do the broadcasting mode, external GPIO boards will no longer work since its the traditional CAN protocol, correct?

I was also planning to have a TinyIOX, if that won't work I may need to find alternatives...

Thanks,

Phil.
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus communication issues

Post by jsmcortina »

It depends what you are trying to do (you still haven't told us.) The 11bit and 29bit messages can co-exist on the bus.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
racingmini_mtl
Super MS/Extra'er
Posts: 9128
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada
Contact:

Re: CAN bus communication issues

Post by racingmini_mtl »

As James says, we need to have an idea of what you're going to do. The main issue with using the TinyIOx on top of having broadcast messages could be the amount of traffic on the CAN bus. But it might also be a non-issue.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

Re: CAN bus communication issues

Post by RyersonFSAE »

Yeah, let me clarify a bit what I'm trying to do.

I have a KEA128 MCU, that natively supports CAN communication. I'm attempting to build a steering wheel console with it, which will fetch certain variables from the ms3pro ECU, such as tps or clt, over CAN. I used the ms3 CAN technical specification page as well as the 1.3.3 source code to figure out how to build the required MSG_REQ message. I've managed to build a valid message, yet when I send it to the ECU, I get no response.

I know that the message is valid since if I send the exact same message using the PCAN, I actually get a valid response.

So to recap what is actually working:

MCU to PCAN:
The PCAN is able to receive what I am sending, and my MCU us able to receive from it. I know this through setting breakpoints in my program, and I have indicator LEDs that light up when I send or receive something.

ECU to PCAN:
If I send an MSG_REQ message from the PCAN, I get a valid response from the ECU. So everything works when I do this.

ECU to MCU:
The transmit LED lights up, so I am clearly transmitting, yet I never get a response. It's a proper message, yet there is no response.

I would also like to mention that I have tried hooking up the PCAN diagnostic tool in parallel with the MCU and ECU to see what is going on. I can see that the MCU is indeed sending a message, but there are no messages from the ECU being sent back. So what is going on?

Another thing: if I set the ECU in broadcast mode, I am able to receive the messages with the MCU. I even tried to turn on broadcasting mode AFTER the MCU has failed to communicate with the ECU and the MCU acknowledges the reception of the broadcast message (led turns on). So the devices can clearly talk with each other. I am just so confused, because everything should be working, yet it doesn't. I don't know what else to try.

I will put up some pictures as soon as I get to school on monday.
Last edited by RyersonFSAE on Sat Jan 24, 2015 9:27 pm, edited 1 time in total.
racingmini_mtl
Super MS/Extra'er
Posts: 9128
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada
Contact:

Re: CAN bus communication issues

Post by racingmini_mtl »

RyersonFSAE wrote:I would also like to mention that I have tried hooking up the PCAN diagnostic tool in parallel with the MCU and ECU to see what is going on. I can see that the ECU is indeed sending a message, but there are no messages from the ECU being sent back. So what is going on?
That is confusing. Do you mean that you see on the PCAN that the MS3 is sending something but your MCU doesn't see it? Or do you mean that there is nothing sent back?

My guess is what I mentioned before that your receive masks are not set correctly and the message is being dropped by the MCU lower CAN layer. Make sure that every bit in the header is exactly the same when the PCAN is sending a message as it is when coming from the MS3.

Again more detail is needed especially an actual CAN trace.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

Re: CAN bus communication issues

Post by RyersonFSAE »

racingmini_mtl wrote:
RyersonFSAE wrote:I would also like to mention that I have tried hooking up the PCAN diagnostic tool in parallel with the MCU and ECU to see what is going on. I can see that the ECU is indeed sending a message, but there are no messages from the ECU being sent back. So what is going on?
That is confusing. Do you mean that you see on the PCAN that the MS3 is sending something but your MCU doesn't see it? Or do you mean that there is nothing sent back?

My guess is what I mentioned before that your receive masks are not set correctly and the message is being dropped by the MCU lower CAN layer. Make sure that every bit in the header is exactly the same when the PCAN is sending a message as it is when coming from the MS3.

Again more detail is needed especially an actual CAN trace.

Jean
My bad: (I should stop posting from my phone :P)

"I can see that the MCU is indeed sending a message, but there are no messages from the ECU being sent back."

I will see what I can get from the PCAN right now to show you but I don't have access to the ECU until monday.

I appreciate your help. And response time!
racingmini_mtl
Super MS/Extra'er
Posts: 9128
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada
Contact:

Re: CAN bus communication issues

Post by racingmini_mtl »

This page shows the header content and the data content: http://www.msextra.com/doc/ms3/can_tech.html. Can you tell us exactly what you have for each register and what each field should be. That would be for the message you're sending from your MCU. You must have some bits missing or wrongly set and that means the MS3 rejects the request.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

Re: CAN bus communication issues

Post by RyersonFSAE »

racingmini_mtl wrote:This page shows the header content and the data content: http://www.msextra.com/doc/ms3/can_tech.html. Can you tell us exactly what you have for each register and what each field should be. That would be for the message you're sending from your MCU. You must have some bits missing or wrongly set and that means the MS3 rejects the request.

Jean
I will update you on monday on the specifics, as I don't have access to the ECU.

However, do you think there is a reason why the PCAN has no trouble of sending a request and receiving a response from the ECU? Keep in mind it is sending an identical frame as was from the MCU.
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus communication issues

Post by jsmcortina »

As Jean says, you aren't giving us information to be able to answer.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

Re: CAN bus communication issues

Post by RyersonFSAE »

Here is a trace file:
PCAN MCU comm..png
Just to clarify our situation:
10946021_10152996501535535_947910887_o.jpg
Since we are sending the SAME request from MCU and PCAN, we should get the same results. PCAN is the only one that receives the reply.
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus communication issues

Post by jsmcortina »

Perhaps a bit-timing or termination issue on your MCU? This sounds quite low-level.

Have you scoped the CANH and CANL lines to see what is different when the two devices are sending?

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
RyersonFSAE
MS/Extra Newbie
Posts: 18
Joined: Tue May 13, 2014 9:11 pm

Re: CAN bus communication issues

Post by RyersonFSAE »

jsmcortina wrote:Perhaps a bit-timing or termination issue on your MCU? This sounds quite low-level.

Have you scoped the CANH and CANL lines to see what is different when the two devices are sending?

James
That is a great idea, i will test it on a scope.

Do you have the MS3 timing parameters, If not where can I find them to make sure I got them right? As in Time segments (time quanta), phase Segment 1(should be 2), phase Segment 2(Should be 13), etc. Just want a sanity check...

The MCU has 2 time segment fields within the timing register and a Synchronization Jump Width register, which sets the allowable time quanta variation for resynchronization.
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus communication issues

Post by jsmcortina »

This is what the current pre-1.4 MS3 code has

Code: Select all

CAN0CTL1 = 0xc0; /* BUSCLK (50MHz) */
CAN0BTR0 = 0xc4; /* SJW=4, prescaler = 5 */
CAN0BTR1 = 0x5c; /* Segment2 = 6, Segment1 = 13 */
That's a change from the original numbers as they appeared to be disallowed according to the datasheet.

Code: Select all

    /* Set Can enable, use Oscclk (8 MHz),clear rest */
    CAN0CTL1 = 0x80;
    CAN0BTR0 = 0xC0;            /* SJW=4,BR Prescaler= 1(8MHz CAN0 clk) */
    CAN0BTR1 = 0x1C;            /* Set time quanta: tseg2 =2,tseg1=13 
                                   (16 Tq total including sync seg (=1)) */
Changing them didn't appear to make any difference to comms.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
Post Reply