Use Python to return information about analog input ports

The ain Python module allows you to return information about the device's analog input ports.

 

  1. Select a device in Remote Manager that is configured to allow shell access to the admin user, and click Actions > Open Console. Alternatively, log into the IX30 local command line as a user with shell access.

    Depending on your device configuration, you may be presented with an Access selection menu. Type shell to access the device shell.

  2. At the shell prompt, use the python command with no parameters to enter an interactive Python session:

    # python
    Python 3.10.1 (main, Mar 30 2023, 23:47:13) [GCC 11.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    

  3. Import the ain module and the Name class:
    >>> from digidevice import ain
    >>> from digidevice.ain import Name
    >>>

    The Name class uses the following naming:

    • Analog input port 1: Name.ain1

    • Analog input port 2: Name.ain2

    • Analog input port 3: Name.ain3

    • Analog input port 4: Name.ain4

  4. To determine the current/voltage mode of an analog input port, use the get_mode function:
    >>> ain.get_mode(Name.ain1)
    <Mode.voltage: 'VOLTAGE'>

    Returns either:

    • Mode.voltage: 'VOLTAGE': The mode is voltage.

    • Mode.current: 'CURRENT': The mode is current.

  5. To determine the value of an analog input port, use the get_value function:
    >>> ain.get_value(Name.ain1)
    			12

    The return value will be in either:

    • mV, if the mode is voltage.

    • uA, if the mode is current.

  6. Use Ctrl-D to exit the Python session. You can also exit the session using exit() or quit().