CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
Instruction set

Table of Contents

SUMMARY:



Preamble



The protocol of communication is the CAN bus that consists of groups of 8 transmission/reception bytes, a number of other bits are for diagnostic. The instruction code and data to send/receive are organized to exploit the 8 bytes, as explained in the next subsection.
Every board is identified by its own 29-bits adrress, or filter in CAN slang. Part of the adrress is from a 8-bits switches present on the board, while other bits are for experiment identification. The board on whcih the CAN bus arrives and has the µ-controller is the postfrontend board, that connects to 2 frontend boards.


The instructions are defined through the enum instructions. The bullet list and the bullet numbers at the Instruction Option
are the instruction identification codes. These codes are the MSB of the CAN messages. As an instance, if you wish to send the instruction instr_Vbias_to_be_set you should use for it the code 4.

Note
The .h file with the instruction definitions listed in the following is downloadable by right clicking, and chosing Savel link as..., on the following link: CROSS_command_parser.h.
The interpretation of the instruction is done at Istruzioni.c.

Some instructions need some parameters for the esecution, other instructions do not need further details. As an instance, the first instruction, instr_NO_operation, does not need additional information, but instr_ADC_LETTURA needs the indication of which node to measure. For every instruction there is a short explanation about the input and output data bytes in a dedicated sub-section linked to the list itself.
The shape of the CAN bus input/output message is according to the Table a and Table b below.
Table a is the prototype for the CAN bus instruction message sent to the board. There are several options that could be embedded in the 8 bytes that are not exploited by all the functions. Byte7 is the only byte always needed: it represents the code that identifies the instrucion. Then, sometimes, Byte6 says to which channel, among the 6 on the mainboard, the instruction has to be applied, in case the function itself is not generic. The MSB bit of Byte6 identifies which of the 2 boards is managed at the moment, while bit_6 of Byte6 is often exploited for other purposes. The options from Byte2 to Byte5 are other possible paramaters for the instruction. As an instance when a node voltage has to be measured Byte6 is the node to be measured.
Finally, from Byte0 to Byte3 are the data to be transmitted, if needed. As an instance, for offset adjustement these 2 bytes indicate the target offset voltage in mV.

Table a: Incoming CAN bus 8 bytes instruction messsage
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
Input data Byte_0 Input data Byte_1 Instruction option Byte_0 Instruction option Byte_1 Instruction option Byte_2 Instruction option Byte_3 selected channels or nodes Instruction code


Table b is the CAN message received from the board, after that the instruction has been executed. In several respects it is a replica of the transmitted command. It differs in the first 4 data bytes. As an instance, when an ADC node is asked to be read these 4 bytes are the measured node voltage in µV.

Table b: 8 bytes CAN bus message replay to the received instruction
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
Output data Byte_0 Output data Byte_1 Output data Byte_2 or Instruction option Byte_0 Output data Byte_3 or Instruction option Byte_1 Instruction option Byte_2 Instruction option Byte_3 selected channels or nodes Instruction code


Several instructions can be applied to several channels of the same board. This is indicated in Byte6 . The first 6 bits of Byte_6 identify the 6 channels, while bit_7 identifies the board, up or down. An easy way to set the channles is using the OR-ing of the following definitions:


An example of setting of Byte_6, ie channel3 and channel5 of upper board, is as follows:

#define instr_canale_3
Definition: Istruzioni.h:38
#define instr_scheda_up
Definition: Istruzioni.h:42
#define instr_canale_5
Definition: Istruzioni.h:40


In the following, very often, tables Table a and Table b are merged toghether and first row is the input iinstruction command while the second row is the µ-controller answer.

Remarks
In the following, every instruction is described by a subsection numbered Istr X. The number X is the code for the instruction. The same applies to the Table that describes the bytes meaning: Table X, where X is the instruction code. This is done to facilitate the usage.

Instructions list, description and references




There are several instructions that spread over several bytes of the CAN message. Below it is explained the way the CAN messages are interpreted.



List of Instructions. Click on the links:

  1. Base:................. instr_NO_operation (see tyhe definition instr_NO_operation);
  2. Base:................. instr_Shut_Down_ON_OFF (see the definition instr_Shut_Down_ON_OFF);
  3. Base:................. instr_inizializza_tutto_da_zero
    (see the definition instr_inizializza_tutto_da_zero);
  4. Detector Bias:.... instr_detector_Vbias_we_want_to_set (see the definition instr_detector_Vbias_we_want_to_set);
  5. Detector Bias:.... instr_Vbias_to_be_set (see the definition instr_Vbias_to_be_set);
  6. Detector Bias:.... instr_Relays_driver_set_reset_channel (see the definition instr_Relays_driver_set_reset_channel);
  7. Detector Bias:.... instr_detector_scrittura_lettura_trimmer_bias (see the definition instr_detector_scrittura_lettura_trimmer_bias);
  8. Preamplifier:....... instr_preamplifier_gain_low_high_set
    (see the definition instr_preamplifier_gain_low_high_set);
  9. Preamplifier:....... instr_preamplifier_temperature_meas
    (see the definition instr_preamplifier_temperature_meas);
  10. Preamplifier:....... instr_preamplifier_memory (see the definition instr_preamplifier_memory);
  11. Preamplifier:....... instr_ouput_offset_we_want_to_set
    (see the definition instr_ouput_offset_we_want_to_set);
  12. Preamplifier:....... instr_output_offset_to_be_set
    (see the definition instr_output_offset_to_be_set);
  13. Preamplifier:....... instr_preamplifier_scrittura_lettura_trimmer_offset
    (see the definition instr_preamplifier_scrittura_lettura_trimmer_offset);
  14. PGA Gain:.......... instr_PGA_gain_set (see the definition instr_PGA_gain_set);
  15. PGA Gain:.......... instr_PGA_set_reset_pre_PGA_gain
    (see the definition instr_PGA_set_reset_pre_PGA_gain);
  16. PGA Gain:.......... instr_PGA_DAC_GAIN_CROSS
    (see the definition instr_PGA_DAC_GAIN_CROSS);
  17. ERRORS:.......... instr_ERROR_inspection (see the definition instr_ERROR_inspection);
  18. ERRORS:.......... instr_ERROR_echo_on_off (see the definition instr_ERROR_echo_on_off);
  19. Common use:...... instr_ADC_LETTURA (see the definition instr_ADC_LETTURA);
  20. Common use:...... instr_readback_variables
    (see the definition instr_readback_variables);
  21. Common use:...... instr_readback_node_voltages
    (see the definition instr_readback_node_voltages);
  22. For experts:......... instr_offset_trimmer_calibration
    (see the definition instr_offset_trimmer_calibration);
  23. For experts:......... instr_DetBias_trimmer_calibration
    (see the definition instr_DetBias_trimmer_calibration;
  24. For experts:......... instr_EPROM_read_write (see the definition instr_EPROM_read_write);
  25. For experts:......... instr_connect_disconnect_mux_node_function (see the definition instr_connect_disconnect_mux_node_function);
  26. For experts:......... instr_LED_ON_OFF_function
    (see the definition instr_LED_ON_OFF_function);
  27. For experts:......... instr_periferal_reset_function
    (see the definition instr_periferal_reset_function);




The instruction instr_NO_operation

This is the simpler instruction: no operation. The answer is the fw revision in the first 4 bytes of the CAN bus answered message. The FW is simply the date of the FW expressed in YYYYMMDD (see also FW release construction). Table_instr_NO_operation is the I/O prototype.
The main purpose of this instruction is to test the communication with the board and to verify its address. When invoked it first try to use the CAN bus address that should be that of the board. If it does not work, then it reads the address from the EPROM on the post-mainboard using the generic CAN bus address, indirizzo_generico_CAN.

I/O CAN bus 8 bytes instruction messsage for instr_NO_operation
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x x x x x see the bullet at instr_NO_operation
output ans FW0 FW1 FW2 FW3 0 0 0 0
Note
To recover the date from the first 4 bytes: FW0 + (FW1 << 8) +(FW2 << 16) +(FW3 << 24), or FW0 + 28⋅FW1 +216⋅FW2 + 224⋅FW3.

The instruction instr_Shut_Down_ON_OFF

Power down for μ-controller is set ON or OFF or chcked according to Byte6 of Table_Shut_Down_ON_OFF below.
The same is applied for ADCs on board, see Table_Shut_Down_ON_OFF again.
Note that this setting is stored in the post-frontend EPROM and applied at the startup.

I/O CAN bus 8 bytes instruction messsage for instr_Shut_Down_ON_OFF
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr Shut down waiting time,
see note below
x x x x if 1=ADCs power down is set ON, dummy resistors are also ON, power unchanged;
if 0=ADCs power down is set OFF;
if 2=ADCs power down is set ON, dummy resistors are OFF, power is reduced;
if >2 = the state of the ADCs power down OFF/ON is returned.
if 1=μ-controller power down is set ON;
if 0=μ-controller power down is set OFF;
if >1 = the state of the μ-controller power down OFF/ON is returned.
see the bullet at In..Shut..
output ans The actual wait time in sec0 00 0 1 if ADCs power down was set ON, 0 if ADCs power down was set off 1 if μ-controller power down was set ON, 0 if μ-controller power down was set off see the bullet at In..Shut..

Byte0: This number is the time, expressed in seconds, from the last command executed and the start of the shut down of the μ-controller. If this number is 0 or greater than 60 the default of 5 seconds is adopted. This time is stored in memory and applied at board startup.

See also
Managing of power down is described at the Power Down page.

The instruction instr_inizializza_tutto_da_zero


With this instruction the board can be re-initialized. This is useful in case a failure of the supply voltage, or the supply voltages have been slow in their settings.

I/O CAN bus 8 bytes instruction messsage for instr_inizializza_tutto_da_zero
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr 0 0 0 0 0 0 0: the reset regards only the fw;
1: the reset is hw, i.e. from the scratch, and fw.
See note below.
see the bullet at ins...inizia...
00 0 0 0 0 0 0 see the bullet at ins...inizia...

Byte6: In case a hw + sw reset is done there is no response to the command on CAN bus. Send a new CAN bus command after a while to get a replay.


The instruction instr_detector_Vbias_we_want_to_set

The amount of the detector bias we would like to set is given here. The value can be applied to more than one channel or to a single channel depending of the setting of Byte6 of the Table below.
The voltage is in mV according to: Byte0 + (Byte1 <<8), or Byte0 + 28⋅Byte1. The voltages are stored in the vector Detector_bias_target[], this time in µV, which can be readout at instr_readback_variables.

Remarks
The values set here are only stored in the registers and not applied to the bias network. To apply the values it needs to run the function instr_Vbias_to_be_set.
Note
If different values of biases must be applied to the channels of the same board it is suggested to run this function several times to set all the values. Then invoke the instruction instr_Vbias_to_be_set just one time, it will provide the different regulations.


Note
If we call Vb the bias set at Byte0 and Byte1, then, the actual value of bias given, Vtot, is Vtot=±Vb, or twice the value of Vb.


Remarks
The detector voltage to set cannot be too close to Vbias given externally or internaly. If the value to be set at any channel is close to Vbias by more than 0.3 V , or the value given at Detector_max_limit_to_rail, than the actual value applied is between -Vbias+Detector_max_limit_to_rail and +Vbias-Detector_max_limit_to_rail. The value returned at the first 2 Bytes is the actual voltage considered.
To better understand the way the detector bias is operated see Detector Bias.
I/O CAN bus 8 bytes instruction messsage for instr_detector_Vbias_we_want_to_set
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr Byte0: LSB of the bias to set in mV Byte1: MSB of the bias to set in mV x x x x The channels this bias is to be applied, and the bit for board selection, see ex. below see the bullet at ins..det..bias
output ans 0 0 0 0 0 0 Byte6 above see the bullet at ins..det..bias


Byte6 of Table_instr_detector_Vbias_we_want_to_set above.
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 Ch5=32, then the channels to which the voltage is applied are the sum, or ORed, of the settings just considered.
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: if we want the same voltage at channel 2, 3 and 5, of the upper board, Byte6 must be: Ch2+Ch3+Ch5+board_up.

See also
The adjustment of the bias at this target voltage can be done at instr_Vbias_to_be_set.
The content of the trimmers for which the bias was found can be read from: instr_detector_scrittura_lettura_trimmer_bias.
The content of Detector_bias_target can be read via the CAN bus at instr_readback_variables.
Detector bias operation can be seen at Detector Bias.

The instruction instr_Vbias_to_be_set

For this instruction to work, the detector target bias must have been previously set with the instruction
instr_detector_Vbias_we_want_to_set, for the channels for which you want to set the new detector bias values. Operation is done according to
Table_instr_detector_Vbias_we_want_to_set_option, below.
Meanings of Byte3 to Byte6 are given after the Table.

Remarks
The bias procedure take time for getting the suitable accuracy. If repetitive settings of the same voltages are needed, such as when characterizing the NTD thermistors at different temperatures, it is suggested to read the trimmers contents and then set them again with instr_detector_scrittura_lettura_trimmer_bias.
I/O CAN bus 8 bytes instruction messsage for instr_Vbias_to_be_set
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x Average # (≤200) of ADC node readings,
a default of 1 is set if 0 is passed.
See list below waiting time between settings in units of 100 ms
(the minimum reccomended value is 10, as 200 ms is the low pass filtering time constant of the circuit)
Tolerance for the target in mV, see note below The channels for which the bias must be set and the board selection bit, see below see the bullet at ins..Vbias..
output ans 0 0 0 0 same as Byte4 above The actual tolerance used, except in case of errors, see below.a 1 for the channles found out of tolerance see the bullet at ins..Vbias..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte2: a node voltage is read this number of imes and averaged. This increase accuracy, but slow down the adjustmente proces. Each reading takes about 20 ms for single ended measurement, 50 ms for differential measurement.
Byte3 options:

  • Bit0: 1 » voltage nodes are read from an external ADC (for developers only); 0 » voltage nodes are read from the on board ADC.
  • Bit1: if set to 1 the preamplifier gain is not set to its smaller value, but it is left as it is (setting the preamplifer gain to low avoid disturbances during the process of adjustment).
  • Bit2: none.
  • Bit3: 1 » after that the bias is set the output offset of the PGA is adjusted at the previous value. The saturation of the outputs are avoided; 0 » nothing is done about the offset: this is the case load curve.
  • Bit4: 1 » bias setting starts with the trimmers at half scale: this option is exploited only when there are problems in conversion to the target voltage; 0 » bias setting starts from the present values of the trimmers, the preferred choice.
  • Bit5 to Bit7 are none.

Byte4: waiting time between test voltage settings. It is in units of 100 ms, that means that a value of 10 means 1000 ms, or 1 s. The limit of the bye is 255, or 25.5 s. If this byte is passed 0, then 1 s is set as default.
Byte5: In the input instruction: the wanted tolerance. In answer: the actual tolerance is repeated, that is the maximum between the user set and the default at minimum_error_detector_voltage.
Byte6 of Table_instr_detector_Vbias_we_want_to_set_option above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 Ch5=32, then the channels to whic the voltage is applied are the sum, or OR, of the settings just considered.
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: if we want the same voltage at channel 2, 3 and 5, the Byte6 must be: Ch2+Ch3+Ch5.

See also
The target values for the adjustment are set via CAN bus with instr_detector_Vbias_we_want_to_set.
For developers: Managing of the detctor bias.

The instruction instr_Relays_driver_set_reset_channel

The connection and managing of the detector is made trhough 4 relais that can be set with this function. The relais are bistabile and 2 switches are needed to set either state. The Table below and the following highlight the syntax to use.

I/O CAN bus 8 bytes instruction messsage for instr_Relays_driver_set_reset_channel
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x x x Relais to set, see below channel whose relais are managed, and Board bit UP/Down. See example below see the bullet at ins..Rel..SR..
output ans 0 0 0 0 0 Same as Byte5 above, except in case of errors, see below. Byte6 above see the bullet at ins..Rel..SR..


Byte5 on answer : In case of errors this byte is set to the value of 255, or 0xff, if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte5 of instruction:
Every bit of this Byte set an action if it is set to "1", while does nothing if "0". In the following, the meaninig of every bit is given.
ATTENTION: To set any bit to "1" Byte5 must be ORed with 2Bullet number below and only one bit can be set at a time:

  1. Detector_bias_invertito
  2. Detector_bias_diretto
  3. Detector_large_RLOAD
  4. Detector_small_RLOAD
  5. Detector_prea_to_GND
  6. Detector_prea_to_det
  7. Detector_external_bias (*) : see Attention below.
  8. Detector_internal_bias (*) : see Attention below.


Attention
(*): for safety reason these 2 switches, Detector_external_bias and Detector_internal_bias, are set if and only if the positive external applied detector biasing voltage is within 1 V and 6 V and the negative external detector applied biasing voltage is within -6 V and -1 V . The absolute limits of ±1 V and ±6 V are subjected to change and are defined at Detector_min_voltage_for_switch and Detector_max_voltage_for_switch.
Hovewer, after the last release of the board the connection or non-connection of the external bias voltage is not necessary and must be left on Detector_external_bias: the circuit senses and connects the external bias voltage, if higher than ±5 V.


Byte6 of Table_instr_Relays_driver_set_reset_channel :
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channel from which the trimmer is read or written is the one settled;
Bit6: 1 » the trimmer is written, let's call it write_trimmer=1<<6, 0 » : the trimmer is read;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: if we want the write in trimmer of channel 3, upper board, then Byte6 must be Ch3 | write_trimmer | board_up.


The instruction instr_detector_scrittura_lettura_trimmer_bias

This function is a so called atomic function: it allows to read from or write to any of the trimmers of the detector bias. This is possible through Table_instr_detector_scrittura_lettura_trimmer_bias and the following list.

I/O CAN bus 8 bytes instruction messsage for instr_detector_scrittura_lettura_trimmer_bias
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr Value to write, range (0, 255) x x x x Trimmer to write in or read from (0, 3) channel whose trimmer is managed, R/W and Board UP/Down. See example below see the bullet at Ins..Vb..we
output ans trimmer contents 0 0 0 0 Same as Byte5 above, except in case of errors, see below. Byte6 above see the bullet at Ins..Vb..we


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_detector_scrittura_lettura_trimmer_bias above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channel from which the trimmer is read or written is the one settled. If more than one channel is selected, then the lower one is considered;
Bit6: 1 » the trimmer is written, let's call it write_trimmer=1<<6, 0 » : the trimmer is read;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: if we want the write in trimmer of channel 3, upper board, then Byte6 must be Ch3 | write_trimmer | board_up.

See also
These trimmers are those set with the instruction instr_Vbias_to_be_set, after than the target voltage has been got.

The instruction instr_preamplifier_gain_low_high_set


The preamplifier gain can be set large, 210 V/V, or small, 22 V/V, according to the syntax below.

I/O CAN bus 8 bytes instruction messsage for instr_preamplifier_temperature_meas
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x x x If 1 the gain is set large, if 0 the gain is set small channel whose gain is to be set and the board bit according to the list below see the bullet at Ins..gai..low..
output ans 0 0 0 00 Same as Byte5 above, except in case of errors, see below. Byte6 above see the bullet at Ins..gai..low..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_preamplifier_temperature_meas_option above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channels to which the gain is set are those ORed, see example below;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: If we want to set the gain of channel 1, channle 3 and channel 5 of the upper board, then Byte6 must be Ch1 | Ch3 | Ch5 | board_up.


The instruction instr_preamplifier_temperature_meas


The preamplifier temeperature, in μ°C, can be read by this function according to the syntax below.

I/O CAN bus 8 bytes instruction messsage for instr_preamplifier_temperature_meas
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x x x x channel whose temperature is read and the board according to the list below see the bullet at Ins..temp...
output ans Byte0 read Byte1 readByte2 readByte3 read0 Same as Byte5 above, except in case of errors, see below. Byte6 above see the bullet at Ins..temp...


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_preamplifier_temperature_meas_option above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channel from which the temperature is read is the one settled;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: If we want to read the temperature of channel 3, upper board, then Byte6 must be Ch3 | board_up.
The temperature is given by: T= (Byte0+ Byte1*28+Byte2*216+Byte3*224)×10-6 °C.


The instruction instr_preamplifier_memory


The memory of any preamplifier can be R/W according to the Table below. Byte4 and Byte5 are the starting address of the memory where data must be read or written. The memory is organized as unsigned int and the first 2 bit of address must be 0. The first 4 bytes of the instruction and replay are the content of the 4 memory locations. The first 4 bytes of the command do not care in case of reading. The channel for which the memory is selected, the R/W bit and the selected board bit are at Byte6 according to the syntax below the Table.
Every used memory cell of the preamplifier EPROM is listed here preamplifier_memory_location_list. Memroy locations beyond the last address are free.

I/O CAN bus 8 bytes instruction messsage for instr_preamplifier_memory
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr Byte0 to store Byte1 to store Byte2 to store Byte3 to store LSB Memory start address MSB Memory start address channel to select, R/W bit and selected board bit according to the list below see the bullet at Ins..mem..
output ans Read Byte0 Read Byte1 Read Byte2 Read Byte3 Byte4 above Same as Byte5 above, except in case of errors, see below. Byte6 above see the bullet at Ins..mem..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_preamplifier_memory_option above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channel from which the memory is managed is the one settled;
Bit6: 1 » : the memory is written with the 4 bytes at Byte0 to Byte3; 0 » : the memory is only read;
Bit7: 1 » : the upper board is considered, set board_up=1<<7 to apply this; 0 » : the lower board is considered.


The instruction instr_ouput_offset_we_want_to_set


The output target offset for every channel we want to set. Take care: this is the value we want to set. To apply this value to the channel the instruction instr_output_offset_to_be_set_option must be launched. Table below shows how to proceed. Byte0 and Byte1 are the value of the offset to set, in mV. The channels to which the offset is defined are at Byte6 according to the syntax below the Table. The same offset value can be applied to different channles at a time. This function is necessary before the offset is applied to the channels and need to be launched for every different value needed.

I/O CAN bus 8 bytes instruction messsage for instr_ouput_offset_we_want_to_set
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr Byte0: LSB of the bias to set in mV Byte1: MSB of the bias to set in mV X X X X The channels this offset is to be set, and the bit for board selection, see ex. below see the bullet at Ins..off..we
output ans 0 0 0000Byte6 above see the bullet at Ins..off..we


Byte6 of Table_instr_ouput_offset_we_want_to_set_option above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channel to which the target offset is defined are the OR of the settings above, exmaple Ch1 | Ch5 ;
Bit7: 1 » : the upper board is considered, set board_up=1<<7 to apply this; 0 » : the lower board is considered.
The target offset, in mV is evaluated according to: Byte0 + Byte1 << 8, or Byte0 + 28 Byte1.


The instruction instr_output_offset_to_be_set


The output offset, whose target was stored at instr_ouput_offset_we_want_to_set, can be adjusted at the PGA outputs of the selected channels. A few parameters can be set according to the Table and instructions below.

I/O CAN bus 8 bytes instruction messsage for instr_output_offset_to_be_set
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x Average # (≤200) of ADC node readings, see below See list below for available options Waiting time between settings in units of 100 ms Tolerance for the target offset in mV The channels this offset is to be set, and the bit for board selection, see ex. below see the bullet at Ins..offs..set
output ans 0 0 00Same as Byte4 above Same as Byte5 above, except in case of errors, see below. A "1" for the channles found out of tolrence See the bullet at Ins..offs..set


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte2 : a node voltage is read this number of times and averaged. This increase accuracy, but it slows down the adjustmente process. If the value passed is 0 the default of 1 is applied. Each reading takes about 10 ms.
Byte3 options:

  • Bit0: 1 » node voltatges are read from an external ADC; 0 » node voltages are read with the on board ADC.
  • Bit1: 1 » offset setting starts with the trimmers at half scale, this option is exploited always when there are problems in convergence to the target voltage; 0 » offset is adjusted starting from the present value set in the trimmers;
  • Bit2: none is done
  • Bit3: 1 » Offset is adjsted and stored to be applied to the channell at startup, i.e.set into the preamplifier trimmer; 0 » no action. Startup preamplifier memoery location is at Memory_preamplifier_startup_offset_trimmer.
  • Bit4: 1 » Offset stored at startup location is applied now. No adjustment is made; 0 » no action.
  • Bit5: 1 » Offset is adjsted and stored at user memory location at Memory_preamplifier_user_offset_trimmer of preamplifier memory; 0 » no action.
  • Bit6: 1 » offset is recalled from user memory location. No adjustment is made; 0 » no action.
  • Bit7: 1 » the state of the channel is stored at user location, as it is. No other actions are taken; 0 » no action.

Byte4: waiting time between each setting. It is in units of 100 ms, that means that a value of 10 means 1000 ms, or 1 s. The limit of the bye is 255, or 25.5 s. If this byte is passed 0, then 1 s is set as default.
Byte5: final maximum error in mV from the target voltage.
Byte6 of Table_instr_detector_Vbias_we_want_to_set_option above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 Ch5=32, then the channels to which the voltage is applied are the sum, or OR, of the settings just considered.
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: if we want the same voltage at channel 2, 3 and 5, the Byte6 must be: Ch2+Ch3+Ch5.

See also
The target values for the adjustment are set via CAN bus with instr_ouput_offset_we_want_to_set.

The instruction instr_preamplifier_scrittura_lettura_trimmer_offset

This function is a so called atomic function: it allows to read from or write to any of the trimmers of the detector bias. This is possible through Table_instr_preamplifier_scrittura_lettura_trimmer_offset and the following list.

I/O CAN bus 8 bytes instruction messsage for instr_preamplifier_scrittura_lettura_trimmer_offset
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr Value to write, in case of write (0, 255) x x x x Trimmer to write in or read from (0, 3) channel whose trimmer is managed, R/W and Board UP/Down. Ssee ex. below see the bullet at Ins..R/W..trim..
output ans trimmer contents 0 0 0 0 Same as Byte5 above, except in case of errors, see below. Byte6 above see the bullet at Ins..R/W..trim..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_preamplifier_scrittura_lettura_trimmer_offset above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channel from which the trimmer is read or written is the one settled. If more than one channel is selected, then the lower one is considered;
Bit6: 1 » the trimmer is written, let's call it write_trimmer=1<<6, 0 » : the trimmer is read;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: if we want the write in trimmer of channel 3, upper board, then Byte6 must be Ch3 | write_trimmer | board_up.

See also
Values in these trimmers are automatically set via CAN bus with instr_output_offset_to_be_set.

The instruction instr_PGA_gain_set

See Table Table_instr_PGA_gain_set.
The applied gain is at Byte0. It must be between 1 V/V and 100 V/V. The same gain can be applied to channels indicated at Byte6, see below.
In the answers at Byte0 the actual applied gain is given, that can be differ slightly due to approximation to the nearest integer.

Remarks
It is recommended to set active the option at Byte5 of maintaining the offset. This avoid the saturation of outputs, with consequent disturbances, if large increase of the gains are set.
I/O CAN bus 8 bytes instruction messsage for instr_PGA_gain_set
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr 1 ≤ Gain ≤ 100 x Average # (≤200) of ADC node readings, if Byte5 is 1 (*) Waiting time between settings in units of 100 ms, if Byte5 is 1 (*) Tolerance for the target offset in mV if Byte5 is 1 (*) if 1 the offset, for the selected channels, is maintened the actual after that the gain is changed. The channels to which the gain is applied and the board bit selction

see the bullet at Ins..gain_set..

output ans Actual Gain set 0 0 0 0 Same as Byte5 above, except in case of errors, see below. same as Byte6 above see the bullet at Ins..gain_set..


(*) If this parameter is passed 0, when byte5 is 1, the default is adopted.
Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_PGA_gain_set above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channels to which the new gain is set are those ORed, see example below;
Bit5: 1 » : the gain is changed to the new value and the offset is set at the value at Byte1 and Byte2 expressed in mV.
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Exmaple: if the gain is being applied to channles 2, 3 and 5 of upper board, then Bit6 should be: Ch2 | Ch3 | Ch5 | (1<<7).


The instruction instr_PGA_set_reset_pre_PGA_gain

This is an atomic function that users could not use. It allows to set the gain of the unput stage of the two stages PGA. The gain of this stage is set by means of a relay and can take the 2 values of 1 V/V and 10 V/V.
The larger gain is set settin "1" at Byte4.
The same gain can be applied to the channels listed at Byte6, see below.

I/O CAN bus 8 bytes instruction messsage for instr_PGA_set_reset_pre_PGA_gain
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x x If 1 the gain is set high x The channels to which the gain is applied and the board bit selection see the bullet at Ins..S/R..gain..
output ans 0 0 0 0 same as Byte4 above e. It allows to set the gain of the second stage of Same as Byte5 above, except in case of errors, see below. same as Byte6 above see the bullet at Ins..S/R..gain..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_PGA_set_reset_pre_PGA_gain above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channels to which the new gain is set are those ORed, see example below;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Exmaple: if the gain is being applied to channles 2, 3 and 5 of upper board, then Bit6 should be: Ch2 | Ch3 | Ch5 | board_up.


The instruction instr_PGA_DAC_GAIN_CROSS

This is an atomic function that users could not use. It allows to set the gain of the second stage of the two stages PGA. The gain of this stage is set by means of a DAC in feedback to an OA.
The gain is set setting the value at Byte4, a number between 1 and 100.
The same gain can be applied to the channels indicated at Byte6, see below.

I/O CAN bus 8 bytes instruction messsage for instr_PGA_DAC_GAIN_CROSS
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x x The gain to set x The channels to which the gain is applied and the board bit selection see the bullet at Ins..DAC..gai..
output ans 0 0 0 0 same as Byte4 above Same as Byte5 above, except in case of errors, see below. same as Byte6 above see the bullet at Ins..DAC..gai..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_PGA_DAC_GAIN_CROSS above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channels to which the new gain is set are those ORed, see example below;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Exmaple: if the gain is being applied to channles 2, 3 and 5 of upper board, then Bit6 should be: Ch2 | Ch3 | Ch5 | board_up.


The instruction instr_ERROR_inspection


The occurrence of any error can be inspected here. A few actions are possible according to the options of the Table_instr_ERROR_echo_on_off below.

I/O CAN bus 8 bytes instruction messsage for instr_ERROR_inspection.
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr If Inst2: the address of the queried error register x x x x x See "Note to Byte6" below.
Inst1: It is asked if there are errors;
Inst2: it is asked to send back the content of the register indicated at Byte0
Inst3: reset all errors
Inst4: echo status is returned at Byte0
see the bullet at Ins..Err..ins..
output ans If Inst1: Address of the last error register;
if Inst2: Byte0 of the selected error register;
if Inst4: 1 if Echo is ON, 0 if Echo is off
if Inst1: the number of errors;
if Inst2: Byte1 of the selected error register
if Inst2: Byte2 of the selected error register if Inst2: Byte3 of the selected error register 0
if Inst2: The address of the selected error regsiter Same as Byte6 above see the bullet at Ins..Err..ins..


Note to Byte6 of Instruction: Inst1,…, Inst4=1,…,4: these are the reference code that set the choices for all the bytes of the instruction and output that refer it.
The error registers are at List of error resisters, while the meaning of the flags contained in the registers is at Errors flags .

See also
Error Echo ON or OFF can be set at instr_ERROR_echo_on_off.

The instruction instr_ERROR_echo_on_off


Error occurence can be notified via CAN bus as soon as it happens. Here this option can be set ON or OFF when the command is sent from the control room. If Echo is ON and a verification of error happens the μ-controller send back the notification to the CAN via row 3 of Table_instr_ERROR_echo_on_off below.

I/O CAN bus 8 bytes instruction messsage for instr_ERROR_echo_on_off
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr 1=set echo ON;
0=set echo off
x x x x x x see the bullet at instr_ERROR_echo_on_off
output ans If Echo is ON → 1;
If Echo is OFF → 0
0 0 0 0
0 0

See the bullet at Ins..Er..Ech..

From the CAN at error verification, Echo ON case Byte0 of error register Byte1 of error register Byte2 of error register Byte3 of error register 0
Error Register address 1 (this marks there is an error echoed) See the bullet at Ins..Er..Ech..
Note
The error registers are at List of error resisters, while the meaning of the flags contained in the registers is at Errors flags .
See also
Errors can be inspected at instr_ERROR_inspection.

The instruction instr_ADC_LETTURA

The instruction instr_ADC_LETTURA needs to specify the node to be read. There are 32 possible different nodes connectible to the ADC. In the present version of the hw not all the 32 are used. The list of the usable nodes and the code to be used at byte MSB-1 of the CAN message are listed at user_use_of_ADC. This happens if Byte5 of the instruction is 0. When Byte5 is 1 the μ-controller sets up the node to be read, but the ADC used is not that on board and the last 2 rows of TableInstr_instr_ADC_LETTURA applies. This operation is for developer only and its details are given below the table.
I/O instruction is at table TableInstr_instr_ADC_LETTURA. The result of the measurement is found at the 4 LSB.
The result is in µV: Meas0 + (Meas1 <<8) + (Meas2 <<16) + (Meas3 <<24), or Meas0 + 28⋅Meas1 + 216⋅Meas2 + 224⋅Meas3.

I/O CAN bus 8 bytes instruction messsage for instr_ADC_LETTURA.
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x 0=ADC offset is measured and discharged;
1=ADC offset is not measured;
Average # (<200) of ADC node readings, see below bit_0: 1= read from external ADC
bit_0: 0= read from on board ADC,
bit_1: 0= read single ended PGA/PreOut/detector bias
bit_1: 1= read differential PGA/PreOut/detector bias
see note below
see the list below at Byte6 for node to read.
To select board up "or" the Byte with 0x80
see the bullet at Ins..ADC..let..
output ans Meas0 (differential PGA/PreOut)
Meas0 (positive PGA/PreOut)
Meas1 (differential PGA/PreOut)
Meas1 (positive PGA/PreOut)
Meas2(differential PGA/PreOut)
Meas0 (negative PGA/PreOut)
Meas3 (differential PGA/PreOut)
Meas1 (negative PGA/PreOut)
0 Same as Byte5 above, except in case of errors, see below.
see the list below Byte6see the bullet at Ins..ADC..let..
output ans with ext ADC from micro 0 0 0 00
The node to measure 1 (that means the node to measure must come from the CAN) see the bullet at Ins..ADC..let..
answer to micro Meas0 from CAN Meas1 from CAN Meas2 from CAN Meas3 from CAN 0 The node measured 0 (that means the node is coming from the CAN) see the bullet at Ins..ADC..let..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte2: a node voltage is read the number of times the content of this byte and averaged. This increase accuracy, but slow down the adjustmente process. Each reading takes about 10 ms.
Byte5: Bit_0: this option will be obsolote after installation. Set it as "0". Bit_1: if 1 2 readings are given for positive and negative ouputs in case of PGa and PreOut. The values are in mV in this case and Byte0 and Byte1 of answer is for positive output while Byte2 and Byte3 is for the negative ouput. Bit_1: if 0 the differential ouput is answered in µV from Byte0 to Byte3.
Byte5 Bit_0 is set to 1 by developer. When this is applied the μ-controller sets up the node to read, then it sends bak to the CAN the third row of TableInstr_instr_ADC_LETTURA. The control room then measures the node with an external ADC such as a multimeter, then sends the result back to the μ-controller according to the last row of TableInstr_instr_ADC_LETTURA. If Bit_0 is 0 the node is read from the on-board ADC.
If Bit_1 is 0 the node is read single ended, while if Bit_1 is 1 the node is read differential.
Byte6: The list of the available node voltage to measure is listed in the 2 Tables below. Take note of the node number on the left of each definition. Discrimination between the upper and lower boards is made with bit 7. The names of the nodes is the same for the 2 boards, what changes is only bit 7.
At the moment, there is an alternative way to select and PGA channels from 0 to 5 are considered on the board down while PGA channels from 6 to 11 are considered on the board up.
The same is for the preamplifier outputs, except the fact that they start to be counted from 12.

Remarks
Discrimination between any nodes on board down and up is done only trough bit 7 in Byte6 of the instruction.


PGA and Preamplifier outputs and Power Supplies nodes have direct individual connections to the output connector of mainboard A. The number to use are the bullets for both board up and down for channels in the same position.

PGA output Pream outputs Power Supplies
node_voltage_PGA_offset: offset for the first set of nodes (for developers only). node_voltage_PreOut_offset: offset for the first set of nodes (for developers only). node_voltage_PowSupp_offset: offset for the first set of nodes (for developers only).
  1. node_voltage_PGA_ch_0;
  2. node_voltage_PGA_ch_1;
  3. node_voltage_PGA_ch_2;
  4. node_voltage_PGA_ch_3;
  5. node_voltage_PGA_ch_4
  6. node_voltage_PGA_ch_5;

  1. node_voltage_PGA_neg_ch_0;
  2. node_voltage_PGA_neg_ch_1;
  3. node_voltage_PGA_neg_ch_2;
  4. node_voltage_PGA_neg_ch_3;
  5. node_voltage_PGA_neg_ch_4
  6. node_voltage_PGA_neg_ch_5;

  1. node_voltage_PreOut_ch_0;
  2. node_voltage_PreOut_ch_1;
  3. node_voltage_PreOut_ch_2;
  4. node_voltage_PreOut_ch_3;
  5. node_voltage_PreOut_ch_4
  6. node_voltage_PreOut_ch_5;

  1. node_voltage_PreOut_neg_ch_0;
  2. node_voltage_PreOut_neg_ch_1;
  3. node_voltage_PreOut_neg_ch_2;
  4. node_voltage_PreOut_neg_ch_3;
  5. node_voltage_PreOut_neg_ch_4
  6. node_voltage_PreOut_neg_ch_5;
  1. node_voltage_Vcc
  2. node_voltage_Vee
  3. node_voltage_Vdig
  4. node_voltage_sense_Vreg_n (measured from posmainboard only)
  5. node_voltage_sense_Vreg_p (measured from posmainboard only)
  6. node_voltage_sense_GND (measured from posmainboard only)


The analog Multiplexers have connected the following nodes. The number to use are the bullets for both board up and down for channels in the same position.

Mux 0 Mux 1
node_voltage_Analog_Mux_0_offset: starting offset for Mux 0 (for developers only).
  1. node_voltage_Analog_Mux_meas_bias_pos_ch0
  2. node_voltage_Analog_Mux_meas_bias_neg_ch0
  3. node_voltage_Analog_Mux_meas_bias_pos_ch1
  4. node_voltage_Analog_Mux_meas_bias_neg_ch1
  5. node_voltage_Analog_Mux_meas_bias_pos_ch2
  6. node_voltage_Analog_Mux_meas_bias_neg_ch2
  7. node_voltage_Analog_Mux_meas_bias_pos_ch3
  8. node_voltage_Analog_Mux_meas_bias_neg_ch3
node_voltage_Analog_Mux_1_offset: starting offset for Mux 1 (for developers only).
  1. node_voltage_Analog_Mux_meas_bias_pos_ch4
  2. node_voltage_Analog_Mux_meas_bias_neg_ch4
  3. node_voltage_Analog_Mux_meas_bias_pos_ch5
  4. node_voltage_Analog_Mux_meas_bias_neg_ch5
  5. node_voltage_Analog_Mux_meas_input_bias_pos
  6. node_voltage_Analog_Mux_meas_input_bias_neg
node_res_fisse_Mux_1: starting offset for Mux 1 (for developers only).
  1. node_voltage_Analog_Mux_meas_none
  2. node_voltage_Analog_Mux_meas_10k_to_gnd


There are additional nodes that can be selected that are usefull to the developers only:

Additional selectable nodes, for developers
  1. Analog mux wire 1
  2. Analog mux wire 2
  1. Dummy per selezionare ADC0
  2. Dummy per selezionare ADC1


See also
For developer: ADC managing and also Multiplexer_strutture_funzioni_definizioni

The instruction instr_readback_variables

I/O CAN bus 8 bytes instruction messsage for instr_readback_variables
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x x x variable to read according to the list belowchannel from which the variable is read see the bullet at Ins..readback..
output ans variable value 0 0 0 0 Byte5 Byte6 above see the bullet at Ins..readback..


Byte5: List of the possible variables to be read, the bullet number is the code to use at this byte:

  1. instr_detector_bias_variable to read from the Detector_bias_target[ ];
  2. instr_offset_voltage_variable to read from the preamplifier_Output_offset_target[ ];
  3. instr_PGA_gain_variable variable to read from the PGA_settled_gain[ ].


Byte6 of Table_instr_readback_variables above:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channels to read from is the one selcted;
Bit7: 1 » : the upper board is considered, set board_up=10^7; 0 » : the lower board is considered.
Exmaple: if we need to read from channel 5, upper board, then Bit6 should be: Ch5 | board_up.

Note
The vectors are 12 cells vectors. The first 6 poitions are for the 6 channles of the lower board, the last 6 positions are for the 6 channels of the upper board. Is therefore important to consider if we are referring to the lower or upper board.
See also
Writing in Detector_bias_target[] is posssible via CAN bus at instr_detector_Vbias_we_want_to_set.
The writing in PGA_settled_gain[] is done whenever the PGA gain is set with the CAN bus instr_PGA_gain_set.

The instruction instr_readback_node_voltages



Node voltages can be read from an external ADC and sent to the µ-controller for comparison, internal use and the like. Take care that this function works only if a multiplexed multimeter is available or the DAQ is connected and either the multimeter or the DAQ must respond to the sw.
This is a non conventional function since the µ-controller asks for the measurement of some nodes: it is a bi-directional function. Byte6 is "0" when the communication is from the external ADC, that communicates to have read the node at Byte5. The result, in mV, is at Byte0 and Byte1: the µ-controller will read it. When Byte6 is "1" is the µ-controller that asks to the external ADC to take the measurement of node at Byte5.
The instruction works if the ADC is connected to the ouput connector of the mainboard A, in parallel to mainboard B.

Note
This instruction will become obsolete at the time of installation.
I/O CAN bus 8 bytes instruction messsage for instr_readback_node_voltages
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr LSB of the node measured (mV), if Byte6=0 MSB of the node measured (mV), if Byte6=0 x x 1= selected node is from board up;
0= selected node is from board down
Readable nodes are at Node list. 0: the voltage is from the ouside,
1: the node voltage is required from the µ-controller
see the bullet at Ins..read_nod..
output ans 0 0 0 0 0 Node voltage to be measured "1" see the bullet at Ins..read_nod..
See also
The instruction instr_ADC_LETTURA.

The instruction instr_offset_trimmer_calibration


Every time the fine or the coarse trimmers for offset adjustment are varied by one or more steps, the output voltage changes by a proper amount. This amount is known by design but, due to accuracy limits, it can be slisgltly different from channel to channel. In addition, it could be totally wrong if fails are present. With this function the calibration values are determined and stored in the EPROM. These calibration values are feedbacked in response to the instruction once evaluated so that it is possible to verify their accuarcy.
The first 2 bytes passed with the instruction, in input, are the integer slope expected for fine trimmer, the following 2 bytes are those for coarse trimmer. The conversion value for the fine slope is 1 V to 106 µV, while that for coarse slope is 1 V to 105 (*10)µV
In output the 2 couples of bytes are the measured values. If the results differ from the input by more than about 15% a "0" is set in the output Byte5 in the corresponding position and the input value is stored in the EPROM.
The slope can be measured for both fine and coarse, fine only or coarse only. In case the either of the fine or coarse slopes are determined the other is returned as 0.
It is suggested to disconnect the detector during this operation.
The value to output at the lower PGA gain for CROSS, for the lower series noise version of the preamplifier, are 1.97 mV/step for fine slope and 242,6 mV/step for coarse slope.

I/O CAN bus 8 bytes instruction messsage for instr_offset_trimmer_calibration
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr LSB fine target MSB fine targetLSB coarse target MSB coarse target 1=node voltages read from external ADC
0=node voltage read from on board ADC;
Bit2 to bit7: ADC number of averaged measurements in case of internal ADC (max 127 averages)
01=fine, 10=coarse, 11=both The channels to which the gain is applied and the board bit selection, see below. see the bullet at instr_offset_trimmer_calibration
output ans LSB fine calibration result, if asked MSB fine calibration result, if asked coarse LSB coarse calibration result, if askedd
MSB coarse calibration result, if askedd 0 The replay of Byte5 above for positive results,
4= starting voltage outside limits,
0=slope outside tolerance, the default is used.
same as Byte6 above see the bullet at Ins..off..tri..


Byte6 of Ins..off..tri..:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channel to which the calibration is done is that having the lower value among the ORed, see example below;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: if the calibration is being applied to channle 3 of upper board, then Bit6 should be: Ch3 | x | x | board_up, where x must be > Ch3. The suggestion is to set to "1" only the bit of the channel to calibrate.

See also
An inside of the fw for trimmer slope determination is here: Preamplifier slope characterization.
                   In costruzione inizio

The instruction instr_DetBias_trimmer_calibration


Every time the fine or the coarse trimmers for detector bias are varied by one or more steps, the detector bias changes by a proper amount. This amount is known by design but, due to expected spread of load resistors, it can be slisgltly different from channel to channel. In addition, it could be totally wrong if fails are present. With this function the calibration values are determined and stored in the EPROM. These calibration values are feedbacked in response to the instruction once evaluated so that it is possible to verify their accuarcy.
The first 4 bytes passed with the instruction, in input, are the integer slope expected for both positive and negative trimmer: they are expected similar. The conversion value for the fine slope is 1 V to 106 µV.
In output the first 2 couples of bytes are the measured values. Byte5 is the multiplication conversion number to convert the 2 byte in µV. If the results differ from the input by more than about 15% a "0" is set in the output Byte5 in the corresponding position and the nominal value value is stored in the EPROM.
Since it is exepcted a tolerance of about 10% in the absolute values of the load resistors and their refernces, the slopes are misured for the positive and negative bias and are stored in independent memory locations.
The slopes can be measured in pair for positive and negative fine and positive and negative coarse.
It is suggested to disconnect the detector during this operation.
The value to output at the lower PGA gain for CROSS, for the lower series noise version of the preamplifier, are 260.4 mV/step for fine slope and 2.96 mV/step for coarse slope.

I/O CAN bus 8 bytes instruction messsage for instr_offset_trimmer_calibration
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr LSB target byte, first target byte (*) second target bute (*)third target byte (*) MSB target byte (*)1=node voltages read from external ADC
0=node voltage read from on board ADC;
Bit2 to bit7: ADC number of averaged measurements in case of internal ADC (max 127 averages)
01=fine, 10=coarse The channels to which the gain is applied and the board bit selection, see below. see the bullet at Ins..DetBi_cal..
output ans LSB positive calibration result MSB positive calibration result LSB negative calibration result
MSB negative calibration result Multiplication factor, 1 or 10, for each pair of bytes on the left to obatin the result in µV
The replay of Byte5 above for positive results,
3= positive slope outside limits,
4=negative slope outside limits.
If 3 or 4 the default is stored but the switch memory is not upgraded.
Except in case of errors, see below.
same as Byte6 above see the bullet at Ins..DetBi_cal..


(*): If these 4 bytes are passed 0 then the tolerance about the measured slope is not performed.


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.
Byte6 of Table_instr_offset_trimmer_calibration:
Setting Ch0=1, Ch1=2, Ch2=4, Ch3=8, Ch4=16 and Ch5=32, then the channel to which the calibration is done is that having the lower value among the ORed, see example below;
Bit7: 1 » : the upper board is considered, set it board_up=1<<7; 0 » : the lower board is considered.
Example: if the calibration is being applied to channle 3 of upper board, then Bit6 should be: Ch3 | x | x | board_up, where x must be > Ch3. The suggestion is to set to "1" only the bit of the channel to calibrate.

See also
An inside of the fw for trimmer slope determination is here: Preamplifier slope characterization.
                   In costruzione end

The instruction instr_EPROM_read_write


There is one EPROM in every preamplifier, an EPROM on the mainboard and 2 EPROM's on the post mainboard. Here the way to read from or write to each of them.
There are several loactions in which system parameters are stored that should not be written. Links to these locations are given below.

I/O CAN bus 8 bytes instruction messsage for instr_EPROM_read_write
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr LSB address (see below) MSB address (see below)EPROM first byte to W EPROM second byte to W EPROM third byte to WEPROM fourth byte to W W/R, which EPROM, board up or down, Preamplifier Channel, according to the rules below. see the bullet at Ins..EPR..R/W..
output ans LSB address MSB address EPROM first byte
EPROM second byte EPROM third byteEPROM fourth byte, except in case of errors, see below. same as Byte6 above see the bullet at Ins..EPR..R/W..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa and Byte0 is set to 0xff or 255 if Byte0 on instruction is different from

Byte6 on instruction :

  • Bit0 to Bit2: the preamplifier channel: 0, 1, 2,... in case the preamplifier EPROM is that to select;
  • Bit3 to Bit4: 0=preamplifier EPROM, 1=mainboard EPROM, 2=post frontend EPROM;
  • Bit5: 1=write to the 4 bytes starting from address at Byte0 and Byte1, the 4 values from Byte2 to Byte5;
  • Bit6: x;
  • Bit7:1=upper board, 0=lower board, only for preamplifier and mainboard.

Example: If we want to read from the channel 4 of the upper board of the preamplifier we must set at Bit6: (1<<7)|(2<<0).


Memory address syntax : To each memory location are dedicated 4 bytes, an uint32_t. To determine address of the memory location of interest consider the list below, the bullet numbers should be multiplied by 4 for determining the actual address. This is not necessary in the instruction since it is done by fw. As an example, if we want to read/write from/in the Memory_preamplifier_address_coarse_trimmer_slope_offset we must write 3 in the adddresses bytes of Table_instr_EPROM_read_write , Byte0 and Byte1 of the isntruction.


The Memory addresses table for preamplifiers is at Preamplifier EPROM location list.
The Memory addresses table for mainboard is at Mainboard EPROM location list.
The Memory addresses table for post-mainboard is at Post-mainboard EPROM location list.
Note that the last definition in the enums marks the number of system locations used and the first free addrres.


The instruction instr_connect_disconnect_mux_node



This is an atomic function. It is possible to route one of the analog nodes connected to the anlog mux to the respectively ouput. Do not forget: this function must be run 2 times. the first is to connect the node, the second to disconnect the node.

Note
This instruction will become obsolete at the time of installation.
I/O CAN bus 8 bytes instruction messsage for instr_connect_disconnect_mux_node
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x x x x 1= selected node is from board up;
0= selected node is from board down
Readable nodes are at Mux Nodes list. 0: disconnect the node,
1: connect the node
see the bullet at Ins..mux..nod..
output ans 0 0 0 0 0 The node voltage connected, 0 if no node is connected, except in case of errors, see below. Same as Byte6 above see the bullet at Ins..mux..nod..


Byte5 on answer : In case of errors it is set to the value of 255, or 0xff if the corresponding instruction byte is different from 0xff, otherwise it is set to 250 or 0xfa.

See also
The instruction instr_ADC_LETTURA, instr_ADC_LETTURA.

The instruction instr_LED_ON_OFF


This function allows to set ON or OFF the RED and/or the GREEN LEDs. It is an useful function to test the LED operation during the test phase and it is usefull for checking the operation of the board with the CAN bus commands. For verification of the address of the board, as an instance.

Remarks
Take care that the setting is applied if Byte5 is 1, otherwise it is the hw that controlls the LEDs. This means that this instruction must be run 2 times: for taking control of the LEDs and to return the control to the hw.
I/O CAN bus 8 bytes instruction messsage for instr_LED_ON_OFF
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x xx x x 1: LEDs are controlled as defined at Byte6;
0: LEDs are controlled by hw, in default mode
Bit0=1 : RED LED is ON;
Bit0=0: RED LED is OFF;
Bit1=1: GREEN LED is ON;
Bit1=0: GREEN LED is OFF
see the bullet at instr_LED_ON_OFF
output ans 0 0 0 0 0
Same as command Byte5 LEDs state see the bullet at instr_LED_ON_OFF

The instruction instr_periferal_reset


This function allows to reset the communication periephrals, CAN bus, I2C (both I2C0 and I2C1) and SPI. The operation can be made in parallel with a single call.

I/O CAN bus 8 bytes instruction messsage for instr_periferal_reset
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
input instr x xx x x x Bit0=1 : CAN bus is reset;
Bit1=1: both I2C are reset;
Bit2=1: SPI is reset
see below
see the bullet at instr_periferal_reset
output ans 0 0 0 0 0
0 same as Byte6 of isnctruction see the bullet at instr_periferal_reset

Byte6: the reset can be made in parallel by OR-ing. Example for CAN bus + SPI reset: binary is 101, or 0x05.