J
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_init("demo");
plc_update(); /* get initial values from the map */
Then we get the points we want:
plc_pt x1,y2,z3;
x1=plc_pt_by_name("X001");
y2=plc_pt_by_name("Y002");
z3=plc_pt_by_name("Z003");
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
plc_done();
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
--
Jiri Baum <[email protected]>
Windows is not popular. Windows is *widespread*. Linux is popular.
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
> 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_init("demo");
plc_update(); /* get initial values from the map */
Then we get the points we want:
plc_pt x1,y2,z3;
x1=plc_pt_by_name("X001");
y2=plc_pt_by_name("Y002");
z3=plc_pt_by_name("Z003");
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
plc_done();
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
--
Jiri Baum <[email protected]>
Windows is not popular. Windows is *widespread*. Linux is popular.
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc