Help with CAN

I have purchased 2 SN65HVD230 CAN transceivers and connected them in the following way to the the Panda. I then wrote the following code and while it appears that the message is being queued, it is never recieved.


using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;

namespace CAN_Tests
{
    public class Program
    {
        public static void Main()
        {
            const int BRP = 6;
            const int T1 = 15;
            const int T2 = 8;

            // Initialize CAN Channel, set bit rate
            CAN canChannel1 = new CAN ( CAN.Channel.Channel_1, ((T2-1) << 20)| ((T1-1) << 16) | ((BRP-1) << 0));
            CAN canChannel2 = new CAN ( CAN.Channel.Channel_2, ((T2-1) << 20)| ((T1-1) << 16) | ((BRP-1) << 0));

            CAN.Message message = new CAN.Message();
            CAN.Message[] message2= new CAN.Message[1];

            for( int i = 0; i < 8; i++)
            {
                message.data[i] = (byte)i;
            }
            message.ArbID = 0xDAE;
            message.DLC   = 8;
            message.isEID = false;
            message.isRTR = false;
            //
            CAN.Message[] send = {message};
            int success = canChannel1.PostMessages( send);
            Debug.Print(send.ToString());

            while (canChannel2.GetRxQueueCount() == 0)
            {
                Debug.Print("Still nothing in the queue :-(");
            }
            canChannel2.GetMessages(message2);
        }
    }
}

To this point I have used CAN in our systems at work, but this is the first time I have attempted to set it up on a FEZ. Note: this is the first real problem I have run into using FEZ

I’ve just checked your code on FEZ Panda and it worked perfectly. I suggest that U check you hardware.

by the way you need to add this to the code

message2[0] = new CAN.Message();

Yep, after careful inspection I found that the 3v3 was intermittent. Duh. sorry.
BTW, when will the new CAN assembly be ready? No rush just want to know if I should wait to start implementing KW2000 or will I be able to migrate my implementation easily to the new assembly?

The current class should work fine. Don’t wait for new assembly as it may take some time to complete.

Hey!!

This is exactly what we are attempting to do. We juste received our CAN transceiver and you provide the schematics !!! Thanks!!

Did you try with a VREF at 12V ?

No I was just trying to prove a concept so I just left it ref float. It was a fun experiment.

i don’t understand the purpose of the two capacitors on your schematics. Can you provide some explanations on that part?

Thanks.

What schematics?

the schematic in the image in the first post…

they’re smoothing the power supply line to both the CAN devices.

I must be losing my mind…how didn’t I see it!!

As a rule I have always placed a small cap as close to the as possible to each IC between power and ground to reduce the effect of the current draw caused by switching as much a possible. This is a carry over from 40 years ago when I did hardware design an my team lead insisted on it. :wink:

Just for fun I have include a photo of the IC on the breakout board where you can clearly see the cap. The breakout board is from SMD Adapters 8 pin SOIC Adapter, and the cap is a 0.1uf I scrounged form my bin.

The link should now work.

thanks for the advice.
FYI, the SOIC adapter link is broken but i found a similar product in my local reseller.

Cheers !

i have been trying to weld my vp230 to SOIC adapter with no succes, i have aquired some MCP2551 which already are on DIP package. I ve reproduced the schematics you descrive with two MCP2551 and two FEZ Domino to send and receive CAN Message.

But i’m not able to receive any CAN on the reception board… I know that the MCP2551 is 5v logic but i think i ve read that’s fully supported by the fez domino right?

Should i do somme kind of pull up/down or add some divider ressitor between the Rx/Tx of the Domino and the Rx/Tx of the tranceiver?

I think the can sending is pretty close to be working because the CANchanel.IsTxBufferAvailable of the sending card become false after sending few messages(something like 4 CAnmessage).

On the reception card, the canChannel.GetRxQueueCount() deseperately stay =0

If someone has any idea it would really help…

Thanks

Please include a link to datasheet in future

The chip will work just fine with our boards. Did you add a termination resistor on the wires? It should be 120ohm in total but you can use any close value…like 100ohm or whatever you have.
See this http://zone.ni.com/cms/images/devzone/tut/HS_CAN_Termination.gif

Sorry, for the missing datasheet i ll do it in the future.

Yes i have added a 60 ohms resistor between the CANH and CANL of my transceiver. The CANH and CANL of my two transceivers are directly linked to each other

i also aded a 0.1uf cap between 5V and ground as in Dave schematics

That’s what i need to do right?

Yes and leave pin 5 unconnected.

See this please http://www.ghielectronics.com/downloads/EMX/EMX_DevSys_sch.pdf

That’s exactly what i did, i just added a led on pin 5 to check if the transceiver is working…

How can i deep further to understand what i don’t do well?

I mean pin 5 on transceiver.

me too. I was thinking that checking Vref is a good way to see if the transceiver is well alimented.

it’s now working !!!

i ve figured out that one on my transceiver was burst… It s not easy to detect btw.

I ve uploaded the all test program inside our CodePlex site : http://mlrobotic.codeplex.com/SourceControl/changeset/changes/4975
There is the all Visual Studio Solution with the 2 programs for sending and receiving with the each Domino cards.

Thanks again.

PAC