• 0
LaTaupe

Zybo with PmodCAN and RPi

Question

Hello all,

I am trying to set up a CAN communication between a ZYBO Z7 Board with a PmodCAN Controller (connected on JE) and a Raspberry PI 3 using a Niren CAN Module as Controller. Letting 2 Raspberries communicating which each other via SocketCAN works fine, both can send and receive CAN data. Now if I try to let the Zybo communicate with the Raspberry using the example codes for transmit and receive data there seems to be no data on the bus. Neither the Zybo receives any data from the RPi nor the RPi from the Zybo. I have created a block design and tried the example codes according to the guide from the digilentinc website here . The LoopBack example does work as intended, Tera Term shows the messages being send, fetched and received. Just when I try to send data from the RPi the Zybo waits endlessly and any data send out from the Zybo wont be caught by the RPi. I have tried different bitrates to no avail. 

Any help or directing towards the right path in case i am way off in what i am trying is greatly appreciated. The block design is attached.

Cheers

zybopmod.JPG

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Hi @LaTaupe,

Welcome to the Digilent Forums!

Looking at your Block Design I see you are using the interrupts on the Pmod CAN IP Core. The interrupts were not incorporated into the RX, TX and loopback examples. The examples and the PmodCAN.c and PmodCAN.h use polling to get data. 

Are you able to oscilloscope the CAN signals? Are the RPI and the Pmod CAN's bit rate the same?

Are you using 2 Pmod CAN's to facilitate the loopback example?

best regards,

Jon

Share this post


Link to post
Share on other sites
  • 0

Hello @jpeyron,

thank you for your swift reply! Right, I actually read it another thread that polling is used. I re-made the block design without interrupts. I am gonna try to oscilloscope the signals and I only used 1 Pmod CAN so far to test but i do have 2.

On 6/26/2019 at 10:13 PM, jpeyron said:

Are the RPI and the Pmod CAN's bit rate the same?

I believe the following line in PmodCAN.c 

u8 CNF[3] = {0x86, 0xFB, 0x41};

sets the bit rate to 250 kbit/s ? So the RPI I set to the same rate with

~$ sudo ip link set can0 type can bitrate 250000

Is there anything else I need to pay attention to? New Block Design is attached.

Best regards

BlockNew.JPG

Share this post


Link to post
Share on other sites
  • 0

Hi @LaTaupe,

I am not seeing anything wrong with your block design. Remember the the CANL, CANH and GND on J3 of the Pmod CAN is a good place to view the CAN bus.

best regards,

Jon

Share this post


Link to post
Share on other sites
  • 0

Speaking of GRND, my setup looks like in the pictures below, where should the GRND be wired to? Do any of the Jumpers need to be loaded, currently both are unloaded?

Cheers

pmod JP.jpg

Zybo_ground.jpg

Share this post


Link to post
Share on other sites
  • 0

Hi @LaTaupe,

Looking at your images, you should connect the GND pin of both Pmod CANs together. Also, I believe you need to terminal the signal with 120 ohm and cap to ground by having both J1 and J2 loaded as discussed here and here.

best regards,

Jon

Share this post


Link to post
Share on other sites
  • 0

Hello @jpeyron,

thank you a lot for your help so far. First I am trying to let just 1 pmod communicate with the niren can module on the RPi, I did ground them together and terminated both ends with 120 ohm, it remains a mystery to me why i can not receive any CAN data on the RPi which is send from the zybo. As stated in my previous post the bitrate of the pmod is set to 250kbs and the can clock 20mhz in following line of PmodCAN.c :

u8 CNF[3] = {0x86, 0xFB, 0x41};

The oscillator on the Raspberry side is 8mhz. Do the CNF value need to be changed to meet the Raspberry oscillator value? 

Also I do not have the means to oscilloscope the CAN values.

Best regards

Share this post


Link to post
Share on other sites
  • 0

Hi @LaTaupe,

Please make sure that you are using the most current Pmod CAN IP Core here. We had an error in the Pmod Can IP Core that didn't allow users to change the bit rate.  We fixed this issue in May. 

Being able to see whats going on on the CAN Bus will be very helpful. 

The Analog Discovery 2: 100MS/s USB Oscilloscope, Logic Analyzer and Variable Power Supply would be able to view the can bus.

best regards,

Jon

Share this post


Link to post
Share on other sites
  • 0

Hi @LaTaupe,

Glad to hear that updating the Pmod CAN IP Core fixed the issue. Thank you for sharing what fixed the issue.

best regards,

Jon

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