Sample for Data Plotting
Home ] Up ] General Use Interface ] Logged Dump w/Request ] StampPlot Activity Board Sample ] StampPlot Web Page ] Javelin-StampPlot1 Object ] [ Sample for Data Plotting ]

 

This sample is in response to a user's question.

Hi, I am using StampPlot Pro version 3 release 5 and can not find the answers to the  following questions.
1) I am plotting 2 analog values and would like the first trace to be black (both the data points and the
line connecting the data points) and the second trace to be red, how can I do this?
2) How do you plot just the data points without the line connecting the data points?
 

Note: Portions of this sample assume the user is using at least Version 3 Release 5 and all discussions may not work properly without it.

There are multiple ways to produce the effect you desire, though they all entail using the incoming data in other-than standard plotting fashion.  Though the use of the ACHN and FCIR instructions, incoming data may represented as you specify. 

Template for Analog Channel Instruction:
!ACHN ch_num, Value, Color
Where Ch_num is 0 to 9, value is the value to be plotted, Color may be 0-15, a macro value such as (RED) or (BLACK), or a hexadecimal value 000000 to FFFFFF (6 characters required even with leading zeros.
!ACHN 0,10,(BLACK)
!ACHN 1,20,(RED)

Template for Filled Circle instruction:
!FCIR X,Y,Raduis,Color
Where X and Y are the plot coordinates, Radius can be relative to coordinates or absolute and independent of coordinates by suffixing with 'a' such as 10a.  Color is the the same as for ACHN.  If you wish to have X coordinate be based on time, use the PTIME macro value.
!FCIR (PTIME),10, 0.3a,(BLUE)

Sending String from Controller
One way would be to send a formatted string from the controller to StampPlot, such as with PBASIC and the BASIC Stamp:
DEBUG "!ACHN 0,", DEC Val1, ",(BLACK)",CR
DEBUG "!ACHN 1,", DEC Val2, ",(RED)",CR
DEBUG "!FCIR (PTIME),", DEC Val3, ",0.3a,(BLUE)",CR

Creating a Macro

Assuming only can or want to send values, another way would be to create a small macro, or text script, to accept and plot the data.  By having StampPlot use the analog data for a macro only (!USEA ON), it can be manipulated prior to being plotted.  As data arrives, it is placed into macro values AINVAL0 to AINVAL9 (and on up to 50) for use in macros.

Sending the data:
DEBUG DEC Val1,",", DEC Val2,",", DEC Val3,CR 

Writing the macro:
From the StampPlot menu, select Macro->Open Macro with NotePad.
Enter the name for a non-existent macro and open for editing.
Enter:

INIT:
' Set this as default macro
!DEFS (ME)
' Clear all plot objects
'POBJ Clear
' Start new plot
!NEWP
' Use analog data for macro only - Don't plot normally
!USEA ON
' Use Default macro - Ran when data arrives
!USED ON
' Reset plot
!RSET
ENDMAC

Default:
!ACHN 0,(AINVAL0),(BLACK)
!ACHN 1,(AINVAL1),(RED)
!FCIR (PTIME),(AINVAL2),0.3a,(BLUE)
ENDMAC

Save the macro, run it (Macro--> Run Macro), connect and plot.

Using the Developer's Licensed Object Editor:

Using the plot object editor and builder, the oAnalog routine may be set to run the appropriate script when analog data arrives, and the object editor can build the macro file required.

Using the Calculation and Plotting control

The new Calc-N-Plot control can be used to plot this data as desired.

bulletStart StampPlot and select the Calc-N-Plot example.
bulletSelect "Clear All" on control.
bulletConfigure Plot 0 as follows (actually, by default it is fine), enable and set:


bulletConfigure Plot 1 as follow, enable and set:


bulletConfigure Plot 2 as follows, enable and set:

bulletRescale plot area to desired.
bulletUse the lower-right hand area to save the configuration.
bulletConnect and plot.

With a developer's license, the additional plots may be deleted, the main plot area resized, and the calc-n-plot control made not-visible if desired.  A macro configuration of this may then be built to be re-opened or distributed.