IR Locator 360

$48.95

The IR Locator detects the direction of IR light in every direction around the robot at a resolution of ±5°. Great for use with the IR Beacon and IR Ball.

Out of stock

SKU: 45-2009 Category:

The IR Locator has four IR detectors facing forward, back, left, and right. The IR intensity received by each of these sensors allows the onboard processor (or PIC) to calculate the direction of the IR Light source to within 5 degrees. The IR Locator can be set to read 1200 or 600Hz IR Light.

Sensor Type: Four Wire I2C Sensor

Default 8-bit I2C Address: 0x1C

Arduino 7-bit I2C Address: 0x0E

Register   Function
0x04   1200 Hz Heading in 5° increments
0x05   1200 Hz Signal Strength
0x06   600 Hz Heading in 5° increments
0x07     600 Hz Signal Strength

The heading value is returned in 5-degree increments from 0 to 71. If an object were to circle the sensor in a clockwise direction, the value of degrees will increase. If the object were to circle in a counter-clockwise direction, the value of the heading will decrease.

Android Studio Example Program

You will need both of the below files in the same program folder.

MRIIrLocator.java –Driver/Class

/*
DO NOT EDIT THIS PROGRAM
Modern Robotics IR Locator 360 Driver
Created 7/27/2017 by Colton Mehlhoff of Modern Robotics using FTC SDK 3.10
Reuse permitted with credit where credit is due
This class provides functions to use the IR Locator 360
Support is available by emailing support@modernroboticsinc.com
*/
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.I2cAddr;
import com.qualcomm.robotcore.hardware.I2cDevice;
import com.qualcomm.robotcore.hardware.I2cDeviceSynch;
import com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl;
public class MRIIrLocator {
private byte[] chache;
private I2cDevice sensor;
private I2cDeviceSynch reader;
HardwareMap hwMap = null;
public MRIIrLocator() {
}
public void init(HardwareMap ahwMap, String cfgName) {
init(ahwMap, cfgName, 0x1C); //Default I2C address for color beacon is 0x4c
}
public void init(HardwareMap ahwMap, String cfgName, int i2cAddr8) {
hwMap = ahwMap;
sensor = hwMap.i2cDevice.get(cfgName);
reader = new I2cDeviceSynchImpl(sensor, I2cAddr.create8bit(i2cAddr8), false);
reader.engage();
}
byte[] readAll(){
chache = reader.read(0x00, 8);
return chache;
}
int heading1200hz(){
return (reader.read8(0x04)&0xFF) * 5;
}
int strength1200hz(){
return reader.read8(0x05) & 0xFF;
}
int heading600hz(){
return (reader.read8(0x06) & 0xFF) * 5;
}
int strength600hz(){
return reader.read8(0x07) & 0xFF;
}
}

MRI_Ir_Locator.java –Example Program

/*
Modern Robotics IR Locator 360 Example
Created 7/27/2017 by Colton Mehlhoff of Modern Robotics using FTC SDK 3.10
Reuse permitted with credit where credit is due
Configuration:
I2CDevice "irl" (MRI IR Locator 360 with default I2C address 0x1C)
MRIIrLocator class must be in the same folder as this program.
To change I2C Addresses, go to http://modernroboticsedu.com/mod/lesson/view.php?id=96
Support is available by emailing support@modernroboticsinc.com
*/
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
@TeleOp(name = "IR Locator Ex", group = "MRI")
//@Disabled
public class MRI_Ir_Locator extends LinearOpMode {
MRIIrLocator locator = new MRIIrLocator();
@Override
public void runOpMode() throws InterruptedException {
telemetry.addData("Status", "Initialized");
telemetry.update();
locator.init(hardwareMap, "irl"); //initializes the I2CDevice. Second parameter is the name of the sensor in the configuration file.
waitForStart();
while (opModeIsActive()) {
telemetry.addData("Dir 1200", locator.heading1200hz());
telemetry.addData("Dir 600", locator.heading600hz());
telemetry.addData("Str 1200", locator.strength1200hz());
telemetry.addData("Str 600", locator.strength600hz());
telemetry.update();
}
}
}
Scroll to Top