Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: cosmetic

...

See the definitions of encoder_header_t and encoder_channel_t in github: UdpEncoder.hh

Zach writes:

...we’re currently taking the PLC’s internal encoder numerator, which is a floating point number less than zero, multiplying it by 10^6, and sending it as an integer. So, the “unit” of the output is baked into the protocol.

Data Format 2.0.

...

0

Version 2.0.0 of encoder_channel_t adds a uint16_t field 'scaleDenom.' If nonzero, it is the denominator of a rational scale value.

'encoderValue' (shape: 1):  23563414
'timing' (shape: 1):  505870
'scale' (shape: 1):  1
'scaleDenom' (shape: 1): 1500150
'mode' (shape: 1):  0
'error' (shape: 1):  0
'majorVersion' (shape: 1):  2
'minorVersion' (shape: 1):  0
'microVersion' (shape: 1):  0

See the definitions of encoder_header_t and encoder_channel_t in github: UdpEncoder.hh

Zach writes:

...if the denominator is used, we do no pre or post multiplication of the values. If I need to express something like numerator = 1.16 and denominator = 5.0, I would send 116 and 500 which maintains the same ratio as the original.

In the specific case of this encoder, I send 1 and 150 exactly and your code on the other side simply doesn’t do the *1e-6 step because a denominator is present.


Along with the introduction of data format 2.0.0,  encoder detector version was updated to 2.0.0 as well.  Here is the first run to be recorded with version 2.0.0:


Code Block
languagetext
titledetnames -r
$ detnames -r /cds/data/psdm/rix/rixlx9720/xtc/rixlx9720-r0263-s000-c000.xtc2
----------------------------------------------
Name         | Det Type  | Data Type | Version
----------------------------------------------
chunkinfo    | chunkinfo | chunkinfo | 0_0_1  
runinfo      | runinfo   | runinfo   | 0_0_1  
mono_encoder | encoder   | raw       | 2_0

...

_0  
----------------------------------------------

Testing With Encoder Simulator (sim_udpencoder)

To test with the simulator, run sim_udpencoder on the same host as drp_udpencoder and use the matching "-p <partition>" setting.  The simulator sends packets to drp_udpencoder via localhost (127.0.0.1).

Code Block
languagetext
titlesim_udpencoder usage
$ sim_udpencoder -h
Usage: sim_udpencoder [options]
Options: -r <rate> (0:929kHz,1:71kHz,..)
         -e <evcode>
         -p <partition>
         -d <data port>  (default 5006)
         -v (verbose)
Either -r or -e or -p is required

Send SIGUSR1 to the sim_udpencoder process to simulate a dropped UDP packet.

$ kill -USR1 pid

Send SIGUSR2 to the sim_udpencoder process to simulate 4 consecutive dropped UDP packets.

$ kill -USR2 pid

Testing With Loopback Mode (drp_udpencoder -L <loopback_port>) 

Configuring TPR On

Configuring the Timing System

...

DAQ Partition

Code Block
languagetext
titletprtrig
You can get tprtrig to trigger the EVR on a DAQ partition, then sleep, like so:
    $ tprtrig -t a -c 0 -o 1 -d 2 -w 10 -p 4 -z
programs EVR /dev/tpra (-t a) to generate a TTL trigger using logic channel 0 (-c 0) on output 0 (-o 1 [bit mask]) with delay of 2 119MHz clocks (-d 2) and width 10 119 MHz clocks (-w 10) for every L1Accept on partition 4 (-p 4). 

Configuring TPR Standalone

Code Block
languagetext
titletprtrig
Generate 1Hz triggers on output 0 with a width of 54 nanoseconds, then sleep.

    $ tprtrig -t a -c 0 -o 1 -d 1 -w 10 -r 6 -z

...

Loopback Mode

In loopback mode no encoder or PLC or added process is required, as the DRP drp_udpencoder sends and receives simulated data via localhost.

...

Code Block
languagetext
titlextcreader output
$ xtcreader -d -w 1 -f /cds/data/psdm/rix/rixdaq18/xtc/rixdaq18-r0027-s000-c000.xtc2 | grep shape | head -16

'encoderValue' (shape: 1):  23563414
'timing' (shape: 1):  505870
'scale' (shape: 1):  6667
'mode' (shape: 1):  0
'error' (shape: 1):  0
'majorVersion' (shape: 1):  1
'minorVersion' (shape: 1):  0
'microVersion' (shape: 1):  0

'encoderValue' (shape: 1):  23563404
'timing' (shape: 1):  838450
'scale' (shape: 1):  6667
'mode' (shape: 1):  0
'error' (shape: 1):  0
'majorVersion' (shape: 1):  1
'minorVersion' (shape: 1):  0
'microVersion' (shape: 1):  0

Recording Experiment rixlx9720 Run 262

This was the first recording of the encoder using interface version 2.0.0.

Code Block
languagetext
titlextcreader output
$ xtcreader -d -w 1 -f /cds/data/psdm/rix/rixlx9720/xtc/rixlx9720-r0262-s000-c000.xtc2 | grep shape | head -18
'encoderValue' (shape: 1):  23808197
'timing' (shape: 1):  772470
'scale' (shape: 1):  1
'scaleDenom' (shape: 1):  150
'mode' (shape: 1):  0
'error' (shape: 1):  0
'majorVersion' (shape: 1):  2
'minorVersion' (shape: 1):  0
'microVersion' (shape: 1):  0

'encoderValue' (shape: 1):  23808214
'timing' (shape: 1):  300
'scale' (shape: 1):  1
'scaleDenom' (shape: 1):  150
'mode' (shape: 1):  0
'error' (shape: 1):  0
'majorVersion' (shape: 1):  2
'minorVersion' (shape: 1):  0
'microVersion' (shape: 1):  0


Viewing Encoder Value in AMI

Run Encoder Sim on Remote Host

Earlier (2022) the sim was limited to localhost.


Code Block
languagetext
titleListen on drp-tst-acc01
-bash-4.2$ hostname
drp-tst-acc01
-bash-4.2$ nc  -lvu 172.21.148.201 5006
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Listening on 172.21.148.201:5006
Ncat: Connection from 172.21.148.110.
sim_updencodersim_updencodersim_updencodersim_updencodersim_updencoder
Code Block
languagetext
titleSend from daq-tst-dev03
(ps-4.5.26) -bash-4.2$ hostname
daq-tst-dev03.pcdsn
(ps-4.5.26) -bash-4.2$ sim_udpencoder -r 0 -a 172.21.148.201 | head -4
 Version          PulseID        TimeStamp  Markers  BeamReq          BsaInit         BsaActiv          BsaAvgD          BsaDone
   10000       374b0fc41f    3e4f023b73138    10040        0                0                0                0                0 
   10000       374b0fc420    3e4f023b7356d    10040        0                0                0                0                0 
   10000       374b0fc421    3e4f023b739a2    10040        0                0                0                0                0