bwise applications and examples

Difference between version 52 and 53 - Previous - Next
By [Theo Verelst]

This page refers to [bwise], which can be downloaded via [Bwise - a graphical programming setup] and more recent versions (see [bwise] page).

Pages making use of the bwise package/library/application (new page probably will appear at the bottom):

   * [bwise]  Main simple examples and list of commands.
   * [Bwise - a graphical programming setup]  Short description.
   * [bwise applications and examples]  This page.
   * [Bwise version 0.34, all in one file, 8.4 compatible]  Download page (currently the latest version, all in just one file).
   * [some of the rationale behind bwise]  Where the ideas come from, and what the logic of the thinking behind doing this project is.
   * [Interactive Polygon in Bwise]  A graphics example.
   * [distributed linked bwise]  A multiple machine connection setup using bwise graph representations.
   * [C compiled image processing on an interactive Bwise canvas]  Calling the C compiler from a block, creating an image with the resulting program, and displaying it on the bwise canvas.
   * [process and stream based bwise blocks]  In builtup.
   * [A grep-like utility]  Part of bwise, just like 'l' for ls -F like command.
   * [A little multiplication toy]  Bwise in 'model view controller' type example (halfway page).
   * [Recursing Eliza] continued from [A simple version of Eliza]  A fun example of blocks supposedly communicating in human language, examplifies the thoughts and counterthoughts when making blocks communicate.
   * [Boolean Logic]  Halfway page a binary decoder in basic ports modeled with bwise.
   * [Little Circular Networks in Tcl]  A digital memory cell explained using bwise.
   * [Bwise for Presentation]  A presentation extension: read a simple textfile which overlays a bwise canvas per section under function key control, has been used in practiceon conference, easy to update text for.
   * [Automatically generate Bwise blocks from procedures]  Make any procedure a bwise block with the click of a button, giving the block pins according to the procedure arguments, and automatically supplying the blockfunction code.
   * [interactive command composer]  An extension to the bwise function window to not just list and edit, but also invoke procedures, with GUI support for argument setting.
   * [Line Plane intersection computation in Bwise]  A mathematical concept explained with a bwise drawing (in fact a first version, it's not interactive).
   * [simulating latch behaviour in Bwise]  An important digital  computer hardware basic unit as a simulatable block in bwise. Also, this page contains a bwise driving construction of a 7 segment display unit, and bit pattern-on-bwise-block diplay and click-editing.
   * [Traveling Salesman Problem]  Where I used bwise to make a circle of blocks with complete connectivity arranged to show all possible paths in a network, which is a problem which grows in complexity very quickly with increasing number of blocks.
   * [Tcl/Tk on Xwindows emulation on XP using Cygwin]  Contains a screen dump (in low Q) of bwise in use under X window simulator on windows XP.
   * [Webserver combined with bwise]  Speaks for itself, this is a simple example where tclhttps activates a chain of bwise blocks to generate a web page which is fed to the browser.
   * [automatically generating socket based Tcl / C connection code, 2, using bwise]  A C program talking to a tcl script of which the interface is automatically generated, and most of the process done as bwise block-chain.
   * [The BWise drum subwindow and driving a C-code sample processor program]  The C program can render tuned samples into a combined mix, applied to drum samples it is driven by the bwise Drum block to automatically create rythm patterns.
   * [Vector rotations with Bwise]  Vector in --> rotate --> vector out, as bwise blocks, extended with rotation angle sliders coupled with the bwise blocks, and a graphical 2D vector display block
   * [Database access for options of all widgets in an application with Bwise]  Access and store widget configurations with the bwise (simple) database procedures.
   * [Webserver with in core database from BWise]  A seemingly more complicated example with the database from bwise with images in it coupled with tclhttpd, not using the bwise canvas itself.
   * [Bwise deCasteljau algorithm example]  Bezier subdivision examplified on an interactive bwise canvas with curve and (working) subdivide block graph.
   * [Saving Bwise widgets on the canvas]  actually part of an extension: saving Entry and Mon blocks on a canvas (not YET term and shell).
   * [Gimp driving with BWise] Describes for the moment an example which lets bwise control the well known Gimp (2.0) drawing program: a block per drawing operation.
   * [BWise block coordinate extraction] An example of how the bwise blocks are used on the canvas, in this case only to get the coordinates from a displaced block.
   * [A Delay Block in Bwise] simply a block which delays the incoming data, maybe I'll throw in a delay line of arbitrary length and some more stuff.
   * [BWise functional graphs] analysing, dealing with, evaluating and tracing networks made of nodes which can be seen as implementing nested function calls.
   * [Bwise combined with Maxima] A daring combination which is starting to work.
   * [Bwise blocks using exec maxima] A simple enough way to do mathematics in bwise using [maxima] for any number of blocks, which however requires exec-ing maxima per invokation of the block.
   * [Starting Bwise as Application] a startup script for setting windows to a prefixed position, and considerations about various OS-es and other startup stuff can be added.
   * [Bwise traffic lights with challenges] Adds a block generator (with the simple popup menu instantiation) for a traffic light block. It responds to messages red green and orange, and I'm making some programming/process challanges with this idea.
   * [Sine wave roundings illustrated with BWise] x and y quantisation, linear interpolation effects as graph on canvas, doesn't require bwise at the moment.
   * [Making mathematical waves] Make and render mathematical formulea, possibly represented by BWise blocks, and make wav files of them to listen to or use in a synthesizer (-program).
   * [Clock divider BWise example] An example bwise canvas which shows a graph to frequency divide a clock signal
   * [Playing with Bwise and a ethernet connected FPGA] to use a 10 input and output bwise block which actually runs in hardware and can be used interactively.
   * [Creating wave formulas with BWise]  Using the principle from mathematical waves page above to create sound synthesis programs from connecting bwise mathematical blocks.
   * [Network Theoretical Elements in Bwise] Graphical blocks of elements like resistors, sources, and such on the bwise canvas.
   * [constructing mathematical formulas with Bwise blocks] Blocks as formula elements combined by bwise network connections
   * [constructing a bwise graph from a formula] formula in --> bwise graph out
   * [bwise 3D graphics viewer block] really! Requires tcl3d, isn't all finished but works.
   * [Wave player for formulas from BWise and Maxima on Windows XP] The same as [Making mathematical waves], but on windows XP.
   * [Creating arrays of wave formulas with BWise] Complicated wave formulas by repeating connected graph elements.
   * [A musical keyboard for BWise and Midi connections] keyboard drawn by {RS} on th bwise canvas.
   * [Bwise, a serial port tcl script and a Xilinx demo board] connecting Bwise with programmable hardware.
   * [Linking Bwise with PostgreSql] that is supposed to be an interesting combination.
   * [Manipulating Jack/Ladspa Audio processing graphs from Bwise] Creating them, first of all, using jack-rack blocks, by forming a jack-audio startup script for Linux machines
   * [Reading Carla patchbay into BWise blocks and Tcldot] A (for me, anyway) very serious [Signal Processing] related application of block wise design of a graph representing a streaming audio application with fixed delays   * [Bwise blocks connecting FPGA accelerated C functions] Page in build up

Most pages come with images/window dumps.

I've changed the place of this list from [distributed linked bwise].

Feel free to add bwise uses of your own, its all free and open source at the moment, so why hold back...

----

[Image TV Diary flipflop1.jpg]
See this list of my diary pages [http://theover.tripod.com/Diary/diarlin.html] and more recently the
local diary pages (on a secure tclhttpd based server)
[http://www.theover.org/Diary]
(this [http://www.theover.org/Diary/ldiary7.html] is a recent one with pictures), while this one contains Bwise:

 http://www.theover.org//Diary/ldiary6.html#bwise.

I'll start making a list of bwise examples and applications, the first being shown above as an important gedanken experiment. Don't think eigenvalues here, we're not getting into that now. Here we do that: [eigenvalues and electronics]

I made a generator block for AND gate blocks on the bwise canvas, which is a block that generates new blocks when it is fired (Eval-ed). This is the command (can be executed on the console or a bwise shell) for making the generator block:

 set n 1;
 newproc "newproc \"set proc\${genproc.n}.q \\\[expr !(\\\${proc\${genproc.n}.a} && \\\${proc\${genproc.n}.b})\\\]\" proc\${genproc.n} {a b} q  ;set genproc.nlast \${genproc.n}" genproc n nlast

Which (evaluated but not executed ends up in the genproc.bfunc as:

 newproc "set proc${genproc.n}.q \[expr !(\${proc${genproc.n}.a} && \${proc${genproc.n}.b})\]" proc${genproc.n} {a b} q  ;set genproc.nlast ${genproc.n}

Which can also be seen here:

[Image TV Diary genproc1.jpg]

The proc1 and proc2 blocks were made by executing 'funprop' from the block menu (middle mouse button on the yellow part of a block), which evaluates the block, passes the current proc index from genproc.nlast to tcl variable Proc1.in, evaluates the Proc1 block function that is stored in tcl variable Proc1.bfunc, which sets Proc1.out to one higher, and finally transfers this values to genproc.n, at which point the funprop functional propagator function stops because it detects it is back where it started.

Of course more basic circuits with [nand] circuits can be made, such as just one, for instance with an alarm sensor at the door and a window, issueing a 1 when the door or window is open, and 0 otherwise, and a buzzer or siren or silent alarm connected to the output. For that, one would need to read signals from the outside world, and one would have to periodically or when one or more of those signals changes values, recompute the outcome of the AND function, and trigger following blocks dealing with the new alarm state. Of course simply filling in values in the infowindow (use the data popup menu on the and block)

One may want to arm or disable the alarm, or one of the inputs by using another and. At this terminal, I don't have bwise running, so the connections are left as an exercise to the reader.


----

As an illustration of the problems that also occur in let's call it real life large scale networks, when they are supposed to aid in the computation of things in which real people have interest, let's use the bwise 0.3 supplied procedure

 newarray 5 5

which generates an array of blocks with two inputs and a certain interconnection pattern, which basically concatenates the two inputs to the output.

I added a term (inal) block to generate input and read output from the block array, and which allows one to press a button or <return> to start a funprop (functional propagate), "firing" each block as its inputs become available from previous blocks.

[Image TV Diary array55.jpg]

- ''Canvas after creating an array, a terminal and a shell'' -

Look at the firing pattern to understand how computation possibility numbers increase first when block connection patterns widen, and in the end narrow down until the final block is reached.

The reverse case, where first information is gathered to one central block, and then expands into many others depending on it is also thinkable, hang on, I'll cut and paste a bwise net for it when I made an example.

The array doesn't do anything particularly useful at the moment, but it could for instance do image processing (where the links indicate neighbouring communication in 2D), or stand for steps in a matrix multiplication or what else there is. One could also process a list in a piecewise way.

----
'''Simple applications'''

[Image Bwise bwiseanis.gif]
Make this graph by using the middle (or right) mouse button on the gray canvas to make a proc, and entry and a monitor.

The wires can be connected by clicking on the pins with the left mouse button to make them green. When two pins are green, press the button on top the canvas names ''Wire'' in green, to make a wire between the green pins.

Then select the next two pins and connect them, until the whole diagram is made.

Now put the cursor in the block called Entry, and type some symbols, numbers or text, and press return, or use the middle mouse button on the small yellow part of the entry block to get a popup menu and select 'funprop'.

Depending on the speed of your machine, and the OS of your choice, the blocks will fire in order quite quickly or invisibly quickly, turning the pins where data passes green shortly.

The things you typed in the entry block will appear in the mon block unchanged.

To 'do something' with the data you typed in, you can use the menu on the proc block block which is called 'data' to open a window with entries for each of the variables associated with the proc block, which includes the pins (in and out), and the procXX.bfunc variable.

That variable contains the function (procedure, or simply some tcl(/tk) commands) which is executed when the block is 'fired', that is when it is activated because it has its inputs available during a 'funprop' invokation for instance.

Pressing the 'eval' button in the data window also effectively fires the block, that is the variable starting with the block name and ending with .bfunc is taken to contain a tcl command which is executed. One may want to call a procedure here, or simply put in the tcl code which is needed directy.

In principle, one could even call another bwise network activity, which is rather intricate without clear rules, though.

Say we change the function associated with proc1 to

 set proc1.out [expr $proc1.in + 1]

that wouldn't work, but

 set proc1.out [expr ${proc1.in} + 1]

would as is to be expected generate a number at the output pin and associated variable of the block which has a numerical value of one higher than the supplied input number.

Feeding the block with a non-numerical value will generate an error, which however is not desastrous, as it could be in after scripts calling each other.

----

More Pages on Bwise programming:

   * [Traveling Salesman Problem]

----
[Lars H] (4 Jun 2003): I think the text between the last two divider lines well illustrate a problem with some of the pages you create, [TV]
-- '''the title does not match the contents.'''
They often start out with some important general thingie in computer science that more or less matches the title, but then they quickly digress into discussions of fairly low-level electronics only vaguely connected to the matter suggested by the title. Such a specialized point of view might be appropriate on an "Electronics Wiki", but as this is [The Tcler's Wiki] it just makes everything look very off-topic and thus uninteresting.

All is not lost, however, since rather small modifications of the titles can make the contents seem much more appropriate. For example, had the above [Traveling Salesman Problem] page instead been named [Bwise Traveling Salesman Problem] then the point of view would be explained in the title. [eigenvalues and electronics] is another page with a curious title that comes to mind. While there is no Web interface for renaming Wiki pages, it is fairly simply to copy the contents of one page to a new page with the new name if one has two browser windows open simultaneously.
----
[TV] The point is that the popularity of tcl (/tk) and maybe some of the reason that it is not so well spread as it could be IS illustrated quite well by these examples. The 'put things on a canvas'approach from above is, just like examples on the last tcl conference, a god way to make clear what one actually does while programming complicated things, which are not always programmed all too well, in contemporary software often very big and inefficient, and these type of pages show why, for the bit over average intelligent reader with some software background (I hope).

So VERY much a tcl issue.

The language comes from designing chip layouts, I even seem to recall.

The eigenvalues page is about the issue of objects sending each other messages.

This is not a new problem. In fact, in electronics the differential equations for two parts of a very basic circuit which also for tcl is the physical foundation of memory do the same, and consistently so for a continuous problem. So if one wants to illustrate that the message sending in many OO extensions (which can be fine to use) can be seen in certain ways much more advanced and secure than the usually very undocumented software X or Y (in that sense), electronics of a simple two functions connected together is a nice and relevant example.

Also, in most programs, also OO ones, the programming type is essentially very much like a functional decomposition, which is also a recurrent theme in this tcl wiki, and important. Two simple functions, as part of an object method, connecting up as on the example [bwise] diagram, form a memory loop.

Very relevant example. Prevents bugs and conceptual errors. And bwise is written in tcl/tk and a good discussion vehicle. im(nsh)o..

<<categories>> Bwise