chrisb4748

GXWorks 2 IP to HEX

7 posts in this topic

Hi,

I am looking for a way to be able to convert an IP Address into HEX.

Any ideas?

Thanks

Share this post


Link to post
Share on other sites

An IP address contains 4 addresses. Dec or hex is just a representation of Bits in word.

What is it you wan to do ? combine 4 decimal values into a double word in which every nibble contains one part of the IP adress ?
 

And which PLC are you using ?

Edited by Gambit

Share this post


Link to post
Share on other sites

I am using a Q06UDV

I want to be able to enter the IP address as a word. So I've split my IP Address into 4 different parts, ie IP_Part1, IP_Part2, IP_Part3, IP_Part4.

I am wanting to write that into the FB ModbusTCPClient which is in GX Works 2 Library.

The input will be going to the RemoteIPAddress, which is a  Double Word Unsigned.

Share this post


Link to post
Share on other sites

So something like this 192.168.3.200

IP.JPG

IP_2.JPG

Edited by Gambit

Share this post


Link to post
Share on other sites

So how am I able to take that Hex value and use it for my Remote IP Address in the Modbus TCP Client FB?

I have created my own FB with the Modbus TCP Client within

 

modbusFB.PNG

modbustcp.PNG

Share this post


Link to post
Share on other sites

okay first of all you do not need to specify  D0 D1 D2 etc. Create an array of words Like MyIPadress[0..3]

Then use MyIPaddress[3], MyIPaddress[2],MyIPaddress[1],MyIPaddress[0] instead of Direct adresses.

 

IP_3.JPG

IP_4.JPG

The Temp variable is a local array of  Word(0..1) 

 

Edited by Gambit

Share this post


Link to post
Share on other sites

Brilliant. Thanks very much for the help.

Absolute Pro!

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