BennieC

Copy INT into second half of a DINT

5 posts in this topic

Hi all, 

I'm trying to copy an INT into bits 16 to 31 of a DINT for a VSD speed control. It sounds easy in theory, but I'm struggling to find a practical solution.

Is there a straight forward way of achieving this? I'm using Logix Designer

Thanks

Edited by BennieC

Share this post


Link to post
Share on other sites

There is a command for that in CLX but you didn't mention which PLC you are using.

BTD - Bit Field Distribute

Page 384

http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1756-rm003_-en-p.pdf

1 person likes this

Share this post


Link to post
Share on other sites

Also look at the COP instruction. If you set up your INT as one INT in an array of 2 INTs with the other INT being whatever needs to be in the lower word of the DINT.  You then COP the array into the DINT using a length of 1.

Alternatively, you can MUL the INT by 2^16 (to shift the bits 16 places to the left) into a holding DINT tag and then MVM (masked move) the holding DINT into the destination DINT.

It looks like the BTD instruction will be the cleanest option, though.

Share this post


Link to post
Share on other sites

Multiply your integer by 65536 with the destination being the double integer (or Long)

Share this post


Link to post
Share on other sites

Thanks for the replies, I'll give it a go after I've sorted the next problem I've found with the setup of addressing using RSNetWorx. 

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