5. Adding a GUI with Tcl/Tk

Tcl/Tk is the most convenient way to create GUIs that will work on both Windows and Linux. Even if you only use one system, you will benefit from the fact that Tcl/Tk is quite easy to learn and used by a lot of people. The particular mix of Tcl/Tk and C that we recommend here was the best solution we found; if you know of other ways to do it, let us know!

Now, take a look at ssc-tester.tcl. This program is very simple: it contains a loop that runs 16 times to create sixteen sliders, one for each of the servos that can be controlled by the servo controller. The critical command is

    scale .servo$i.scale -width 20 -length 200 -orient vertical
      -from 500 -to 5500 -command "stepTo 0 $i " -showvalue 0

This creates a slider with values from 500 to 5500, so that whenever you adjust the slider, the command

stepTo 0 slider position

will be run, with slider and position replaced by the slider number and position. This command is defined in ssctester.c by the line

  Tcl_CreateObjCommand(interp, "stepTo", &stepToProc, NULL, NULL);

The arguments are interpreted by the C function stepToProc and passed on to stepTo in ssc.c, where they are translated into commands to be sent to the serial port. When modifying the program for your own purposes, you will need to find the documentation for both commands in the Tcl/Tk language and special C functions used for interacting with Tcl. The Tcl/Tk manual will probably be your most useful reference.

New Products

Glideforce GF01-121005-2-66 Micro Linear Actuator with Feedback Potentiometer: 12V, 4.3kgf, 17.6mm/s, 50mm Stroke
Pololu Basic 2-Channel SPDT Relay Carrier with 12VDC Relays, Terminal Blocks, and JST SH-Style Top-Entry Connector
MPQ6612A Single Brushed DC Motor Driver Carrier (Soldered Connectors)
ACS37042KLHBLT-010B5 Current Sensor Micro Carrier -10A to +10A, 5V
ACS37200LLXTR-200B3 Current Sensor Compact Carrier -200A to +200A, 3.3V
ISO6541 4-Channel Digital Isolator Carrier, 3/1, Default High, Functional Isolation
ACS37100LMATR-025B3 TMR Current Sensor Compact Carrier -25A to +25A, 3.3V
Pololu Reverse Voltage Protector, 4-75V, 8A
Pololu Reverse Voltage Protector, 4-75V, 17A
QTRX-MD-01RC-S Reflectance Sensor: 1-Channel, 8mm Wide, RC Output, Low Current, Side-Entry Connector
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors