06-22-2011 09:02 AM
I am trying to output a fixed current to a single channel use VB6
My code is below. I get no error messages but I also get no output. If I save this task to MAX the current value saved is 0. If I change this and run it and I get the appropriate output.
DaqMxErrChk = DAQmxCreateTask("Task2", mytask1)
MsgBox ("Create Task" & DaqMxErrChk)
DaqMxErrChk = DAQmxCreateAOCurrentChan(mytask1, "Dev14/ao16", "ImaxLD1", 0, 0.02, DAQmx_Val_CurrentUnits2_Amps, "")
MsgBox ("Set Chan" & DaqMxErrChk)
DawMxErrChk = DAQmxWriteAnalogScalarF64(mytask1, True, 10, 0.01, Null)
MsgBox ("Set Current" & DaqMxErrChk)
DaqMxErrChk = DAQmxStartTask(mytask1)
MsgBox ("start" & DaqMxErrChk)
Solved! Go to Solution.
06-23-2011 01:22 PM
Clarify what you mean by, "If I can change this and run it and I get the appropriate output." I'm not sure what you mean by this. Not sure if this is a typo, but your code is: DawMxErrChk = DAQmxWriteAnalogScalarF64(mytask1, True, 10, 0.01, Null). You may need to change that.
Thanks,
Sean
06-27-2011 05:55 AM
I am running the task two ways.
#1 : With MAX. I need to manually enter the current set value since this value is not saved with the task. I then press the run button. This method works and I get output from the card.
#2 : With the VB code shown. When I run this all the functions return 0 (no error) but I get no output from the card. ("Daw " was just a typo when entering in this forum).
06-28-2011 10:59 AM
It maybe the fact that you are using the DAQmxErrchk as a handle, and that you are not performing a boolean check. See the attached example to verify syntax (it is for voltage, but it should still give you an idea of syntax).
Thanks,
Sean
07-05-2011 06:48 AM
With some help from ni support I found this solution. Last parameter in function call cannot be null
DaqMxErrChk = DAQmxWriteAnalogScalarF64(mytask1, True, 10, 0.003, ByVal 0&)