Pages: 1 ... 27 28 [29]   Go Down
Author Topic: Building a CAN API for Arduino DUE  (Read 130757 times)
0 Members and 1 Guest are viewing this topic.
Earth
Offline Offline
Sr. Member
****
Karma: 14
Posts: 331
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops, I did miss that bug in your code. The data line should be:

myFrame.data.bytes[0] = 0xFF;

The data member of the structure is a union full of different types of access patterns so you can access it by byte, by 16 bit int, by 32 bit int, or by 64 bits all at once.
Logged

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

thank you Collin,
i compile and run this code and im watching the arduino's can ports via my logic analyzer.
after the reset i can see the initalize logic levels, after init, tx ports high , rx ports staying low positions and nothing more smiley-sad
i didnt connect my transceiver chips yet. logic analyzer directly connected to can tx -rx pins directly
why i cant see the id and data
when i connect my logic analyzer to my can bus data logger's ports i can see the all id and data but arduino doesnt work smiley-sad


i think you might be busy but i need really help collin smiley-sad thank you again
warm regards


* NOT WORK.PNG (206.32 KB, 1357x755 - viewed 85 times.)
Logged

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

To help narrow it down you should try two things:

1. Compile and run one of the example sketches that sends data. The pingpong sketch should be fine for this. It should immediately saturate the bus with attempts to deliver frames.
2. You don't happen to have another Due do you? (I'm doctor Suess now)
Logged

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

Hi

Thanks a million for this thread makes everything much easier, i have a question which is of the options below is viable with due arduino and which one would be best with an arduino ethernet shield.

http://www.ti.com/product/sn65hvd233

http://www.wvshare.com/product/SN65HVD230-CAN-Board.htm

http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010405

Thanks for your help this will help me with my project

manewc
Logged

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

Manewc,

The first two use the SN65HVD23X transceiver (where X is 0,3,4, etc). That transceiver will work fine. I really wouldn't recommend using the MCP2551 as it assumes a 5V tolerant MCU which the Due is not. If you are building a one-off prototype then the second link with a breakout board would probably be ideal. But, if you're going to use another board like an ethernet shield, then you might be able to add the bare SN65HVD chip on a prototyping section. All the ethernet shields I found don't have such an area though.
Logged

United States
Offline Offline
Newbie
*
Karma: 0
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My thanks again to Collin and Palliser!

I've built a number of these boards for a project but placed my clamping diode incorrectly and will have to run them again. They are perfectly fine for someone that won't be going over the 36V input range ever.  I think they would be quite nice for someone who is looking to tinker and wants a stable platform to do so.

It has placements for a 9-36V input, a pheonix contact push in connector for powre and CAN, a multi dip switch and all the caps. I've used it with the arduino due and the DigiX due clone with great success. Also dual ethernet.

I've soldered it all by hand so you shouldn't need to be too scared of it.

If someone is interested let me know. dimensions are 4.4" square.

Logged

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

Many thanks to Collin, Palliser and everyone else that has contributed to this library.  I am working on a project that will have up to 22 nodes on a single bus.  Without this library I don't think I could attempt this with my limited knowledge.

I have a couple of questions that hopefully someone could comment on.

1. I want to isolate each node on the bus.  This is because the bus length will be up to 100m and each node will have it's own power supply (230VAC at each node).  So far my testing has been using the SN65HVD234 transceivers and they work very well.  But to isolate each node I'm thinking that I'd need to either us some optocouplers between the transceiver and micro controller or change to a different transceiver.  I quick Google turns up the ISO1050 which is available locally.  Here's the datasheet:
http://www.ti.com/lit/ds/symlink/iso1050.pdf
 Am I on the right track?  Has anyone else done something similar?

2. Can the due_can library be used with the AT90CAN series of micro controllers?
Logged

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

1. I want to isolate each node on the bus.  This is because the bus length will be up to 100m and each node will have it's own power supply (230VAC at each node).  So far my testing has been using the SN65HVD234 transceivers and they work very well.  But to isolate each node I'm thinking that I'd need to either us some optocouplers between the transceiver and micro controller or change to a different transceiver.  I quick Google turns up the ISO1050 which is available locally.  Here's the datasheet:
http://www.ti.com/lit/ds/symlink/iso1050.pdf
 Am I on the right track?  Has anyone else done something similar?

Good thinking. The ISO1050 works fine with the Due and with the due_can library. I do have experience with this. The GEVCU project has several (> 50) boards out in the field with that exact transceiver. We haven't blown up the transceiver or board yet.

Quote
2. Can the due_can library be used with the AT90CAN series of micro controllers?

No. The AT90CAN series of processors are 8 bit AVR processors and this library is meant specifically for the 32 bit ARM Cortex M3 processor in the Due.
Logged

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

Hi there,

I'm trying to get an Arduino Due to work with my car but init functions always returns 0 when the transcreceiver is connected to the cars bus system.
I'm using a transcreceiver board with the SN65HVD230 chip (http://www.wvshare.com/product/SN65HVD230-CAN-Board.htm). As far as I understood this thread it should work with the library here.

I guess the main problem is that the cars bus is working at 100Kbit/s while this library doesn't seem to support it.
At least in the due_can.h there are only higher or lower values, so I added a line for 100Kbit/s.
Code:
#define CAN_BPS_100K                  100000
I found out that the CANRaw::set_baudrate functions seems to work out and it does return 1. But I'm not realy sure if the can_bit_time array has the right values for the desired speed.
I understand some of the code but as a java and .net programmer c(++) code is pretty hard to understand for me (especialy the bit-shifting ... smiley-eek).

So maybe someone here could help me out and tell me if the code should work with 100Kbit/s or if it needs some modification. If it does it would be great to get some hints for the right direction  smiley.

Edit: I forgot to mention that I removed the 120 Ohm resistor on the board already since this is not the start/end point of the bus.
« Last Edit: September 07, 2014, 12:15:28 pm by g4rb4g3 » Logged

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

Yes, all of that should work fine. There is an array for bit timing but it isn't directly tied to the actual canbus speed. In theory you should be able to set any canbus speed. But, some speeds will not be possible to exactly reach. I'd imagine that 100k baud wouldn't be a problem. But, if you try to set it to 46,247 baud you'll probably have trouble.
Logged

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

I can confirm that it does work fine at 100k, I tested this in my car on the infotainment bus which runs at that speed.
Logged

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