chrisb4748 Posted August 31, 2018 Report Posted August 31, 2018 Hi, I am looking for a way to be able to convert an IP Address into HEX. Any ideas? Thanks
Gambit Posted August 31, 2018 Report Posted August 31, 2018 (edited) 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 August 31, 2018 by Gambit
chrisb4748 Posted August 31, 2018 Author Report Posted August 31, 2018 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.
Gambit Posted August 31, 2018 Report Posted August 31, 2018 (edited) So something like this 192.168.3.200 Edited August 31, 2018 by Gambit
chrisb4748 Posted August 31, 2018 Author Report Posted August 31, 2018 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
Gambit Posted August 31, 2018 Report Posted August 31, 2018 (edited) 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. The Temp variable is a local array of Word(0..1) Edited August 31, 2018 by Gambit
chrisb4748 Posted August 31, 2018 Author Report Posted August 31, 2018 Brilliant. Thanks very much for the help. Absolute Pro!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now