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!

Sound Card Chart Recorder Mini-App

Introduction:

The Chart_Recorder macro mini-app that is included with Daqarta demonstrates how to use the macro system to turn your sound card into a multi-trace chart recorder and data logger. It allows you to select from among 19 chart rates, from one sample every 0.010 sec (100 samples per second) to 1 sample per hour, and you can easily slow that to one sample per day or slower.

Note that this mini-app is largely superceded by the Multi_Meters mini-app, which also does screen plotting and data logging, and has many advanced options. Chart_Recorder is a good learning tool, however, since it uses the Generator to provide convenient test signals. Also, if you are planning to write your own macro, Chart_Recorder is a simpler starting point, and you can compare it to Multi_Meters as you advance.

(Note also that another way to get chart recorder action is to use Decimate mode with a slow Rate, and Trigger off.)

To run Chart_Recorder, hit the F8 key followed by the 'R' key, or hit CTRL+F8 to open the Macro Dialog and double-click on Chart_Recorder in the Macro List.

Chart_Recorder uses a Custom Controls dialog to allow easy changes in real-time. Note that you can open this Help topic by right-clicking anywhere in the dialog.

Two channels are plotted, as selected by the Upper Channel and Lower Channel controls. Each allows selection from among Left In, Right In, Left Out, or Right Out. The chart traces are plotted in the colors of their respective selected channels.

By default, Chart_Recorder loads a Generator Setup called "ChartDemo" and selects Left and Right Out for plotting. These signals are amplitude (AM) and frequency (FM) modulated sine waves, with the AM Phase on the Right channel set to 180 degrees.

The RMS voltage for each channel is plotted. This is true RMS, computed over 1024 points of the raw waveform using the wSig sigma (summation) function. However, the scale value doesn't necessarily match that shown on the Y axis for the raw waveform. If you use the Data Logging option to save the values to a text file, you will notice that they are scaled such that 1.00 is the full-scale value of the raw wave, which for the sine waves used in the setup would give a maximum RMS value of 0.707.

The Update Interval is set by default to 0.010 sec (100 samples per second) to give rapidly scrolling traces for demonstration purposes. The AM Mod Freq control defaults to 0.100 Hz, so the traces take 10 seconds to go through a full cycle of modulation. Due to the 180 degree AM Phase on the Right channel, its plot appears to be inverted compared to the Left channel.

Note that at the fastest speed(s) the timing is typically not exact unless you have a fast system, due to system graphics overhead. For example, at 0.010 sec (100 samples per second) an old 1.6 GHz laptop with integrated graphics actually takes 1.5+ seconds for 100 points, instead of the expected 1.00 seconds. At 0.020 sec (50 samples per second) the timing is exact, as shown in the Data Logger output. (See below.)

Clicking on the One Trace/Chan button toggles it to Two Traces/Chan. This shows twice as many time points on the screen (2048 vs 1024) by doubling the number of traces. A given point scrolls from left to right until it reaches the right margin, then appears on a second trace below the first and contines scrolling. (Daqarta has 8 Macro Arrays Buf0-Buf7 which can be scrolled and shown on custom traces, allowing you to create a macro that scrolls a single channel over 8192 time points.)

In Interval Mode, the first time point is taken immediately after a mode or speed change, and thereafter at the Update Interval. If you toggle to Time Mode, the first point is not taken until the UTC Time is a multiple of the Update Interval, and thereafter at that rate. For example, if the current time is 11:55:49.671 and you change the interval to 1.00 sec, the first point will be at 11:55:50.000, the next at 11:55:51.000, and so on. This may be important if you are running a test that requires a reading "every hour on the hour". It also makes a log file easier to read, and easier to compare with similar log files.

The Data Logging button sends the data to the current log file, typically DqaLog.TXT (although you can change it with a LogName command). Each line holds 3 columns: A time stamp, the upper channel reading, and the lower channel reading. You can change the format by modifying the LogTxt line in the _Chart_Update macro... see below.

Toggling the Frequency (Upper Chan) button replaces the RMS plot with an average frequency plot for the upper channel. The screen scaling is arbitrary, but the data log will show the actual frequency in Hz. This mode activates Daqarta's Frequency Counter option, and sets the Trigger Source to the selected Upper Channel. You can minimize the separate Frequency Counter display manually (or by adding an FcountDlg#m=1 after the FcountDlg=1 line in the _Chart_Ctrls macro) if it gets in the way.

The Frequency Counter uses the same Trigger that is used for the main display, which means only one channel can be selected at a time for Frequency ploting. But you can set both Upper and Lower channels the same to see plots of both frequency and RMS for the given channel.

When viewing the default Left Out channel as frequency, you will notice little dips or notches in the frequency plot every 10 seconds. The Left Out signal from the Generator is frequency modulated at 0.025 Hz, which results in the slow 40-second sine wave of the plot. But it is also {\i amplitude} modulated at 0.1 Hz, and since the AM depth is 100%, the signal goes to zero amplitude every 10 seconds. When that happens, there is no frequency to count, so the frequency plot dips. (It would of course go to zero and stay there if the signal amplitude stayed at zero, but here the outage is very brief.)

The glitches should serve as a reminder that you need a triggerable minimum amplitude to get a working frequency plot or display. Also, that you can't tell from the frequency plot when the signal amplitude is getting low, until it is so low that triggering fails.


Note that if the Upper Channel or Lower Channel selector controls are moved to Left In or Right In, you must manually (or via macro modifications) toggle Input on and set the Input Controls to the desired line (Line, Mic, etc) and level.

The Upper Channel and Lower Channel selector controls are identical to those in the Diff_Chan Channel Difference macro mini-app. They use the Slider Control with Read-Only Edit method discussed in the Custom Controls Command Summary.

See Independent Edit and Slider Controls under the same topic for a description of the Update Interval chart speed control operation.

Further information can be obtained by following the links in the macro listings below:


Chart_Recorder Macro Listing:

;<Help=H4902
Close=
Spect=0
Sgram=0
TrigMode=Norm
TrigLevel=0
TrigHyst=0
A.LoadGEN="ChartDemo"
Buf7[0]=0.01
Buf7[1]=0.02
Buf7[2]=0.05
Buf7[3]=0.1
Buf7[4]=0.2
Buf7[5]=0.5
Buf7[6]=1
Buf7[7]=2
Buf7[8]=5
Buf7[9]=10
Buf7[10]=20
Buf7[11]=30
Buf7[12]=60
Buf7[13]=120
Buf7[14]=300
Buf7[15]=600
Buf7[16]=1200
Buf7[17]=3000
Buf7[18]=3600
Ctrls="<<Chart Recorder Controls"
Ctrl0="<r(0,3)"
Ctrl0="<<Upper Channel"
UU=2
Ctrl0#s=UU
Ctrl0="< " + UU(c)
TrigSrc=UU
Ctrl2="<r(0,3)"
Ctrl2="<<Lower Channel"
UL=3
Ctrl2#s=UL
Ctrl2="< " + UL(c)
UR=0
Ctrl1="<S(0.01,3600)"
Ctrl1="<s(0,18)"
Ctrl1="<<Update Interval, sec"
Ctrl1#s=UR
R=Buf7[UR]
Ctrl1=R
Ctrl3="<S(0,1)"
Ctrl3="<<AM Mod Freq"
Ctrl3=0.10

Btn0="<T"
UD=0
Btn0=UD
Btn0="One Trace/Chan"

Btn1="<T"
Btn1=0
Btn1="Interval Mode"

Btn2="<T"
Btn2=0
Btn2="Data Logging"

Btn3="<T"
Btn3=0
Btn3="Frequency (Upper Chan)"
FcountMode=Hz

UT=1
T=Time<<32/10M + R
Task="_Chart_Task"
Buf0="<=(0)"
Buf1="<=(0)"
Buf2="<=(0)"
Buf3="<=(0)"
Ch=2
Buf0="<dWU(ColorNum?c)"
Buf0#Z=128
Ch=3
Buf2="<dWU(ColorNum?c)"
@_Chart_Ctrls=Ctrls
Task="-_Chart_Task"
Buf0="<d-"
Buf1="<d-"
Buf2="<d-"
Buf3="<d-"

_Chart_Ctrls Macro Listing:

;<Help=H4902
IF.Ctrls=0                      ;Ctrl0, top chan scroll
    UU=(UU+Ctrl0?u) & 3
    Ctrl0#s=UU
ENDIF.

IF.Ctrls=h80                    ;Ctrl0, top chan slider
    UU=Ctrl0?s
    Ctrl0="< " + UU(c)
    Ch=UU
    Buf0="<dWU(ColorNum?c)"
    TrigSrc=UU
ENDIF.

IF.Ctrls=2                      ;Ctrl2, bottom chan scroll
    UU=(UL+Ctrl2?u) & 3
    Ctrl2#s=UL
ENDIF.

IF.Ctrls=h82                    ;Ctrl2, bottom chan slider
    UL=Ctrl2?s
    Ctrl2="< " + UL(c)
    Ch=UL
    Buf2="<dWU(ColorNum?c)"
ENDIF.

IF.Ctrls=1                      ;Ctrl1, chart speed
    IF.Ctrl1?u=!0
        UR=UR+Ctrl1?u
        IF.UR=>18
            UR=18
        ENDIF.
        IF.UR=<0
            UR=0
        ENDIF.
    ELSE.
        UR=0
        WHILE.UR=<=18
            IF.Buf7[UR]=>=Ctrl1
                LoopBreak=2
            ENDIF.
            UR=UR+1
        WEND.
    ENDIF.
    R=Buf7[UR]
    Ctrl1=R
    Ctrl1#s=UR
ENDIF.

IF.Ctrls=h81                        ;Ctrl1, chart speed slider
    UR=Ctrl1?s
    R=Buf7[UR]
    Ctrl1=R
    UT=0
    IF.UR=<3
        UT=1
    ENDIF.
    T=Time<<32/10M + R
    X=int(Time<<32/10M/R)
    IF.Btn1=0
        @_Chart_Update
    ENDIF.
ENDIF.

IF.Ctrls=3
    L.0.AMmodFreq=Ctrl3
    R.0.AMmodFreq=Ctrl3
ENDIF.

IF.Ctrls=4                          ;Btn0
    UD=Btn0
    IF.Btn0=0
        Btn0="One Trace/Chan"
        Buf0#Z=128
        Buf1="<d-"
        Buf2#Z=0
        Buf3="<d-"
    ELSE.
        Btn0="Two Traces/Chan"
        Ch=UU
        Buf1="<dWU(ColorNum?c)"
        Buf1="<=(0)"
        Buf0#Z=192
        Buf1#Z=128
        Ch=UL
        Buf3="<dWU(ColorNum?c)"
        Buf3="<=(0)"
        Buf2#Z=64
        Buf3#Z=0
    ENDIF.
ENDIF.

IF.Ctrls=5                              ;Btn1
    IF.Btn1=0
        Btn1="Interval Mode"
        T=Time<<32/10M + R
        @_Chart_Update
    ELSE.
        Btn1="Time Mode"
        X=int(Time<<32/10M/R)
    ENDIF.
ENDIF.

IF.Ctrls=7                              ;Btn3
    IF.Btn3=1
        FcountDlg=1
        Trig=1
    ENDIF.
ENDIF.

_Chart_Task Macro Listing:

;<Help=H4902
IF.Btn1+UT=0
    Q=Time<<32/10M
    IF.Q=>T
        T=T+R
        @_Chart_Update
    ENDIF.
ELSE.
    Q=int(Time<<32/10M/R)
    IF.Q=>X
        X=Q
        @_Chart_Update
    ENDIF.
ENDIF.

_Chart_Update Macro Listing:

;<Help=H4902
Buf0="<>B(UD)"
IF.Btn3=0
    Ch=UU
    Buf0[0]=wSig(0,1023)
ELSE.
    Buf0[0]=Freq * 32
ENDIF.
Buf2="<>B(UD+2)"
Ch=UL
Buf2[0]=wSig(0,1023)
IF.Btn2=1
    IF.Btn3=0
        A=Buf0[0] / 32768
    ELSE.
        A=Buf0[0] / 32
    ENDIF.
    B=Buf2[0] / 32768
    LogTxt=n + t +p20 + A + p40 + B
ENDIF.

See also Macro Examples and Mini-Apps

GO:

Questions? Comments? Contact us!

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