CANbus to Instruments etc. working

This forum is for the discussion of other projects on Megasquirt/Microsquirt hardware that don't fit into any of the other forums

Moderators: jsmcortina, muythaibxr

acab
Experienced MS/Extra'er
Posts: 243
Joined: Tue Aug 21, 2012 5:52 am

Re: CANbus to Instruments etc. working

Post by acab »

Does that code right in ms2_extra_can.c for 500kBit/s?

Code: Select all

    /* Set timing for .5Mbits/ sec */
    CANBTR0 = 0xC2;  /* SJW=4,BR Prescaler= 3(24MHz CAN clk) */
    CANBTR1 = 0x1C;  /* Set time quanta: tseg2 =2,tseg1=13 
                        (16 Tq total including sync seg (=1)) */
I found some info about it in Application Note AN3034. And correct is:

Code: Select all

/* Set timing for .5Mbits/ sec */
CANBTR0 = 0xC2;  /* SJW=4,BR Prescaler= 3(24MHz CAN clk) */
CANBTR1 = 0x58; /* Tseg2 = 6, Tseg1 = 9 (Tseg1 + Tseg1 + Sync(=1) = 16 => 8 Mhz / 16 = 0.5 Mhz */ 
Or i make mistake?
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CANbus to Instruments etc. working

Post by jsmcortina »

I believe that there are a number of different settings that can achieve the same result from my recollection of reading the datasheet. Have you scoped the outputs from the two settings and compared them?

What is leading you to question the existing setting?

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".
racingmini_mtl
Super MS/Extra'er
Posts: 9128
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada
Contact:

Re: CANbus to Instruments etc. working

Post by racingmini_mtl »

And you still haven't posted what your problem is with the alpha code. Is there a reason why you don't want to help debug the code? That is a really annoying attitude; if everyone did that, the development would have been a disaster.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
acab
Experienced MS/Extra'er
Posts: 243
Joined: Tue Aug 21, 2012 5:52 am

Re: CANbus to Instruments etc. working

Post by acab »

racingmini_mtl wrote:And you still haven't posted what your problem is with the alpha code. Is there a reason why you don't want to help debug the code? That is a really annoying attitude; if everyone did that, the development would have been a disaster.

Jean

I post it later in topic with bugs of alpha code. In shortly - all coils work in same time.



What about CANBTR0 and CANBTR1?

On oscilloscope i can see something on CAN (packets). But i cant sniff it on my CAN-USB dongle. If i understand - problem in speed of CAN.
Peter Florance
Super MS/Extra'er
Posts: 3653
Joined: Fri Apr 02, 2004 8:40 pm
Location: Virginia Beach, VA
Contact:

Re: CANbus to Instruments etc. working

Post by Peter Florance »

I've modified (badly) the MS3 Beta code to drive a BMW (Seimens) instrument cluster based on data on this thread.
http://forums.bimmerforums.com/forum/sh ... ?t=1887229

The BMW dash seems to use 500kb/second.

It does work, despite my poor programming skills.

http://www.youtube.com/watch?v=U7GoQ28ghKY

One question, the tachometer wants a minimum 20msec update rate. I modified the ini file to allow 20msec rate.

Any issue with a transmission rate that high on MS3?

Thanks!
Peter Florance
PF Tuning
81 BMW Euro 528i ESP Car
60-2 Wheel LS2 Coils, Low Z Inj
Co-Driver 1999 BMW E46 DSP car.
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CANbus to Instruments etc. working

Post by jsmcortina »

Sounds good Peter. 20ms should be ok. Check your "mainloop time" - this is the time in microseconds that each mainloop pass is taking. So long as the mainloop time is significantly less than 20ms you'll be ok. I've only seen it anywhere close (10ms?) when testing the code with all options enabled and a 60-2 and high rpms.

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".
acab
Experienced MS/Extra'er
Posts: 243
Joined: Tue Aug 21, 2012 5:52 am

Re: CANbus to Instruments etc. working

Post by acab »

This is my Alfa Romeo Dashboard

Its work, but i have some questions about CANBTR0 and CANBTR1.
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CANbus to Instruments etc. working

Post by jsmcortina »

[quote="acab"but i have some questions about CANBTR0 and CANBTR1.[/quote]
Did you read my answer?

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".
acab
Experienced MS/Extra'er
Posts: 243
Joined: Tue Aug 21, 2012 5:52 am

Re: CANbus to Instruments etc. working

Post by acab »

jsmcortina wrote: Did you read my answer?

James
Yes, i read your post...
But i didnt know, wich settings are right.
Peter Florance
Super MS/Extra'er
Posts: 3653
Joined: Fri Apr 02, 2004 8:40 pm
Location: Virginia Beach, VA
Contact:

Re: CANbus to Instruments etc. working

Post by Peter Florance »

I did not have to change the CAN data rate to work with BMW; which is 500K
Peter Florance
PF Tuning
81 BMW Euro 528i ESP Car
60-2 Wheel LS2 Coils, Low Z Inj
Co-Driver 1999 BMW E46 DSP car.
acab
Experienced MS/Extra'er
Posts: 243
Joined: Tue Aug 21, 2012 5:52 am

Re: CANbus to Instruments etc. working

Post by acab »

Peter Florance wrote:I did not have to change the CAN data rate to work with BMW; which is 500K
Hmmm, strange.


I think my CAN transiever in MS2 is bad :oops:
Peter Florance
Super MS/Extra'er
Posts: 3653
Joined: Fri Apr 02, 2004 8:40 pm
Location: Virginia Beach, VA
Contact:

Re: CANbus to Instruments etc. working

Post by Peter Florance »

acab wrote:
Peter Florance wrote:I did not have to change the CAN data rate to work with BMW; which is 500K
Hmmm, strange.


I think my CAN transiever in MS2 is bad :oops:
Can your Arduino read it?
Peter Florance
PF Tuning
81 BMW Euro 528i ESP Car
60-2 Wheel LS2 Coils, Low Z Inj
Co-Driver 1999 BMW E46 DSP car.
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: CANbus to Instruments etc. working

Post by jsmcortina »

It is rare for the CAN transceiver to be faulty. You haven't answered this previous reply.
jsmcortina wrote: Have you scoped the outputs from the two settings and compared them?
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".
acab
Experienced MS/Extra'er
Posts: 243
Joined: Tue Aug 21, 2012 5:52 am

Re: CANbus to Instruments etc. working

Post by acab »

Peter Florance wrote:
Can your Arduino read it?
I have CAN-USB dongle. I cant connect and sniff data ;(
jsmcortina wrote:It is rare for the CAN transceiver to be faulty. You haven't answered this previous reply.
jsmcortina wrote: Have you scoped the outputs from the two settings and compared them?
James

Not yet... Can you explain about it?
Peter Florance
Super MS/Extra'er
Posts: 3653
Joined: Fri Apr 02, 2004 8:40 pm
Location: Virginia Beach, VA
Contact:

Re: CANbus to Instruments etc. working

Post by Peter Florance »

acab wrote:
Peter Florance wrote:
Can your Arduino read it?
I have CAN-USB dongle. I cant connect and sniff data ;(
jsmcortina wrote:It is rare for the CAN transceiver to be faulty. You haven't answered this previous reply.
jsmcortina wrote: Have you scoped the outputs from the two settings and compared them?
James

Not yet... Can you explain about it?
should look like this; CANH is blue, CANL is red

Image

Edit, if hotlink doesn't work, it is here:

http://www.picoauto.com/showpicauto.php ... form_1.jpg
Peter Florance
PF Tuning
81 BMW Euro 528i ESP Car
60-2 Wheel LS2 Coils, Low Z Inj
Co-Driver 1999 BMW E46 DSP car.
acab
Experienced MS/Extra'er
Posts: 243
Joined: Tue Aug 21, 2012 5:52 am

Re: CANbus to Instruments etc. working

Post by acab »

Tnx for post, Peter!


I attach oscilope and i see waweform... But i think i cant get right speed of CAN BUS;(
Peter Florance
Super MS/Extra'er
Posts: 3653
Joined: Fri Apr 02, 2004 8:40 pm
Location: Virginia Beach, VA
Contact:

Re: CANbus to Instruments etc. working

Post by Peter Florance »

jsmcortina wrote:Sounds good Peter. 20ms should be ok. Check your "mainloop time" - this is the time in microseconds that each mainloop pass is taking. So long as the mainloop time is significantly less than 20ms you'll be ok. I've only seen it anywhere close (10ms?) when testing the code with all options enabled and a 60-2 and high rpms.

James
Right now the gauge shows 23 ms at 7300 rpm (60-2 & cam)
If I turn off CAN broadcasting, it doesn't really change from 23 ms.

At 1000 rpm mainloop is about 12ms, with or without CAN broadcast turned on.
Peter Florance
PF Tuning
81 BMW Euro 528i ESP Car
60-2 Wheel LS2 Coils, Low Z Inj
Co-Driver 1999 BMW E46 DSP car.
Peter Florance
Super MS/Extra'er
Posts: 3653
Joined: Fri Apr 02, 2004 8:40 pm
Location: Virginia Beach, VA
Contact:

Re: CANbus to Instruments etc. working

Post by Peter Florance »

Peter Florance wrote:
jsmcortina wrote:Sounds good Peter. 20ms should be ok. Check your "mainloop time" - this is the time in microseconds that each mainloop pass is taking. So long as the mainloop time is significantly less than 20ms you'll be ok. I've only seen it anywhere close (10ms?) when testing the code with all options enabled and a 60-2 and high rpms.

James
Right now the gauge shows 23 ms at 7300 rpm (60-2 & cam)
If I turn off CAN broadcasting, it doesn't really change from 23 ms.

At 1000 rpm mainloop is about 12ms, with or without CAN broadcast turned on.
Oops, I can't read.
It is 2.3ms

Sorry!
:oops:
Peter Florance
PF Tuning
81 BMW Euro 528i ESP Car
60-2 Wheel LS2 Coils, Low Z Inj
Co-Driver 1999 BMW E46 DSP car.
NArcher
Helpful MS/Extra'er
Posts: 55
Joined: Wed Mar 23, 2011 1:38 pm

Re: CANbus to Instruments etc. working

Post by NArcher »

For some reason, I do not have the 120 ohm resistor in my MS3 (V3.0 board, followed all instructions in the manual). My rpm gauge is lagging behind by about 1 - 2 seconds. Is it because the resistor is missing? The gauge cluster has the resistor installed and as I understand it, you need a resistor on each side of the bus to act as a terminator. I will check this for myself later, just wanted to get confirmation.
NArcher
Helpful MS/Extra'er
Posts: 55
Joined: Wed Mar 23, 2011 1:38 pm

Re: CANbus to Instruments etc. working

Post by NArcher »

Sorry, another CAN question.

I have an ABS computer that I would like to receive the data from and pass to the vss to get speedo to work. Which part of the code do I have to modify to make this work. I am [also] a poor programmer :cry: but am continuously learning! :RTFM:
Post Reply