You can send commands to the HVPS directly via a serial link. This is useful if you don’t want to use the GUI or if you want to integrate the HVPS in one of your own programs (if you are working with LabVIEW, we have a library that makes it easy to integrate a HVPS).
1 Setup and parameters
To use direct serial communication with the HVPS, you need
- The arduino drivers.
- A serial terminal program (you can use the serial monitor option in the Arduino IDE) to send direct commands interactively, or any programming language that can access the serial ports to integrate your HVPS in a more complex computer-controlled programme.
The settings you need to use for the serial communication are:
- COM port to the correct port name corresponding to the HVPS
- Bits per second: 115200
- Data bits: 8
- Parity: None
- Stop Bits: 1
- Flow Control: None
You need to end each command you send to the HVPS by a carriage return (0x0D).
If you use the serial monitor of the Arduino IDE, you need to set the correct speed (115200 bauds), and the correct termination character (carriage return) in the drop-down lists at the bottom of the screen.
The list of commands that you can send to the HVPS once you have established communication is given below.
2 List of commands for the single channel HVPS (SHVPS)
Generally speaking, commands starts with either a S to set a parameter to a desired value, or with Q to query the value of a parameter. The S commands take an argument which is the desired value (e.g. SVset 3500 to set the voltage setpoint to 3500 V). Q commands take no argument, but simply return the value of the parameter. S commands also return the new parameter value, for control. Every commands return a value. A command which is not understood returns Err.
You can set parameters at any time, even when they are not relevant. For example, when the HVPS is in DC mode, you can set the frequency and number of cycles, but these values will be used only once you place the HVPS in switching mode.
The commands are case-sensistive!
2.1 Commands related to voltage and frequency
- QVmax: Queries the maximal voltage of the board. The returned value is in volts.
- SVset: Sets the output voltage setpoint. Example: SVset 1250 to set the output voltage to 1250. Returns the new voltage setpoint for control. Although this command can be used at any time, it mainly useful when the HVPS voltage control mode is 0 (interal regulator; see SVMode command).
- QVset: Queries the voltage set point. The returned value is in volts.
- QVnow: Queries the current feeback voltage of the HVPS. The returned value is in volts. Note that it is not necessarily the voltage at the output, which also depends on the switching mode (if the box is off, in DC mode, or switching).
- SPWM: Defines the functioning set point of the HV programmable source as a 10-bit (0-1023) raw PWM value. Although this command can be used at any time, it mainly useful when the HVPS voltage control mode is 2 (internal openloop; see SVMode command).
- QPWM: Queries the current HVPS setpoint as a raw PWM value.
- SF: Sets the frequency of the signal when the HVPS is in switching mode. For example SF 0.5 to set the frequency to 0.5 Hz. The value returned is the new frequency, taking quantification into account.
- QF: Queries the switching frequency. The returned value is in Hz.
- SCycle: Sets the number of switching cycles to perform when the HVPS is in switching mode. The maximum value is 65535. A value of 0 means continuous switching (unlimited number of cycles). For any value other than 0, the HVPS will change to switching mode 0 (HVPS off) after the desired number of cycles is reached. A new series of switching cycles can be can be initiated by placing the HVPS back in switching mode (mode 2). When you issue a SCycle command, the cycle counter is reset to 0. Example: SCycle 1000 to switch 1000 times at the selected frequency and then stop.
- QCycle: Queries the number of cycles. The returned value is in the form XXX/YYY, with XXX being the current cycle number and YYY the total number of cycles to make. Once the total number of cycles is reached, the output is turned off, and QCycle returns 0/YYY.
2.2 Commands to change the voltage control and switching behaviour
- SSwMode: Sets the switching mode of the HVPS. Four possible values: 0 HVPS is off (0 V output irrespective of voltage setpoint), 1 the HVPS is in DC mode with a constant output voltage at the desired setpoint, and 2, the HVPS is switching at the desired frequency between 0V and Vset. 3, the HVPS is in user-defined waveform mode. Setting the switching mode is only effective if the switching source is 0 (onboard switching). Example: SSwMode 1 to set the HVPS in DC mode
- QSwMode: Queries the switching mode of the HVPS: 0 box is off (0 V output irrespective of voltage setpoint), 1 the HVPS is in DC mode with a constant output voltage at the desired setpoint, and 2, the HVPS is switching at the desired frequency between 0V and Vset. 3, the HVPS is in user-defined waveform mode.
- SSwSrc: Sets the source of the switching signal. Accepted values are: 0 for onboard switching (from internal clock of the board), 1 for external switching via pin 6 (Ext.F) on the board main connector, and 2 for the push button. Example: SSwSrc 1 to use the external signal to switch the source on/off. Note that this setting is useful only if the jumper on header H2 is set to “onboard control”, else the jumper setting defines the source of the switching signal.
- QSwSrc: Queries the source of the switching signal: 0 for onboard switching (from internal clock of the board), 1 for external switching via pin 6 (Ext.F) on the board main connector, and 2 for the push button mounted on the board. Jumper on header H2 must be set to “onboard control” for this setting to have any effect.
- SLatchMode: Defines the behaviour of the push button, when the switching source of the HVPS is set to the push button (c.f. SSwSrc command above). Accepted values are 0 and 1: 0 for a push button behaviour (i.e. the high voltage is turned on as long as the button is pressed), and 1 for a latching switch behaviour (i.e. press once to turn the high voltage on, and press a second time to turn it off).
- SVMode: Sets the voltage control mode (i.e. how is the value of the output voltage controlled): 0 for internal voltage regulator (regulates the voltage to the value defined with the Vset command), 1 external voltage control (sets the output voltage according to the control voltage applied on pin 5 (Ext.V) of the main connector of the board. The input voltage range is 0 to 5V. 2 internal open loop control (on-board regulator disconnected).
- QVMode: Queries the voltage control mode: 0 internal voltage regulator, 1 external voltage control. 2 internal open loop control (on-board regulator disconnected).
2.3 User waveform functions
- SP: Add a point to the user waveform. Usage: SP xxx, with xxx between 0 and 255 representing 0 to 100% of the voltage setpoint. SPX or SP X erases all points of the current waveform. A new waverform is defined by issuing SPX (to clear the previous waveform), followed by a series of SP xxx to define the points of the new waveform. The maximal number of allowed points is 255.
- QP: Two usages: 1) QPtot: queries how many points are currently saved in the waveform. 2) QP xxx: queries the set point value of the point number xxx of the waveform (0<=xxx<nb_pts, with nb_pts being the result of the command QPtot (i.e. total number of points)). The returned value is between 0 and 255 and represents 0 to 100% of the voltage set point.
- QR: Same as QP, but instead of returning the set point value, it returns the voltage value read by the SHVPS internally. In order for QR to return meaningful values, the SHVPS must have been in Waveform mode (Switching mode 3) for at least one cycle. Example QR 50 to return the effective value at index 50 (use QPtot to know how many points there are in the array). The returned value is between 0 and 255 and represents 0 to 100% of the voltage set point.
2.4 Trigger/Strobe pulse functions
- SStMode: Sets the strobe mode. Usage: SStMode X, with X being 0, 1 or 2. 0: trigger/strobe pulse off: no signal is generated. 1: fixed position: a trigger/strobe signal is generated at a fixed position, with a fixed duration. By default, the pulse is synchronized with the HV switching signal, but the position and duration of the pulse can be defined by the user (see next commands). 2: sweep mode: the position of the trigger/strobe pulse is shifted along the HV signal at a user-defined speed. The HVPS must be in switching mode for the trigger pulse to be generated. The trigger pulse is generated on pin T of the multi-purpose 10-pins header on the HVPS board.
- QStMode: Queries the current strobe mode. 0: Off, 1: Fixed position, 2: Sweep mode.
- SStPos: Sets the position of the rising edge of the strobe pulse with respect to the HV output. Usage: SStPos xxx, with xxx a value between 0 and 255, representing the position of the rising edge of the trigger pulse as a fraction of the period T of the HV signal. A value of 0 means that the rising edge of the trigger pulse is coincident with the rising edge of the HV output. A value of 127 means that the rising edge of the trigger pulse is coincident with the falling edge of the HV output. The position of the pulse is only used when the strobe pulse mode is 1 (fixed position). In mode 2 (sweep mode), the position is constantly incremented.
- QStPos: Queries the current position of the rising edge of the strobe/trigger pulse. The returned value is between 0 and 255, and represents a fraction of the period of the HV output, with the beginning (position 0) being the rising edge of the HV signal.
- SStDur: Sets the duration of the strobe/trigger pulse as a fraction of the period of the HV output. Usage: SStDur xxx, with xxx being the fraction of the period of the HV output during which the strobe/trigger pulse must remain high (0: constantly off, 127: on during 50% of the period, and 255: constantly on). The duration of the pulse is used both in strobe mode 1 (fixed position) and 2 (sweep mode)
- QStDur: Queries the current duration of the strobe/trigger pulse. Returns a value between 0 and 255 representing the fraction of the period of the HV signal during which the strobe/trigger signal remains high (0: constantly off, 127: on during 50% of the period, and 255: constantly on).
- SStSw: sets the sweep time in ms. Usage SStSw xxx, where xxx is the time (in ms) that it takes to sweep the strobe/trigger pulse over a complete period of the HV output. This parameter is only used in strobe mode 2 (sweep mode). If the pulse is used to drive a strobe LED, the sweep time defines the apparent period of the motion. Logically, the period set with SStSw much be considerably longer than the period of the HV signal.
2.5 Miscellaneous functions
- QName: queries the name of the board.
- Save: This command saves the following parameters in EEPROM: Voltage setpoint, Frequency, Frequency divider, Source of switching signal (external, internal, button), Switching mode (off, DC output, switching output), Voltage mode (internal voltage regulator or following external signal), and number of switching cycles. It also saves the user-defined waveform into the EEPROM. This is useful so that it is not necessary to reconfigure the HVPS for the desired behavior every time it is powered up, for example when the HVPS is meant to be used without computer (when connected to a demo device). Note that when the HVPS is used with a computer, it is safer to save a voltage setpoint of 0V (and/or a switching mode 0 (box off)) so as to be sure that no high voltage is present at the output when the board is powered up (and before the computer has the time to initialise it to 0V output).
- QMem: queries the content of the memory (when the box is powered up, it will use the settings stored in memory, which allows using the board without a computer). This commands returns a string of parameters separated by commas: Voltage, Frequency, Switching source, Switching mode, Voltage mode, Regulator gain P, Regulator gain I, Regulator gain D , Voltage Calibration factor 0, Voltage Calibration factor 1, Voltage Calibration factor 2, number of switching cycles, button latching mode.
- QVer: returns the current version of the firmware running on the board.
- QJack: returns 1 if the power adapter is plugged in the Jack socket J1, and 0 if it is not.
2.6 Configuration functions
The normal user doesn’t need these functions. They are used after the assembly of a HVPS to configure and calibrate it. It is anyway recommended to use the GUI to perform the configuration/calibration.
- Conf: Performs the initial configuration of a board (instead of using commands below sparately). Usage: Conf XXXX, where XXX is the voltage rating of one of the 5 configurations shown on this website (i.e. 5000, 3000, 2000, 1200, and 500). Initialises Vmax to the value of XXX, and Co, C1, C2, Kp, Ki, and Kd to the default values for each voltage rating.
- SI2C: sets the I2C address of the board.
- QI2C: queries the I2C address of the board.
- SVmax: sets the voltage rating of the SHVPS. Must match the EMCO DC/DC converter rating.
- QVmax: Queries the maximal voltage of the board. The returned value is in volts.
- SC0: Sets the calibration factor c0
- QC0: Queries the value of the calibration factor c0
- SC1: Sets the calibration factor c1
- QC1: Queries the value of the calibration factor c1
- SC2: Sets the calibration factor c2
- QC2: Queries the value of the calibration factor c2
- SKp: sets parameters Kp of the PID regulator.
- QKp: Queries the value of the parameters Kp, Ki, and Kd of the PID regulator.
- SKi: sets parameters Ki of the PID regulator.
- QKi: Queries the value of the parameters Kp, Ki, and Kd of the PID regulator.
- SKd: sets parameters Kd of the PID regulator.
- QKi: Queries the value of the parameters Kp, Ki, and Kd of the PID regulator.
- SName: Sets the name of the HVPS
- QName: queries the name of the HVPS.
- SPowJack: Defines if power if provided by the power jack, SPowJack 1 (default), or through the 5V pin, SPowJack 0. You only need the use this command with SPowJack 0 if you wish to use the HVPS in the standalone configuration, or in the multichannel configuration.
- QPowJack: Queries the power jack setting. 1 when HVPS expects to receive power from power jack, and 0 when power comes from 5 V pin.
3 List of commands for the multi channel HVPS (MHVPS)
Generally speaking, commands starts with either a S to set a parameter to a desired value, or with Q to query the value of a parameter.
The commands to set a parameters are followed by the channel number to which the parameter should be applied. For example SVset0 1000 sets the voltage setpoint of channel 0 to 1000V, and SVset1 500 sets the voltage setpoint of channel 1 to 500V. It is possible to set a parameter to all channels at once using letter x (or X, or no letter at all) instead of the channel number. For example setting the voltage of all channels to 1500 V can be done with either of these 3 commands: SVsetx 1500, or SVsetX 1500, or SVset 1500.
Note that when n board are installed in a box, then they can be addressed by channel number ranging from 0 to n-1 (same logic than addressing an array in most programming languages, such as C)
The commands to query the value of a parameter will return the value for all of the installed channels, separated by commas. For example, the response to QVset (query voltage set point) in a box with 3 installed channels would be: Vset0,Vset1,Vset2 (For example 1000,1200,1500, for 1000V on channel 0, 1200V on channel 1, and 1500V on channel 2)
When issuing a command to set a parameter, the MHVPS answers with the new value of the parameters for all channels, in the same format as the reply to a query command. For example:
|Command||Answer from MHVPS|
Every commands return a value, so no answer from the MHVPS means that the command was not understood.
Note that commands are case-sensistive!
3.1 Commands related to voltage and frequency
- SVsetn: Set voltage setpoint of channel n (0<=n<=3). For example SVset0 1000 to set the voltage of channel 0 to 1000V. To set all the channels to the same value, the command SVsetx or SVsetX, or SVset can be used. Returns the voltage setpoint of each channel.
- QVset: queries the voltage setpoint for all channels. The returned value is in volt.
- QVnow: queries the actual feedback voltage for all channels. The returned value is in volt.
- SFn: Set the frequency of channel n (0<=n<=3) to a desired value in Hz. (For example SF0 2 to set the switching frequency of all channel 0 to 2 Hz. Even if a common frequency is used for all channels, the switching mode (box off, box on with DC voltage, or box switching at desired frequency) can be set individually for each channel (see SSwMode command). Frequency can be set in the range 0.001-1000 Hz. To set the frequency of all connected channels to the same value, use SFx, SFX, or SF (for example SFx 3). Setting all channels to the same frequency leads to synchronous switching, while having one or more channel set to a different frequency from the others leads to asynchronous switching.
- QF: queries the switching frequency of each channel
- SPSn: sets the phase shift of channel n (0<=n<=3) to a given value in percentage of a full period by step of 5% (i.e. between 0 and 95). For example SPS1 50 to set the phase shift of channel 1 to 50% (i.e. 180° phase shift). To set all channels at once, use SPSx, SPSX or SPS, but this means that all channels are switching at the same time). The returned value is the phase shift of all of the channels in %. If you don’t enter a multiple of 5%, the value will be rounded to the lowest integer.
- QPS: queries the phase shift for all channels. The returned value is the phase shift of all of the channels in %.
3.2 Commands to change the voltage control and switching behaviour
- SSwModen: Set switching mode of channel n (0<=n<=3). Three possible values: 0 channel is off (0 V output irrespective of voltage setpoint), 1 the channel is in DC mode with a constant output voltage at the desired setpoint, and 2, the channel is switching at the desired frequency between 0V and Vset. Example, SSwMode0 2 to set channel 0 to switching mode. Returns the switching mode of all channels. n can be replaced by x, X or a space to set same switching mode to all channels (e.g. SSwMode 0 to turn off all channels).
- QSwMode: queries the switching mode of the channels: 0 channel is off (0 V output irrespective of voltage setpoint), 1 the channel is in DC mode with a constant output voltage at the desired setpoint, and 2, the channel is switching at the desired frequency between 0V and Vset.
3.3 Miscellaneous functions
- SI2Cn: Sets the I2C address of channel n (0<=n<=3). Example: SI2C0 12 to set the address of the board installed in channel 0 to 12 (the board installed in this slot must have been previously programmed with this address). This command is usually not necessary, as the command Scan can be used to scan the I2C bus automatically (see command Scan). Note that for this command, the syntax described above to set the same parameters to all channels (n=x, or X or space) is not valid, because the address of each installed board is different.
- QI2C: queries the addresses of the connected boards. Can be used to check that the addresses memorised in the microcontroller do indeed correspond to those of the board installed in the box
- QC: queries the number of connected boards (response is an integer between 1 and 4)
- Download: download the voltage rating of each connected board and their respective names to the main microcontroller. Only necessary if I2C addresses are entered manually (see initial firmware configuration). Not necessary if Scan command is used to scan the bus, because the voltage rating of each board are automatically downloaded when using this command. The MHVPS restarts at the end of this command.
- Scan: scans the I2C bus to detect which cards are mounted in the box and downloads their maximal voltage rating. Use only if channels are installed by increasing I2C addresses. The MHVPS restarts at the end of this command.
- QVmax: queries the maximal voltage rating of each board installed in the box.
- QE: queries the error code. When the red LED is on, an error has occurred. This command allows reading the error code. See the bottom of this page for a list of error codes and their signification.
- CE: clears the error. Once the error code has been read with QE, you can clear the error code by issuing the CE command (the red LED will turn off).
- Save: Save the current parameters in the microcontroller EEPROM, so that the MHVPS restarts with the same parameters when it is powered on. The parameters which are saved are:
- The set point of each connected channel
- The switching mode (off, on DC, on switching) for each connected channel
- The phase shift for each connected channel
- The frequency.