Cobra
The Cobra Line Follower provides an array of IR reflective sensors to be used for detecting a line.
Cobra V2
Cobra V2 Specifications (Click to Open)
Function |
Min |
Typical |
Max |
|---|---|---|---|
Input Voltage |
3.3VDC |
5VDC |
— |
Current |
25mA |
70mA |
100mA |
Sensing Distance |
1mm |
3mm |
5mm |
Note
The Cobra V2 requires the Analog Module to send data to the VMX. It is possible to place the inputs directly on the analog pins of the VMX. However, the analog module is recommended.
Cobra V3
The Cobra V3 has an upgraded IR sensor and the ADC has been added to the sensor. There are two outputs on V3, i2c and raw. The i2c connection, connects to the ADC and will return an accurate 12-bit value. Wheras, the raw outputs the raw analog output of the sensor.
Cobra V3 Specifications
Function |
Min |
Typical |
Max |
|---|---|---|---|
Input Voltage |
3.3VDC |
5VDC |
— |
Current |
25mA |
200mA |
250mA |
Sensing Distance |
0mm |
5mm |
20mm |
Programming
Using WPILib:
1//import
2import com.studica.frc.Cobra;
3
4//Cobra Library
5private Cobra cobra;
6
7//Custruct and instance
8cobra = new Cobra();
9
10//or if sensor is using 3.3V
11cobra = new Cobra(3.3F);
12
13//Grab data
14cobra.getVoltage(channel); // returns a float of the voltage
15cobra.getRawValue(channel); // returns a double
The accessor methods will output either the votlage (0 - VIN) or the raw ADC value (0 - 2047).
Header
1//Cobra Library
2#include "studica/Cobra.h"
3
4//Constructor
5studica::Cobra cobra{};
6// or if sensor is using 3.3V
7studica::Cobra cobra{3.3F};
Source
1// Call to access data
2cobra.GetVoltage(channel); // Gets the votlage at the specfified channel.
3cobra.GetRawValue(channel); // Gets the raw value from the ADC at the specified channel.
The accessor functions will output either the voltage (0 - VIN) or the raw ADC value (0 - 2047).