CGC PSU-CTRL-2D User manual

Page: 1/81 PSU-CTRL-2D, Rev.1-00
Digital Controller of Double Power Supply Units
Firmware Version 1-00
User Manual
Document version 2, created on Oct-15-2021
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 2/81 PSU-CTRL-2D, Rev.1-00
Contents
Technical Data................................................................7
Characteristics .............................................................................. 7
Digital Interface ............................................................................. 7
Description .....................................................................8
Controller Configuration .............................................................. 10
Configuration Management......................................................... 13
Remote Control........................................................................... 13
Quick Setup Guide .......................................................15
Software Utilities...........................................................17
Utility COM-HVPSU2D-Control................................................... 17
General Control........................................................................ 19
System Monitoring ................................................................... 21
Device Monitoring .................................................................... 23
Controller Settings ................................................................... 25
Configuration Management...................................................... 27
Backing Up and Restoring the Data ........................................ 34
Utility FlashLoader ...................................................................... 35
Driver Installation..........................................................38
Installation of the Virtual Port for the USB Interface ................... 38
Software Interface ........................................................39
Functionality of the Software Interface ....................................... 39
Direct Command Control ............................................................ 41
Error Codes................................................................................. 44
Communication Control .............................................................. 48
Function COM_HVPSU2D_Open............................................ 48
Function COM_HVPSU2D_Close ........................................... 48
Function COM_HVPSU2D_SetBaudRate ............................... 49
Function COM_HVPSU2D_Purge ........................................... 49
Function COM_HVPSU2D_GetBufferState............................. 50
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 3/81 PSU-CTRL-2D, Rev.1-00
Function COM_HVPSU2D_DevicePurge ................................ 50
Device Control............................................................................. 52
Function COM_HVPSU2D_GetInterlockEnable...................... 52
Function COM_HVPSU2D_SetInterlockEnable ...................... 52
Function COM_HVPSU2D_GetMainState............................... 53
Function COM_HVPSU2D_GetDeviceState ........................... 53
Function COM_HVPSU2D_GetHousekeeping........................ 54
Function COM_HVPSU2D_GetSensorData............................ 55
Function COM_HVPSU2D_GetLEDData ................................ 55
Management of the Power Supply Units .................................... 56
Function COM_HVPSU2D_GetPSUState ............................... 56
Function COM_HVPSU2D_GetPSUEnable ............................ 58
Function COM_HVPSU2D_SetPSUEnable............................. 58
Function COM_HVPSU2D_HasPSUFullRange ...................... 59
Function COM_HVPSU2D_GetPSUFullRange....................... 59
Function COM_HVPSU2D_SetPSUFullRange ....................... 60
Function COM_HVPSU2D_GetPSUOutputVoltage ................ 60
Function COM_HVPSU2D_SetPSUOutputVoltage................. 61
Function COM_HVPSU2D_GetPSUSetOutputVoltage........... 61
Function COM_HVPSU2D_GetPSUOutputCurrent ................ 62
Function COM_HVPSU2D_SetPSUOutputCurrent................. 63
Function COM_HVPSU2D_GetPSUSetOutputCurrent ........... 63
Function COM_HVPSU2D_GetPSUData................................ 64
Function COM_HVPSU2D_GetPSUHousekeeping ................ 65
Function COM_HVPSU2D_GetADCHousekeeping ................ 66
Device Configuration................................................................... 67
Function COM_HVPSU2D_GetDeviceEnable......................... 67
Function COM_HVPSU2D_SetDeviceEnable......................... 67
Configuration Management......................................................... 68
Function COM_HVPSU2D_ResetCurrentConfig..................... 68
Function COM_HVPSU2D_SaveCurrentConfig...................... 68
Function COM_HVPSU2D_LoadCurrentConfig ...................... 69
Function COM_HVPSU2D_GetConfigName........................... 70
Function COM_HVPSU2D_SetConfigName ........................... 71
Function COM_HVPSU2D_GetConfigFlags............................ 71
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 4/81 PSU-CTRL-2D, Rev.1-00
Function COM_HVPSU2D_SetConfigFlags ............................ 72
Function COM_HVPSU2D_GetConfigList............................... 73
Miscellaneous Functions............................................................. 74
Function COM_HVPSU2D_GetSWVersion............................. 74
Function COM_HVPSU2D_GetHWType................................. 74
Function COM_HVPSU2D_GetHWVersion............................. 75
Function COM_HVPSU2D_GetFWVersion ............................. 75
Function COM_HVPSU2D_GetFWDate.................................. 76
Function COM_HVPSU2D_GetProductNo.............................. 76
Function COM_HVPSU2D_GetProductID............................... 77
Function COM_HVPSU2D_GetUptime ................................... 77
Function COM_HVPSU2D_GetTotalTime............................... 78
Function COM_HVPSU2D_GetCPUData................................ 78
Function COM_HVPSU2D_Restart ......................................... 79
Error Handling ............................................................................. 80
Function COM_HVPSU2D_GetInterfaceState ........................ 80
Function COM_HVPSU2D_GetErrorMessage ........................ 80
Function COM_HVPSU2D_GetIOState................................... 80
Function COM_HVPSU2D_GetIOErrorMessage .................... 80
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 5/81 PSU-CTRL-2D, Rev.1-00
Figure List
Fig. 1. Block diagram of the device............................................... 9
Fig. 2. Device control logic.......................................................... 13
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 6/81 PSU-CTRL-2D, Rev.1-00
Table List
Tab. 1. Assignment of the control and status bits....................... 12
Tab. 2. Command line parameters of the program COM-
HVPSU2D-Control - General control................................. 19
Tab. 3. Command line parameters of the program COM-
HVPSU2D-Control - System monitoring. .......................... 21
Tab. 4. Command line parameters of the program COM-
HVPSU2D-Control - Device monitoring. ........................... 23
Tab. 5. Command line parameters of the program COM-
HVPSU2D-Control - Controller settings. ........................... 26
Tab. 6. Displayed names of the control and status bits.............. 27
Tab. 7. Command line parameters of the program COM-
HVPSU2D-Control - Configuration management.............. 30
Tab. 7 continued. ........................................................................ 31
Tab. 8. Items of configuration files. ............................................. 33
Tab. 9. Command line parameters of the program COM-
HVPSU2D-Control - Backup and restore.......................... 34
Tab. 10. Return values of the interface functions ....................... 44
Tab. 11. I/O errors....................................................................... 46
Tab. 12. Status bits of the PSU modules. ................................... 57
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page:17/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com
Software Utilities
The software utilities can be found in the directory "Program" of the
enclosed software package. Before using them with a device with a
USB interface, the virtual USB port driver must be installed (see sec-
tion "Driver Installation"). The utilities do not require any additional in-
stallation, you only need to copy them to a suitable directory on your
computer.
Before starting the utilities, you need to obtain the number of the port
to which the device is connected. Devices with an RS-232 interface
have to be connected to a physical serial port (for instance COM1). In
Windows™ systems, you can find out its number using the device
manager. Devices with a USB interface use a virtual serial port for
communication. The details are described in the section "Driver Instal-
lation".
Utility COM-HVPSU2D-Control
COM-HVPSU2D-Control is a Windows™ program that runs in text
mode. It enables you to control and monitor the pulse controller, man-
age its configurations, and backup and restore its data. Executing the
utility COM-HVPSU2D-Control.exe in a Windows™ command shell†
without any additional parameters displays a help text with the list of
all available commands:
COM-HVPSU2D-Control
To start the program without any error messages, at least the number
of the COM port must be given as a parameter:
COM-HVPSU2D-Control 6
This command starts the utility COM-HVPSU2D-Control and as-
sumes that the device is connected to the (virtual) port COM6. When
successful, the utility displays the following message:
†Press the Windows key + R to open the "Run" dialog box. Type "cmd" and press En-
ter, this opens a window with a command prompt. Then change the directory to the
one containing the program files using the command "cd". Finally, execute the given
command by copying & pasting and pressing "Enter". A better and more comfortable
alternative to the Windows™ command shell are utilities such as "Total Commander",
"File Commander/W", or "File and archive manager (FAR)". Please use an internet
search engine to find out how to obtain these applications.

Page:18/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com
COM6 opened for the communication port 0
Press '?' for help
The utility enters the interactive mode and waits for command input.
In case of any problems, check whether the port number matches the
system settings and whether the connected device is powered on and
working properly. If an error occurs, please consult the section "Error
Codes". Tables 10 and 11 explain the possible error messages; they
should help you to locate the reason for the software failure.
To check the communication, press the 'p' key to obtain the product
identification text. The device should respond as follows:
Product identification: HV-PSU-CTRL-2D, Rev.1-00
If the device responds properly, you can enter other program com-
mands. Press '?' to obtain the help listing of all available commands‡.
In practice, you may prefer to use the command line mode instead of
the interactive mode. For instance, the former allows you to save
complete commands in batch files for repeated usage.
Tables 2-9 summarize all allowable command line parameters of the
utility COM-HVPSU2D-Control. Besides the parameters, the tables
also list the functions of the software interface (see section "Software
Interface") that are called by the utility when the respective parameter
is executed. Refer to the descriptions of the functions for more details.
Note that several command line parameters, e.g. most of the com-
mands for managing the configurations, do not have any equivalent
functions. They either call several functions or they use functions not
intended to be called by the user directly.
The parameters are processed from left to right. When encountering
an error in the command line, the program stops with an error text in-
dicating the command line parameter in which the error occurred and
displaying the help text with the list of all available commands.
In several cases, the command line parameters can be specified as
either a lowercase or an uppercase character. Use capitals, i.e. up-
percase characters, if a continuous operation should be initiated. In
‡Note that keyboard layouts different to the US one may cause issues when evaluating
several characters. We recommend to switch to the US keyboard layout when using
the utility COM-HVPSU2D-Control in the interactive mode.

Page:19/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
Tab. 2. Command line parameters of the program COM-HVPSU2D-
Control - General control.
Parameter Explanation
-b, -B get the device buffer status
(see function COM_HVPSU2D_GetBufferState)
-z, -Z purge the communication
(see function COM_HVPSU2D_DevicePurge)
-t, -T terminate the program
-q, -Q quiet mode
-g debug mode
-G debug mode with output into Debug.txt
-$speed set the communication speed to the value speed
(see function COM_HVPSU2D_SetBaudRate)
-! restart the device
(see function COM_HVPSU2D_Restart)
-? show the help text with the list of all available com-
mands
the continuous mode, an operation is repeated until the user interrupts
it by pressing a certain key - usually Esc.
Numerical integer values can be specified either in decimal code or in
hexadecimal or binary ones when characters hor bare appended.
This implies that, for example, 16, 10h or 10000b all specify the
same value, namely sixteen.
If you wish to specify a name parameter containing spaces or special
characters, such as a pathname of a file containing spaces, use the
conventions valid for your operating system. In Windows™ systems,
for instance, enclose the names in quotation marks.
General Control
The command line parameters for the general control are listed in
Tab. 2. They are intended to control the function of the utility.
The communication speed defaults to 9600 baud (see section
"Software Interface"). This is usually sufficient for any short data trans-
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page:20/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
fer but may be too slow when the device data are queried periodically
or when large data amounts should be transferred. In such cases, the
communication speed can be set to a higher value using the parame-
ter -$. To set the communication speed to the maximum supported
value of 230.4 kbaud, enter the following command:
COM-HVPSU2D-Control 6 -$230400
Note that the parameter -$ is processed the same as any other pa-
rameter, thus the changed communication speed is only valid for all
subsequent commands, i.e. for all parameters following the parameter
-$. The communication speed can be changed several times within
the command line. This makes it possible to increase the communica-
tion speed for data-intensive transmissions and later reset it to the de-
fault value for other commands. Also note that the communication
speed is automatically reset to the default value of 9600 baud when
the utility stops. For more details, see section "Software Interface" and
function COM_HVPSU2D_SetBaudRate.
If the command line includes the parameter -t, the program termi-
nates without processing any following parameters. If you do not
specify the parameter -t at all, the program does not stop and enters
the interactive mode after having processed the complete command
line.
The quiet mode activated by the parameter -q reduces the text output
of the program. In contrast to that, the debug mode provides a de-
tailed output for error analysis. It can be activated by the parameter
-g. The parameter -G activates the debug mode and additionally cre-
ates a protocol file Debug.txt in which it saves the time of occur-
rence and the descriptions of all communication issues. In case of any
problems that you cannot resolve yourself, describe the issues in de-
tail and send this to the manufacturer together with the debug protocol
Debug.txt.
To restart the device, the parameter -! has to be specified. The utility
waits until the device completes its restart and responds again. During
the restart, the complete configuration is stored in the non-volatile
memory (NVM). Thus, a restart can be used to store data and prevent
an accidental data loss.
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page:21/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
Tab. 3. Command line parameters of the program COM-HVPSU2D-
Control - System monitoring.
Parameter Explanation
-v get the device firmware version
(see function COM_HVPSU2D_GetFWVersion)
-V get the device hardware version
(see functions COM_HVPSU2D_GetHWType and
COM_HVPSU2D_GetHWVersion)
-d get the device firmware date
(see function COM_HVPSU2D_GetFWDate)
-p get the product identification text
(see function COM_HVPSU2D_GetProductID)
-n, -N get the product number
(see function COM_HVPSU2D_GetProductNo)
-u get the device uptime
(see functions COM_HVPSU2D_GetUptime and
COM_HVPSU2D_GetTotalTime)
-U get the device uptime periodically
-c get the CPU data
(see function COM_HVPSU2D_GetCPUData)
-C get the CPU data periodically
-h get the device housekeeping data
(see function COM_HVPSU2D_GetHousekeeping)
-H get the device housekeeping data periodically
System Monitoring
The command line parameters for system monitoring are listed in
Tab. 3. They are useful in case of a malfunction to collect the data
necessary for describing the issues.
Using the parameter -u or -U, you can monitor the uptime of the de-
vice:
COM-HVPSU2D-Control 6 -u -t
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page:34/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
Tab. 9. Command line parameters of the program COM-HVPSU2D-
Control - Backup and restore.
Parameter Explanation
-y FileName backup the NVM data into a text file with
the name FileName
-Y FileName restore the NVM data from a text file with
the name FileName
Backing Up and Restoring the Data
All data stored in the device's NVM, i.e. the device settings including
the current configuration as well as the user configurations can be
backed up or restored (see Tab. 9). A restore procedure rolls back the
device exactly to the state it was in at the time of the backup. Thus, if
any adjusting of the settings is planned, it is recommended to first
create a backup with which the original state can be restored.
Since the back up and restore procedures transfer a large amount of
data, it is recommended to increase the communication speed by
specifying the parameter -$ (see section "General Control"). To back
up the system memory into a data file Memory.txt at a communica-
tion speed of 230.4 kbaud, execute the following command:
COM-HVPSU2D-Control 6 -$230400 -y MemoryData.txt
-t
This command downloads the memory data from the device into the
file Memory.txt.
To restore the data at the same communication speed, execute the
following command:
COM-HVPSU2D-Control 6 -$230400 -Y MemoryData.txt
-t
This command uploads the memory data from the file Memory.txt to
the device. Since all data in the NVM will be overwritten, the utility
asks for a confirmation twice.
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page:35/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
Utility FlashLoader
FlashLoader is a simple Windows™ program running in text mode. It
enables you to upgrade the firmware of the pulse controller. You
should perform an upgrade when you have received or downloaded a
new firmware file from the device manufacturer. Launching the utility
FlashLoader.exe without any parameters displays a simple help
text with the expected syntax of the command line.
FlashLoader is a universal utility for many different devices. The pulse
controller uses a variable data rate for communication, thus a utility
with the revision number 1-20 or later must be used and it must be
launched with the command line parameter -$.
Before upgrading the firmware, you should first test the device and the
communication by verifying the current firmware version. To do so,
execute the following command:
FlashLoader 6 Firmware.txt -$ -v
where Firmware.txt is the file containing the current firmware and
the number 6 indicates the port COM6 to which the device is con-
nected. The program should produce the following output:
Code file Firmware.txt from 06/18/2021, 12:00:00
Flash Loader 2.00
Verifying code file Firmware.txt
Verification completed on Mon, 06/21/2021, 12:34:56
23293 (5AFDh) bytes processed, 24064 (5E00h) bytes
verified
Resetting the target
Program completed successfully
For the verifying procedure, a flash-loader utility on the device is acti-
vated. When the verification is completed without any errors, the de-
vice is restarted.
!Attention: To ensure that the device cannot activate the attached
switches or other peripherals and produce erratic signals while Flash-
Loader is active, disconnect the power cables of the switches or turn
off the power supply units providing the supply voltages for the
switches.
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page:36/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
If any error occurs, do not proceed with the firmware upgrade. If you
cannot resolve the issues, contact the manufacturer. Note that even if
the verification fails and the flash loader on the device remains active,
it is safe to power the device off to restart it. However, a safer and
more comfortable alternative is to execute the following command:
FlashLoader 6 -$ -i -f
This prevents the utility on the host computer from initializing the flash
loader utility on the microcontroller and sends the reset command to
the device.
!Attention: If the flash loader on the device is still active and you do
not specify the command line parameter -i, the programming utility
sends data to the device at a wrong data rate during initialization. This
data stream cannot be received properly, the device ends up in an
undefined state and does not respond anymore. It must be powered
off and on to restart the controller. Since there is no other way to stop
the flash loader on the device and resume normal operation, be sure
to exactly follow the instructions in this section.
If the verification has succeeded, you may start the firmware upgrade
by entering the command:
FlashLoader 6 Firmware.txt -$
The parameter Firmware.txt is the file with the new firmware. The
program should produce the following output:
Code file Firmware.txt from 06/18/2021, 12:00:00
Flash Loader 2.00
Programming code file Firmware.txt
Programming completed on Mon, 06/21/2021, 12:34:56
23293 (5AFDh) bytes processed, 24064 (5E00h) bytes
programmed
Resetting the target
Program completed successfully
For the programming procedure, a flash loader utility on the device is
activated as well. When the programming is completed, the device is
restarted with the new firmware. You can recognize this by the startup
sequence of the LED on the front panel of the device.
If an error occurs, the flash loader utility on the microcontroller may
remain active. This is the case if the device did not restart. In this
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page:37/81 User Manual PSU-CTRL-2D, Rev.1-00:Software Utilities
case, you should reattempt the upgrade with the command line pa-
rameter -i:
FlashLoader 6 Firmware.txt -$ -i
This will prevent the utility on the host computer from initializing the
flash loader utility on the microcontroller and it will only try to repro-
gram the file Firmware.txt. If the error persists, contact the
manufacturer.
!Attention: You must not power down the device if the firmware up-
grade has not succeeded. Otherwise, the device will not operate
properly or it might not even restart at all. If this were to happen, it
would be necessary to reprogram the device in the factory.
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 38/81User Manual PSU-CTRL-2D, Rev.1-00: Driver Installation
Driver Installation
Installation of the Virtual Port for the USB Interface
The virtual port driver is required for the operation of the device with a
USB interface. If your operating system is Windows™, please note the
following:
• Please use the update function of the operating system at the host
computer or download the most recent driver from the homepage of
the manufacturer of the USB adapter. The drivers are located at the
following address: http://www.ftdichip.com/Drivers/VCP.htm. Please
choose the correct driver version according to your operating sys-
tem.
• To install the driver, administrative rights are required.
• The installation is described in detail in the "Installation Guides"
available at the abovementioned address. Please read this descrip-
tion carefully before starting the installation.
• After the installation, the number of the virtual port can be set. You
can change the settings in the device manager by opening the set-
tings of the device USB Serial Port (COMx). To modify the settings,
administrative rights are required. The settings are applied immedi-
ately, you do not need to reboot the PC to activate them.
The software can also be used on computers running Linux.
You can run it using the Windows™ emulator Wine (see
http://www.winehq.org/).
Starting with Linux Kernel 3.0.0-19, all FTDI devices are already sup-
ported without the need to compile any additional kernel modules. For
more details, consult the homepage of the manufacturer of the USB
adapter: http://www.ftdichip.com/Drivers/VCP.htm.
The system has to be configured in the following way:
• Use a program such as 'dmesg' to find out which USB port the de-
vice is connected to: Look for a line similar to "FTDI USB Serial De-
vice converter now attached to ttyUSB0"
• Link the Linux device to the virtual COM port of wine:
ln -s /dev/ttyUSB0 ~ /.wine/dosdevices/com6
This assumes that the device is attached to ttyUSB0 and will be
linked with COM6.
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 39/81User Manual PSU-CTRL-2D, Rev.1-00: Software Interface
Software Interface
The software interface for the device consists of a 32- or 64-bit dy-
namic link library COM-HVPSU2D.dll. Both versions are located in
the directory "Program" of the enclosed software package. The soft-
ware interface is a stand-alone software package, it does not require
any additional library or driver, except for the virtual port driver (see
section "Driver Installation").
The user functions in the dynamic link library COM-HVPSU2D.dll can
be called from any conventional programming language. For the de-
tails, please consult the user manual of your compiler. The definition
of the interface functions is located in the declaration file
COM-HVPSU2D.h written in C/C++. If your compiler cannot create an
import library from the dynamic link library COM-HVPSU2D.dll,
please link the library COM-HVPSU2D.lib instead of the dynamic link
library to your project.
Functionality of the Software Interface
The software interface typically controls up to 16 communication
channels for the data transfer to and from the device
(see the constant COM_HVPSU2D_MAX_PORT in the declaration file
COM-HVPSU2D.h). This means it can control up to 16 devices at a
time.
Before utilizing any function from the dynamic link library
COM-HVPSU2D.dll, the software should check the version of the li-
brary by calling the function COM_HVPSU2D_GetSWVersion. Note
that a library with a different version number can contain different im-
plementations of the functions and calling them may lead to unpre-
dictable results; in most cases, the software will crash.
Each communication channel must be opened before starting
the communication. The opening procedure (function
COM_HVPSU2D_Open) configures the used physical (RS-232) or vir-
tual (USB) serial port and clears the port buffers.
The communication channel should be closed at the end of the pro-
gram. If this does not happen, the software interface automatically
does it for you when the dynamic link library COM-HVPSU2D.dll is
unloaded from the system memory.
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 40/81User Manual PSU-CTRL-2D, Rev.1-00: Software Interface
The communication speed of the serial port defaults to 9600 baud but
can be changed to any value up to 230.4 kbaud (see function
COM_HVPSU2D_SetBaudRate). Please note that the highest speed
can be used with any USB connection.
When using the RS-232 interface, check the host hardware for the
maximum available communication speed. Most simple serial ports in
PCs only support communication speeds up to 115.2 or 128 kbaud.
They may also lose data characters when receiving the data from the
device. If you encounter such issues, replace the serial-port hardware
by a high-speed adapter card with a dedicated system driver. USB
adapters providing one or more serial ports usually do not cause any
issues either. However, due to the latency of the USB protocol, they
are significantly slower than serial ports placed directly on a PC main-
board or than serial-port cards.
If a real-time control of the hardware with a temporal resolution of
1 ms or better should be implemented, a high-speed adapter card with
a serial port (RS-232) is the recommended solution. When run at the
communication speed of 230.4 kbaud, a typical command consisting
of 2-3 ASCII characters can be sent within only 0.1-0.2 ms. In contrast
to that, a typical USB transmission may take up to 50 ms. This means
that, usually, only less than 10 bidirectional transfers per second can
be achieved when USB is used.
The communication uses the handshake lines of the serial port. Thus,
when using the RS-232 interface, be sure that you use a connection
cable that connects all pins in the DE-09 (D-Sub-9) connector. The
device emulates a null-modem, i.e. the line DTR is replicated by the
hardware as DSR and DCD and the line RTS is replicated by the
firmware as the signal CTS. If time-consuming tasks like bulk opera-
tions with the NVM are performed, the device deasserts the signal
CTS and indicates that it is not ready to respond. If the host deasserts
the lines DTR and/or RTS, the input communication buffer of the de-
vice is cleared. This can be used to repair the communication if the
response becomes erratic (see function COM_HVPSU2D_Purge).
Moreover, if the lines DTR and/or RTS are deasserted for more than
100 ms, the communication interface is reset and the communication
speed is set to the default value of 9600 baud. This happens auto-
matically when the software stops using the serial port, thus the com-
munication with the device always starts at the default speed of
9600 baud.
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 41/81User Manual PSU-CTRL-2D, Rev.1-00: Software Interface
As a first parameter, most of the interface functions require the vari-
able PortNumber, which is the number of the communication
channel that should be used for the operation in question.
This number is an unsigned integer that must be lower than
COM_HVPSU2D_MAX_PORT, i.e. it must be in the range from 0 to 15.
The return value of most functions contains a number indicating
the success of the operation. The return value is a signed
32-bit number (int). The last return value can be
reloaded by the function COM_HVPSU2D_GetInterfaceState. Ta-
ble
10 summarizes the possible return values together
with the error messages, which can also be obtained
by the function COM_HVPSU2D_GetErrorMessage. If a data
transfer failure has occurred, you can find the reason by
calling the functions COM_HVPSU2D_GetIOState and
COM_HVPSU2D_GetIOErrorMessage. The former returns the last
I/O error, the latter the corresponding error message (see Tab. 11).
If you encounter any problems with the error messages or with estab-
lishing the communication, please contact the manufacturer of the de-
vice.
Direct Command Control
As an alternative, direct control by a terminal program or another
software is possible. When using self-written software instead of the
supplied dynamic link library COM-HVPSU2D.dll, the programmer
must make sure to collect the data response after issuing a command
and to handle the possible communication errors.
The hardware communication protocol uses 8 data bits, 2 stop bits,
and even parity. The commands use ASCII characters only. Each
data transfer consists of a command character, optional control data,
and a termination character.
The termination character is the Carriage-Return code (CR, 0D hexa-
decimal; in the following text, it is referred to as the symbol ©). The
termination character initiates the command execution in the device,
which then responses with ASCII characters that are similar to the
command.
Most parameters are transferred as a sequence of hexadecimal digits
in uppercase; the most significant digit is transferred first. In several
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com

Page: 42/81User Manual PSU-CTRL-2D, Rev.1-00: Software Interface
commands, Boolean parameters are used. They use the uppercase
characters 'Y' for true and 'N' for false. An ASCII character string is
transferred as is but without the null-termination. Instead, the termina-
tion character of the command indicates the end of the string.
If a transmitted command is misspelled or unknown or if it contains in-
valid parameters, the device will not process it. The command and its
data are cleared from the input buffer and the device does not provide
any response. This implies that the communication control should
specify a certain timeout and if no response is received within this
timeout, the command has to be considered erroneous. The timeout
depends on the interface latency; with USB, the recommended value
is 100 ms. With the RS-232 interface, significantly shorter timeouts
can be used. However, the proper timeout value may also be influ-
enced by the operating system of the host and the serial-port hard-
ware. Thus, it should be determined experimentally. If the error detec-
tion is not time-critical in the application in question, the value recom-
mended for the USB interface (i.e. 100 ms) can also be used for the
RS-232 interface.
If the device does not respond or if the response is invalid, use the
handshake lines of the serial port to clear the input device buffer
(see section "Functionality of the Software Interface" and function
COM_HVPSU2D_Purge) before reattempting the operation. The clear-
ing procedure should start with deasserting the lines DTR and/or RTS
and waiting for an inactive signal CTS which indicates that the device
is not ready and that it has recognized the clear command. Then, the
abovementioned handshake lines should be reasserted and the de-
vice should respond with activating the signal CTS to indicate that it is
ready to receive further commands. Please ensure that the software
controlling the communication does not start to send any data to the
device while the signal CTS is still inactive, i.e. when the device is not
yet ready. The device would either not receive the data at all or the
first characters of the sent sequence may be lost.
If you use a communication speed different from the default value of
9600 baud, be sure to deassert the lines DTR and/or RTS for a short
time only. It is recommended to assert the handshake lines immedi-
ately after the device has responded with an inactive signal CTS. If
the handshake lines were deasserted for a longer time period (see
section "Functionality of the Software Interface"), the communication
speed would be set to the default value and it would need to be ad-
justed again by the function COM_HVPSU2D_SetBaudRate.
CGC Instruments Tel.: +49 (371) 355 098–55
Hübschmannstr. 18
|
D
–
09112 Chemnitz Fax: +49
(
371
)
355 098
–
60
internet: www.cgc-instruments.com
e
–
mail: info
@
c
g
c-instruments.com
Table of contents