Daqarta
Data AcQuisition And Real-Time Analysis
Scope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
The following is from the Daqarta Help system:

Features:

Oscilloscope

Spectrum Analyzer

8-Channel
Signal Generator

(Absolutely FREE!)

Spectrogram

Pitch Tracker

Pitch-to-MIDI

DaqMusiq Generator
(Free Music... Forever!)

Engine Simulator

LCR Meter

Remote Operation

DC Measurements

True RMS Voltmeter

Sound Level Meter

Frequency Counter
    Period
    Event
    Spectral Event

    Temperature
    Pressure
    MHz Frequencies

Data Logger

Waveform Averager

Histogram

Post-Stimulus Time
Histogram (PSTH)

THD Meter

IMD Meter

Precision Phase Meter

Pulse Meter

Macro System

Multi-Trace Arrays

Trigger Controls

Auto-Calibration

Spectral Peak Track

Spectrum Limit Testing

Direct-to-Disk Recording

Accessibility

Applications:

Frequency response

Distortion measurement

Speech and music

Microphone calibration

Loudspeaker test

Auditory phenomena

Musical instrument tuning

Animal sound

Evoked potentials

Rotating machinery

Automotive

Product test

Contact us about
your application!

Memory Arbs (MemArb0-7)

Introduction:

Instead of loading an Arb wave from a file, you can create it directly in memory using MemArb macro commands. A created MemArb behaves just like a file Arb, taking up one of the Arb 0-7 buttons on the Arb dialog which can be toggled on and off or removed, either manually or using the regular Arb macro commands.

A MemArb must designate one of the 8 Arb buttons based on a digit in its name: MemArb0 refers to a MemArb at the Arb 0 button location, while MemArb7 refers to Arb 7. You can also use MemArbV to refer to a button specified ahead of time via the Ch Channel Select command.

Each MemArb has a specific size, just as normal Arbs do. You set the size when creating the MemArb. MemArb0#N=1 creates MemArb0 at the Arb 0 button location, with a size of 1024 samples (1K, hence the 1). You can use 1, 2, 4, 8 or 16 to specify 1024, 2048, 4096, 8192, or 16384 samples.

You can't create a MemArb at a button location that is already occupied by either a MemArb or a normal Arb; nothing happens if you try. You can test if anything is present at the Arb 0 location, for example, via X=MemArb0?N, where variable X (or any variable you choose) will return the size; a size of zero means nothing is there. (Note that this command returns the actual size, in samples, such as 1024... not 1 with an implied 'K' as used when setting the size.)

You can delete an existing MemArb0 (or Arb 0) via MemArb0#X=0 (value ignored).

The Engine Crank and Cam Sensor Simulator Mini-App creates MemArbs for use as the Crank and Cam tooth profiles, allowing variable width control instead of standard Daqarta waveforms. See in particular the listing for the Engine_Sim main macro which sets up the initial MemArbs, plus the _Engine_Wave macro that is called to fill a MemArb with the chosen waveform and width.

Besides creating Arb waveforms in memory, you can also use MemArbs as general-purpose arrays for writing and reading signed integers in the +/-32767 range. Create a MemArb as above, but don't toggle it on for use as an Arb. You can then write or read data as discussed below, or use MemArb values in expressions.


MemArb Command Summary:

MemArb0#N=1                Create 1K MemArb0 (1, 2, 4, 8, 16 allowed)
X=MemArb0?N                Read size of MemArb0 into variable X
MemArb0#X=0                Delete existing MemArb0 or Arb 0

MemArb0="<=(K)"            Fill MemArb0 with constant K
MemArb0[UA]=X              Write value X to index UA
X=MemArb0[UA]              Read value X from index UA

MemArb0="<=B1"             Copy 1024 values from Buf1 to MemArb0
MemArb0="<=B(UC)"          Copy from Buf0-7 as set by UC
MemArb0#SO=n              Set copy Start Offset to index n
Buf1="<uM0"                Equivalent to MemArb0="<=B1"
Buf1="<uM0(n)"            Same as above with prior MemArb0#SO=n
Buf1="<uM(UC)"             Copy from Buf1 to MemArb set by UC

MemArb0="<=D1(n)"         Copy raw Right In data starting from absolute sample n

MemArb0="<Save"            Save dialog with Arb.DAT default
MemArb0="<Save:"           Save dialog with no default
MemArb0="<Save:MyFile"     Save dialog with MyFile.DAT default
A.MemArb0="<Save:MyFile"   Save MyFile.DAT; no dialog
MemArb0="<SaveDQA"         As above, but save in DQA format
MemArb0="<SaveWAV"         As above, but save in WAV format
MemArb0="<SaveDAT"         As above, but save in DAT format
MemArb0="<SaveTXT"         As above, but save in TXT format

Writing to and Reading from MemArbs:

A MemArb is an array of 16-bit sample values in the range of +/-32767. When first created the array is filled with zeros. Use MemArb0="<=(K)" to fill MemArb0 with constant K, which may be an immediate value, a variable, or an expression.

To write a value X to MemArb0 at index UA, use MemArb0[UA]=X. Values outside of the +/-32767 range will be automatically limited to that range.

To read value X from index UA, use X=MemArb0[UA]. You may also use MemArb values in expressions like any other variable or value.

You may use any variable or immediate value for the MemArb index. Index numbers run from 0 to one less than the MemArb size. When writing, if the index is negative or too large for the specified MemArb size no action is taken. When reading, it is limited to the valid range. A negative index thus returns the 0th position, and a too-large index returns the value at the maximum index (1023, 2047, 4095, 8191, or 16383).

You can write to an existing Arb or MemArb, which will overwrite the waveform image in memory. (The Arb file it may have been loaded from will be untouched.) You can do this deliberately to modify an existing Arb or MemArb waveform, or you may do it inadvertently if you attempted to create a MemArb on a button that was already occupied.

If the size happens to be the same as the MemArb you were trying to create, the data you write will create the waveform you intended. (The button label will not change, so if it shows an Arb file name it might be misleading.)

If the existing Arb or MemArb is smaller, your data write index values will be automatically limited to the maximum index for the actual size present, and your waveform will end abruptly. If the existing size is larger than your waveform code expects, your wave will overwrite the initial portion of the existing wave.


Copying Buf0-7 Data to MemArbs:

Instead of filling the MemArb index-by-index using commands like MemArb0[UA]=X, you can copy 1024 samples at a time from Macro Arrays Buf0-Buf7 using MemArb0="<=B1" to copy Buf1 to MemArb0. Since MemArbs can hold up to 16384 samples, you can set the Start Offset for the copy by first using MemArb0#SO=n. If n is too close to the end, the copy will take only as many samples from Buf1 as needed to just fill the MemArb. Note that the Start Offset must be given before each copy command, since it is cleared afterwards.

MemArb0="<=B(UC)" behaves like MemArb0="<=B1" but allows an expression or variable like UC to specify the Buf1-Buf7 number.

Alternatively, you can use Macro Array upload commands to copy from Buf0-Buf7. Buf1="<uM0" is equivalent to MemArb0="<=B1", while Buf1="<uM(UC)" uses an expression or variable to specify the MemArb number to upload to. (Not the Buf1-Buf7 number.)

Buf1="<uM0(n)" is the same as MemArb0="<=B1" with a prior MemArb0#SO=n command. You may find this all-in-one command more convenient than two separate commands.


Copying Raw Input/Output Data to MemArbs:

You can copy 1024 samples of raw sound card waveform data via MemArb0="<=D1(n)", where D1 indicates Data channel 1 (Right In) and n is an expression or variable for the absolute sample number. For example, MemArb0="<=D1(Posn?D)" copies from the start position of the Right In data currently displayed, while Buf0="<=D1(Posn?D - 100)" would start 100 samples earlier than that, equivalent to a Trigger Delay of -100 samples.

Channel numbers (the digit after 'D') are:

    0 = Left In
    1 = Right In
    2 = Left Out
    3 = Right Out

You can use MemArb0#SO=n to set the Start Offset into the MemArb before the Data copy.


Saving MemArbs to Files:

Note that MemArb data is not saved in .GEN setups. If you save a setup containing MemArbs, when you later load it you will find the MemArb buttons have reverted to empty Arb buttons, labeled 'Arb0' instead of 'MemArb0', etc. If the MemArb had been active (selected as the Arb waveform for that stream), the Wave type will have reverted to Sine.

If you want to create a setup that uses MemArb data without having to calculate it each time, you should first save the data to a file, then load it as a normal Arb. Arb file names are saved with GEN setups, and when the setup is later loaded it automatically loads the Arb files as well.

MemArb0="<Save" will open a Save dialog to save the contents of MemArb0 to a file with the .DAT file type. All .DAT files in Daqarta's User_Data folder are shown by default, but you can navigate to other folders.

At the bottom of the Save dialog under Save as type you can select .DQA, .WAV, or .TXT instead of the default .DAT file type.

The default filename shown will be "Arb", which would mean a file named "Arb.DAT". Using MemArb0="<Save:" (note the colon) will show an empty default name.

This command will automatically detect the size of the MemArb and save the entire contents, from 1024 to 16384 samples, as required.

Although this is nominally a 'MemArb' command, note that if there is a normal Arb file already loaded to the same numerical position (Arb 0 in this example), it will be saved instead... no distinction is made between MemArb and Arb.

MemArb0="<Save:MyFile" works as above, but shows MyFile as the default. You can use string expressions to create the file name, as in MemArb0="<Save:" + Field1 + UA. Here Field1 holds a previously-entered base name, and UA holds an integer to be appended to that. The default name might thus be something like SpkrTest123.

After any of the above commands that invokes a Save As dialog, you may use IF.Posn?f=0 to see if the user has hit Cancel to exit without choosing a file name. This allows your macro to exit gracefully or take other action.

Using an 'A.' prefix as in A.MemArb0="<Save:MyFile" + "123" saves MyFile123.DAT directly, without opening any dialog or showing any user prompt. If a file of the same name already exists, it will be automatically overwritten.

Note: In general, you can supply a file extension with the Save command, as in MemArb0="<Save:MyFile.WAV" and it will be saved with that format. However, that doesn't work when using the 'A.' prefix; the '.DAT' extension is automatically added, saving "MyFile.WAV.DAT". Instead, use A.MemArb="<SaveWAV:MyFile" as discussed below.

To save using the .DQA, .WAV, or .TXT format, replace the 'Save' in the above examples with 'SaveDQA', 'SaveWAV', or 'SaveTXT'.

Saving a MemArb to a .TXT file will create a column of integers. Note that these .TXT files are not the same format as those created with the Save Trace as .TXT Text File option in the File menu, or the normal SaveTXT= macro that does the same thing. Those have headers, and have an initial column giving the time or frequency (X-axis) value for the data that follows on each line.

MemArbN text files have no header, and no X-axis column. They are simply lists of numbers.

After a MemArb Save command, .DQA, .WAV, .DAT or .TXT files can be opened as normal Daqarta files using the DD / Open button in the toolbar. However, note that although a MemArb saved as a .TXT file may contain up to 16384 samples, only the first 1024 (one full screen) can be loaded in this manner... you can't scroll through larger files as you can with the .DQA, .WAV, or .DAT formats.

Suppose you have just run a macro such as Engine_Sim that created a MemArb you want to save to a file. You don't have to modify the code and re-run it, just use a simple Instant Macro to do the job. Starting with the Macro Dialog closed, hit the F8 function key followed by Spacebar. The Macro Edit dialog will be opened as for New macro creation, but with the cursor already positioned in the Definition field. Enter the following, replacing the '0' in MemArb0 with the relevant MemArb number you want to save:

    MemArb0="<Save:

Conclude the entry with SHIFT+Enter and the macro will be run immediately. A Save As dialog will allow you to enter a file name, and change the file type from the .DAT default.


See also Wave Dialog, Arb Wave.

GO:

Questions? Comments? Contact us!

We respond to ALL inquiries, typically within 24 hrs.
INTERSTELLAR RESEARCH:
Over 35 Years of Innovative Instrumentation
© Copyright 2007 - 2023 by Interstellar Research
All rights reserved