Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

C++ example of Using SCC-RLY01(relay) with NI-6062E?

Hello,

I would like to known where I can find examples of using SCC-RLY01(relay) with NI-6062E under DAQmx, C++ and Measurement Studio?

Thank you!
0 Kudos
Message 1 of 9
(4,107 Views)
Hi Rolly-

The SCC-RLY01 is just controlled by the digital lines of your DAQ board on port 0 as explained in the SCC-RLY01 User Manual on pages 3-4.

Examples for controlling the digital lines in C++ install automatically with Measurement Studio in the "C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\Generate Values" directory of your hard drive. Pertinent examples are "Write Dig Chan" and "Write Dig Port."

I hope this helps!

EDIT: Please make sure you are using NI-DAQmx 7.1 or later. According to This KnowledgeBase the SCC-RLY01 is only supported in version 7.1 or later.

Thanks-

Message Edited by Tom W. on 06-30-2005 04:17 PM

Tom W
National Instruments
0 Kudos
Message 2 of 9
(4,109 Views)
Hello Tom,
 
Thanks for your advice, besides the folder you mentioned, I also discovered this C:\Program Files\National Instruments\MeasurementStudioVS2003\VCNET\Examples\DAQmx\Digital\Generate Values, where I found the WriteDigPort example, and it used a different approach, i.e. CNiDAQmxDigitalSingleChannelWriter. Whereas the example you mentioned used DAQmxWriteDigitalU32. Could you please advice the relationship between these methods and which one is better for beginner like myself? 
I understand I can write different digital data to the SCC-RLY01, but what is the correct value to trigger "Open" (0?)and "Close"(1?).
What happens if I wrote value of 255 or others besides 0 and 1 to the relay? 
Smiley Happy
 
Thank you,
Rolly

Message Edited by Rolly on 07-02-2005 02:03 PM

0 Kudos
Message 3 of 9
(4,081 Views)
Hello Tom,
 
After testing the example you mentioned, I discovered in the Write Dig Port, it used:
 DAQmxErrChk (Configure_WriteDigPort("Dev1/port0",&taskHandle));
 DAQmxErrChk (Start_WriteDigPort(taskHandle));
 DAQmxErrChk (Write_WriteDigPort(taskHandle,data));
 
Since I used the SCC2345 with 4 SCC-RLY01 relays in socket 9, 10 ,11, 12, I need to specify the Dev and port to write, how can I change that as in "Dev1/port0"? Shall it be "Dev1/SCCMod9/port0" and so on?
 
Secondly, what data should I wrote to trigger open(I tried 0, it works) and open(1) of the relay? What will happen if I wrote other values? i.e. 255?
 
Finally I would like to know the minimum respond time of the relay? i.e. How fast can I trigger it from open to close then back  to open? 1 millisec possible?
 
Thank you for patient.
Regards,
Rolly 
0 Kudos
Message 4 of 9
(4,075 Views)
Hello Tom,
 
I also wonder if there is something like "timer" in DAQmx where I can wait for a certain milliseconds btw two DAQmxWriteDigitalScalarU32 events:
what I am doing now is split into two sections as following code
 
//NI trigger relay ON (Close)

  if (UserHookDataPtr->ProcessedImageCount == 10)

   {   DAQmxCreateTask("",&taskHandle);

       DAQmxCreateDOChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines);

       DAQmxStartTask(taskHandle);

       DAQmxWriteDigitalScalarU32 (taskHandle, 1, 10.0, 1, NULL);

       DAQmxClearTask(taskHandle); }

   //NI trigger relay OFF (Open)

   if (UserHookDataPtr->ProcessedImageCount == 40)

   {   DAQmxCreateTask("",&taskHandle);

       DAQmxCreateDOChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines);

       DAQmxStartTask(taskHandle);

       DAQmxWriteDigitalScalarU32 (taskHandle, 1, 10.0, 0, NULL);

       DAQmxClearTask(taskHandle); }

 

0 Kudos
Message 5 of 9
(4,069 Views)

However I would like to simplify and combine them together as:

//NI trigger relay ON & OFF

   if (UserHookDataPtr->ProcessedImageCount == 10)

   {   DAQmxCreateTask("",&taskHandle);

       DAQmxCreateDOChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines);

       DAQmxStartTask(taskHandle);

       DAQmxWriteDigitalScalarU32 (taskHandle, 1, 10.0, 1, NULL);

       [Timer to wait 500 millisecond];

       DAQmxWriteDigitalScalarU32 (taskHandle, 1, 10.0, 0, NULL);

       DAQmxClearTask(taskHandle);}

Is this possible? and what timer should I use?

Thank you!

0 Kudos
Message 6 of 9
(4,074 Views)
Hi Rolly-
 
Let me see if I can address your questions.
 
First, I would recommend using the DAQmxWriteDigitalU32 function to address the ports because it is more straightforward than the more advanced function you have seen elsewhere.  I would suggest using the format of the "Write Dig Port" example and writing values to open and close certain relays as you desire.  For instance, if you would like to open relays on J9 and J10 I would write 0xb00000011 or 0d3 to port zero.  Instructions for connecting the modules so that a logic "high" will activate the lines can be found in this KnowledgeBase
 
All of the relays will be controlled by port 0 of the device and do not need to be called seperately if you employ the method I suggested previously of writing to the entire port and activating or deactivating the relays based on your needs.  The format "DevX/port0" will be the only necessary setting. 
 
The operate times are given in page four of the SCC-RLY01 Relay Module User Guide  .  The Average switching times for closed to open and open to closed switching are 5ms and 4ms, respectively.  The longest guaranteed operation times for these are 10ms and 5ms, respectively, so an ON-OFF-ON cycle will not be possible within 1ms.  The worst case for this operation will be 15ms.
 
Finally, there is no need to destroy and recreate tasks as a single task that writes to port 0 of the device will be sufficient.  NI-DAQmx does not have timer functionality to implement the delay between operations.  I don't have a great deal of experience with implementing delays in C++ but you should be able to find references of built-in functions from C++ to accomplish this functionality.
 
I hope this helps!
 
Thanks-
 
Tom W
National Instruments
0 Kudos
Message 7 of 9
(4,047 Views)
Hi Tom,
Thank you for replying, I change the name of the device from "DevX/port0" to "SCC1Mod9/port0" as indicated from MAX, but I have error as show on the attached sreen shot. How can I resolve this problem?
If I can only use "DevX/port0", how can I individually switch ON/OFF these relays?
 
Thx, and now I can switch OFF/ON/OFF with 0/1/0 Smiley Very Happy
 
Regards,
Rolly

Message Edited by Rolly on 07-07-2005 11:26 AM

0 Kudos
Message 8 of 9
(4,044 Views)

Hi Rolly-

As mentioned in my last post you will still need to address the lines as "DevX/port0" to control the relays.  As you have seen there will be errors if you attempt to access them by their "SCC1ModX" identifiers.

When you use "DevX/port0" with the "DAQmxWriteDigitalU32" function to write an entire port value for the lines you would like to control.  This will give the best simultaneous control between the lines and will be the best method.  This can be accomplished by writing a port value such as 0b11111111 (i.e. 0d255 or 0xFF) to write a "high" to each line or write highs and lows only to the appropriate lines.  As mentioned before the port0 lines will control the relays in ascending order beginning with slot J9.

I hope this helps.

Tom W
National Instruments
Message 9 of 9
(4,024 Views)