From: Michael Wiebusch Date: Mon, 13 May 2013 13:49:53 +0000 (+0200) Subject: added Raspberry Pi Slow Control Suite v0.1 including support for controlling a Huber... X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=5484e1ab7e9fdddaa3ae1b140a56aa232784b65f;p=labtools.git added Raspberry Pi Slow Control Suite v0.1 including support for controlling a Huber cooling device, reading onewire temperature sensors and controlling a GW Instek power supply --- diff --git a/RasPi_slow_control_suite/README.txt b/RasPi_slow_control_suite/README.txt new file mode 100644 index 0000000..f721324 --- /dev/null +++ b/RasPi_slow_control_suite/README.txt @@ -0,0 +1,50 @@ +Raspberry Pi slow control suite v0.1 +by Michael Wiebusch +mwiebusch@stud.uni-frankfurt.de + + +This package includes: + +"cooling" - a simple tool to control one or more Huber CC405 cooling devices that are connected via RS232 to the Raspberry Pi (e.g. via an RS232toUSB converter). + +"onewire" - a simple monitoring tool to display the output of several onewire temperature sensors that are read out by a MyAVR board with custom firmware by Jan Michel. + +"pwr" - a simple tool to monitor and control one or more laboratory power supplies of the type "GW Instek PSP-405" + + + +Installation: + +Step 1: + +Install an Apache2 webserver on your Raspberry Pi. + +Step 2: + +Configure the Apache thusly, that it executes perl scripts, especially outside of the "cgi-bin" directory. + +You can easily perform this task by adding the following lines to /etc/apache2/apache2.conf (/var/www/ be your default http root directory) + + +Options +ExecCGI +AddHandler cgi-script .cgi .pl + + +Step 3: + +Install the perl module "libdevice-serialport-perl". +It is necessary so perl can use serial devices in a comfortable way. +You can perform that by using the Raspbian package manager: + +"sudo apt-get install libdevice-serialport-perl" + +Step 4: + +Copy the contents of the "www"-directory included in this archive into the http root directory on your raspberry pi (default: /var/www/). + +Step 5: + +Point your browser to http://[IP of the raspberry]/tools/ +and use the tools. + +You can configure the monitoring/control tools (especially what serial device to use) on each webinterface. diff --git a/RasPi_slow_control_suite/www/tools/cooling/.pwr.htm.swp b/RasPi_slow_control_suite/www/tools/cooling/.pwr.htm.swp new file mode 100644 index 0000000..692acb5 Binary files /dev/null and b/RasPi_slow_control_suite/www/tools/cooling/.pwr.htm.swp differ diff --git a/RasPi_slow_control_suite/www/tools/cooling/build_index.pl b/RasPi_slow_control_suite/www/tools/cooling/build_index.pl new file mode 100755 index 0000000..68dd00b --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/build_index.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +print "Content-type: text/html\n\n"; +use Cwd; + +my $pwd = &Cwd::cwd(); + + +open(LESEN,"cooling.conf") + or die "Fehler beim oeffnen von : $!\n"; + +while(defined(my $i = )) { + + if( $i =~ /^HUBERDEV:([^:]+):([^:]+)/g ) { + my $ser_dev=$1; + my $dev_id=$2; + +print < + +

+EOF + } +} + +#print "CWD: ".$pwd."
(for debug)\n"; + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/cooling/cooling.conf b/RasPi_slow_control_suite/www/tools/cooling/cooling.conf new file mode 100644 index 0000000..953ebae --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/cooling.conf @@ -0,0 +1,2 @@ +//HUBERDEV:/path/to/device:Device_ID +HUBERDEV:/dev/ttyUSB3:HUBER_DUTY diff --git a/RasPi_slow_control_suite/www/tools/cooling/cooling.htm b/RasPi_slow_control_suite/www/tools/cooling/cooling.htm new file mode 100644 index 0000000..726fe3e --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/cooling.htm @@ -0,0 +1,125 @@ + + + + + + +Power Supply Monitor and Access + + + + +

HUBER Cooling System Control

+ + + + + + + + + + + + + + + + +
Readings: Settings:
+ + +
+
+ +
+ + + + +
Temperature Setpoint + +

+

+ +
+
+ +
+ + + + + + diff --git a/RasPi_slow_control_suite/www/tools/cooling/cooling.pl b/RasPi_slow_control_suite/www/tools/cooling/cooling.pl new file mode 100755 index 0000000..b404313 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/cooling.pl @@ -0,0 +1,133 @@ +#!/usr/bin/perl +print "Content-type: text/html\n\n"; + +use strict; +use warnings; +use Device::SerialPort; +use Time::HiRes; +use feature 'state'; + +my $envstring = $ENV{'QUERY_STRING'}; +$envstring =~ s/%20/ /g; + + +my @new_command = split('&',$envstring); +my $ser_dev = shift(@new_command); + + + +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(9600); +$port->parity("none"); +$port->databits(8); +$port->stopbits(1); +$port->handshake("xoff"); +$port->write_settings; + +# debug output +#print "attempting to communicate with power supply connected to interface:\n$ser_dev\n\n"; + + +transmit_command(); #if new command, send it! +receive_answer(); # always called +Time::HiRes::sleep(1); +#transmit_command(); # send relais off in case current maximum is reached! + + + + + + + + + + + + + + + + +sub transmit_command { + +$port->lookclear; + +while ( my $command = shift(@new_command) ) { + + $port->write("$command\r\n"); + print "i sent the command: $command
"; + print "\n\nokay.\n
"; + Time::HiRes::sleep(.1); + } +} + + + + +sub receive_answer { + + + + + my %state_lookup = ( + 0 => 'off', + 1 => 'on' ); + + my $found = 0; + + + + # clear buffers, then send the "list"-command to the power supply + #$port->lookclear; + $port->write("IN_SP_00\r\n"); + $port->write("TI?\r\n"); + # sleep a second to give the supply time to react + #sleep 1; + Time::HiRes::sleep(.1); + + # read what has accumulated in the serial buffer + for (my $i = 0; ($i<200) && ($found < 2);$i++) { + while(my $a = $port->lookfor) { + #print $a."
\n"; # debug output + if ( $a =~ m/^TI (.+)/ ) { + my $value = $1/100; + print "Internal Sensor: $value °C
\n"; + $found++; + } + if ( $a =~ m/^(.[\d]+\.[\d]+)/) { + print "Set Point: $1 °C
\n"; + $found++; + } + Time::HiRes::sleep(.01); + } + + } + + + + + if($found) { + + print "connection ok
"; + } else { + print "!!! cooling device not responding !!!
"; + } + + print " \n"; + + + + + + + +} + +exit 1; diff --git a/RasPi_slow_control_suite/www/tools/cooling/index.html b/RasPi_slow_control_suite/www/tools/cooling/index.html new file mode 100644 index 0000000..05a87c4 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/index.html @@ -0,0 +1,71 @@ + + + + + + Huber Remote + + + + + +

+Platzhalter +

+ + + +

+Feel free to alter the config file to accommodate your needs!
+Please don't use the # character to comment out lines
+ +
+ + + + + +

+ + + + + + + + + + + + + diff --git a/RasPi_slow_control_suite/www/tools/cooling/read_conf.pl b/RasPi_slow_control_suite/www/tools/cooling/read_conf.pl new file mode 100755 index 0000000..054090a --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/read_conf.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w +print "Content-type: text/html\n\n"; + +use Cwd; + +my $pwd = &Cwd::cwd(); + + +open(LESEN,"cooling.conf") + or print "Fehler beim oeffnen von : $!\n"; + +while(defined(my $i = )) { + +print $i; + + } + + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/cooling/save_conf.pl b/RasPi_slow_control_suite/www/tools/cooling/save_conf.pl new file mode 100755 index 0000000..0b979ac --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/save_conf.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl +print "Content-type: text/html\n\n"; + +my $envstring = $ENV{'QUERY_STRING'}; +$envstring =~ s/%20/ /g; +$envstring =~ s/&/\n/g; +##$envstring =~ s/&/\n/g; + + +open(SCHREIBEN,">cooling.conf") + or print "Fehler beim oeffnen von : $!\n"; + +print SCHREIBEN $envstring; +close(SCHREIBEN); + +print "saved!"; + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/cooling/scripts.js b/RasPi_slow_control_suite/www/tools/cooling/scripts.js new file mode 100644 index 0000000..930d429 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/scripts.js @@ -0,0 +1,43 @@ + + +function getdata(command,callback) { + var xmlhttp = null; + var cb = null; + xmlhttp=new XMLHttpRequest(); + cb = callback; + + xmlhttp.onreadystatechange = function() { + if(xmlhttp.readyState == 4) { + if(cb) + cb(xmlhttp.responseText); + } + } + xmlhttp.open("GET",command,true); + xmlhttp.send(null); + } + + + +// function reload() { +// xmlhttp=new XMLHttpRequest(); +// xmlhttp.onreadystatechange = function() { +// if(xmlhttp.readyState == 4) { +// document.getElementById("content").innerHTML=xmlhttp.responseText; +// if(document.getElementById('logbox')) { +// if(saveScrollTop) { +// document.getElementById('logbox').scrollTop = saveScrollTop; +// } +// } +// +// document.getElementById("stop").style.background="#444"; +// reloadevery = setTimeout('reload()',$.($delay*1000).qq$); +// } +// }; +// if(document.getElementById('logbox')) { +// saveScrollTop = document.getElementById('logbox').scrollTop; +// if (saveScrollTop == 0) {saveScrollTop = 0.1;} +// } +// xmlhttp.open("GET","get.cgi?$.$ENV{'QUERY_STRING'}.qq$",true); +// xmlhttp.send(null); +// document.getElementById("stop").style.background="#111"; +// } \ No newline at end of file diff --git a/RasPi_slow_control_suite/www/tools/cooling/styles.css b/RasPi_slow_control_suite/www/tools/cooling/styles.css new file mode 100644 index 0000000..db44aa0 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/styles.css @@ -0,0 +1,48 @@ +body { + background:#def; +} + + +table#content, table#contentregs { + border:1px solid #aaa; + border-collapse:collapse; +} + + +table#content td, table#content th, table#contentregs td, table#contentregs th{ + border:1px solid #aaa; + width:100px; + text-align:right; + padding-right:15px; +} + +table#content, table#contentregs { + border:1px solid #aaa; +} + + +div#bar1 { + width:900px; + overflow-x:scroll; + } + +div#bar1 div { + width:66500px; + height:0px; +} + +div#bar2 { + width:900px; + overflow-x:scroll; + } + +div#bar2 div { + width:65536px; + height:0px; +} + + +#total { + text-align:center; + font-weight:bold; + } \ No newline at end of file diff --git a/RasPi_slow_control_suite/www/tools/cooling/test.pl b/RasPi_slow_control_suite/www/tools/cooling/test.pl new file mode 100755 index 0000000..5e8ec31 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/test.pl @@ -0,0 +1,3 @@ +#!/usr/bin/perl +print "Content-type: text/html\n\n"; +print "Hello, World."; diff --git a/RasPi_slow_control_suite/www/tools/cooling/testi.pl b/RasPi_slow_control_suite/www/tools/cooling/testi.pl new file mode 100755 index 0000000..bb6c092 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/cooling/testi.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl -w + +my $envstring = $ENV{'QUERY_STRING'}; +$envstring =~ s/%20/ /g; + +my @argum = split('-',$envstring); + +for (@argum) { +print "$_\n"; +} +sleep 1; +#print "fertig!!!\n"; diff --git a/RasPi_slow_control_suite/www/tools/onewire/bak/voltage_readout.pl_bak12.10.25_17:59:26 b/RasPi_slow_control_suite/www/tools/onewire/bak/voltage_readout.pl_bak12.10.25_17:59:26 new file mode 100755 index 0000000..8789972 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/bak/voltage_readout.pl_bak12.10.25_17:59:26 @@ -0,0 +1,136 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use Device::SerialPort; +use feature 'state'; + + + + + + + + +sub adc2mV { + my $adc = $_[0]; + my $voltage = ($adc -(-0.904714))/0.936225; + return $voltage; +} + + + +#default device +my $ser_dev = "/dev/ttyUSB0"; + + + +# read config file + +open(LESEN,"htdocs/chiptemp/config.conf") + or die "Fehler beim oeffnen von : $!\n"; + +while(defined(my $i = )) { + + if( $i =~ /^SER_DEV=([^=]+)/g ) { + $ser_dev=$1; + $ser_dev =~ s/\n//g; + $ser_dev =~ s/\r//g; + } + +} + + + + + + + + + + + + + + + + + + + +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(19200); +$port->parity("none"); +$port->databits(8); +$port->stopbits(1); +$port->handshake("xoff"); +$port->write_settings; + + + +my $nmax = 10; +my $n = 0; +my @data; + + + + + + # clear buffers, then send the "list"-command to the power supply + $port->lookclear; + + # read what has accumulated in the serial buffer + +while ($n < $nmax) { + sleep 1; + while(my $a = $port->lookfor) { + #print $a."\n"; # debug output + if ($a =~ m/(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t(\d\d\d\d)\t/) { + push(@data,[$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16]); + $n++; + #print $data[0]->[0]."\n"; + if($n == $nmax) { + last; + } + + } + } +} + +#print $data[9]->[15]."\n"; + +my @mean; +for (my $j=0; $j<$nmax;$j++){ + for (my $i=0; $i<16;$i++) { + $mean[$i] += $data[$j]->[$i]; + } +} + +for my $j (0..15) { + $mean[$j] = sprintf("%6.1f mV",adc2mV($mean[$j]/$nmax)); +} + + +#$mean = $mean/$nmax; +#my $voltage=adc2mV($mean); +#print $mean."\n"; +#printf("this corresponds to %6.1f mV\n",$voltage); + +print join("\n",@mean); + + +#open(SCHREIBEN,">> calib_data.dat") +# or die "Fehler beim oeffnen von file: $!\n"; +# +#print SCHREIBEN $ARGV[0]."\t".$mean."\n"; + + + + diff --git a/RasPi_slow_control_suite/www/tools/onewire/chiptemp.htm b/RasPi_slow_control_suite/www/tools/onewire/chiptemp.htm new file mode 100644 index 0000000..4593a79 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/chiptemp.htm @@ -0,0 +1,130 @@ + + + + + + +One Wire Temperature Sensors + + + + +

One Wire Temperature Sensors

+ + + + + + + + + + + + + + +
Readings:
+ +
+
+ + + + + + diff --git a/RasPi_slow_control_suite/www/tools/onewire/config.conf b/RasPi_slow_control_suite/www/tools/onewire/config.conf new file mode 100644 index 0000000..b011460 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/config.conf @@ -0,0 +1,14 @@ +//define serial interface here +//example: +//SER_DEV=/dev/ttyUSB0 + +SER_DEV=/dev/ttyUSB2 + +//you can define sensor renaming rules here +//example: +//ID:284CFD41030000D7=Lieblingssensor +//ID:284CFD41030000D7=kleiner Tobi +ID:284EFC4103000074=Prototyp_heat_sink +ID:281B28E20200007A=Cleanroom_air +ID:28CF43E202000003=Plane_f +ID:284037E2020000BF=Plane_e \ No newline at end of file diff --git a/RasPi_slow_control_suite/www/tools/onewire/delete_log.pl b/RasPi_slow_control_suite/www/tools/onewire/delete_log.pl new file mode 100755 index 0000000..2c3ed0a --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/delete_log.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl + +print "content-type: text/html \n\n"; #The header +$file = "shm/onewirelog.txt"; +if (unlink($file) == 1) { + print "File deleted successfully."; +} else { + print "File was not deleted."; +} + + + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/onewire/index.html b/RasPi_slow_control_suite/www/tools/onewire/index.html new file mode 100644 index 0000000..c0613d9 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/index.html @@ -0,0 +1,71 @@ + + + + + + One Wire Temperature Sensors + + + + + +

+ +

+ + + +

+Feel free to alter the config file to accommodate your needs!
+Please don't use the # character to comment out lines
+ +
+ + +

+Download Logfile
+ + + + +

+ + + + + + + + + + + + + diff --git a/RasPi_slow_control_suite/www/tools/onewire/read_conf.pl b/RasPi_slow_control_suite/www/tools/onewire/read_conf.pl new file mode 100755 index 0000000..9e2c2bd --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/read_conf.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w +print "Content-type: text/html\n\n"; +use Cwd; + +my $pwd = &Cwd::cwd(); + + +open(LESEN,"config.conf") + or print "Fehler beim oeffnen von : $!\n"; + +while(defined(my $i = )) { + +print $i; + + } + + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/onewire/save_conf.pl b/RasPi_slow_control_suite/www/tools/onewire/save_conf.pl new file mode 100755 index 0000000..d405d79 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/save_conf.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w +print "Content-type: text/html\n\n"; + +my $envstring = $ENV{'QUERY_STRING'}; +$envstring =~ s/%20/ /g; +$envstring =~ s/&/\n/g; +##$envstring =~ s/&/\n/g; + + +open(SCHREIBEN,">config.conf") + or print "Fehler beim oeffnen von : $!\n"; + +print SCHREIBEN $envstring; +close(SCHREIBEN); + +print "saved!"; + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/onewire/scripts.js b/RasPi_slow_control_suite/www/tools/onewire/scripts.js new file mode 100644 index 0000000..930d429 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/scripts.js @@ -0,0 +1,43 @@ + + +function getdata(command,callback) { + var xmlhttp = null; + var cb = null; + xmlhttp=new XMLHttpRequest(); + cb = callback; + + xmlhttp.onreadystatechange = function() { + if(xmlhttp.readyState == 4) { + if(cb) + cb(xmlhttp.responseText); + } + } + xmlhttp.open("GET",command,true); + xmlhttp.send(null); + } + + + +// function reload() { +// xmlhttp=new XMLHttpRequest(); +// xmlhttp.onreadystatechange = function() { +// if(xmlhttp.readyState == 4) { +// document.getElementById("content").innerHTML=xmlhttp.responseText; +// if(document.getElementById('logbox')) { +// if(saveScrollTop) { +// document.getElementById('logbox').scrollTop = saveScrollTop; +// } +// } +// +// document.getElementById("stop").style.background="#444"; +// reloadevery = setTimeout('reload()',$.($delay*1000).qq$); +// } +// }; +// if(document.getElementById('logbox')) { +// saveScrollTop = document.getElementById('logbox').scrollTop; +// if (saveScrollTop == 0) {saveScrollTop = 0.1;} +// } +// xmlhttp.open("GET","get.cgi?$.$ENV{'QUERY_STRING'}.qq$",true); +// xmlhttp.send(null); +// document.getElementById("stop").style.background="#111"; +// } \ No newline at end of file diff --git a/RasPi_slow_control_suite/www/tools/onewire/shm b/RasPi_slow_control_suite/www/tools/onewire/shm new file mode 120000 index 0000000..0d99fd7 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/shm @@ -0,0 +1 @@ +/dev/shm \ No newline at end of file diff --git a/RasPi_slow_control_suite/www/tools/onewire/styles.css b/RasPi_slow_control_suite/www/tools/onewire/styles.css new file mode 100644 index 0000000..db44aa0 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/styles.css @@ -0,0 +1,48 @@ +body { + background:#def; +} + + +table#content, table#contentregs { + border:1px solid #aaa; + border-collapse:collapse; +} + + +table#content td, table#content th, table#contentregs td, table#contentregs th{ + border:1px solid #aaa; + width:100px; + text-align:right; + padding-right:15px; +} + +table#content, table#contentregs { + border:1px solid #aaa; +} + + +div#bar1 { + width:900px; + overflow-x:scroll; + } + +div#bar1 div { + width:66500px; + height:0px; +} + +div#bar2 { + width:900px; + overflow-x:scroll; + } + +div#bar2 div { + width:65536px; + height:0px; +} + + +#total { + text-align:center; + font-weight:bold; + } \ No newline at end of file diff --git a/RasPi_slow_control_suite/www/tools/onewire/voltage_readout.pl b/RasPi_slow_control_suite/www/tools/onewire/voltage_readout.pl new file mode 100755 index 0000000..532dd62 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/voltage_readout.pl @@ -0,0 +1,140 @@ +#!/usr/bin/perl -w +print "Content-type: text/html\n\n"; + +use strict; +use warnings; +use Device::SerialPort; +use feature 'state'; + + + + + + + +my %idhash; + + +#default device +my $ser_dev = "/dev/ttyUSB0"; +my $logfile = "onewirelog.txt"; + + +# read config file + +open(LESEN,"config.conf") + or die "Fehler beim oeffnen von : $!\n"; + +while(defined(my $i = )) { + + if( $i =~ /^SER_DEV=([^=]+)/g ) { + $ser_dev=$1; + $ser_dev =~ s/\n//g; + $ser_dev =~ s/\r//g; + } + + if( $i =~ /^(ID:[^=]+)=([^=]+)/g ) { + my $id = $1; + my $designator = $2; + $id =~ s/[\n\r\s]//g; + $designator =~ s/[\n\r\s]//g; + $idhash{$id} = $designator; + } + +} + + + +#### date and time + +my $seconds = (localtime)[0]; +my $date = sprintf "%02d.%02d.%02d",(localtime)[3],((localtime)[4] +1),((localtime)[5] -100); +my $hour = sprintf "%02d",(localtime)[2]; +my $now = sprintf "%02d.%02d.%02d %02d:%02d:%02d",(localtime)[3],((localtime)[4] +1),((localtime)[5] -100),(localtime)[2],(localtime)[1],(localtime)[0]; + + + + + +print "now: $now
\n"; + + + +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(19200); +$port->parity("none"); +$port->databits(8); +$port->stopbits(1); +$port->handshake("xoff"); +$port->write_settings; + + + +my $nmax = 20; +my $n = 0; +my @data; +my $found = 0; + +my %reporthash; + + + # clear buffers, then send the "list"-command to the power supply + $port->lookclear; + + # read what has accumulated in the serial buffer + +while ($n < $nmax) { + sleep 1; + $n++; + while(my $a = $port->lookfor) { + $found = 1; + #print $a."\n"; # debug output + if ($a =~ /^(ID:[^T]+)T:\s+\S+\s+=\s+([-+\d.]+)/ ) { + + my $rawid = $1; + my $temp = $2; + my $id = $rawid; + $id =~ s/[\s\r\n]//g; + $temp =~ s/[\s\r\n]//g; + + + # print $id."\n".$temp."\n"; + + if(defined($idhash{$id})) { + # print "match!\n"; + $reporthash{$idhash{$id}} = $temp; + } else { + $reporthash{$rawid} = $temp; + } + + } + } +} + + +unless($found){ + print "!!! no data / no sensors ? !!!
\n"; +} + +open(SCHREIBEN,">> shm/$logfile") + or die "Fehler beim oeffnen von $ARGV[0].c: $!\n"; + while( my ($k, $v) = each %reporthash ) { + print "Sensor $k => $v °C\n"; + print SCHREIBEN "$now:\t$k\t$v Deg.C\n"; + } +close(SCHREIBEN); + + + +print "\n"; + + + + diff --git a/RasPi_slow_control_suite/www/tools/onewire/voltage_readout.pl_bak b/RasPi_slow_control_suite/www/tools/onewire/voltage_readout.pl_bak new file mode 100755 index 0000000..1768bd9 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/onewire/voltage_readout.pl_bak @@ -0,0 +1,127 @@ +#!/usr/bin/perl -w +print "Content-type: text/html\n\n"; + +use strict; +use warnings; +use Device::SerialPort; +use feature 'state'; + + + + + + + +my %idhash; + + +#default device +my $ser_dev = "/dev/ttyUSB0"; + + + +# read config file + +open(LESEN,"config.conf") + or die "Fehler beim oeffnen von : $!\n"; + +while(defined(my $i = )) { + + if( $i =~ /^SER_DEV=([^=]+)/g ) { + $ser_dev=$1; + $ser_dev =~ s/\n//g; + $ser_dev =~ s/\r//g; + } + + if( $i =~ /^(ID:[^=]+)=([^=]+)/g ) { + my $id = $1; + my $designator = $2; + $id =~ s/[\n\r\s]//g; + $designator =~ s/[\n\r\s]//g; + $idhash{$id} = $designator; + } + +} + + + + + + + + + + + +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(19200); +$port->parity("none"); +$port->databits(8); +$port->stopbits(1); +$port->handshake("xoff"); +$port->write_settings; + + + +my $nmax = 2; +my $n = 0; +my @data; +my $found = 0; + +my %reporthash; + + + # clear buffers, then send the "list"-command to the power supply + $port->lookclear; + + # read what has accumulated in the serial buffer + +while ($n < $nmax) { + sleep 1; + $n++; + while(my $a = $port->lookfor) { + $found = 1; + #print $a."\n"; # debug output + if ($a =~ /^(ID:[^T]+)T:\s+\S+\s+=\s+([\d.]+)/ ) { + + my $rawid = $1; + my $temp = $2; + my $id = $rawid; + $id =~ s/[\s\r\n]//g; + $temp =~ s/[\s\r\n]//g; + + + # print $id."\n".$temp."\n"; + + if(defined($idhash{$id})) { + # print "match!\n"; + $reporthash{$idhash{$id}} = $temp; + } else { + $reporthash{$rawid} = $temp; + } + + } + } +} + + +unless($found){ + print "!!! no data / no sensors ? !!!
\n"; +} + + while( my ($k, $v) = each %reporthash ) { + print "Sensor $k => $v °C\n"; + } + +print "\n"; + + + + diff --git a/RasPi_slow_control_suite/www/tools/pwr/.pwr.pl.swp b/RasPi_slow_control_suite/www/tools/pwr/.pwr.pl.swp new file mode 100644 index 0000000..f357731 Binary files /dev/null and b/RasPi_slow_control_suite/www/tools/pwr/.pwr.pl.swp differ diff --git a/RasPi_slow_control_suite/www/tools/pwr/build_index.pl b/RasPi_slow_control_suite/www/tools/pwr/build_index.pl new file mode 100755 index 0000000..c6db061 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/build_index.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl -w +use Cwd; +print "Content-type: text/html\n\n"; + +my $pwd = &Cwd::cwd(); + + +open(LESEN,"pwr.conf") + or die "Fehler beim oeffnen von : $!\n"; + +while(defined(my $i = )) { + + if( $i =~ /^PWRSPLY:([^:]+):([^:]+)/g ) { + my $ser_dev=$1; + my $dev_id=$2; + +print < + +

+EOF + } +} + +#print "CWD: ".$pwd."
(for debug)\n"; + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/pwr/index.html b/RasPi_slow_control_suite/www/tools/pwr/index.html new file mode 100644 index 0000000..5ed6b33 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/index.html @@ -0,0 +1,71 @@ + + + + + + Access all POWER! + + + + + +

+Platzhalter +

+ + + +

+Feel free to alter the config file to accommodate your needs!
+Please don't use the # character to comment out lines
+ +
+ + + + + +

+ + + + + + + + + + + + + diff --git a/RasPi_slow_control_suite/www/tools/pwr/pwr.conf b/RasPi_slow_control_suite/www/tools/pwr/pwr.conf new file mode 100644 index 0000000..96661f6 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/pwr.conf @@ -0,0 +1,3 @@ +//PWRSPLY:/path/to/device:Device_ID +PWRSPLY:/dev/ttyUSB1:PWR_DUT +PWRSPLY:/dev/ttyUSB0:PWR_REF \ No newline at end of file diff --git a/RasPi_slow_control_suite/www/tools/pwr/pwr.conf_out b/RasPi_slow_control_suite/www/tools/pwr/pwr.conf_out new file mode 100644 index 0000000..8f4bdb9 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/pwr.conf_out @@ -0,0 +1,3 @@ +PWRSPLY:/dev/ttyUSB0:Device_1 +PWRSPLY:/dev/ttyUSB1:Device_2 +PWRSPLY:/dev/ttyUSB2:Device_3 diff --git a/RasPi_slow_control_suite/www/tools/pwr/pwr.htm b/RasPi_slow_control_suite/www/tools/pwr/pwr.htm new file mode 100644 index 0000000..06c6698 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/pwr.htm @@ -0,0 +1,155 @@ + + + + + + +Power Supply Monitor and Access + + + + +

MIMOSA26 Prototype Power Supply Access

+ + + + + + + + + + + + + + + + +
Readings: Settings:
+ + +
+
+ +
+ + + + +
Voltage [V] + +

+
Voltage limit [V] + +
Current limit [A] + +
Power limit [W] + +
Save settings to EEPROM +

+ +
Output Relais +
+
+ +
+ + + + + + diff --git a/RasPi_slow_control_suite/www/tools/pwr/pwr.pl b/RasPi_slow_control_suite/www/tools/pwr/pwr.pl new file mode 100755 index 0000000..7ad6e8b --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/pwr.pl @@ -0,0 +1,158 @@ +#!/usr/bin/perl -w +print "Content-type: text/html\n\n"; + + +use strict; +use warnings; +use Device::SerialPort; +use feature 'state'; + +my $envstring = $ENV{'QUERY_STRING'}; +$envstring =~ s/%20/ /g; + + +my @new_command = split('&',$envstring); +my $ser_dev = shift(@new_command); +$ser_dev = "/dev/ttyUSB0" unless defined $ser_dev; + + + +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(2400); +$port->parity("none"); +$port->databits(8); +$port->stopbits(1); +$port->handshake("xoff"); +$port->write_settings; + +# debug output +#print "attempting to communicate with power supply connected to interface:\n$ser_dev\n\n"; + + +transmit_command(); #if new command, send it! +receive_answer(); # always called +transmit_command(); # send relais off in case current maximum is reached! + + + + + + + + + + + + + + + + +sub transmit_command { + +$port->lookclear; + +while ( my $command = shift(@new_command) ) { + + $port->write("$command\r"); + #print "i sent the command: $command"; + #print "\n\nokay.\n"; + sleep 1; + } +} + + + + +sub receive_answer { + + + + + my %state_lookup = ( + 0 => 'off', + 1 => 'on' ); + + my $found = 0; + + + + # clear buffers, then send the "list"-command to the power supply + $port->lookclear; + $port->write("L\r"); + # sleep a second to give the supply time to react + sleep 1; + + # read what has accumulated in the serial buffer + while(my $a = $port->lookfor) { + #print $a."\n"; # debug output + if ($a =~ m/V(\d\d\.\d\d)A(\d\.\d\d\d)W(\d\d\d\.\d)U(\d\d)I(\d\.\d\d)P(\d\d\d)F(\d\d\d\d\d\d)/) { + $found = 1; + my $c_volt = $1; + my $c_cur = $2; + my $c_pwr = $3; + my $l_volt = $4; + my $l_cur = $5; + my $l_pwr = $6; + my $state_string = $7; + my $relais_state = $state_lookup{substr $state_string, 0,1}; + printf(" + + + + + + + + + + + +
%2.2f V +
%1.3f A +
%3.1f W +
voltage limit: %d V +
current limit: %1.2f A +
power limit: %d W +
output relais: $relais_state
" + ,$c_volt,$c_cur,$c_pwr,$l_volt,$l_cur,$l_pwr); + + if( $c_cur > 0) { + if($c_cur > ($l_cur * 0.9) ) { # check if current limit reached, if so, turn power off! + print "!!! current limit reached, power off !!!
"; + push(@new_command,"KOD"); + } + } + + last; + + } + } + + + + + if($found) { + + print "connection ok
"; + } else { + print "!!! power supply not responding !!!
"; + } + + print " \n"; + + + + + + + +} +exit 1; diff --git a/RasPi_slow_control_suite/www/tools/pwr/read_conf.pl b/RasPi_slow_control_suite/www/tools/pwr/read_conf.pl new file mode 100755 index 0000000..dab1f38 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/read_conf.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w +print "Content-type: text/html\n\n"; + +use Cwd; + +my $pwd = &Cwd::cwd(); + + +open(LESEN,"pwr.conf") + or print "Fehler beim oeffnen von : $!\n"; + +while(defined(my $i = )) { + +print $i; + + } + + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/pwr/save_conf.pl b/RasPi_slow_control_suite/www/tools/pwr/save_conf.pl new file mode 100755 index 0000000..efb7af1 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/save_conf.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w +print "Content-type: text/html\n\n"; + + +my $envstring = $ENV{'QUERY_STRING'}; +$envstring =~ s/%20/ /g; +$envstring =~ s/&/\n/g; +##$envstring =~ s/&/\n/g; + + +open(SCHREIBEN,">pwr.conf") + or print "Fehler beim oeffnen von : $!\n"; + +print SCHREIBEN $envstring; +close(SCHREIBEN); + +print "saved!"; + + +return true; diff --git a/RasPi_slow_control_suite/www/tools/pwr/scripts.js b/RasPi_slow_control_suite/www/tools/pwr/scripts.js new file mode 100644 index 0000000..930d429 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/scripts.js @@ -0,0 +1,43 @@ + + +function getdata(command,callback) { + var xmlhttp = null; + var cb = null; + xmlhttp=new XMLHttpRequest(); + cb = callback; + + xmlhttp.onreadystatechange = function() { + if(xmlhttp.readyState == 4) { + if(cb) + cb(xmlhttp.responseText); + } + } + xmlhttp.open("GET",command,true); + xmlhttp.send(null); + } + + + +// function reload() { +// xmlhttp=new XMLHttpRequest(); +// xmlhttp.onreadystatechange = function() { +// if(xmlhttp.readyState == 4) { +// document.getElementById("content").innerHTML=xmlhttp.responseText; +// if(document.getElementById('logbox')) { +// if(saveScrollTop) { +// document.getElementById('logbox').scrollTop = saveScrollTop; +// } +// } +// +// document.getElementById("stop").style.background="#444"; +// reloadevery = setTimeout('reload()',$.($delay*1000).qq$); +// } +// }; +// if(document.getElementById('logbox')) { +// saveScrollTop = document.getElementById('logbox').scrollTop; +// if (saveScrollTop == 0) {saveScrollTop = 0.1;} +// } +// xmlhttp.open("GET","get.cgi?$.$ENV{'QUERY_STRING'}.qq$",true); +// xmlhttp.send(null); +// document.getElementById("stop").style.background="#111"; +// } \ No newline at end of file diff --git a/RasPi_slow_control_suite/www/tools/pwr/styles.css b/RasPi_slow_control_suite/www/tools/pwr/styles.css new file mode 100644 index 0000000..db44aa0 --- /dev/null +++ b/RasPi_slow_control_suite/www/tools/pwr/styles.css @@ -0,0 +1,48 @@ +body { + background:#def; +} + + +table#content, table#contentregs { + border:1px solid #aaa; + border-collapse:collapse; +} + + +table#content td, table#content th, table#contentregs td, table#contentregs th{ + border:1px solid #aaa; + width:100px; + text-align:right; + padding-right:15px; +} + +table#content, table#contentregs { + border:1px solid #aaa; +} + + +div#bar1 { + width:900px; + overflow-x:scroll; + } + +div#bar1 div { + width:66500px; + height:0px; +} + +div#bar2 { + width:900px; + overflow-x:scroll; + } + +div#bar2 div { + width:65536px; + height:0px; +} + + +#total { + text-align:center; + font-weight:bold; + } \ No newline at end of file