View previous topic :: View next topic |
Author |
Message |
mxkid
Joined: 08 Apr 2008 Posts: 16
|
Controller Area Network CAN Vehicle Diagnostic Software |
Posted: Mon Feb 10, 2014 1:08 pm |
|
|
Hi there,
I was wondering if anyone can help me with a project I'm working on. This is a bit of a step up from the normal projects I do so it’s a bit of a learning curve. I’m trying to get RPM via a vehicle CAN network. I have my PICDEM2 board loaded with an 18F4585 running at 20MHz. For the signal translation I’m using an MCP2551 which is linked directly to the high speed CAN of the vehicle.
I’m going use the EX_CAN software with the header file can-18xxxc.c but am a little unsure how to set a few things up. For example, how do I set the BRGCON registers to get a baud rate to 500kb/s? I’ve looked at the datasheet and I think if I set BRGCON1 to 19 that will equate to 2uS which is 500kb/s but I’m not 100% sure where to go from here.
Also, for a sanity check, the ECU has an address of 07e0 and I need to address the module with a request of 0x0c for the rpm and am expecting a reply of two bytes. So, with the line:
can_putd(tx_id, out_data, tx_len,tx_pri,tx_ext,tx_rtr);
am I correct in setting the registers as follows:
tx_id = 07e0 (send out to address)
out_data = 12 (0x0c for the RPM)
tx_len = 2 (two bytes of data)
tx_pri = 3
tx_ext = 0 (it’s not extended id – should be 11 bit)
tx_rtr = 1
Any help would be great. I think I’m nearly there as I've changed a few things but I don’t want to chase my own tail with a silly setup mistake!
Thanks in advance.
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Mon Feb 10, 2014 1:27 pm |
|
|
Use a tool to help you:
<http://www.bittiming.can-wiki.info/>
Trying to calculate all the timings yourself, is hard work.....
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|