simonongsk Posted July 16, 2019 Report Posted July 16, 2019 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, Quote
Michael Walsh Posted July 16, 2019 Report Posted July 16, 2019 You have to make a union. See below: First, make a union under data types like this: Then create a variable that is of the type that you created: Then use the variable as both a bit and a word like this: You can ignore my comments about VB in the ladder, this was an example that I did for someone else. Quote
simonongsk Posted July 16, 2019 Author Report Posted July 16, 2019 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? Quote
Crossbow Posted July 17, 2019 Report Posted July 17, 2019 Elements of a union or structure (with the period in the name) cannot be used in the I/O Map. Quote
Michael Walsh Posted July 18, 2019 Report Posted July 18, 2019 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. Quote
simonongsk Posted July 20, 2019 Author Report Posted July 20, 2019 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 Quote
Michael Walsh Posted July 22, 2019 Report Posted July 22, 2019 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.