• 0
david.600

Using Canbus on the Zynq 7000 board

Question

Hello,

I have the Zynq 7000 board (Z-7010).

I'm trying to build a Vhdl Program that receives a Canbus Frame.

I saw in the tutorial that There is a builtin Canbus Controller, where is the canbus Interface?should i use the standard interface?

Is there a simple example of such a program?  - I use the 2017.1 Vivado and the Z-7010 Board.

Thanks.

Share this post


Link to post
Share on other sites

23 answers to this question

Recommended Posts

  • 1

Hi @david.600,

CAN communication can be reached using the Zynq processor through the emio pins on the board. Due to the way CAN works as described here you would need an external board to facilitate it since all of the i/o is 3v3. I have attached an Image of the Zynq processor for reference. We have a PmodCAN here that will facilitate CAN communication to other devices. This would be the way to go as long as your goal is working with CAN devices and not trying to make a CAN controller. 

cheers,

Jon

 

zynq.jpg

Share this post


Link to post
Share on other sites
  • 1

@david.600

There are two Xilinx documents describing ARM implememtation of CAN interface controller: UG585 and PG096. CAN protocol is much more elaborate than RS232 or RS485 and I am not sure that starting oroginal development of CAN controller has reasonable justification.

PmodCAN is an option but it will duplicate functionality of the existing controller implemented in Zynq. In my personal opinion the easiest way to implement CAN would be using approach described in UG585. You will need to use CAN SN65HVD230 breakout board, connect it to JF MIO Pmod and configure Zynq processing system for CAN0, for example.

Xilinx also provides canps driver, example and test application in Vivado XilinxProcessorIPLib.

Good luck!

Share this post


Link to post
Share on other sites
  • 0
On 9/25/2017 at 11:34 PM, jpeyron said:

Hi @david.600,

CAN communication can be reached using the Zynq processor through the emio pins on the board. Due to the way CAN works as described here you would need an external board to facilitate it since all of the i/o is 3v3. I have attached an Image of the Zynq processor for reference. We have a PmodCAN here that will facilitate CAN communication to other devices. This would be the way to go as long as your goal is working with CAN devices and not trying to make a CAN controller. 

cheers,

Jon

 

zynq.jpg

Hi @jpeyron

I bought the Pmod CAN from Digilent.

I've followed all the Installation Steps, and i should have a working code.

I'm Trying to receive Data from the PE3 ECU, that works with the SAE J1939 standard (http://pe-ltd.com/assets/AN400_CAN_Protocol_C.pdf).

When i Use the Example code(Receive only - Author: @artvvb -  ) provided with the Pmod Can. I always get Status = 0.

When i Connect the PE3 to a Scope, i can see that is sends the Canbus Messages.

 In the Pmod CAN notes i see that it only Compatible with ISO-11898-1, ISO-11898-2, and ISO-11898-5

What should i change in the code in order to make it work?

this is the code description:

/*************************************************************************/
/*                                                                       */
/*     RX.c --     PmodCAN Example Projects                              */
/*                                                                       */
/*************************************************************************/
/*     Author: Arthur Browm                                              */
/*                                                                       */
/*************************************************************************/
/*  File Description:                                                    */
/*                                                                       */
/*  This demo receive data through the PmodCAN and send it through uart  */
/*  normal mode function                                                 */
/*                                                                       */
/*************************************************************************/
/*  Revision History:                                                    */
/*                                                                       */
/*            8/30/2017(ArtVVB): Created                                 */
/*               9/1/2017(jPeyron): formatted Validated                     */
/*            9/6/2017(jPeyron): Added RX and TX demos                   */
/*                                                                       */
/*************************************************************************/
/*************************************************************************/

Thanks,
David
Edited by david.600

Share this post


Link to post
Share on other sites
  • 0

Hi @david.600,

Have you verified that CANL is connected to Pin 2 and CANH is connected to Pin 7 on J1. Looking on page 25 here it states that when the can bus is connected to the ECU it will always be broadcasting data on the bus. Looking at the The SAE J1939 Communications Network it states the that SAE J1939 communications network is a high speed ISO 11898-1 CAN-based communications so it should be compatible. 

cheers,

Jon

 

 

Share this post


Link to post
Share on other sites
  • 0
6 hours ago, jpeyron said:

Hi @david.600,

Have you verified that CANL is connected to Pin 2 and CANH is connected to Pin 7 on J1. Looking on page 25 here it states that when the can bus is connected to the ECU it will always be broadcasting data on the bus. Looking at the The SAE J1939 Communications Network it states the that SAE J1939 communications network is a high speed ISO 11898-1 CAN-based communications so it should be compatible. 

cheers,

Jon

 

 

I connected the CanH and CanL to the Blue connector(J3), and the ground of the ECU to the ground on J3.

i've used the following config:

three commands set a CAN speed of 250 kBPS with a CAN clock of 20 MHz.
  1. CNF1 (0x2A) set to 0x41
  2. CNF2 (0x29) set to 0xFB
  3. CNF3 (0x28) set to 0x86
then i configured the ECU  Canbus messages speed to 250kBps.
 
what can i check/do?
 
Thanks,
David

Share this post


Link to post
Share on other sites
  • 0

Hi @jpeyron,

i've tried all 4 options:

only jp1 on

only jp2 on

jp1 and jp2 on,

both of them off(jumper not connected)

when i remove the Pmod, i get status FF.

when its connected my status is always 0.

Thanks,

David

 

Share this post


Link to post
Share on other sites
  • 0

Hi @david.600

I am wondering what are you using for communication with the PmodCAN/Zynq, specifically, hardware and software.

In my experience I've spent a some of time making sure PC side of CAN is working properly.

 

Share this post


Link to post
Share on other sites
  • 0
On 1/3/2018 at 12:24 AM, jpeyron said:

Hi @david.600,

Have you tried the loopback demo to test that the Pmod CAN is working correctly? Could you try running the ecu at 500kbps?

thank you,

Jon

 

3 minutes ago, Notarobot said:

Hi @david.600

I am wondering what are you using for communication with the PmodCAN/Zynq, specifically, hardware and software.

In my experience I've spent a some of time making sure PC side of CAN is working properly.

 

jon - i've tried all the speeds available in the ECU including 500 Kbps, about the loopback - i'll do it soon and update.

 noterobot - i'm using  PE3 ECU, that works with the SAE J1939 standard.

Share this post


Link to post
Share on other sites
  • 0

@david.600,

Thank you for your answer.

To my knowledge J1939 requires 29 bit Identifier. Hope you set this the same on both sides. It was one of my problems initially.

My advice to test loopback, it will rule out a number of possible issues.

Share this post


Link to post
Share on other sites
  • 0

i've finally tried the loopback program - it seems to work -  the output:

Spoiler

Waiting to send
sending message:
    Standard Frame
    ID: 100
    Standard Data Frame
    dlc: 6
    data:
        01
        02
        04
        08
        10
        20
requesting to transmit message through transmit buffer 0
CAN_SendMessage message.dlc: 06
CAN_SendMessage: 20
CAN_SendMessage: 00
CAN_SendMessage: 01
CAN_SendMessage: 5A
CAN_SendMessage: 06
CAN_SendMessage: 01
CAN_SendMessage: 02
CAN_SendMessage: 04
CAN_SendMessage: 08
CAN_SendMessage: 10
CAN_SendMessage: 20
Waiting to complete transmission
Waiting to receive
Error, message not received
Waiting to send
sending message:
    Standard Frame
    ID: 100
    Standard Data Frame
    dlc: 6
    data:
        01
        02
        04
        08
        10
        20
requesting to transmit message through transmit buffer 0
CAN_SendMessage message.dlc: 06
CAN_SendMessage: 20
CAN_SendMessage: 00
CAN_SendMessage: 01
CAN_SendMessage: 5A
CAN_SendMessage: 06
CAN_SendMessage: 01
CAN_SendMessage: 02
CAN_SendMessage: 04
CAN_SendMessage: 08
CAN_SendMessage: 10
CAN_SendMessage: 20
Waiting to complete transmission
Waiting to receive
fetching message from receive buffer 0
received message:
    Standard Frame
    ID: 100
    Standard Data Frame
    dlc: 6
    data:
        01
        02
        04
        08
        10
        20

 

Share this post


Link to post
Share on other sites
  • 0
On 1/3/2018 at 12:24 AM, jpeyron said:

Hi @david.600,

Have you tried the loopback demo to test that the Pmod CAN is working correctly? Could you try running the ecu at 500kbps?

thank you,

Jon

Hi @jpeyron,

I found the reason why it didnt work, the following command isnt working with "CAN_ModeNormalOperation", it works only with "CAN_ModeListenOnly" for some reason:

void CanBusInitialize()
{
    EnableCaches();
    CAN_begin(&myDevice, XPAR_PMODCAN_0_AXI_LITE_GPIO_BASEADDR, XPAR_PMODCAN_0_AXI_LITE_SPI_BASEADDR);
    CAN_Configure(&myDevice, CAN_ModeListenOnly);
}

anyway, now i have another problem, when i connect to the PE3 ECU, i get the following Raw Data:

j1939 standart - 500 Kb/S:
        3FD3CD1533A43BD7ECE2
        3FD37C1533A43BD7ECE2


pe3 standart - 500 Kb/S:
        3F40CDCC0124810208FB
        3FD3CD1533A43BD7ECE2

pe3 standart - 250 Kb/S:
        3FD37C1533A43BD7ECE2

none of this msgs standards are consistent with the CanBus ID PE use(attached).

To find the data i receive from the PE, i added the following code to the  CAN_ReceiveMessage function in the PmodCan.c file:

xil_printf("id is ");
    for (index = 0; index < 48; index++)
        xil_printf("%X", data[index]);

any idea what am i doing wrong?

Thanks,

David
 

 

 

pe3_can_protocol_b.pdf

Edited by david.600

Share this post


Link to post
Share on other sites
  • 0

Hi @jpeyron

i've connected the PE3 ECU to the agilent keysight oscilloscope, what i see is that the ECU sends the data like it should(according to the document attached)

the ECU sent one msg all the time:

ID Type DLC Data CRC
0CFFF048 Data 8.00 00 00 00 00 00 00 00 00 12000.00
0CFFF048 Data 8.00 00 00 00 00 00 00 00 00 12000.00

all of the data from the scope is attached. 

how should i proceed?

thanks,

David

pe3_can_protocol_b.pdf

scope_3_SBUS1_CAN.csv

scope_recording_from_PE3.csv

scope_recording_from_PE3_bits_data_voltage.csv

scope_7.png

Edited by david.600

Share this post


Link to post
Share on other sites
  • 0

Hi @david.600,

Looking at the datasheet for the MCP25625 CAN Controller with Integrated Transceiver on page 27 it discusses using the Message Error Interrupt and the INT pin. This is intended to be used to facilitate baud rate determination when used in conjunction with Listen-Only mode. I was thinking that this interrupt could help us narrow down the issue.

thank you,

Jon

Share this post


Link to post
Share on other sites
  • 0
On 3/30/2018 at 12:41 AM, jpeyron said:

Hi @david.600,

Looking at the datasheet for the MCP25625 CAN Controller with Integrated Transceiver on page 27 it discusses using the Message Error Interrupt and the INT pin. This is intended to be used to facilitate baud rate determination when used in conjunction with Listen-Only mode. I was thinking that this interrupt could help us narrow down the issue.

thank you,

Jon

Hi @jpeyron

In the Code there is a reg that determines the baud rate - 

Quote

 

Three registers are manipulated in this way with a variety of settings; for more details see Section 4.4 (page 47) in the MCP25625 datasheet. The following three commands set a CAN speed of 250 kBPS with a CAN clock of 20 MHz.
  1. CNF1 (0x2A) set to 0x41
  2. CNF2 (0x29) set to 0xFB
  3. CNF3 (0x28) set to 0x86

 

how can i change the baud rate to be fixed?
 
and what could cause the raw data from the canbus to be wrong? the baud rate only?
Edited by david.600

Share this post


Link to post
Share on other sites
  • 0

Hi @david.600,

I would guess that it is a timing issue. The only thing i can think of is to o-scope the can input and implement the debugging in sdk to see what data is being read in and go from there.

thank you,

Jon

Share this post


Link to post
Share on other sites
  • 0

Hi @jpeyron

these are the facts untill now:

the pe3 ECU sends canbus data like it should on its datasheet but the format isnt exactly like in formal protocol.

the msg it sends can be seen a few posts ago.

when the pmod is on listen only mode - i have corrupted data , and the pmod doesnt sent ack so the ECU sends the same msg all the time.

when the pmod is on normal mode - i have no data received("Error, message not received")

 I thought that the reason is that the msp25625 drops the frame for error.

that why i changed the CAN_RXB0CTRL_REG data to 0x0 istead of 0x60(ignore error - page 37 in the msp datasheet)

CAN_ModifyReg(InstancePtr, CAN_RXB0CTRL_REG_ADDR, 0x64, 0x00) - line 663 in PmodCAN.c

this didnt help.

what else can i do to make it work?

 

Edited by david.600

Share this post


Link to post
Share on other sites
  • 0

Hi @david.600,

I have reached out to my co-workers about this thread. We are not sure why this issue is occurring. We also do not have the can device you are trying to communicate with. With the not formal protocol at this point I think your best course of action would be to reach out to performance electronics about this issue. 

thank you,

Jon

Share this post


Link to post
Share on other sites
  • 0
On 4/26/2018 at 1:20 AM, jpeyron said:

Hi @david.600,

I have reached out to my co-workers about this thread. We are not sure why this issue is occurring. We also do not have the can device you are trying to communicate with. With the not formal protocol at this point I think your best course of action would be to reach out to performance electronics about this issue. 

thank you,

Jon

Hi @jpeyron

I have an open case with PE on this Issue , but i see on my scope that the send valid msgs, just not like the official protocol , i should be able to see the raw data on the Zybo.

I also have an open case with Microchip , maybe then can help.

is there anything else i can do until they answer? 

 

Share this post


Link to post
Share on other sites
  • 0

Dear @david.600

In your case I would get working CAN bus USB adapter for PC with software and try to understand messages coming from  PE3 ECU. If your budget is limited I would recommend either Microchip CAN BUS Analyzer Tool Part Number: APGDT002 or less expensive CANable - small open-source USB to CAN adapter which is supported by open source software. There are several good commercial CAN tools but they are way more expensive.

With these tools you will be able to understand PE3 ECU messaging, test your Zybo CAN implementation and understand where is the problem.

Good luck!

Edited by Notarobot

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now