Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-XNET input timing

Solved!
Go to solution

I have more general question. I am new to CAN interface and I just trying to understend better functioanlity of NI-XNET input vi.

MY main issue was that when I ran vi by itself, It was working just fine. Read every frame my MCU was sending.

When I put the same vi as part of main program, I start missing frames if I write to MCU first. I have to run input vi few times until evensually I get a frame.

If I  strat the program and only do inputs then vi was getting every frame.

I was using PCAN scan program to read the same MCU, and it was getting 4 frames every 100ms everytime.

I am only trying to read one ID frame.

 

When I increased timeout time to 100ms it seems made program more stable.

I was not sure why it helps. I am using frame in queued. Does it mean that the buffer will hold the data until vi gets there?

 

THis is Frame IN VI

NI-XNET input.png

 

The same Vi as part of Main vi

NI-XNET input in Main.png

Fram out Vi that use in Main VI.

 

NI-XNET output.png

0 Kudos
Message 1 of 4
(4,904 Views)
Solution
Accepted by topic author Rus_K

The Frame In Queued VI, as explained in the XNET Hardware and Software Manual (pg 4-15), allows you to read data a sequence of data specific to a frame. Therefore, the read will only return values of that frame only. If you are only trying to read in one ID frame this should work well for you. Expanding the timeout might be correcting the behavior because the specific type of frame you have specified is not coming within the shorter timeout. 

 

But I am curious why it is behaving differently when you write first vs when you don't write. I would like to see what is going on. You can use the NI-XNET Bus Monitor to Monitor the bus when you don't write and when you do write before reading the frames. This will help me see if what you are seeing is expected or if something needs to be configured differently.

A Johnson
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(4,870 Views)

HI,

 

 

I think the increasing timout time resolve the issue, Wehn I ran manualy th elop was slow enough that data alredy was in the queue.

When I ran vi as part of the main loop, I think vi was expecting data before data got there.

0 Kudos
Message 3 of 4
(4,867 Views)

I would not keep opening and closing your sessions. Open at the beginning, close at the end and just do the reads in the middle. If a frame is received by the hardware without an active session, it will be discarded.

0 Kudos
Message 4 of 4
(4,860 Views)