For more complex tasks which the controller has to carry out independently, that is without connection to a PC, the user can use scripts based on Python. For this purpose, PI offers PIPython, a collection of Python modules, with which PI controllers can be directly controlled using Python. The power of this programming language is, therefore, combined with the flexibility of PI's proprietary GCS commands. Furthermore, PIPython offers a variety of useful auxiliary support functions.
PIPython can be used starting with Python 3.6+ and it works on all platforms which support Python. Some additional functions are only available with standard operating systems such as Windows, Linux, and macOS.
Example of commands in Python
|from pipython import GCSDevice|
pi_device = GCSDevice ()
|# Load PI Python Libraries|
|pi_device.ConnectUSB ('123456789')||# Connect to the controller via USB|
|pi_device.SVO ('A', 1)||# Turn on servo control of axis "A"|
|pi_device.MOV ('A', 3.142)||# Command axis "A" to position 3.142|
|position = pi_device.qPOS ('A')||# Query current position of axis "A"|