Pages: 1 ... 23 24 [25] 26 27 ... 29   Go Down
Author Topic: Building a CAN API for Arduino DUE  (Read 134093 times)
0 Members and 2 Guests are viewing this topic.
Honolulu
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Finally finished my shield.  The through holes are to give access to the header pins in the middle of the board.  I think the next version will just have the pins go through.  The header sockets were a little annoying to solder.  Solder paste does amazing things with surface mount chips.  No more frustrating solder joint problems.   Now just waiting for the engine to arrive.  smiley-grin



* IMG_5669.JPG (2660.52 KB, 3264x2448 - viewed 291 times.)
« Last Edit: March 06, 2014, 08:23:32 pm by jspobuk » Logged

Pacific Electro-Mechanical Inc. - Honolulu -

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

Love what you guys are doing here!
I have a very newbie question. I wonder if someone can show me how to filter for just the ECU?
It seems that what I am doing is not the right thing.

I want to read trouble codes and I keep getting lost somewhere.
I can TX 0x7DF with 03 parameter but RX is my downfall.

CAN.setRXFilter(filter, 0, 0, false); //gets way too much of everything

I try the following two lines and that's where I go wrong:

CAN.setRXFilter(filter, 0x7E8, 0, false);

CAN.setRXFilter(filter, 0, 0x7E8, false);

I just don't get how to set the filter.
« Last Edit: March 10, 2014, 11:38:15 am by noop » Logged

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

setRXFilter has two forms:

int setRXFilter(id, mask, extended);

and

int setRXFilter(mailbox, id, mask, extended);

You seem to be using the second type that allows you to explicitly set which mailbox you are talking about.

In order to properly filter a frame you need to set reasonable values for both id and mask. The incoming frames are AND with the mask and then compared to the id. So, if you need to accept only frames with 0x7E8 then you can set the mask to 0x7FF which forces all frames to exactly match the id. Thus, your call would be:

CAN.setRXFilter(filter, 0x7E8, 0x7FF, false);
Logged

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

Thank you for that answer. Filtering is little clearer for me now.

I will test this in a couple of days.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm trying to send CAN frames from one Due compatible board to another one using Collin80's library.  The sending part works fine and I can see byte traffic with a scope all the way up to the RX TX side of the transceiver on the receiving board.  However, rx_avail() never returns true on the receiving side.  I'm using the CAN_TrafficSnooper example sketch that should not filter any messages and print out everything to the serial console.

Any debugging hints or ideas about what might be going wrong?

As a side question: what is the
Code:
#define TEST1_CAN0_TX_PRIO       15
line in the example sketches?  I don't see it used anywhere.
Logged

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

Hello Mike,
Have you tried the two can modules (CAN0/CAN1) in the same DUE as initially intended in the examples? I tested the EchoTest, ExtendedPingPong and TrafficSnooper and they worked OK on the same original DUE (also with Taijiuino). I haven't tried with two DUEs but Collin's examples should work. It is just about to be careful with the interconnection of the modules. I.e. CAN0 on Due1 with CAN1 on Due2 or CAN1 on Due1 with CAN0 on Due2...or depending on your code, therefore, it would be good if you post your code if differs from the original Collin's examples.

Regards, Palliser     
Logged

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

I need to get the most obvious two points out of the way first:

1. Are you using some sort of CANBus shield which has transceivers on it? You really do need transceivers. If you do have a board then it would help to know if it was something you made or something you bought (and if so, which board did you buy?)

2. Are the canbus wires terminated? A lot of shields are going to have at least selectable termination but you need there to be 60 ohms between CANH and CANL. This should take the form of a 120 ohm resistor at each end of the bus.

Even with the proper transceivers you will not get a signal through between two devices without some termination. A lot of times you can get away with just one 120 or 100 ohm resistor on one end if the link is short. But, 60 ohms is proper.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies.

I've made two AT91SAM3X8E based Arduino-compatible boards working off the Due schematics.  I'm using two TI ISO1050 isolated CAN transceivers (datasheet).  Since these transceivers need to be powered from both sides I have one board powering the transceiver of the other board.  I've attached a partial schematic below.

I do own an official Due.  I'll try wiring up transceivers from CAN0 to CAN1 on the Due and see if the PingPong example works.

UPDATE: The breadboarded version using two of the ISO1050 transceivers and one Arduino Due runs the CAN_EchoTest and CAN_ExtendedPingPong examples correctly.  I'll keep looking through my hardware, but let me know if there's something I could be missing.


* CAN_Schematic.png (84.28 KB, 1602x535 - viewed 166 times.)
« Last Edit: March 13, 2014, 01:18:30 pm by Mike M » Logged

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

Hello Mike,

It might be considered a note on page 4 of the TI ISO1050 specs doc:
http://www.ti.com/lit/ds/symlink/iso1050.pdf

Quote
"TXD is very weakly internally pulled up to VCC1. An external pull up resistor should be used to make sure that TXD is biased to recessive (high) level to avoid issues on the bus if the microprocessor doesn't control the pin and TXD floats. TXD pullup strength and CAN bit timing require special consideration when the device is used with an open-drain TXD output on the microprocessor's CAN controller. An adequate external pullup resistor must be used to ensure that the TXD output of the microprocessor maintains adequate bit timing input to the input on the transceiver".
« Last Edit: March 14, 2014, 08:54:16 pm by Palliser » Logged

US
Offline Offline
Newbie
*
Karma: 1
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Long overDUE and probably rushed, here is an OBD2 /free-running CAN library I've been picking away at.

I'll apologize in advance for:
-developing with the old due_can libraries Collin80 developed and not porting it over to the newer yet
- it's probably slow and I haven't taken full advantage of the HW (only using one CAN mailbox for example)
- any code conventions I probably don't follow, I did put as much green as a plane flight would allow for
- it's only been tested on one vehicle (see logs), toyota w/11-bit ID's

See the readme on github and the examples for OBD2 implementaitons and free-running CAN
https://github.com/togglebit/ArduinoDUE_OBD_FreeRunningCAN

Hope this moves the needle a bit. I should have some upcoming practical uses for this code that will force me to work on it a bit more.
-Dan
Logged

Dan - www.togglebit.net - Arduino DUE proto shields - Arduino DUE CAN shields

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

Hello Dan and thank you very much for share your OBD library for Arduino DUE. Nice job (an a lot of work). I think it is one of the first practical automotive applications based in the due_can library. It really moves the needle (up to 99 KPH!)
I have one question: did you use the pins 6 (CANH) and 14(CANL) in the OBD connectors like I showed in my reply #38?
http://forum.arduino.cc/index.php?PHPSESSID=6fjbgmq82640nklcdr2psed920&topic=131096.30
Regards. -P

Logged

US
Offline Offline
Newbie
*
Karma: 1
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a pre-made OBD cable for CAN ( i think from obd2cables.com)....While i didn't check it would have to be 6 and 14 in order to work (CANH, CANL) .
Logged

Dan - www.togglebit.net - Arduino DUE proto shields - Arduino DUE CAN shields

texas
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Doing CAN now. got my MPG gauge running.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

answer to question.
Customers can also look on the box label for the 2-character Environment Category (E-Cat) Code. If it starts with "G" (G3, G4, etc), the box contains Green compatible parts (E-Cat Codes were added to boxes beginning on June 1st, 2004.



Thank you for the links and info.
The page with the transceiver chip has different ones.
Which one do I need and whats the difference between these ?
SN65HVD234D
SN65HVD234DG4  (G4 means super GREEN part, for sure, above may not be.. )   R suffix are reel parts.

Can you recommend a Arduino bread board start kit also ?

I don't have any idea why places like Mouser and Digikey do that... They're the same part. Sometimes they have funny stuff like that where you have the same part with very slightly different part numbers varying only in suffix. Perhaps there is a slight difference of some sort but I don't know what it is. Chances are either would work fine.

As for an Arduino bread board, I did recommend one. The schmartboard is a breadboard with 1.27mm spots for chips that fits on an arduino.
Logged

togglebit, CAN shield, WIP (to build a jeep CAN monitor)

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

I'd like to build up a CAN Receiver with the Arduino DUE just to receive data.
Is there anywhere a solution or a project like that?

Is the CAN API for the DUE rdy for use?

Thx for your help!
« Last Edit: April 02, 2014, 09:35:32 am by MorgKrig » Logged

US
Offline Offline
Newbie
*
Karma: 1
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

MorgKrig you may want check out my acquisition lib on github I have an rx example in there for free running 11bit messages. Could certainly use more testing.
Logged

Dan - www.togglebit.net - Arduino DUE proto shields - Arduino DUE CAN shields

Pages: 1 ... 23 24 [25] 26 27 ... 29   Go Up
Jump to: