# Power box scripts ## notes from testing ### noise problems When testing in the counting house, the I2C link was pretty noisy. This is probably going to be just as bad in the hall, possibly worse. Because of details of the I2C isolator on the control boards and the level shifting at the Pi, the noise margin is much smaller for signals coming back from the control board (I2C reads and ack signals) than for signals going to the control board (I2C writes). In other words, voltage settings are relatively reliable unless the ACK gets lost (and then all you need to do is retry the write, which the scripts do automatically). Reads from the ADC are pretty noisy and you will often see a bit get flipped. ## setup on Raspberry Pi setup from scratch (Raspbian): apt-get install screen git krb5-user vim raspi-config: disable predictable network interface names edit /etc/dhcpcd.conf to set static IP apt-get install python-smbus python-numpy add to /boot/config.txt: dtoverlay=i2c-gpio,i2c_gpio_sda=2,i2c_gpio_scl=3 git clone https://github.com/meeg/DPDaq ## configuration The `config.json` file stores the list of power boxes and the paths to the mapping and calibration files. In normal use, you should only ever have to change the list of power boxes. ### power boxes This is a list of the power boxes that are connected to this Raspberry Pi. The boxes are identified by the mux address, where box #1 has address 0x70, box #2 has address 0x71, etc. ### calibration This is the path to the calibration file. This file is in CSV format, and is an exact copy of the Excel spreadsheet Sergey sent us with the boards. The Excel spreadsheet is also in the same directory. ### mapping This is the path to the mapping file. This file is in CSV format, and is an exact copy of the Google spreadsheet "dark photon channel mapping" that was used for tracking the SiPM serial numbers (ask Sho or Kun for a link). ## usage All scripts can be run with the `-h` option to show command-line options. * power_on.py: turn on the output voltages * power_off.py: turn off the output voltages * read_power.py: read the ADC inputs (input voltages, output currents) * readback_vmon.py: read the DAC outputs through the DAC's voltage monitor