S200DriveIO.cs

Setup and use the avaiable I/O on the J13 connector of the SynqNet option card on an S200 drive

/*  
 Copyright(c) 1998-2009 by Robotic Systems Integration, Inc. All rights reserved.
 This software contains proprietary and confidential information of Robotic 
 Systems Integration, Inc. (RSI) and its suppliers. Except as may be set forth 
 in the license agreement under which this software is supplied, disclosure, 
 reproduction, or use with controls other than those provided by RSI or suppliers
 for RSI is strictly prohibited without the prior express written consent of 
 Robotic Systems Integration.

 Warning!  This is a sample program to assist in the integration of your motion 
 controller with your application.  It may not contain all of the logic and safety
 features that your application requires.

 For any questions regarding this sample code please visit www.roboticsys.com.
 ==================================================================================
*/

using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
//using NUnit.Framework.SyntaxHelpers;
using RSI.RapidCode.SynqNet.dotNET;
using RSI.RapidCode.SynqNet.dotNET.Enums;

namespace SampleApplications
{
    [TestFixture]
    public class S200DriveIO
    {
   
        MotionController controller;             // RapidCode objects
        Axis axis;
        
        
        [Test]
        public void Main()
        {
            try
            {
                //local variables
                bool[] Input;
                bool[] DedicatedInput;
                Input = new bool[16];
                DedicatedInput = new bool[4];
                double AnalogIN;
                int i;
                                

                //RapidCode Objects
                controller = MotionController.CreateFromBoard(0);
                axis = controller.AxisGet(0);


                //Digital Output J13 (SyqNet Option Card) pins 8 & 9
                Console.WriteLine("Testing available output: J13 Pins 8 & 9 "); 
                Console.Write("* * * * * * * Toggling Output");
                for (i = 0; i < 7; i++)
                {
                    if (i % 2 == 0)
                        axis.DigitalOutSet(RSIMotorGeneralIo.RSIMotorGeneralIo2, false); //OOUT Pins 8 & 9
                    else
                        axis.DigitalOutSet(RSIMotorGeneralIo.RSIMotorGeneralIo2, true); //OOUT Pins 8 & 9
                    Console.Write(" *");
                    controller.OS.Sleep(2000);
                }
                
                //General Digital Inputs J13 (SyqNet Option Card) pins 6,7 - 14,15 - 12,13  
                Input[0] = axis.DigitalInGet(RSIMotorGeneralIo.RSIMotorGeneralIo0); //IN0 Pins 12 & 13
                Input[1] = axis.DigitalInGet(RSIMotorGeneralIo.RSIMotorGeneralIo1); //IN1 Pins 14 & 15
                Input[3] = axis.DigitalInGet(RSIMotorGeneralIo.RSIMotorGeneralIo3); //IN3 Pins 6 & 7
                Console.WriteLine("\n\nReading available general purpose inputs...");
                Console.WriteLine("IN0:" + Input[0]);
                Console.WriteLine("IN1:" + Input[1]);
                Console.WriteLine("IN3:" + Input[3]);

                //Dedicated Digital Inputs J13 (SynqNet Option card) pins 1,2, - 1,3, - 1,4
                DedicatedInput[0] = axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInHOME);    //HOME Pins 1 & 2
                DedicatedInput[1] = axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInLIMIT_HW_NEG);  //NegLimit Pins 1 & 4
                DedicatedInput[2] = axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInLIMIT_HW_POS);  //PosLimit Pins 1 & 3
                Console.WriteLine("\nReading available dedicated purpose inputs...");
                Console.WriteLine("Home:" + DedicatedInput[0]);
                Console.WriteLine("Neg_Limit:" + DedicatedInput[1]);
                Console.WriteLine("Pos_Limit:" + DedicatedInput[2]);


                //Analog Differential Input –12.5 to +15.5 VDC on J4 pins 24,25,26 
                axis.DriveMonitorAddressSet(0, (int)RSIS200MonitorAddress.RSIS200MonitorAddressCMD_IN);
                AnalogIN = axis.DriveMonitorValueGet(0);
                Console.WriteLine("\nReading available analog input...");
                Console.WriteLine("Analog CMD_IN:" + AnalogIN);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}