09-25-2014 07:01 AM
Hello,
I am reading a sensor data using NI CAN frame API. Sensor sends data every 10ms. It means, my software should read 100 values/second. In my software I am reading faster than the sensors sends i.e. while loop is executing every 5ms. But I am getting random no. of sensor data (always less than 100) per second.
please have a look at the code in the attached pic.
thanks in advance
09-25-2014 07:03 AM - edited 09-25-2014 07:05 AM
sorry, here is the attachment
09-25-2014 10:24 AM
General comments:
Use XNET API not NI-CAN API if your hardware supports it.
Post VIs not pictures, you wouldn't post a screenshot of text code for other languages.
Specific comments:
This is not running on real-time it is running on a non-deterministic operating system. Good luck getting a while loop that always executes in 5ms dispite what Windows is doing. Do you have anti-virus running? Any other programs open? Any other Windows services running? Do you have a network adapter? Is Windows caching some search data? Even is a UI being displayed? Well then you have no way of knowing what good that timing is.
The good news is it doesn't matter. The CAN hardware has a buffer and if you go and read your frames once a second, then your frames will be pilled up in a queue and you read them all at once. So increase your delay on the loop rate it doesn't matter, you're not going to miss any frames unless your buffer is full and for that to happen you'll likely need to not read CAN maybe once a minute or so.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-26-2014 01:52 AM
Hi Hoovahh,
I tested my software and found that I am getting 100 frames/second but when I write this data in a text file, the no. of frames written in a file are sometimes 100/second or less than 100 (random values). please have a look on attached VI
09-26-2014 01:54 AM
hey I am sorry....I am trying to attach VI but th VI is not being uploaded.............don't know whats the proble.....thats why I posted image previously
09-26-2014 07:51 AM
Hello swap15,
try to pack your vi in a .zip file
how do you know that you have 100 frames ?
it sounds for me as if you lost frames when you write them in a text file is that right ?
Regards
Andi
09-29-2014 03:31 AM
Hi Andi.
I cant attach zip file also 😞
I know that the sensor is sending message every 10ms (100 messages/second).
Yes, you are right ....my software is reading all the frames but when I write in text file, I am missing some messages.
10-01-2014 03:04 AM
Hello swap15,
programm a short vi where you only read and write the files and try to solve it step by step.
Maybe you got some effect in your programm which you don't mentioned yet.
Regards
Stefan
10-02-2014 01:46 AM
Hi Britzelm,
I tried .......My software is reading all the messages but I am not getting all the values when I log the data. In my data logger I dont have any loop and it executes all the time when main reading loop executes
regards,
swap
10-02-2014 02:24 AM - edited 10-02-2014 02:52 AM
Hi swap15,
could you post your example program ?
If you could not upload your vi send a screenshot
Regards,
Stefan