Relays Return to Their Default Position Upon Initialization.
Hardware: Switches>>Multiplexer/Matrix>>PXI-2501
Problem: In a switch program that requires stopping and starting the program, I have to reinitialize my switch which results in the relays returning to their default positions. I would like to keep the switch in its current state between operations or times that I stop and start the program. How can I do this?
Solution: When a session to a switch module is opened, all the relays are set in their default position. Therefore, within a session the driver can track the state of each relay and report it to the user upon request. To maintain the state of the relays, here are 2 options:
- The easiest method is to keep your program running in a loop. Initialize once before entering the loop, use a while loop to execute all of the switch operations, and finally when you are done, exit the loop and call the niSwitch Close. This prevents the program from having to call the Initialize routine several times, which would reset the relays each time (an example is attached "Continuous Switching VI").
- A more advanced method is to use a global variable to record and reuse the session Instrument Handle. This would allow you to use the Instrument Handle until you close out the session.
To do this, at the start you will need to call niSwitch Initialize VI and write the Instrument Handle out to a global variable. Then as you need to complete switch operations, you can pass the Instrument Handle Global into the switch VI's similar to how you would typically pass it in from the Switch Initialization. Since the session has not been closed out, the driver will continue to track and maintain the state of the switch.
Once you have completed all of the switch operations, call the niSwitch Close VI using the session global to end the session. After closing the session, any further use will require a new session which will cause the relays to reinitialize.
Related Links:
Attachments:

Report Date: 06/12/2003
Last Updated: 01/28/2007
Document ID: 2YBA68ZO