04-24-2013 02:33 PM
Hi,
I have a cRIO 9024 with a NI 9853 CAN module. I am attempting to make a reat time application that can be deployed wirelessly on a vehicle so as to send and recieve CAN signals and log data. However, I currently do not have the vehicle or the signals that will be used. I would like to create a VI that would accomplish this and test it without the vehicle as I won't have the vehicle or data signals for a long time from now. I have looked through the CAN module specific examples and have made a VI but it doesn't seem to be doing what I want. I am fairly new to both CAN and labview.
I have done the CAN basic example but it doesn't make any sense to me. I need something that would be remote and that can recieve any signal sent and log it without any human interaction. I am currently using the example.ncd as a databse of the channels that would be sent. That being said, is there a way to send CAN frames from one port to another on the NI 9853 that actually makes any sense? Do I need to make a signal and if so, how? Thank you.
04-24-2013 03:26 PM
You can ignore the channel API entirely and read and write raw frames. It's been a while since I used a CAN module on a cRIO, but I believe you're reading or writing an array of integers, which you can reformat into a cluster that matches a CAN frame. To send a packet between ports, you need to wire the two ports together, supply external power to CAN1, write a packet on one port and read it on the other. Can you share the code you've tried?
04-24-2013 03:33 PM
nathand,
I understand that I could specify a packet through a VI but I'm trying to make a VI where I wouldn't have to interfere with it save for the first time. In otherwords, I tell it what CAN channels will be used and then data is streamed and logged. I know that if I had a source of the CAN signals I could do this but I currently am trying to do this without a source but with the same functionality. Would I be able to create a simulated CAN signal that constantly sends out random signals with the appropriate frame confguration? Thank you.
04-24-2013 03:35 PM
Sure, you can write a VI that sends random data in a CAN packet (with a random arbitration ID, or several bits randomized, if you want).
04-24-2013 03:37 PM
04-24-2013 03:43 PM
Do you have any advice on how to do this?
04-24-2013 03:48 PM - edited 04-24-2013 03:50 PM
Hi Ramirez,
the CAN packet consists of 6 U32 values (if my memory serves correctly: U64 timestamp, U32 ArbID, U32 for Length and settings, U64 data). You have to send such an array to the CAN port node on your FPGA.
You may use the CAN cluster instead - that depends on the configuration of the CAN write node. NI also provides a function to convert between CAN cluster and corresponding array...
If you need examples you have to wait til tomorrow when I have access to my office PC.
When you already know which data you expect to receive on CAN port 2 it should be no problem to send exactly those data packets on port 1...
04-24-2013 04:06 PM
Can you be more specific about the problems you're having? You said that the CAN Basic example doesn't make any sense to you. I just pulled it up. Which part does not make sense? There's one loop that constantly looks to see if a packet has been received, and another that sends a packet when you click a button.
You would want to add a host VI running on the cRIO, and modify the FPGA example. The FPGA would handle only the direct interaction with the CAN card; it would receive packets from the host VI and send them, and pass received packets back to the host VI. For a simple example like this you can use front panel controls to pass data, so you don't need to make major changes to the existing code. The host code running on the cRIO would build the packet you want to send, filling in the data and arbitration ID. It would also log all received packets, or only those that meet your criteria, however you decide to code it.
04-24-2013 05:52 PM
nathand,
I guess what confused me about the CAN basic example is when I would click on the button I didn't see any identifiable pattern in what was sent. It all seemed really random. I know I mentioned wanting to make a random signal but I guess random is the wrong word. What I meant was probably more like a signal that follows a set pattern for multple channels with different sizes that is random in the sense that the values of the data are randomized. I also was hoping to make a VI that didn't require the pressing of a button but rather was constantly looking for a packet of data and that a packet of data was constantly being generated in the fashion mentioned earlier.
04-24-2013 06:27 PM - edited 04-24-2013 06:27 PM
There's a control on the front panel of the example that lets you set the packet that will be sent. Note that it sends a raw CAN packet - using the Frame API, as NI calls it. You have complete control over the frame that is sent, how you send it, and when you send it. Translation to a CAN channel is a bit more complicated but there are examples available on the NI site. It is not difficult to write a VI that sends a particular frame, or set of frames, repeatedly. However, I can't point you at an example that does it already and I can't write it for you. If you give it a try, though, and upload your code when you get stuck, then I and other forum users can help fix the errors.