07-18-2016 06:36 PM
Hello.
Can I use the same CAN interface for read and write?
For example:
I am sending CAN frame using CAN1 to my MCU.
IF MCU acknowledged the receiving command it immediately sends echo command back and it has different ID than send command.
I was trying to use CAN1 to output frame and then reconfigure CAN1 to frame in queued and get the echo frame back.
But it seems I was always missing it. The "frame CAN" vi kept timing out.
When I used the splitter on the CAN output of my MCU I configured CAN1 for frame out and CAN2 for frame in, and I was able to catch the echo frame.
I think it takes 100ms for the echo frame to be sent out after command has been received. Does it takes longer for NI PXI-8513 to reconfigure? Can I even do it, or I have to use the splitter?
I wad hopping to use one interface for read and write.
Thank you
Solved! Go to Solution.
07-19-2016 07:00 AM
See my response on your other thread, but basically you need to create the input and output sessions at the beginning. Then, during your main "loop", you would perform your reads/writes as necessary. Don't keep 'reconfiguring' as that is ripe for losing data .
07-19-2016 08:00 AM
Thanks. I'll try to change the program and let you know if it helped.
I actually tried to configure in the same loop two sessions for the same interface (CAN1).
I used Loopback example, just changed interface and frame inputs. But I never could read my echo frame. Data was always empty.
I'll try one more time anyway.
07-19-2016 08:03 AM
If you want to see the echoed frame, you need to enable the echo transmission property (I don't recall the exact name). You also will need a real listener on the bus as well as CAN requires two nodes. You can somewhat get around that by enabling the single-shot transmission property, but that isn't exactly perfect.
07-19-2016 08:12 AM
HI,
It seems echo property only monitors if transmited frame was echoed. In my case echoed frame has different ID.
I'll try to call NI today and see if they can clerify it better. I will update.
07-19-2016 08:18 AM
Ok. I misread your notion of echo. I now understand. Sorry. The code you posted seems reasonable.
1) Do you have termination on or off for the session?
2) What baud rate? You may add a baud rate parameter to the property node to be explicit.
3) I don't recall the VI name, but you may add a Get Comm State after the read. This will give you some information about the bus - if any errors were detected, etc. That may be useful to help debug.
07-19-2016 01:29 PM
HI,
I am not sure what is going on, but it seems Iam making stupid mistake somewhere I cannot see where.
I was able to make one vi to send and recieve frames using the same interface. No errors, works everytime.
When I put inside a main loop, it gives me an error:
Error -1074384742 occurred at XNET Create Session (Frame Output Queued).vi:5330001
Possible reason(s):
NI-XNET: (Hex 0xBFF6309A) The interface has already been opened with different cluster settings than the ones specified for this session. Solution: make sure that the cluster settings agree for the interface, or use a different interface.
Error happens inside CAN_Output_and_IN_R1, when it tries to create session for frame out.
Once error happens, I cannot write anymore even with subvi. I have to open and close labview to clear an error.
When Vi works I get session nmber 1 for frame in and session 2 for frame out.
When it stops workin, frame in still gets session 1, but session out alway 0.
I need help with it. ALredy spend too mach time on it.
THank you
07-19-2016 01:33 PM
I didn't look at your code (I don't have LV installed), but make sure you don't open or close the interface (i.e., sessions) within the loop. Just do the writes and reads.
07-19-2016 01:34 PM
Just figure out.
Yep, it was stupid. I have two databases that have the same signals.
I was trying to configure one iterface from two different databases.
One I set to the same databese, no more errors