How to time external events
Any event or occurrence can be timed provided there is a clear way to determine the beginning and ending points of that event. This section deals with the timing of an event which is triggered by the closing of electrical contacts. The Digital I/O Module or the Digital Input Module can be used to sense the contact closures and report them to the host PC or Laptop. Refer to the product data sheet for more information on how to use and wire up these modules.
To time an event, whether external or within the program execution itself, ModCom provides an Event Timer which is ideal for this task. This object can be run in stand-alone mode, or be operated on by other objects within ModCom. Simply choose an Event Timer from the <Place Object> menu at the top of the screen and move it to the desired position with the mouse. Follow the steps below to set up the Event Timer for operation.
Step 1: Connect the inputs of the DAQ Module to the electrical contacts being used to indicate the starting and stopping points of the event to be timed. This can be two separate contact pairs, or a single pair can be used for both start and stop.
Step 2: To use the Digital I/O Module or Digital Input Module to report a contact closure on its inputs, you must first set up these inputs for BUTTON configuration. Go to the <Run-Loop> menu at the top of the screen and click on Initialization. From the command set shown in Table 2 of the product data sheet, choose the command string or strings which are required to set up the desired inputs for BUTTON and type them into this dialog box. If using the Digital I/O Module you will also have to disable the TYPEMATIC feature of these inputs; this dialog box is where you would place those command strings also. Close out this box when you have finished.
Step 3: To set the properties of the Event Timer, right-click on the object. This will bring up the Properties dialog box which contains a number of user defined attributes which can be used to customize the Event Timer's appearance and operation.
Step 4: In the "Conditionals" section, type in the command strings which will be returned from the DAQ Module when the start and stop contact closures occur. If you are uncertain about the syntax of these command strings, open the Send/Receive dialog box in the <Communicate> menu and look at the data being returned when these contact closures take place. Be sure to click on the "Send Config" button initially to make sure that the DAQ Module's inputs are set up for BUTTON.
Step 5: Close out the Properties dialog box and start the main run-time loop by clicking on the green "Run" button at the top of the screen. Execute the event and watch how the Event Timer measures the time it takes for the event to complete.
You can place a multitude of Event Timers on the screen and configure them to respond to their own set of contact closures allowing a whole series of events to be timed and compared to each other. If wishing to start or stop a group of Event Timers in unison with a single contact closure, write a Conditional statement to respond to the contact closure and have it start or stop all of the Event Timers.