Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to programming USB-6009 with Delphi but....

realTroy,
 
Thanks for your attachment.
 
How do you solved the problem  "Access violation at address 000003E8. Read of address 000003E8." ?
I have the same problem.
 
I will have my USB 6009 during the next few days.
 
I will test it to see if I have the same speed problem. We Delphi programmers have to work togheter, to bypass the non-existent
support from National (regarding Delphi).
 
I believe that this topic will be of interest to many people.
 
Thanks
 
Joaquim
 
0 Kudos
Message 11 of 17
(3,195 Views)

I am having the same problems that have arisen before in this thread, but there seems to be no solution posted up. (Although the rewritten nidaqmx unit is very helpful - it would be good if that were being distributed by NI in the nidaqmx_80_delphi zip).

When I look at the example programs I find that in the VB6 example for reading a voltage there is no call to DAQmxStartTask, but this is present in the C example. When I include this call I get the "Access violation at address 0000003E8" error; if I don't call DAQmxStartTask then a call to DAQmxReadAnalogF64 produces the same output each time (in fact the read variable is not updated in that function call).

Does anyone have a simple piece of code which shows how to read the analogue inputs on the USB-6009?

 

0 Kudos
Message 12 of 17
(3,102 Views)
Hi RTP -

Which version of the DAQmx driver are you working with?  The only analog input example for VB6 that ships with DAQmx 8.3 is Acq-Int Clk.vbp, which I found in this folder:

C:\Program Files\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\Analog In\Measure Voltage\Acq-Int Clk

In this example, I see what you're saying about the DAQmxStartTask function not being present.  If you look in the documentation file called NI-DAQmx C Reference Help, you'll find the answer to your question in this part of the Contents tree:

NI-DAQmx Concepts >> NI-DAQmx Key Concepts >> Channels and Tasks >> Tasks >> Explicitly Starting a Task

In the Starting a Finite Measurement Task section, the text explains that the DAQmxStartTask and DAQmxStopTask funcitons aren't necessary.  This explains why the program works without calling them.

As for the error you get when the function is added, I'm unable to reproduce that.  On line 88, I inserted this string:  DAQmxStartTask(taskHandle), and the program ran without error.  What environment (OS, ADE, etc) are you working in?
David Staab, CLA
Staff Systems Engineer
National Instruments
0 Kudos
Message 13 of 17
(3,080 Views)
Dear Delphi&USB-friends,

Although I tried all of the examples listed above, I could not get any serous data out of my USB6009.

I tried to simplfy the code to this:

Function TMainform.ReadValue( Channel : Integer ) : extended;
var
  hdl           : Integer;
  data, ModeNew : Double;
  ret           : LongInt;
  channelstr    : string;
  channelpchar  : pansichar;
  Value, Mode   : integer;
begin
  ret := DAQmxCreateTask('Analog Input', @hdl);
  channelstr := 'Dev1/ai' ;
  channelpchar := addr(channelstr[1]);
  //ret := DAQmxCreateAIVoltageChan(hdl, channelpchar, '', DAQmx_Cfg_Default(-1),       -10.0, 10.0, DAQmxVoltageUnits2(0),         nil);
  ret := DAQmxCreateAIVoltageChan(hdl, channelpchar, '', DAQmx_Val_InputTermCfg_RSE,  -10.0, 10.0, DAQmx_Val_VoltageUnits1_Volts, '');
  ret := DAQmxReadAnalogScalarF64(hdl, 100, @data, nil);
  ret := DAQmxWaitUntilTaskDone(hdl,10);
  ret := DAQmxStopTask(hdl);
  ret := DAQmxClearTask(hdl);
  result := data ;
end;

But all I get is "1.1246933868e-312", which is seems to be not correct.

All return values are "0", which should mean that the call and execution was OK (isn't it?)
Morover, I added the fixed "nidaqmx.pas" file.

Could any one tell what am I doing wrong?

thanx in advance,
Wollie

0 Kudos
Message 14 of 17
(2,860 Views)
Hi Wollie -

I have to merely repeat Justin's post from months ago:  NI doesn't support Borland Delphi with DAQmx, but hopefully someone else on the forums has had some success.  If any working code is found, I'll be happy to add it to the KnowledgeBase article.

Message Edited by David S. on 04-12-2007 08:46 AM

David Staab, CLA
Staff Systems Engineer
National Instruments
0 Kudos
Message 15 of 17
(2,847 Views)
Hi david,

yes I know. Therefore I spent a bit more time since I was waiting on a relpy and get things to work with trial and error.

At the end, it seemed to be a failing USB cable, which worked sometimes and sometimes didn't.

For other people who starts working with the stuff, here a bit of code that works:

procedure TMainform.DoMeasure(Sender: TObject);
var
  hdl  : Integer;
  data : Double;
  ret  : LongInt;
begin

  ret := DAQmxCreateTask('Analog Input', @hdl);
  ret := DAQmxCreateAIVoltageChan(hdl, 'Dev1/ai0', '', DAQmx_Val_InputTermCfg_RSE,  -10.0, 10.0, DAQmx_Val_VoltageUnits1_Volts, '');
  ret := DAQmxReadAnalogScalarF64(hdl, 100, @data, nil);
  ret := DAQmxWaitUntilTaskDone(hdl,10);
  ret := DAQmxStopTask(hdl);
  ret := DAQmxClearTask(hdl);
end;

Now I'm still struggling with the digital out "DAQmxWriteDigitalLines", Getting error -200562 .Anyone a clue?

regards,
Wollie

Message Edited by Wollie on 04-12-2007 10:25 AM

0 Kudos
Message 16 of 17
(2,841 Views)
Hi Wollie -

The message text of that error is, Measurements: Attempted writing digital data that is not supported.  Perhaps you're trying to give the wrong datatype or integer width to the function?  (U8, U16, U32)
David Staab, CLA
Staff Systems Engineer
National Instruments
0 Kudos
Message 17 of 17
(2,825 Views)