Go Down

Topic: NMEA 2000 Shield (Read 390404 times) previous topic - next topic

JCW

Thank you Timo, I appreciate the advice. I will try that, if that does not work I will try and find a scope and scope out the bus.

Regards,

Johan

JCW

Hi guys, I now have two Megas each with a MCP2515 set up. I am having success with the CAN_BUS_Shield-master library.

If I set #define USE_MCP_CAN_CLOCK_SET 8, I have the one Mega run the send example and I can then receive it with the other Mega using receive_check.

If I attach the correct interrupt then receive_interrupt also receives this data.

What would be the next logical step to move over to NMEA2000 to see where things go wrong? I am trying temperature monitor on the one and actisense listener on the other but still no luck. Obviously also setting #define USE_MCP_CAN_CLOCK_SET 8. I tried with interrupt on and off. Nothing.

Any help?

timolappalainen

Did you use MCP_CAN library from my Git? If not, remove the other and install the one under my Git.

Do you have mcp CS (chip select) pin on NMEA2000 library default pin 53. If not use
#define N2k_SPI_CS_PIN cspin.

Remember to have termination resistors even it worked with your simple test.



JCW

Hi Timo,

Yes I followed your whole guide on Git to install the correct libraries. CS pin is correct. And I have both the termination resistors on the MCP modules on. Is it safe to say that since the MCP_CAN library works and I have comms between the two arduinos that the hardware is all good and that I should now look for my mistake in software?

Regards,

Johan

timolappalainen

What examples you are using? USE_MCP_CAN_CLOCK_SET definition is on NMEA2000 library NMEA2000_CAN.h module and should not have any effect on CAN examples.

Which shields do you have?

JCW

Timo I use "Send" on the one Arduino Mega and "Receive_interupt" on the other. Both from the CAN_BUSMaster Libary as linked to in your github.

The data gets sent successfully from one to the other.

I am now trying to figure out what next to do to progress to the NMEA2000 library

timolappalainen

On both samples there is definition const int SPI_CS_PIN = 9; Have you oveeride that? As I mentioned on NMEA2000 library default cs pin is 53. If your cs pin is 9, you have to add definition
#define N2k_SPI_CS_PIN 9
before calling NMEA2000_CAN.h
Also check right interupt pin, which is different on "Receive_interrupt"

JCW

Hi Timo,

I see what you mean the define for SPI speed makes no difference in the CAN bus examples. They work with or without this line

I have now again run NMEA2000 on the two Megas. One with temperature monitor example, correct interupt and cs pin defined and also SPI speed = 8.

On the other I have actisense listener also with parameter correctly configured.

I noticed that if I remove the arduino with actisense listener I get the following from the arduino running temp monitor:

CAN device ready
Start address claim for device 0
PGN 130312 send failed
PGN 130311 send failed
PGN 130310 send failed

If I connect the Mega with the actisense listener I get only

CAN device ready
Start address claim for device 0

This tells me that the messages do go pass through from one Mega to the other? I am not receiving anything at all out of the Mega running actisense though. Not even a init message.

Any more ideas?

timolappalainen

If you get 'send failed' most likely you bus is not working. Either tranceiver is broken or misconnected, bus CAN L/H is misconnected or terminal resistor is missing.

JCW

Hi guys, this has by far been the most challenging arduino I ever had but I really want it to work.

I did more tests and had some progress. On all these test I made sure my bus resistance is 60ohms and I had messagesender on one board and actisense listener on the other board.

1. I connected the two Megas to each other via the two MCP2515 boards. I noticed that when I load message sender on one and actisense listener on the other if work ONLY one way around. If I swop the two MCP2515 boards around if does NOT work anymore. When I swop back it works.

2. While these two are in a working state (receiving messages on actisense listener) I then connect my Garmin 742xs (without termination resistor to the bus). The moment the Garmin device finishes booting the actisense listener no longer receives the messages from the other Mega. When I unplug the +12V from the garmin NMEA2000 connector it works again. So it looks like Garmin unit prevents the bus from working.

3. I then take a Due wired in exactly the same config as on Timos Git except I use MCP2551 and a voltage divider on the RX to Mega for 3.3V comp. The moment I connect the Due CAN to the but it also stop working.

4. I then put a termination resistor on the Garmin unit and connect it to each of the Megas individually after uploading message sender to both. Nothing in the device list. Upload temperature monitor to both and try again individually. Nothing.


I REALLY want to get this to work.


JCW

Update: The Due with MCP2551 works with the Garmin GPSMAP 742xs. I suspect that there is something wrong with these CAN modules. Or likely it is because they are running at 8MHz instead of 16MHz.

timolappalainen

MCP2515 controller has been tested by some others with 8MHz and it should work.

In some pictures you had only modules with megas connected together. Did you had terminal resistor on that test? Modules has jumpers for enabling terminal resistor and at least on picture 20200424_131150 they were not enabled. In that case it may work or may not.

If you are sure and terminal resistors in case 1 then sounds like other module can not send anything. You could connect the module, which worked as actisense listener to bus with Garmin and Due. Then you should see data.


JCW

Hi Timo, sorry I did not mention the detail. Yes those had 120ohm resistors enabled by a solder short on the bottom of the board.

Ok I will try this test and see.

At least the Due now works with Garmin. :). Thx again for the library and all the help.

JCW

I can confirm the following:

1) Due works with Garmin.
2) Mega works with another Mega each with a 8MHz CAN module.
3) Mega with module does NOT work with Garmin
4) Mega with module does NOT work with Due.

I am convinced there is some compatibility issue with these modules. I read on the web that a lot of guys had problems with 8MHz crystals and some claim that changing to 16MHz solved the problem. I will try and find the posts.

For now I am happy. I can develop with the Due.

timolappalainen

Are you sure you have definition right before including can library?

#define N2k_SPI_CS_PIN 53  // Pin for SPI Can Select
#define N2k_CAN_INT_PIN 21 // Use interrupt  and it is connected to pin 21
#define USE_MCP_CAN_CLOCK_SET 8  // possible values 8 for 8Mhz and 16 for 16 Mhz clock
#include <NMEA2000_CAN.h>
 

Go Up