Trying to use a simple DLL function (written in C) that sets a voltage through a serial port.
The text from the documentation file reads:
Description: Sets the Voltage.
Entry Parameters: dV is the Value required. nMaxV is the known maximum for the voltage unit, which is planned to be 2000
Returns: 0 = failed
1 = success
-1 = range error
-2 = no COM1 available
int SetVoltage ( double dV, int nMaxV );
int nSuccess = SetVoltage ( 750.0, 2000 );
I've put the following into an application:
Function SetVoltage(var dV:double; nMaxV:integer):integer; stdcall; external 'THE.dll';
procedure TForm1.Button1Click(Sender: TObject);
temp, nMaxV : integer;
dV : double;
dV := 750.0;
nMaxV := 2000;
Temp := SetVoltage(dV, nMaxV);
Label.Caption := inttostr(temp);
I can't seem to make this function return anything other than -1 for range error. I believe this should work but I'm getting nowhere. I think it's time to ask people who are smarter than me...
Thanks in advance...