AGPS Interfacing Manual 0.2
AGPS Interfacing Manual 0.2
V 0.2
Changelog
Date Version Author Description
31st March, 2021 0.1 Sofian Jafar Initial draft.
20th April, 2021 0.2 Sofian Jafar Added more details for states and CLI
interfaces
1 Table of Contents
1 Table of Contents ......................................................................................................................................................... 3
2 Introduction ................................................................................................................................................................. 4
2.1 Priorities .............................................................................................................................................................. 4
3 Interfaces ..................................................................................................................................................................... 4
3.1 CLI interfaces ....................................................................................................................................................... 4
3.1.1 Debug CLI ........................................................................................................................................................ 4
3.1.2 TCP CLI............................................................................................................................................................. 5
3.1.3 Commands ...................................................................................................................................................... 5
3.2 TCPDatastream .................................................................................................................................................... 6
3.2.1 Protocol ........................................................................................................................................................... 6
4 System Commands ....................................................................................................................................................... 8
4.1 Command Map .................................................................................................................................................... 8
5 Registers ....................................................................................................................................................................... 8
5.1 Registers Map ...................................................................................................................................................... 9
6 Parameters ................................................................................................................................................................. 10
6.1 Parameters Map ................................................................................................................................................ 10
7 States ......................................................................................................................................................................... 12
7.1 Machine Task..................................................................................................................................................... 12
7.2 Filament PS Task ................................................................................................................................................ 13
7.3 High Voltage PS Task ......................................................................................................................................... 13
7.4 Regulator Task ................................................................................................................................................... 13
7.5 Logger Task ........................................................................................................................................................ 14
7.6 Supervisor Task ................................................................................................................................................. 14
2 Introduction
The AGPS (Auxiliary Gun Power Supply) has 3 different means of interfacing; Debug-CLI, TCP-CLI and Datastream. Both
the Debug-CLI and TCP-CLI are to be used by the user directly using ASCII coded commands. Datastream is optimized for
speed and lowest data transmission requirement, for this reason it is recommended to use the Datastream interface for
building Graphical User Interfaces.
2.1 Priorities
The power supply can be controlled from a single interface at any given time, all interfaces are capable of reading all
parameters at all times though.
To be able to control the power supply an interface must send the CONTROL command thus taking hold of the power
supply while other interfaces lose the ability to send commands until one of them sends the CONTROL command again.
Register control_interface shows which interface is in control at the time.
If an interface that does not have control sends a commands or tries to write a value on a register or a parameter an error
will be returned stating that this interface is not in control.
3 Interfaces
There are 2 general types of interfaces that the AGPS has, CLI (Command Line Interface) and what’s called Datastream.
CLI interfaces are text based interfaces designed to be used by operators and maintenance engineers directly for easy
access and tuning.
Datastream interface is a binary interface, meaning that all data is transmitted back a forth between the AGPS and the
client using binary data that needs to be interpreted, but this interfaces is the fastest of the 3, which makes it the most
suitable for fast GUI applications.
Client connects to it using a USB cable to port J900 on the evaluation board, and it will be detected on the PC as a serial
port. For windows please install Microchip Studio for drivers to be installed. On Linux it should normally be automatically
detected as ttyASMx, x being some number based on how many other devices are connected.
Configuration:
• Baud rate: 115200
• Data bits: 8
• Stop bits: 1
• Parity: None
• Flow control: None
• Line end: Line Feed or Carriage Return, do not send both.
The Debug CLI has an added feature that it can continuously print a summery on the terminal showing the status of the
Operating System tasks running on the controller and the status of the power supply in general. This can be started and
stopped by sending an empty line proceeded by a line end (Line Feed or Carriage Return).
Configuration:
IP Address: AGPS IP address
Port: 2008
3.1.3 Commands
All the commands listed below can be used for both Debug CLI and TCP CLI. All commands must be terminated with
either Line Feed or Carriage Return but not both.
• CONTROL
Take control of the power supply, all other interfaces will not be able to write values to registers or parameters
or not able to send commands.
• SYS:COM <X>
Send a command to the power supply.
X: Command value according to Table…….
• PAR:R <ADDRESS> <Datatype>
Read the value of a parameter
ADDRESS: The address of the parameter according to Table 5.
Datatype: Parameter value can be read a 32-bit unsigned integer or a single precision float,
expected values are either “i” for integer or “f” for float.
• PAR:W <ADDRESS> <VALUE> <Datatype>
Write a value to a parameter
ADDRESS: The address of the parameter according to Table 5.
VALUE: The value to be written to the parameter, this will be interpreted according to
<Datatype>.
Datatype: Parameter value can be read a 32-bit unsigned integer or a single precision float,
expected values are either “i” for integer or “f” for float.
• REG:R <ADDRESS> <Datatype>
Read the value of a register
ADDRESS: The address of the register according to Table 4.
Datatype: Register value can be read a 32-bit unsigned integer or a single precision float,
expected values are either “i” for integer or “f” for float.
• REG:W <ADDRESS> <VALUE> <Datatype>
Write a value to a register
ADDRESS: The address of the register according to Table 4.
VALUE: The value to be written to the register, this will be interpreted according to
<Datatype>.
Datatype: Register value can be read a 32-bit unsigned integer or a single precision float,
expected values are either “i” for integer or “f” for float.
• ADC:R <CH>
Read current value of the ADC channel
CH The channel to be read: 1-12
• STATE:GENERAL
Print the state of the tasks of the power supply on screen using their enum values
• STATE:GENERAL:S
Similar to the STATE:GENERAL but states printed as text.
• task-stats
Print various stats of the FreeRTOS running on the controller.
• FIRMWARE:RESET
Restart the firmware.
• help
Prints all available commands with some helping instructions on how to use them.
3.2 TCPDatastream
TCPDatastream is a binary interface relying on TCP socket between the AGPS and the client. It is the preferred
communication interface for creating GUI applications as it requires less CPU power from the AGPS. This allows for faster
throughput between the AGPS and the client.
3.2.1 Protocol
The AGPS is listening for a TCP socket connection to start receiving data and react based on that data.
Sending and receiving is described from the AGPS point of view from here onward. A received packet is a packet that the
AGPS received and visa-versa.
Configuration:
IP Address: AGPS IP address
Port: 2009
• Byte 1: Type
o [0x00] - SYS_COMMAND
Send a command to the power supply, this command will be defined in the Address byte according to
Table 3. Bytes 3-6 are ignored but must be sent.
o [0x01] - READ_REGISTER
Read the binary value of a register defined by the Address byte. Bytes 3-6 are ignored but must be sent.
o [0x02] - WRITE_REGISTER
Write the binary value represented by the Data bytes on the register defined by the Address byte.
o [0x03] - READ_PARAMETER
Read the binary value of a parameter defined by the Address byte. Bytes 3-6 are ignored but must be
sent.
o [0x04] - WRITE_PARAMETER
Write the binary value represented by the Data bytes on the parameter defined by the Address byte.
o [0x05] – CONTROL
Take control of the power supply, all other interfaces will not be able to write values to registers or
parameters or not able to send commands.
• Byte 2: Address
o [0x00] – [0xFF]
Used as the address when writing or reading registers and parameters
Used as the actual command for the power supply when using SYS_COMMAND.
• Byte 3 - 6: Data
o [0x00000000] – [0xFFFFFFFF]
The binary value to be written on the register or the parameter according to Byte 1.
It is the responsibility of the client to format this value as an integer or a float according to Table 4 and
Table 5.
• Byte 1: Reply
o [0x00] - SYS_COMMAND_OK
The received SYS_COMMAND has been processed successfully. Ignore Data bytes.
o [0x01] - READ_REGISTER_OK
The requested register has been correctly read and its binary value is provided in the Data bytes.
o [0x02] - WRITE_REGISTER_OK
The received value for the register has been written successfully, and as a confirmation the value has
been re-read and sent in its binary form in the Data bytes.
o [0x03] - READ_PARAMETER_OK
The requested parameter has been correctly read and its binary value is provided in the Data bytes.
o [0x04] - WRITE_PARAMETER_OK
The received value for the parameter has been written successfully, and as a confirmation the value
has been re-read and sent in its binary form in the Data bytes.
o [0x05] – CONTROL_INTERFACE_OK
Data received in the Type byte is not defined. Ignore Data bytes.
o [0x06] – SYS_COMMAND_ERROR
The value for SYS_COMMAND that was sent is not defined.
o [0x07] – INPUT_TYPE_ERROR
Data received in the Type byte is not defined. Ignore Data bytes.
o [0x08] – PACKET_SIZE_ERROR
Received packet is not 6 bytes long.
o [0x09] – ADDRESS_OUT_OF_RANGE_ERROR
Address value for parameter or register is not defined.
o [0x0A] – PERMISSION_ERROR
Cannot write to a read-only parameter or register.
o [0x0B] – CONTROL_INTERFACE_ERROR
Not able to perform due to control being with another interface.
• Byte 2 - 5: Data
o [0x00000000] – [0xFFFFFFFF]
The binary value that was read or written on the register or the parameter according to the Type byte
in the received packet.
It is the responsibility of the client to format this value as an integer or a float according to Table 4 and
Table 5.
4 System Commands
The system makes all actions according to received commands, these commands can be sent via interfaces (DEBUG-CLI,
TCP-CLI, TCPDatastream):
5 Registers
The power supply uses these registers for its functionality, they indicate the states of the various components, they also
store some of the operational configurations for the power supply.
The operational configurations are initialized from the parameters that are stored in the flash. Any values modified in
these registers will be overwritten on the next power cycle of the power supply. This makes these registers suitable for
testing different configurations before storing them in the parameters.
6 Parameters
The power supply uses these parameters to store configuration that gets loaded every power cycle from the internal
flash.
The operational configurations are initialized from the parameters that are stored in the flash. Any values modified in
these parameters will only take effect in the next power cycle after being written to flash. Registers must be used for
testing different configuration before writing them to the parameters for long term storage.
Read / Default
Address Parameter Dataform Description
Write Value
Filament parameters
Power supply maximum current output, this must be
1 I_FIL_PS_MAX R/W Float 15 equivalent to 10V on the remote analog interface, this is
used to scale the ADC and DAC values
Power supply maximum voltage output, this must be
2 V_FIL_PS_MAX R/W Float 20 equivalent to 10V on the remote analog interface, this is
used to scale the ADC and DAC values
3 I_FIL_MAX R/W Float 1 Upper limit for current set value by AGPS controller
4 I_FIL_MIN R/W Float 0 Lower limit for current set value by AGPS controller
5 V_FIL_MAX R/W Float 1 Upper limit for voltage set value by AGPS controller
6 V_FIL_MIN R/W Float 0 Lower limit for voltage set value by AGPS controller
7 V_FIL_SETPOINT R/W Float 0 Voltage set value
8 I_FIL_SETPOINT R/W Float 0 Current set value
HV parameters
Power supply maximum current output, this must be
9 I_HV_PS_MAX R/W Float 0.1 equivalent to 10V on the remote analog interface, this is
used to scale the ADC and DAC values
Power supply maximum voltage output, this must be
10 V_HV_PS_MAX R/W Float 3000 equivalent to 10V on the remote analog interface, this is
used to scale the ADC and DAC values
11 I_HV_MAX R/W Float 0.015 Upper limit for current set value by AGPS controller
12 I_HV_MIN R/W Float 0 Lower limit for current set value by AGPS controller
13 V_HV_MAX R/W Float 100 Upper limit for voltage set value by AGPS controller
14 V_HV_MIN R/W Float 0 Lower limit for voltage set value by AGPS controller
15 V_HV_SETPOINT R/W Float 0 Voltage set value
16 I_HV_SETPOINT R/W Float 0 Current set value
Gun parameters
Amperes per Volt for the Gun measurement signal, this is
17 I_GUN_PER_V R/W Float -1
used to scale the ADC reading of the Gun.
Regulation parameters
18 TRIG_PERIOD R/W Float 1 Time between triggers in seconds
19 POLL_PERIOD R/W Float 0.01 Kp value in standby mode (regulating I_HV)
20 I_HV_STANDBY_REFERENCE R/W Float 0 Auxiliary gun current reference for regulation
21 I_GUN_TRIG_REFERENCE R/W Float 0 Gun current reference for regulation
22 DRIVE_DIFF_MAX R/W Float 0.01 Kp value in standby mode (regulating I_HV)
PID parameters in standby mode
23 KP_STANDBY R/W Float 0.01 Kp value in standby mode (regulating I_HV)
24 KI_STANDBY R/W Float 0 Ki value in standby mode (regulating I_HV)
25 KD_STANDBY R/W Float 0 Kd value in standby mode (regulating I_HV)
PID parameters in trigger mode
26 KP_TRIG R/W Float 0.01 Kp value in trigger mode (regulating I_GUN)
27 KI_TRIG R/W Float 0 Ki value in trigger mode (regulating I_GUN)
28 KD_TRIG R/W Float 0 Kd value in trigger mode (regulating I_GUN)
interlocks and faults
29 I_FIL_INTRLK R/W Float 3 Interlock value for Filament current
30 V_FIL_INTRLK R/W Float 3 Interlock value for Filament voltage
31 I_HV_INTRLK R/W Float 0.03 Interlock value for High Voltage current
32 V_HV_INTRLK R/W Float 500 Interlock value for High Voltage voltage
33 I_GUN_INTRLK R/W Float 0.5 Interlock value for the gun current
34 EMISSION_FLT_TIME R/W Int32 5 Number of triggers…
35 EMISSION_FLT_THRSHLD R/W Float 0.047 Threshold of I_HV for emission fault
36 INTERLOCKS_MASK R/W Int32 0 Mask interlocks
ADC Channels settings
37 I_FIL_ADC_CH R/W Int32 1 ADC channel connected to Filament current reading [1-12]
38 V_FIL_ADC_CH R/W Int32 2 ADC channel connected to Filament voltage reading [1-12]
ADC channel connected to High Voltage current reading [1-
39 I_HV_ADC_CH R/W Int32 3
12]
ADC channel connected to high Voltage Voltage reading [1-
40 V_HV_ADC_CH R/W Int32 4
12]
ADC channel connected to sample and hold circuit of the
41 I_GUN_ADC_CH R/W Int32 5
Gun signal [1-12]
42 DAC1_FB_ADC_CH R/W Int32 7 ADC channel connected to the DAC1 output [1-12]
43 DAC2_FB_ADC_CH R/W Int32 8 ADC channel connected to the DAC2 output [1-12]
44 DAC3_FB_ADC_CH R/W Int32 9 ADC channel connected to the DAC3 output [1-12]
45 DAC4_FB_ADC_CH R/W Int32 10 ADC channel connected to the DAC4 output [1-12]
DAC Channels settings
46 I_FIL_DAC_CH R/W Int32 1 DAC channel connected to Filament current set [1-4]
47 V_FIL_DAC_CH R/W Int32 2 DAC channel connected to Filament voltage set [1-4]
48 I_HV_DAC_CH R/W Int32 3 DAC channel connected to High Voltage current set [1-4]
49 V_HV_DAC_CH R/W Int32 4 DAC channel connected to High Voltage voltage set [1-4]
Ethernet settings
50 USES_DHCP R/W Int32 0 Enable DHCP or not
Fallback IP address if DHCP not found as follows:
51 IP_ADDR0 R/W Int32 10
[0].[1].[2].[3]
Fallback IP address if DHCP not found as follows:
52 IP_ADDR1 R/W Int32 1
[0].[1].[2].[3]
Fallback IP address if DHCP not found as follows:
53 IP_ADDR2 R/W Int32 22
[0].[1].[2].[3]
Fallback IP address if DHCP not found as follows:
54 IP_ADDR3 R/W Int32 208
[0].[1].[2].[3]
Fallback gateway address if DHCP not found as follows:
55 GATEWAY_ADDR0 R/W Int32 10
[0].[1].[2].[3]
Fallback gateway address if DHCP not found as follows:
56 GATEWAY_ADDR1 R/W Int32 1
[0].[1].[2].[3]
Fallback gateway address if DHCP not found as follows:
57 GATEWAY_ADDR2 R/W Int32 22
[0].[1].[2].[3]
Fallback gateway address if DHCP not found as follows:
58 GATEWAY_ADDR3 R/W Int32 1
[0].[1].[2].[3]
Fallback DNS address if DHCP not found as follows:
59 DNS_SERVER_ADDR0 R/W Int32 8
[0].[1].[2].[3]
Table 5: List of parameters
7 States
The states of the various parts of the system can be checked by reading the registers that end with “_state”, these
express the current state that each task is at according to the following tables.