PLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. jnorris
  2. PLCnext Engineer
  3. Saturday, 10 October 2020

I am working on the start of a project from home and don't have access to the hardware to test right now.  When I go to the Data List of an Axioline module, like a DI16 or DO16, I have the option to assign a BOOL variable to each individual I/O point; but there is also an option at the top of the list that says ~DI16 (or ~DO16) that will not accept a BOOL variable; but will accept a WORD.  I assume this holds the total value of the active inputs/outputs; so if I assign a WORD to this can I use the individual elements of the WORD in my program? 

IE: ~DI16 : I1  ---> IN1 : I.1

If not, is there a way to assign I/O points to a common variable, or do I have to assign them to individual variable and then map them over element by element to a program variable? 

Martin PLCnext Team Accepted Answer Pending Moderation
1
Votes
Undo

Hello,

Yes, you are correct, you can assign either Port variables or Global variables of type WORD to the ~DI16 and ~DO16 process variables.

You can then access the individual bits in those words using the .X0, .X1, ... access modifiers. So, if the name of your WORD variable is MyWord, you can access bit 0 of that word using the variable MyWord.X0 in your code.

You might want to check that the byte order of the WORD variable is what you are expecting, to save rework later on. One benefit of connecting individual BOOL variables to digital inputs is that, if you get the byte order wrong, you only need to rearrange the connections in the Data Table. If you are using WORD variables with access modifiers, then any rework will require a little more effort.

There is a discussion on byte order here:

https://www.plcnext-community.net/en/discussions-2-offcanvas/low-and-hi-byte-of-word-is-overturned.html

... which will hopefully steer you in the right direction.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

jnorris Accepted Answer Pending Moderation
0
Votes
Undo

Ok, thanks Martin!

 

I think I've decided to actually just map the IO to individual elements of a BOOL array; it makes for neater wire labeling since I don't have to include the bit modifier X.  Avoiding byte swaps is a bonus!

jnorris Accepted Answer Pending Moderation
0
Votes
Undo

Well, maybe I wont be assigning them to array elements... it doesn't seem to be an option.  I created a 1_16_of_BOOL variable in my program and set it to external access, but the elements do not come up as options when assigning variables to IO module, or as options to assign to ports.

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

It works for me ... in a Program, I create an variable as an array of BOOLs, with usage "IN port".

I have an instance of that program created in an ESM task.

In the PLCnext -> Port List window, I can attach digital inputs to the  individual elements of the array in the program instance.

There are a few different ways to connect I/O to variables ... perhaps you are in a different window?

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

jnorris Accepted Answer Pending Moderation
0
Votes
Undo

Sorry I had forgot to change it to an IN PORT usage after trying it as an external variable first.

 

 

jnorris Accepted Answer Pending Moderation
0
Votes
Undo

Just throwing this out there as a request for future ideas, it would be great if we could assign structure variables to the IO modules.  IE if I create a structure called "slot" and have 16 BOOLs inside of it "I1-I16" it would be nice to be able to  assign SLOT1.I1 to the actual module variable.

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hmmm ... that works for me too.

In a Program, I create an variable as a STRUCT containing at least one BOOL, with usage "IN port".

I have an instance of that program created in an ESM task.

In the PLCnext -> Port List window, I can attach digital inputs to the individual BOOL elements of the struct in the program instance.

(PLCnext Engineer 2020.6.2)

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

jnorris Accepted Answer Pending Moderation
0
Votes
Undo

Ok that is working now.  I don't know why it wasn't showing up as an option before.

  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.