Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN reading and writing a frame with offset and scaling using NI-XNET database

I am new to LabView....

 

Has anyone managed to get the CAN network work with the NI-XNET database to have the offset and scaling done all through the database instead of having do do everything by hand? I can't find any examples or VIs, although I keep seeing that everyone has the same general issue. The only response is that the API can't do it....ok...has anyone successfully done this and can share the VI?

 

Is there a way to feed in decimal (double) real world values and have a VI take the values and do the conversions necessary to make the can message with the scaling and offset that you put in the database using the NI-XNET API and LabView? How does this work when your message has the following format:

 

Sensor Reading 1: 2 bytes [unsigned 8]

Sensor Reading 2: 2 bytes

Sensor Reading 3: 2 bytes

Failure code 1: 5 bits

Failure code 2: 5 bits

Failure code 3: 5 bits

 

I am trying to put this message together and emulate a CAN message that would come from this sensor (has 3 different readings), and have this be generic enough to be ported to other kinds of sensors later. I can't get the database, which is already set-up, to have the scaling and offset applied or even get the correct format. The output I am expecting is a Hexadecimal output corresponding to the decimal values that I give it as input....

 

ie:

The initial input for the CAN message would be something like...

22.3 degC 

25.9 degC 

25.9 degC 

2 (Failure Mode Indication)

 

so the data field message would read E824 5C25 5C25 FFFF 

So the data length is 2 bytes. 0.03125 degC / bit scaling and -273 degC offset...

 

 

I can't get this to work with the API, and am hoping someone can point me in the right direction....

 

Thank you for any help in advance!


 



0 Kudos
Message 1 of 9
(8,518 Views)

Hi estradjm,

I'm a little confused by your first paragraph.  It originally sounded like you are trying to use the database editor to handle your scaling and offset, but then you asked if anyone has done the scaling and offset in a VI.  Are you just trying to have the conversion from the frame to a real world signal handled behind the scenes, or am I missing something?  You have the ability to create custom scales through the Database Editor that you can specify the scaling with.  You may find some of the information from this white paper on FIBEX and the NI-XNET Database Editor useful as well.

 

If you open up the nixnet_example database, you can see under the CAN_Demo_Box cluster that you can specify this sort of scaling under the WAVEFORM0_SAW0_SWITHCES_FROM_CDB frame that each portion of the frame is broken up to represent different messages, and that each message in that frame has values associate with it.  For example, Switch0 has to possible values, either 35 or 40 (real world signal) that is represented by a single bit.  To do this, the signal properties are set accordingly.

 

I hope this helps.

0 Kudos
Message 2 of 9
(8,509 Views)
I do want to just be able to use the database editor to handle your scaling and offset, but I cannot make it work, which is why out of frustration I started looking into bypassing that with doing the scaling and offset in a VI.
 
I am trying to have the conversion from real world value signals into CAN frames handled behind the scenes. I know you can create custom scales through the Database Editor, but I cannot make the real world values into the CAN frame equivelent within a VI. I do have the database set up, and I call it out and try writing a real world value to the CAN frame, but it is not doing the scaling and offset on the signal, nor is it doing the bit order or creating the correct signals, despite having the database set up and called within the VI. 
 

I cannot open up the nixnet_example database, as there is something wrong with it on my computer, or we do not subscibe to the service. I don't know, but I have been looking into this with no success.

 

0 Kudos
Message 3 of 9
(8,483 Views)

Hello AHHHHHHHG,

Are you having the same concern that estradjm is having?  You mentioned in your most recent post that you can't open the nixnet_example database and that something is wrong with your computer.  What exactly do you mean by "something is wrong with your computer"?  Do you mean that for example perhaps one of the drivers or the examples was not installed properly, or something like the computer crashes?  You should be able to access the example database through the editor.  If you can't do that, you may want to verify that you do have NI-XNET installed.  If you do have XNET installed, I would encourage you to do a repair on that driver.  It sounds to me that you may have something wrong with your driver installation.

0 Kudos
Message 4 of 9
(8,474 Views)

I have three 5 bit long signals that become two bytes when concatenated together. This is the portion that is not working still. Is this problem because LabView doesn't work below 8 bits inherently? 

 

I want to give either 31 or 2, to represent a failure mode indicator. There are three of these, of which the user will be using three boolean buttons to indicate the status of the 3 sensors, respectively. ....3 buttons, one for each of the 3 sensor status'. Each status should be 5 bits long, and all three will be concatenated to create 16 bits. Parsed to create 2 U8s, which is seen over can as hexadecimal (4 alphanumerics total, 2 alphanumerics per byte). 

 

I would like to have the API handle all the conversions, but I don't think that it is capable of handling data manipulation under 8 bits. Any ideas? 

0 Kudos
Message 5 of 9
(8,469 Views)

estradjm,

You can absolutely handle signals that are of different lengths.  For example, I've attached two screen shots of the Database Editor with a frame configured to transmit every .1 seconds with a payload length of 2 bytes.  In that frame, I have three different signals, each with a length of 5 bits.  I've attached a screen shot of the Signal as well.  You can set your scaling, ofset, maximum and minimum in this property screen as well.  I hope this helps.

Download All
0 Kudos
Message 6 of 9
(8,459 Views)

If you feed in the values for the signals, do you have to give the values in the same order as you labelled in the Database?

 

Do you feed in the value in bits, or will the truncation happen if you give a U8 signal?

 

 

 

 

0 Kudos
Message 7 of 9
(8,453 Views)

Isn't the min and max for informational purposes only? Or does the API take and clamp at the values given regradless of the user's input in the VI?

0 Kudos
Message 8 of 9
(8,452 Views)

estradjm,

Yes, you will need to pass the signals into the frame in the appropriate order.  You do not have to pass this bit by bit, you can pass the actual signal.  Also, you can go in and actually change the minimum and maximum values as well.  Typically, the minimum is zero, but you could certainly set it to something different.  Try it out.  Also, feel free to take a look at the CAN Signal examples from your Example Finder.  This should give you some clarification on what exactly is going on and how to use the Signal API.  The example is based around an automotive system, but you can get an idea of how the signals get sent.  I hope this helps.

0 Kudos
Message 9 of 9
(8,439 Views)