* * * * * * * * * Help for flukecom Procomm Plus Macro, V1.2 * * * * * * * * * 

* * * * * * * * * * * * * * * Script control * * * * * * * * * * * * * * * * 

:                   COMMENT for any use you wish.

                    Please note that a space must be present between the
                    colon and the comment

beep                BEEPS on local machine only, does nothing else.

cd <directory>      CHANGES DIRECTORY so you can put files somewhere else.

clock <hr> <min>    WAITS FOR TIME to occur, specified in 24hr format.  Can
                    be terminated with <esc>.

clock+ <hr> <min>   like above only takes current time and adds an INCREMENT
                    TO THE CURRENT TIME

del <filespec>      DELETES file

dir <filespec>      LISTS FILES in directory, use *.* for all

edit <filespec>     invokes the DOS EDITOR

ifgoto <min> <max> [<count>]    Will GOTO STATEMENT FOLLOWING LOOP command
                                (default first line in file if loop not used)
                                if value of last 'read' is between the
                                min and max (inclusive).  In other words,
                                the jump will occur if min<=read<=max is true.

                                The optional count parameter will limit
                                the number of times the jump will be 
                                executed to that specified.

                                The zero command may be used to clear the
                                internal loop counter (is cleared at the
                                begining of every macro). 

                                This command only works for macros.

                                If a count of -1 is given, the counter will
                                not be updated, this is useful as shown in
                                examples.

                                A count of 0 will act as a placeholder
                                (see notes).

ifnotgoto <min> <max> [<count>] exactly like above only will JUMP ON THE
                                NOT of the condition above.  Therefore
                                read < min or read > max must be true.

init                            RESTARTS the script.

                                WARNING! This is like quiting the script
                                and starting up again.  All settings are
                                lost including status of last read
                                variable, current loop setting, and log
                                file turned on.

logon <filename>    WRITES all transactions to specified file.

logoff              STOPS logging.

loop                LABEL for ifgoto, ifnotgoto (defaults to top of 
                    macro if not present).

mkdir               CREATES DIRECTORY.

pause <secs>        STOPS MACRO EXECUTION for number of seconds, can
                    be terminated with <esc>.

                    Please note that the clock time starts after the pause
                    command is issue.  Therefore timing is critical, you
                    must account for the time that it takes to execute
                    other statements.  For example:

                    read 1
                    pause 60
                    read 1
                    pause 60
                    ...

                    will cause reads approximately every minute but 
                    after a short time the clock will drift due to the time
                    to execute the read.  See clock+ if this is an issue.

play <filename>     RUNS MACRO, can be terminated with <esc>.  By convention
                    the supplied macro names end with .mac.  However, there
                    is nothing that forces this.  You can use the 'dir *.mac'
                    command from the flukecom prompt to display your macros.

                    If the macro named 'profile.mac' is located in the 
                    current directory, it will automatically be played upon
                    startup.

pwd                 Lists CURRENT DIRECTORY.

ren <old> <new>     RENAMES old filename to new filename.

rmdir <filename>    REMOVES a directory.

type <filename>     DISPLAYS a file.

quit                STOP.

shell               Drops to DOS SHELL.

timestamp [<filename>]  PRINTS TIME AND DATE for display, useful for logging.

                        If optional filename is present, the date and time
                        will be written to file.

zero                sets the loop COUNTER TO ZERO, see ifgoto & ifnotgoto.

* * * * * * * * * * * * * * * Meter control * * * * * * * * * * * * * * * * 

arm                 REARMS trigger on meter. Does nothing if meter is
                    currently ready for trigger.

autosetup           Same as AUTOSET key on meter.

default             Changes meter to POWER ON condition.

get <filename>      GETS the current configuration and creates a data file.

local               RESTORES front panel key operation.   Alternatively,
                    power the meter off then on again.  WARNING with this
                    procedure.  This script will not attempt to autobaud
                    after the initial configuration.  Therefore, since the
                    meter will be set back to 1200 baud, the script will
                    no longer talk to the meter.  Restart the script to
                    initialize the meter.

lockout             DISABLES AUTOSET operation during remote, only way
                    to go local is to power off the meter or issue local.
                    See notes in local.

put <filename>      PUTS the saved configuration back into the meter from
                    the specified data file.

recall <num>        RECALLS a defined setup in the scopemeter.

                    There are two ways to save a setup.  First is to use the
                    front panel keys on the scopemeter and save the current
                    setup under a setup memory or to a waveform memory.  The
                    second is to use the save command.

                    <num> is as follows:

                    1-10 specifies the setup memories 1-10
                    101-111 is the waveform memories as specified below:

                       101         Channel A
                       102         Channel B
                       103         Channel A+/-B
                       104         temporary 1
                       105           and so on
                       106
                       107         memory 4
                       108           and so on
                       109
                       110
                       111

                    See the manual for further explanations.  If you find
                    a use for this send me a script and I'll clean this up.

remote              DISABLES all front panel keys except autoset (autoset
                    may be used to restore local operation).  Power may
                    also be used to restore operation.  See local.

reset               CLEARS meter I/O buffers, does not destroy comm setup
                    or any other waveforms or settings.

save <num>          SAVES setups to memory.  See recall for description.

trigger             FORCE TRIGGER of scope.

version             Displays IDENTIFICATION string from meter.

* * * * * * * * * * * * * * * Data Handling * * * * * * * * * * * * * * * * 

copy <src> <dest>   COPIES anything to anything.

                    src can be any of of the following
                       a           Channel A
                       b           Channel B
                       ab          Channel A+/-B
                       temp1       temporary 1
                       temp2         and so on
                       temp3
                       memory4     memory 4
                       memory5       and so on
                       memory6
                       memory7
                       memory8
                       <filename>  disk file which has the *.dat and *.hdr
                                   files.  Do not specify an extension
            
                     dest can be any of the above plus
                       datestamp   creates a file with DDHHMMSS.* stamp

                     See below for extension explanation

read <meas> [<filename>] GETS the respective defined value.

                     The value is left in an internal variable which may be 
                     tested with the ifgoto and ifnotgoto statements.

                     If the optional filename is present, data will
                     be written to it in a comma separated format with
                     a date and timestamp.

                     meas is one of the following:
                        -in scope mode-
                         1        dV             voltage between cursors
                         2        dt             time between cursors
                         3        1/dt           as above
                         4        TRIG to -1-    trigger to cursor 1
                         5        RMS            RMS value measured
                         6        MEAN           MEAN value measured
                         7        P-P            peak peak voltage
                         8        MAX-P          maximum peak
                         9        MIN-P          minimum peak
                         10       FREQ           signal frequency
                         11       RISE           rise time (10%-90%)
                         12       PHASE src>des1 with 2 or more signals
                         13       PHASE src>des2 with 3 or more signals
                         14       PHASE src>des3 with 4 signals
                         15       VOLT AT -1-    voltage value at cursor 1

                        -in meter mode (read manual!)-
                         1        first measurement result
                         2        second measurement result
                         3        first calculated result
                         4        maximum (record) result
                         5        average (record) result
                         6        minimum (record) result
                         7        maximum time
                         8        average time
                         9        minimum time
                         10       duty cycle

                     If enough people ask, I'll consider putting in
                     the mnemonics instead of just supporting the numeric
                     values.  Maybe next rev.  In any event, the numerics
                     will be supported in the future.

* * * * * * * * * * * * * * * Example Scripts * * * * * * * * * * * * * * * * 

These scripts are intended for use with the scope mode.  If in the
meter mode, you need to switch to meter mode of operation.

This script is provided to just get you familiar with the scripting
language.  To execute this script type 'play test.mac'.  Please note that
you cannot use extensions on filenames.  If the file exists that you
specify, IT WILL BE OVERWRITTEN!

: test.mac
reset                    resets the meter, mostly to hear the beep
copy a newfile           put the a waveform into newfile.*
pause 5                  wait for 5 secs
copy b newfilb           now grab b

This macro shows the use of the delay function.  In addition, it shows
the use of the keyword datestamp which will create a filename of
MMDDHHMM.*.  Please note that this macro will wait until 10:11am before
it does anything.  The pause command can be used for fine control (in
seconds).

: delay.mac
pause 10                 wait for 10 seconds before doing anything
beep                     speak to user
clock 10 11              wait until 10:11am
beep
copy a datestamp         put channel a into a datestamped file
clock 10 12              wait until 10:12am
beep
copy b datestamp         same to channel b

Lets say you want to grab the waveform every minute from channel a for
the next hour.  Please note that the use of ifnotgoto here is actually
just to force 60 jumps.  The condition specified will never be false
since the min is greater than the max.  Also, no read operation is needed
since the condition is always false regardless of what is stored in the
last read variable.  The zero command is not needed since it defaults to
cleared out upon starting the macro.

: minbymin.mac
loop
clock+ 0 1               wait for the next minute to come up
copy a datestamp
ifnotgoto 1 -1 60        do for 60x unconditionally
quit                     leave script

Similarly, lets say you want to start logging voltages every minute
after 1pm.  <esc> can be used to terminate the script

: waitgrab.mac
clock 13 0               wait till 1pm
loop
read 1 logfile.dat       presence of filename causes info to be written
clock+ 0 1
ifnotgoto 1 -1

Lets say you want to wait for a single shot event to get captured and
download this to the meter.  Set the meter up for single event, turn off
free run, turn on the cursors and set them at the extreme left and 
right hand portion of the screen, enable the Vpp measurement.  Set
up the meter for proper triggering.

Fluke doesn't have a very nice way of doing this so check out this
trick (from Fluke's BBS).

The peak to peak voltage is zero for the null waveform and when a
real waveform is captured, it is downloaded since the voltage is nonzero.

: single.mac
: script to automatically wait for a single shot event and download it
: will then rearm meter and wait for next event.  Do this 10 times
loop
read 7                  read the peak to peak voltage
ifgoto 0 0 -1           a -1 code will not update the counter          
beep                    voltage was greater than zero
copy a datestamp        get the waveform
copy null a             TRICK: rewrite the waveform to all zeros
arm                     rearm the meter
ifnotgoto 1 -1 10       unconditionally do this 10 times

Put two different setups in recall memory 1 and 2.  The current setup will
be put in 3.

: flksetup.mac
save 3                current setup put in memory 3
recall 1
trigger               force trigger
copy a wave1
recall 2
trigger               force trigger
copy a wave2
recall 3              restore meter

I spent several hours getting the copy command to be very general
so I hope that someone uses it.  In particular you can copy a waveform
or file to a waveform or file.  The datestamp keyword is only good for a
destination.

: copywave
mkdir waveform          create a subdirectory
cd waveform
copy a wavea            put channel a into file wavea.*
copy b memory5          and channel b into memory5
copy wavea b            put the wavea file into b
: copy a b                is also possible
copy wavea acopy        make a disk file copy called acopy
cd ..                   return to where you were

If you wish to insure that someone doesn't mess with the meter buttons,
you can use the commands for control.  However, remember that the power
button always works so this is somewhat of a ridiculous point.

: remote.mac
version                 display meter rev
remote                  disable front panel except autoset
lockout                 disable autoset
clock 1 0               wait until 1 am
read 1
local                   restore front panel operation

The script can automatically execute a given sequence by naming the script
'profile.mac' and putting it in the current directory

: this is profile.mac, default macro for flukecom
get default.set

Finally, lets assume you want to run down the batteries on the scopemeter
and know how long it took.  You will have to terminate this with the 
<esc> key.  As you know, the meter will shut itself off with no activity.
This makes it busy to force it to run down.  This can be used to 
recondition the batteries.  In theory, you should use a logoff to 
close the log file after you use <esc> to get out of this script, however
in practice, it doesn't seem necessary.

: killbat.mac
logon bat.log                put all stuff in bat.log
zero
loop
timestamp
read 1
ifnotgoto 1 -1

                           * File structure *
A given capture to disk for the copy command will have three separate files.

.hdr contains an ascii version of the header and has the waveform
.dat is always 512 bytes and contains the binary data for the waveform
.csv is a comma separated value version of the waveform readable by Excel 5.0
(as well as others).

The .csv file is provided as output to the user, the script does not use
it once written.

* * * * * * * * * * * * * * * * Other Stuff * * * * * * * * * * * * * * * * * 

- Don't forget that Fluke has only used 1 A/D in the meter and if you wish
to obtain timing between to simultaneous waveforms (A and B), there is a
close to 17ms delay!

- As it turns out, the interpreter doesn't look on the command line past
the required (or optional) parameters.  If you have filled out all of the
parameters for a particular command, you can put anything else on the
line as a comment.

For example

ifgoto -1 1 40   wait for voltage to exceed 1V for a max of 40x

is ok, but

ifgoto -1 1      wait for voltage to exceed 1V for a max of 40x

is not since 'wait' will cause an error.  However, in most cases a
zero can be substitued for a null parameter so

ifgoto -1 1 0    wait for voltage to exceed 1V

is ok as well.  0 in this context is crazy setting anyway since why would
you put the statement in to execute it zero times.

This could be a problem if and when I extend the language.  Additional 
parameters for a given command would be pulled out of comment fields for
existing macros.
