Impinj GPIO quick start guide

First explain GPIO, General-purpose input/output, general-purpose input/output interface. In fact, it uses the high and low potential of the pins to transmit information, so as to control external devices or obtain control of external devices. The two most common examples are infrared sensors and alarms.
The infrared alarm is regarded as an input device (with the controller as the main body). It can detect whether there is an object in front of it. Once an object is detected, it outputs a signal. The controller gets the signal and can make a further response.
The alarm is an output response device, which can respond to the alarm after it is controlled by the signal.
The following introduces a simple case to have a comprehensive understanding of the use process and methods of GPIO. Note that the following is just how to connect, please refer to the attached document ( ImpinjGPIO document collection ) for the specific principles and other details .
https://download.csdn.net/download/xiaohaigary/11580460

1. Equipment used

1. Impinj reader, impinj GPIO box, 24v DC power adapter
2. Infrared sensor (DC three-wire NPN normally open type), sound and light alarm (5-wire type)
 impinj reader, impinj GPIO box, 24v DC power adapter
Infrared sensor (DC three-wire NPN normally open type), sound and light alarm

2. Wiring

Schematic diagram of the GPIO box
This is a schematic diagram of the GPIO box, one of which is connected to the GPIO port of R420, 8 and 9 are respectively connected to an external DC 24V power supply, 8 positive and 9 negative. At this point, the basic preparations are completed. You can use the Item Test that comes with impinj to test it. When out 1 is valid, the light on No. 4 is on, and when out 4 is valid, the light on No. 7 is on.

The next step is to connect the sound and light alarm, which is the wiring of the five-wire alarm. The two leftmost wires are the positive and negative power supply. The gray wire in the middle is the speaker control wire, the fourth (red wire) is the light control wire, and the fifth (black wire) is the common end or ground wire.

Insert picture description here

How to connect the alarm to the GPIO box?
First of all, the two power cords can be connected at positions 8 and 9, or at positions 10 and 15.
The red light control line is connected to position 4, which is out1. The gray wire connects to position 5, which is out2.
The last black wire is connected at number 3.
In this way, the connection of the sound and light alarm is completed. Use ItemTest to test, you can control the sound and light separately to alarm.

Now let's talk about the connection of the infrared sensor:
1, 2, and 3 marked in the figure below are the three wires of the infrared sensor. 1 and 3 are the positive and negative electrodes respectively. Connect to positions 10 and 15 respectively. 2 is the control line, connected to 11 positions.
Test: Cover the infrared sensor with your hand and see if the small lights at 11 will be on. If it is on, it means the sensor is working normally.
Insert picture description here

Principle of output signal control:

This box is actually quite convenient, the output is a relay output. But I tried to connect one end directly to COM and the other end to out1, and then the small light could not be used.
I consulted the manufacturer and found that the power supply only supports 0-5v small lights.
But how to control the two-wire small lights that are on when the power is supplied? Let's talk about the connection methods for the two-wire small lights and the four-wire small lights in turn.

Core principle: When outX is valid, it will be connected to COM to form the level of COM.
Two-line small lights:

If it is a small 24v light, it is too convenient.

The positive pole of the lamp---->24v of the box +
negative pole of the lamp---->
The COM port of the box out1 of the box is shorted to the 0V of the box

In this way, when out1 is valid, the out1 and COM ports are connected, and the positive and negative poles of the small light are also connected.

But what if it is a 12v two-line small light?
That must add a 12v power supply.

The positive pole of the lamp---->12v+the
negative pole of the lamp---->
The COM port of the out1 box of the box is shorted to the 0V of the box, and also to the 0 pole of the 12v power supply, so that the two power supplies are zero.

Four-line small lights:

The four-wire small light is a light triggered by high and low levels. The four lines are: positive, negative, high-level trigger line, and low-level trigger line.

The positive pole of the lamp---->The 24v of the box +
the low level trigger line of the lamp---->
The COM port of the box out1 of the box is shorted to the 0V of the box

At this time, when out1 of the box is valid, it is low, and the small light will be triggered.

Three, code control

The following code is used to demonstrate: After the infrared sensor detects an object, the sound and light alarm will alarm.

package com.example.sdksamples;

import com.impinj.octane.ImpinjReader;
import com.impinj.octane.OctaneSdkException;
import com.impinj.octane.Settings;

import java.util.Scanner;

public class SetGPO {

    public static void main(String[] args) {

        try {
            String hostname = System.getProperty(SampleProperties.hostname);

            if (hostname == null) {
                throw new Exception("Must specify the '"
                        + SampleProperties.hostname + "' property");
            }

            ImpinjReader reader = new ImpinjReader();

            reader.connect(hostname);

            Settings settings = reader.queryDefaultSettings();
            reader.applySettings(settings);


            reader.setGpiChangeListener(
                            new GpiChangeListenerImplementation()
            );

           	
        } catch (OctaneSdkException ex) {
            System.out.println(ex.getMessage());
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            ex.printStackTrace(System.out);
        }
    }
}

The GpiChangeListenerImplementation file is:

package com.example.sdksamples;
import com.impinj.octane.GpiChangeListener;
import com.impinj.octane.GpiEvent;
import com.impinj.octane.ImpinjReader;
import com.impinj.octane.OctaneSdkException;

public class GpiChangeListenerImplementation implements GpiChangeListener {

    @Override
    public void onGpiChanged(ImpinjReader reader, GpiEvent e) {
        System.out.println("GPI Change--port: " + e.getPortNumber()
                + " status: " + e.isState());
        try {
            if(e.isState()==true){

                reader.setGpo(1, true);
reader.setGpo(2, true);
            }else{
                reader.setGpo(1, true);
reader.setGpo(2, true);
            }
        } catch (OctaneSdkException ex) {
            ex.printStackTrace();
        }
    }
}

Guess you like

Origin blog.csdn.net/xiaohaigary/article/details/99765196