Pages: 1 ... 10 11 [12] 13 14 ... 27   Go Down
Author Topic: Building a CAN API for Arduino DUE  (Read 94274 times)
0 Members and 3 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

jspobuk: I don't want to sound like I'm stating the obvious, but since you say you're new to it then it may have been overlooked.... make sure the serial bitrate in your serial console is the same as the one in the serial.begin line. Without the code to hand I can't be certain, but I don't think there's any "halts" in the code before the first bit of code you post, and mismatched speeds could be a prime culprit there.
Logged

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

jspobuk: I don't want to sound like I'm stating the obvious, but since you say you're new to it then it may have been overlooked.... make sure the serial bitrate in your serial console is the same as the one in the serial.begin line. Without the code to hand I can't be certain, but I don't think there's any "halts" in the code before the first bit of code you post, and mismatched speeds could be a prime culprit there.

Hi Sherlock
Do you have a project thread or some place you post about what your working on

I would like to follow your progress and see how you got it all working
What else do you have planned ?

Thanks
Allen
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

[General]
Hi,
I just found the CAN-bus example for the Atmel SAM3X-EK eval board in the Atmel ASF (similar uC, same CAN-module). There are four examples for sending data to the mailboxes toggling a led. Maybe this will help the starters to help for easier understanding.
Logged

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

Do you have a project thread or some place you post about what your working on

Nope - it's just a simple read CAN, write serial, let computer software make it pretty. Pretty much all the code for the first two parts can be found in the CAN examples palliser and adderd put out with their libs. The only thing left for you to do is put the CAN data into a format you'll be able to extract it at the other end of the serial interface.
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a german project name microcopter, all parts are communicating via I2C. The copter community is so hot for CAN, I'm pretty sure if a copter with CAN-Aerospace on top is built the geeks will greedy snap for it.
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

at the moment I'm testing several CAN examples (Adder + modified ASF example which is very similar). Does it work by simply crossing the lines?
CAN0 TX <-> CAN1 RX
CAN0 RX <-> CAN1 TX
Unfortunately I don't have a transceiver here.


I'm trying to listen to the data stream with a led (have no scope available at the moment), but even with lower speeds it seems the modules are still disabled. Wonder what's going on here.
Logged

nr Bundaberg, Australia
Online Online
Tesla Member
***
Karma: 121
Posts: 8439
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Unfortunately I don't have a transceiver here.
It's a balanced, multi-drop, open drain link, I doubt it will work without transceivers.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

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

Quote
Unfortunately I don't have a transceiver here.
It's a balanced, multi-drop, open drain link, I doubt it will work without transceivers.

______
Rob

You are correct. It won't work without either transceivers or some extra EE magic to make the signals compatible. It's not worth it to try to doctor something up because transceivers are pretty cheap. It's all around best to just get the transceiver chips and use them.
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Right, but after the physical layer with its differential lines we have plain 3.3V to the GPIO - which seems not to work at all. So I simply believe none of the TX lines is fire-breathing at the moment... bummer.
Logged

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

I've been loosely watching this forum but I don't see that anyone has built a "proper" CAN shield yet that comes populated with transceivers? Is that correct?
« Last Edit: April 08, 2013, 03:02:06 pm by tbit » Logged

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

Venezuela
Offline Offline
Sr. Member
****
Karma: 12
Posts: 432
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello tbit,

I have built a couple of DIY pseudo CAN shields that work 'properly'. You can find pictures of them in replies #34 and #61.
I am happy you asked the question because I would also like to see more shields and projects from other users. The people from Arduino, Atmel, the user AdderD and me have invested considerable time to generate a workable CAN API that must be exploited to the full. Arduino Due is now a good platform for automotive application developments. Hope you can joins us.

Regards,
Wilfredo
Logged

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


1. Make sure that the variant files (.c, .h) located in
    ...\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\variants\arduino_due_x\    contains the CAN0 and CAN1 pin definitions.


Palliser,
Number 2 and 3 are an affirmitive, but can you explain in detail where these pin definitions should be at?  I only found DAC0 and DAC1 pins along with the CANRX and CANTX in variant.h

jspobuk: I don't want to sound like I'm stating the obvious, but since you say you're new to it then it may have been overlooked.... make sure the serial bitrate in your serial console is the same as the one in the serial.begin line. Without the code to hand I can't be certain, but I don't think there's any "halts" in the code before the first bit of code you post, and mismatched speeds could be a prime culprit there.


I checked, and both are running at 9600.  So I believe that should be good.  Thanks for the suggestion though, I am new so it's not that obvious. smiley

Thanks
Logged

Pacific Electro-Mechanical Inc. - Honolulu -

Venezuela
Offline Offline
Sr. Member
****
Karma: 12
Posts: 432
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello jspobuk,

Search for the following:

Quote
variant.c    CAN Pin Descriptions

-Lines 234 and 235 contain CANRX0 (68) and CANTX0 (69)
-Lines 281 and 282 contain CANRX1 (88) and CANTX1 (89)
-Line 286 contains function call of all pins in CAN0 (90)
-Line 288 contains function call of all pins in CAN1 (91)

variant.h     CAN Pin Definitions
- Line 157 defines CANRX (68)
- Line 158 defines CANTX (69)
- Line 164 defines CAN1RX (88)
- Line 165 defines CAN1TX (89)
- Line 168 defines PINS_CAN0 (90)
- Line 170 defines PINS_CAN1 (91)

There are other descriptions/definitions for the CAN transceiver pins but if your variant files contain the information above, you have the right variant files.
Logged

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

Palliser - Thank you for the response. I completely agree, I have a bit of background in the automotive industry and see some real potential here with the DUE where the little 8 bit guys didn't quite cut it (especially without an internal controller and DMA).....i hope to contribute. I've just taken a first stab at a DUE protoshield and I plan on spinning a rev to include transceivers. I just ordered some 233's from TI.


* DUEPROTO_STACKED.jpg (1710.12 KB, 3264x2448 - viewed 87 times.)
Logged

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

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,
I adapted the ASF to the SAM8XE (I'm not a big afficionado of the Arduino IDE since it even doesn't has the modest capabilities of c&p-ing stuff from the output window so I use AS 6.0 instead). Still have no transceivers but at least a oscilloscope here...

=> Palliser:
Do you remember you changed some 'special' RX code from the 3X-EK lib for the Due platform? I did some debug stuff but at the moment I'm in a dead end. 

At next CAN1_Handler(void) must bring g_ul_recv_status to log. 1 but no go.


Test1: CAN0 Mailbox 0 transmitting to CAN1 Mailbox 0

All registers in hex:

CAN0->CAN_MR:         1
CAN0->CAN_SR:         610001
CAN0->CAN_BR:         63233
CAN0->CAN_ECR:         0
CAN0->CAN_TCR:         0
CAN0->CAN_TIM:         93C0
CAN0->CAN_WPMR:      0
CAN0->CAN_WPSR:      0

Box 0:
CAN0->CAN_MB[0].CAN_MDL:       11223344
CAN0->CAN_MB[0].CAN_MDH:   55AAAA5
CAN0->CAN_MB[0].CAN_MCR:   0

CAN1->CAN_MR:         1
CAN1->CAN_SR:         610000
CAN1->CAN_BR:         63233
CAN1->CAN_ECR:         0
CAN1->CAN_TCR:         0
CAN1->CAN_TIM:         E8B6
CAN1->CAN_WPMR:         0
CAN1->CAN_WPSR:         0

Box0:
CAN1->CAN_MB[0].CAN_MDL:   0
CAN1->CAN_MB[0].CAN_MDH:   0
CAN1->CAN_MB[0].CAN_MCR:   0

DEBUG: (1) g_ul_recv_status = 0  // => no receiving




« Last Edit: April 10, 2013, 05:49:13 am by Transistorfips » Logged

Pages: 1 ... 10 11 [12] 13 14 ... 27   Go Up
Jump to: