If I was to setup something like this from scratch, meaning not using other people's kits or whatever; and if you really want to keep computer control in a central location, like a laptop; I would look to get a USB breadboard

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); }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: Perl Code To Control Industrial Applications? by zentara
in thread Perl Code To Control Industrial Applications? by jdlev

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.