Building a CAN API for Arduino DUE

Palliser:
Hi that_kid. I am sorry to know about your broken foot. Just take it easy. Even thou I have my shield working OK, I still looking for a better out-of-the-shelf board that fits better the design. I am also working on some eagle files to build, at some time, my own design. Remember that for the two transceiver we are going to need 8 pins of the Arduino DUE (CANRX0, CANTX0, CANEN0, CANRS0, CANRX1, CANTX1, CANEN1, CANRS1). For my tests, I didn't use the EN and RS pins. I just connected them to +3.3 and ground respectively.

Thanks Palliser, I was also thinking of building my own board as well. I have some other parts I want to add for other functions from the DUE. In the meantime I'll just get a small board that I can mount the transceivers to for testing. The good thing about not being able to move around much is that I can think more about my designs.

Hi All,
I'm very excited about this project and I'm constantly watching this thread for news and source.
BTW what we did here [Q]: Tailoring the Due to Eclipse.. - #32 by system - Arduino Due - Arduino Forum may be very helpful for the project Have a look.
I'm planning to use a debugger too with the arduino , but that is still a working in progress.
Happy new year at everyone
Zad

For those that already have in mind an automotive application for the Arduino Due and the almost ready for release CAN API, while it seems to be too early, I believe is timely for them to start seeking out as much information as possible of the CAN protocol of their vehicles and get familiar with it. For example, the specific type of CAN standard and some specifications like CAN identifiers, Bit rate, message type (default 11-bit identifier?), data format, range definition, etc... I must say, during some tests, often, I had to stop my test and spend a considerable amount of time searching for needed CAN info. Oh, I forgot: try to get an OBD-II male connector (plug) and where is the OBD-II connector located in your car (Most are located under the steering column).

I wanted to show, briefly, how I started building my second DIY pseudo CAN shield. I decided to use two SN65HVD235 transceivers in order to compare them with the two SN65HVD234 I used in my first shield. For these 235s I also used a different SchmartBoard: The model 206-0004-01, and instead of keep it intact, I did cut it. Here a picture of the two 235s soldered in the SchmartBoard, with pin headers and a pinout.

*WARNING: This pinout corresponds to the SN65HVD234 transceivers. Not the 235 ones

I wanted to present it here, for those that have not started yet their shield, as an example to be followed using the previous schematic I published in this post. Even thou 234 and 235 transceivers are very similar, differ in the pin 5. For the 234 this pin corresponds to EN (enable) for an ultralow-current (50-nA) sleep mode and for the 235 this pin 5 corresponds to AB that implements a bus listen-only loopback which allows baud rate synchronization.

Notice that this second CAN shield, more than a shield, will work as a side car (alone or inserted in a bread board) unlike the first one which is a true shield. I made it that way to avoid soldering work. I hope to be uploading more pictures of my progress with it.

Nice, I'm going to try my hand at making my own surface mount board. I need to get my hands on a laser printer first. For testing I'll start with making a board just to hold the tranceiver. If all goes well I can have the trancievers plus the other components I need for my project.

Hello that_kid. I hope your foot is doing better. Here another picture of my second DIY pseudo CAN shield and a brief comparison between the two shields:

SHIELD ADVANTAGE DISADVANTAGE
#1 Compact Prone to hot spots (soldering)
#2 Easy-to-assemble Bulky and messy

Hello Palliser the foot is coming along. I'm now able to walk on it but I still have the boot on my foot, still it feels good to be on both feet again. I see you got your second DUE, while gathering the things I need for my board I'm also working on learning more about Arduino programming. I should be good and ready by the time I'm able to move around more.

Palliser:
Hello that_kid. I hope your foot is doing better. Here another picture of my second DIY pseudo CAN shield and a brief comparison between the two shields:

SHIELD ADVANTAGE DISADVANTAGE
#1 Compact Prone to hot spots (soldering)
#2 Easy-to-assemble Bulky and messy

I think I'll be building an interface in the near future -so will be following this thread closely. I've messed about with CAN decoding in the past - using USB can interfaces ( Lawicwl CanUSB), and various monitoring / message filtering software. I hate being locked out of my car's software, so using DUE as a smart interface makes sense.
The mixture of 11 & 29 bit messages (and several different bus speeds) makes life pretty complex, and given that vehicle manufacturers like to hide useful features.. lets hope the energy & problem solving in the Arduino community can cut through the BS :slight_smile:
Lawicel do an AVR/CAN adapter, with some sample code available.
Also worth looking at : http://rbei-etas.github.com/busmaster/
With some contributions from Bosch - who started it all... open source code on github.
looking forward to see what libraries develop!

Graeme

Hi everybody!

I`m quite new to the Arduino world, but not to the uC world. I'd like to collaborate as much as possible with the development of the CAN API for the Arduino DUE. I actually have several DUE and other Arduino boards (with the necessary shields) and USB CAN interfaces, as well as other applications that are extensively using CAN BUS.

I'm very sorry of not having been able to start collaborating with you earlier, but I really would like to help as much as possible in any task you give me.

Cheers!

Lufe

lufegimenez:
Hi everybody!

I`m quite new to the Arduino world, but not to the uC world. I'd like to collaborate as much as possible with the development of the CAN API for the Arduino DUE. I actually have several DUE and other Arduino boards (with the necessary shields) and USB CAN interfaces, as well as other applications that are extensively using CAN BUS.

I'm very sorry of not having been able to start collaborating with you earlier, but I really would like to help as much as possible in any task you give me.

Cheers!

Lufe

Except we can't contribute or do anything, it's really fun this way...

zabaat,
What you're saying is partly true, until the new CAN library is published. The Atmel engineer that developed a prior CAN API for the SAM3X8H, is supporting Arduino with this CAN interface for Due. Once the library is on github, everyone should start to test/discuss/contribute. And I say partly because at this very moment people in this forum could be contributing, let's say, with the design of the shield. Electric schematics have been published here. I have also shown a couple of my shield approaches. What I would like to hear in this post is: My pseudo CAN shield is ready. Here a picture of it, but I have yet to see any of them here. Does that really matter? Yes, because otherwise, you can't do any test or discuss or contribute just with the sketch or the classes. Am I right?

Palliser:
zabaat,
What you're saying is partly true, until the new CAN library is published. The Atmel engineer that developed a prior CAN API for the SAM3X8H, is supporting Arduino with this CAN interface for Due. Once the library is on github, everyone should start to test/discuss/contribute. And I say partly because at this very moment people in this forum could be contributing, let's say, with the design of the shield. Electric schematics have been published here. I have also shown a couple of my shield approaches. What I would like to hear in this post is: My pseudo CAN shield is ready. Here a picture of it, but I have yet to see any of them here. Does that really matter? Yes, because otherwise, you can't do any test or discuss or contribute just with the sketch or the classes. Am I right?

Oh, I guess I was waiting the same way, thinking what use is a can shield in my efforts to contribute to the testing when I have no sketch or classes. Since it's now clear that is what I need to do to get access. I will build the shield as you have listed and post it's picture. I have had 20 of the chips and 4 Dues for a couple weeks now, definitely would have built this had I known.

I already posses a good understanding of the protocol, USB-CAN adapters and debugging software tools to tackle this. I even have a project that needs it.

I would suggest making a closed project at least for people that understand it is in beta stage so you can control the feedback you get.

I'm in the same position as Zabaat.

I'll build the Pseude shield ASAP and post pics. Maybe I try out another HW solution from the IC I have right here. I would also like to be collaborating with a beta release and feedback you directly.

Cheers

Lufe

lufegimenez:
I'm in the same position as Zabaat.

I'll build the Pseude shield ASAP and post pics. Maybe I try out another HW solution from the IC I have right here. I would also like to be collaborating with a beta release and feedback you directly.

Cheers

Lufe

Lufe - I'm working to build a better "industrial protocol" arduino board, integrating modbus / rs232 (12v) and CAN and 2x Due chips. I just saw Palliser's ethernet addin and am debating adding that in by exposing those pins off of the dues for future expansion for profinet if possible. Is this something you would be interest in collaborating in?

Hola Lufe.

Your CAN experience will surely be very useful. As I mentioned in my first CAN post, my humble role is to channel the efforts to let the CAN API be completed. So far, I must say, it has been more a behind-the-forum work between Arduino, Atmel and me. Tests are in progress; the CAN library is working using the IDE directly (no makefile) and we are close.

From all of this, we have learned a big lesson: DO NOT (I repeat) DO NOT try to build something from Atmel Studio ASF and introduce it into Arduino. Both software architectures are entirely different and it shall be a pain to remove unneeded references. This experience is helping us to understand better how to create a Due library. The updated libsam will be solid ground for future developments for Due. Saludos!

Palliser:
Hola Lufe.

Your CAN experience will surely be very useful. As I mentioned in my first CAN post, my humble role is to channel the efforts to let the CAN API be completed. So far, I must say, it has been more a behind-the-forum work between Arduino, Atmel and me. Tests are in progress; the CAN library is working using the IDE directly (no makefile) and we are close.

From all of this, we have learned a big lesson: DO NOT (I repeat) DO NOT try to build something from Atmel Studio ASF and introduce it into Arduino. Both software architectures are entirely different and it shall be a pain to remove unneeded references. This experience is helping us to understand better how to create a Due library. The updated libsam will be solid ground for future developments for Due. Saludos!

Some good news some bad news, good to hear but can you explain the part from "Not trying to port Atmel Studio ASF to Arduino Software architecture a little bit more for me for better understanding.

zabaat:
Lufe - I'm working to build a better "industrial protocol" arduino board, integrating modbus / rs232 (12v) and CAN and 2x Due chips. I just saw Palliser's ethernet addin and am debating adding that in by exposing those pins off of the dues for future expansion for profinet if possible. Is this something you would be interest in collaborating in?

Zabaat (and everybody else too, of course)

I'm developing for several projects I'm involved in a multifunctional shield with RS485, TTL UART, CAN BUS, TTL digital GPIO, discrete open-ground outputs, relay module and Analog Input port, for the MEGA board.
CAN BUS is based on MCP2515 IC, but I would absolutely prefer to use an internal CAN peripheral, therefore I'm following very closely the evolution of the Due board. Testings of this board will start middle February and if everything goes ok, I'll be presenting it soon.

As I told in my introduction, I'm not an Arduino expert nor a programmer guru, but I really would like to collaborate with any interesting project like the one you are presenting.

Estimado Palliser
I'm looking forward to test as soon as possible this CAN library. Being able to have direct access to CAN from a CortexM3 processor... :stuck_out_tongue_closed_eyes: this sounds sooooo good!!!
I'll get today all my 3.3V CAN transceivers, I'll mount them tomorrow or Monday and I will have my DUE CAN test bench available for you!

Cheers

Lufe

Lufe,
Thank you. I will be waiting to see your shield!

Markus,
I am being the spokesperson of the Atmel engineer who is supporting us, and Massimo (of course). As you may know, I ported the CAN files from ASF to Arduino IDE
but, because of the AFS structure, it took over 20 files to make the interface run. This is not under the Laws of Arduino. Arduino should be simple, beautiful. All the time, in this post. Massimo's retort has been: use few files.
For this project, Atmel is using some non-ASF drivers they had before the ASF era. They explained to me that if we include any ASF based file in the project, there will be needed to add thousand others. I know you did a great job with your RTC Library but in the case of the CAN class, more references need to be considered.

Hello all, firstly I am new to Arduino, but am eager with the anticipation of Canbus for the Due as it will serve my application well.

While I can understand why some of you may require a shield to provide easy connectivity with a Canbus interface and the arduino due, could I ask what would be wrong with using something such as the below link for a canbus development module that appears to be quite cost effective to me + my application? I presume it would still work with the upcoming Due library?

SN65HVD230 CAN Board Network Transceiver Evaluation Development Module Kit 3.3V

To those developing the canbus library, keep up the good work, your efforts will very much be appreciated I'm sure as it will bring the simplicity of the other numerous other libraries to this very capable processor.

(not to be pushy, but do we have a timeline of when we may see a beta library, or an initial issue?)

Thanks in advance
Rob

Hello Rob and thank you for your encouraging words!

I checked the electric schematic of the SN65HVD230 based board you mentioned. It can work with the CAN library but in a direct mode. I mean, pin 8 (Rs) is been underused and fixed to ground (high-speed mode). The CAN library contains the SN65HVD234 component data conforming to Arduino API that will be sub-utilized too (I think you don't want to port the manufacture ones).

I would recommend it only for tests purposes, but for your application, you will surely want to migrate to 234 to take advantage of the Due libraries for ultra-low current sleep mode. Additionally, the missing filter and buffer capacitors should be needed if distance between Due and CAN device increases.

In case you decide to get it, I would also recommend to get two for loop tests of the CAN controllers. Notice that the manufacturer's (Wave Share) price differs considerably from the vendor's (DX) (Russian?). By the way, I don't see the 120 ohm terminal resistor in the photos. Only the 10K, I think. Regards!

Here the schematic of the SN65HVD230 based board you mentioned.