ioshow.tcl




List

I did a little fiddling with Fred's ioshow code and Dan will soon place the
result in the dropbox. (my success rate is real low)

This TclTk file is intended to be a script to run alongside tkemc.  If you
are using the new tkemc with a script menu, you can move this file into
your scripts directory and access it from that menu.

It will run with iosh alone.  You may need to fix the reference to the
location of iosh in its third line.  

This ioshow window watches the output pins of either 0x278 or 0x378
parallel port and reports low and high voltage states by changing the color
of the virtual led's.  

If you are running steppers from a parallel port you will not always see
the steps but you can see the direction signals.  The reason for this is
that ioshow is running at a fixed rate and only shows the stepper pulse
when its rate is coincident with the stepper pulse rate.  (Moire or
interference pattern) 

Ray

----cut and paste copy of ioshow.tcl starts on the line below----
#!/bin/sh
# the next line restarts using emcsh \
exec plat/linux_2_0_36/bin/iosh "$0" "$-at-"

# TclTk script for tkemc gui

# Notes
# This script presents a canvas with i/o condition displays
# Based on a Fred Proctor post to emc-at-nist.gov 
# 

wm title . "IO"
global array buffer

# create the main window top frame
set top [frame .ioshow]
pack $top
 
message $top.message1 \
   -text "Shows the condition of parallel port pins." \
   -justify center

set address 0x378

radiobutton $top.radio1 -text 0x378 -variable address -value 0x378 \
    -relief groove -command compute
radiobutton $top.radio2 -text 0x278 -variable address -value 0x278 \
    -relief groove -command compute
 
button $top.button1 -bg darkgray\
    -font {Helvetica -12 bold} -text CANCEL -command {destroy .} 
set c [canvas $top.canvas]
$c configure -height 190 -width 100
pack $top.message1 $top.radio1 $top.radio2 $c $top.button1 \
    -side top -fill x

for {set i 0} {$i < 12} {incr i 1} {
    $c create oval 5 [expr $i * 15 + 5] 15 [expr $i * 15 + 15] \
    -fill green
}

for {set i 0} {$i < 5} {incr i 1} {
    $c create oval 45 [expr $i * 15 + 5] 55 [expr $i * 15 + 15] \
    -fill green
}

for {set i 0} {$i < 12} {incr i 1} {
    $c create text 25 [expr $i * 15 + 10] -text $i
}

for {set i 0} {$i < 5} {incr i 1} {
    $c create text 65 [expr $i * 15 + 10] -text $i
}

proc compute {} {
    global address buffer
    if {$address == 0x278} {
        set buffer(1) 0x278
        set buffer(2) 0x27A
        set buffer(3) 0x279
    } elseif {$address == 0x378} {
        set buffer(1) 0x378
        set buffer(2) 0x37A
        set buffer(3) 0x379
    } else {
        set address "HUH? 0x378 or 0x278"
    }
}

compute

# 'update' updates the dynamic value repeatedly
proc update {} {
    global c address buffer 

    set value1 [inb $buffer(1)]
    set value2 [inb $buffer(2)]
    set value3 [inb $buffer(3)]
    set value3 [expr $value3 >> 3]

    for {set i 1} {$i <= 8} {incr i 1} {
	if {$value1 % 2} {
	    $c itemconfigure $i -fill red
	} else {
	    $c itemconfigure $i -fill green
	}
	set value1 [expr $value1 / 2]
    }

    for {set i 9} {$i <= 12} {incr i 1} {
	if {$value2 % 2} {
	    $c itemconfigure $i -fill red
	} else {
	    $c itemconfigure $i -fill green
	}
	set value2 [expr $value2 / 2]
    }

    for {set i 13} {$i <= 17} {incr i 1} {
	if {$value3 % 2} {
	    $c itemconfigure $i -fill red
	} else {
	    $c itemconfigure $i -fill green
	}
	set value3 [expr $value3 / 2]
    }

    # schedule this again
    after 100 update
}

# start it
update






Date Index | Thread Index | Back to archive index | Back to Mailing List Page

Problems or questions? Contact