Go Down

Topic: MCP_CAN_lib on a CAN-BUS Shield (Read 452 times) previous topic - next topic

johnjudge01

I am using a Sparkfun CAN-Bus shield to talk to an ultrasonic module from a GM vehicle. I have found the MCP_CAN_lib and wrote the following code to send CAN signals that I have recorded in the vehicle. But the module is not responding the way I think it should to the signals sent. When I try to check if the message is being sent, I get an error code of 7. A 7 is #define CAN_SENDMSGTIMEOUT (7). Not sure why the message is timing out.

 

mikb55

Do a loopback test to check that the Tx/Rx functionality is working.
Take a photo showing how things are connected.
Provide a link to the datasheet for the sensor.

johnjudge01

#2
Sep 09, 2018, 05:30 pm Last Edit: Sep 09, 2018, 05:35 pm by johnjudge01
Quote
Do a loopback test to check that the Tx/Rx functionality is working.
The loopback show it will send the first can id 0x100 and the last 0x10242040

Quote
Take a photo showing how things are connected. Provide a link to the datasheet for the sensor.
There is no "data sheet" on the sensor. It is a system out of a vehicle with four ultrasonic sensors connected to a module and that module outputs a can signal that operates at 33.33kbs GM signal wire can. I have the signal wire can wired to the high port on the board and the low and ground to the ground of the 12-volt power supply that is powering the module.

johnjudge01


coryjfowler

Do you have any termination enabled or added to the bus you created between the shield and sensor?
"Taking the time to make a proper, punctuated, post is a mark of courtesy and respect."  http://forum.arduino.cc/index.php?topic=149022.0

johnjudge01

No there is no added termination and I did not know there could be any enabled termination. How do you tell if it is enabled and how to disable it?

coryjfowler

How do you tell if it is enabled and how to disable it?
I would start at the schematics for your hardware.

As for the termination, I do not have any prior experience with Single Wire CAN and my little bit of research suggests that most Single Wire CAN transceivers require a ~7kΩ resistance from BUS to LOAD or in your case CAN_H to GND.  It is likely this resistance will get communications going for you.
"Taking the time to make a proper, punctuated, post is a mark of courtesy and respect."  http://forum.arduino.cc/index.php?topic=149022.0

johnjudge01

I have never heard of a 7k ohm resistance from Bus to load. I have heard 120-ohm resistance.

johnjudge01

this is the hardware. pin 6 is can. not much too it. sensors are on another harness.

coryjfowler

#9
Sep 15, 2018, 05:37 am Last Edit: Sep 15, 2018, 05:38 am by coryjfowler
I have never heard of a 7k ohm resistance from Bus to load.
Here is a datasheet for a Single Wire CAN transceiver.  https://www.nxp.com/docs/en/data-sheet/MC33897.pdf
Page 15 has an application circuit which shows a 6.49k resistor.

I have heard 120-ohm resistance.
Which is for CAN using a differential pair.
"Taking the time to make a proper, punctuated, post is a mark of courtesy and respect."  http://forum.arduino.cc/index.php?topic=149022.0

johnjudge01

So a asked someone in the department that works on this module what do they do when they work on this module on the bench. He said normally the Vector can case adds enough resistance around 120 ohms to the circuit and it is fine. If I am not mistaken the Sparkfun board has 100 ohms to the input circuit, so that should be fine.

I just received an oscilloscope today and had to see what I was getting as an output. I have attached the output to this post.

What could cause error 7 to be returned from a send the message?

The order
a. Obtain an available buffer for the message that is to be sent.
b. Write the message (output to the network).
c. Wait for a positive response from MCP2551.


It's the last step, waiting for the response, that returns error 7



 If I remove the if sndStat ==Can_OK this is what I get

22:47:10.931 -> Setting Baudrate Successful!
22:47:10.931 -> MCP2515 Initialized Successfully!
22:47:10.931 -> MCP2515 Library Loopback Example...
22:47:10.931 -> Extended ID: 0x13FFE0BB  DLC: 0  Data:
22:47:10.965 -> Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:
Extended ID: 0x13FFE0BB  DLC: 0  Data:

Which is a start.

johnjudge01

I would start with the schematics for your hardware.

As for the termination, I do not have any prior experience with Single Wire CAN and my little bit of research suggests that most Single Wire CAN transceivers require a ~7kΩ resistance from BUS to LOAD or in your case CAN_H to GND.  It is likely this resistance will get communications going for you.
Is this a termination issue are a software issue?

Go Up