Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
Sound Card Macro Overview
Daqarta includes a number of ready-to-run example macros and mini-apps to perform various tasks and experiments. You can use these as-is, or modify them for your own needs, or study them to learn how to write your own custom macros.
You can open the Help topic for any included macro by selecting it in the Macro List and clicking the Help button below the list, next to Run. If you click the Edit button to see the macro definition, you'll find a duplicate Help button near the upper right.
A simple Daqarta macro consists of one or more commands that directly operate controls to allow task automation. All Daqarta controls have associated variables that can be accessed directly via mnemonic names, such as SmplRate for Sample Rate. (The macro command name is given in each control's Help topic, which you can open by right-clicking the control.)
Macros can also perform custom calculations on raw data using a rich set of expressions and operators, math functions, variables, and arrays. Arrays can also be used as large general-purpose storage areas for numerical values or text strings. Special string arrays allow advanced text manipulation options, including flexible lengths, case conversion, and numerical expression evaluation.
A macro can also install another macro as one of up to 16 tasks in a multitasking system, allowing it to run concurrently with other operations.
The Macro Dialog is independent of the normal Daqarta dialog system and can be kept open while you work. Complex test suites can be operated entirely from the Macro Dialog, without the need to delve into other dialogs to find controls. The macro names and descriptions, as well as macros that provide helpful prompt messages, can guide even novice operators through a series of tests.
Alternatively, macros can be run as "hot keys" that are invoked via the F8 function key followed by an ID key that you assign. The Macro Dialog opens when you hit F8 and vanishes when you hit the ID key.
A special Instant Macro mode uses F8 followed by Spacebar to accept a direct macro command (or list of commands) that is run immediately via SHIFT+Enter.
Macros can be run via remote control from your own external application, allowing it to use Daqarta for data collection, analysis, and/or signal generation.
Macros execute very quickly. They typically operate on controls directly, without requiring the normal control dialog to be opened, so they can perform a complicated series of operations virtually instantly.
All the macros in the Macro Dialog can be saved to a .MAC file. Daqarta0.MAC (or another file that you specify) is loaded automatically when Daqarta starts. Other files can be loaded manually at any time.
NOTE: The Macro Save File button is disabled after the trial period, unless a Professional license key is present. However, you may continue to load and use the included macro files, or those you have previously created, and you may create and use macros within a session without saving to a file.
A macro with a special '!' ID can be run automatically every time Daqarta starts up, which can set test parameters and prompt the operator for needed information.
You can specify an arbitrary auto-run macro via the A: command line parameter, allowing you to use selected features of Daqarta as part of a larger test system.
A macro is created via the New button in the Macro Dialog, which opens the Macro Editor where you can enter the ID, Name, optional Description, and the actual Definition which contains the commands that make up the macro. The definition can also include comments to explain the purpose of individual command steps, or the overall macro operation.
Almost all Daqarta controls have associated macro commands. When you right-click on a control, its specific macro command is shown at the top of the Help topic that opens. More detailed information about how to use the command is provided near the end of the topic, in the Macro Notes section.
All macro commands consist of a command or variable name followed immediately by an = sign and (usually) a value or expression. Many commands have optional prefixes that provide additional information to the macro processor. Each prefix must be followed by a period. For example, L.0.ToneFreq=1000 sets the Generator Tone Frequency for Left Stream 0 to 1000 Hz.
Macros commands for adjustable values like frequency accept the desired value or expression after the = sign, as in the above example. But you can also increment or decrement any existing value such as ToneFreq via ToneFreq=>A, where A may be a constant, variable, or expression. The right-hand side after the '=>' (A here) is evaluated and if it is positive, ToneFreq is scrolled up one step. If negative, it is scrolled down, and if zero it is unchanged.
The actual size of the step is a constant +/-1 for most controls (and all macro variables), but this increment/decrement option is particularly useful with the special step sizes allowed by Tone Frequency and other Generator frequencies like AM, FM, or Phase/Slope modulation frequencies. Only one step is allowed per command. (You can't use =>2 to move by two steps.) However, you can always use an expression like ToneFreq=ToneFreq + X if you don't need the special steps.
Macro commands for on/off button controls or checkboxes use a value of 1 for On and 0 for Off. To toggle the current state, use x. For example, Trig=x toggles Trigger off if it was on, or on if it was off.
Radio button macro commands allow a mnemonic name instead of a value, such as SpectWind=Bkmn to set a Blackman type spectrum window. To use a numeric value instead, start with 0 for the first button in the radio group and count to the desired button... in this case SpectWind=2 would set Blackman. The advantage of a number over a name is that you can store it in a macro variable while you use a different setting for a certain test, then later restore the original setting from the variable.
A macro may contain many commands, including invocations of other macros that you have previously defined to act as subroutines of the main macro. A macro named _MyMacro is called from another macro definition as @_MyMacro. A macro can call a macro that calls a macro... up to 16 levels deep.
As a notational convenience, subroutine macros start with an underscore, as in the above example. This is not mandatory, but it has the benefit that subroutine names will be sorted to the bottom of the macro list, below the macros that you Manually invoke and need ready access to.
Macros can be repeated in loops. @_MyMacro=N runs _MyMacro for N repetitions, where N may be a value or expression. You can also use WHILE/WEND loops for more control, and to keep everything in a single macro.
In addition to commands that operate Daqarta controls, there are also special macro-only commands to display messages in specified fonts, colors, and locations as operator prompts, or to query the operator for a response. There are special macros to wait for specified events or time durations, or store values in macro variables for later use.
Macros can also contain logical IF statements to perform conditional operations based upon the values of most variables.
A macro can tell a Label or Field to maintain a copy of a specified Daqarta variable. This allows you to insure that relevant test information like stimulus frequency and loudness are saved with file data.
Macros can be used to set controls or variables, including timer intervals, with random values that are uniformly distributed over a range you define.
You can create a macro that prompts an operator to enter a test name or number into a Field and waits for entry before proceeding. That entry can then be used as a file name by a macro that saves the test data.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2017 by Interstellar Research
All rights reserved