Analog I/O
The AnalogIO API provides two types of analog functionality:
Monitoring of on-board sensors, e.g. for voltages, currents, and temperatures;
Control of voltage (power) supplies, on Digilent Waveforms devices that support it.
The AnalogIO functionality, despite its name, does not overlap with the functionality of the AnalogIn and AnalogOut instruments. It cannot be used to control the analog signal outputs or to monitor the analog signal inputs.
An exception is that the AnalogOut instrument on an Analog Discovery 2 device (and perhaps some others) can be made to control the voltage sources of the device as if they were regular, low bandwidth analog output channels, by selecting an appropriate device configuration when opening the device. This feature can be useful in rare cases when a non-constant supply voltage is needed for testing. However, in most cases by far, only a static (constant) voltage is needed, and the easiest way to accomplish that is via the AnalogIO API.
Using the Analog I/O functionality
To use the AnalogIO functionality you first need to initialize a DwfLibrary instance. Next, you open a specific device. The device’s AnalogIO API can now be accessed via its analogIO
attribute, which is an instance of the AnalogIO
class:
from pydwf import DwfLibrary
from pydwf.utilities import openDwfDevice
dwf = DwfLibrary()
with openDwfDevice(dwf) as device:
# Get a reference to the device's AnalogIO functionality.
analogIO = device.analogIO
# Use the AnalogIO functionality.
analogIO.reset()
AnalogIO channels and nodes
The quantities that can be monitored and controlled by the AnalogIO functionality are organized in channels. Each channel can have one or more nodes.
A typical example is the USB Monitor channel of the Analog Discovery 2 device. It has 3 nodes: Voltage, Current, and Temperature, that can be used to report on these three quantities.
The USB Monitor channel is fully passive; its nodes can only be monitored. Other channels have nodes that can also be controlled, for example the Positive Supply and Negative Supply channels of the Analog Discovery 2. Those channels have two nodes each that can be controlled (Enabled and Voltage), and one node that can only be monitored (Current).
The AnalogIO.py example program enumerates the AnalogIO channels and nodes of any Digilent Waveforms device; it is recommended to study that program to understand how to use the AnalogIO functionality.
Below, by way of example, we show the channels and nodes of three Digilent Waveforms devices: the Analog Discovery 2, the Digital Discovery, and the Analog Discovery Pro.
channel |
channel name |
ch. label |
node |
node name |
unit |
node type |
0 |
Positive Supply |
V+ |
0 |
Enable |
n/a |
|
1 |
Voltage |
V |
||||
2 |
Current |
A |
||||
1 |
Negative Supply |
V- |
0 |
Enable |
n/a |
|
1 |
Voltage |
V |
||||
2 |
Current |
A |
||||
2 |
USB Monitor |
USB |
0 |
Voltage |
V |
|
1 |
Current |
A |
||||
2 |
Temperature |
C |
||||
3 |
Auxiliary Monitor |
Aux |
0 |
Voltage |
V |
|
1 |
Current |
A |
||||
4 |
Power Supply |
V+- |
0 |
Limit |
n/a |
channel |
channel name |
ch. label |
node |
node name |
unit |
node type |
0 |
Digital Voltage |
VDD |
0 |
Voltage |
V |
|
1 |
DINPP |
n/a |
||||
2 |
DIOPE |
n/a |
||||
3 |
DIOPP |
n/a |
||||
4 |
Drive |
n/a |
||||
5 |
Slew |
n/a |
||||
6 |
Clock |
Hz |
||||
1 |
Voltage Output |
VIO |
0 |
Voltage |
V |
|
1 |
Current |
A |
||||
2 |
USB Monitor |
USB |
0 |
Voltage |
V |
|
1 |
Current |
A |
channel |
channel name |
ch. label |
node |
node name |
unit |
node type |
0 |
Digital Voltage |
DVCC |
0 |
Voltage |
||
1 |
DIOPE |
n/a |
||||
2 |
DIOPP |
n/a |
||||
1 |
Zynq |
Zynq |
0 |
Temperature |
C |
|
1 |
VccInt |
V |
||||
2 |
VccAux |
V |
||||
3 |
VccBRam |
V |
||||
4 |
VccPInt |
V |
||||
5 |
VccPAux |
V |
||||
6 |
VccDDR |
V |
||||
2 |
ZynqMin |
ZynqMin |
0 |
Temperature |
C |
|
1 |
VccInt |
V |
||||
2 |
VccAux |
V |
||||
3 |
VccBRam |
V |
||||
4 |
VccPInt |
V |
||||
5 |
VccPAux |
V |
||||
6 |
VccDDR |
V |
||||
3 |
ZynqMax |
ZynqMax |
0 |
Temperature |
C |
|
1 |
VccInt |
V |
||||
2 |
VccAux |
V |
||||
3 |
VccBRam |
V |
||||
4 |
VccPInt |
V |
||||
5 |
VccPAux |
V |
||||
6 |
VccDDR |
V |
Note
Channel 2 (ZynqMin), node 5 of the Analog Discovery Pro device was reported incorrectly in version 3.16.3 of the DWF library. This has been corrected in version 3.17.1.
AnalogIO reference
- class AnalogIO
The AnalogIO class provides access to the analog I/O functionality of a
DwfDevice
.The AnalogIO methods are used to control the power supplies, reference voltage supplies, voltmeters, ammeters, thermometers, and any other sensors on the device. These are organized into channels which contain a number of nodes. For instance, a power supply channel might have three nodes: an ‘enable’ setting, a voltage level setting/reading, and current limitation setting/reading.
Attention
Users of pydwf should not create instances of this class directly.
It is instantiated during initialization of a DwfDevice and subsequently assigned to its public
analogIO
attribute for access by the user.- reset() None
Reset and configure all AnalogIO settings to default values.
If autoconfiguration is enabled, the changes take effect immediately.
- Raises:
DwfLibraryError – An error occurred while executing the reset operation.
- configure() None
Configure the AnalogIO functionality.
This method transfers the settings to the Digilent Waveforms device. It is not needed if autoconfiguration is enabled.
- Raises:
DwfLibraryError – An error occurred while executing the configure operation.
- status() None
Read the status of the device and stores it internally.
The status inquiry methods that follow will return the information that was read from the device when this method was last called.
Note that the AnalogIO functionality is not managed by a state machine, so this method does not return a value.
- Raises:
DwfLibraryError – An error occurred while executing the status operation.
- enableInfo() Tuple[bool, bool]
Verify if Master Enable and/or Master Enable Status are supported.
The Master Enable is a software switch that enable the AnalogIO voltage sources.
If supported, the current value of this Master Enable switch (Enabled/Disabled) can be set by the
enableSet()
method and queried by theenableGet()
method.The Master Enable Status that can be queried by the
enableStatus()
method may be different from the Master Enable value if e.g. an over-current protection circuit has been triggered.- Returns:
The tuple elements indicate whether Master Enable Set and Master Enable Status, respectively, are supported by the AnalogIO device.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- enableSet(master_enable: bool) None
Set value of the Master Enable setting.
- Parameters:
master_enable (bool) – The new value of the Master Enable setting.
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- enableGet() bool
Return the current value of the Master Enable setting.
- Returns:
The value of the Master Enable setting.
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- enableStatus() bool
Return the actual Master Enable Status value (if the device supports it).
The Master Enable Status value may be different from the Master Enable setting if e.g. an over-current protection circuit has been triggered.
- Returns:
the current status of the Master Enable circuit.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelCount() int
Return the number of AnalogIO channels available on the device.
- Returns:
The number of AnalogIO channels.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelName(channel_index: int) Tuple[str, str]
Return the name (long text) and label (short text, printed on the device) for the specified AnalogIO channel.
- Parameters:
channel_index (int) – The channel for which we want to get the name and label.
- Returns:
The name and label of the channel.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelInfo(channel_index: int) int
Return the number of nodes associated with the specified AnalogIO channel.
- Parameters:
channel_index (int) – The channel for which we want to get the number of associated nodes.
- Returns:
The number of nodes associated to the channel.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelNodeName(channel_index: int, node_index: int) Tuple[str, str]
Return the node name (“Voltage”, “Current”, …) and units (“V”, “A”, …) for the specified AnalogIO node.
- Parameters:
- Returns:
The name and unit of the quantity associated with the node.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelNodeInfo(channel_index: int, node_index: int) DwfAnalogIO
Return the type of physical quantity (e.g., voltage, current, or temperature) represented by the specified AnalogIO channel node.
- Parameters:
- Returns:
The type of physical quantity represented by the node.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelNodeSetInfo(channel_index: int, node_index: int) Tuple[float, float, int]
Return the limits of the value that can be assigned to the specified AnalogIO channel node.
Since a node can represent many things (power supply, temperature sensor, etc.), the minimum, maximum, and steps parameters also represent different types of values.
The
channelNodeInfo()
method returns the type of values to expect and thechannelNodeName()
method returns the units of these values.- Parameters:
- Returns:
The minimum and maximum values for the specified node’s value, and the number of resolution steps.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelNodeSet(channel_index: int, node_index: int, node_value: float) None
Set the node value for the specified AnalogIO channel node.
- Parameters:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelNodeGet(channel_index: int, node_index: int) float
Return the current value of the specified AnalogIO channel node.
- Parameters:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelNodeStatusInfo(channel_index: int, node_index: int) Tuple[float, float, int]
Return the range of status values for the specified AnalogIO channel node.
- Parameters:
- Returns:
The minimum and maximum status values for the specified node, and the number of resolution steps.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.
- channelNodeStatus(channel_index: int, node_index: int) float
Return the most recent status value reading of the specified AnalogIO channel node.
To fetch updated values for all AnalogIO nodes, use the
status()
method.- Returns:
The most recent value read for this channel node.
- Return type:
- Raises:
DwfLibraryError – An error occurred while executing the operation.