Michael Ong

Convert DINT to 2 word

3 posts in this topic

Hi Sir,

I'm using NX1P2-9000 CPU, How can i convert DINT to 2 WORD?

Example:

input from HMI Data will 12345678, I need to export this DATA to SCADA. From PLC to SCADA using Modbus interface which is accept WORD or BYTE DATA. So how can i convert this DINT to 2 difference WORD then i can move to 2 difference modbus address.

 

Thanks

Share this post


Link to post
Share on other sites

One option would be to use CopyNumToDWORD will convert it to DWORD, then you can use MoveDigit and move 4 digits starting at first to a word, then move 4 digits starting at 5th to another word...

As another option you can use ToAryByte to convert the DINT to an array of bytes.

Can your SCADA reassemble the data into a DINT once it receives it?

Share this post


Link to post
Share on other sites

not sure i recall instruction set but this can be done on any platform using generic mask operations

Word_Low = MyDint AND 65535 ; AND with 0xFFFF to get the lower 16 bits

Word_High = MyDint \ 65536 ; integer division (or shift right 16 places) to get the higher 16 bits

 

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