You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 37 Next »

Overview

Data Format 1.0.0

At each trigger, the UDP Encoder sends one header structure followed by up to eight channel structures.

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): 150
'mode' (shape: 1):  0
'error' (shape: 1):  0
'majorVersion' (shape: 1):  2
'minorVersion' (shape: 1):  0
'microVersion' (shape: 1):  0

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.

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).

sim_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_udpecoder process to simulate a dropped UDP packet.

$ kill -USR1 pid

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

$ kill -USR2 pid

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

Configuring TPR On DAQ Partition

tprtrig
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

tprtrig
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 drp_udpencoder sends and receives simulated data via localhost.

Run drp_udpencoder with the -L <loopback_port> flag to enable loopback mode.  For example, "-L 5007" loops back on localhost port 5007.

Monitoring UDP packets with netcat

-bash-4.2$ hostname
drp-neh-cmp015

-bash-4.2$ nc -lvu 192.168.0.8 5006
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Listening on 192.168.0.8:5006
Ncat: Connection from 192.168.0.3.
'plc-tst-proto6w?
                 ?bdSimEncoder
(plc-tst-proto6Q?
                 ?zdSimEncoder
)plc-tst-proto6+g
                 ??dSimEncoder
*plc-tst-proto6
               ??dSimEncoder
+plc-tst-proto6
               ??dSimEncoder^C
-bash-4.2$

Updates to rix.cnf file

$ diff rix.cnf rix.cnf.ENCODER 
67a68,69
>  { host: 'drp-neh-ctl002', id:'tprtrig',     flags:'sp',             cmd:'tprtrig -t a -c 0 -o 1 -d 2 -w 10 -z'},
>  { host: 'drp-neh-cmp015', id:'encoder_0',   flags:'spu', rtprio:50, cmd:f'drp_udpencoder -l 0x8 -o {data_dir} -P {hutch} -d /dev/datadev_0 -C {collect_host}'},

Recording Experiment rixdaq18 Run 23

encoder_0 log file
rix-drp_udpencoder[70415]: <I> UDP receiver thread started
rix-drp_udpencoder[70415]: <I> setting lane 0
rix-drp_udpencoder[70415]: <I> PGPReader saw Configure transition @ 985133577.575584342 (0004674c799500)
rix-drp_udpencoder[70415]: <I> EbReceiver saw Configure transition @ 985133577.575584342 (0004674c799500)
rix-drp_udpencoder[70415]: <I> received key = beginrun
Opening file /ffb01/data/rix/rixdaq18/xtc/rixdaq18-r0023-s002-c000.xtc2
rix-drp_udpencoder[70415]: <I> Opening file '/ffb01/data/rix/rixdaq18/xtc/rixdaq18-r0023-s002-c000.xtc2'
rix-drp_udpencoder[70415]: <I> Opening file '/ffb01/data/rix/rixdaq18/xtc/smalldata/rixdaq18-r0023-s002-c000.smd.xtc2'
rix-drp_udpencoder[70415]: <I> PGPReader saw BeginRun transition @ 985133590.653839154 (0004674d32e3bd)
rix-drp_udpencoder[70415]: <I> EbReceiver saw BeginRun transition @ 985133590.653839154 (0004674d32e3bd)
rix-drp_udpencoder[70415]: <I> received key = beginstep
rix-drp_udpencoder[70415]: <I> PGPReader saw BeginStep transition @ 985133595.531025432 (0004674d77fa30)
rix-drp_udpencoder[70415]: <I> EbReceiver saw BeginStep transition @ 985133595.531025432 (0004674d77fa30)
rix-drp_udpencoder[70415]: <I> received key = enable
rix-drp_udpencoder[70415]: <I> PGPReader saw Enable transition @ 985133600.224320451 (0004674dba80e8)
rix-drp_udpencoder[70415]: <I> EbReceiver saw Enable transition @ 985133600.224320451 (0004674dba80e8)
rix-drp_udpencoder[70415]: <I> received key = disable
rix-drp_udpencoder[70415]: <I> PGPReader saw Disable transition @ 985133613.263120215 (0004674e7336db)
rix-drp_udpencoder[70415]: <I> EbReceiver saw Disable transition @ 985133613.263120215 (0004674e7336db)
rix-drp_udpencoder[70415]: <I> received key = endstep
rix-drp_udpencoder[70415]: <I> PGPReader saw EndStep transition @ 985133613.268625231 (0004674e734afa)
rix-drp_udpencoder[70415]: <I> EbReceiver saw EndStep transition @ 985133613.268625231 (0004674e734afa)
rix-drp_udpencoder[70415]: <I> received key = endrun
rix-drp_udpencoder[70415]: <I> PGPReader saw EndRun transition @ 985133613.326952707 (0004674e742027)
rix-drp_udpencoder[70415]: <I> EbReceiver saw EndRun transition @ 985133613.326952707 (0004674e742027)
rix-drp_udpencoder[70415]: <I> received key = unconfigure
rix-drp_udpencoder[70415]: <I> PGPReader saw Unconfigure transition @ 985133630.918879608 (0004674f6d5f9b)
rix-drp_udpencoder[70415]: <I> EbReceiver saw Unconfigure transition @ 985133630.918879608 (0004674f6d5f9b)

Recording Experiment rixdaq18 Run 27

This was the first recording of the encoder at 120Hz.


xtcreader 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

Viewing Encoder Value in AMI

  • No labels