• 0

Question

Hello members,

I have the Zybo-Z7 Board and I want to connect it with other Zybo-Z7 Board via CAN.

The board has an integrated CAN Controller and I need following PmodCAN-Connector which has also can controller integrated.

http://store.digilentinc.com/pmod-can-can-2-0b-controller-with-integrated-transceiver/

 

Which CAN Controller shall I use and how do I make it work?

I have implemented a basic design for Zybo in Vivado and added the IP core for PmodCAN. Is something more I need?

 

Cheers,

mb

 

zybo_can.JPG

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

Hello @mbo,

On a first look your Block Design looks good. Please make sure that you validate it and you don't have any errors. As a starting point for your design, if you fallow into the "vivado library master" folder this path : vivado-library-master -> ip -> Pmods ->PmodCAN_v1_0 -> drivers, you can find example projects. Also in the main folder there is a ReadMe file, that gives you instruction on how to use the Pmod IP core for Zynq projects.I have reached out to more experienced engineers to see if they have more input for this issues.

Best Regards,

Vanca Bogdan

Share this post


Link to post
Share on other sites
  • 0

Hello @BogdanVanca,

thank you for your reply.

If I want to connect PmodCAN to standard Pmod Connector JE, which I/O ports do I have to connect CAN0 to get it work with Pmod Connector JE? I have looked up the table 16.1 in the Zybo-Z7 Reference Manual. Do I have to set it to EMIO or to specific ports?

Further in the board overview with the connected ports in vivado there is no Pmod Connector JF but there should be one which is for MIO.
I installed the right board files from Digilent github repository.

Cheers,
Mb

Edited by mbo
falsely as quote

Share this post


Link to post
Share on other sites
  • 0

Hello @mbo,

I have created for you a project that take one of the examples that I spoken earlier, and I adapted it for the Zynq Architecture. I also connected the PmodCAN to the standard Pmod Connector JE. I hope this will help you.

Cheers,

Vanca Bogdan       

Pmod_CAN.rar

Share this post


Link to post
Share on other sites
  • 0

@mbo

Have you completed the Getting Started with Pmod IP Cores tutorial through to using Vivado SDK and programming your board? Your hardware looks fine. Using Pmod Header JF would be significantly more difficult than using any other header, since the MIO/EMIO pins don't use the same drivers as the AXI SPI controller that the Pmod CAN IP core wraps. The MIO pins are configured by customizing the Zynq7 Processing System block in Vivado IPI (they appear in the block design as part of the FIXED_IO interface).

You can use the LoopBack.c example to make sure that your Zybo can talk to the Pmod CAN. LoopBack places the CAN controller into a mode where the controller receives it's own messages in hardware, so it is a good way of making sure that your hardware works. After that, you can program your hardware onto both Zybos, connecting each to a CAN, and connecting each of the CANs to one another. You can program one Zybo with the RX.c example and the other with the TX.c example. This set up should be able to send a packet defined in the example code from one Zybo to the other. You can demonstrate that this communication has happened by connecting both boards to serial terminals.

Thanks,

Arthur

Share this post


Link to post
Share on other sites
  • 0

@BogdanVanca and @artvvb,

thank you so much for your replies.

I will try it as soon as possible. Due to organizational problems it will take some weeks but I will let you know about the progress of testing and if it works.

Thank you so much!

Cheers,

Mirco (mbo)

 

ADDED:
Yes, I have completed the Getting Started Guide with Pmod IP Cores.

Edited by mbo
additional information

Share this post


Link to post
Share on other sites
  • 0

@BogdanVanca and @artvvb,

after a long time I got my Zybo Z7-Boards and Pmod CAN.

The loopback-demo is working fine and my next step was to implement the Rx.c and Tx.c from Pmod_CAN source.

But there is one problem...
In Rx.c the status is always "Error, message not received" but I dont know what the cause of the problem is.

Thanks,
Mirco

Share this post


Link to post
Share on other sites
  • 0

Hi @jpeyron,

yes exactly.

I am using a d-sub 9-pin zero modem cable to connect them. The weird thing is that the loopback demo is working which means that pmod hardware is working fine.

I suggest the pin assignment is not correct wether in the cable or in vivado.

But I have no idea how to check the pin assignment in the cable.

I did not found a d-sub cable with 9 pin socket in digilent store.

 

The error in rx program is that it fails to check the CAN status.

When I connect two pmod CANs together via cable do I have to set the jumper on pmod at specific position?

 

Thanks,

Mirco

 

 

Share this post


Link to post
Share on other sites
  • 0

Hi @mbo,

We recently made some changes to the Zybo-Z7 board files. Please update the board files.  What ports are you using?

thank you,

Jon

Share this post


Link to post
Share on other sites
  • 0

Hi @jpeyron,

thank you for the hint of updated board files. 

I am using Pmod port JE on my Zybo-Z7 and the port assignment in my constraint file is following:

##Pmod Header JE             
set_property -dict { PACKAGE_PIN V12   IOSTANDARD LVCMOS33 } [get_ports { pmod_out_pin1_io }]; #IO_L4P_T0_34 Sch=je[1]						 
set_property -dict { PACKAGE_PIN W16   IOSTANDARD LVCMOS33 } [get_ports { pmod_out_pin2_io  }]; #IO_L18N_T2_34 Sch=je[2]                     
set_property -dict { PACKAGE_PIN J15   IOSTANDARD LVCMOS33 } [get_ports { pmod_out_pin3_io  }]; #IO_25_35 Sch=je[3]                          
set_property -dict { PACKAGE_PIN H15   IOSTANDARD LVCMOS33 } [get_ports { pmod_out_pin4_io  }]; #IO_L19P_T3_35 Sch=je[4]                     
set_property -dict { PACKAGE_PIN V13   IOSTANDARD LVCMOS33 } [get_ports { pmod_out_pin7_io  }]; #IO_L3N_T0_DQS_34 Sch=je[7]                  
set_property -dict { PACKAGE_PIN U17   IOSTANDARD LVCMOS33 } [get_ports { pmod_out_pin8_io  }]; #IO_L9N_T1_DQS_34 Sch=je[8]                  
set_property -dict { PACKAGE_PIN T17   IOSTANDARD LVCMOS33 } [get_ports { pmod_out_pin9_io  }]; #IO_L20P_T3_34 Sch=je[9]                     
set_property -dict { PACKAGE_PIN Y17   IOSTANDARD LVCMOS33 } [get_ports { pmod_out_pin10_io  }]; #IO_L7N_T1_34 Sch=je[10] 

Thanks,

Mirco

Edited by mbo

Share this post


Link to post
Share on other sites
  • 0

Hello @mbo

I am not sure that you are aware that ARM processors on Zynq have two CAN 2.A (2.0B) controllers embedded on the chip. Unless some specific requirements, logic of adding an external controller Pmod-CAN is difficult understand. Pmod-CAN is well suited for boards without Zynq (ARM) capabilities.

The only piece of hardware needed to make ARM CAN to work over a pair of twisted wires is a breakout board, for example, like this connected to the Zybo Pmod port JF. This breakout board is required to implement physical CAN interface.

You can find JF port configuration searching FPGA forum, check Xilinx provided examples of the driver and you are good to go. You can start with the Xilinx source code but change loopback mode to normal in the configuration call.

I would also recommend to have include PC in the network for debugging purposes. For the intreface I would recommend USB-CAN adapter from this open source project. It works with open source software so that you can start with very low monetary investment into your project.

Good luck!

Share this post


Link to post
Share on other sites
  • 0

@Notarobot,

Yes the Zynq has CAN controllers but unless they are connected to the MIO and available on an board connector or through the EMIO that functionality is unavailable. Check the schematic for your board.

My understanding of the Zynq CAN is that regardless of whether or not the interface goes though the PS IO or the PL IO you still need a PHY to connect it to external networks. Can (no pun intended) anyone confirm this?

Edited by zygot

Share this post


Link to post
Share on other sites
  • 1

Hi @zygot

Yes, it requires MIO to be configured, for example, like this

image.thumb.png.4786e6dec891940a7755db6490445a33.png

On Zybo these MIO are wired to Pmod JF. You are also correct that PHY = breakout board is needed to implement differential signaling.

I've done this on Zybo and on other Zynq board and happy with results. CAN is more complicated but worth the effort. It is fast, reliable, only two wires, and you can put 64 devices on these two wires and since there is no master node you can add/remove any device easily.

Share this post


Link to post
Share on other sites
  • 0

@zygot

Thank for the advice, I did check the schematic when implemented CAN on Zynq and configuring CAN on MIO 10,11 for using Zybo port JF. You are correct, a PHY = CAN_breakout_board is needed for implementing differential signaling. This is the only purpose of PHY in this particular case.

Anyway it was done a while ago and CAN delivered expected results. CAN is fast, low latency communication allowing to put many devices on the same pair of wires. I can add or remove any one without disrupting the network.

Edited by Notarobot

Share this post


Link to post
Share on other sites
  • 0

@Notarobot

Thank you for lucid commentary.  Can can! (Yes, that was a pun) Can is widely used in automotive and industrial applications, has been around for quite some time and has a robust protocol. Hopefully, you've got more people interested in experimenting with Canning and learning about a useful interface.

Share this post


Link to post
Share on other sites
  • 0

@zygot

Initially, I tried CAN as a replacement for RS485 which is not supported on Zynq, and found that it's not difficult to implement. I think I showed the way, relevant C-code anyone can find in Xilinx library embeddedsw\XilinxProcessorIPLib\drivers\canps\ .

My response to this post was motivated by troubles understanding the way @mbo tried to implement CAN on Zybo. I think it's very awkward approach and I am not sure that it can be successfully accomplished. I hope to spare him from unnecessary suffering.

 

Share this post


Link to post
Share on other sites
  • 0

@Notarobot,

I'm sure that you know this but I thought that I'd mention for the benefit of any curious readers that while there is still a place for RS-485 it can get quite messy. One could certainly add the hardware to a Zynq board for implementing RS-485 networks but if CAN does the job and your application needs fit within it's protocol then using it has a lot of advantages. I've appreciated your comments. Thanks.

Share this post


Link to post
Share on other sites
  • 0

Thank you all for help and further information,

@jpeyron do you mean design wrapper?

To answer your question about input for can I'll try to describe the structure. I use two Zybo-Z7 boards and each board has one Pmod CAN Transceiver connected to Pmod port JE.
The Pmod CAN Transceiver of both boards are connected together via d-sub 9-pin cable. One board has Tx.c example source of Pmod CAN implemented and other board has Rx.c source implemented.

@Notarobot I understand that the way I've chosen may not be the easiest and I am thankful for your advices. The breakout-board you presented has an onboard can transceiver and is I think not different to Pmod CAN from Digilent where I also have the option simply to connect wires. Both ways should work. Thank you

My goal is that two boards are connected to each other via two CAN lines and in case of a failure of one line the connection between these boards is switched automatically to the other CAN line. But this one is far away and first I need CAN to get work correctly by sending messages from one board to other board.

Thanks,
Mirco

design_wrapper.txt

Share this post


Link to post
Share on other sites
  • 0

In addition, I have another question...
When I use the source files Tx.c and Rx.c from PmodCAN source directory is there any way I can find out how to set PmodCAN to specific status?

In Tx.c and Rx.c following function is used several times to check current status of CAN but at beginning of Rx.c the status is not correct and I want to set it by myself.

status = CAN_ReadStatus(&myDevice);

Does anyone know which registers I have to set at specific value to get specific status?

Thanks,
Mirco

Share this post


Link to post
Share on other sites
  • 0

Hi @mbo,

What sort of status were you hoping to read? Based on datasheet for the CAN device in the Pmod CAN, there a few registers that show status (4-2, 4-11, 4-35) but they all tend to be single bits of information. There is also a Read Status instruction which is what that function you listed is, but it returns specific bits in certain registers (the bits are detailed on page 60, the registers referenced are on page 52 and page 32).

Thanks,
JColvin

Share this post


Link to post
Share on other sites
  • 0

Hi @JColvin

I monitored the loopback demo and in the receiving part of that demo the ReadStatus-function is returning value 9 as status. With that status the switch-case statement is switching between receiving message from buffer 0 or 1. But if status is not 9 an error is returned by switch-case statement.

Next step was to use Rx.c example code which starts at mentioned ReadStatus-function and switch-case statement afterwards. To get it work the ReadStatus-function needs to return 9 as status.

I will take a look at the pages you mentioned.

Thanks, Mirco

Share this post


Link to post
Share on other sites
  • 0

Hi @Notarobot,
 

On 9.3.2018 at 1:58 PM, Notarobot said:

You can find JF port configuration searching FPGA forum, check Xilinx provided examples of the driver and you are good to go. You can start with the Xilinx source code but change loopback mode to normal in the configuration call.

I have searched for JF port configuration in Digilent and Xilinx forum but found nothing. Where can I find it?

Thanks,
Mirco

Share this post


Link to post
Share on other sites
  • 0

Dear @mbo

If you trace Zybo Pmod JF schematic diagram you will find that

- pin JF2 (MIO-10 = Rx in) should be connected to CAN Rx on the PHY breakout board SN65HVD230 or similar,

- pin JF3 (MIO-11 = Tx out) should be connected to CAN Tx on the PHY breakout board.

- pin JF5 and JF6 - GND and 3.3V power.

Please, note that the above mentioned breakout board is does not include CAN controller, CAN controller is implemented in ARM on Zynq. I am not sure that you can use Pmod-CAN is such configuration. I don't have time to investigate this.

My recommendation is to get USB-CAN dongle and use PC for monitoring the CANetwork. It will help you to debug and configure your nodes and messages.

Edited by Notarobot

Share this post


Link to post
Share on other sites
  • 0

Hi @Notarobot, @JColvin, @jpeyron,

Can is working! Also with breakout board and PmodCAN.

To my shame, I have to confess that I have used wrong d-sub cable all time.
With tips from Notarobot I tried to implement can with breakout board which worked at first moment. After that success I tried other d-sub cable for PmodCAN and now both ways are working.

Thank you guys for all your help. You're the best!

Thanks and cheers,
Mirco

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