Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

how does shared memory schedule read and write?

Hi,
 
I have a PIC-7041 RT board installed in a PC running Windows2000.
 
On the RT side, I am sampling data with a BNC-2110 connection box and writing those data(1 to 2 byte, which is very small) to a certain address of the shared memory. The sampling and writing is done with a timed loop.
 
On the PC side, I am getting the data from the same address of the shared memory in 7041 board. It has been done by using a "While loop" periodically.
 
Most time, it works ok. Occasionally, it seems that there is error in the data.
 
I wonder how the shared memory schedule the write from the RT board itself and the read from Windows LabVIEW, since I assumes that there's no explicit coordination between the data access from different sources.
 
1. Is it possible that sometimes the access to the shared memory in the RT board from PC and RT itself clashes with each other?
2. How to avoid that or is there any walk around?
 
 
Ray
0 Kudos
Message 1 of 4
(3,963 Views)

Dear Ray:

      Listed below are some useful links that explain shared memory. There is an example that you can refer that shows the SGL VIs they use to achieve time critical capability. From your application your rate surely is not a problem. You are writing to shared memory address and you are not writing to file, right. That implies you should be able to get determinism.  Can you post a snapshot of your simple code for me to look at? What is the error you are seeing? Is it on the host VI or RT VI?

http://zone.ni.com/devzone/cda/epd/p/id/3884

http://zone.ni.com/devzone/cda/tut/p/id/3959

http://zone.ni.com/devzone/cda/tut/p/id/3898

http://forums.ni.com/ni/board/message?board.id=170&message.id=122469&requireLogin=False

http://zone.ni.com/devzone/cda/tut/p/id/2833

You want to make sure that the shared resources are minimized completely and eliminate possibilities of priority inversion. The explanation of shared resource and priority inversion is also mentioned in links above.

Hope this helps. Please let me know.

Best regards
Avi Harjani



0 Kudos
Message 2 of 4
(3,940 Views)

Dear Avi,

Thanks for your response and hints.

It appears that the error was on the host computer. Basically I've got the data I was not expecting to obtain (no error message).

I believe I have figured out what went wrong. I was trying to read from RT (for two different addresses) using "RT-peek" in two different while loops. Although I assigned different values to "wait until next ms multiple" for each individual loop, those two read operations might still race into each other occassionally. I have combined two RT-peek operations and placed them in one while loop. It seems to correct my problem.

 

Thanks for your help!

 

Ray

0 Kudos
Message 3 of 4
(3,810 Views)
Dear Ray:
 Thanks for the update.
Regards
Avi


0 Kudos
Message 4 of 4
(3,783 Views)