Digital Inputs Overview

Written on: October 20, 2022 12:23 pm

The 410 has 8 inputs and 8 outputs, the 412 and 412DMX have 4 inputs and 12 outputs, and the 414 has 12 inputs and 4 outputs. Each digital input can accept AC or DC voltage sources in the 0 – 30 V range. The input voltage must be greater than 2 VDC for the input to register as “on” and then less than 1 VDC to register as “off”. The JNIOR uses a 2-piece terminal connector system for all power and I/O wiring connections allowing for easy installation and/or removal of the JNIOR. Digital Inputs are Optically Isolated.  

Controlling Digital Inputs

When controlling the JNIOR’s I/O, the JANOS class can be used to get/manipulate their statuses. In the following example the JANOS class is used to invert an input and print the input state mask, manipulate an input counter, and check an input’s usage meter.

package inputcontrolexample;

import com.integpg.system.JANOS;
import java.io.IOException;
import static java.lang.Thread.sleep;

public class InputControlExample {
    
    public static void main(String[] args) throws IOException, InterruptedException {
        
        //Use input conditioning to invert input 1's status
        JANOS.setInputConditioning(0, JANOS.INPUT_COND_INVERT);
        //print out the current mask of inputs that are on.
        System.out.println(String.format("current input states are %d\n", JANOS.getInputStates()));
        sleep(3000);
        //Turn off input 1's inversion
        JANOS.setInputConditioning(0, JANOS.INPUT_COND_NONE);
        sleep(1000);
        //Check and manipulate input 1 counter
        System.out.println(String.format("Current counter value for input 1: %d\n", JANOS.getInputCounter(0)));
        JANOS.incInputCounter(0);
        System.out.println(String.format("Current counter value for input 1 after being incremented: %d\n", JANOS.getInputCounter(0)));
        JANOS.setInputCounter(0, 100);
        System.out.println(String.format("Current counter value for input 1 after being set to 100: %d\n", JANOS.getInputCounter(0)));
        //print out usage meter value for input 1, values may change for different model JNIOR:
        System.out.println(String.format("Current usage meter value for input 1: %d\n", JANOS.getUsageMeter(0)));
        
    }

}

I put the built jar file of this example application into the JNIOR’s flash folder and ran it from the Web UI’s console tab. As you can see it displays different data about the inputs at the time of the application running.

Getting Inputs from the IO Log

Another way to interact with the I/O on the JNIOR is via the Iolog Monitor. The Iolog Monitor is an object that can be checked for I/O events that have occurred on the JNIOR. There is the IoEvent class and Iolog class. An IoEvent is when an input or output state changed on the JNIOR, and the Iolog is an object that contains all the IoEvents from a certain timestamp. The example below inverts an input, and then shows how the Iolog has recorded that input pulse as an IoEvent.

package inputcontrolexample2;

import com.integpg.system.IoEvent;
import com.integpg.system.Iolog;
import com.integpg.system.JANOS;
import java.io.IOException;
import static java.lang.Thread.sleep;
import java.text.SimpleDateFormat;

public class InputControlExample2 {

    public static void main(String[] args) throws IOException, InterruptedException {
        
        //gets the current time as a long.
        long now = System.currentTimeMillis();
        
        JANOS.setRegistryString("IO/Inputs/din1/Inversion", "enabled");
        sleep(4000);
        JANOS.setRegistryString("IO/Inputs/din1/Inversion", "disabled");
        
        //iolog object for getting I/O events
        //refresh Iolog so getting output events from it are only output evetns
        //from when this application start AKA the outputs we just pulsed. 
        Iolog iolog = new Iolog();
        iolog.refresh(now);
        IoEvent[] events = iolog.getInputEvents();

        //for each output event in the iolog, print the output states at that
        //time and the timestamp it occured.
        if (events.length > 0) {
            //SimpleDateFormat object that formats the timestamps of the IO events
            //into a caladender date and time.
            SimpleDateFormat date = new SimpleDateFormat("MM/dd/yy HH:mm:ss.SSS");
            for (int i = iolog.getInputEvents().length - 1; i >= 0; i--) {
                System.out.println(String.format("States: %d @ %s\n",
                        events[i].states, date.format(events[i].timestamp)));
            }
        } else {
            System.out.println("no input events...\n");
        }
        
    }
    
}

I put the built jar file of this example application into the JNIOR’s flash folder and ran it from the Web UI’s console tab. As you can see it recorded the input change where input 1 turned on and again when it turned back off.

By | Updated On October 24, 2022 2:59 pm | No Comments | Categories: , | Tags:


 

INTEG Process Group, inc. © 2022

Real-Time
Mon - Fri, 8am - 4pm EST
P: 724-933-9350
PureChat
Always Available
Contact Form
sales@integpg.com
support@integpg.com

@integpg
@jniordev