HALCON: Set IP Address

This topic introduces how to obtain and modify the camera’s current IP address, subnet mask, and gateway in Windows using the HALCON sample programs provided by Mech-Mind.

Obtain Sample Program and Select Camera

Before obtaining or modifying the IP address, you need to download the sample program and set the camera to be connected in the program.

  1. Download the configure_camera_ip_address sample program: select Code ‣ Download as ZIP.

  2. Open the sample program in HDevelop: Open HDevelop, and drag the sample program into HDevelop.

  3. Select the line containing the info_framegrabber operator in Program Windows, and click step_over in the toolbar or press the F6 key to run this line.

  4. In the Control Variables area, double-click DeviceInfos to display a list of all the available cameras.

    ../../_images/camera_information_1.png
  5. In the list, double-click the camera that you want to connect, and copy the camera name after unique_name: or user_name:.

    ../../_images/camera_information_3.png
  6. Locate the following line, and replace MechEye with the copied unique_name or user_name.

    DeviceInfo := 'MechEye'
    

Obtain Camera IP Address, Subnet Mask and Gateway

Please follow these steps to obtain the current IP address, subnet mask and gateway of the camera:

Run the sample program by clicking run or pressing the F5 key. In the Control Variables area, check the following variables for the current IP address, subnet mask and gateway of the camera.

  • CurrentIPAddress: IP address

  • CurrentSubnetMaskString: subnet mask

  • CurrentDefaultGatewayString: gateway

Note

If the camera firmware version is 2.0.2 or below, the above information cannot be obtained, and the error message will be recorded in the Exception variable.

Set Static IP address

This sample program sets a static IP address by default. Please follow these steps to modify the IP address, subnet mask and gateway of the camera.

  1. Locate the following line, and change the IP address, subnet mask and gateway to the values to be set.

    IPAddressString := '192.168.1.100'
    SubnetMaskString := '255.255.255.0'
    DefaultGatewayString := '192.168.1.1'
    
  2. Run the sample program by clicking run or pressing the F5 key.

  3. Restart the camera to make the new settings take effect.

Set Dynamic IP Address

Please follow these steps to dynamically assign an IP address to the camera.

  1. Locate the following line, and replace true with false.

    set_framegrabber_param (AcqHandle, 'GevCurrentIPConfigurationPersistentIP', true)
    
  2. Run the sample program by clicking run or pressing the F5 key.

  3. Restart the camera to make the new settings take effect.

Note

When the camera is connected to the IPC directly, the IP address of the camera cannot be dynamically assigned.