Jump to content

read/write CAN Data USB-8473


Sagi

Recommended Posts

Hi Guys,

I really need some help with reading/writing defined data over the USB-8473 module.

 

I am not really familiar with CAN at all, so maybe it is just a small thing I am missing to fix my problem.

 

 

What do I want:

I want to write/read defined signals from my .dbc-file

In this case for example i want to write a specific value to the can signal "ISw_Stat", also I want to read some values like "CSC_val_01" to "CSC_val_12"

 

What do I have right now:

I managed to get a working communication up and running, also I can read/write data (but not a defined one, for now I just do all data)

 

What is missing:

I have struggle to do the right formatting of my data

 

 

I have attached my program so far.

 

 

thanks

Test CAN.zip

Link to comment

So the good news is it looks like you are on the right track.  You already realize you can't use the channel API with that low cost hardware.  So you have to do the conversion your self and it seems you found the old conversion library.  It is recommended that you use the XNet conversion library instead.  The old library has some known bugs and is several years old.  I'm guessing since XNet can do the same conversion that they won't be releasing new versions of it.

 

So if you want you can try out my conversion library, which wraps the XNet conversion API.

 

https://decibel.ni.com/content/docs/DOC-39793

 

In the example it shows how to take a DBC, and create frames from signals, and then take those signals and turn them back into frames.  Also know that NI has a subforum for automotive questions like CAN, you may get more help there.

 

http://forums.ni.com/t5/Automotive-and-Embedded-Networks/bd-p/30

Link to comment

Hi hoovahh,

thank you for your answer.

 

 

I have stumbled over your solution before but didnt try it yet.

I will do this today :)

 

 

If I am right i just have to use your "Get TX RX Signals From DBC" Example to get all of my Signals.

 

Then I can just use your Convert vis to get a valid Frame and send this Frame via the original XNET Send_Frame vi?

 

 

If its really that easy I have to thank you 10000 times in advance!

 

 

br

Sagi

 

€: sry, was on a wrong way... xnet isnt working on the usb device ;) so have to use the old can drivers

Edited by Sagi
Link to comment

€: sry, was on a wrong way... xnet isnt working on the usb device ;) so have to use the old can drivers

If you read my link I mention that the XNet conversion library works on non XNet hardware, and can be used to convert an array of frames to signals and signals to an array of frame without needing any hardware.  This library can work with your hardware when used properly.

 

Oh and the example is just meant to show that you can get all TX and RX signals from a DBC, but you can also replace it with a constant of the signals you want to be able to convert.

Link to comment

Hi,

thanks for watching this thread again :)

 

I didnt really meant your VIs (they work just fine!), I meant the normal XNET communication VIs (like send/receive) they dont work on the USB module.

http://www.ni.com/product-documentation/5859/en/

 

So i have to use the old NI-CAN vis, like "ncReadNetMult.vi". And as I can see by now I have to reformat your XNET Cluster to the old format (if thats all).

 

I can try this in about 2-3 hours, right now I dont have the HW available.

 

 

br

Link to comment

I didnt really meant your VIs (they work just fine!), I meant the normal XNET communication VIs (like send/receive) they dont work on the USB module.

http://www.ni.com/product-documentation/5859/en/

Yes sorry if that wasn't clear.  The API I wrote is just intended to facilitate the conversion, but the actual communication is done by what ever your hardware has available for you.  In the past I've used some cheap CAN devices like a RS-232 to CAN converter.  Here there were a set of VIs to get and set frames and they worked fine.  Using the conversion API meant there was some option to convert to signals, from a database, that the user could load from a file on disk instead of hard coding it.

Link to comment

Hi,

nono it was totally clear :)

 

I tried to fix my problem yesterday but still have some troubles to get valid data out of the can frames I receive...

 

I have attached my actual test project with your XNET API.

 

 

I try to convert my received data, which I get from the "ncReadNetMult.vi", into scaled data. but its allways "NaN".

I have also saved my last received data in the test.vi as standard values for the output arrays.

 

 

br

Sagi

Test CAN.zip

Link to comment

Looks like you attached a lot of information, luckily by including the database, and saving the frames as default I can tell you a bit about why you are getting NaN.  You told the API that the tester's ECU name is "BMS"  I suspect this is incorrect because there is a second ECU in the database and it is "Tester"  If you change this constant from BMS to Tester the conversion will take place and get some results.

 

Now why is giving the ECU name important?  Well it doesn't have to be.  If you remove the Get TX and RX Signals VI and replace it with a constant 1D array of string with the signals you want to convert everything should be fine.  But what is happening right now is you are telling the API that you want to convert all the signals that the BMS expects to receive.  The problem is you are actually getting BSM data and you want to convert all the signals it transmits instead.

 

Another way of looking at it is you are asking to convert frames with ID 0x520, but in the frames to convert that frame is never seen, so when you say what is the value for BMU_Alive_Hil, the conversion says that there is no value for that signal.

 

Also you are forgetting the Close Conversion VI at the end after the while loop which cleans up the opened references.  And you can remove the old and busted way of doing frame conversion.

Link to comment

Thank you again!

 

Sorry, I attached the wrong project (but at least with some data). It was the "dirty" version without closing anything and old stuff packed in it :/ sorry for that. And even more big thanks from my side for still watching this garbage!

 

 

 

you are right, now as I added only signals I really want to read and changed the ECU I get some values.

 

 

But I have to ask some other guys (the guys who developed the other side of the CAN) what values I have to expect, for now they dont really look familiar to me.

 

 

br

Sagi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.