C
Hi all
I've more or less got the simple demo PLC hacked into shape and will attempt to wrestle it into the archive soon.
It consists of two executables, smio and smdisp. smdisp is the general purpose map displayer hacked into using a shared memory map amd a kludge
to allow forcing of outputs. The shared memory map I am using is not SysV shared mem it is ram excluded from the Linux mm and is reserved by telling the kernel you have 1 mb less than you actually have. mmap() is used to map a struct sized portion of this into user space. The pointer to struct returned by mmap() is used to access the map structure. Dereferencing this
pointer allows us to read and write to the structs in the reserved ram. All this is a lot simpler than it sounds.
The smio executable does the same shared mapping routine, does some things to setup and init the card and then goes into a read, solve, write loop. The two processes use "hit or miss" synchronization for now, if one is using the map, the other busywaits until it is done.
The solve part, the P in plc, is C code for now. We don't have a ladder compiler or a full suite of IEC1131 languages at our disposal (hint)
I'll post this working but horribly terse code tomorrow or Monday. The bad part is that it isn't real useful unless you have a dio48 or
dio48H card. The good part is that the lplc project actually has what is technically a plc available.
As far as the solving part is concerned, I have defined some macros so that we can do code like this:
if( I1 && I3 ) Q13; else !Q13;
That's the part I could use some ideas on. Ladder logic assumes the else clause. It would be nice if we can make that automatic. Or perhaps it is useful to leave an output on. In some places, I'm sure it would be. But, you guys are the control experts. I've attached the defines and the functions they use.
I'll make a tarball for anyone who's interested, I am having line problems again so It'll be probably be tomorrow noon CST till I get it in the archive. If it can wait for a couple of days I can provide some docs.
Also, I'd like to pause at this point long enough where this model is comfy for all. Then we will put Jiri's smm in the middle. This will remain so
that we have a tool to test and develop I/O. Jiri's map model is enough different that user side apps will have to be developed against that. I also need this model for some immediate applications. Doing the logic in C is fine for this as I am not a ladder maven anyway.
Regards
Curt W.
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc
I've more or less got the simple demo PLC hacked into shape and will attempt to wrestle it into the archive soon.
It consists of two executables, smio and smdisp. smdisp is the general purpose map displayer hacked into using a shared memory map amd a kludge
to allow forcing of outputs. The shared memory map I am using is not SysV shared mem it is ram excluded from the Linux mm and is reserved by telling the kernel you have 1 mb less than you actually have. mmap() is used to map a struct sized portion of this into user space. The pointer to struct returned by mmap() is used to access the map structure. Dereferencing this
pointer allows us to read and write to the structs in the reserved ram. All this is a lot simpler than it sounds.
The smio executable does the same shared mapping routine, does some things to setup and init the card and then goes into a read, solve, write loop. The two processes use "hit or miss" synchronization for now, if one is using the map, the other busywaits until it is done.
The solve part, the P in plc, is C code for now. We don't have a ladder compiler or a full suite of IEC1131 languages at our disposal (hint)
I'll post this working but horribly terse code tomorrow or Monday. The bad part is that it isn't real useful unless you have a dio48 or
dio48H card. The good part is that the lplc project actually has what is technically a plc available.
As far as the solving part is concerned, I have defined some macros so that we can do code like this:
if( I1 && I3 ) Q13; else !Q13;
That's the part I could use some ideas on. Ladder logic assumes the else clause. It would be nice if we can make that automatic. Or perhaps it is useful to leave an output on. In some places, I'm sure it would be. But, you guys are the control experts. I've attached the defines and the functions they use.
I'll make a tarball for anyone who's interested, I am having line problems again so It'll be probably be tomorrow noon CST till I get it in the archive. If it can wait for a couple of days I can provide some docs.
Also, I'd like to pause at this point long enough where this model is comfy for all. Then we will put Jiri's smm in the middle. This will remain so
that we have a tool to test and develop I/O. Jiri's map model is enough different that user side apps will have to be developed against that. I also need this model for some immediate applications. Doing the logic in C is fine for this as I am not a ladder maven anyway.
Regards
Curt W.
_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc