05-05-2014 05:25 AM
Hello,
I have developed a code that reads CAN data frame from the CAN port (PCI CAN/2 series 2 board). The board have 2 CAN ports. I have connected a sensor to one of the ports and reading the CAN frames using my code. I want to use the same code to read CAN frames from 1o sensors simultaneously. Can anyone help me? I have tried creating SUB VI of my code but it reads only one port at a time.
Thanks in advance
Solved! Go to Solution.
05-05-2014 05:41 AM
Can you post your code?
I'd guess if your code isn't running in parallel, your sub VI is not marked as reentrant.
05-05-2014 05:59 AM
Hi,
please see the code attached. This is not a sub VI but I want to use it as Sub VI to read data from 10 sensors simultaneously.
05-05-2014 06:15 AM
Mark the VI as re-entrant, and you should be able to call it in parallel (VI Properties -> Execution -> Pre-allocated clone reentrant execution).
Keep in mind, if you do this, you will need to use multiple files (as multiple threads cannot write to the same file handle).
05-05-2014 06:44 AM
hi,
thanks for the information. I want to write results in multiple files (i.e store the data of each sensor in individual file), I will take care of that.
05-05-2014 07:31 AM
Hi,
one more question......how can I display my CAN data frame in a graphical format?.....I tried the available Graph options but it didn't worked for me......
05-05-2014 09:04 AM
Using the old Frame API, you'll need to parse out each data frame into signals according to your network database. That is, you'll have to convert the array of U8 you get out of the API into other data types, and then plot those.
If your hardware supports NI-XNET, I would highly recommend using that. With XNET, you can load your DBC, and it does all the hard work for you. If you're familiar with DAQmx, it should be a breeze to learn.
05-05-2014 09:19 AM
HI,
I haven't worked with NI XNET. I think to use NI XNET I need compatible hardware but my CAN card doesn't support it. Concerning the data type conversion, I understood it partially. I tried it but it doesn't show complete data. Is it possible for you to show me the short example. (you can use the VI that I attached previously)
05-20-2014 02:49 AM
Hi Gruenberg,
I have one question....in my code the while loop interates at 1000ms i.e. I want to read CAN data every second (1 value per sec). But when I log this data I see that it gives me 11 values per sec. Because of this my log file is getting very bigger unnnecessarily. I tried to figure it out but couldn't find any solution. Can you tell me why this is happening?
Please see attached docs.
Thanks in advance.
05-20-2014 07:32 AM
Your sensor is sending out data faster than that--you'll just have to select which frame you want to record. On the "data" output of ncReadNetMult.vi, inside the innermost case structure, use index array to select the first frame, build that into an array, and pass it to your VI that converts the frame to a string.
You will still need to read all the frames from the network, otherwise the buffer will fill.