hardware_interfaces.fpas module¶
-
class
Fpas(port: str, integration_time: int = 3014, integration_delay: int = 100, json_path: Optional[str] = None, name: str = 'FPAS')[source]¶ Bases:
objectThis class is used to communicate with the FPAS Box from Infrared Systems Development corporation.
We use Pyserial to communicate with the FPAS electronics. The FPAS is used to amplify the signal which comes from MCT detector and then is send to the ADC. Please note that all the values should be in integer format. The algorithm will tell you that something is wrong if you plug in a float value. All serial communication to and from the FPAS2 electronics occurs at 9600 baud rate, with 8 data bits, 1 stop bit, no parity bits, and no termination characters, and no flow control. All commands must begin with the character ‘I’ (Hex 0x49). All communication occurs in 8 bytes. IXXXXXXX. Where XXXXXXX is specific to certain commands listed below.
- Parameters
port (str) – COM port to which the FPAS is connected. Please
in the device manager of your operating system. (check) –
E.g.: “port5”
integration_time (int) – Integration time in nanoseconds. This is the integration time that is set upon init. Defaults to 3014 ns.
integration_delay (int) – Integration delay in nanoseconds. This is the integration delay that is set upon init. Defaults to 100 ns.
json_path (str) – Path to json file with all gain and trim values. If this is specified, all trims and gains will be set upon init. Default to None.
name (str, optional) – Name / Identifier to give to this FPAS. This is relevant for log statements, especially when there is more than one FPAS in the setup. Defaults to “FPAS”.
-
ser¶ pyserial object which initiates the communication with the FPAS.
- Type
serial.Serial
-
number_of_channel¶ Number of channels for our FPAS. From 0 to 144 for this FPAS. Other FPAS have up to 255.
- Type
int
-
min_gain¶ Minimum value for gain is 0.
- Type
int
-
max_gain¶ Maximum value for gain is 7.
- Type
int
-
min_trim¶ Minimum value for gain is 0.
- Type
int
-
max_trim¶ Maximum value for gain is 255.
- Type
int
-
step_delay_time¶ Stepsize in which the delay time/ width can be set. 5 nanoseconds.
- Type
int
-
min_delay_time¶ Minimum value for the delay time is 50 nanoseconds.
- Type
int
-
max_delay_time¶ Maximum value for the delay time is 1325 nanoseconds.
- Type
int
-
step_int_time¶ Stepsize in which the integration time can be set. 20 nanoseconds.
- Type
int
-
min_int_time¶ Minimum value for the delay time is 54 nanoseconds.
- Type
int
-
max_int_time¶ Maximum value for the integration time is 5154 nanoseconds.
- Type
int
-
name = name Name / Identifier to give to this FPAS. This is relevant for log statements, especially when there is more than one FPAS in the setup. Defaults to “FPAS”.
- Type
str
References
FPAS2 Serial Communication GuideEmails with Walter-
download(path: str, gain_values: dict, trim_values: dict)[source]¶ Creates a json file containing the gain and trim value for each channel/ pixel.
- Parameters
path (str) – Path where the json file is saved. Also defines the file name.
gain_values (dict) –
Dictionary containing channels as keys and gain values as values.
E.g. {0: 3, 1: 7, 2: 5,…}
trim_values (dict) –
Dictionary containing channels as keys and trim values as values.
E.g. {0: 31, 1: 74, 2: 54,…}
-
read()[source]¶ Reads out the FPAS answer to a sent command.
Since only one command (“ICXYYY00”) is used for reading out data we can take the last three string characters and transform them into an integer to get the gain/ trim value for a specific channel.
- Returns
- Answer to sent command. Typically consists of command
and value.
- Return type
int
-
read_gain_trim(channel_number: int, gain: bool = True)[source]¶ Reading gain/ trim value.
ICXYYY00
X – The read function. ‘G’ (Hex 0x47) indicates a Read Gain function. ‘T’ (Hex 0x54) indicates a Read Trim Function.
YYY – These three bytes are used to indicate the desired channel. Please ensure that ASCII representation of the numbers is being used. 0 is Hex 0x30 up to 9 which is Hex 0x39. This value can range from 000 to 255, inclusive.
E.g.: ICG00100 – Read Gain Value for Channel 1.
Returned: ICXYYZZZ – ZZZ is the gain/trim value at the particular channel.
Note
Please note, firmware version 1.4 or higher is required to reading the gain and trim values
- Parameters
channel_number (int) – Number of the channel for which we want to set the gain.
gain (bool, optional) – True if gain should be read out, Flase if trim should be read out Defaults to True.
-
read_integration_delay()[source]¶ Reading integration time value.
ICD00000 is the command which has to be sent.
-
read_integration_time()[source]¶ Reading integration time value.
ICW00000 is the command which has to be sent.
-
readout_channels(channels: list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143], gain: bool = True)[source]¶ Reads out gain or trim values for specified channels and returns a dict. Default are all channel for an FPAS with 144 channels.
- Parameters
channels (list, optional) – List of channels which should be read out after each other. Default are list from 0…144 channels (all channels for FPAS in H-Lab).
gain (bool, optional) – Defines if gain or trim values should be read out. Defaults to true = gain value should be read out.
- Returns
- Dictionary containing either {channel: trim_values} or
{channel: gain_values}.
- Return type
dict
-
send_command(input_command: str)[source]¶ Creates necessary ascii format of the command which will be send to the FPAS. Raises an error if the input_command contains any dots since the FPAS only accepts integer values.
- Parameters
input_command (str) – Command which should be send to the FPAS
- Returns
Command which is send to FPAS. In ascii format.
- Return type
str
-
set_delay_and_integration_time(integration_time: int, delay_time: int)[source]¶ Modifying the integration time and delay time.
IWXXXYYY
XXX- indicates the delay time. Sending 000 (Hex 0x30 0x30 0x30) will set the delay time to 50 ns. Sending 001 (Hex 0x30 0x30 0x31) will set the integration time to 55 ns. And so forth until you send 255 (Hex 0x32 0x35 0x35) which would set the delay time to 1325 ns. This value can range from 000 to 255.
YYY – indicates the integration time. Sending 000 (Hex 0x30 0x30 0x30) will set the integration time to 54 ns. Sending 001 (Hex 0x30 0x30 0x31) will set the integration time to 74 ns. And so forth until you send 255 (Hex 0x32 0x35 0x35) which would set the integration time to 5154 ns. This value can range from 000 to 255.
E.g.: IW255255 – Set Integration Time to Max and Delay Time to Max.
- Parameters
integration_time (int) – Value for the integration time in nanoseconds. Value should start at 54 ns and chosen in steps of 20 ns. However, the algorithm corrects that if you did not read the docmentation.
delay_time (int) – Value for the delay time in nanoseconds. Value should start at 50 ns and chosen in steps of 5 ns.
-
set_gain(channel_number: int, gain: int)[source]¶ Set gain value for certain channel.
IGXXX00Y. Modifying Gain values.
G - Indicates modification of the single channel Gain value.
XXX – These three bytes are used to indicate the channel whose gain you are changing. Please ensure that ASCII representation of the numbers is being used. 0 is Hex 0x30 up to 9 which is Hex 0x39. This value can range from 0 to 255, inclusive.
00 – These two bytes must be 0 (Hex 0x30)
Y – The desired Gain value of the channel. Values can range from 0 (Hex 0x30) to 7 (Hex 0x37), inclusive. 0 is maximum gain and 7 is minimum gain.
E.g.: IG001001 – Set Channel 1 Gain to 1
Please note that in the FPAS2SerCmd.VI, 7 represents maximum gain and 0 represents minimum gain.
Note
0 is maximum gain and 7 is minimum gain. This is opposite to LabView. E.g. set_gain(10,0) wil set the gain of channel 10 to 7 in terms of LabView. set_gain(10,3) will set the gain of channel 10 to 4.
- Parameters
channel_number (int) – Number of the channel for which we want to set the gain.
gain (int) – Value for the gain. Between 0 and 7.
-
set_gain_all(values: dict)[source]¶ Set gain for all channels. Channels and gains are taken from a dictionary.
This method is implemented since the FPAS in the H-Lab is not able to set all gain value for all channels at the same time due to old firmware (1.4)
- Parameters
values (dict) –
Dictionary containing channels as keys and gain values as values.
E.g. {0: 3, 1: 7, 2: 5,…}
-
set_gain_all_newfirmware(gain: int)[source]¶ Set gain value for all channels. Does only work for FPAS version 1.7, not 1.4 (ours)
IA00000N
where N is the gain value 0 - 7 in ascii 00000 – These three bytes must be set to 000 (0x30 0x30 0x30 0x30 0x30). Since all channels are being changed you do not need to indicate a desired channel.
E.g.: IA000007 - Set all channel gain to 7
- Parameters
gain (int) – Value for the gain. Between 0 and 7
-
set_gain_range(low: bool = True)[source]¶ Modifying the systems gain range.
IL00000Y
L – Indicates a change in the gain range.
00000 – These five bytes must be set to 00000 (0x30 0x30 0x30 0x30 0x30).
Y - This byte is used to indicate the gain range. 1 (Hex 0x31) is used for high gain, and 0 (Hex 0x30) is used for low gain.
No other values are valid.
E.g.: IL000001 – Set System Gain Range To 1.
- Parameters
low (bool, optional) – True if gain should be set to low. False if gain should be set high. Defaults to True.
-
set_trim(channel_number: int, trim: int)[source]¶ Modifying single channel trim value
ITXXXYYY
T – Indicates modification of single channel Trim values.
XXX – These three bytes are used to indicate the channel whose trim you are changing. Please ensure that ASCII representation of the numbers is being used. 0 is Hex 0x30 up to 9 which is Hex 0x39. This value can range from 0 to 255, inclusive.
YYY- These three bytes are used to indicate the desired trim value. Please ensure that ASCII representation of the numbers is being used. 0 is Hex 0x30 up to 9 which is Hex 0x39. This value can range from 000 to 255, inclusive.
E.g.: IT001001 – Set Channel 1 Trim to 1.
Information comes from other FPAS documentation
Maximum value: 255, minimum value: 0
IMPORTANT: Always set trim before gain!
- Parameters
channel_number (int) – Number of the channel for which we want to set the gain.
trim (int) – Value for the trim. Between 0 and 255.
-
set_trim_all(values: dict)[source]¶ Set trim for all channels. Channels and trims are taken from a dictionary.
This method is implemented since the FPAS in the H-Lab is not able to set all trim value for all channels at the same time due to old firmware (1.4)
- Parameters
values (dict) –
Dictionary containing channels as keys and trim values as values.
E.g. {0: 31, 1: 74, 2: 54,…}
-
set_trim_all_newfirmware(trim: int)[source]¶ Modify all channels trim values. Does only work for FPAS version 1.7, not 1.4 (ours)
II000YYY
T – Indicates modification of single channel Trim values.
000 – These three bytes must be set to 000 (0x30 0x30 0x30). Since all channels are being changed, you do not need to indicate a desired channel.
YYY- These three bytes are used to indicate the desired trim value. Please ensure that ASCII representation of the numbers is being used. 0 is Hex 0x30 up to 9 which is Hex 0x39. This value can range from 000 to 255, inclusive.
E.g.: II000001 – Set all Channels’ Trim to 1.
- Parameters
trim (int) – Value for the trim. Between 0 and 255.
-
upload(path: str)[source]¶ Loads gain and trim values from a specific json file and saves them to separate dictionaries.
- Parameters
path (str) – Path where the json file is located.
- Returns
- Dictionary containing the gain values and channels/
pixels. {pixel0: gain0, pixel1: gain1,…}
- dict: Dictionary containing the trim values and channels/
pixels. {pixel0: trim0, pixel1: trim1,…}
- Return type
dict