Skip to main content.

CAEN C219 input monitoring

Foreword

This example monitors 4 signals connected to a CAEN C219 I/O unit; the state of these inputs is monitored every second, and the User web page is updated with the result. The four signals have literal names in order to easily identify signals. HTML tags are embedded into the string displayed on the User page to properly format the results.

A screenshot of the resulting User web page follows:

Some notes follow:

Lua code

-- definiton of labels for all four inputs
inp1_label  = "power supply: "
inp2_label  = "section 2: "
inp3_label  = "temp 2 > threshold: "
inp4_label  = "acquisition completed: "

inp1_status = "----"
inp2_status = "----"
inp3_status = "----"
inp4_status = "----"

-- C219 in slot 6, inputs are 5,6,7,9 
-- (slots are numbered 1 to 24)
-- (inputs on C219 are numbered 0 to 15, on front panel from 1 to 16 !!)
slot = 6
inp1 = 5
inp2 = 6
inp3 = 7
inp4 = 9

-- miscellaneous parameters
mydelay = 500

-- init C219 to set up inputs (positive logic, normal mode)
CSSA(17,slot,inp1,7)
CSSA(17,slot,inp2,7)
CSSA(17,slot,inp3,7)
CSSA(17,slot,inp4,7)

-- infinite loop to monitor signal status
while (1) do

  doevents();
  pause(mydelay);
  -- read input values

  q,C219status = CSSA(0,slot,0,0);

  ---- test signal 1, OK if 1, FAIL if 0 ----
  bitmask = bsl(1,inp1);
  res = band(C219status,bitmask);
  if ( res ~= bitmask) then
     inp1_status = "FAIL"
  else
     inp1_status = "OK"
  end
  ---- test signal 2, OK if 1, FAIL if 0 ----
  bitmask = bsl(1,inp2);
  res = band(C219status,bitmask);
  if ( res ~= bitmask) then
     inp2_status = "FAIL"
  else
     inp2_status = "OK"
  end
  ---- test signal 3, TRUE if 1, FALSE if 0 ----
  bitmask = bsl(1,inp3);
  res = band(C219status,bitmask);
  if ( res ~= bitmask) then
     inp3_status = "FALSE"
  else
     inp3_status = "TRUE"
  end
  ---- test signal 4, TRUE if 1, FALSE if 0 ----
  bitmask = bsl(1,inp4);
  res = band(C219status,bitmask);
  if ( res ~= bitmask) then
     inp4_status = "FALSE"
  else
     inp4_status = "TRUE"
  end
 
  ---- assemble strings for proper display in HTML ----
  str1 = format("%s <b>%s</b>", inp1_label, inp1_status)
  str2 = format("%s <b>%s</b>", inp2_label, inp2_status)
  str3 = format("%s <b>%s</b>", inp3_label, inp3_status)
  str4 = format("%s <b>%s</b>", inp4_label, inp4_status)

  display = format ("%s<br>%s<br>%s<br>%s", str1,str2,str3,str4);
  web_setuser(display);

end