Shared memory interface (was: Re: Questions on my mind)


Thread Starter

Jiri Baum

Phil Covington:
> The code that deals with the I/O (digital and analog) is the foundation
> on which the rest will be built. It is critical that this be coded so
> that people has something to work to. It would be great just to have a
> defined way of interfacing to I/O and shared memory. I agree with you
> that a simple model is the way proceed.

The SMM already has such an interface defined. I know I've been a bit tardy implementing the stuff behind it, but I have the excuse of a precedent :)

It's in smm/smm.h

I'll try to explain how to use it from C in short tutorial form.

First, we must initialise the library:

plc_update(); /* get initial values from the map */

Then we get the points we want:

plc_pt x1,y2,z3;


Now the main loop:
while (1) {
if (plc_get(x1)) {
plc_set(y2,plc_get(z3)); /* LD Z003, OUT Y002 */
} else {
plc_set(y2,0); /* RST Y002 */

plc_update(); /* do the IO scan */

Theoretically you should close the library at the end, but the above is an
infinite loop anyway :)


Actually, I'll stick this in the CVS, too (doc/smm/tutorial.txt). Anyone who has a better way than me with words feel free to improve it.

Jiri Baum <[email protected]>
Windows is not popular. Windows is *widespread*. Linux is popular.

LinuxPLC mailing list
[email protected]