Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with CAN example given with Labview 7.1

Hi All,

 

I have modified one CAN example given with labview 7.1. As per my understanding this VI should read the message depending upon the "Frame Format Selector" control.

 

If it is Standard then the VI should read only standard frames not the extended

 

& if the input to "Frame Format Selector" control is extended then the VI should only read extended frames not the standard.

 

But this VI is reading Standard frames also while the "Frame Format Selector" control is extended.

 

Kindly tell me why it is happening like that. This VI should only read either of Standard or Extended depending upon "Frame Format Selector" control.

 

I have attached the modified example also for your reference. Kindly  guide me as soon as possible.

 

Regards,

J

0 Kudos
Message 1 of 4
(7,006 Views)

J:

If I am not mistaken, when you set the value to read extended frames it should also read standard frames if they are present on the bus.  The CAN 2.0B specification allows both extended and standard frames on a network bus.  If you have a mixed bus and you need to read only the 29 bit IDs then you can check the IDE bit to determine whether the frame is standard or extended.  You can also look at the arb ID returned by the VI to see if it is greater than $7FF, in which case it is an extended ID.

Hope this is of some help.

 

Bill 

GCentral
0 Kudos
Message 2 of 4
(6,971 Views)

Hi Bill,

 

Thanks for the reply. Yes you are right. CAN bus will have both extended and extended frames at the same time. And i only wants to read either standard or extended frames at a time.

 

In ncConfigCANNET.vi what is the use of Comparator and Mask ? I thought using Comparator and Mask i will be able to read either Standard or Extended CAN frames.

 

One more question, How to read IDE bit ?

 

Thanks & Regards,

J

0 Kudos
Message 3 of 4
(6,966 Views)

J:

I can't help you at this moment with the ncConfigCANNET.vi as my laptop was clicking this morning and I'm having it backed up as a precautionary measure.

 

However, the ARB IDs returned from the NI VI you use will probably all be 32 bits long (if mixed IDs are present), with the standard frame IDs padded with zeros from bits 12 through 29.   Note that NI modifies returned extended IDs by setting the 30th bit to 1, and they may do this with standard IDs in the mixed case (once more I apologize for not being able to pull up this information from within LabVIEW as my PC is still "in the shop" as I write this). Take a look at http://digital.ni.com/public.nsf/allkb/31A91B09E54A8A8F862573AE00608583 for some insight into NI's handling of extended IDs. 

 

There should be a boolean in the frame cluster returned from the VI you are calling that can tell you whether you are receiving standard or extended frames.  The boolean is called "Is Extended".  If it is present you could look at that to see the status of the IDE bit. The problem with the IDE bit is that it is abstracted away by the hardware layer in the frame reception process.  The hardware and accompanying controller will decode the frame and return the ARB ID, data length, data bytes, and several flags which may or may not be provided by your language of choice.  Higher level languages often return the IDE flag and others, and in this case, under some flavors of NI CAN, the IDE bit is called "Is Extended".  Otherwise, the IDE bit would be after the 11th bit received right after the "Remote Transmission Request" bit, which also is normally not returned as part of the ARB ID but is available in some flavors of NI CAN and other languages.  If you want to get really low level with all this I suggest you order the free wall chart from Vector "CAN Protocol Reference Chart" since they were the ones that invented CAN.  See http://www.can-solutions.com/ and select "Info material" on the right.

 

My suggestion would be to check the bits above 11 for non-zero values after you adjust for the $20000000 value (if added by NI).  If there are non zero values in the ARB ID above a value of $7FFh, then the ID is extended, not standard. 

 

Hope this helps.

 

Bill

GCentral
0 Kudos
Message 4 of 4
(6,962 Views)