Go to Post Unsure if I'll get it to work, but that's no reason to not try. - DonRotolo [more]
Go Back   Chief Delphi > Technical > Electrical > CAN
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-17-2016, 11:51 AM
RyanN's Avatar
RyanN RyanN is offline
AKA: Ryan Nazaretian
FRC #2468 (Team Appreciate)
Team Role: Mentor
Join Date: Jun 2006
Rookie Year: 2005
Location: Austin, TX
Posts: 1,151
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
CAN + MCP2515, no data

Has anyone ever attempted to hook up one of the many available Arduino CAN shields that utilizes the Microchip MCP2515 CAN controller?

Seeed Studios
has code available that is supposed to work at 1Mbps, but I have not been able to get it to work on the robot's CAN bus. The code is supposed to read data on the bus and transmit it over the UART interface to my computer.

I have checked that the example code does indeed work using my car at 500kbps.

I thought maybe they had the calculations wrong, but they appear to be correct.

The Seeed Studio shield uses a 16MHz crystal oscillator. That would give a TQ of 2/16MHz, or 1/8MHz, Of course, the inverse of Hertz, or cycles / second, is seconds / cycle, giving the time base.

The three registers that select the CAN baud rate are cnf1, cnf2, and cnf3.

The "+ 1" are referenced from the datasheet, such that it will increment the value internally by 1, so if the register is set to 0, the interpreted number will really be 1.

cnf1 = 0x00: SJW = 0; BRP = 0 + 1
cnf2 = 0xD0: BTLMODE = 1; SAM = 1; PHSEG1 = 2 + 1; PRSEG = 0 + 1
cnf3 = 0x82: SOF = 1; WAKFIL = 0; PHSEG2 = 2 + 1

So now that you know what the registers are set to, let's do the math on what that means for bit timings.

For 1 Mbps, I need a bit timing of 1x10^-6 seconds, or 1 / 1 MHz (which is why I kept it in that silly format above, it makes the math easier), or again, for math terms, let's assume 8 / 8 MHz.

Tbit = Tsync_seg + Tprop_seg + Tps1 + Tps2
Tsync_seg = 1 * TQ, or 1 / 8 MHz (1/8)
Tprop_seg = (0 + 1) TQ, or 1 / 8 MHz (1/8)
Tps1 = (2 + 1) TQ, or 3 / 8 MHz (3/8)
Tps2 = (2 + 1) TQ, or 3 / 8 MHz (3/8)

From here, it's simple addition: (1/8) + (1/8) + (3/8) + (3/8) == (8/8).

So, those registers seem fine, and from what I can tell, follow all the rules the datasheet specified. I don't know why it's not working. The red RX light is flashing, so it's seeing data coming in. I know the code works because it works in my car from the OBDII port at 500kbps. Bus impedance was measured at 56 Ohms (a little shy of 60 Ohms, but should still be fine).

One other puzzling thing is my SALAE logic can read the bus just fine at 1 Mbps. The only thing I can note is that the bus uses the extended frame format with the 29-bit identifiers rather than the standard frame with 11-bit.

Any ideas?
Controls Mentor

Current team:
Team Appreciate, FRC 2468

Previous teams:
Team Fusion, FRC 364 (2003 - 2015)
Garnet Squadron, FRC 4901 (2015-2016)
Reply With Quote
  #2   Spotlight this post!  
Unread 09-09-2017, 03:42 PM
Wasabi Fan Wasabi Fan is offline
Registered User
AKA: Kaelin Laundry
FRC #0488
Join Date: Dec 2015
Rookie Year: 2015
Location: Washington
Posts: 23
Wasabi Fan has a spectacular aura aboutWasabi Fan has a spectacular aura about
Re: CAN + MCP2515, no data

Did you ever find a solution here? I'm looking at this same chip and it'd be super helpful to know that someone else got it working.
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -5. The time now is 02:33 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi