indirect access to hardware inputs

3 posts in this topic


is it possible to access to hardware inputs indirect? I want to use a function like

val := read_digital(module_nr, bit_nr);


I have found this page:

which says i need to map all digital inputs by using the controller tag name to put it into an bool array.


On S7, there is this function: PEEK_BOOL(area := 16#81, dbNumber := 0, byteOffset := module_nr, bitOffset := bit_nr);


Edit: I am using CompactLogix, Studio 5000.

Edited by AndiTheBest

Share this post

Link to post
Share on other sites

Welcome to the forum.  There is no method, that I'm aware of, to indirectly address module and bits via a function like you wish without mapping it to an array or other structure first.  Module input and output definitions are unique and rarely share the same map.  There are some tricks you can do with aliasing but I don't believe it would yield the same result.

If the digital modules are of all the same type, an AOI(s) (similar to S7s FB) could be created that would do what you want.

1 person likes this

Share this post

Link to post
Share on other sites

As far I can see, you may get the input inderctly but not the slot number. I haven't try with real plc but the following code didn't prompt any error. Wish it help



Edited by slcman

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now