ruili

interger as a coil in codesys

3 posts in this topic

I recently logged into a Schneider PLC (M241)machine and found a coding style I had never seen before. I understand what they are doing after a fashion, just not sure why it works.

They have assigned an INT to a coil as a means of avoiding duplicate coil symbols. I have always used a MOV function to write values to INT and do not understand the value change behavior that occurs when doing this.

They then simply use a >0 as a means of triggering output

Could anyone point me at an explanation or lesson on this? I am not a computer science programmer(can not read ST) and suspect that is why I do not know this technique already.

Share this post


Link to post
Share on other sites

You should get a type mismatch error doing that.

You can address a bit in an int and use it for coils:

(int).00 = first bit, (int).01 = second bit.

Share this post


Link to post
Share on other sites

It sounds like something I did in my Model train project. Several outputs are assigned to energize sections of track. With all the different train operations I wrote, it would mean pointing to that output bit many times in many subroutines which would be a mess. Its not a good idea to have an output referenced more then once in a program,

So what I did was use an integer. If the value is greater then zero, energize the output. So when I want to energize a section of track, I put a non-zero number in the integer. I do put a useful number in it. Say for example I am on Ladder 23, rung 10, I will put "2310" in the integer so I know where the track was energized from.

Mike

 

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