01-22-2013 09:53 AM
Hi,
I'm working on a tension project. I read data with the use of OPC. My variable is bunded to an OPC address. I want to plot this data with the resolution of 10ms. Is it possible?
I upload a sample code , that I tried to solve this problem. but is is not accurate, and not working good.
Do you have any idea to plot a real-time data with the resolution of 10 ms?
Solved! Go to Solution.
01-22-2013 10:00 AM
Hi beginner,
but is is not accurate, and not working good.
Well, you heavily use the CPU just as heating element...
- Use a simple Wait function instead of comparing timestamps (btw your comparison is flowad...)
- put a wait function in the first loop.
- Write better error descriptions when asking for help, "not working good" is the same as "it works"...
01-22-2013 10:27 AM
🙂
Well It's working as it's ploting something, but it's not working well as the time is not accurate. I used a wait of 10 ms in a single while loop. but problem still ramins. Is there any accurate structure to use?
01-22-2013 10:44 AM
Waits of 10 ms on a desktop OS are not very accurate as the OS often disrupts things for longer than that.
If you need accurate timing at the 10 ms level, you should do it in hardware. Does the device communicating via OPC have hardware timing?
A Producer/Consumer loop where the data is acquired in one loop and displayed in another loop is also useful in such applications.
Lynn
01-22-2013 12:10 PM
well, there is a timestamp variable between opc variables. I have never used it. I found a timed loop in labview. can I use it for accurate timing?
01-22-2013 01:52 PM
01-22-2013 02:22 PM
so you mean there is no way to have a accurate timed loop in a non real-time OS? what about the real-time module?
01-22-2013 02:30 PM - edited 01-22-2013 02:31 PM
Hi beginner,
you really have to redesign your project!
1) Does the OPC data source really supply new data with sample rates of >100Hz?
2) Do you really need to plot new data with a rate of 100Hz? You can't watch the chart that fast!
If 1) applies: Make a separate loop to collect data at the needed rate In a shift register (or any other method to store data). If 1) does not apply: lower the rate at which you try to read new data!
2) applies (no alternative!): update your chart with a rate of (let's say) 5Hz. That is still fast enough when viewing your plot and is much less CPU consuming.
You have to separate the task of collecting data from the task of displaying them!
To your last question:
Any (standard) multitasking OS will imply a great jitter in your loop timings. With a RT-OS that jitter is much lower, but still non-zero. Look at the specifications...