init this repo

This commit is contained in:
2020-10-12 15:38:02 -05:00
commit 6c332e722a
76 changed files with 1114 additions and 0 deletions

1
pages/work/alcap.txt Normal file
View File

@@ -0,0 +1 @@
AlCap experiment notes

View File

@@ -0,0 +1,141 @@
This note describe how I set up the Cocalc server on ''mu2e.bu.edu'' machine
====== Docker services ======
===== Linuxserver swag =====
This service takes care of Let's Encrypt certificate issuance and renewal. Be careful though, do not delete/recreate this service too often because there is a rate limit of 5 certs per week.
* ports ''80'', ''443'', and ''8443'' are exposed. The first two are needed for the certificates, the ''8443'' is for the Cocalc service
* nice thing about ''linuxserver'' dockers are graceful handling of ''uid'' and ''gid''
* asking for certificate for ''mu2e.bu.edu'' only. Cocalc doesn't appear to work nicely with a subfolder path. And subdomain doesn't appear to work on this box (maybe net admin at BU must add/allow subdomain?).
<code yaml>
swag:
image: linuxserver/swag
container_name: swag
cap_add:
- NET_ADMIN
environment:
- PUID=1004
- PGID=1004
- TZ=America/New_York
- URL=mu2e.bu.edu
- VALIDATION=http
- ONLY_SUBDOMAINS=false #optional
- STAGING=false
volumes:
- ./swag-config:/config
ports:
- 443:443
- 80:80 #optional
- 0.0.0.0:8443:8443
restart: unless-stopped
networks:
- cocalc
</code>
===== Cocalc service =====
Copied from Cocalc documentation, nothing much to say here.
<code yaml>
cocalc:
image: sagemathinc/cocalc
container_name: cocalc
volumes:
- ./cocalc-data:/projects
# ports:
# - 0.0.0.0:8752:443
restart: unless-stopped
networks:
- cocalc
</code>
====== Further configuration ======
===== Reverse proxy for Cocalc =====
The proxy is configured in ''swag'' by adding a server on port ''8443'' which is forwarded to ''cocalc:443''.
<code nginx>
(base) @mu2e:cocalc-docker nam $ cat swag-config/nginx/proxy-confs/cocalc.subdomain.conf
server {
listen 8443 ssl;
listen [::]:8443 ssl;
index index.html index.htm index.php;
server_name mu2e.bu.edu;
# all ssl related config moved to ssl.conf
include /config/nginx/ssl.conf;
client_max_body_size 50;
server_tokens off;
location / {
proxy_pass https://cocalc:443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3m;
proxy_send_timeout 3m;
}
}
</code>
===== Spin it up! =====
Run ''docker-compose up -d''
===== Configure user on Cocalc =====
* self-register on first launch
* launch an interactive shell within running ''cocalc'' container,
* generate SSH pubkey and add to Github
* create ''.gitconfig''
<code bash>
~$ cat .gitconfig
[user]
name = Nam Tran
email = thnam.me@gmail.com
[core]
editor = vim
quotepath = false
autocrlf = input
excludesfile = /projects/0223d4fc-683f-424a-8bdf-8d867a4ac9c9/.gitexcludes
[merge]
tool = opendiff
conflictstyle = diff3
[alias]
ci = commit
co = checkout
st = status
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
type = cat-file -t
dump = cat-file -p
ignored = !git ls-files -v | grep ^[[:lower:]]
[color]
ui = true
[push]
default = tracking
[branch]
autosetupmerge = true
</code>
===== Prepare Latex code =====
* Pull the source ''~$ git clone git@github.com:bostonu-cas/r15a_xray.git''
* Install Revtex v4.2 <code bash>
~$ mkdir texmf
~$ cd texmf/
~$ wget https://journals.aps.org/revtex/revtex4-2-tds.zip
~$ unzip revtex4-2-tds.zip
</code>
* Go to the source directory, Cocalc automatically runs ''latexmk'' to compile
===== Syncing =====
* Automatic pull <code bash>
~$ mkdir utils && cd utils && git clone https://github.com/kolbasa/git-repo-watcher
# Add PATH, then run in a latex terminal
~/r15a_xray$ git-repo-watcher -d . -i 60 > /dev/null 2>&1 &
</code>
* Auto commit and push
* prepare script and add to ''PATH'' <code bash>
~$ cat utils/git-auto-commit
#!/usr/bin/env bash
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
git pull && git ci -am "auto-commit from mu2e.bu.edu:8443" && git push
</code>
* edit compile command to: ''latexmk -pdf ... xray.tex && ~/utils/git-auto-commit''

2
pages/work/gm2.txt Normal file
View File

@@ -0,0 +1,2 @@
G-2 related notes
* [[work:gm2:esq|ESQ]]

3
pages/work/gm2/esq.txt Normal file
View File

@@ -0,0 +1,3 @@
Electrostatic quadrupole
* [[work:gm2:esq:bu_controller|BU controller]]
* [[work:gm2:esq:bu_controller:compiling_on_opt|Test compiling on opt]]

View File

@@ -0,0 +1 @@
{{indexmenu>work:gm2:esq:bu_controller}}

View File

@@ -0,0 +1,51 @@
====== Hardware ======
===== Overview =====
The box's job is to emit TTL pulses to control 4 HV pulsers, and stop doing so when a trouble is detected.
===== Block diagram and photo =====
{{work:gm2:esq:bu_controller:bu_controller_block_diagram.png?800x0}}
===== Carrier board =====
The carrier board has a PicoZed System-On-Module (SOM), which contains:
* a XC7Z020 System-on-Chip (one dual core ARM processor, and one Artix-7 FPGA)
* 1 GB of DDR3 SDRAM
* 16 GB eMMC memory
* Ethernet interface
* UART interface
This board serves as a bridge between user and programmable logic parts (ADC boards) of the controller.
There is a Linux system (Xilin Petalinux 2015.4) installed:
* user: ''root''
* password: ''root''
* static IP address: ''192.168.30.89''
===== ADC boards =====
There are 4 identical ADC boards in the box, each has one pulser and one 8-channel waveform digitizer.
{{work:gm2:esq:bu_controller:bu_controller_front_panel.png?800x0}}
==== Pulser ====
{{work:gm2:esq:bu_controller:io_numbering.png?600x0}}
Each pulser has 8 SMA outputs, numbered from 1 to 8 from left to right:
* outputs 1-4: RF control outputs
* output 5: discharge signal
* output 6: charge signal, first step
* output 7: charge signal, second step for two-step HV cabinets. Not used in case of 1-step pulser.
* outputs 8: spare I/O
Pulse modes are:
- External trigger: produces a set of pulse after receiving a LVTTL (3.3 V) logic pulse at the external trigger input. The trigger pulse width should not exceed 50 ns.
- Internal trigger: produces sets of pulses periodically, up to 100 Hz
==== WFD ====
These are 12-bit WFDs, run at 100 MSPS. Clock source can be either an external 40 MHz clock, or internal clock generated by the carrier board.
The WFD inputs are numbered from 1 to 8 from left to right, similar to the pulser numbering above. These inputs have protection against surges might happen during a spark.
The WFDs provide several pieces of information:
* waveforms: all channels are in zero-suppressed mode, which will only export samples above programmed individual threshold. The maximum sampling length is 100 us (the current firmware can only give 20 us)
* spark threshold (not the waveform threshold above) crossings: there are upper and lower thersholds for each channel, the threshold crossing counting is active for the whole g-2 muon fill (~700 us)
* waveform integrals at charge and discharge times: the integration starts at charge and discharge steps, maximum integration length is 256 samples (~2.5 us)
Each WFD will produce one block of data for one trigger, the data format is described here: https://docs.google.com/spreadsheets/d/19r_blWufX368hKRkoa1FGhIzBLOzIvKfg5ZKRVmEVkI/edit?usp=sharing. The data is written to RAM on the carrier board, and can be accessed via a DMA controller.
====== Firmware ======
====== Software ======

View File

@@ -0,0 +1,6 @@
* Board 3 could not be initialized
* Skipping every other pulse (yellow) in the 8 pulses train (teal)
{{work:gm2:esq:bu_controller:pxl_20201007_202452451.jpg?400x0}}
* Switching back to ''2019-12-13'' version fixed both of them
{{work:gm2:esq:bu_controller:pxl_20201007_210215108.jpg?400x0}}

View File

@@ -0,0 +1,48 @@
====== First test ======
* It seems the issue of board initialization is still there, but moves to board 4 ...
* Still shows only 4 out of 8 pulses in a train
* will try with different triggers
<code bash>
daq@gm2-01:scripts $ BUTool -q 192.168.30.89
Registered device: G2QUAD
>write TRIGGER.STATUS.ENABLE_PULSERS 1
Write to register TRIGGER.STATUS.ENABLE_PULSERS
>write TRIGGER.FREE_RUN.EN_FR_TRIG 0
Write to register TRIGGER.FREE_RUN.EN_FR_TRIG
>write TRIGGER.FREE_RUN.EN_EXT_TRIG 1
Write to register TRIGGER.FREE_RUN.EN_EXT_TRIG
>read SYSTEM.SYNTH_DATE
SYSTEM.SYNTH_DATE: 0x20201008
>read ADCBOARD.1.*SYNTH_DATE
ADCBOARD.1.SYSTEM.SYNTH_DATE: 0x20201005
>read ADCBOARD.2.*SYNTH_DATE
ADCBOARD.2.SYSTEM.SYNTH_DATE: 0x20201005
>read ADCBOARD.3.*SYNTH_DATE
ADCBOARD.3.SYSTEM.SYNTH_DATE: 0x20201005
</code>
====== Trigger from a waveform generator ======
* The function generator is programmed to output a burst of 8 pulses: 3 Vpp, 1.5 V offset, 10 ms separation every 1.4 s. Pulse width is adjustable. This WG has minimum 6 ns rise time and fall time.
{{work:gm2:esq:bu_controller:pxl_20201008_190541385.jpg?600x0}}
* Output 1 & 2 are in-sync
{{work:gm2:esq:bu_controller:pxl_20201008_190526636.jpg?600x0}}
* Output 1 is kept on channel 1 of the scope, output 2 goes to the ext. trigger input of the BU controller
====== Tweaking trigger pulse length ======
Channel 1 on scope is the synced signal of ext trigger, channel 2 is discharge pulse from ADC board 1.
* < 50 ns, still shows only 4 pulses. All pulses from 12 ns to 50 ns worked.
{{work:gm2:esq:bu_controller:pxl_20201008_191532389.jpg}}
{{work:gm2:esq:bu_controller:pxl_20201008_191547871.jpg}}
{{work:gm2:esq:bu_controller:pxl_20201008_191643263.jpg}}
{{work:gm2:esq:bu_controller:pxl_20201008_191710289.jpg}}
{{work:gm2:esq:bu_controller:pxl_20201008_191730525.jpg}}
* 54 ns, picking up random pulses among 8, but never 2 consecutive ones
{{work:gm2:esq:bu_controller:pxl_20201008_191758570.jpg}}
{{work:gm2:esq:bu_controller:pxl_20201008_191806670.jpg}}
{{work:gm2:esq:bu_controller:pxl_20201008_191757168.jpg}}
* 56 ns, still can pick up pulses
{{work:gm2:esq:bu_controller:pxl_20201008_191818632.jpg}}
{{work:gm2:esq:bu_controller:pxl_20201008_191821833.jpg}}
* 60 ns, no trigger picked up at all
===== Different pulse separation =====
Still only 4 pulses, there seems to be some change in phase.
{{work:gm2:esq:bu_controller:pxl_20201008_195535792.jpg}}{{work:gm2:esq:bu_controller:pxl_20201008_195613934.jpg}}{{work:gm2:esq:bu_controller:pxl_20201008_195009724.jpg}}{{work:gm2:esq:bu_controller:pxl_20201008_194714818.jpg}}

View File

@@ -0,0 +1,40 @@
====== Prepare code ======
===== Zynq software =====
<code bash>
daq@gm2-01:ESQ $ svn co http://gauss.bu.edu/svn/g2-quad-pulser.firmware/carrier zynq-carrier.trunk.svn
...
Checked out revision 548.
daq@gm2-01:zynq-carrier.trunk.svn $ svn log | head
------------------------------------------------------------------------
r548 | dgastler | 2020-10-05 15:11:09 -0500 (Mon, 05 Oct 2020) | 1 line
New version for Nam
------------------------------------------------------------------------
r546 | dgastler | 2020-10-05 07:52:45 -0500 (Mon, 05 Oct 2020) | 1 line
updated address tables
------------------------------------------------------------------------
r545 | dgastler | 2020-10-05 07:17:03 -0500 (Mon, 05 Oct 2020) | 1 line
</code>
===== Copy old BUTool over =====
<code bash>
daq@gm2-01:zynq-carrier.trunk.svn $ cp -r ~/ESQ/zynq-carrier.trunk/os/software/BUTool ./os/software/
</code>
====== Build ======
===== BUTool =====
Clean up old code, regenerate ''env.sh'', then ''make'' again
<code bash>
daq@gm2-01:BUTool $ export PLATFORM=petalinux
daq@gm2-01:BUTool $ ./setup.sh
env.sh
Source env.sh and run 'make' to build BUTool
daq@gm2-01:BUTool $ make clean
daq@gm2-01:BUTool $ make -j4 && make install
</code>
===== Zynq software =====
Edit the ''buildArm.sh'' a little bit (skip building BUTool since it is done in previous step)
<code bash>
daq@gm2-01:software $ ./buildArm.sh
</code>

View File

@@ -0,0 +1,137 @@
====== Check out codes ======
===== Zynq software =====
<code bash>
nam@opt:ESQ $ svn co http://gauss.bu.edu/svn/g2-quad-pulser.firmware
nam@opt:ESQ $ mv g2-quad-pulser.firmware g2-quad-pulser.firmware.svn
nam@opt:g2-quad-pulser.firmware.svn $ cd carrier/trunk/os/software/
</code>
Make sure this is the latest version (as of 2020/10/05):
<code>
nam@opt:software $ svn info
Path: .
Working Copy Root Path: /home/nam/work/gm2/ESQ/g2-quad-pulser.firmware.svn
URL: http://gauss.bu.edu/svn/g2-quad-pulser.firmware/carrier/trunk/os/software
Relative URL: ^/carrier/trunk/os/software
Repository Root: http://gauss.bu.edu/svn/g2-quad-pulser.firmware
Repository UUID: 7ce3f3ac-83d5-4068-a32b-ab773f4188fc
Revision: 548
Node Kind: directory
Schedule: normal
Last Changed Author: dgastler
Last Changed Rev: 546
Last Changed Date: 2020-10-05 07:52:45 -0500 (Mon, 05 Oct 2020)
</code>
===== BUTool =====
<code bash>
nam@opt:software $ svn co http://gauss.bu.edu/svn/butool/trunk BUTool
nam@opt:BUTool $ svn info
...
Last Changed Rev: 70
Last Changed Date: 2019-09-17 10:35:07 -0500 (Tue, 17 Sep 2019)
</code>
Need to revert to ''r42'' which is compatible with Petalinux 2015.4
<code bash>
nam@opt:BUTool $ svn up -r42
nam@opt:BUTool $ svn info
Path: .
Working Copy Root Path: /home/nam/work/gm2/ESQ/g2-quad-pulser.firmware.svn/carrier/trunk/os/software/BUTool
URL: http://gauss.bu.edu/svn/butool/trunk
...
Last Changed Rev: 42
Last Changed Date: 2018-07-12 15:56:11 -0500 (Thu, 12 Jul 2018)
</code>
====== Build ======
===== BUTool =====
Run ''setup.sh'' to generate ''env.sh'' where all environment variables would be set. Also change the path to Petalinux to match the local installation.
<code bash>
nam@opt:BUTool $ PLATFORM=petalinux ./setup.sh
env.sh
Source env.sh and run 'make' to build BUTool
nam@opt:BUTool $ cat env.sh
if [[ $_ == $0 ]]; then
echo "$0 is meant to be sourced:"
echo " source $0"
exit 0
fi
export PLATFORM="petalinux"
export PREFIX="/work/butool"
export MAKEFLAGS="-I /home/nam/work/gm2/ESQ/g2-quad-pulser.firmware.svn/carrier/trunk/os/software/BUTool/mk"
export PROJECT_ROOT="/home/nam/work/gm2/ESQ/g2-quad-pulser.firmware.svn/carrier/trunk/os/software/BUTool"
export PATH="$PATH:/work/butool/bin"
export VIVADO_VERSION=2015.4
export VIVADO_SDK=/home/nam/Downloads/petalinux-v2015.4-final/settings.sh
source $VIVADO_SDK
export CXX=arm-xilinx-linux-gnueabi-g++
export CC=arm-xilinx-linux-gnueabi-gcc
export CROSS_HOST=arm-xilinx-linux-gnueabi
export MAKEOBJDIRPREFIX="$PROJECT_ROOT/obj"
export DESTDIR="$PROJECT_ROOT/install"
export BUTOOL_COMPILETIME_PATH="$DESTDIR/$PREFIX"
export BUTOOL_RUNTIME_PATH="$PREFIX"
</code>
Source ''env.sh'' and ''make'':
<code bash>
nam@opt:BUTool $ . env.sh
nam@opt:BUTool $ make
...
CXX (link) -o obj/lib/libBUTool.so
CXX src/tool/BUTool.cxx
CXX (link) -o obj/bin/BUTool
</code>
===== Zynq software =====
<code bash>
nam@opt:BUTool $ cd ../
nam@opt:software $ ./buildArm.sh
</code>
Need to change a few things
<code bash>
nam@opt:software $ svn diff
Index: buildArm.sh
===================================================================
--- buildArm.sh (revision 548)
+++ buildArm.sh (working copy)
@@ -15,7 +15,7 @@
export PLATFORM=petalinux
cd BUTool
-./setup.sh
+#./setup.sh
source env.sh
make clean
make
Index: zynq_daq/Makefile
===================================================================
--- zynq_daq/Makefile (revision 548)
+++ zynq_daq/Makefile (working copy)
@@ -1,6 +1,9 @@
+SHELL := /bin/bash
VIVADO_VERSION=2015.4
#VIVADO_VERSION=2017.2
VIVADO_SDK="/opt/Xilinx/SDK/"${VIVADO_VERSION}"/settings64.sh"
+VIVADO_SDK=/home/nam/Downloads/petalinux-v2015.4-final/settings.sh
+
CXX=source ${VIVADO_SDK} && arm-xilinx-linux-gnueabi-g++
#CXXFLAGS+=-c -g -O2 -Wall -Wextra -Werror -Wno-pointer-arith -I ./ -I ${G2FRAME_PREFIX}/include
Index: zynq_pl_bridge/Makefile
===================================================================
--- zynq_pl_bridge/Makefile (revision 548)
+++ zynq_pl_bridge/Makefile (working copy)
@@ -1,6 +1,7 @@
VIVADO_VERSION=2015.4
VIVADO_SDK="/opt/Xilinx/SDK/"$(VIVADO_VERSION)"/settings64.sh"
+VIVADO_SDK=/home/nam/Downloads/petalinux-v2015.4-final/settings.sh
CXX=source $(VIVADO_SDK) && arm-xilinx-linux-gnueabi-g++
CXXFLAGS+=-c -O2 -static -Wall -Wextra -Werror -Wno-pointer-arith
</code>

View File

@@ -0,0 +1,3 @@
- log-01: before
- log-02: after
- log-03: another pulse