Configure Python 3.8.0 to Deploy Engine Demo Scripts in NI VeriStand

Updated Sep 19, 2023

Environment

Software

  • VeriStand 2021 R2

Operating System

  • Windows

Other

  • Python 3.8.0
  • Pythonnet 2.5.2

This article focuses on configuring Python 3.8.0 environment and deploying Engine Demo Scripts in NI VeriStand with an internet connection to a PC. Python for .NET (pythonnet 2.5.2) is a package that gives Python programmers nearly seamless integration with the .NET 4.0+ CLR on Windows. The niveristand package implemented in Python contains an API (Application Programming Interface) that interacts with NI VeriStand systems. 
This article's outcome is automating the NI VeriStand application using Python. The intended audiences are HIL System developers seeking to automate the test process by integrating HIL System into a continuous integration workflow.


Pre Requisite Knowledge Required:

  1. NI VeriStand 2021 R2
  2. Python Scripting

Python Setup in Windows System

  1. Download the Python 3.8.0 setup file.
  2. Run the setup file to install Python 3.8.0 on the windows system.
  3. Check the box Add Python 3.8.0 to PATH to add the Python file to default paths.
  4. Click on Install Now to start the installation.
Python Setup
  1. Once the installation is complete, close the setup window.
2.PNG
  1. Press <Windows Key- R> to open the Run Window and type cmd to open the Command Prompt Window.
  2. Type the command python -m pip install niveristand to install NI VeriStand APIs in Python.
  3. Once the installation is complete, close the Command Prompt Window.


Running Python Script to Automate Engine Demo in NI VeriStand

  1. Click on the IDLE (Python 3.8. 64 bit) icon to open the Python 3.8.0 shell.
IDLE
  1. Click on File>> New File to open a new Python Script File.4.png
  2. Copy the Engine Demo Basic script from Engine Demo Examples into the new Python script file.
  3. Click to File>>Save to save this script by Engine Demo Basic name.5.png
  4. Go to line number 63 and edit the run_engine_demo file path to the file path where the Engine Demo Basic.py file is saved. For example, 'C:\\Users\\XX\\Documents\\VeriStand Projects\\Engine Demo\\Python Scripts'.
12.png
  1. Close the IDLE (Python 3.8. 64 bit) window.
  2. Locate NI VeriStand 2021 R2 shortcut and double-click to start NI VeriStand.
6.PNG
  1. On the landing page, click on Engine Demo.
7.png
  1. Create the Engine Demo Project and save it at the default file path.
  2. Deploy the Engine Demo VeriStand Project (running on windows OS) by clicking on the Idle and then Deploy.
8.png
  1. Once the Engine Demo project is deployed successfully, verify that VeriStand Engine is in Connected status.
9.png
  1. Right-click on the Engine Demo Basic.py script saved in step 4.
  2. Select Edit with IDLE>>Edit with IDLE 3.8 (64 Bit). This will open the Python Script in edit mode.
10.png
  1. Click on Run>>Run Module to run the Python script.
11.png
 
 

Once the above steps are performed, the user can observe that the automation steps coded in the Engine Demo Basic Python script are executed to
  1. Turn on the engine, set the desired_rpm to the passed value of 2500 for 20 seconds in NI VeriStand Application.
Result-1.png
  1. Shut down the engine after 20 seconds in NI VeriStand Application.
Result-2.png
  1. Python Output:
Result-3.PNG