in reply to Perl Code To Control Industrial Applications?
Then once you have the idea of how to read/write to it, you can get going. It probably does the same thing the old parallel printer port interfaces did, just write values in C, to a specific memory address. I'm sure Perl can do that.
Then, make up your control interface using something like Tk, SDL, Wx, Gtk3, or whatever Perl GUI you like.
Here for example is a simple dial guage which you can either use to set temperature, or read it's current value.
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; my $gray50_width = 2; my $gray50_height = 2; my $gray50_bits = pack "CC", 0x02, 0x01; $mw->DefineBitmap('mask' => 2,2, $gray50_bits); $mw->fontCreate('medium', -family=>'courier', -weight=>'bold', -size=>int(-14*14/10)); my $c = $mw->Canvas( -width => 200, -height => 200, -bd => 2, -relief => 'sunken', -background => 'black', )->pack; $c->createLine(100,100,10,100, -tags => ['needle'], -arrow => 'last', -width => 5, -fill => 'hotpink', ); my $gauge = $c->createOval( 10,10, 190,190, -fill=> 'lightblue', -outline => 'skyblue', -width => 5, -tags => ['gauge'], -stipple => 'mask', ); my $hub = $c->createOval( 90,90, 110,110, -fill => 'lightgreen', -outline => 'seagreen', -width => 2, -tags => ['hub'], ); $mw->bind('<B1-Motion>' => sub{ my $ev = $c->XEvent; &update_meter($ev->x,$ev->y); }); my $text = $c->createText( 100,50, -text => 180, -font => 'medium', -fill => 'yellow', -anchor => 's', -tags => ['text'] ); $c->raise('needle','text'); $c->raise('hub','needle'); MainLoop; sub update_meter { my($x,$y) = @_; # transform coords center to 100,100 $x = $x - 100; $y = 100 - $y; my $cos = $x/($x**2 + $y**2)**(.5); my $sin = $y/($x**2 + $y**2)**(.5); my $x1 = 100.0 + 90.0 * $cos; my $y1 = 100.0 - 90.0 * $sin; $c->coords('needle', 100,100, $x1, $y1); #see perldoc -f cos my $angle = sprintf('%.2d', 180 / 3.1416 * atan2( sqrt(1 - $cos * $ +cos), $cos )); if( $y < 0){ $angle = 359 - $angle } $c->itemconfigure($text,-text => $angle); }
|
|---|