PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about niDCPower_SetSequence in niDCPower library used to set PXIe-4141

The help says:

 

Function niDCPower_SetSequence(vi As ViSession, channelName As ViString, values As ViReal64, sourceDelays As ViReal64, size As ViUInt32) As ViStatus
    Member of niDCPower.Functions_Source
    Set Sequence

 

In above function, the input values (values of the sequence to set) and sourceDelays (delay of each sample of the sequence) should be array or double? I tried both, but neither works. Below is my code:

 

....

vistat = niDCPower_Abort(session)
vistat = niDCPower_ConfigureSourceMode(session, NIDCPOWER_VAL_SEQUENCE)
vistat = niDCPower_ConfigureOutputFunction(session, chan, NIDCPOWER_VAL_DC_VOLTAGE)
vistat = niDCPower_ConfigureSense(session, chan, NIDCPOWER_VAL_LOCAL)
vistat = niDCPower_ConfigureVoltageLevelRange(session, chan, 10#)
vistat = niDCPower_ConfigureCurrentLimit(session, chan, NIDCPOWER_VAL_CURRENT_REGULATE, 2)

Dim x(), dt(), Vout() As Double
ReDim x(nStep - 1)
ReDim dt(nStep - 1)
For i = 0 To nStep - 1
    x(i) = x0 + CDbl(i) * dx
   dt(i) = dt0
Next
vistat = niDCPower_SetSequence(session, chan, x(), dt(), nStep)

vistat = niDCPower_Initiate(session)

...

 

I know... it is VB6... But we have to use it for now for some reasons. The program sequence is a direct tranlate from NI's example code in C#.

I also tried putting SetSequence into for loop and load double(x) and double(dt) every run. Still not working.

0 Kudos
Message 1 of 10
(7,581 Views)

here is error message when i use array in

 

error compile.png

0 Kudos
Message 2 of 10
(7,568 Views)

SetSequence expects an array of doubles. If you call it a second time, the previous values will be overwritten.

 

What do you mean by "it doesn't work"? Are you getting an error? Are you not seeing the output you are expecting?

 

It's been a while since I've used VB6 so my syntax is a bit rusty, but what you have appears correct to me without trying it.

Tobias
Principal Software Engineer
Driver Software
National Instruments
0 Kudos
Message 3 of 10
(7,564 Views)

Thanks! I uploaded the error window in an earlier reply. Actually the program can be compiled. But when the program run into vistat = SetSequence(session, chan, x(), dt, nStep), the error window pops up and x() is higlighted. Looks to me it is very likely the interface between main prgram and dll is wrong.

 

BTW, I tried SetSequence(session, chan, x, dt, nStep) instead of x(). (Here x is still an array of double) Same thing. 

0 Kudos
Message 4 of 10
(7,557 Views)

So, one thing to try, if you could.

 

I believe that you are declaring x() as variant because you're not specifying it's type (or of dt()) - only the type of Vout().

 

Try

Dim x() As Double, dt() As Double, Vout() As Double

Tobias
Principal Software Engineer
Driver Software
National Instruments
0 Kudos
Message 5 of 10
(7,550 Views)

Nope... Same thing. But it is good to know there is a difference. Thanks!

0 Kudos
Message 6 of 10
(7,547 Views)

hxu,

 

Have you tried declaring the Values and sourceDelays arrays in the ViReal64 datatype instead of Doubles?  I don't have a system set up that can run VB6 at the moment to try it out myself, but I am curious if this would solve the issue for you.

Regards,

Jared R.
Precision DC Product Support Engineer
National Instruments
0 Kudos
Message 7 of 10
(7,529 Views)

Yes, I tried decalring the array to be VIReal64, still not working. Only if I set values and delays to a non-array value, will no error pops up. But this definitely won't "set a sequence", right?

0 Kudos
Message 8 of 10
(7,521 Views)

Hi hxu,

 

Which of our examples did you base this code on?

 

Thanks!

 

 

Mason M
Applications Engineer
National Instruments
0 Kudos
Message 9 of 10
(7,485 Views)

Never mind, We found the solution ourselves:

 

In calling this function, one need put in first element of the array to set. In my case (see the first post), the change is:

vistat = niDCPower_SetSequence(session, chan, x(0), dt(0), nStep)

 

I guess the inside dll function is looking for a pointer.

0 Kudos
Message 10 of 10
(7,476 Views)