10-14-2014
09:50 PM
- last edited on
06-03-2024
11:06 PM
by
Content Cleaner
Hi guys. I got a problem here. How do i convert the raw data or message of CAN bus into the Engineering Unit. All the components in my LabVIEW program is working properly as I have already tested them and checked using the MAX application. I am using DAQ usb-6251 together with the CAN modules NI usb-8473 (high speed) and NI-usb 8472 (low speed). I've referred to this website as well for some more information but it is too general.
http://www.ni.com/swf/presentation/us/can/
I have already got the messages. Just wondering how to convert them to Engineering Unit. Also here I attached together my project's photo for the reference.
10-15-2014 02:14 AM
10-15-2014 03:31 AM
Hi clark,
Use NI XNET APIs. This will convert your CAN data to Engineering values based on provided DBC.
You need to create proper CAN frames from your Table and pass it XNET Convert.VI.
10-15-2014 03:40 AM
10-16-2014
09:43 AM
- last edited on
06-03-2024
11:07 PM
by
Content Cleaner
@GerdW wrote:
Hi clark and Munna,
you can do the very same with those old plain CAN functions - but you need your CAN database in all cases…
At the moment I know of 3 ways to convert a CAN frame to a channel, and only the XNet method is one I'd recommend.
Using the older NI-CAN drivers you get two virtual CAN ports. You can write to one virtual port, and read on another. I think the CAN ports were something like CAN255 and CAN256. So you write your frame on the CAN255, then create a new sessions where you read channels, on 256 giving the database. I never had issues with this method but I always thought it was convoluted having these virtual ports used.
Another method is using the CAN Frame Channel Conversion Library. This thing hasn't been updated in over 5 years. Last time I used it I had several errors in the conversion routine and it didn't convert frames to channels property. I contacted NI and their answer was to use the XNet conversion tools.
Since then I wrote a wrapper around the XNet conversion functions so all you need to do is provide a database, and signals to covnert along with frames and you get signals either as single point, XY or Waveform just like the other XNet read functions. It can of course go in reverse too.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-16-2014 09:56 AM - edited 10-16-2014 09:56 AM
Hi Hoovaa,
4th method:
Using "CAN Initialize" from old CAN library you can initialize a CAN task based on signals described in a CAN database file. Then you use that CAN task reference to read/write data in engineering units. Quite simple, just basic operations like INIT, START, READ/WRITE, CLOSE…
10-16-2014 10:23 AM
I don't know if I believe you, or if I'm confused. I tried using the Init (without start) and it complains that I need to specify an Interface. So I use the virtual one 256 mentioned ealirer. Then it complains I don't have the right mode. Not sure why I need to specify I am reading or writing but okay. So I write a channel, now how do I get what the frame equivalant would be? The I can't use the read frame function because they are different types and it throws an error.
Would you mind posting a VI explaining what you are describing? Thanks.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-17-2014 01:24 AM - edited 10-17-2014 01:28 AM
Hi Hooovahh,
Init CAN:
"Get Chan Names" filters the CAN database for "channels", "INIT" initializes a CAN task based on the channel list and the CAN database file. And yes, there's a CAN interface wired (had to snip it…)
CAN reading:
Business as usual: start task, read task (in engineering units!), stop&clear task…
The point is: instead of applying scaling to receive values with engineering values later on you could (or: should) apply that scaling from the start by supplying a CAN database to whatever CAN function you use in LabVIEW (XNET accepts them the same way as this old CAN driver)…
10-17-2014
07:28 AM
- last edited on
06-03-2024
11:08 PM
by
Content Cleaner
Okay just as I thought this is all contingent on the fact that you actually have a NI-CAN port (not XNet), and that CAN port supports the signals API, and you actually are receiving the data on the bus. The question was how to convert from frames to engineering units, which in my mind means you have frames and you need to convert them to signals (or channels). The three methods I mentioned above do that without relying on any required hardware, and can be done after getting the frames from some other source.
Many people post on the forums using the cheap crappy NI USB CAN devices, or Vector or Intrepid hardware which all only support a frame API. This means those VIs for the NI-CAN library can't be used the way you described to read signals.
Of course if you actually have a NI-CAN port that supports the signal API you should use it. And if you have an XNet CAN port then you should use the XNet API for reading/writing signals. If neither of those are an option, any of the three mentioned above will work.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-17-2014 07:44 AM
Another (more general) method: Do it on your own!
A CAN frame is just an U64 value. All you need to know for a signal is to be found in the CAN database (start bit, bit length, gain, offset). So you need to mask some bits, shift them to LSB and scale the value. Finished…
I use this "plain" method in my cRIO systems with a 9853 CAN module after transferring frames from FPGA to RT host…