Sign in to follow this  
Followers 0
darmoll

GX Works2 Reversing word order (32bit)

5 posts in this topic

Hi, I am interfacing a device with a Mitsu PLC (Q04UDE) via modbusTCP (QJ71MT91). The device's modbus data is mostly 32-bit float and in big-endian format (most significant word first). However it seems the PLC/GxWorks2 reads/writes floats in little-endian format (least significant word first). There doesn't seem to be any obvious method of reversing the word order in GxWorks2, resulting in incorrect readings. Can anyone provide any assistance with this? i.e what is the best method for reversing the word order? Thanks, Darren ps I am using GxWorks2 V1.77F

Share this post


Link to post
Share on other sites
Don't know if it works with GX Works (I'm using GX IEC Dev) But have you tried the ROR or ROL function? ROR - Rotate Right without carry flag. ROL - Rotate Left without carry flag. RCR - Rotate Right through carry flag. RCL - Rotate Left through carry flag. I think the function ROR is named ROR_2_M in GX Works.

Share this post


Link to post
Share on other sites
You can use XCH for swapping the content of two words. It's worth checking if there isn't an option in the card/software itself in the case of when data arrives in a certain format. Edited by Mitsu

Share this post


Link to post
Share on other sites
Thank you both for your suggestions. I have tried both but I am still having trouble. 1. DROR/DROL doesn't work on floats. It does seem to work on double words, but there doesn't appear to be a function for converting double words to floats. 2. I tried using XCH to swap the words, but then I am left with 2 words (rather than 1 float). I couldn't find any options in the card/software for reversing the float 'endianness'. I would have thought this would be a relatively common issue, I am surprised GxWorks does not account for this. I have seen other software implement options for the float 'endianness'. Does anyone have any more suggestions?

Share this post


Link to post
Share on other sites
A float is 2 words (32-bit) so i'm not sure what you mean by "I tried using XCH to swap the words, but then I am left with 2 words (rather than 1 float)." What are you intending to do with the floats? Do you want to use them in your plc program? In that case, you have to approach the data with float instructions instead of normal instructions (E*, E-,...). Mitsubishi doesn't really have datatypes in a sense that the whole data adressing structure is 16-bit (word). The way you approach the data (the instruction) defines the datatype. You can do "+ D10 D20" (word addition), "D+ D10 D20" (double word addition) and "E+ D10 D20" (float addition). Edited by Mitsu

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
Sign in to follow this  
Followers 0