|
| |

The Calculation and Plotting (CnP) Control
provides an easy means of manipulating incoming real-time data and plotting in a
variety of ways, including relationships between data. The above plots were made
using data from a BASIC Stamp that counted from 0 to 255, and a count by 3's.
The code for data is below.
Using a StampPlot Developer's license, macros can
be developed using this control, and the control may be configured and set as
not-visible to allow it a perform operations and plotting for specific plot
uses.
The supplied example allows the saving and
loading of configurations locally to the running computer's registry.
General Discussion of Control:
 |
 | The 50 Functions, FUNC0 to FUNC49 can be named and
referenced by name. In this example FUNC2 is names SIN360AIN0. |
 | A function operator, such as SIN DEG, can be applied
to the parenthetical operation, then 2 more operations can be
performed on the result.
SIN360AIN = SIN DEG (360AIN + 0) + 0 x 100 + 0
360AIN is the name of another function. |
 | The calculation will be to 3 decimal places (DP) as
shown and on plot reset the value will
revert to the provided value for RST. |
 | This section also allows the use of IF-Then type
functions.

|
 | This section shows the results of the currently
selected function calculation, currently select plot configuration
(below) if enabled, and any function errors. Note that errors in
plotting are noted by StampPlot Debug window. |
 | Additionally, the "Func's" radio button
will show a list of all configured functions, and "Plots"
will show all configured plots. These may be copied and pasted
for easier reading.

|
 | In this section up to 25 plots configurations (PLOT0
to PLOT24) may be configured. Options include:
 | The friendly-name of the plot the user provides. |
 | If multiple plot controls are on StampPlot, a
choice of plot areas will be shown. |
 | The style of configuration, such as Normal (a
simple plotted value), Line, Circle, etc. |
 | Coordinates and other parameters. |
 | A color selector. |
 | Draw Mode: How the current color will interact
with current colors.
13 is normal, 9 gives a transparent effect, beyond that feel free
to experiment! |
 | Plot Mode: How the data from plotting will be
stored:
! = Stored normally, but kept within grid area.
^ = Stored normally, but all but "Normal" drawing can be
outside the grid area.
~ = Same as ^, but not saved for redrawing.
@ = Same as ^, but stored as a constant drawing and NOT cleared on
reset. To clear, use the !CLRC instruction. Only a limited
number of these can be used (1000). |
 | Enabling allows the plot configuration to be
performed each time the control is called.

|
|
 | The update section allows the to define when to run
the plot configuration:
 | On New Data, when the control is called: i.e. -
!O CnP |
 | Based on Time shown (.05 to 60). Note you
must TAB off time after setting. |
 | Reset Plot: Resets the plot prior to plotting a
new set. |
|
 | Clear All returns all functions and plot
configurations to default. |
 | ? Opens the help file for the control. |
|
Working with Function:
 |
There exists 50 function calculations
available on a control. When creating a function, provide it an
appropriate friendly-name and Set it to use. The general format of the
functions is:
func op(val1 op1 val2) op2 val3 op3 val4 such as:
SIN DEG (AINVAL0 x 100) + 50 / 2
Note the the order of operations is Parenthesis, Function operation (SIN
DEG), operation 2 (+50) operation 3 (/2). |
 |
Functions will be performed in ascending
order each time the control is ran by either calling it or by basing time
based on an update time. |
 |
Many common function operations are include:
SIN, COS, TAN, LOG, LN, ABS (absolute value), INT (Integer), 10^, e^.
Special cases are COLOR and IF described later. |
 |
Results of operations are stored as that
function name, by FUNC# or friendly-name. |
 |
For values, the user has a choice of:
 |
An entered numeric value. |
 |
AINVAL#, such as AINVAL1
When data is sent to StampPlot, such as 123,456, the 1st value is
referred to as AINVAL0 and the second as AINVAL2 and so on for each
comma-separated value. |
 |
FUNC#, such as the results of
FUNC4. |
 |
PASSED#, such as PASSED2
When the control is called, such as with !O CnP,
data may be optionally passed:
!O CnP.Set =10,20,30
Where the 1st value is PASSED0, 2nd is PASSED1 and so on. The
supplied sample does NOT pass any values. |
 |
A function-friendly name such as
SINAIN1. The drop-down box will be populated with all available.
Remember that functions are performed in ascending order. |
 |
Certain controls on the StampPlot
interface that can accept data from the user, such as drop-down boxes,
text boxes, sliders, etc. This provides and easy means of
accepting input from the user for calculations and plotting. The
supplied sample uses the slider under the control called 'Slider'.
Note that the drop-down function values will be populated with any
available controls. |
 |
Other StampPlot values may also be
used, such as PTIME (plot time), DATAVAL0 (the green text box near the
top of StampPlot) and any other values of interest. See the
StampPlot help files, Math Summary for a full list. |
 |
Note: The math functions do NOT use the
main StampPlot math capabilities and code such as [(AINVAL0),+,5] cannot
be used as it can be in normal StampPlot coding.
|
|
 |
Function values can be accessed by
other StampPlot code, such as !STAT (CnP.SINAIN1).
Note that it is accessed by the friendly-name, not the function
number. |
 |
The Color function coverts a value to
a 6-hex number (24 bit) which can be used in the Color parameter of the plot
controls. Colors are such that each 2 digits is the amount of Blue,
Green and Red from left to right such that &HFF0000 is all blue,
&H00FF00 is all green and &H0000FF is all red. |
 |
The IF Function sets a 1 or 0 (True or
False) as the value for the function and can be used to immediately set
another function value, run a plot configuration by name (which would
normally NOT be enabled), or to run StampPlot code such as : !STAT
(RTIME)(CR)!BELL |
 |
Coding of configurations for functions
is complex and should be handled by the macro builder available with the
developer's license. |
Working with Plot Configurations:
 |
There are 25 plot configurations (PLOT0
to PLOT24) that may be used and assigned friendly names. |
 |
An 'Enabled' plot is one which run each time
functions are calculated such as when the function is called on data
arrival. |
 |
When multiple plot areas are available on
screen, the "Plot to use:" drop-down will populated with
the choices. |
 |
A "Normal" plot
configuration is line plotting of a value. A channel between 0 to 9
must be selected, and normally each channel can only be used once, but
interesting effects can be obtained if re-used. |
 |
The remaining boxes will be populated with
friendly-names of functions, AINVAL#, FUNC#, PASSED#, and user-input type
controls in the StampPlot interface, and other StampPlot values may be used,
such as PTIME (time in seconds into the plot). StampPlot values do not
need to be in parenthesis unless modified using StampPlot math. |
 |
For more advanced use, StampPlot math CAN
be used in the various parameter boxes. For example [(AINVAL0),*,2]
would use AINVAL x 2. |
 |
Color can be a StampPlot color, such
as 0-15, StampPlot Values such as Red, Blue, a selected color selected using
the color selector box, or the results of a COLOR function. |
 |
From StampPlot code, a plot
configuration can be ran (one which would normally not be 'Enabled') by
calling the plot name.
!O CnP.MarkSin+Cos |
 |
PASSED Data refers to data sent when
the control is set or called, such as !O CnP=10,20,30
, but in the cases of plots, the data may be passed specifically sent for
that plot: !O CnP.PassedRect=10,20,100,100
Where 10 is PASSED0, 20 is PASSED1 and so on. |
 |
A plot may be enabled or disabled via
StampPlot code using the plot number (case sensitive): !O
CnP.PLOT7=1 |
 |
When plotting coordinated, widths, etc, one
appended with 'a' means to use absolute coordinates of the plot,
which is 0,0 to 100,100 irregardless of the X or Y axis settings. The
a can be appended to functions names such as myFunction
can use myFunctiona.
Other StampPlot values should use (AINVAL0)a and
so on. |
 |
Coding of configurations for plots is
complex and should be handled by the macro builder available with the
developer's license. |
Developers Notes for Making New Macros:
 |
Typically, Use Analog for Macros will be set
(!USEA ON). |
 |
To call the function when new analog data
arrives, the follwing code should be in oAnalog:
!POBJ CnP.set |
 |
To use the reset values for function when
StampPlot resets, the following code should be in oReset:
!POBJ CnP.Reset |
 |
Multiple Calc-n-plot controls may be used.
In our examples CnP was used as the object name. Be sure to use the
one assigned! |
 |
The speed of plotting is dependent on the
number of functions and plots assigned, they type of plotting, and the speed
of the computer. |
BASIC Stamp Code used for Sample Plot:
'{$STAMP BS2}
'{$PBASic 2.5}
X VAR Byte
Y VAR Byte
PAUSE 1000
DEBUG CR,"!RSET",CR
DO
FOR X = 0 TO 255
y = y + 3
DEBUG DEC x,",", DEC y,CR
'plot 0 to 255 and 0 to 255 by 3's
PAUSE 200
NEXT
LOOP
Look though each of the functions
and plot configurations with the installed example. Review this help files
to see how different features are used. Enable plots that are not enabled
to test them.
|