From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxSwitchCloseRelays() Issue

CVI 2012, XP Pro

 

Not sure this is the best place to post this, but hopefully there is an NI person who can answer this.

 

The description of  DAQmxSwitchCloseRelays() says:

"Closes the specified relays. If you set waitForSettling to TRUE, this function waits only after closing all relays. If you want to wait for settling after closing each relay, use this function multiple times to close each relay separately." and "If (waitForSettling) TRUE, this function waits for the switches to settle before returning. If FALSE, the function returns immediately after the operation."

 

When I read this, and decided to use the SCXI-1600 USB Controller and the SCXI relay module to control some solenoid valves, I expected that a call to this function, with waitForSettling = 0, would immediately return.  I assumed immediately meant, like, microseconds.  Testing this functionality results in very consistent 30 milliseconds delay before returning. 

 

What is this doing for 30 milliseconds?  Is there any way to speed this up?  I need much faster response than this.

 

 

 

0 Kudos
Message 1 of 4
(2,914 Views)

hendra@ngms,

 

If I am correct, you are putting this close function and the wait for settling in a loop? If so, then the time to iterate the code in the loop and reset itself may take up to a milisecond. the USB control of the SCXI is the slowest form of communicating and depending on how many lines it has to iterate through, this may take a considerable amount of time. If you answer the following questions I may be able to give you an idea of how realistic the data you are getting is:

 

What switch device are you using and how many of them do you have?

How many relays are you closing?

If you are using a loop here, Hhave you tried to put all the connections in one line instead? If you are not looping, disrgard this question.

What is the time difference if you do not wait for debounce on each connection separately but instread wait after the fact?

How are you measuring this delay time?

 

Best,

Jason M.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(2,895 Views)

Jason,

 

Thanks for looking into this.

 

I am not using a loop to wait for settling.  I don't want to wait for settling, I want the function to return immediately.  I am sequencing through a series of single relay closures at various intervals, that I would like to do as close together as 20 milliseconds.  So the code is call to close relay, delay a few msec, call to close relay, delay a few ms, etc, until five or six relays are closed. 

 

I'm wondering now about changing this to CompactDAQ.

 

To your questions:

 

What switch device are you using and how many of them do you have? SCXI-1161.  Two of them in my assembly.

 

How many relays are you closing?  Required to close only one at a time. 

 

If you are using a loop here, Hhave you tried to put all the connections in one line instead? If you are not looping, disrgard this question.  As described, must do these one at a time, no loop.

 

What is the time difference if you do not wait for debounce on each connection separately but instread wait after the fact?  My observation is that the function requires 16 - 31 milliseconeds to return, when waitforsettlilng = 0, longer if it is set to 1.

 

How are you measuring this delay time?  Yes, using both GetCurrentDateTime() and clock(), before and after the close relay call, subtracting one from teh other results in 16 or 31 milliseconds -- note that it is either, as though there is rounding going on; 16 or 31 milliseconds, not any number in between.

 

Thanks...

0 Kudos
Message 3 of 4
(2,886 Views)

hendra@ngms,

 

A few thing come to mind from your response. Firstly, getting the time and data and the clock function are purely software functions and are related to the PC you are using. This is not going to be the best way to measure your delay. Next, the proper way to delay the switching of the modules is one of the following ways: setting the "wait for debounce" to a specified value (max 5000ms), or set up a HW or SW trigger to indicate that a switch should close. You could also configure a scan list and set the value of the scan delay to a specified value (max 5000 ms). These properties will only be available on the PXI or SCXI platforms, as they are the only NI devices that are used with the NI Switch, Switch Executive, or DAQmx Switches drivers. I assume that you are interested in the cDAQ relay module. In this case, the best and most accurate way to indicate that the module should open and close is with a HW trigger. This could be configured with a digital device that outputs a pulse as a trigger. Let me know if you have any questions about anything discussed here.

 

Best,

Jason M.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(2,868 Views)