Prog Manual 7 IO Control
Prog Manual 7 IO Control
This guide is owned by Mini-Circuits and is protected by copyright, trademark and other intellectual
property laws.
The information in this guide is provided by Mini-Circuits as an accommodation to our customers and
may be used only to promote and accompany the purchase of Mini-Circuits’ Parts. This guide may
not be reproduced, modified, distributed, published, stored in an electronic database, or transmitted
and the information contained herein may not be exploited in any form or by any means, electronic,
mechanical recording or otherwise, without prior written permission from Mini-Circuits.
Trademarks
Microsoft, Windows, Visual Basic, Visual C# and Visual C++ are registered trademarks of Microsoft
Corporation. LabVIEW and CVI are registered trademarks of National Instruments Corporation.
Delphi is a registered trademark of Delphi Technologies, Inc. MATLAB is a registered trademark of
The MathWorks, Inc. Agilent VEE is a registered trademark of Agilent Technologies, Inc. Linux is a
registered trademark of Linus Torvalds. Mac is a registered trademark of Apple Inc. Python is a
registered trademark of Python Software Foundation Corporation.
All other trademarks cited within this guide are the property of their respective owners. Neither
Mini-Circuits nor the Mini-Circuits PTE (portable test equipment) series are affiliated with or
endorsed or sponsored by the owners of the above referenced trademarks.
Mini-Circuits and the Mini-Circuits logo are registered trademarks of Scientific Components
Corporation.
Mini-Circuits
13 Neptune Avenue
Brooklyn, NY 11235, USA
Phone: +1-718-934-4500
Email: [email protected]
Web: www.minicircuits.com
1 - Overview ................................................................................................... 5
2 - Operating in a Windows Environment via USB .......................................... 6
2.1 - The DLL (Dynamic Link Library) Concept ................................................................. 6
2.1 (a) - ActiveX COM Object .......................................................................................................... 7
2.1 (b) - Microsoft.NET Class Library .............................................................................................. 9
2.2 - Referencing the DLL (Dynamic Linked Library) ...................................................... 10
2.2 (a) - Example Declarations using the ActiveX DLL (MCL_USB_To_IO.dll) ............................... 10
2.2 (b) - Example Declarations using the .NET DLL (mcl_USB_To_IO_64.dll) ............................... 10
2.3 - Summary of DLL Functions ................................................................................... 11
2.4 - Description of DLL Functions ................................................................................ 12
2.4 (a) - Open Control Box Connection ......................................................................................... 12
2.4 (b) - Close Control Box Connection ......................................................................................... 13
2.4 (c) - Read Model Name of Control Box ................................................................................... 14
2.4 (d) - Read Serial Number of Control Box ................................................................................ 15
2.4 (e) - Get List of Connected Serial Numbers ............................................................................ 16
2.4 (f) - Set Byte A As Output ........................................................................................................ 17
2.4 (g) - Set Byte B As Output ....................................................................................................... 18
2.4 (h) - Set Byte A As Input .......................................................................................................... 19
2.4 (i) - Set Byte B As Input ........................................................................................................... 20
2.4 (j) - Set Byte A ......................................................................................................................... 21
2.4 (k) - Set Byte B......................................................................................................................... 22
2.4 (l) - Read Byte ......................................................................................................................... 23
2.4 (m) - Read Byte A .................................................................................................................... 25
2.4 (n) - Read Byte B ..................................................................................................................... 26
2.4 (o) - Set TTL Bit ........................................................................................................................ 27
2.4 (p) - Set TTL Pulse.................................................................................................................... 28
2.4 (q) - Get TTL Bit ....................................................................................................................... 29
2.4 (r) - Set SPI Pulse Width .......................................................................................................... 30
2.4 (s) - Send SPI Data ................................................................................................................... 31
2.4 (t) - Send SPI Data with Trigger Out ........................................................................................ 32
2.4 (u) - Set Individual Relay ......................................................................................................... 33
2.4 (v) - Set All Relays.................................................................................................................... 34
2.4 (w) - Read Relay States ........................................................................................................... 36
2.4 (x) - Get Firmware ................................................................................................................... 38
3 - Operating in a Linux Environment ............................................................39
3.1 - Summary of Commands....................................................................................... 39
3.2 - Detailed Description of Commands ...................................................................... 40
3.2 (a) - Get Device Model Name ................................................................................................. 40
3.2 (b) - Get Device Serial Number ............................................................................................... 41
3.2 (c) - Get Status of Relays ......................................................................................................... 42
3.2 (d) - Set Single Relay ............................................................................................................... 44
3.2 (e) - Set All Relays ................................................................................................................... 45
3.2 (f) - Set Single TTL Bit .............................................................................................................. 47
3.2 (g) - Get Single TTL Bit ............................................................................................................. 49
3.2 (h) - Set TTL Byte ..................................................................................................................... 51
3.2 (i) - Get TTL Byte ..................................................................................................................... 53
3.2 (j) - Set Byte A As Input ........................................................................................................... 55
3.2 (k) - Set Byte B As Input .......................................................................................................... 56
3.2 (l) - Set Byte A As Output ........................................................................................................ 57
Support for Windows® operating systems is provided through the Microsoft®.NET® and
ActiveX® frameworks to allow the user to develop customized control applications. Support
for Linux® operating systems is accomplished using the standard libhid and libusb libraries.
Mini-Circuits has experience with a wide variety of environments including (but not limited
to):
Visual Basic®, Visual C#®, Visual C++®
Delphi®
Borland C++®
CVI®
LabVIEW®
MATLAB®
Python®
Agilent VEE®
The IO control box software package includes a GUI program, ActiveX and .NET DLL files,
Linux support, project examples for third party software, and detailed user manuals. The
latest package is available for download at:
https://www.minicircuits.com/softwaredownload/usbio.html
For details on individual models, application notes, GUI installation instructions and user
guides please see:
https://www.minicircuits.com/WebStore/PortableTestEquipment.html
Files made available for download from the Mini-Circuits website are subject to Mini-Circuits’
terms of use which are available on the website.
The Dynamic Link Library concept is Microsoft's implementation of the shared library
concept in the Windows environment.
DLLs provide a mechanism for shared code and data, intended to allow a developer to
distribute applications without requiring code to be re-linked or recompiled.
Mini-Circuits' software package provides DLL Objects designed to allow your own software
application to interface with the functions of the IO control box.
Mini-Circuits’
USB Portable Test Equipment
Fig 2.1-a: DLL Interface Concept
The software package provides two DLL files, the choice of which file to use is dictated by the
user’s operating system:
ActiveX COM object DLL files are designed to be used with both 32-bit and 64-bit Windows
operating systems. A 32-bit programming environment that is compatible with ActiveX is
required. To develop 64-bit applications, the Microsoft.NET Class library should be used
instead.
Installation
Fig 2.1-c: Opening the Command Prompt in Windows 7 (left), Windows 8 (middle) and Windows 10 (right)
Microsoft.NET class libraries are designed to be used with both 32-bit and 64-bit Windows
operating systems. To develop 64-bit applications the user must have both a 64-bit
operating system and 64-bit programming environment. However, the Microsoft.NET class
library is also compatible with 32-bit programming environments.
Installation
The following functions are defined in both of the DLL files. Please see the following sections
for a full description of their structure and implementation.
Declaration
Description
This function is called to initialize the connection to a USB control box. If multiple control
boxes are connected to the same computer, then the serial number should be included,
otherwise this can be omitted. The connection process can take a few milliseconds so it is
recommended that the connection be made once at the beginning of the routine and left
open until the control box is no longer needed. The control box should be disconnected on
completion of the program using the Disconnect function.
Parameters
Return Values
Examples
Visual Basic
status = MyPTE1.Connect(SN)
Visual C++
status = MyPTE1->Connect(SN);
Visual C#
status = MyPTE1.Connect(SN);
Matlab
status = MyPTE1.Connect(SN)
See Also
Declaration
Void Disconnect()
Description
This function is called to close the connection to the control box. It is strongly recommended
that this function is used prior to ending the program. Failure to do so may result in a
connection problem with the device. Should this occur, shut down the program and unplug
the control box from the computer, then reconnect the control box before attempting to
start again.
Parameters
Return Values
Examples
Visual Basic
MyPTE1.Disconnect()
Visual C++
MyPTE1->Disconnect();
Visual C#
MyPTE1.Disconnect();
Matlab
MyPTE1.Disconnect
See Also
Declaration
Description
This function is called to determine the Mini-Circuits part number of the connected control
box.
Parameters
Return Values
Examples
Visual Basic
If MyPTE1.Read_ModelName(ModelName) > 0 Then
MsgBox ("The connected model is " & ModelName)
' Display a message stating the model name
End If
Visual C++
if (MyPTE1->Read_ModelName(ModelName) > 0 )
{
MessageBox::Show("The connected model is " , ModelName);
// Display a message stating the model name
}
Visual C#
if (MyPTE1.Read_ModelName(ref(ModelName)) > 0 )
{
MessageBox.Show("The connected model is ", ModelName);
// Display a message stating the model name
}
Matlab
[status, ModelName] = MyPTE1.Read_ModelName(ModelName)
if status > 0
h = msgbox('The connected model is ', ModelName)
% Display a message stating the model name
end
See Also
Declaration
Description
This function is called to determine the Mini-Circuits serial number of the connected control
box.
Parameters
Return Values
Examples
Visual Basic
If MyPTE1.Read_SN(SN) > 0 Then
MsgBox ("The connected model is " & SN)
'Display a message stating the serial number
End If
Visual C++
if (MyPTE1->Read_SN(SN) > 0 )
{
MessageBox::Show("The connected model is " + SN);
// Display a message stating the serial number
}
Visual C#
if (MyPTE1.Read_SN(ref(SN)) > 0 )
{
MessageBox.Show("The connected model is " + SN);
// Display a message stating the serial number
}
Matlab
[status, SN] = MyPTE1.Read_SN(SN)
if status > 0
h = msgbox('The connected switch is ', SN)
% Display a message stating the serial number
end
See Also
Declaration
Description
This function takes a user defined variable and updates it with a list of serial numbers for all
available (currently connected) control boxes.
Parameters
Return Values
Examples
Visual Basic
If MyPTE1.Get_Available_SN_List(SN_List) > 0 Then
array_SN() = Split(SN_List, " ")
' Split the list into an array of serial numbers
For i As Integer = 0 To array_SN.Length - 1
' Loop through the array and use each serial number
Next
End If
Visual C++
if (MyPTE1 ->Get_Available_SN_List(SN_List) > 0)
{
// split the List into array of SN's
}
Visual C#
if (MyPTE1.Get_Available_SN_List(ref(SN_List)) > 0)
{
// split the List into array of SN's
}
Matlab
[status, SN_List] = MyPTE1.Get_Available_SN_List(SN_List)
if status > 0
% split the List into array of SN's
end
See Also
Declaration
Short Set_ByteA_As_Output()
Description
This function is applicable to USB-I/O-16D8R only. The function changes the mode of byte A
so that it acts as an output, rather than an input. By default Byte A is an output.
Parameters
Return Values
Examples
Visual Basic
status = MyPTE1.Set_ByteA_As_Output()
Visual C++
status = MyPTE1->Set_ByteA_As_Output();
Visual C#
status = MyPTE1.Set_ByteA_As_Output();
Matlab
status = MyPTE1.Set_ByteA_As_Output()
See Also
Declaration
Short Set_ByteB_As_Output()
Description
This function is not available for USB-I/O-4D2R. The function changes the mode of byte B so
that it acts as an output, rather than an input. By default Byte B is an output.
Parameters
Return Values
Examples
Visual Basic
status = MyPTE1.Set_ByteB_As_Output()
Visual C++
status = MyPTE1->Set_ByteB_As_Output();
Visual C#
status = MyPTE1.Set_ByteB_As_Output();
Matlab
status = MyPTE1.Set_ByteB_As_Output()
See Also
Declaration
Short Set_ByteA_As_Input()
Description
This function is applicable to USB-I/O-16D8R only. The function changes the mode of byte A
so that it acts as an input, rather than an output. By default Byte A is an output.
Parameters
Return Values
Examples
Visual Basic
status = MyPTE1.Set_ByteA_As_Input()
Visual C++
status = MyPTE1->Set_ByteA_As_Input();
Visual C#
status = MyPTE1.Set_ByteA_As_Input();
Matlab
status = MyPTE1.Set_ByteA_As_Input()
See Also
Declaration
Short Set_ByteB_As_Input()
Description
This function is not available for USB-I/O-4D2R. The function changes the mode of byte B so
that it acts as an input, rather than an output. By default Byte B is an output.
Parameters
Return Values
Examples
Visual Basic
status = MyPTE1.Set_ByteB_As_Input()
Visual C++
status = MyPTE1->Set_ByteB_As_Input();
Visual C#
status = MyPTE1.Set_ByteB_As_Input();
Matlab
status = MyPTE1.Set_ByteB_As_Input()
See Also
Declaration
Description
This function is applicable to USB-I/O-16D8R only. The function sets the state of output byte
A so that each bit is logic “low” (0) or logic “high” (1). Byte A is made up of 8 output bits, A0
to A7.
Note: Byte A must be set to output mode rather than input mode in order to use this
function (see Set_ByteA_As_Output).
Parameters
Return Values
Examples
Visual Basic
status = MyPTE1.Set_ByteA(Val)
Visual C++
status = MyPTE1->Set_ByteA(Val);
Visual C#
status = MyPTE1.Set_ByteA(Val);
Matlab
[status, Val] = MyPTE1.Set_ByteA(Val)
See Also
Declaration
Description
This function sets the state of output byte B so that each bit is logic “low” (0) or logic “high”
(1). Byte B is made up of 8 output bits, B0 to B7.
Notes:
1. For models other than USB-I/O-4D2R, byte B must be set to output mode rather than
input mode in order to use this function (see Set_ByteB_As_Output)
2. For USB-I/O-4D2R, only bits B0 to B3 are available, bits B4 to B7 are "don't care” and
can be any value
Parameters
Return Values
Examples
Visual Basic
status = MyPTE1.Set_ByteB(Val)
Visual C++
status = MyPTE1->Set_ByteB(Val);
Visual C#
status = MyPTE1.Set_ByteB(Val);
Matlab
[status, Val] = MyPTE1.Set_ByteB(Val)
See Also
Declaration
Description
This function reads the state of the specified input (byte A or byte B). Each byte is made up
of 8 input bits, 0 to 7, which could be at logic “low” (0) or logic “high” (1).
Parameters
Return Values
Examples
Visual Basic
Status = MyPTE1.ReadByte("A", Ret_ByteVal)
Visual C++
Status = MyPTE1->ReadByte("A", Ret_ByteVal);
Visual C#
Status = MyPTE1.ReadByte("A", Ret_ByteVal);
Matlab
[Status, ~, Ret_ByteVal] = MyPTE1.ReadByte('A', Ret_ByteVal)
See Also
Declaration
Description
This function reads the state of the byte A input. Byte A is made up of 8 input bits, A0 to A7,
which could be at logic “low” (0) or logic “high” (1).
Parameters
Return Values
Examples
Visual Basic
Status = MyPTE1.ReadByteA(Ret_ByteVal)
Visual C++
Status = MyPTE1->ReadByteA(Ret_ByteVal);
Visual C#
Status = MyPTE1.ReadByteA(Ret_ByteVal);
Matlab
[Status, Ret_ByteVal] = MyPTE1.ReadByteA(Ret_ByteVal)
See Also
Declaration
Description
This function reads the state of the byte B input. Byte A is made up of 8 input bits, B0 to B7,
which could be at logic “low” (0) or logic “high” (1).
Parameters
Return Values
Examples
Visual Basic
Status = MyPTE1.ReadByteB(Ret_ByteVal)
Visual C++
Status = MyPTE1->ReadByteB(Ret_ByteVal);
Visual C#
Status = MyPTE1.ReadByteB(Ret_ByteVal);
Matlab
[Status, Ret_ByteVal] = MyPTE1.ReadByteB(Ret_ByteVal)
See Also
Declaration
Description
This function sets the state of a single output bit specified by the user. Bits A0 to A7 and B0
to B7 can be set (model dependent). The value of each bit can be set to logic “low” (0) or
logic “high” (1).
Note: The relevant byte must be set to output mode rather than input mode in order to use
this function (see Set_ByteA_As_Output and Set_ByteB_As_Output).
Parameters
Return Values
Examples
Visual Basic
Status = MyPTE1.Set_TTLBit(BitName, BitVal)
Visual C++
Status = MyPTE1->Set_TTLBit(BitName, BitVal);
Visual C#
Status = MyPTE1.Set_TTLBit(BitName, BitVal);
Matlab
Status = MyPTE1.Set_TTLBit(BitName, BitVal)
See Also
Declaration
Description
This function outputs a positive pulse from a single bit specified by the user. The specified
bit will be set to logic high for a user specified time and then drop to logic low. Bits A0 to A7
and B0 to B7 can be pulsed (model dependent). If the selected bit was already at logic high it
will remain so for the specified time and then drop to logic low.
Note: The relevant byte must be set to output mode rather than input mode in order to use
this function (see Set_ByteA_As_Output and Set_ByteB_As_Output).
Parameters
Return Values
Examples
Visual Basic
Status = MyPTE1.Set_TTLPulse(BitName, Ms)
Visual C++
Status = MyPTE1->Set_TTLPulse(BitName, Ms);
Visual C#
Status = MyPTE1.Set_TTLPulse(BitName, Ms);
Matlab
Status = MyPTE1.Set_TTLPulse(BitName, Ms)
See Also
Declaration
Description
This function is not available for USB-I/O-4D2R. The function reads the state of a single bit
specified by the user. Bits A0 to A7 and B0 to B7 can be requested (model dependent). The
value of each bit could be logic “low” (0) or logic “high” (1).
Parameters
Return Values
Examples
Visual Basic
Status = MyPTE1.ReadBit(BitRequest, Ret_ByteVal)
Visual C++
Status = MyPTE1->ReadBit(BitRequest, Ret_ByteVal);
Visual C#
Status = MyPTE1.ReadBit(BitRequest, Ret_ByteVal);
Matlab
[Status, ~, Ret_ByteVal] = MyPTE1.ReadBit(BitRequest, Ret_ByteVal)
See Also
Declaration
Description
This function sets the pulse width that will be used for the Clock, Data and LE (Latch Enable)
connections when the control box is used for SPI (Serial Peripheral Interface) communication.
The pulse width can be set as any integer value from 0 to 255μs although in practice the
minimum pulse width will be approximately 0.08μs.
Note: The duty cycle remains constant at 50% so clock frequency will change as pulse width
is varied.
Parameters
Return Values
Examples
Visual Basic
Status = MyPTE1.Set_SPI_PulseWidth(PulseWidth)
Visual C++
Status = MyPTE1->Set_SPI_PulseWidth(PulseWidth);
Visual C#
Status = MyPTE1.Set_SPI_PulseWidth(PulseWidth);
Matlab
Status = MyPTE1.Set_SPI_PulseWidth(PulseWidth)
See Also
Declaration
Description
This function sends SPI (Serial Peripheral Interface) data. The Clock bit, Data bit and LE (Latch
Enable) bits to be used are defined by the user. The user specified binary data will be sent
along with all required start, stop and parity bits (as required by the SPI communication
protocol).
Note: The relevant byte must be set to output mode rather than input mode in order to use
this function (see Set_ByteA_As_Output and Set_ByteB_As_Output).
Parameters
Return Values
Data Type Value Description
Short 0 Command failed
Short Non zero Command completed successfully
Examples
Visual Basic
Status = MyPTE1.SPI_OUT(ClockBit, DataBit, LEBit, RegData)
Visual C++
Status = MyPTE1->SPI_OUT(ClockBit, DataBit, LEBit, RegData);
Visual C#
Status = MyPTE1.SPI_OUT(ClockBit, DataBit, LEBit, RegData);
Matlab
Status = MyPTE1.SPI_OUT(ClockBit, DataBit, LEBit, RegData)
See Also
Set SPI Pulse Width
Send SPI Data With Trigger Out
Declaration
Description
This function sends SPI (Serial Peripheral Interface) data with a trigger bit that will rise and
fall together with the LE (Latch Enable) bit. Bit B0 is used as the Clock bit, B1 as the Data bit,
B2 as the LE bit and B3 as the trigger. The user specified data will be sent along with all
required start, stop and parity bits (as required by the SPI communication protocol).
Note: Byte B must be set to output mode rather than input mode in order to use this
function (Set_ByteB_As_Output).
Parameters
Return Values
Examples
Visual Basic
Status = MyPTE1.SPI_OUT_Trigg(RegData, Trigger)
Visual C++
Status = MyPTE1->SPI_OUT_Trigg(RegData, Trigger);
Visual C#
Status = MyPTE1.SPI_OUT_Trigg(RegData, Trigger);
Matlab
Status = MyPTE1.SPI_OUT_Trigg(RegData, Trigger)
See Also
Declaration
Description
This function sets the state of an individual relay, either Com to NO (Common port
connected to Normally Open port) or Com to NC (Common port connected to Normally
Closed port).
In the case of USB-I/O-4D2R, Com to NO turns on the 24V outputs and Com to NC turns them
off.
Return Values
Examples
Visual Basic
Status = MyPTE1.Set_Relay(RelayNo, On_OFF)
Visual C++
Status = MyPTE1->Set_Relay(RelayNo, On_OFF);
Visual C#
Status = MyPTE1.Set_Relay(RelayNo, On_OFF);
Matlab
Status = MyPTE1.Set_Relay(RelayNo, On_OFF)
See Also
Set All Relays
Read Relay States
Declaration
Description
This function sets the state of all relays at once. Each relay can be set to either Com to NO
(Common port connected to Normally Open port) or Com to NC (Common port connected to
Normally Closed port).
In the case of USB-I/O-4D2R, Com to NO turns on the 24V outputs and Com to NC turns them
off.
Return Values
Visual Basic
Status = MyPTE1.Set_RelayByte(Val)
Visual C++
Status = MyPTE1->Set_RelayByte(Val);
Visual C#
Status = MyPTE1.Set_RelayByte(Val);
Matlab
Status = MyPTE1.Set_RelayByte(Val)
See Also
Declaration
Description
This function reads the state of all 8 relays simultaneously to determine whether they are in
the Com to NO (Common port connected to Normally Open port) state or Com to NC
(Common port connected to Normally Closed port) state.
In the case of USB-I/O-4D2R, the function will determine whether the 24V outputs, OUT1 and
OUT2, are on or off.
Return Values
Visual Basic
Status = MyPTE1.Read_Relays_Byte(RetVal)
Visual C++
Status = MyPTE1->Read_Relays_Byte(RetVal);
Visual C#
Status = MyPTE1.Read_Relays_Byte(RetVal);
Matlab
[Status, Ret_ByteVal] = MyPTE1.Read_Relays_Byte(RetVal)
See Also
Declaration
Description
This function returns the internal firmware version of the control box along with three
reserved variables (for factory use).
Parameters
Return Values
Examples
Visual Basic
If MyPTE1.GetExtFirmware(A0, A1, A2, Firmware) > 0 Then
MsgBox ("Firmware version is " & Firmware)
End If
Visual C++
if (MyPTE1->GetExtFirmware(A0, A1, A2, Firmware) > 0 )
{
MessageBox::Show("Firmware version is " + Firmware);
}
Visual C#
if (MyPTE1.GetExtFirmware(ref(A0, A1, A2, Firmware)) > 0 )
{
MessageBox.Show("Firmware version is " + Firmware);
}
Matlab
[status, A0, A1, A2, Firmware] = MyPTE1.GetExtFirmware(A0, A1, A2, Firmware)
if status > 0
h = msgbox('Firmware version is ', Firmware)
end
Communication with the control box is carried out by way of USB Interrupt. The transmitted
and received buffer sizes are 64 Bytes each:
Transmit Array = [Byte 0][Byte1][Byte2]…[Byte 63]
Returned Array = [Byte 0][Byte1][Byte2]…[Byte 63]
In most cases, the full 64 byte buffer size is not needed so any unused bytes become “don’t
care” bytes; they can take on any value without affecting the operation of the control box.
Worked examples can be found in the Programming Examples & Troubleshooting Guide,
downloadable from the Mini-Circuits website. The examples use the libhid and libusb
libraries to interface with the IO control box as a USB HID (Human Interface Device).
The commands that can be sent to the control box are summarized in the table below and
detailed on the following pages.
Command Code
# Description Comments
(Byte 0)
a Get Device Model Name 40
b Get Device Serial Number 41
c Get Status of Relays 35
d Set Single Relay 34
e Set All Relays 33
f Set Single TTL Bit 32
g Get TTL Bit 30
h Set TTL Byte 31
28 Byte A
i Get TTL Byte
29 Byte B
j Set Byte A As Input 24
k Set Byte B As Input 26
l Set Byte A As Output 25
m Set Byte B As Output 27
n Send SPI Output 36
o Send SPI Output With Trigger 37
p Set SPI Pulse Width 8
q Get Firmware 99
Description
This function determines the Mini-Circuits part number of the control box.
Transmit Array
Send code 40 in BYTE0 of the transmit array. BYTE1 through to BYTE63 are don’t care bytes
and can be any value.
Byte Byte 0
Description Code
Value 40
Returned Array
The model name is represented as a series of ASCII characters in the returned array, starting
from BYTE1. The final ASCII character is contained in the byte immediately preceding the
first zero value byte. All subsequent bytes up to BYTE63 are “don’t care” bytes and could be
any value.
Example
The following array would be returned for Mini-Circuits’ USB-IO-4D2R control box. See
Appendix A for conversions between decimal, binary and ASCII characters.
See Also
Description
This function determines the serial number of the connected control box.
Transmit Array
Send code 41 in BYTE0 of the transmit array. BYTE1 through to BYTE63 are “don’t care”
bytes and can be any value.
Byte Byte 0
Description Code
Value 41
Returned Array
The serial number is represented as a series of ASCII characters in the returned array,
starting from BYTE1. The final ASCII character is contained in the byte immediately
preceding the first zero value byte. All subsequent bytes up to BYTE63 are “don’t care” bytes
and could be any value.
Example
The following example indicates that the current control box has serial number
11301210001. See Appendix A for conversions between decimal, binary and ASCII
characters.
See Also
Description
This function returns the states of all relays at once. Each relay could be set to either Com to
NO (Common port connected to Normally Open port) or Com to NC (Common port
connected to Normally Closed port).
Transmit Array
Send code 35 in BYTE0 of the transmit array. BYTE1 through to BYTE63 are “don’t care”
bytes and can be any value.
Byte Byte 0
Description Code
Value 35
Returned Array
Each bit in BYTE1 of the returned array represents the state of an individual relay, with bit 0
(LSB) representing relay 0 and bit 7 (MSB) representing relay 7. Each bit could be 1 for “Com
to NO” or 0 for “Com to NC”.
In the case of USB-I/O-4D2R, only bit 0 (LSB) and bit 1 of BYTE1 apply, with bit 0 representing
OUT1 and bit 1 representing OUT2. Each bit could be 1 to indicate the 24V output is on or 0
indicate it is off.
BYTE2 through to BYTE63 are “don’t care” bytes and can be any value.
The state of 7 in the above returned array can be interpreted as a binary number and broken
down as below:
Bit 7 Bit 0
Bit Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1
(MSB) (LSB)
Relay 7 Relay 6 Relay 5 Relay 4 Relay 3 Relay 2 Relay 1 Relay 0
Description
State State State State State State State State
Value 0 0 0 0 1 0 1 1
This indicates relays 0, 1 and 3 are in the “Com to NO” state, with all other relays in the “Com
to NC” state.
See Also
Description
This function sets the state of an individual relay, either Com to NO (Common port
connected to Normally Open port) or Com to NC (Common port connected to Normally
Closed port).
Transmit Array
Send code 34 in BYTE0 of the transmit array and the relay number (0 to 7) in BYTE1. BYTE2
sets the state of the specified relay, 1 for “Com to NO” or 0 for “Com to NC”.
In the case of USB-I/O-4D2R, BYTE1 determines which of the 2 outputs to control, 0 for OUT1
or 1 for OUT2. BYTE2 sets the state of the specified output, 1 to turn on the 24V output or 0
to turn it off.
BYTE3 through to BYTE63 are “don’t care” bytes and can be any value.
Returned Array
Byte Byte 0
Description Code
Value 34
Example
The following transmit array would set relay 3 of USB-I/O-16D8R into the “Com to NO” state:
The following transmit array would set OUT2 of USB-I/O-4D2R so that the 24V output is
connected:
See Also
Get Status of Relays
Set All Relays
Description
This function sets the state of all relays at once. Each relay can be set to either Com to NO
(Common port connected to Normally Open port) or Com to NC (Common port connected to
Normally Closed port).
Transmit Array
Send code 33 in BYTE0 of the transmit array. Each bit in BYTE1 represents the required state
of an individual relay, with bit 0 (LSB) representing relay 0 and bit 7 (MSB) representing relay
7. Each bit can be 1 for “Com to NO” or 0 for “Com to NC”.
In the case of USB-I/O-4D2R, only bit 0 (LSB) and bit 1 of BYTE1 apply, with bit 0 representing
OUT1 and bit 1 representing OUT2. Each bit can be set to 1 to turn on the 24V output or 0 to
turn it off.
BYTE2 through to BYTE63 are “don’t care” bytes and can be any value.
Returned Array
Byte Byte 0
Description Code
Value 33
Example
To set relays 0, 1 and 3 into the “Com to NO” state, with all other relays in the “Com to NC”
state, the following byte would be sent for BYTE1:
Bit 7 Bit 0
Bit Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1
(MSB) (LSB)
Relay 7 Relay 6 Relay 5 Relay 4 Relay 3 Relay 2 Relay 1 Relay 0
Description
State State State State State State State State
Value 0 0 0 0 1 0 1 1
The byte to send in BYTE1 is therefore 00001011 binary which equates to a decimal value of
7. The complete transmit array would be:
See Also
Description
This function sets the state of a single output bit specified by the user. Bits A0 to A7 and B0
to B7 can be set (model dependent). The value of each bit can be set to logic “low” (0) or
logic “high” (1).
Note: The relevant byte must be set to output mode rather than input mode in order to use
this function.
Transmit Array
Returned Array
Byte Byte 0
Description Code
Value 32
Example
To set bit “B3” (bit 3 of byte B) to logic high, the following transmit array would be sent:
Description
This function gets the state of a single TTL input bit from digital byte A or byte B, as specified
by the user. Bits A0 to A7 and B0 to B7 are available. The value of each bit could be logic
“low” (0) or logic “high” (1).
Note: The relevant byte must be set to input mode rather than output mode in order to use
this function.
Transmit Array
Returned Array
The returned array contains the TTL logic value (0 or 1) of the requested bit in BYTE1.
To read bit “B3” (bit 3 of byte B), the following transmit array would be sent:
The following array would be returned to indicate the input was at logic high:
See Also
Description
This function sets the state of output byte A or byte B so that each bit is logic “low” (0) or
logic “high” (1).
Note: The relevant byte must be set to output mode rather than input mode in order to use
this function.
Transmit Array
Returned Array
Byte Byte 0
Description Code
Value 31
To set byte A to the below state (1 indicating logic high and 0 indicating) logic low:
Bit 7 Bit 0
Bit Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1
(MSB) (LSB)
Description State State State State State State State State
Value 0 0 0 0 1 0 1 1
The binary value is 00001011 which equates to a decimal value of 11. The transmit array
would therefore be:
See Also
Description
This function reads the state of digital input byte A or byte B. Each bit within the byte could
be logic “low” (0) or logic “high” (1).
Notes:
1. This function is not available for USB-I/O-4D2R
2. The relevant byte must be set to input mode rather than output mode in order to
use this function
Transmit Array
Byte Byte 0
Description Code
Value 28 or 29
Returned Array
The returned array repeats code 28 or 29 in BYTE0 and contains a numeric value
representing the state of the required byte in BYTE1. BYTE2 to BYTE63 could be any value
(“don’t care” bytes).
The value in BYTE1 of the returned array should be interpreted as a binary number, with
each bit corresponding to a digital input bit within the byte, from 0 for bit 0 (LSB) to 7 for bit
7 (MSB).
Byte Byte 0
Description Code
Value 28
The following returned array indicates the input state of byte A is 11:
To determine the state of each individual input bit of byte A, the decimal value 11 should be
interpreted as a binary number (00001011). Each bit in the binary number confirms whether
the corresponding input bit is at logic low (0) or logic high (1):
Bit 7 Bit 0
Bit Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1
(MSB) (LSB)
Description State State State State State State State State
Value 0 0 0 0 1 0 1 1
See Also
Description
This function changes the mode of byte A so that it acts as an input, rather than an output.
By default Byte A is an output.
Transmit Array
Send code 24 in BYTE0 of the transmit array. BYTE1 to BYTE63 can be any value (“don’t care”
bytes).
Byte Byte 0
Description Code
Value 24
Returned Array
Byte Byte 0
Description Code
Value 24
See Also
Description
This function changes the mode of byte B so that it acts as an input, rather than an output.
By default Byte B is an output.
Transmit Array
Send code 26 in BYTE0 of the transmit array. BYTE1 to BYTE63 can be any value (“don’t care”
bytes).
Byte Byte 0
Description Code
Value 26
Returned Array
Byte Byte 0
Description Code
Value 26
See Also
Description
This function changes the mode of byte A so that it acts as an output, rather than an input.
By default Byte A is an output.
Transmit Array
Send code 25 in BYTE0 of the transmit array. BYTE1 to BYTE63 can be any value (“don’t care”
bytes).
Byte Byte 0
Description Code
Value 25
Returned Array
Byte Byte 0
Description Code
Value 25
See Also
Description
This function changes the mode of byte B so that it acts as an output, rather than an input.
By default Byte B is an output.
Transmit Array
Send code 27 in BYTE0 of the transmit array. BYTE1 to BYTE63 can be any value (“don’t care”
bytes).
Byte Byte 0
Description Code
Value 27
Returned Array
Byte Byte 0
Description Code
Value 27
See Also
Description
This function sends SPI (Serial Peripheral Interface) data. The Clock bit, Data bit and LE (Latch
Enable) bits to be used are defined by the user. The user specified binary data will be sent
along with all required start, stop and parity bits (as required by the SPI communication
protocol).
Notes:
1. For USB-I/O-4D2R, only bits 0 to 3 of Byte B are available
2. The relevant byte must be set to output mode rather than input mode in order to
use this function.
Transmit Array
Returned Array
Byte Byte 0
Description Code
Value 36
Example
Use the following transmit array to send SPI data “10010” using B0 as Clock, B1 as Data and
B2 as LE:
See Also
Description
This function sends SPI (Serial Peripheral Interface) data with a trigger bit that will rise and
fall together with the LE (Latch Enable) bit. Bit B0 is used as the Clock bit, B1 as the Data bit,
B2 as the LE bit and B3 as the trigger. The user specified data will be sent along with all
required start, stop and parity bits (as required by the SPI communication protocol).
Note: Byte B must be set to output mode rather than input mode in order to use this
function.
Transmit Array
Returned Array
Byte Byte 0
Description Code
Value 37
Use the following transmit array to send SPI data “10010111” with the trigger enabled:
See Also
Description
This function sets the pulse width that will be used for the Clock, Data and LE (Latch Enable)
connections when the control box is used for SPI (Serial Peripheral Interface) communication.
The pulse width can be set as any integer value from 0 to 255μs although in practice the
minimum pulse width will be approximately 0.08μs. The default value is 10μs.
Note: The duty cycle remains constant at 50% so clock frequency will change as pulse width
is varied.
Transmit Array
Returned Array
Byte Byte 0
Description Code
Value 8
Example
See Also
Description
This function returns the internal firmware version of the control box.
Transmit Array
Send code 99 in BYTE0 of the transmit array (BYTE1 through BYTE63 can be any value).
Byte Byte 0
Description Code
Value 99
Returned Array
The firmware version will be returned in BYTE5 and BYTE6 as ASCII character codes
representing the letter and number of the firmware. BYTE1 through to BYTE4 contain
internal Mini-Circuits reference codes and BYTE7 through to BYTE63 are “don’t care” bytes
and could be any value.
Example
The following return array would indicate that the current firmware version is C3: