l’m asking about VM140,after connecting it to the usb and to the power supply,if i connect an analogue sensor to it where can i found the values arrays of the input signals?
thank u
You can use these Analogue to Digital converter procedures:
ReadAnalogChannel(CardAddress, Channelno), this reads the status of one analogue input channel.
ReadAllAnalog(CardAddress, Buffer), this reads the status of all analogue input channels.
For more details please see the “K8061_DLL_manual.pdf” available in the package “Complete software package edition 2011” from: velleman.eu/support/download … M140&type=
thank u for your answer,but excuse me i’m a beginner,where i can found the compiler in which i can write the codes u talk about ?
please tell me the steps in details,thank u
best regrades
I made a minimal program to read the Analog-to-Digital converters of the VM140 and display the values on the screen. The software is written in Free Pascal using Lazarus IDE.
[quote]thank u for your answer,but excuse me i’m a beginner,where i can found the compiler in which i can write the codes u talk about[/quote] The compiler is available here: lazarus.freepascal.org/
[quote]please tell me the steps in details,thank u [/quote]This DelphiBasics site contains a lot of info about the Pascal programming:
delphibasics.co.uk/index.html
E.g. Tutorials
- Writing your first program
etc.
This “Run Time Library Reference by first letter” is also very good:
delphibasics.co.uk/ByLetter.asp?Letter=A
There are examples for all functions.
Here is the software code for the VM140 program to read the AD inputs:
[size=85][code]unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
ConnectButton: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Label1: TLabel;
Label12: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Timer1: TTimer;
procedure ConnectButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
CardAddress:longint;
implementation
{$R *.lfm}
function OpenDevice: Longint; stdcall; external ‘K8061.dll’;
procedure CloseDevices; stdcall; external ‘K8061.dll’;
function ReadAnalogChannel(CardAddress: Longint; Channel: Longint):Longint; stdcall; external ‘K8061.dll’;
procedure ReadAllAnalog(CardAddress: Longint; Buffer: Pointer); stdcall; external ‘K8061.dll’;
procedure TForm1.ConnectButtonClick(Sender: TObject);
var h:longint;
begin
h:= OpenDevice;
case h of
0…7: begin
label12.caption:=‘Card ‘+ inttostr(h)+’ connected’;
timer1.enabled:=true;
CardAddress:=h;
end;
-1: label12.caption:=‘All cards connected.’;
-2: label12.caption:=‘Card not found.’;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var Data: array [0…7] of longint;
begin
Timer1.Enabled:=False;
ReadAllAnalog(CardAddress,@Data[0]);
Edit1.Text:=IntToStr(Data[0]);
Edit2.Text:=IntToStr(Data[1]);
Edit3.Text:=IntToStr(Data[2]);
Edit4.Text:=IntToStr(Data[3]);
Edit5.Text:=IntToStr(Data[4]);
Edit6.Text:=IntToStr(Data[5]);
Edit7.Text:=IntToStr(Data[6]);
Edit8.Text:=IntToStr(Data[7]);
Timer1.Enabled:=True;
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
CloseDevices;
CloseAction:=caFree; // The form is closed and all allocated memory for the form is freed.
end;
end.[/code][/size]
The whole project is here: app.box.com/s/zehmwy3w9zdgl986v4en
thank u for your answer,so should i download The whole project from: app.box.com/s/zehmwy3w9zdgl986v4en ?
and what about reading the digital signals ?
thank u for your answer,so should i download The whole project from: app.box.com/s/zehmwy3w9zdgl986v4en ? Yes, it is a ZIP package. Please extract it to a folder. Then from the Lazarus editor/compiler IDE select Open Project in the Project menu.
For more info please see: wiki.freepascal.org/Lazarus_Tutorial
[quote]and what about reading the digital signals [/quote]You can use either the function ReadDigitalChannel or ReadAllDigital.
Here an example code where the function ReadAllDigital has been used:
[size=85][code]unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
ConnectButton: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Label1: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label2: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Timer1: TTimer;
procedure ConnectButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
CardAddress:longint;
implementation
{$R *.lfm}
function OpenDevice: Longint; stdcall; external ‘K8061.dll’;
procedure CloseDevices; stdcall; external ‘K8061.dll’;
function ReadAnalogChannel(CardAddress: Longint; Channel: Longint):Longint; stdcall; external ‘K8061.dll’;
procedure ReadAllAnalog(CardAddress: Longint; Buffer: Pointer); stdcall; external ‘K8061.dll’;
function ReadDigitalChannel(CardAddress: Longint; Channel: Longint): Boolean; stdcall; external ‘K8061.dll’;
function ReadAllDigital(CardAddress: Longint): Longint; stdcall; external ‘K8061.dll’;
procedure TForm1.ConnectButtonClick(Sender: TObject);
var h:longint;
begin
h:= OpenDevice;
case h of
0…7: begin
label12.caption:=‘Card ‘+ inttostr(h)+’ connected’;
timer1.enabled:=true;
CardAddress:=h;
end;
-1: label12.caption:=‘All cards connected.’;
-2: label12.caption:=‘Card not found.’;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var Data: array [0…7] of LongInt;
i:LongInt;
begin
Timer1.Enabled:=False;
ReadAllAnalog(CardAddress,@Data[0]);
Edit1.Text:=IntToStr(Data[0]);
Edit2.Text:=IntToStr(Data[1]);
Edit3.Text:=IntToStr(Data[2]);
Edit4.Text:=IntToStr(Data[3]);
Edit5.Text:=IntToStr(Data[4]);
Edit6.Text:=IntToStr(Data[5]);
Edit7.Text:=IntToStr(Data[6]);
Edit8.Text:=IntToStr(Data[7]);
i:=ReadAllDigital(CardAddress);
CheckBox1.Checked:=(i and 1)>0;
CheckBox2.Checked:=(i and 2)>0;
CheckBox3.Checked:=(i and 4)>0;
CheckBox4.Checked:=(i and 8)>0;
CheckBox5.Checked:=(i and 16)>0;
CheckBox6.Checked:=(i and 32)>0;
CheckBox7.Checked:=(i and 64)>0;
CheckBox8.Checked:=(i and 128)>0;
Timer1.Enabled:=True;
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
CloseDevices;
CloseAction:=caFree; // The form is closed and all allocated memory for the form is freed.
end;
end.[/code][/size]
And the result may look like this:
thank u
but i don’t have the Lazarus editor/compiler ? from where can i get it
thank u very much
best regards