AnsweredAssumed Answered

VRF-Array_Plots

Question asked by VRFuser on Apr 25, 1998
send q VRF-Array_Plots ww vrf

from: Greg Goebel / HP-MXD
      gvg@lvld.hp.com / 800-452-4844
      website:  ftp://fcext3.external.hp.com/dist/mxd/index.html
to:   VRF -- Dr. David Holder
date: Sunday, 26 April 1998 1241 MDT

Sir:

I am not sure what problem you are seeing ... if you push 16 traces into a
an XY Chart, they should all show up. 

Possibly this is a sequencing problem?  This can be tricky and here's what
I did about that in another case:

--------------------------------- cut here ----------------------------------



[17.1] DISPLAYING SEQUENTIAL TRACES

* One of our people in Singapore had a customer who wanted to display a
sequence of waveforms on a single display, adding them one at a time.  I
wrote an example program for him that will display up to three waveforms,
but could easily be redesigned to handle more.

The problem is that an XY Trace object cannot be dynamically configured to
display different numbers of traces -- you set it up to display three traces,
it must be given three waveforms.  The trick to make it display different
numbers of waveforms -- one, two, or three -- is to provide additional dummy
waveforms that simply show up as a straight line in order to ensure that the
total number of waveforms given to the XY Trace object is always three.

The unused traces show up as a colored line in the middle of the display, but
this is not much of a nuisance (it's not so different from what you would get
on a multi-channel oscilloscope display).  The user can specify an offset
to allow the traces to be separated (or not) on the display.

    +-----------------------------------------------+
    | Main                                          |
    +-----------------------------------------------+
    |   +--------+                                  |
    |   | OffSet |                                  |
    |   +--------+                                  |
    |   | 2      |                   [ New Trace ]  |
    |   +--------+                                  |
    | +-------------------------------------------+ |
    | |                  XY Trace                 | |
    | +-------------------------------------------+ |
    | |                                           | |
    | |                                  x        | |
    | | x    x x               x x     x   x  x   | |
    | |  x  x    x     x x   x     x x      x   x | |
    | |    x       x x     x                      | |
    | |                                           | |
    | |                                           | |
    | |  +         +  +           +            +  | |
    | | + +      +     +  + +   +   + +    + +    | |
    | |     + +               +        + +        | |
    | |                                           | |
    | |                                           | |
    | |    *               * *           *    * * | |
    | |  *   *    *  *        *        *  * *     | |
    | | *      *        *       * *  *            | |
    | |                             *             | |
    | +-------------------------------------------+ |
    |                    [ Exit ]                   |
    +-----------------------------------------------+

There are a few restrictions in this example, however.  First, you can only
add waveforms; you cannot subtract them.  Second, all the waveforms must have
the same number of points (though this is likely to be the case in practice
anyway).

The implementation is a little tricky.  I wasn't able to think of a good way
to store the different waveforms in a single data structure, so each gets its
own global variable.  Another tricky feature is that the routines don't know
how big the waveforms are going to be until they get the first one.

The program is based on three UserFunctions:

  % ShowTrace:    Display all the waveforms.
  % InitTrace:    Initialize the first waveform.
  % AddTrace:     Add the following waveforms.

In practice, all the user has to do is specify the OffSet Value and initialize
the number of traces (Ntrace) to 0, and then call ShowTrace to display the
traces:

     +---------+    +---------------+
     | OffSet  |    | Set Variable  |
     +---------+    +---------------+
     | 0       +--->|     OffSet    |
     +---------+    +-------+-------+
                            |
     +---------+    +-------+-------+
     | Integer |    | Set Variable  |
     +---------+    +---------------+
     | 0       +--->|     Ntrace    |
     +---------+    +-------+-------+
                            |
                        +---+---+
                        | Until |
                        | Break +---+
                        +---+---+   |
                            |       |
                        +---+---+   |
                     OK | Exit  |   |
                        +-------+   |
                                    |
                              +-----+-----+
                           OK | New Trace +--+
                              +-----------+  |
                                             |
                                       +-----+-----+
                                       |   Noise   |
                                       | Generator +--+
                                       +-----------+  |
                                                      |
      +-----------------------------------------------+
      |
      |                                    +-------------------------
      |                                    |                XY Trace
      |                                    +--------+----------------
      |                                    |        |
      |   +----------------+-------------->| Trace1 |
      +-->| Call Showtrace +--------+      |        |
          +----------------+---+    |      |        |
                               |    |      |        |
                               |    +----->| Trace2 |
                               |           |        |
                               |           |        |
                               |           |        |
                               +---------->| Trace3 |
                                           |        |
                                           |        |
                                      +--->| Auto   |
                                      |    | Scale  |
                                      |    |        |
                                      |    +--------+--------------+--
                                      |                            |
                                      +----------------------------+

ShowTrace in turn will determine if no traces have been displayed -- and
call InitTrace -- or if there have been other traces displayed -- and call
AddTrace.  It then returns the values of all three of the waveform global
variables:

         +---------------------------------------------+
         |                  Formula                    |
         +---------------------------------------------+
    A -->|( Ntrace == 0 ? InitTrace(A) : AddTrace(A) ) |
         +---------------------+-----------------------+
                               |
                       +-------+-------+
                       | Get Variable  |   USERFUNCTION SHOWTRACE
                       +---------------+
                       |    Trace1     +----------------------> Trace1
                       +-------+-------+
                               |
                       +-------+-------+
                       | Get Variable  |
                       +---------------+
                       |    Trace2     +----------------------> Trace2
                       +-------+-------+
                               |
                       +-------+-------+
                       | Get Variable  |
                       +---------------+
                       |    Trace3     +----------------------> Trace3
                       +---------------+

InitTrace loads the initial waveform into its global variable, increments
Ntrace, then walks through a count to initialize the other two global
variables to dummy waveforms:

                                               +--------------+
                   USERFUNCTION INIT           | Set Variable |
                                               +--------------+
         +------------------------------------>|    Trace1    |
         |                                     +-------+------+
         |                                             |
         |                                     +-------+------+
         |                                     |   Formula    |
  wave --+----------+                          +--------------+
         |          |                          | Ntrace = 1   |      
         |  +-------+-------+                  +--------------+
         |  | For Count: 2  +---+   
         |  +---------------+   |      +----------------------+
         |                      |      |        Formula       |
         |  +---------+---------+      +----------------------+    build
         |  |         |            +-->| ramp(totsize(A),0,0) +--+ dummy
         |  |         |            |   +----------------------+  | data
         |  |         |            |                             |
         |  |         |            |  +--------------------------+
         |  |         |            |  |                          
         |  |   +-----+----+ array |  |   +----------+
         +--|-->| UnBuild  +-------+  +-->|  Build   +--+ dummy
            |   | Waveform +------------->| Waveform |  | waveform
            |   +----------+ time         +----------+  |
            |                                           |
            |   +---------------------------------------+
            |   |
            |   |  +-----------------+      +--------------+
            |   |  |  Demultiplexer  |      | Set Variable |
            |   |  +------+-+--------+      +--------------+
            |   +->| Data | | Addr 0 +----->|    Trace2    |
            +----->| Addr | | Addr 1 +--+   +--------------+
                   +------+-+--------+  |
                                        |   +--------------+
                                        |   | Set Variable |
                                        |   +--------------+
                                        +-->|    Trace3    |
                                            +--------------+

AddTrace routes the waveform (with the OffSet added) to its appropriate
global variable and increments Ntrace:

              +---------------------+        USERFUNCTION ADDTRACE
              |       Formula       |
              +---------------------+  
          +-->| A + OffSet * Ntrace +--+ input waveform plus offset
          |   +---------------------+  |
          |                            |
          |                   +--------+
          |                   |
          |                   |  +---------------+      +--------------+
          |   +------------+  |  | Demultiplexer |      | Set Variable |
          |   |  Formula   |  |  +------+--------+      +--------------+
          |   +------------+  +->| Data | Addr 0 +----->|    Trace2    |
  wave ---+-->| Ntrace - 1 +---->| Addr | Addr 1 +--+   +--------------+
              +------------+     +------+--------+  |
            specify trace to set        |           |   +--------------+
                                        |           |   | Set Variable |
                                        |           |   +--------------+
                                        |           +-->|    Trace3    |
                                        |               +--------------+
                             +----------+----------+
                             |       Formula       |
                             +---------------------+
                             | Ntrace = Ntrace + 1 | increment trace count
                             +---------------------+

Note that this example doesn't have provisions for clearing the traces or
preventing the user from adding one trace too many.  Such features would have
made the program harder to understand but can be easily added by the user.

This example program is available as xmtrace.vee.

[<>]

Outcomes