Entradas digitales - Software

Nota

Esta sección cubre entradas digitales en software. Para obtener una guía de hardware para entradas digitales, consulte Entradas digitales - Hardware.

The Systemcore’s Smart I/O supports up to 6 digital input channels.

Digital inputs read one of two states - «high» or «low.» By default, the built-in ports on the RIO will read «low» due to internal pull-up resistors (for more information, see Entradas digitales - Hardware). Accordingly, digital inputs are most-commonly used with switches of some sort. Support for this usage is provided through the DigitalInput class (Java, C++).

Advertencia

The roboRIO had pull-up resistors instead of pull-down resistors, so the behavior of the Smart I/O ports is different from that of the roboRIO’s digital input ports. This means that sensors designed for the roboRIO’s digital input ports may different wiring for the Smart I/O ports.

La clase DigitalInput

Una entrada digital DigitalInput se puede inicializar de la siguiente manera:

  // Initializes a DigitalInput on DIO 0
  DigitalInput input = new DigitalInput(0);
  // Initializes a DigitalInput on DIO 0
  wpi::DigitalInput input{0};

Leyendo el valor de DigitalInput

El estado de DigitalInput se puede consultar con el método get:

    // Gets the value of the digital input.  Returns true if the circuit is open.
    input.get();
    // Gets the value of the digital input.  Returns true if the circuit is
    // open.
    input.Get();

Crear una DigitalInput a partir de un AnalogInput.

Nota

Analog Triggers are not supported on Systemcore.

Uso de entradas digitales en el código

As almost all switches on the robot will be used through a DigitalInput. This class is extremely important for effective robot control.

Limitar el rango de movimiento de un mecanismo

Nearly all motorized mechanisms (such as arms and elevators) in FRC® should be given some form of «limit switch» to prevent them from damaging themselves at the end of their range of motions. For an example of this, see Programación de interruptores de límite.

Dirigiendo un mecanismo

Limit switches are very important for being able to «home» a mechanism with an encoder. For an example of this, see Homing a Mechanism.