pymepix.SPIDR package¶
Submodules¶
pymepix.SPIDR.error module¶
-
exception
pymepix.SPIDR.error.
PymePixException
(error_code)[source]¶ Bases:
Exception
-
ERR_STR
= ['no error', 'ERR_UNKNOWN_CMD', 'ERR_MSG_LENGTH', 'ERR_SEQUENCE', 'ERR_ILLEGAL_PAR', 'ERR_NOT_IMPLEMENTED', 'ERR_TPX3_HARDW', 'ERR_ADC_HARDW', 'ERR_DAC_HARDW', 'ERR_MON_HARDW', 'ERR_FLASH_STORAGE']¶
-
MONITOR_ERR_STR
= ['MON_ERR_TEMP_DAQ', 'MON_ERR_POWER_DAQ']¶
-
SPIDR_ERR_STR
= ['SPIDR_ERR_I2C_INIT', 'SPIDR_ERR_LINK_INIT', 'SPIDR_ERR_MPL_INIT', 'SPIDR_ERR_MPU_INIT', 'SPIDR_ERR_MAX6642_INIT', 'SPIDR_ERR_INA219_0_INIT', 'SPIDR_ERR_INA219_1_INIT', 'SPIDR_ERR_I2C']¶
-
STORE_ERR_STR
= ['no error', 'STORE_ERR_TPX', 'STORE_ERR_WRITE', 'STORE_ERR_WRITE_CHECK', 'STORE_ERR_READ', 'STORE_ERR_UNMATCHED_ID', 'STORE_ERR_NOFLASH']¶
-
TPX3_ERR_STR
= ['no error', 'TPX3_ERR_SC_ILLEGAL', 'TPX3_ERR_SC_STATE', 'TPX3_ERR_SC_ERRSTATE', 'TPX3_ERR_SC_WORDS', 'TPX3_ERR_TX_TIMEOUT', 'TPX3_ERR_EMPTY', 'TPX3_ERR_NOTEMPTY', 'TPX3_ERR_FULL', 'TPX3_ERR_UNEXP_REPLY', 'TPX3_ERR_UNEXP_HEADER', 'TPX3_ERR_LINKS_UNLOCKED']¶
-
-
class
pymepix.SPIDR.error.
SPIDRErrorDefs
[source]¶ Bases:
object
-
ERR_ADC_HARDW
= 7¶
-
ERR_DAC_HARDW
= 8¶
-
ERR_FLASH_STORAGE
= 10¶
-
ERR_ILLEGAL_PAR
= 4¶
-
ERR_MONITOR
= 11¶
-
ERR_MON_HARDW
= 9¶
-
ERR_MSG_LENGTH
= 2¶
-
ERR_NONE
= 0¶
-
ERR_NOT_IMPLEMENTED
= 5¶
-
ERR_SEQUENCE
= 3¶
-
ERR_TPX3_HARDW
= 6¶
-
ERR_UNKNOWN_CMD
= 1¶
-
pymepix.SPIDR.spidrcmds module¶
This module contains a list of all (found) commands for the SPIDR board
-
class
pymepix.SPIDR.spidrcmds.
SpidrCmds
[source]¶ Bases:
enum.IntEnum
A class that packages all the commands under a single name
-
CMD_AUTOTRIG_START
= 1090¶
-
CMD_AUTOTRIG_STOP
= 1091¶
-
CMD_BIAS_SUPPLY_ENA
= 1375¶
-
CMD_BURN_EFUSE
= 297¶
-
CMD_CLEAR_BUSY
= 2313¶
-
CMD_CONFIG_CTPR
= 288¶
-
CMD_DDRIVEN_READOUT
= 1094¶
-
CMD_DECODERS_ENA
= 1377¶
-
CMD_DISPLAY_INFO
= 2315¶
-
CMD_ERASE_ADDRPORTS
= 1652¶
-
CMD_ERASE_DACS
= 1653¶
-
CMD_ERASE_PIXCONF
= 1655¶
-
CMD_ERASE_REGISTERS
= 1654¶
-
CMD_GET_ADC
= 1352¶
-
CMD_GET_AVDD
= 1355¶
-
CMD_GET_AVDD_NOW
= 1357¶
-
CMD_GET_BOARDID
= 2318¶
-
CMD_GET_CHIPBOARDID
= 2319¶
-
CMD_GET_CTPR
= 290¶
-
CMD_GET_DAC
= 282¶
-
CMD_GET_DEVICECOUNT
= 2317¶
-
CMD_GET_DEVICEID
= 272¶
-
CMD_GET_DEVICEIDS
= 273¶
-
CMD_GET_DEVICEPORT
= 278¶
-
CMD_GET_DVDD
= 1356¶
-
CMD_GET_DVDD_NOW
= 1359¶
-
CMD_GET_EFUSES
= 296¶
-
CMD_GET_EXTSHUTTERCNTR
= 1366¶
-
CMD_GET_FANSPEED
= 1385¶
-
CMD_GET_FIRMWVERSION
= 2306¶
-
CMD_GET_FPGATEMP
= 1384¶
-
CMD_GET_GENCONFIG
= 820¶
-
CMD_GET_GPIO
= 1920¶
-
CMD_GET_HEADERFILTER
= 2309¶
-
CMD_GET_HUMIDITY
= 1390¶
-
CMD_GET_IPADDR_DEST
= 276¶
-
CMD_GET_IPADDR_SRC
= 274¶
-
CMD_GET_LOCALTEMP
= 1354¶
-
CMD_GET_OUTBLOCKCONFIG
= 828¶
-
CMD_GET_PIXCONF
= 557¶
-
CMD_GET_PLLCONFIG
= 822¶
-
CMD_GET_PRESSURE
= 1391¶
-
CMD_GET_PWRPULSECONFIG
= 1371¶
-
CMD_GET_READOUTSPEED
= 1380¶
-
CMD_GET_REMOTETEMP
= 1353¶
-
CMD_GET_SERVERPORT
= 279¶
-
CMD_GET_SHUTTERCNTR
= 1367¶
-
CMD_GET_SHUTTEREND
= 1365¶
-
CMD_GET_SHUTTERSTART
= 1364¶
-
CMD_GET_SLVSCONFIG
= 830¶
-
CMD_GET_SOFTWVERSION
= 2305¶
-
CMD_GET_SPIDRREG
= 1923¶
-
CMD_GET_SPIDR_ADC
= 1358¶
-
CMD_GET_STARTOPTS
= 1661¶
-
CMD_GET_TIMER
= 1362¶
-
CMD_GET_TPNUMBER
= 819¶
-
CMD_GET_TPPERIODPHASE
= 816¶
-
CMD_GET_TRIGCONFIG
= 1088¶
-
CMD_GET_VDD
= 1388¶
-
CMD_GET_VDD_NOW
= 1389¶
-
CMD_MASK
= 65535¶
-
CMD_NOP
= 0¶
-
CMD_NOREPLY
= 524288¶
-
CMD_PAUSE_READOUT
= 1095¶
-
CMD_PWRPULSE_ENA
= 1373¶
-
CMD_READ_FLASH
= 1662¶
-
CMD_REINIT_DEVICE
= 294¶
-
CMD_REINIT_DEVICES
= 295¶
-
CMD_REPLY
= 65536¶
-
CMD_RESET_COUNTERS
= 1368¶
-
CMD_RESET_DEVICE
= 292¶
-
CMD_RESET_DEVICES
= 293¶
-
CMD_RESET_MODULE
= 2311¶
-
CMD_RESET_PIXELS
= 558¶
-
CMD_RESET_TIMER
= 1361¶
-
CMD_RESTART_TIMERS
= 1360¶
-
CMD_SELECT_CHIPBOARD
= 1387¶
-
CMD_SEQ_READOUT
= 1093¶
-
CMD_SET_BIAS_ADJUST
= 1376¶
-
CMD_SET_BOARDID
= 1926¶
-
CMD_SET_BUSY
= 2312¶
-
CMD_SET_CHIPBOARDID
= 1925¶
-
CMD_SET_CTPR
= 289¶
-
CMD_SET_CTPR_LEON
= 291¶
-
CMD_SET_DAC
= 283¶
-
CMD_SET_DACS_DFLT
= 287¶
-
CMD_SET_EXTDAC
= 826¶
-
CMD_SET_FANSPEED
= 1386¶
-
CMD_SET_GENCONFIG
= 821¶
-
CMD_SET_GPIO
= 1921¶
-
CMD_SET_GPIO_PIN
= 1922¶
-
CMD_SET_HEADERFILTER
= 2310¶
-
CMD_SET_IPADDR_DEST
= 277¶
-
CMD_SET_IPADDR_SRC
= 275¶
-
CMD_SET_LOGLEVEL
= 2314¶
-
CMD_SET_OUTBLOCKCONFIG
= 829¶
-
CMD_SET_OUTPUTMASK
= 1378¶
-
CMD_SET_PIXCONF
= 554¶
-
CMD_SET_PLLCONFIG
= 823¶
-
CMD_SET_PWRPULSECONFIG
= 1372¶
-
CMD_SET_READOUTSPEED
= 1379¶
-
CMD_SET_SENSEDAC
= 824¶
-
CMD_SET_SERVERPORT
= 281¶
-
CMD_SET_SLVSCONFIG
= 831¶
-
CMD_SET_SPIDRREG
= 1924¶
-
CMD_SET_TIMEOFDAY
= 2316¶
-
CMD_SET_TIMER
= 1363¶
-
CMD_SET_TPNUMBER
= 818¶
-
CMD_SET_TPPERIODPHASE
= 817¶
-
CMD_SET_TRIGCONFIG
= 1089¶
-
CMD_STORE_ADDRPORTS
= 1648¶
-
CMD_STORE_DACS
= 1649¶
-
CMD_STORE_PIXCONF
= 1651¶
-
CMD_STORE_REGISTERS
= 1650¶
-
CMD_STORE_STARTOPTS
= 1660¶
-
CMD_T0_SYNC
= 1381¶
-
CMD_TPX_POWER_ENA
= 1374¶
-
CMD_UPLOAD_PACKET
= 827¶
-
CMD_VALID_ADDRPORTS
= 1656¶
-
CMD_VALID_DACS
= 1657¶
-
CMD_VALID_PIXCONF
= 1659¶
-
CMD_VALID_REGISTERS
= 1658¶
-
CMD_WRITE_FLASH
= 1663¶
-
pymepix.SPIDR.spidrcontroller module¶
SPIDR related classes
-
class
pymepix.SPIDR.spidrcontroller.
SPIDRController
(dst_ip_port, src_ip_port)[source]¶ Bases:
pymepix.core.log.Logger
Object that interfaces over ethernet with the SPIDR board
This object interfaces with the spidr board through TCP and is used to send commands and receive data. It can be treated as a list of
SpidrDevice
objects to talk to a specific deviceParameters: - dst_ip_port (
tuple
ofstr
andint
) – socket style tuple of SPIDR ip address and port - src_ip_port (
tuple
ofstr
andint
, optional) – socket style tuple of the IP address and port of the interface that is connecting to SPIDR
Examples
The class can be used to talk to SPIDR
>>> spidr = SPIDRController(('192.168.1.10',50000)) >>> spidr.fpgaTemperature 39.5
Or access a specific
SpidrDevice
(e.g. Timepix/Medipix)>>> spidr[0].deviceId 7272 >>> spidr[1].deviceId 2147483648
Warning
This object assumes SPIDR is working as intended however since this is still in development there are a few functions that do not behave as they should, this will be documented in their relevant areas.
-
CpuToTpx
¶ Cpu2Tpx register access
Parameters: value (int) – Value to write to the register Returns: Current value of the register Return type: int Raises: PymePixException
– Communication errorNotes
Register controls clock setup
-
DeviceAndPorts
¶
-
ShutterTriggerCount
¶ Number of times the shutter is triggered in auto trigger mode
Parameters: value (int) – Trigger count to set for auto trigger mode ( Set to 0 for infinite triggers) Returns: Current value of the trigger count read from SPIDR Return type: int Raises: PymePixException
– Communication error
-
ShutterTriggerCtrl
¶ Shutter Trigger Control register access
Parameters: value (int) – Value to write to the register Returns: Current value of the register Return type: int Raises: PymePixException
– Communication error
-
ShutterTriggerDelay
¶ Delay time before shutter can be triggered again in auto trigger mode
Parameters: value (int) – Time in ns Returns: value – Current time in ns read from SPIDR Return type: int Raises: PymePixException
– Communication error
-
ShutterTriggerFreq
¶ Triggering frequency for the auto trigger
Parameters: value (float) – Frequency in mHz Returns: Frequency value in mHz read from SPIDR Return type: float Raises: PymePixException
– Communication error
-
ShutterTriggerLength
¶ Length of time shutter remains open at each trigger
Parameters: value (int) – Length in ns Returns: value – Current length in ns read from SPIDR Return type: int Raises: PymePixException
– Communication error
-
ShutterTriggerMode
¶ Controls how the shutter is triggered
Parameters: value ( SpidrShutterMode
) – Shutter trigger mode to setReturns: Current shutter operation mode read from SPIDR Return type: SpidrShutterMode
Raises: PymePixException
– Communication errorNotes
AutoTrigger is the only functioning trigger mode that SPIDR can operate in
-
TdcTriggerCounter
¶ Trigger packets sent by SPIDR since last counter reset
-
UdpMonPacketCounter
¶
-
UdpPacketCounter
¶ UDP packets sent by SPIDR since last counter reset
-
UdpPausePacketCounter
¶ UDP packets collected during readout pause since last counter reset
-
avdd
¶
-
avddNow
¶
-
biasVoltage
¶ Bias voltage
Parameters: volts (int) – Bias voltage to supply in volts Minimum is 12V and Maximum is 104V Returns: Current bias supply in volts Return type: int Raises: PymePixException
– Communication error
-
chipboardFanSpeed
¶
-
chipboardId
¶
-
closeShutter
()[source]¶ Immediately closes the shutter
Raises: PymePixException
– Communication error
-
datadrivenReadout
()[source]¶ Set SPIDR into data driven readout mode
Data driven mode refers to the pixels packets sent as they are hit rather than camera style frames
Raises: PymePixException
– Communication errorWarning
This is the only tested mode for pymepix. It is recommended that this is enabled
-
deviceCount
¶ Count of devices connected to SPIDR
Returns: Number of devices connected to SPIDR Return type: int Raises: PymePixException
– Communication errorWarning
SPIDR always returns 4 since it currently can’t determine if the devices are actually valid or not
-
deviceIds
¶ The ids of all devices connected to the SPIDR board
Returns: A list all connected device ids Return type: list
ofint
Raises: PymePixException
– Communication errorNotes
Index of devices are the same as the those in the SPIDRController list
>>> spidr[1].deviceId == spidr.deviceIds[1] True
-
disableExternalRefClock
()[source]¶ SPIDR recieves its reference clock internally
This should be set in single SPIDR mode. When combining other SPIDR board, the master will set this to disabled
Raises: PymePixException
– Communication error
-
dvdd
¶
-
dvddNow
¶
-
enableDecoders
(enable)[source]¶ Determines whether the internal FPGA decodes ToA values
Time of Arrival from UDP packets are gray encoded if this is enabled then SPIDR will decode them for you, otherwise you have to do this yourself after extracting them
Parameters: enable (bool) – True - enable FPGA decoding False - disable FPGA decoding Raises: PymePixException
– Communication errorTip
Enable this
-
enableExternalRefClock
()[source]¶ SPIDR recieves its reference clock externally
This is often used when combining multiple Timepixs together so they can synchronize their clocks. The SPIDR board essentially acts as a slave to other SPIDRs
Raises: PymePixException
– Communication error
-
externalShutterCounter
¶
-
firmwareVersion
¶ Firmware version
Returns: Version number of firmware within the FPGA Return type: int Raises: PymePixException
– Communication error
-
fpgaTemperature
¶ Temperature of FPGA board read from sensor
Returns: Temperature in Celsius Return type: float Raises: PymePixException
– Communication error
-
humidity
¶ Humidity read from sensor
Returns: Humidity as percentage Return type: int Raises: PymePixException
– Communication error
-
linkCounts
¶
-
localTemperature
¶ Local ????!?!? Temperature read from sensor
Returns: Temperature in Celsius Return type: float Raises: PymePixException
– Communication error
-
openShutter
()[source]¶ Immediately opens the shutter indefinetly
Raises: PymePixException
– Communication errorNotes
This overwrites shutter configurations with one that forces an open shutter
-
pressure
¶ Pressure read from sensor
Returns: Pressure in bar Return type: int Raises: PymePixException
– Communication error
-
reinitDevices
()[source]¶ Resets and initializes all devices
Raises: PymePixException
– Communication error
-
remoteTemperature
¶ Remote ????!?!? Temperature read from sensor
Returns: Temperature in Celsius Return type: float Raises: PymePixException
– Communication error
-
request
(cmd, dev_nr, message_length, expected_bytes=0)[source]¶ Sends a command and (may) receive a reply
Parameters: - cmd (
SpidrCmds
) – Command to send - dev_nr (int) – Device to send the request to. 0 is SPIDR and device number n is n+1
- message_length (int) – Length of the message in bytes
- expected_bytes (int) – Length of expected reply from request (if any) (Default: 0)
Returns: Returns a numpy array of ints if reply expected, otherwise None
Return type: numpy.array
ofint
orNone
Raises: PymePixException
– Communication error- cmd (
-
resetModule
(readout_speed)[source]¶ Resets the SPIDR board and sets a new readout speed
Parameters: readout_speed ( SpidrReadoutSpeed
) – Read-out speed the device will operate atNotes
Its not clear if this does anything as its not usually used
-
resetTimers
()[source]¶ Resets all timers to zero
Sets the internal 48-bit timers for all Timepix/Medipix devices to zero
Raises: PymePixException
– Communication error
-
restartTimers
()[source]¶ Restarts SPIDR and Device timers
Synchronizes both the SPIDR clock and Timepix/Medipix clocks so both trigger and ToA timestamps match
Important
This must be done if event selection is required (e.g. time of flight) otherwise the timestamps will be offset
Raises: PymePixException
– Communication error
-
setBiasSupplyEnable
(enable)[source]¶ Enables/Disables bias supply voltage
Parameters: enable (bool) – True - enables bias supply voltage False - disables bias supply voltage Raises: PymePixException
– Communication error
-
setShutterTriggerConfig
(mode, length_us, freq_hz, count, delay_ns=0)[source]¶ Set the shutter configuration in one go
Parameters: - mode (int) – Shutter trigger mode
- length_us (int) – Shutter open time in microseconds
- freq_hz (int) – Auto trigger frequency in Hertz
- count (int) – Number of triggers
- delay_ns (int, optional) – Delay between each trigger (Default: 0)
Raises: PymePixException
– Communication error
-
shutterCounter
¶
-
shutterTriggerConfig
¶
-
softwareVersion
¶ Software version
Returns: Version number of software in the SPIDR board Return type: int Raises: PymePixException
– Communication error
-
spidrFanSpeed
¶
-
vdd
¶
-
vddNow
¶
- dst_ip_port (
pymepix.SPIDR.spidrdefs module¶
Module that contains constants that can be passed into spidr
-
class
pymepix.SPIDR.spidrdefs.
SpidrReadoutSpeed
[source]¶ Bases:
enum.Enum
An enumeration.
-
Default
= 0¶
-
HighSpeed
= 2309737967¶
-
LowSpeed
= 305419896¶
-
-
class
pymepix.SPIDR.spidrdefs.
SpidrRegs
[source]¶ Bases:
enum.IntEnum
An enumeration.
-
SPIDR_CPU2TPX_WR_I
= 456¶
-
SPIDR_DEVICES_AND_PORTS_I
= 704¶
-
SPIDR_FE_GTX_CTRL_STAT_I
= 768¶
-
SPIDR_IPMUX_CONFIG_I
= 896¶
-
SPIDR_PIXEL_FILTER_I
= 916¶
-
SPIDR_PIXEL_PKTCOUNTER_I
= 832¶
-
SPIDR_PIXEL_PKTCOUNTER_OLD_I
= 912¶
-
SPIDR_SHUTTERTRIG_CNT_I
= 660¶
-
SPIDR_SHUTTERTRIG_CTRL_I
= 656¶
-
SPIDR_SHUTTERTRIG_DELAY_I
= 684¶
-
SPIDR_SHUTTERTRIG_FREQ_I
= 664¶
-
SPIDR_SHUTTERTRIG_LENGTH_I
= 668¶
-
SPIDR_TDC_TRIGGERCOUNTER_I
= 760¶
-
SPIDR_UDPMON_PKTCOUNTER_I
= 904¶
-
SPIDR_UDPPAUSE_PKTCOUNTER_I
= 908¶
-
SPIDR_UDP_PKTCOUNTER_I
= 900¶
-
pymepix.SPIDR.spidrdevice module¶
-
class
pymepix.SPIDR.spidrdevice.
SpidrDevice
(spidr_ctrl, device_num)[source]¶ Bases:
pymepix.core.log.Logger
Object that interfaces with a specific device (Timepix/Medipix) connect to SPIDR
This object handles communication and management of a specific device. There is no need to create this object directly as
SpidrController
automatically creates it for you and is accessed by its [] getter methodsParameters: - spidr_ctrl (
SpidrController
) – SPIDR controller object the device belongs to - device_num – Device index from SPIDR (Starts from 1)
-
TpPeriodPhase
¶
-
columnTestPulseRegister
¶
-
deviceId
¶ Returns unique device Id
Parameters: - spidr_ctrl (
SpidrController
) – SPIDR controller object the device belongs to - device_num – Device index from SPIDR (Starts from 1)
- spidr_ctrl (
-
devicePort
¶
-
genConfig
¶
-
headerFilter
¶
-
ipAddrDest
¶
-
ipAddrSrc
¶
-
linkStatus
¶
-
outBlockConfig
¶
-
pixelPacketCounter
¶
-
pllConfig
¶
-
powerPulseConfig
¶
-
readoutSpeed
¶
-
serverPort
¶
-
shutterEnd
¶
-
shutterStart
¶
-
slaveConfig
¶
-
timer
¶
-
tpNumber
¶
- spidr_ctrl (