Read vehicle speed with CANBUS

General discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
kartal_0689
Posts: 8
Joined: 18 Jun 2014 11:59
Contact:

Read vehicle speed with CANBUS

#1 Post by kartal_0689 » 21 Oct 2017 08:41

Hi,

How can I read vehicle speed with the CAN BUS protocol?
I plan to show this data on the LCD screen on my car.
can you give sample code?

Thank you,

Best Regards.

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Read vehicle speed with CANBUS

#2 Post by dusan.poluga » 25 Oct 2017 14:02

Hello,

It should be possible to read the vehicle speed over can if you know what packet contains that information on the can bus.
Unfortunately there are no practical examples showing how this can be done.

Best Regards,
Dusan Poluga.

kartal_0689
Posts: 8
Joined: 18 Jun 2014 11:59
Contact:

Re: Read vehicle speed with CANBUS

#3 Post by kartal_0689 » 25 Oct 2017 16:32

dusan.poluga wrote:Hello,

It should be possible to read the vehicle speed over can if you know what packet contains that information on the can bus.
Unfortunately there are no practical examples showing how this can be done.

Best Regards,
Thanks,

Can I use the "CAN" library in the compiler for this?

Best Regards

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Read vehicle speed with CANBUS

#4 Post by dusan.poluga » 26 Oct 2017 10:41

Hello,

You can use our compiler library as a base configuration for your project.

Best Regards,
Dusan Poluga.

GShettlesworth
Posts: 1
Joined: 14 Jun 2018 20:32

Re: Read vehicle speed with CANBUS

#5 Post by GShettlesworth » 14 Jun 2018 23:54

Wikipedia has an in-depth discussion of the On-Board Diagnostics (OBD-II) and the Parameter Identification Codes (PID's). Using the CAN-Bus, you send the On-Board Computer (OBC) a code with the appropriate Address and PID (e.g.,
0x7DF : Address
0x02 : Two valid bytes following
0x01 : Show Current Data
0x0D : Show Vehicle Speed
0x5555555555 : Filler bytes - ignored
The OBC will respond with an Address and PID in CAN-Bus FrameFormat (8-bytes) e.g.,
0x7EF : Address
0x04 : Four bytes in this response
0x41 : Current Data Snapshot
0x0D : Vehicle Speed
[byte] : Speed between 0-255 Km/h
0x00000000 : Filler bytes - ignore these
Continue querying for updates on the vehicle speed.

Hope this helps - you'll probably need to adjust these values for your specific vehicle, but at least this is the general sequence you'll need to get the data from your car. Good luck.

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 General”