simonongsk

Map Physical Input and Output to Word

7 posts in this topic

How to map physical Input and output into variables type of Word?  It is easy in CX programmer with Mov 0 to  Inp_Word_0  (type Channel)

Global Variable  -----> Inp_Word_0 ,      Inp_Word_1     Type Word

                                      Out_Word_0,        Type Word                          

Example in NX1P2   map Input Bit 00 to Input Bit 15 to a Inp_Word_0,     and    map  Input Bit 16 to Input Bit 23 to a Inp_Word_1

                                     map Outpu Bit 00 to Input Bit 15 to a Out_Word_0, 

 

 

                                 

 

Share this post


Link to post
Share on other sites

You have to make a union.    See below:

First, make a union under data types like this:

Union1.jpg.ea3d03c445708928cfbe36c930f3e

Then create a variable that is of the type that you created:

Union2.jpg.301856bb548a4a18f5ab8b4934da9

Then use the variable as both a bit and a word like this:

Union3.thumb.jpg.9c1c1cd4543598857177890

You can ignore my comments about VB in the ladder, this was an example that I did for someone else. 

Share this post


Link to post
Share on other sites

I am using the above method:-), I thought there is a more simple method instead of writing bits to bits. Is there a way of assigning a variable at IO Table directly with the union variable?

 

Share this post


Link to post
Share on other sites

Elements of a union or structure (with the period in the name) cannot be used in the I/O Map.

Share this post


Link to post
Share on other sites
On 7/16/2019 at 7:19 PM, simonongsk said:

I am using the above method:-), I thought there is a more simple method instead of writing bits to bits. Is there a way of assigning a variable at IO Table directly with the union variable?

 

Just assign a word variable to the input channel (in my example, I am using an input card) and then put a move instruction in the first rung of code that moves the input word variable into the unionVariable.word and done.

Of course output words would be at the very end of your program and you would be moving from the unionVariable.word into the output word.

Share this post


Link to post
Share on other sites

It will only work if I am using modular input and output . But I am using nx1p2. There is no channel as compare to Cp1e

Share this post


Link to post
Share on other sites

Ah, then unfortunately you will have to do it bit by bit at the beginning of the code for inputs and at the end of the code for outputs.

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