Writing Code for the USB Isolated Volmeter Board
Windows
Some users may want to write their own software to work with the USB isolated voltmeter
board. EtherTek Circuits has provided an Application Programming Interface (API) by way of
a Dynamically Linked Library (DLL) that users can use to communicate to the USBisoVM board.
The USBisoVM_DLL.dll can be used with many programming languages. Some example code is
listed below.
Download the programming pack here: Programmer's Pack
Win32 ASM example code: Download it here.
Coded using: RADASM IDE
C-Sharp 2008 .NET example code: Download
it here.
C++ MFC 2010 example code: Download it
here.
Visual Basic 2008 .NET example code: Download it here.
Visual Basic 6 example code: Download it
here.
Active PERL example code: Download it here.
The DLL Functions Are Listed Below
TestDLL
Purpose:
To test connectivity to the DLL without the need of a USBisoVM board plugged in.
Calling Parameters:
1. supply a pointer to a buffer (minimum 4 bytes).
Return Value:
If the function fails, the return value will be FALSE. If the function succeeds, the return
value will be TRUE and the buffer will contain OK.
FindUSBisoVMs
Purpose:
To gather a list of all USBisoVMs attached to the control device.
Calling Parameters:
1. supply a pointer to a buffer (1024 byte) that will hold the list of USBisoVMs.
Return Value:
If the function fails, the return value will be FALSE. If the function succeeds, the return
value will be TRUE. When the function completes successfully, each unique identifier for
each USBisoVM board found will be placed in a zero terminated string. Each identifier will
be separated by a "|". The string also is ending in a "|". The calling program will have to
parse out the identifiers.
Example: 000A|001C|005F|
GetManufacturerString
Purpose:
To poll the Manufacturer specified in the device firmware for a specific device ID.
Calling Parameters:
1. product identifier. This typically is one of the IDs given by FindUSBisoVMs.
2. supply a pointer to a buffer (512 byte) that will hold the manufacturer string of the
USBisoVM.
Return Value:
If the function fails, the return value will be FALSE. If the function succeeds, the return
value will be TRUE. When the function completes successfully, the buffer will contain a
zero terminated character string containing the manufacturer.
GetProductString
Purpose:
To poll the Product specified in the device firmware for a specific device ID.
Calling Parameters:
1. product identifier. This typically is one of the IDs given by FindUSBisoVMs.
2. supply a pointer to a buffer (512 byte) that will hold the product string of the
USBisoVM.
Return Value:
If the function fails, the return value will be FALSE. If the function succeeds, the return
value will be TRUE. When the function completes successfully, the buffer will contain a
zero terminated character string containing the product string.
GetVersionString
To poll the Version specified in the device firmware for a specific device ID.
Calling Parameters:
1. product identifier. This typically is one of the IDs given by FindUSBisoVMs.
2. supply a pointer to a buffer (512 byte) that will hold the version string of the
USBisoVM.
Return Value:
If the function fails, the return value will be FALSE. If the function succeeds, the return
value will be TRUE. When the function completes successfully, the buffer will contain a
zero terminated character string containing the version.
ReadUSBisoVM
Purpose:
To retrieve the voltage value read by a voltmeter.
Calling Parameters:
1. product identifier. This typically is one of the IDs given by FindUSBisoVMs.
2. voltmeter. This is a value from (1-6) representing the voltmeter to read.
3. return format. 0 is raw format. 1 is calculated format.
4. supply a pointer to a buffer (32 byte) that will hold the voltmeter reading either in
raw or calculated format.
Return Value:
If the function fails, the return value will be FALSE. If the function succeeds, the return
value will be TRUE. When the function completes successfully, the returned buffer contains
a zero terminated string with the voltmeter reading. See below for a more in-depth
explanation of the RAW versus CALCULATED format.
CALCULATED FORMAT
The zero-terminated string is a voltage in the format of:
- sign; "+" for positive; "-" for negative
- a single space
- voltage whole number (up to 3 places)
- a decimal, "."
- voltage partial number (6 decimal places)
Example Answer: "+ 37.134865",0
RAW FORMAT
The zero-terminated string is a list in the format of:
- USB report number, typically zero; "0"
- Voltmeter number, 1-6
- Bit 31, dummy bit, always zero
- Bit 30, sign bit, "1" if positive, "0" if negative
- Bit 29 to Bit 5; Bit 29 is the MSB, Bit 5 is the LSB, there are 24 bits in total
- Bit 4 to Bit 0; sub LSBs, can be discarded or used for averaging
Example Answer: "031172111552",0
CONVERTING FROM RAW TO CALCULATED FORMAT
Using the Example Answer: "031172111552" above.
1. Strip the first 0 (USB Report number), and the 3 (Voltmeter Number).
2. Convert the remaing number (1172111552) to Binary: 01000101110111010000000011000000
3. Strip off the dummy bit (bit 31) and the sign bit (bit 30).
4. Strip off the last 5 bits (sub LSB numbers). Keep for averaging if desired.
5. If the value is negative, perform a 2s complement on the value.
6. Convert value to decimal format.
7. Divide by 16777215 (24bits, FFFFFF hex).
8. Multiply by the reference voltage (4.089V).
9. Multiply by calibration factor (49.56505). Based on equation (y=mx+b). This calibration
method was determined by plotting measurement values versus calibration values resulting in
a linear relationship over the full 100V range.
10. Subtract by calibration factor (0.000212034). Based on equation (y=mx+b).
11. Convert to an absolute value.
12. Apply desired formatting. (ie. Decimal places, polarity sign, averaging filter).
Our Story
EtherTek Circuits started its business in 2001. Ever since we have provided remote monitoring and control solutions for Remote Tower Sites, the Oil & Gas industry, Telemetry systems for Agriculture, Municipalities, Mines, Solar Farms, Hydro Plants, and the Military.