CAN bus receiving

Testing and development of Megasquirt 3

Moderators: jsmcortina, muythaibxr

Post Reply
xrattiracer
Experienced MS/Extra'er
Posts: 301
Joined: Fri Aug 01, 2008 2:25 pm

CAN bus receiving

Post by xrattiracer »

The new CAN broadcasting stuff is great, so easy to work with. There really isn't anything for receiving though, or at least it is very limited.
My current project will have gps and accelerometer data available, which i would like to send to the ms to be logged along with everything else, as well as using the gps module as a rtc. The current CAN receiving seems to be only for pwm and analog values, and a couple specific implementations for other data points. Are there any plans for extending the CAN receiving function to handle these other types of data?
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus receiving

Post by jsmcortina »

I'm glad to hear that the broadcasting is working out for you.

For the receiving, GPS, accelerometer and time are difficult to define in a generic manner. It might be better to define a message protocol for that datatype and have MS3 specifically listen for it. Jean's IO-x can provide that data too, so it could (perhaps) use the same messaging protocol.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
xrattiracer
Experienced MS/Extra'er
Posts: 301
Joined: Fri Aug 01, 2008 2:25 pm

Re: CAN bus receiving

Post by xrattiracer »

yeah i think for now i can send accelerometer as analog values, and try to figure out the jbperf format for the gps and clock. looking around here and jbperf forum for details on that now...
racingmini_mtl
Super MS/Extra'er
Posts: 9130
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada
Contact:

Re: CAN bus receiving

Post by racingmini_mtl »

The format is quite simple and you can find it in the IOx ini file. What is going to be more complex is that you're going to have to implement the Megasquirt CAN protocol so that the MS3 can poll the data from your device.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus receiving

Post by jsmcortina »

Currently yes. In the future though we could define an 11bit broadcast message for that data and bypass the Megasquirt-CAN stuff.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
xrattiracer
Experienced MS/Extra'er
Posts: 301
Joined: Fri Aug 01, 2008 2:25 pm

Re: CAN bus receiving

Post by xrattiracer »

I am most likely not going to be able to implement the MS format, it is just too different from standard CAN to be able to use the existing teensy flexcan library as far as i can tell and my c++ isn't strong enough to go lower level than that. So I guess i will be stuck for now.
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus receiving

Post by jsmcortina »

For reference, the Megasquirt 29bit CAN protocol is documented here:
http://www.msextra.com/doc/pdf/Megasqui ... -10-28.pdf

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
xrattiracer
Experienced MS/Extra'er
Posts: 301
Joined: Fri Aug 01, 2008 2:25 pm

Re: CAN bus receiving

Post by xrattiracer »

I've actually managed to make significant progress on this. Able to decode the 29 bit id into all its component values (unions are really, really cool!). The packets i am sending back dont seem to do anything though, i am probably either decoding the 3 data bytes from the MSG_REQ incorrectly or am sending back bad data.
If I have decoded things correctly, it is wanting 8 bytes, sent to table 14 offset 1178 for the clock. I am not otherwise able to find out if this is correct by looking in various ini files, can anyone else confirm this is correct? (running pre 1.4 alpha 6).
xrattiracer
Experienced MS/Extra'er
Posts: 301
Joined: Fri Aug 01, 2008 2:25 pm

Re: CAN bus receiving

Post by xrattiracer »

had things a little bit backwards, it is working now at table 7 offset 589.
jsmcortina
Site Admin
Posts: 39617
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CAN bus receiving

Post by jsmcortina »

That sounds more like it.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
Post Reply