Go Down

Topic: Building a CAN API for Arduino DUE (Read 149728 times) previous topic - next topic

Collin80

By default the canbus library (well, my version) has a 32 entry rolling receive buffer so you can afford to have that many messages come in while you are busy. Changes are you won't be getting that many behind your back unless the bus is *really* busy.

Also, FWIW, I just updated the library. I fixed the examples to call the proper header and added keywords.txt so things are actually highlighted/colored properly.

Hi Everyone

Ive been reading up on this thread for a while now. 
I tinker around with old cars, and have been wanting to figure out how to put a gauge cluster out of a 09 Corvette into my current project.
Im a software developer by day and junk yard mechanic by night :-)

I would like to get started with the Arduino DUE to tinker with the can bus on the cluster.
Its GMLAN which I read that they have a Highspeed and low speed can bus in there system.

Im about to order the DUE, but what other hardware should I order to get me started using the CAN API.
I come from a OO background so I probably will look into AdderD branch of the CAN API, since he mention its a little more structured for OO

I saw earlier post that people are making a shield with SN65HVD243..  I search online a bit and havnt found a place to order these...
What other fun stuff will I need to order ?  And possibly from where if its allowed to be posted ..

Thanks in advance!  Cant wait to get started
Allen

Collin80

I ordered most of my stuff from Mouser. The transceiver chip ends in 234 which is maybe why you can't find it. Here it is at Mouser: http://www.mouser.com/_/?Keyword=SN65HVD234&FS=True

You will need one of those chips for each canbus port (so, two per Due) and some misc other goodies (60 or 120 ohm resistors, small value capacitors, etc). Also, use a schmartboard 1.27mm arduino board which is part # 206-0004-02 (also available at mouser). This board has a place to put the transceiver chips as well as having pins that go into a normal arduino board. It is not the proper size for a Due but you can run jumper wires to the proper pins of the Due. It's sort of a cobble job at the moment but it does work.

#138
Mar 25, 2013, 06:33 pm Last Edit: Mar 25, 2013, 10:01 pm by DarkKnightWong Reason: 1

I ordered most of my stuff from Mouser. The transceiver chip ends in 234 which is maybe why you can't find it. Here it is at Mouser: http://www.mouser.com/_/?Keyword=SN65HVD234&FS=True

You will need one of those chips for each canbus port (so, two per Due) and some misc other goodies (60 or 120 ohm resistors, small value capacitors, etc). Also, use a schmartboard 1.27mm arduino board which is part # 206-0004-02 (also available at mouser). This board has a place to put the transceiver chips as well as having pins that go into a normal arduino board. It is not the proper size for a Due but you can run jumper wires to the proper pins of the Due. It's sort of a cobble job at the moment but it does work.


Hi AdderD

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

Can you recommend a Arduino bread board start kit also ?

Thanks Again
Allen

Thanks for your earlier support AdderD, and the continued development. I've got the Due happily taking data off a 1MHz bus with a DTA ECU and accelerometer spamming it.

Code: [Select]
CAN message received:
13036 0x2000 0x1EFF Ext 8b 0 0 5C 0 14 0 12 0 
13042 0x498 0x1EFF Std 8b 7F CD 7F 4F 88 34 80 7 
13049 0x2001 0x1EFF Ext 8b 64 0 3 2 0 0 11 0 
13055 0x2002 0x1EFF Ext 8b 2C 1 3C 0 79 0 0 0 
13061 0x2003 0x1EFF Ext 8b 0 0 0 0 0 0 0 0 
13067 0x2004 0x1EFF Ext 8b CD E 0 0 0 0 0 0 
13073 0x2005 0x1EFF Ext 8b 0 0 0 0 1F 1 42 3 


Working a treat. I don't suppose anyone knows if there's some industry standard for converting data put out by the ECU to something useable? I know our ECU has 6 data frames (0x2000-0x2005), each 8-byte with 2 bytes for each value (engine rpm, throttle position etc) but not sure if there's a standard way to turn this into something useable (0x5C00 doesn't mean much as an idle throttle position!) or if I'm going to have to ask the ECU manufacturer nicely to give us some help converting.

Palliser

Hello Sherlock3112,

I am very happy seen your progress with Due and CAN.

Based on my experience, most manufacturers of devices/equipment with CAN capability, should have available what is called "CAN matrix" of the correspondent device/equipment. Such CAN matrix should contain, among other things, CAN identifiers, Length, Byte and Bit descriptions, access (read or write only), range, resolution, units, etc.. I believe, a good step for you is to contact the ECU manufacturer. We could make also time to help you but we need from your device at least the Brand, Model and firmware version/revision (if apply). Good luck!

Thanks Palliser. I had a feeling that would be the case, but thought it was worth checking if there was a standard before I call them and look silly. ;)

It's a less-than-common ECU - a DTA fast S series. I'll get on to them tomorrow and try to get a copy of the matrix. All they give us on their site is a basic list identifying which byte(s) of each frame relate to which sensors.

Collin80


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

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.

AJK101

#143
Mar 28, 2013, 06:25 am Last Edit: Mar 28, 2013, 06:57 am by AJK101 Reason: 1
Hey, I bought a due a week ago and tried using can with a device I have.
I checked the family id due was sending yesterday, and saw it to be huge. The docs of the device say it is expecting a 11bit cob id.

Googling it ,I found out  about can v2 having 29 bit ids and can v1 having 11 bit ids. ...  my current assumption is that the device is expecting can v1 while due is using v2
So, any idea how I can make due use v1?

Graynomad

Quote
any idea how I can make due use v2?

Do you mean v1?

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com


Only example 4 in AdderD's code uses extended (29-bit) identifiers. All the other examples use the old standard identifiers. Make sure you're checking against the right variable? The family ID isn't the frame standard/extended id...

The difference is when setting up the mailbox, there's a "true" or "false" at the end of the parameter list - true is extended, false is standard.

Collin80


Hey, I bought a due a week ago and tried using can with a device I have.
I checked the family id due was sending yesterday, and saw it to be huge. The docs of the device say it is expecting a 11bit cob id.

Googling it ,I found out  about can v2 having 29 bit ids and can v1 having 11 bit ids. ...  my current assumption is that the device is expecting can v1 while due is using v2
So, any idea how I can make due use v1?



Family ID is not what the Due sends. Family ID is a special field that allows you to track which sort of frames a receive mailbox is supposed to accept. When sending what matters is the ID you set. As Sherlock3112 said, the end parameter to several of the commands is either true or false. True means use extended addressing, false means don't (use standard addressing.)

For reference, family ID is there just to help you to do fast branching decisions on messages coming in on receive mailboxes. The docs for the processor go into the gritty details of how that works. But, you should be able to pretty much ignore it.

AJK101

Thanks for the replies, AdderD, Sherlock.

I assumed family id to be three id being sent as it started with 1100, which I read somewhere is supposed to be for sdo, which is what I was trying out ...

Anyway, back to my issue, I directly used the example 1 from CAN0 to CAN2, and it worked (with 2 transceivers )

And as I already mentioned, with the device I'm using, it doesn't work

In the docs of the device, only the bits for the frame are, given, and this is the first time I'm using can ...
What I tried was to check all the values of the registers on the can and mailbox structures.

Could you help me out with this? Basically how do I find out exactly what it's sending, what mask is being used while receiving, what is the mall being applied on (full frame from id, or only data, etc) and finally what it's receiving ...

If you'll could help me out, it'd be awesome ... been trying to get the thing work for a week now ..

Palliser

Hello AJK101,
Could you give us more details of your CAN device? Brand, model, firmware version/revision?

Thanks!

Go Up