]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
power supplies web page update:
authorJan Michel <j.michel@gsi.de>
Tue, 1 Nov 2016 15:15:00 +0000 (16:15 +0100)
committerJan Michel <j.michel@gsi.de>
Tue, 1 Nov 2016 15:15:00 +0000 (16:15 +0100)
- HMP and HMC power supplies via Ethernet
- support for HMC power supplies
- support for devices identifying as 'Rohde&Schwarz'

web/htdocs/tools/pwr/build_index.pl
web/htdocs/tools/pwr/index.html
web/htdocs/tools/pwr/pwr.pl
web/htdocs/tools/pwr/pwr_hmp.htm

index c5ea77aefaa986b2d8d230e4febbf2fed9c414a8..6b403004a4f7bf21dc7d7c5808e5fd73a5c37336 100755 (executable)
@@ -36,7 +36,7 @@ print <<EOF;
 EOF
 }
 
-if($type =~ /HMP/ or $type =~ /PST/) {
+if($type =~ /HMP/ or $type =~ /HMC/ or $type =~ /PST/) {
 print <<EOF;
 <p>
 <iframe name="inlineframe" src="pwr_hmp.htm?device=$ser_dev&id=$dev_id&type=$type&channels=$channels&speed=$speed" frameborder="0" scrolling="auto" width="800" height="340" ></iframe>
index b7cf2cc0b228c46f4f58926df4c780b8cc22e7d4..729595698f7ef3ab0a477cd0126acbcafd5e22e7 100644 (file)
@@ -27,10 +27,18 @@ getdata('build_index.pl',update);
 <p id="conf_area">
 Note that you need to have libdevice-serialport-perl or perl-Device-SerialPort<br> 
 installed and that the /dev/ttyUSBn need to be accessible by normal users.<br>
-To be able to read back values from the supply, you need an interface capable<br>
-of supplying at least 7V on the DTR line of the serial port.<br>
 Feel free to alter the config file to accommodate your needs!<br>
 Please don't use the # character to comment out lines<br>
+Tested with HMC8043, HMP4040, HMP4030, PSP405, PSP2010, PST3202
+<br><pre>
+//PWRSPLY:/path/to/device:Speed:Name:Type:Channels
+//PWRSPLY:IP0.0.0.0:Port:Name:Type:Channels
+PWRSPLY:/dev/ttyUSB0:9600:PST3202:PST:3
+PWRSPLY:/dev/ttyUSB0:115200:HMP4030:HMP:3
+PWRSPLY:IP192.168.0.56:5050:HMP4040:HMP:4
+PWRSPLY:/dev/FTDI_FT232R_USB_UART_AH02HFZW:2400:PSP2010:PSP:1
+PWRSPLY:/dev/FTDI_FT232R_USB_UART_A702HE33:2400:PSP405:PSP:1</pre>
+<br>
 <TEXTAREA NAME="Address" id="config_field" ROWS=10 COLS=50 >
 Platzhalter
 </TEXTAREA>
index 2e3807e055201a61602955f3dd0f96bdefe028c0..140a16633a9a31182ef6e624ac4cc0b963253e48 100755 (executable)
@@ -8,9 +8,11 @@ print "Content-type: text/html\n\n";
 use strict;
 use warnings;
 use Device::SerialPort;
+use IO::Socket;
 use feature 'state';
 use URI::Escape;
 use Time::HiRes qw( usleep);
+use POSIX qw/floor ceil strftime/;
 
 my $envstring = $ENV{'QUERY_STRING'};
 $envstring =~ s/%20/ /g;
@@ -23,26 +25,39 @@ $ser_dev = "/dev/ttyUSB0" unless defined $ser_dev;
 my $ser_type = shift(@new_command);
 $ser_type = "PSP" unless defined $ser_type;
 
-my $ser_speed = shift(@new_command);
+my $ser_speed = shift(@new_command);  #speed or port number
 $ser_speed = "2400" unless defined $ser_speed;
 
 
-my $port = new Device::SerialPort($ser_dev);
-unless ($port)
-{
-       print "can't open serial interface $ser_dev\n";
-       exit;
-}
 
-$port->user_msg('ON'); 
-$port->baudrate($ser_speed); 
-$port->parity("none"); 
-$port->databits(8); 
-$port->stopbits(1); 
-$port->handshake("xoff");
-$port->handshake("none") if $ser_type eq "HMP" or $ser_type eq "PST"; 
-$port->write_settings;
 
+my $port;
+my $isIP = 0;
+
+if($ser_dev =~ /^IP(.*)/) {
+  $ser_dev = $1;
+  $isIP = 1;
+  $port = IO::Socket::INET->new(PeerAddr => $ser_dev, PeerPort => $ser_speed, Proto => "tcp", Type => SOCK_STREAM) 
+              or die "ERROR: Cannot connect: $@";  
+  }
+else {  
+  $port = new Device::SerialPort($ser_dev);
+  unless ($port)
+  {
+    print "can't open serial interface $ser_dev\n";
+    exit;
+  }
+
+  $port->user_msg('ON'); 
+  $port->baudrate($ser_speed); 
+  $port->parity("none"); 
+  $port->databits(8); 
+  $port->stopbits(1); 
+  $port->handshake("xoff");
+  $port->handshake("none") if $ser_type eq "HMP" or $ser_type eq "HMC" or $ser_type eq "PST"; 
+  $port->write_settings;
+  }
+  
 # debug output
 #print "attempting to communicate with power supply connected to interface:\n$ser_dev\n\n";
 
@@ -51,8 +66,8 @@ transmit_command() if $ser_type eq "PSP"; #if new command, send it!
 receive_answer() if $ser_type eq "PSP"; # always called
 
 
-print receive_answer_HMP() if $ser_type eq "HMP" or $ser_type eq "PST"; # always called
-
+print receive_answer_HMP() if (($ser_type eq "HMP" or $ser_type eq "HMC") && $isIP == 0) or $ser_type eq "PST"; # always called
+print HMP_ethernet() if (($ser_type eq "HMP" or $ser_type eq "HMC") && $isIP == 1);
 # transmit_command(); # send relais off in case current maximum is reached!
 
 
@@ -157,6 +172,7 @@ sub receive_answer {
 
 sub receive_answer_HMP {
   my $ret ="";
+  print strftime("%H:%M:%S &", localtime());
   while ( my $command = shift(@new_command) ) {
     $port->lookclear; 
     usleep(1000);
@@ -186,6 +202,27 @@ sub receive_answer_HMP {
   return $ret;
   }
 
+  
+  
+sub HMP_ethernet {
+  my $ret ="";
+  print strftime("%H:%M:%S &", localtime());
+  while ( my $command = shift(@new_command) ) {
+    usleep(20000);
+    $command = uri_unescape($command);
+    print $port "$command\n";
+    if($command =~ /\?/) {
+      my $e = <$port>;
+      chomp $e;
+      $e =~ s/\&//;
+      print $e.'&';
+      }
+    }
+  return $ret;
+  }
+  
+  
+  
 print "\n";
   
 exit 1;
index b35773a671f29915e84356b570346c8e08f975fe..76dc1bae9814bd68e9c10e36160099fb96c06dcf 100644 (file)
   <td class="state"><input type="button" onClick="turn_on(2)" value="on"><td class="state"><input type="button" onClick="turn_off(2)" value="off">
   <td class="state"><input type="button" onClick="turn_on(3)" value="on"><td class="state"><input type="button" onClick="turn_off(3)" value="off">
   <td class="state"><input type="button" onClick="turn_on(4)" value="on"><td class="state"><input type="button" onClick="turn_off(4)" value="off">
-
-<tr class="sep"><td colspan=5><input type="checkbox" value="1" id="showreadings">Enable read-back of values<td colspan=4>Read Settings<input type="button" onClick="readSettings()" value="Go">
+<tr class="sep"><td id="master">Global Switch<td colspan=8><input type="button" onClick="globalOn()" value="ON">
+<input type="button" onClick="globalOff()" value="OFF">
+<tr class="sep"><td colspan=5><input type="checkbox" value="1" id="showreadings">Enable read-back of values<td colspan=4>
+Read settings<input type="button" onClick="readSettings()" value="Go">
 <tr><td colspan=9 id="info">&nbsp;
 </table>
 </form>
@@ -72,7 +74,7 @@ function set_v(chan) {
   if (chan > channels) return;
        var value = parseFloat(document.getElementById("form_v"+chan).value);
        var command;
-  if(type=="HMP") command = "INST OUT"+chan+"&VOLT "+value.toFixed(3);
+  if(type=="HMP" || type=="HMC") command = "INST OUT"+chan+"&VOLT "+value.toFixed(3);
   if(type=="PST") command = ":CHAN"+chan+":VOLT "+value.toFixed(3);
        new_commands.push(command);
   forceShowReadings = 1;
@@ -83,6 +85,7 @@ function set_v_lim(chan) {
        var value = parseInt(document.getElementById("form_v_lim"+chan).value);
        var command;
   if(type=="HMP") command = "INST OUT"+chan+"&VOLT:PROT "+value.toFixed(3);
+  if(type=="HMC") command = "INST OUT"+chan+"&VOLT:PROT ON&VOLT:PROT:LEV "+value.toFixed(3);
   if(type=="PST") command = ":CHAN"+chan+":PROT:VOLT "+value.toFixed(3);
        new_commands.push(command);
   forceShowReadings = 1;
@@ -92,7 +95,7 @@ function set_c_lim(chan) {
   if (chan > channels) return;
        var value = parseFloat(document.getElementById("form_c_lim"+chan).value);
        var command;
-  if(type=="HMP") command = "INST OUT"+chan+"&CURR "+value.toFixed(3);
+  if(type=="HMP" || type=="HMC") command = "INST OUT"+chan+"&CURR "+value.toFixed(3);
   if(type=="PST") command = ":CHAN"+chan+":PROT:CURR "+value.toFixed(3);
        new_commands.push(command);
   forceShowReadings = 1;
@@ -100,18 +103,31 @@ function set_c_lim(chan) {
 
 function turn_on(chan) {
   if (chan > channels) return;
-  if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP ON");
+  if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP:SEL ON");
+  if(type=="HMC") new_commands.push("INST OUT"+chan+"&OUTP:CHAN ON");
   if(type=="PST") new_commands.push(":OUTP:STAT ON");
   forceShowReadings = 1;
 }
 
 function turn_off(chan) {
   if (chan > channels) return;
-  if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP OFF");
+  if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP:SEL OFF");
+  if(type=="HMC") new_commands.push("INST OUT"+chan+"&OUTP:CHAN OFF");
   if(type=="PST") new_commands.push(":OUTP:STAT OFF");
   forceShowReadings = 1;
 }
 
+function globalOn() {
+  if(type=="HMP") new_commands.push("OUTP:GEN ON");
+  if(type=="HMC") new_commands.push("OUTP:MAST ON");
+  forceShowReadings = 1;
+}
+
+function globalOff() {
+  if(type=="HMP") new_commands.push("OUTP:GEN OFF");
+  if(type=="HMC") new_commands.push("OUTP:MAST OFF");
+  forceShowReadings = 1;
+}
 
 function update(data) {
   updateTask = setTimeout("communication()",updaterate);
@@ -120,9 +136,11 @@ function update(data) {
   
 function updatereads(data) {
   var e = data.split("&");
+  document.getElementById("info").innerHTML = e.shift();
+  document.getElementById("master").style.background=(e.shift()=='1')?"limegreen":"#C00";
   for(i=0;i<channels;i++) {
-    document.getElementById("vol"+(i+1)).value=e[i*3];
-    document.getElementById("cur"+(i+1)).value=e[i*3+1];
+    document.getElementById("vol"+(i+1)).value=(+e[i*3]).toFixed(3);
+    document.getElementById("cur"+(i+1)).value=(+e[i*3+1]).toFixed(3);
     document.getElementById("chan"+(i+1)).style.background=(e[i*3+2]=="1")?"limegreen":"#C00";
     }
   updateTask = setTimeout("communication()",updaterate);
@@ -130,12 +148,13 @@ function updatereads(data) {
 
 function updatesettings(data) {
   var e = data.split("&");
-  var id = e.shift();
-  document.getElementById("info").innerHTML = "Device Info: "+id;
+//   var id = e.shift();
+  document.getElementById("info").innerHTML = e.shift()+" Device Info: "+e.shift();
+  document.getElementById("master").style.background=(e.shift()=='1')?"limegreen":"#C00";
   for(i=0;i<channels;i++) {
-    document.getElementById("form_v"+(i+1)).value=e[i*3];
-    document.getElementById("form_c_lim"+(i+1)).value=e[i*3+1];
-    document.getElementById("form_v_lim"+(i+1)).value=e[i*3+2];
+    document.getElementById("form_v"+(i+1)).value=(+e[i*3]).toFixed(3);
+    document.getElementById("form_c_lim"+(i+1)).value=(+e[i*3+1]).toFixed(3);
+    document.getElementById("form_v_lim"+(i+1)).value=(+e[i*3+2]).toFixed(3);
     }
   updateTask = setTimeout("communication()",updaterate);
   }    
@@ -147,10 +166,14 @@ function communication() {
     }
   else if(readSettingsRequest == 1) {
     readSettingsRequest = 0;
-    if(type=="HMP") {
+    if(type=="HMP" || type=="HMC") {
       cmds = "&SYST:MIX&%2AIDN%3F";
-      for(i=1;i<=channels;i++)
-        cmds +="&INST OUT"+i+"&SOUR:VOLT%3F&SOUR:CURR%3F&VOLT:PROT%3F";
+    if(type=="HMP") cmds += '&OUTP:GEN%3F';
+    if(type=="HMC") cmds += '&OUTP:MAST%3F';
+      for(i=1;i<=channels;i++){
+        if(type=="HMP") cmds +="&INST OUT"+i+"&SOUR:VOLT%3F&SOUR:CURR%3F&VOLT:PROT%3F";
+        if(type=="HMC") cmds +="&INST OUT"+i+"&SOUR:VOLT%3F&SOUR:CURR%3F&VOLT:PROT:LEV%3F";
+        }
       }
     if(type=="PST") {
       cmds="&%2AIDN%3F";
@@ -162,7 +185,9 @@ function communication() {
   else if(document.getElementById("showreadings").checked || forceShowReadings) {
     forceShowReadings = 0;
     cmds = "";
-    if(type=="HMP") {    
+    if(type=="HMP") cmds += '&OUTP:GEN%3F';
+    if(type=="HMC") cmds += '&OUTP:MAST%3F';
+    if(type=="HMP" || type=="HMC") {    
       for(i=1;i<=channels;i++)
         cmds +="&INST OUT"+i+"&MEAS:VOLT%3F&MEAS:CURR%3F&OUTP:STAT%3F";
       }