Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

XNET Signal Conversion and Scheduling Questions

Solved!
Go to solution

After review of the NI-XNET API and user manual, I had some questions and comments:

 

1.Signal Conversion and Coercing

I could not find any documentation explaining the use of database minimum, maximum, and scaling within NI-XNET.  Testing of the API resulted in the following findings:

  • XNET coerces values to nearest when converting from scaled to raw
  • XNET does not display any warnings if a scaled value is out of range
  • XNET does not provide any functions to warn or indicate that the value written to the bus was coerced, am I missing something or is there a way to be warned in the API?

 

2. What is the suggested way to write a raw signal to the bus?  The only solution I found was to create a conversion session to convert the signal to a frame, and then write the raw frame.

 

3. What is the suggested way to convert scaled signal data to raw data and vice versa?  I was wondering if there was a property/method that allows for raw or scaled conversion rather than writing a (simple) utility to handle this.

 

4. Is there an easy way to replace signal data within a frame that already contains data?  For instance, I would like to increment and replace a transaction counter in a frame and send this frame back as acknowledgement.

 

5. What is the suggested way to schedule a fixed number of frames with delay between each?  For instance, I would like to transmit 15 messages at an extremely high rate (1msec, 2msec, 4msec, 10msec) with different data but only for a fixed interval on a Windows system.

  • Frame Stream Output will write all data immediately.
  • Frame Queued Output can transmit cyclic data, but would rely on a software "stop" occuring at the correct time else duplicate messages will be transmitted.

 

Looking forward to your responses...

CLA, CTA
0 Kudos
Message 1 of 9
(10,429 Views)

I should mention these questions are in reference to CAN...

CLA, CTA
0 Kudos
Message 2 of 9
(10,424 Views)

LVB,

 

1)  Information regarding the use of these properties can be found by selecting a CAN signal in the Database Editor and selecting Help » Open Online Help.  The information is below:

  • Scaling Factor—The factor to convert the signal binary value to its physical value.
  • Scaling Offset—The offset to add to the signal scaled physical value.
  • Maximum—The largest possible signal value. This parameter is informational only.
  • Minimum—The smallest possible signal value. This parameter is informational only. 

 

Can you provide an example in which data is coerced?  I am not sure what you are referring to.  As far as "out of range" warnings, are you referring to the max and min defined in the database?  These are informational only and not used for error checking, although this may be a good product suggestion.

 

2-3. When you refer to raw vs. scaled data, can you elaborate a bit more?  Are you refering to raw frames?  Are you referringto the bits on the bus, or an unscaled integer?

 

The best way to write a data to the bus, without having to deal with the frames would be using a signal session.  This is captured in an example located in the NI Example Finder (Help » Find Examples) under Hardware Input and Output » CAN » NI-XNET » Intro to Sessions » Signal Sessions.  I would recommend checking out CAN Singal Output Single Point.

 

4. If you use the Frame Input and Frame Output Single Point examples in the Frame Sessions folder, you can recieve a signal, add logic to manipulate the resultant data cluster and then output the updated data to the bus.

 

5. If you remove the timed loop from the Framed Queued Output example, you will not get duplicate data, only the data in the array.

 

I hope this helps and look forward to your response.

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 3 of 9
(10,410 Views)
Drew,
Thank you for the reply, your feedback is appreciated and does help.

@drew T wrote:

1)  Information regarding the use of these properties can be found by selecting a CAN signal in the Database Editor and selecting Help » Open Online Help.  The information is below:

Can you provide an example in which data is coerced?  I am not sure what you are referring to.  As far as "out of range" warnings, are you referring to the max and min defined in the database?  These are informational only and not used for error checking, although this may be a good product suggestion.


 1) Thanks for pointing to the documentation.  I believe this should be added to the NI-XNET Hardware and Softare Manual.

The scaled value is coerced to nearest AFTER conversion to raw.  Consider an 8 bit signal with the following properties:

 

  • Factor = 1
  • Offset = 0
  • Min = 0
  • Max = 100

The raw value (transmitted in on the bus) for this signal has a range of 0-255 in decimal.  Writing a scaled value of 1000 will transmit 255 on the bus with no "out of range" warning based upon the min and max defined in the database.  I was expecting the NI-XNET Write Signal VI would at least output a "warning" from the error cluster.

 

 

 


Drew T wrote:

2-3. When you refer to raw vs. scaled data, can you elaborate a bit more?  Are you refering to raw frames?  Are you referringto the bits on the bus, or an unscaled integer?

 

The best way to write a data to the bus, without having to deal with the frames would be using a signal session.  This is captured in an example located in the NI Example Finder (Help » Find Examples) under Hardware Input and Output » CAN » NI-XNET » Intro to Sessions » Signal Sessions.  I would recommend checking out CAN Singal Output Single Point.


2-3) In general, a "raw" value is referred to as the representation of data without scaling.  By writing a "raw" value to a signal, it would bypass the scaling factor and offset.  In the case of an 8-bit unsigned signal, the range of raw values could be 0-255.  Most CAN tools support either "scaled" or "raw" values to be written and displayed for signals.

 

I am familiar with the NI-XNET Signal Sessions, but they only seem to support writing a "scaled" signal.  This would mean the raw would have to be converted to a scaled value.  This could be accomplished by a "wrapper" VI, but I was wondering if there was anything build into NI-XNET to handle this.

 

 

 


Drew T wrote:

4. If you use the Frame Input and Frame Output Single Point examples in the Frame Sessions folder, you can recieve a signal, add logic to manipulate the resultant data cluster and then output the updated data to the bus.


4) If we use the analog of a "cluster" with a "frame", I would like to keep all other data and "bundle" a single element (signal) by name.  It would be nice if the Conversion libraries allowed frames to be "input" and then only replaced the signals wired as "input" maintaining other data.  It sounds like there is no easy way, and a custom VI must be written to "manipulate the resultant data cluster".  This can get complex when dealing with multiplexed signals.

 

 

 


Drew T wrote:

5. If you remove the timed loop from the Framed Queued Output example, you will not get duplicate data, only the data in the array.


5) This does indeed work for my original use case, but the use case needs to be clarified:
I would like to transmit the SAME message 15 times with different delays between each transmission.  These transmissions would occur at an extremely high rate (1msec, 2msec, 4msec, 10msec) with different data on a Windows (non-RT system).  The Windows system is not reliable enough to dynamically change the CAN.TxTime between transmissions.  Is there any way with the NI-XNET API to achieve this?
Looking forward to your responses....
CLA, CTA
0 Kudos
Message 4 of 9
(10,254 Views)
Solution
Accepted by LVB

LVB,

 

So, the raw value is only coerced when you exceed the bit size defined for the signal in question.  This is expected behavior, and the number of bits for a signal should be large enough to contain any number being written to it.  If this is not the case, error checking would need to be implemented in your code.  Some things you could do to prevent this are:

 

  • Change the representation of the control (or source) to U8 (or whatever your signal size is).
  • Check value beforehand against the Number of Bits property of the frame

For writing a raw value to the bus, would you need to write a raw value to a scaled signal?  If not, you could create a signal with a scale factor of 1.

 

As for the issue of modifying a single signal and retransmitting, would something like this not work?

 

Replace Signal.png

 

I do not think this is possible in the XNET API.  The two options here would be Frame Output Queued and Frame Output Stream.  Unfortunately, Frame Output Queued only allows one frame (and hence one frame TxTime), and the Frame Output Stream allows multiple frames but ignores TxTime and outputs as fast as possible.  This sounds more suited to RT or FPGA implementations of CAN.  

 

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 5 of 9
(10,243 Views)

Drew,

 

Thanks for the information, it looks like I will have to customize the NI XNET library to accomplish the items listed in this post.  I have summarized the answers below.

 

 

1.Signal Conversion and Coercing

The XNET API does not provide a warning when a signal value written is outside the min/max or bit size defined for the signal.  Create a custom wrapper around the XNET Write VI to provide custom error checking.

 

2. What is the suggested way to write a raw signal to the bus?

This functionality does not exist within the XNET API.  Create a custom wrapper VI around the XNET Write VI.

 

3. What is the suggested way to convert scaled signal data to raw data and vice versa?

This functionality does not exist within the XNET API.  Create a custom VI.

 

4. Is there an easy way to replace signal data within a frame that already contains data?

Use the XNET Frame to Channel and Channel to Frame conversion libraries.  After a little more digging into the XNET API, it seems the following snippet would accomplish replacing a signal using the XNET API:

xnet_replace_xnet_signal.png

 

5. What is the suggested way to schedule a fixed number of frames with different delays and with tight timing constraints?

This functionality does not exist within the XNET API.  Only a fixed delay is supported.  Real-time or FPGA should be used.

CLA, CTA
0 Kudos
Message 6 of 9
(10,231 Views)

@LVB wrote:
2. What is the suggested way to write a raw signal to the bus?

This functionality does not exist within the XNET API.  Create a custom wrapper VI around the XNET Write VI.

 

3. What is the suggested way to convert scaled signal data to raw data and vice versa?

This functionality does not exist within the XNET API.  Create a custom VI.

 

5. What is the suggested way to schedule a fixed number of frames with different delays and with tight timing constraints?

This functionality does not exist within the XNET API.  Only a fixed delay is supported.  Real-time or FPGA should be used.


For 2: Use the Frame API and not the signal API. Then you are writing raw information to the bus.

For 3: Frame to Channel Conversion Sessions are the way to convert scaled data to raw data.

For 5: You could use replay mode for stream output.

Message 7 of 9
(10,227 Views)

@GPIB Guru wrote:

@LVB wrote:
2. What is the suggested way to write a raw signal to the bus?

This functionality does not exist within the XNET API.  Create a custom wrapper VI around the XNET Write VI.

 

3. What is the suggested way to convert scaled signal data to raw data and vice versa?

This functionality does not exist within the XNET API.  Create a custom VI.

 

5. What is the suggested way to schedule a fixed number of frames with different delays and with tight timing constraints?

This functionality does not exist within the XNET API.  Only a fixed delay is supported.  Real-time or FPGA should be used.


For 2: Use the Frame API and not the signal API. Then you are writing raw information to the bus.

For 3: Frame to Channel Conversion Sessions are the way to convert scaled data to raw data.

For 5: You could use replay mode for stream output.


2. I am looking to write both scaled and raw signal values in my use case.  The signal interface would be used most of the time (thus a Signal session would be preferred), but occasionally I would like to write a raw value (for instance 0xFF) for a single signal and not modify the other frame data.  This is a pretty simple VI, I was just curious if there was anything built into NI XNET.

 

3. The Frame to Signal Conversion session are great converting a raw frame into a scaled signal.  However, a scaled signal to raw signal conversion gives an output of a raw frame, not a signal.  Custom code would be required to extract the signal from the frame.

 

5. Thanks for the suggestion on replay mode.  This is exactly what I was looking for.

I would edit my previous post as this IS possible within the XNET API, but it seems NI only allows you to edit a post for a few minutes after the posting...

CLA, CTA
0 Kudos
Message 8 of 9
(10,221 Views)

Hello all,

 

Please help me on my VI.

 

  1. I want to read the more data from log file (i.e. >2GB) with read from notepad file( line by line) or spread sheet. This output I’m giving to CAN frame (with NI XNET).
  2. In NI XNET Convert.VI I’m getting last frame values (Signal data), so how can we get the all frame values with  time interval( for selected signals).
  3. My log file contains two types CAN networks, I want to read both .DBC files with NI XNET convert.VI and I need extract the data for selected signals .

 

Please check my VI and give me your valuable suggestions.

 

Thanks & Regards,

Guru

Munna
0 Kudos
Message 9 of 9
(8,946 Views)