Pages: 1 ... 26 27 [28] 29   Go Down
Author Topic: Building a CAN API for Arduino DUE  (Read 117793 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For those looking for an easy solution for the transceiver, i'm using a pair of SN65HVD230 eveluation boards (Amazon) probably you can find them cheaper.
 
  I could get some commands to be recognized by some car units in the bench, but i need to send timed messages, is there any timing function in the library itself or i just need to stick to "millis"?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is anyone still working on integrating the Due CAN libraries into the mainstream Arduino release?

I've been working on a "unified" CAN library that works for both the SAM3X8E and MCP2515. The library syntax follows Arduino conventions (begin(), available(), read(), write() and end()), and right now I've gotten it down to a pair of #if defined() statements needed in the main .ino to separate the two hardware implementations.
 
I'm wondering if it's possible to combine the two hardware implementations even further to reduce confusion to new CAN users? Possibly having just a single CAN() class that covers multiple hardware implementations?

Thanks!

-Neil
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there any working samples that simply receives data from ecu such as  motec?
Logged

Venezuela
Offline Offline
God Member
*****
Karma: 16
Posts: 512
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Jason,
You can try the CAN_TrafficSnooper example from Collin's library. Regards.
https://github.com/collin80/due_can

p
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I have a CAN network already established with multiple nodes fully functional. I have just aquired a Due and would like be able to use the Due to see the traffic on the CAN bus and also be able to send messages. Most/all of these posts deal with using CAN0 and CAN1 to communicate back and forth. I want to be able to see the traffic from an already existing CAN bus, and no this is not in my car...

I have the WaveShare CAN board as I was told these would be good to use for this kind of application because they function at 3.3V. These are the boards: http://www.wvshare.com/product/SN65HVD230-CAN-Board.htm

Can any of you guys provide some help with this?
« Last Edit: June 16, 2014, 04:56:16 pm by rtfh » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

rtfh,

It looks like you are off to a good start with that board. Connect CAN TX on the Due to CAN TX on the board, and the same for CAN RX. Hook up power and ground, and check your termination, and you should be good to go.

And since nobody else had mentioned it, I went ahead and implemented a "unified" CAN library. One API gets you functionality for three different types of CAN controller; Microchip MCP2515, Atmel SAM3X (Due), and Freescale K2x (Teensy 3.1). It's not quite finished yet, but if you are interested in using it, take a look at https://github.com/McNeight/CAN-Library/

-Neil
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Palliser,

I having many problems running the traffic snooper file



CAN_TrafficSnooper:15: error: variable or field 'printFrame' declared void
CAN_TrafficSnooper:15: error: 'CAN_FRAME' was not declared in this scope
CAN_TrafficSnooper:15: error: 'frame' was not declared in this scope
CAN_TrafficSnooper.ino: In function 'void setup()':
CAN_TrafficSnooper:19: error: no matching function for call to 'CANRaw::init(int)'
C:\Users\jj\Desktop\arduino\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:185: note: candidates are: uint32_t CANRaw::init(uint32_t, uint32_t)
CAN_TrafficSnooper:20: error: no matching function for call to 'CANRaw::init(int)'
C:\Users\jj\Desktop\arduino\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:185: note: candidates are: uint32_t CANRaw::init(uint32_t, uint32_t)
CAN_TrafficSnooper:28: error: 'class CANRaw' has no member named 'setRXFilter'
CAN_TrafficSnooper:29: error: 'class CANRaw' has no member named 'setRXFilter'
CAN_TrafficSnooper:33: error: 'class CANRaw' has no member named 'setRXFilter'
CAN_TrafficSnooper:34: error: 'class CANRaw' has no member named 'setRXFilter'
CAN_TrafficSnooper.ino: At global scope:
CAN_TrafficSnooper:39: error: variable or field 'printFrame' declared void
CAN_TrafficSnooper:39: error: 'CAN_FRAME' was not declared in this scope
CAN_TrafficSnooper:39: error: 'frame' was not declared in this scope


any advise?
Logged

Earth
Offline Offline
Sr. Member
****
Karma: 14
Posts: 326
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try to make sure that you really are compiling for the Arduino Due, using the 1.5.4 IDE or newer, and that you don't have any older copies of the library around. I've had people accidentally have two copies with an older one in the first place Arduino looks.
Logged

Venezuela
Offline Offline
God Member
*****
Karma: 16
Posts: 512
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Palliser,

I having many problems running the traffic snooper file

[code errors]
any advise?


Hello Jason. It sounds like you have selected the wrong board in your IDE 1.5.X.

p
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello guys,
i have a so many mcp2551 transceiver chip. and i dont want to wait for work (china ship time 15 days  smiley-roll )
so they are 5v level, due is 3.3v level
after the level harmonize (5v>3.3v)
can i use them together with this can api?
Thank you so much
Tufan.
Logged

Earth
Offline Offline
Sr. Member
****
Karma: 14
Posts: 326
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello guys,
i have a so many mcp2551 transceiver chip. and i dont want to wait for work (china ship time 15 days  smiley-roll )
so they are 5v level, due is 3.3v level
after the level harmonize (5v>3.3v)
can i use them together with this can api?
Thank you so much
Tufan.

Sure, I don't see why not. We had standardized on a different chip just because it is 3.3v, reasonably respected, and easy to obtain. But, within reason you can use any canbus transceiver chip you want. The transceiver is almost completely transparent as far as the library goes. The only reason we even have code for the transceiver at all is because the SN65HVD chip we're using has an enable pin so you can turn the transceiver on and off. If you don't care about this you can just hard wire it to on or use a chip that doesn't have an enable pin.

As you mentioned, using a 5V chip will necessitate a level shift. You will, at the least, need to turn the 5V CAN_RX output from the MCP2551 into 3.3V for the Due. I'll bet the 3.3V CAN_TX signal from the Due will trigger the MCP just fine but you'll have to try it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you so much collin80,

i see a howtouse.txt file in new github

but examples are very hard for me
i need to send simple can message
how can i do that? can you show me please a very very simple code like this
because this is doesnt work smiley-sad


Code:

#include "variant.h"
#include <due_can.h>

void setup()
{
CAN.init(250000);
}

void loop()
{
uint32_t id ;
uint8_t length;
uint8_t data[8];

CAN_FRAME myFrame;
myFrame.id = 7E0;
myFrame.length = 1
myFrame.data[0] = 0xFF;
CAN.sendFrame(myFrame);
delay(100);
}


i have a peak system can bus interface  for watch
i want to test my mcp2551  with simple code
thank you so much
« Last Edit: July 14, 2014, 04:58:02 pm by gambit1244 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

anybody can help me please    smiley-confuse
i need a very simple code for send can message

warm regards.
Logged

Earth
Offline Offline
Sr. Member
****
Karma: 14
Posts: 326
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I wanted to help but but I've been unable to log into this forum for the past few days. It seems to be fixed now.

Anyway, your code looked right except that you were missing a semi-colon and a hexadecimal prefix. The below two lines are what would have to change:

myFrame.id = 0x7E0;
myFrame.length = 1;

Those are the correct lines.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you so much Collin,
but i cant compile this code where is the bug smiley-sad
i am watcihng the can1-can2 tx rx pins of arduino with my saleae logic analyzer

this is the screenshot
thank you for your help


* fault.PNG (19.76 KB, 601x623 - viewed 15 times.)
Logged

Pages: 1 ... 26 27 [28] 29   Go Up
Jump to: