FAQ: How to control ADI DAC Evaluation Boards (EVB) using python scripts?

Most of the latest ADI DAC EVBs are controlled by the ACE software. By making use of the ACE Remote Control function, DAC EVBs can be controlled via a python script.  

There are two practical ways to create a python code to remotely control the ACE software:
1. Create a python code from scratch. Referring to the ACE Remoting Client documentation under “ACE Help”.
2. Export python code from the ACE Macro tools. This option is recommended for a quick and easy to use way to generate a base python code. The ACE Macro tools basically record the actions done on the ACE software UI which can be exported as python code.

This document focuses on method 2. Discussing how to set up the ACE evaluation setup for remote control, recording a macro, and exporting to python scripts and sample codes.

Initial Setup

Make sure to install the latest ACE software and have the correct plugin for the DAC family you are using. In the example below, we use the NanoDAC plugin to control EVAL-AD5679RSDZ.

Hardware Requirements:
DAC Evaluation board
SDP-B

SW Requirements:
ACE Software
NanoDAC 
Python IDE of choice with pythonnet module

Before starting the macro recording or running a generated Python code, there are some requirements to be met. The example below shows them using EVAL-AD5679RSDZ.
1.  Make sure EVAL-AD5679RSDZ thru SDP-B is detected by ACE Software. Please refer to the EVB user guide on how to set up ACE with the EVB via the SDP-B Board.

 

2. The IPC Server is enabled (under Settings of ACE SW) and the Port Number is the same as the port number in the python code.

Recording Macro and Exporting Python Script

  1. Open the ACE software. If the hardware is properly connected, the main UI should look like this
  2. On the left side of the ACE Software UI, select Tools, then Macro Tools.
  3. A Macro Tools Window will appear on the main UI. Hovering above the buttons will show what general functions each button has. Click on the record macro commands button to start recording.
  4. Once the Macro Tools started recording, proceed to do the desired tasks on UI. In the given sample code, the actions done include (1) selecting the hardware, (2) selecting the AD5679R, and (3) trying out all the functions on the AD5679R Plugin UI.

  1. The Commands text field on the Macro Tools Window will be displaying each command recorded by the macro tool i.e., updating DAC input data registers, using GPIOs, changing power modes, etc. Click the Stop button to finish recording the macro commands. Then click on the Generate.

  2. A Generated Code Editor window will pop-up. Click on the drop-down menu and select python to convert your ace macro into python code. Click Export to choose where to save your file and finish the conversion.
  3. Now that the python code has been generated, the exported file, in *.py format, can be used and imported to the python IDE for execution.
    Important reminder: Before running the script, make sure that the ACE software is open since the python script controls the EVB through the ACE Remoting Client function.

 

Sample Python Code Generated from ACE Macro

# Generated code compatible with Python 2.7+

## Copyright (c) 2019 Analog Devices, Inc.  All Rights Reserved. This software is proprietary to Analog Devices, ##Inc. and its licensors.

## These code snippets are provided ‘as is’ with no warranties, guarantees of suitability, or acceptance of any ## ## liability, for their use.

# Requirements:

#  - pythonnet

import sys

sys.path.append(r'C:\Program Files (x86)\Analog Devices\ACE\Client')

# noinspection SpellCheckingInspection

import clr  # noqa

# noinspection SpellCheckingInspection

clr.AddReference('AnalogDevices.Csa.Remoting.Clients')

 

# noinspection PyUnresolvedReferences,SpellCheckingInspection

from AnalogDevices.Csa.Remoting.Clients import ClientManager  #noqa

 

# Make sure the localhost is matched with the IPC server settings

def main():

    manager = ClientManager.Create()

    client = manager.CreateRequestClient("localhost:2357")

    execute_macro(client)

    # client.CloseSession()

# noinspection SpellCheckingInspection

def execute_macro(client):

 

    # UI Select AD5679RBoard Hardware on the main window

    client.AddByComponentId("AD5679RBoard")

    client.NavigateToPath("Root::System")

 

    # UI Select AD5679R Subsystem on the signal chain view

    client.set_ContextPath("\System\Subsystem_1\EVAL-AD5679RSDZ")

    client.Run("@DefaultView")

 

    # UI Navigate to AD5679R main plugin UI

    client.set_ContextPath("\System\Subsystem_1\EVAL-AD5679RSDZ\AD5679R")

    client.NavigateToPath("Root::System.Subsystem_1.EVAL-AD5679RSDZ.AD5679R")

 

    # UI Select gain under the configuration tab

    client.SetIntParameter("virtual-parameter-GainSelector", "1", "-1")

    client.Run("@InitialConfigWizard")

 

    # Modify data on the DACx Input Register text field in the UI

    client.SetBigIntParameter("Input_Value_DAC0", "65535", "-1")

    client.SetBigIntParameter("Input_Value_DAC1", "65535", "-1")

    client.SetBigIntParameter("Input_Value_DAC2", "4095", "-1")

    client.SetBigIntParameter("Input_Value_DAC3", "4095", "-1")

 

    client.Run("@ApplySettings")

 

    # UI Use the Hardware LDAC Button

    client.Run("@HardwareLdac")

 

    # UI Navigate to Input Register Tab 1 (DAC4-DAC7)

    client.SetIntParameter("virtual-parameter-MultiPanes", "1", "-1")

 

    # Modify data on the DACx Input Register text field in the UI

    client.SetBigIntParameter("Input_Value_DAC4", "65535", "-1")

    client.SetBigIntParameter("Input_Value_DAC5", "65535", "-1")

 

    # UI Use the Hardware LDAC Button

    client.Run("@HardwareLdac")

 

    # UI Navigate to Input Register Tab 2 (DAC8-DAC11)

    client.SetIntParameter("virtual-parameter-MultiPanes", "2", "-1")

 

    # Modify data on the DACx Input Register text field in the UI

    client.SetBigIntParameter("Input_Value_DAC8", "65535", "-1")

    client.SetBigIntParameter("Input_Value_DAC10", "65535", "-1")

 

    # UI Use the Hardware LDAC Button

    client.Run("@HardwareLdac")

 

    # UI Navigate to Input Register Tab 3 (DAC12-DAC15)

    client.SetIntParameter("virtual-parameter-MultiPanes", "3", "-1")

 

    # Modify data on the DACx Input Register text field in the UI

    client.SetBigIntParameter("Input_Value_DAC13", "65535", "-1")

    client.SetBigIntParameter("Input_Value_DAC15", "65535", "-1")

 

    # UI Use the Hardware LDAC Button

    client.Run("@HardwareLdac")

 

    # Modify data on the DACx Input Register text field in the UI

    client.SetBigIntParameter("Input_Value_DAC12", "65535", "-1")

 

    # UI Use the Software LDAC Button for DAC12

    client.Run("@SoftwareLdac12")

 

    # Modify data on the DACx Input Register text field in the UI

    client.SetBigIntParameter("Input_Value_DAC14", "4095", "-1")

 

    # UI Use the Software LDAC Button for DAC14

    client.Run("@SoftwareLdac14")

 

    # UI Navigate to Input Register Tab 0 (DAC0-DAC3)

    client.SetIntParameter("virtual-parameter-MultiPanes", "0", "-1")

 

    # UI Enable/Disable LDAC Mask for DAC0

    client.SetBoolParameter("LDAC_Mask_DAC0", "True", "-1")

 

    # UI Select Power Mode for DAC0

    client.SetIntParameter("Power_Mode_DAC0", "1", "-1")

    client.SetIntParameter("Power_Mode_DAC0", "3", "-1")

    client.SetIntParameter("Power_Mode_DAC0", "0", "-1")

 

    client.Run("@ApplySettings")

 

    # UI Enable/Disable Internal Reference

    client.SetIntParameter("Internal_Ref_En", "1", "-1")

    client.SetIntParameter("Internal_Ref_En", "0", "-1")

 

    client.Run("@ApplySettings")

 

    # Memory Map, Modify Register “160”=0xA0 BitN

    client.SetRegisterBit("160", "0", "True", "-1")

    client.SetRegisterBit("160", "1", "True", "-1")

    client.SetRegisterBit("160", "2", "True", "-1")

    client.SetRegisterBit("160", "9", "True", "-1")

    client.SetRegisterBit("160", "10", "True", "-1")

    client.SetRegisterBit("160", "11", "True", "-1")

    client.SetRegisterBit("160", "15", "True", "-1")

 

    client.Run("@ApplySettings")

 

    # Memory Map, Modify Register “192”=0xC0 BitN

    client.SetRegisterBit("192", "0", "True", "-1")

    client.SetRegisterBit("192", "2", "True", "-1")

    client.SetRegisterBit("192", "5", "True", "-1")

    client.SetRegisterBit("192", "9", "True", "-1")

    client.SetRegisterBit("192", "13", "True", "-1")

    client.SetRegisterBit("192", "15", "True", "-1")

 

    client.Run("@ApplySettings")

 

    # UI Use the Software Reset Button

    client.Run("@SoftwareReset")

 

    # UI Use the Main Reset Button

    client.Run("@Reset")

 

 

if __name__ == "__main__":

    main()

 

The python script can be run in any python IDE program. Make sure to check initial setup procedures.

 

What to do when the desired device function is not on the ACE UI plugin or memory map?

In case the user cannot find a certain function on the main UI or memory map, therefore cannot record the function on the macro tool, the RawWriteRegister function can be used.

Say the user wants to write to a specific register address from the datasheet. For example, writing to and updating the data on DAC2 by full-scale. From the datasheet of AD5679R, we have


The combined Command and Channel Address bits will represent the register address 0x32 in hex while the data for a full-scale output would be 0xFFFF in hex. The following syntax can be used in python

 

client.RawWriteRegister(“Addr”, “Data”)

Where:

Addr = decimal value of the register address

Data = decimal value of the desired data to write

 

In our example’s case,

client.RawWriteRegister(“50”, “65535”)

This command sends a value of “65535” or 0xFFFF to the device’s register address “50” or 0x32.

 Just insert this code within the execute_macro sub function in the python code.



Put sample codes in a code box.
[edited by: iandal at 12:32 PM (GMT -4) on 18 Oct 2021]