Pages: [1]   Go Down
Author Topic: CAN BUS shield, Arduino Uno and a Motec M400 ECU  (Read 1719 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Everyone,

I am new to Arduino and I am looking for some help with my current project. I have an arduino uno, the spark fun can bus shield (https://www.sparkfun.com/products/10039) and a Motec M400 ECU powering a car. The ECU has a built in CAN bus which I would like to use to read messages from the ECU with the arduino and display them on an LCD display. I would like to display certain parameters such as speed, rpm, etc on the LCD readout. How should I go about doing this?

I have wired the CAN Bus of the ECU to the the can bus shield and I have connected the shield to my arduino but I don't have any code to test the setup.

I am going to need some code that will read the CAN messages from the ECU and then some code to display these messages on the LCD.

Where should I start, is there a sketch I could use to start reading CAN messages from my ECU?

Thanks for the help.

Let me know if you need any more information.
Logged

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

I found this sample code: http://skpang.googlecode.com/files/Canbus_v4.zip

The problem is that this seems to be for an OBD2 car. I am connecting to a third party ECU. Where could I get some code that would simply monitor the CAN bus to see what messages are being received?

Thanks
Logged

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

Nobody has any idea of a sketch that would allow me to monitor incoming CAN data?
Logged

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

There are people writing CAN code for the Due, maybe they have some idea.

http://arduino.cc/forum/index.php/topic,131096.0.html

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

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

Yeah but I need to eventually put this on an Uno or a mini.
Logged

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

Bump
Logged

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

I have a document from Motec that defines the message structure. You'll mostly need this once you have got you arduino code to read basic CAN messages etc.

On the M400 you need to define the data sets 1 & 2, then configure it to send the data set(s) to CAN device on address XXX. The format can be one of "CRC32", "compound", or "squential". The doc I have describes these three formats and also give hints as to the data scaling, injector time might be in units of micro seconds etc.

Also download the Motec SDL3 (or ADL etc) software as this has the "templates" for read the CAN data and will list the scaling such as data width (8 v16 bit) whether its signed etc etc.

If you think the motec doc is of interest, let me know where to email to...

A
Logged

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

I've tried almost exactly what you wanted, using a sparkfun canbus shield and an uno to read M800 msgs. I had the problem of missed can msgs. I'm guessing it's because the uno just isn't fast enough. Considering Uno runs at 16Mhz, SPI to the shield is at 4mhz and the can bus itself is 1mhz. This doesn't leave a lot of time for processing msgs. Then again, it might be because of my crappy code. I'm currently trying the Due which has a cpu clock of 84mhz and has a onboard can controller which eliminates the SPI bottleneck but it's slow progress...
Logged

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

Hi James
Since reading this thread, its renewed my interesting in using the M400 CANbus.
Im using the mbed NXP LPC1768 which running at 96Mhz seems to be able to keep up with the M400 as long as the "data set" is too large.
Using the Motec CRC32 format which basically send a seq of N + data items/4 CAN frames, you need a complete set of frames to be able to decode data set and validate the CRC.
Im going to investigate the other Motec formats (sequencial and compund) as with these each frame contains enough infomation to decode the application data, even if the odd frame is "lost". Its amazing to thing that this Motec ECU must be 10+ old technology, but still manage to pack a lot of fast (efficient processing in :-) )
Im sure someone with better coding skills than me could easily make the mbed keep up with the Motec CAN stream, but for my projects I can get away with "sloppy" code running on a over the top fast processor...
Anyway, would be interested to hear how you get on with the faster model Arduino and maybe swap notes at some point.

Heres a brief list of what I have managed to do wrt M400 CAN so far:
Decode CRC32 data and write it to local flash (tested with Motec sending 12channels at 100Hz)
Send data in to the Motec M400 in Compound format (eg as per an ADL etc)

Just a tip for when youre testing this out, try sending the Motec Runtime channel. Its basically a timer running in units of 0.1seconds. If the Motec is sending a dataset at a rate of 100Hz, you should see every 10 datasets received have the same value for the Runtime data item. You can vary the dataset rate from 33-200Hz on the Motec.
Logged

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

Hi Guys,

I am glad I decided to check back to this post, nice to know others are trying the same type of project. Cat7 I could really use the document you are talking about, I will PM you my e-mail.

I will be trying my luck this weekend so I will report back with any findings.
Logged

Pages: [1]   Go Up
Jump to: