Interactive Control
Home ] Up ] Basic Concepts ] Serial Connection ] Plotting Basics ] Logging, Saving and Printing ] [ Interactive Control ] Macro Basics ] Macros - Default & Events ] Macro Math Discussion ] Defined Macro Buttons/Menus ] Drawing Basics ] Media and Paths ] Drawing Coordinate Modes ] Plot Objects ] Macro Editor ] Using Templates ] External Applications ] Historical/Logged Data ] Internet ] Binary and Special Data ]


StampPlot has a variety of means for interactive control from your controller or from within a macro.  After issuing the instruction, your micro simply needs to accept the returning value.  Example:
Using the Basic Stamp the SERIN instruction may be used:
SERIN pin, baudvalue, timeout, timeout label, [DEC variable]
 ' accepts data returning on the programming port at 9600 baud with a timeout of 1 second.
SERIN 16,84,1000,Timeout,[DEC x]
If you are using the programming port (P16), insert a 100mSec pause after the SERIN to allow the echo to clear.

bulletReading Values:

The !READ instruction can be sent from your controller to return a value from StampPlot on the serial port.  Any of the StampPlot values may be read and returned.
!READ (value)
Or, from the Stamp:
DEBUG "!READ (value)",CR

A value which you may want read is the number of seconds into the plot for example:
DEBUG "!READ (PTIME)",CR

StampPlot will return the number of seconds into the plot.

bulletReading Objects

Object can be treated the same as values.  For example, an text object is created and named txtVal.  To read the value of the object:
DEBUG "!READ (txtVal)",CR

Another object which is commonly read may be a slider, a check box, or an Image button.
DEBUG "!READ (sldVal)",CR

bulletValues, Objects and Math Pre-Processing:

Bracketed math may be used to inform StampPlot to to perform math operations on the data prior to sending it back serially.

DEBUG "!READ [(sldVal),/,2]",CR  'Returns the value of sldVal object/2

bulletData Values

Data Values are a special group of values.  Opening the Values Window is a tab called Data.  These are Data Values 0 - 9.  0 is also the duplicated as the green box at the top of the normal plot window.

The data values can be used for quick storage and interactivity since a user can simply type current data directly  The values are also represented by values DATAVAL0-9

Setting:
!SETD number, value
DEBUG "!SETD 1,", DEC Temp,CR

Labeling:
!LBLD value, Label
DEBUG "!LBLD 1,Temperature",CR

Reading:
!GETD number
!DEBUG "!GETD 1",CR
or
DEBUG "!READ (DATAVAL1)",CR

bulletRequesting Data through a pop-up

The Request data may be used to use a pop-up to request data input from the user.
REQD Default value, Time to display in seconds, Request String
DEBUG "!REQD 120,5,High Temp set point",CR

Note:  With the Basic Stamp, the SERIN must pause (timeout) until the user enters data or the pop-up times out to ensure it is ready to receive data.  This instruction should normally NOT be used in a macro.

From a macro (or controller), a value may also be requested and stored in a data marker.
MREQ default value, time to display in seconds, request string, data marker number
!MREQ 80,10,Lowest temperature,5
Stores the entered data into %m5, which may be read by the BS2 using:
DEBUG "!READ %m5",CR

A carriage return may be entered using \n and a tab may be entered using \t
!MREQ 80,10,Lowest temperature\n\tMin:80\n\tMax:100,5

bulletDisplaying a message box

A user message box may be displayed for information only.
!UMSG Time to display in seconds, String
!UMSG 10,The plot is complete


A carriage return may be entered using \n and a tab may be entered using \t
bulletStampPlot Initiating the Send

StampPlot may of course send data without being requested.  For buttons, timers, etc, simple use:
!SEND (value)
!SEND is processed in the exact same manner as !READ, but it makes more sense in code to have StampPlot !SEND and the controller !READ.

bulletReturning Binary Data

For controller which can send ASCII strings easily, but may have trouble accepting ASCII strings, the data may be returned as a byte value (0-255).
DEBUG "!BSND (value)",CR

Or, Macro Math may be used to convert a value to a character:
DEBUG "!READ [(value),CHR]",CR

bulletInteractive Notes:
To increase interactive data reliability, the following are suggested with the BASIC Stamp:
bulletIf possible, do NOT use the programming port (P16).  This port echoes data causing data glitches.  Much more reliable data can be exchanged using other Pins for serial I/O.  Please refer to your Stamp documentation.
bulletIf the programming port is used, allow a 100mSec pause typically following SERIN to allow echoes to clear.
bulletWhen Micro Echoes data is enabled (!ECHO ON/OFF) a string of |Q| is appended to all data sent to the micro to allow StampPlot to recognize and ignore echoed data.