The “MXP I/O Expansion” example program demonstrates the use of the MXP I/O Expansion capabilities of the navX-MXP, including the following capabilities:
- Pulse-Width Modulation [PWM] (e.g., Motor Control)
- Digital Inputs (e.g., Contact Switch closure)
- Digital Outputs (e.g., Relay control)
- Quadrature Encoders (e.g., Wheel Encoder)
- Analog Inputs (e.g., Ultrasonic Sensor)
- Analog Input Trigger (e.g., Proximity Sensor trigger)
- Analog Trigger Counter
- Analog Output (e.g., Constant-current LED, Sound)
This example also demonstrates a simple method for calculating the ‘RoboRIO Channel Number’ which corresponds to a given navX-MXP IO Pin number.
FRC C++ Example
FRC Java Example
FRC LabView Example
The navX-MXP FieldCentric-Drive LabView example shows how to make small modifications to the LabView “FRC RoboRIO Robot Project” using the “Mecanum Robot” configuration to implement high-accuracy Field-Centric drive.
The RobotMain.vi invokes the InitExpansionIO.vi during initialization, and routes the resulting DigitalIoObjects and AnalogIoObjects clusters to the Teleop.vi.
The InitExpansionIO.vi instantiates the various objects which map onto the navX-MXP Expansion IO Pins.
The GetChannelFromNavX-MXPPin.vi performs the translation from the navX-MXP Digital or Analog Pin number to the corresponding RoboRIO Channel Number, which is provided to the various VIs that open that particular port.
The Teleop.vi reads the Joystick inputs and programs the output pins accordingly (PWM to motor controllers, Digital Outputs and Analog Outputs). As well, values from the input pins (Digital Inputs, Encoders and Analog Inputs) is retrieved and displayed on the Smart Dashboard.