Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

sine wave

Hi at all,

i´m trying to create a sine wave with delphi. I have the PCI 6014. I look up the examples, which are deliverd with the NI-Card. I use the AO-Example. It was not able for me to plot the sine wave on the cwgraph. The Freq is 50Hz and the number of cysles is continuous.

I´m new to handle with this staff. I hope someone can help me, or give me more informations in using AO´s or CWGraph´s.

Thanks
0 Kudos
Message 1 of 4
(3,603 Views)
There are currently no examples available for Delphi, but you can try to use the Visual C examples.
You will find these examples in your DAQ installation folder (National Instruments\NI-DAQ\Examples\VisualC)
0 Kudos
Message 2 of 4
(3,590 Views)
Hi DirkW,

thanks for your answer.
I´ll look at the examples. If i don´t get a solution i´ll ask here again.
0 Kudos
Message 3 of 4
(3,583 Views)
Hi @all,

I look at the exampels from Visual C, but they don´t realy help me. I post now the part what i create to get a sine wave. My problem is that i don´t see anything at the cwgrpah??? I don´t know why, may be someone can help me, or give some tips!

Here my code:


unit AO;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
CWHELPBUTTONLib_TLB, CWUIControlsLib_TLB, CWDAQControlsLib_TLB, StdCtrls,
OleCtrls, Variants;

{...}

var
Form1: TForm1;
data: Variant;
IsRunning: Boolean;
const
PI2 = 6.2832;

implementation

{$R *.DFM}

procedure TForm1.WaveformTypePointerValueChanged(Sender: TObject;
Pointer: Integer; var Value: OleVariant);
var
i: Integer;
begin
Case WaveformType.Value of
0:
For i := 0 To 19 do
data[i] := Sin(i / 20 * PI2)*6;
1:
For i := 0 To 19 do
data[i] := Int(i / 10) * 2 - 1;
2:
For i := 0 To 19 do
data[i] := 1 - (Abs(i - 10) / 5);
End;
data[20] := data[0]; // for display purposes only
CWGraph1.PlotY(data,0,1,TRUE);
end;


procedure TForm1.btnStartClick(Sender: TObject);
var
WriteSpec: CWAOWriteSpec;
begin
WriteSpec := CWDAQTools1.CreateCWAOWriteSpec;

CWAO1.UpdateClock.Frequency := FreqVal.Value * 20;
CWAO1.NIterations := IterationVal.Value; //Wiederholungen
CWAO1.Infinite := ContinuousSelect.Checked; //unendliche Wiederholung

CWAO1.Configure;
CWAO1.Write(data,WriteSpec);
CWAO1.Start;
If ContinuousSelect.Checked Then
begin
IsRunning := True;
btnStop.Enabled := True;
end
Else
begin
IsRunning := False;
btnStop.Enabled := False;
end;
end;

procedure TForm1.btnStopClick(Sender: TObject);
begin
CWAO1.Reset;
IsRunning := False;
btnStop.Enabled := False;
end;

procedure TForm1.FormShow(Sender: TObject);
var
v : OleVariant;
begin
data := VarArrayCreate([0,20],varDouble);
WaveformTypePointerValueChanged(WaveformType, 0, v);
end;

end.
0 Kudos
Message 4 of 4
(3,572 Views)