From: Jan Michel Date: Tue, 1 Nov 2016 15:15:00 +0000 (+0100) Subject: power supplies web page update: X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=e33821460e93a5b4c99641fe7c1b184300edc8a0;p=daqtools.git power supplies web page update: - HMP and HMC power supplies via Ethernet - support for HMC power supplies - support for devices identifying as 'Rohde&Schwarz' --- diff --git a/web/htdocs/tools/pwr/build_index.pl b/web/htdocs/tools/pwr/build_index.pl index c5ea77a..6b40300 100755 --- a/web/htdocs/tools/pwr/build_index.pl +++ b/web/htdocs/tools/pwr/build_index.pl @@ -36,7 +36,7 @@ print < diff --git a/web/htdocs/tools/pwr/index.html b/web/htdocs/tools/pwr/index.html index b7cf2cc..7295956 100644 --- a/web/htdocs/tools/pwr/index.html +++ b/web/htdocs/tools/pwr/index.html @@ -27,10 +27,18 @@ getdata('build_index.pl',update);

Note that you need to have libdevice-serialport-perl or perl-Device-SerialPort
installed and that the /dev/ttyUSBn need to be accessible by normal users.
-To be able to read back values from the supply, you need an interface capable
-of supplying at least 7V on the DTR line of the serial port.
Feel free to alter the config file to accommodate your needs!
Please don't use the # character to comment out lines
+Tested with HMC8043, HMP4040, HMP4030, PSP405, PSP2010, PST3202 +

+//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
+
diff --git a/web/htdocs/tools/pwr/pwr.pl b/web/htdocs/tools/pwr/pwr.pl index 2e3807e..140a166 100755 --- a/web/htdocs/tools/pwr/pwr.pl +++ b/web/htdocs/tools/pwr/pwr.pl @@ -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; diff --git a/web/htdocs/tools/pwr/pwr_hmp.htm b/web/htdocs/tools/pwr/pwr_hmp.htm index b35773a..76dc1ba 100644 --- a/web/htdocs/tools/pwr/pwr_hmp.htm +++ b/web/htdocs/tools/pwr/pwr_hmp.htm @@ -39,8 +39,10 @@ - -Enable read-back of valuesRead Settings +Global Switch + +Enable read-back of values +Read settings   @@ -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