Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
Sound Card Channel Difference Mini-App
Diff_Chan displays the difference (or sum) of the waveforms or spectra of any two selected channels. In waveform display mode this is analogous to the A - B mode of a benchtop oscilloscope.
Note that in spectrum mode the display is not the spectrum of the difference (or sum) of the two raw waveforms.
Diff_Chan launches a Custom Controls dialog that allows you to select A and B channels and operation mode (A-B, B-A, or A+B), change the vertical screen position of the difference (or sum) trace, and adjust its color and line style. The _Diff_Ctrls macro handles the control changes.
Note that you can open this Help topic at any time by right-clicking anywhere in the Diff_Chan control dialog.
Diff_Chan also installs _Diff_Task as a multitasking macro to actually compute and display the difference (or sum) trace each time the main traces are updated. This task is uninstalled when the dialog is closed.
The mode and line style buttons use the M-type momentary type discussed under Button Type under that same topic, where the mode button is used as an example.
The Line Color control uses Ctrl3="<p(0)" to set the displayed decimal places to zero for an integer display, but otherwise is a standard S-type edit control with slider. The color spectrum is controlled from the _Diff_Ctrls handler via Buf0="<dWB(colr(Ctrl3))", which uses the Color Function discussed in Macro Math Functions. This command redundantly sets the buffer display mode to Waveform Bipolar; since only the color is being changed you could use the simpler Buf0#C=colr(Ctrl3) instead.
Further information can be obtained by following the links in the macro listings below:
;<Help=H4903 Sgram=0 Ctrls="<<Channel Difference" Ctrl0="<r(0,3)" Ctrl0="<<A Channel" UU=2 Ctrl0#s=UU Ctrl0="< " + UU(c) Ctrl2="<r(0,3)" Ctrl2="<<B Channel" UL=3 Ctrl2#s=UL Ctrl2="< " + UL(c) Ctrl1="<<Zero Position" Ctrl1="<S(-128,+128)" Ctrl1=0 Ctrl3="<<Line Color" Ctrl3="<S(0,1791)" Ctrl3="<p(0)" Ctrl3=0 Btn0="<M(2)" Btn0="A - B" Btn1="<M(4)" Btn1="Solid Line" Btn2="<X" Btn3="<X" Task="_Diff_Task" US=0 Buf0#Y=US Buf0#Z=Ctrl1 @_Diff_Ctrls=Ctrls Task="-_Diff_Task" Buf0="<d-" Buf0#Y=0
;<Help=H4903 IF.Ctrls=0 ;Ctrl0, A chan scroll UU=(UU+Ctrl0?u) & 3 Ctrl0#s=UU ENDIF. IF.Ctrls=h80 ;Ctrl0, A chan slider UU=Ctrl0?s Ctrl0="< " + UU(c) ENDIF. IF.Ctrls=2 ;Ctrl2, B chan scroll UU=(UL+Ctrl2?u) & 3 Ctrl2#s=UL ENDIF. IF.Ctrls=h82 ;Ctrl2, B chan slider UL=Ctrl2?s Ctrl2="< " + UL(c) ENDIF. IF.Ctrls=1 ;Ctrl1 Zero Posn Buf0#Z=Ctrl1 ENDIF. IF.Ctrls=3 ;Ctrl3 Line Color Buf0="<dWB(colr(Ctrl3))" ENDIF. IF.Ctrls=4 ;Btn0 Mode IF.Btn0=0 Btn0="A - B" ENDIF. IF.Btn0=1 Btn0="B - A" ENDIF. IF.Btn0=2 Btn0="A + B" ENDIF. ENDIF. IF.Ctrls=5 ;Btn1 Line Style IF.Btn1=0 Btn1="Solid Line" ENDIF. IF.Btn1=1 Btn1="Dashed Line" ENDIF. IF.Btn1=2 Btn1="Dotted Line" ENDIF. IF.Btn1=3 Btn1="Dash-Dot Line" ENDIF. IF.Btn1=4 Btn1="Dash-Dot-Dot Line" ENDIF. Buf0#Y=Btn1 ENDIF.
;<Help=H4903 IF.Spect=1 Buf0="<mS(UU)" Buf1="<mS(UL)" Buf0="<dSU(colr(Ctrl3))" ELSE. Buf0="<=W(UU)" Buf1="<=W(UL)" Buf0="<dWB(colr(Ctrl3))" ENDIF. IF.Btn0=0 Buf0="<-B1" ENDIF. IF.Btn0=1 Buf0="<~B1" ENDIF. IF.Btn0=2 Buf0="<+B1" ENDIF.
See also Macro Examples and Mini-Apps
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 35 Years of Innovative Instrumentation
© Copyright 2007 - 2021 by Interstellar Research
All rights reserved