proc disnum { {n} } { # the numbers 0-9 in the coding for how I connected up the segments to the bits set dis {192 252 146 152 172 137 129 220 128 136} set a [string index $n end-2] set b [string index $n end-1] set c [string index $n end] # 'open' our control register lpt_wrctrl 0 # select the rightmost display unit to become active lpt_wrdata 32 # 'open' the display channel(s) lpt_wrctrl 1 # figure out but pattern for the rightmost digit if {$c=={}} { set o 255 } { set o [lindex $dis $c] } # And write it to the display memory lpt_wrdata $o lpt_wrctrl 0 lpt_wrdata 64 lpt_wrctrl 1 if {$b=={}} { set o 255 } { set o [lindex $dis $b] } lpt_wrdata $o lpt_wrctrl 0 lpt_wrdata 128 lpt_wrctrl 1 if {$a=={}} { set o 255 } { set o [lindex $dis $a] } lpt_wrdata $o } # count from 0 to 999 in 100 seconds: proc disnumat {t} { global n; disnum $n ; incr n; if {$n < 1000} { after $t "disnumat $t" } } # start at zero: set n 0 # and count up every 10th second! disnumat 100Works perfectly neat.
TV (14 Dec 2003) For those interested in the workings of the circuit, I'm starting a page on simulating latch behaviour in Bwise where also the actual circuits can be driven over bwise blocks as a simulation of the hardware in the longer run.
TV (sept 9 '05) I've lately been using programmable logic for which the following VHDL (see VHDL and Tcl page code would decode a 4 bits code to 7 segment data, except the elements are shifted and one order is different, this is for the FPGA (Xilinx/Digilent) demo board displays:
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; -- Uncomment the following lines to use the declarations that are -- provided for instantiating Xilinx primitive components. --library UNISIM; --use UNISIM.VComponents.all; entity display3 is Port ( hex : in std_logic_vector(3 downto 0); segments : out std_logic_vector(7 downto 0)); end display3; architecture Behavioral of display3 is begin with hex SELect segments <= "00000110" when "0001", --1 "01011011" when "0010", --2 "01001111" when "0011", --3 "01100110" when "0100", --4 "01101101" when "0101", --5 "01111101" when "0110", --6 "00000111" when "0111", --7 "01111111" when "1000", --8 "01100111" when "1001", --9 "01110111" when "1010", --A "01111100" when "1011", --b "00111001" when "1100", --C "01011110" when "1101", --d "01111001" when "1110", --E "01110001" when "1111", --F "00111111" when others; --0 end Behavioral;Of course the comments are optional, and this kind of code can be automatically generated by tcl code, or lets say Bwise.I'll make a page on how to connect to hardware using the serial port connected with a fpga demo board to drive hardware in various ways, including displays via tcl commands. Lets see, I'll call it 'basic digital IO with tcl and Digilent FPGA board'
uh 13-Aug-05 - I'd like to use the LED display driven by the parallel port under tcl control. The problem is that i have no windows to test the given code and i have no clue how to *talk* to it under unix (NetBSD). I tryed:
set parport "/dev/lpt0" set pport [open $parport w]after a few seconds: couldn't open "/dev/lpt0": file busy while executing "open $parport w" invoked from within "set pport [open $parport w]" (file "./pp1.tcl" line 16)any ideas?Peter Newman 13 August 2005: As far as I know, every PC still has the system BIOS burnt into the motherboard. Which has standard (and well-documented, and easy to use,) APIs for accessing the serial and parallel, etc, ports. Accessing BIOS from DOS and assembler is a piece of cake. But I've no idea about how you do it from NetBSD. It must be possible though (surely). Even if you have to get a freeware DOS, and boot to it from a floppy.ECS 20050814: On linux, debian at least, the first parallel port is /dev/lp0. And check if you have permissions to access it. By default it is owned by root and group lp.
[morrongo] - 2011-02-04 10:45:31Did you remember to close the channel?