Total Phase Aardvark Adapter connection
Since R2023a
expand all in page
Description
An aardvark
object represents a connection to a Total Phase® Aardvark I2C/SPI™ Host Adapter. The Aardvark™ controller can have one or more I2C peripheral devices connected to it. To configure and communicate with a peripheral device on the Aardvark controller, you must first create an aardvark
object and then use the device function. You can connect to multiple peripheral devices with a single aardvark
object. The aardvark
object in MATLAB® always has the I2C controller role and cannot be used in the peripheral role.
Note
To use the aardvark
interface, you must have the Instrument Control Toolbox™ Support Package for Total Phase Aardvark I2C/SPI Interface installed. For more information, see Install Instrument Control Toolbox Support Package for Total Phase Aardvark I2C/SPI Interface.
Creation
Syntax
controller = aardvark(serialNumber)
controller = aardvark(serialNumber,Name=Value)
controller = aardvark
Description
example
controller = aardvark(
creates a connection to the Total Phase Aardvark I2C/SPI Host Adapter specified by the serial number serialNumber
)serialNumber
. You can find the serial number for your Aardvark controller by calling the aardvarklist
function.
The input serialNumber
sets the SerialNumber property.
controller = aardvark(
creates a connection to the Aardvark controller board and sets properties using one or more name-value arguments, where serialNumber
,Name=Value
)Name
is the property name and Value
is the corresponding value. Set the EnablePullupResistors and EnableTargetPower properties using name-value arguments as Name1=Value1,...,NameN=ValueN
, where Name
is the property name and Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the arguments does not matter.
example
controller = aardvark
, without arguments, attempts to create a connection to the last successfully connected Aardvark controller board. If you have not previously connected to an Aardvark controller, using this syntax creates a connection to the first available controller in the aardvarklist
output.
Properties
expand all
Model
— Controller board model
Total Phase Aardvark
(default)
This property is read-only.
Controller board model, specified as Total Phase Aardvark
.
Example: controller.Model
returns the model Total Phase Aardvark
.
Data Types: string
SerialNumber
— Unique identifier of Aardvark controller board
string scalar
This property is read-only.
Unique numeric identifier of the Total Phase Aardvark controller board, specified as a string scalar. This property can be set only at object creation.
Example: controller.SerialNumber
returns the unique identifier of the Aardvark controller.
Data Types: string
AvailableDigitalPins
— Digital pins available on Aardvark controller
["Pin1" "Pin3" "Pin5" "Pin7" "Pin8" "Pin9"]
(default) | string array
This property is read-only.
Digital pins available on Aardvark controller, specified as a string array. Connect your I2C peripheral devices to the controller using these pins. Refer to the Aardvark documentation for a description of each pin. Configure and communicate with these pins using configureDigitalPin, readDigitalPin, and writeDigitalPin.
Example: controller.AvailableDigitalPins
returns the digital pins of the Aardvark controller.
Data Types: string
VoltageLevel
— Voltage level of pins
3.3 (default)
This property is read-only.
Voltage level of pins in volts, specified as 3.3. This is the only possible voltage level of the pins on the Aardvark controller.
Example: controller.VoltageLevel
returns the voltage level of the Aardvark pins.
Data Types: double
EnablePullupResistors
— Allow I2C communication
true
or 1
(default) | false
or 0
Setting to allow I2C communication by enabling internal pullup resistors, specified as a numeric or logical 1 (true
) or 0 (false
). Each I2C line (SCL and SDA) has a 2.2 kΩ resistor. When enabled, they are pulled up to 3.3 V, resulting in approximately 1.5 mA of pullup current.
Example: controller.EnablePullupResistors = false
disables internal pullup resistors.
Data Types: logical
EnableTargetPower
— Allow target power
false
or 0
(default) | true
or 1
Setting to allow target power on pins 4 and 6 of the Aardvark controller, specified as a numeric or logical 1 (true) or 0 (false).
Example: controller.EnableTargetPower = false
disables target power on pins 4 and 6.
Data Types: logical
DigitalPinModes
— Modes of digital pins of Aardvark controller
table
This property is read-only.
Modes of digital pins of Aardvark controller, specified as a table. The table has the columns Pin
and Mode
. Pin
lists the digital pins specified by AvailableDigitalPins
and Mode
lists the pin mode of each of these pins as input
or output
.
When you create an aardvark
object, all the pins are input by default. Change pin modes using configureDigitalPin
. You can read logic values from input pins using readDigitalPin
and send logic level values to output pins using writeDigitalPin
.
Example: controller.DigitalPinModes
returns a table with the pin modes of the digital pins on the Aardvark controller.
Data Types: table
Object Functions
configureDigitalPin | Set digital pin mode on controller |
readDigitalPin | Read logic level value of digital pin on controller |
writeDigitalPin | Write logic level value to digital pin on controller |
scanI2CBus | Scan for I2C peripheral devices connected to controller board |
Examples
collapse all
Connect to Total Phase Aardvark I2C/SPI Host Adapter
Discover and connect to a Total Phase Aardvark I2C/SPI Host Adapter controller board on your machine.
Use aardvarklist
to list all available Total Phase Aardvark I2C/SPI Host Adapter controller boards connected to your machine.
list = aardvarklist
list = 1×2 table Model SerialNumber ______________________ ____________ 1 "Total Phase Aardvark" "2239143731"
Use the value of SerialNumber
to create a connection to your Aardvark.
controller = aardvark(list.SerialNumber)
controller = Aardvark with properties: Model: "Total Phase Aardvark" SerialNumber: "2239143731" AvailableDigitalPins: ["Pin1" "Pin3" "Pin5" "Pin7" "Pin8" "Pin9"] Show all properties, functions
You can now connect to any I2C peripheral devices on the Aardvark controller by using the device
function.
Set Digital Pin Mode on Total Phase Aardvark I2C/SPI Host Adapter
Connect to a Total Phase Aardvark I2C/SPI Host Adapter and configure the pins on it.
Connect to the Total Phase Aardvark using its serial number. In this example, the Aardvark controller board that is connected to the computer has a serial number 2239143731
.
controller = aardvark("2239143731");
View the available digital pins on the controller and their respective pin modes by using the DigitalPinModes
property.
controller.DigitalPinModes
ans = 6×2 table Pin Mode ______ _______ "Pin1" "input" "Pin3" "input" "Pin5" "input" "Pin7" "input" "Pin8" "input" "Pin9" "input"
Configure pin 5 as output.
configureDigitalPin(controller,"Pin5","output")
Since pin 5 is an output pin, you can now send it a logic high level using writeDigitalPin
.
Scan for I2C Peripheral Devices on Total Phase Aardvark I2C/SPI Host Adapter
Connect to a Total Phase Aardvark I2C/SPI Host Adapter and scan for I2C peripheral devices connected to it.
Connect to the Total Phase Aardvark using its serial number. In this example, the Aardvark controller board that is connected to the computer has a serial number 2239143731
.
controller = aardvark("2239143731");
Make sure that your I2C peripheral devices are physically connected to the controller. Scan for connected I2C peripheral devices. The scanI2CBus
function returns a list of the I2C addresses of these peripheral devices.
i2cAddresses = scanI2CBus(controller)
i2cAddresses = 1×2 string array "0x38" "0x50"
In this example, two peripheral devices are connected. You can now create a connection to one or more of them using the device
function with one of the listed I2C addresses. Refer to your peripheral device's datasheet to determine its I2C address.
Version History
Introduced in R2023a
See Also
aardvarklist | ni845x | scanI2CBus | device
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Contact your local office