Difference between revisions of "Java: Device Characterization"

From Deep Blue Robotics Wiki
Jump to: navigation, search
Line 1: Line 1:
  
Sensor Inputs
+
==Sensor Inputs==
  
 
Find the datasheet or other documentation online, and read it in order to understand what the sensor does, what range of conditions it can detect, what range of values it produces, etc.
 
Find the datasheet or other documentation online, and read it in order to understand what the sensor does, what range of conditions it can detect, what range of values it produces, etc.
Line 9: Line 9:
 
Note the range of fluctuation under stable conditions and the frequency and amplitude of output spikes, so that we know how large an error band is required when using the value, and whether we need to "filter" or "debounce" the value, such as by calculating a moving average or by electronic signal conditioning, such as using a capacitor.
 
Note the range of fluctuation under stable conditions and the frequency and amplitude of output spikes, so that we know how large an error band is required when using the value, and whether we need to "filter" or "debounce" the value, such as by calculating a moving average or by electronic signal conditioning, such as using a capacitor.
 
Try to use the value to control a robot function, such as autonomous driving or movement of a manipulator.
 
Try to use the value to control a robot function, such as autonomous driving or movement of a manipulator.
Actuator Outputs
+
 
 +
==Actuator Outputs==
  
 
Find the datasheet or other documentation online, and read it in order to understand what the device does, what range of control inputs it accepts, etc.
 
Find the datasheet or other documentation online, and read it in order to understand what the device does, what range of control inputs it accepts, etc.
Line 17: Line 18:
 
Note polarity (e.g., forward vs. reverse), extreme device responses, and "dead band" (i.e., control values for which the device doesn't respond).
 
Note polarity (e.g., forward vs. reverse), extreme device responses, and "dead band" (i.e., control values for which the device doesn't respond).
 
Try to use the device to perform some function.
 
Try to use the device to perform some function.
Actuators
 
  
SpeedController
+
==Actuators==
 +
 
 +
==Speed Controller==
  
 
This is the abstract superclass of all of the speed controllers. SpeedControllers have a range of -1.0 to 1.0, full reverse to full forward. Note that output is not linear, and there may be a large deadband. Also, many motors don't go as fast backwards as they do forwards. Calibrate the motor controller as per the user's manual. There are a few different types of speed controllers that we use:  
 
This is the abstract superclass of all of the speed controllers. SpeedControllers have a range of -1.0 to 1.0, full reverse to full forward. Note that output is not linear, and there may be a large deadband. Also, many motors don't go as fast backwards as they do forwards. Calibrate the motor controller as per the user's manual. There are a few different types of speed controllers that we use:  
Talon
+
 
 +
==Talon==
  
 
user's manual
 
user's manual
 
Wpilib classes: Talon
 
Wpilib classes: Talon
Victor 888
+
 
 +
==Victor 888==
  
 
user's manual
 
user's manual
 
Wpilib classes: Victor  
 
Wpilib classes: Victor  
Victor 884
+
 
 +
==Victor 884==
  
 
user's manual
 
user's manual
 
Wpilib classes: Victor
 
Wpilib classes: Victor
Servo
+
 
 +
==Servo==
  
 
Servos are different than normal speed controllers. They take a value between 0 and 1 where 0 is left and 1 is right, and then automatically set themselves to that position.
 
Servos are different than normal speed controllers. They take a value between 0 and 1 where 0 is left and 1 is right, and then automatically set themselves to that position.
 
Wpilib classes: Servo
 
Wpilib classes: Servo
Compressor
+
 
 +
==Compressor==
  
 
The compressor provides pressure to all pneumatic components. The compressor stops after the total pressure is between 100-150 psi, and restarts when pressure goes lower than the 100-150 psi range.
 
The compressor provides pressure to all pneumatic components. The compressor stops after the total pressure is between 100-150 psi, and restarts when pressure goes lower than the 100-150 psi range.
Line 44: Line 51:
 
Compressor name = new Compressor(int pcmId) is used for a non-default PCM ID
 
Compressor name = new Compressor(int pcmId) is used for a non-default PCM ID
 
The 2 methods needed for the compressor are the .start() and .stop() methods
 
The 2 methods needed for the compressor are the .start() and .stop() methods
Solenoids
 
  
Single:
+
==Solenoids==
 +
 
 +
'''Single:'''
 
The single solenoid only allows air in one direction.
 
The single solenoid only allows air in one direction.
 
It only takes one port number
 
It only takes one port number
Line 53: Line 61:
 
Solenoids use .set(boolean on) method to turn on, if true, and off, if false.
 
Solenoids use .set(boolean on) method to turn on, if true, and off, if false.
  
Double:
+
'''Double:
The double solenoid allows air in two directions
+
'''The double solenoid allows air in two directions
 
It requires two port numbers
 
It requires two port numbers
 
DoubleSolenoid name = new DoubleSolenoid(int forwardChannel, int reverseChannel)
 
DoubleSolenoid name = new DoubleSolenoid(int forwardChannel, int reverseChannel)
Line 60: Line 68:
 
the .set(DoubleSolenoid.Value.value) method sets the DoubleSolenoid in forward and reverse direction
 
the .set(DoubleSolenoid.Value.value) method sets the DoubleSolenoid in forward and reverse direction
 
value can be set to kForward, kReverse, or kOff (kForward and kReverse allow air through different parts of the solenoid)
 
value can be set to kForward, kReverse, or kOff (kForward and kReverse allow air through different parts of the solenoid)
Sensors
 
  
Vex Line Tracker
+
===Sensors===
 +
 
 +
==Vex Line Tracker==
  
 
inventor guide
 
inventor guide
Line 70: Line 79:
  
 
The sensor is connected as an analog input on the cRio, and I used both the AnalogChannel and AnalogTrigger classes to program it. I found that the AnalogTrigger class had more capability because it could set hysteresis limits. There are two hysteresis limits; one low and one high. The signal must pass below the lower limit or above the upper limit to signify a change. The hysteresis limits can be set by using the .setLimitsVoltage(,) function. The lower limit is first in the parentheses, followed by a comma, and then the upper limit. This is described in the WPILib documentation. Please note that the limits should be set in the constructor.I used this sensor to count lines on a piece of paper. To do this, I used the FPGA counter, which is a piece of hardware in the cRio that can be accessed through the Counter class. In the class, you can start, stop, and reset the count.
 
The sensor is connected as an analog input on the cRio, and I used both the AnalogChannel and AnalogTrigger classes to program it. I found that the AnalogTrigger class had more capability because it could set hysteresis limits. There are two hysteresis limits; one low and one high. The signal must pass below the lower limit or above the upper limit to signify a change. The hysteresis limits can be set by using the .setLimitsVoltage(,) function. The lower limit is first in the parentheses, followed by a comma, and then the upper limit. This is described in the WPILib documentation. Please note that the limits should be set in the constructor.I used this sensor to count lines on a piece of paper. To do this, I used the FPGA counter, which is a piece of hardware in the cRio that can be accessed through the Counter class. In the class, you can start, stop, and reset the count.
Gyro
+
 
 +
==Gyro==
  
 
Accelerometer/gyro datasheetGyro datasheets 2013 gyro doc
 
Accelerometer/gyro datasheetGyro datasheets 2013 gyro doc
Line 76: Line 86:
  
 
The gyro can tell what angle it is pointing in, relative to an initial angle, which can be used to make a robot drive in a straight line or make precise turns. To use a gyro, first create it and initialize it. Its constructor only requires an int for the analog channel. It has two main methods: reset(), which sets the current angle as zero, and getAngle(), which returns the current angle. A negative angle means that the gyro is facing to the left, and vice versa.
 
The gyro can tell what angle it is pointing in, relative to an initial angle, which can be used to make a robot drive in a straight line or make precise turns. To use a gyro, first create it and initialize it. Its constructor only requires an int for the analog channel. It has two main methods: reset(), which sets the current angle as zero, and getAngle(), which returns the current angle. A negative angle means that the gyro is facing to the left, and vice versa.
AXDL345 Accelerometer
+
 
 +
==AXDL345 Accelerometer==
  
 
datasheet
 
datasheet
Line 91: Line 102:
  
 
The I2C connection can potentially block the calling thread, so it may be necessary to create and use the AXDL345_I2C object in a separate thread. More about this issue is described in this post.
 
The I2C connection can potentially block the calling thread, so it may be necessary to create and use the AXDL345_I2C object in a separate thread. More about this issue is described in this post.
US Digital E4P Optical Encoder
+
 
 +
==US Digital E4P Optical Encoder==
  
 
usdigital.com tutorial
 
usdigital.com tutorial
Line 104: Line 116:
 
Direction the robot is going can also be found with “.getDirection”
 
Direction the robot is going can also be found with “.getDirection”
 
More in this group thread.
 
More in this group thread.
IR Rangefinder
+
 
 +
==IR Rangefinder==
  
 
information on the GP2D12
 
information on the GP2D12
Line 115: Line 128:
 
For the Sharp IR Rangefinder 2Y0A02 F 04, to convert the getVoltage() value to inches:
 
For the Sharp IR Rangefinder 2Y0A02 F 04, to convert the getVoltage() value to inches:
 
inches = (((1/rangefinder.getVoltage())*26.16)- 1.5908)
 
inches = (((1/rangefinder.getVoltage())*26.16)- 1.5908)
Potentiometer
+
 
 +
==Potentiometer==
  
 
Wpilib classes: AnalogInput
 
Wpilib classes: AnalogInput
 
Has an integer range of about 1000 (-2 to ~985).
 
Has an integer range of about 1000 (-2 to ~985).
Axis Camera
+
 
 +
==Axis Camera==
  
 
M1011 Home page
 
M1011 Home page
 
Wpilib classes: AxisCamera
 
Wpilib classes: AxisCamera
Kinect
+
 
 +
==Kinect==
  
 
Documentation(PDF)
 
Documentation(PDF)
Line 132: Line 148:
  
 
It is uncertain whether the roboRIo can handle all the data. However, the Kinect has so far been deemed inessential to our robots and so has not been used.
 
It is uncertain whether the roboRIo can handle all the data. However, the Kinect has so far been deemed inessential to our robots and so has not been used.
Photogate
+
 
 +
==Photogate==
  
 
Wpilib classes: DigitalInput
 
Wpilib classes: DigitalInput
 
The photogate is a digital input. You can get a boolean value (true=blocked) using the get() method.
 
The photogate is a digital input. You can get a boolean value (true=blocked) using the get() method.
Magnetic Limit Switch
+
 
 +
==Magnetic Limit Switch==
  
 
Wpilib classes: DigitalInput
 
Wpilib classes: DigitalInput
 
Attach wires to the ground (com), and either the NO or the NC. Plug into the digital IO.
 
Attach wires to the ground (com), and either the NO or the NC. Plug into the digital IO.
Hall Effect Switch
+
 
 +
==Hall Effect Switch==
  
 
datasheet
 
datasheet
Line 157: Line 176:
  
 
Use a counter to detect the magnet passing over the sensor.
 
Use a counter to detect the magnet passing over the sensor.
HiTechnic Color Sensor
+
 
 +
==HiTechnic Color Sensor==
  
 
Wpilib classes: HiTechnicColorSensor
 
Wpilib classes: HiTechnicColorSensor
Line 169: Line 189:
  
 
*ONLY a HiTechnic color sensor will work with the I2C.
 
*ONLY a HiTechnic color sensor will work with the I2C.
Ultrasonic RangeFinders
 
  
Ultrasonic Rangefinder LV-MaxSonar-EZ1
+
==Ultrasonic RangeFinders==
 +
 
 +
==Ultrasonic Rangefinder LV-MaxSonar-EZ1==
  
 
Data SheetBeam Pattern
 
Data SheetBeam Pattern
Line 193: Line 214:
  
 
Needs to be insulated from the frame's vibration with foam tape.
 
Needs to be insulated from the frame's vibration with foam tape.
Ultrasonic Rangefinder mb1023
+
 
 +
==Ultrasonic Rangefinder mb1023==
  
 
Data Sheet
 
Data Sheet
Line 228: Line 250:
 
JUST FYI...
 
JUST FYI...
 
This sensor has around a 0.5 second lag between when it senses a change in distance and when the computer receives it. This is because of the fact that it has a built-in 2 Hz bandwidth filter to process range data, according to the datasheet.
 
This sensor has around a 0.5 second lag between when it senses a change in distance and when the computer receives it. This is because of the fact that it has a built-in 2 Hz bandwidth filter to process range data, according to the datasheet.
Maxbotix mb1010 Ultrasonic Sensor
+
 
 +
==Maxbotix mb1010 Ultrasonic Sensor==
  
 
We did the same experiment number 1. as with the mb1023 but this sensor gave us weird values and was unreliable. not worth throwing away, but we should not use it until it's reliability is verified.
 
We did the same experiment number 1. as with the mb1023 but this sensor gave us weird values and was unreliable. not worth throwing away, but we should not use it until it's reliability is verified.
Line 234: Line 257:
 
Date: 1/6/2014
 
Date: 1/6/2014
  
Ultrasonic Rangefinder mb1220
+
==Ultrasonic Rangefinder mb1220==
  
 
Data Sheet
 
Data Sheet
Line 246: Line 269:
  
 
To convert the getVoltage() value to inches, multiply the getVoltage() value by 81.37 and add 0.2498.
 
To convert the getVoltage() value to inches, multiply the getVoltage() value by 81.37 and add 0.2498.
Optical Sensor
+
 
 +
==Optical Sensor==
  
 
Wpilib classes: DigitalOutput
 
Wpilib classes: DigitalOutput
Line 254: Line 278:
  
 
Finding the counts and time isn't enough to get an accurate reading for RPM because you end up with the average RPM for the time. An array has to be used to get delta count and delta time for smaller periods which will give a more instantaneous RPM.
 
Finding the counts and time isn't enough to get an accurate reading for RPM because you end up with the average RPM for the time. An array has to be used to get delta count and delta time for smaller periods which will give a more instantaneous RPM.
Custom Photomicrosensor Encoder
+
 
 +
==Custom Photomicrosensor Encoder==
  
 
Thorough explanation
 
Thorough explanation
Line 260: Line 285:
  
 
Although it is constructed completely differently from a regular encoder, the custom sensor still returns the exact same signal if the photomicrosensors are spaced properly, at an optimal 7/16" distance apart. Make sure there is a resistor to limit the current to the emitters, see the explanation for details. Declared in code as Encoder, and distance per pulse is set to the distance it takes for one photo sensor to travel past a clear and a black stripe.
 
Although it is constructed completely differently from a regular encoder, the custom sensor still returns the exact same signal if the photomicrosensors are spaced properly, at an optimal 7/16" distance apart. Make sure there is a resistor to limit the current to the emitters, see the explanation for details. Declared in code as Encoder, and distance per pulse is set to the distance it takes for one photo sensor to travel past a clear and a black stripe.
Operator Input Devices
 
  
Point of View
+
===Operator Input Devices===
 +
 
 +
==Point of View==
  
 
To read values from the POV, call the joystick's getPOV method. It returns the angle of the POV measured in degrees clockwise from the up position, or -1 if it's not pressed. There are 8 different directions: up, right, down, left, and the 4 diagonals. In order to bind commands to the POV, the InternalButton class can be used. An InternalButton is essentially a virtual button that can be used to start commands.
 
To read values from the POV, call the joystick's getPOV method. It returns the angle of the POV measured in degrees clockwise from the up position, or -1 if it's not pressed. There are 8 different directions: up, right, down, left, and the 4 diagonals. In order to bind commands to the POV, the InternalButton class can be used. An InternalButton is essentially a virtual button that can be used to start commands.
Line 292: Line 318:
 
     leftButton.setPressed(value == 6);
 
     leftButton.setPressed(value == 6);
 
}
 
}
Xbox 360 Controller
+
 
 +
==Xbox 360 Controller==
  
 
The Xbox 360 Controller for Windows is an alternative joystick module for operator input. It has different joystick locations and features an additional axis for trigger inputs. The Xbox 360 Controller can be easily accessed using the Joystick class in the wpi library.
 
The Xbox 360 Controller for Windows is an alternative joystick module for operator input. It has different joystick locations and features an additional axis for trigger inputs. The Xbox 360 Controller can be easily accessed using the Joystick class in the wpi library.
  
Ports for Axis' and Buttons:
+
'''Ports for Axis' and Buttons:'''
 +
 
 
Axis:
 
Axis:
 
leftX 1
 
leftX 1

Revision as of 21:07, 27 October 2016

Sensor Inputs

Find the datasheet or other documentation online, and read it in order to understand what the sensor does, what range of conditions it can detect, what range of values it produces, etc. Search WPIlib for relevant classes, such as AXDL345_I2C, Gyro, Encoder, or Ultrasonic. If there isn't anything more specific, use AnalogChannel for analog sensors and DigitalInput for digital sensors. Get the raw value from the sensor and put it to the SmartDashboard. Observe the values produced under different conditions. Plot the correlation between the conditions and the sensor output values (e.g., measured distance vs. rangefinder output). If the range of values produced is very narrow, we may need to electronically amplify the signal. If the range of values exceeds the 5v range of analog inputs, we may need to electronically compress the output range. Note the range of fluctuation under stable conditions and the frequency and amplitude of output spikes, so that we know how large an error band is required when using the value, and whether we need to "filter" or "debounce" the value, such as by calculating a moving average or by electronic signal conditioning, such as using a capacitor. Try to use the value to control a robot function, such as autonomous driving or movement of a manipulator.

Actuator Outputs

Find the datasheet or other documentation online, and read it in order to understand what the device does, what range of control inputs it accepts, etc. Search WPIlib for relevant classes, such as Jaguar, Victor, Relay, Servo, or Solenoid. If there isn't anything more specific, use SafePWM for PWM-controlled devices and DigitalOutput for digital devices. Get output values from the SmartDashboard and use them to control the device. Set at least 10 values over the device's control input range. Plot the correlation between the values and the device responses, ideally measured using a sensor, such as an encoder. Note polarity (e.g., forward vs. reverse), extreme device responses, and "dead band" (i.e., control values for which the device doesn't respond). Try to use the device to perform some function.

Actuators

Speed Controller

This is the abstract superclass of all of the speed controllers. SpeedControllers have a range of -1.0 to 1.0, full reverse to full forward. Note that output is not linear, and there may be a large deadband. Also, many motors don't go as fast backwards as they do forwards. Calibrate the motor controller as per the user's manual. There are a few different types of speed controllers that we use:

Talon

user's manual Wpilib classes: Talon

Victor 888

user's manual Wpilib classes: Victor

Victor 884

user's manual Wpilib classes: Victor

Servo

Servos are different than normal speed controllers. They take a value between 0 and 1 where 0 is left and 1 is right, and then automatically set themselves to that position. Wpilib classes: Servo

Compressor

The compressor provides pressure to all pneumatic components. The compressor stops after the total pressure is between 100-150 psi, and restarts when pressure goes lower than the 100-150 psi range. The standard constructor is Compressor name = new Compressor(). This has a default PCM ID (0). Compressor name = new Compressor(int pcmId) is used for a non-default PCM ID The 2 methods needed for the compressor are the .start() and .stop() methods

Solenoids

Single: The single solenoid only allows air in one direction. It only takes one port number Solenoid name = new Solenoid(int channel) uses the default PCM ID (0) Solenoid name = new Solenoid(int moduleNumber, int channel) for non-default PCM ID Solenoids use .set(boolean on) method to turn on, if true, and off, if false.

Double: The double solenoid allows air in two directions It requires two port numbers DoubleSolenoid name = new DoubleSolenoid(int forwardChannel, int reverseChannel) DoubleSolenoid name = new DoubleSolenoid(int moduleNumber, int forwardChannel, int reverseChannel) is used for non-default PCM ID the .set(DoubleSolenoid.Value.value) method sets the DoubleSolenoid in forward and reverse direction value can be set to kForward, kReverse, or kOff (kForward and kReverse allow air through different parts of the solenoid)

Sensors

Vex Line Tracker

inventor guide Wpilib classes: AnalogInput, AnalogTrigger, Counter

The Vex Line Sensor: The Vex Line Sensor works by emitting infrared light and measuring how much is returned. This means it can be somewhat useless in high infrared light environments. It usefulness also greatly diminishes as it is placed/held further from the object or ground. It reads in a voltage between 0 and 5, 0 being pure white and 5 being pure black. The exact readings can significantly vary depending on the exact sensor (even if they both look exactly the same). I found that one read in white binder paper as 0.2 volts and a dark marker line on the paper as 3.7 volts. Another one read in the paper as 2.3 volts and the line as 4.55 volts.

The sensor is connected as an analog input on the cRio, and I used both the AnalogChannel and AnalogTrigger classes to program it. I found that the AnalogTrigger class had more capability because it could set hysteresis limits. There are two hysteresis limits; one low and one high. The signal must pass below the lower limit or above the upper limit to signify a change. The hysteresis limits can be set by using the .setLimitsVoltage(,) function. The lower limit is first in the parentheses, followed by a comma, and then the upper limit. This is described in the WPILib documentation. Please note that the limits should be set in the constructor.I used this sensor to count lines on a piece of paper. To do this, I used the FPGA counter, which is a piece of hardware in the cRio that can be accessed through the Counter class. In the class, you can start, stop, and reset the count.

Gyro

Accelerometer/gyro datasheetGyro datasheets 2013 gyro doc Wpilib classes: Gyro

The gyro can tell what angle it is pointing in, relative to an initial angle, which can be used to make a robot drive in a straight line or make precise turns. To use a gyro, first create it and initialize it. Its constructor only requires an int for the analog channel. It has two main methods: reset(), which sets the current angle as zero, and getAngle(), which returns the current angle. A negative angle means that the gyro is facing to the left, and vice versa.

AXDL345 Accelerometer

datasheet Wpilib classes: AXDL345_I2C

Installation: connect 4 pins (5V, SCL, SDA, GND) to respective pins on I2C on the digital sidecar, only pins closest to little gray box are I2C.

Constructer parameters: ordinal of the digital module (it's almost always 1), and

Dataformat range (ie. ADXL345_I2C.DataFormat_Range.k16G)

Methods: getAcceleration(axis) axis ie. ADXL345_I2C.Axes.kX Each axis can individually measure the amount of g's pushing on it between 0.0&1.0 turning it upside down will return a negative value.

The I2C connection can potentially block the calling thread, so it may be necessary to create and use the AXDL345_I2C object in a separate thread. More about this issue is described in this post.

US Digital E4P Optical Encoder

usdigital.com tutorial Wpilib classes: Encoder

The types of encoder we use at robotics are known as Quadrature encoders. They count shaft rotation and can sense direction. These encoders have two digital outputs and have their own class in the WPIlib. Because the encoders have two outputs, they require two ports on the digital side card and in the constructor. However, if you only use one, by creating a Counter instead of an Encoder it will count the same, except it will not be able to distinguish between going forwards or backwards. Using the encoder, we can record how far the robot has traveled, find its speed, find the speed of the wheels, and do precise driving. The crio can handle up to 4 encoders and 8 counters, so use counters if you don't need direction, such as when just measuring velocity in one direction.

Steps: Create a program to drive the robot and record encoder values. Display the encoder values on the smart dashboard. In order to use the encoder information for the functions mentioned above, distance per pulse needs to be found. One way to do this is to divide the circumference of the wheel by the number of encoder pulses per rotation. The pulses per rotation is 4 times the number of lines on the hub disk, which is part of the encoder part number -- 250 for most of the ones we have. A second way is to drive the robot a set distance and divide by the number of pulses recorded. Once distance per pulse is set, distance and speed can be found. Direction the robot is going can also be found with “.getDirection” More in this group thread.

IR Rangefinder

information on the GP2D12 Wpilib classes: AnalogInput

Group thread*

  • linear interpolation is no longer necessary, instead import this file "com.sun.squawk.util.MathUtils" (w/o the quotes) and call the function MathUtils.pow(double x, double y) where x is the base and y is the exponent.

For the Sharp IR Rangefinder 2Y0A02 F 04, to convert the getVoltage() value to inches: inches = (((1/rangefinder.getVoltage())*26.16)- 1.5908)

Potentiometer

Wpilib classes: AnalogInput Has an integer range of about 1000 (-2 to ~985).

Axis Camera

M1011 Home page Wpilib classes: AxisCamera

Kinect

Documentation(PDF) Wpilib classes: Kinect & KinectStick

  • (Past version) Because the amount of information that the Kinect reads is too much for the cRIO it's necessary to put a single board computer, such as "Pandaboard", to process all the data.

For more information click here for a document detailing how team 987 successfully used the Kinect on their robot for auto aim.

It is uncertain whether the roboRIo can handle all the data. However, the Kinect has so far been deemed inessential to our robots and so has not been used.

Photogate

Wpilib classes: DigitalInput The photogate is a digital input. You can get a boolean value (true=blocked) using the get() method.

Magnetic Limit Switch

Wpilib classes: DigitalInput Attach wires to the ground (com), and either the NO or the NC. Plug into the digital IO.

Hall Effect Switch

datasheet 1718701 CONTINUOUS TIME UNIPOLAR SWITCHES Allegro Microsystems A1104LUA-T Wpilib classes: DigitalInput

Proper connection:

       pin1 VCC (5V)
       pin 2 GND
       pin 3 VOUT (Signal)

Note that this is NOT the same order of the pins as they go into the digital sidecar.

Returns true when not sensing the magnet, false when the magnet is within 3/8 in.

Use a counter to detect the magnet passing over the sensor.

HiTechnic Color Sensor

Wpilib classes: HiTechnicColorSensor

Installation: Take your HiTechnic lego color sensor* and plug it into the little grey box; this will connect it to the I2C.

Constructor: The constructor requires only one parameter which is the ordinal of the digital module being used (it's almost always 1)

Methods: getColor(); returns a byte between 0 and 17, representing the color being sensed. getRed()/getGreen()/getBlue(); returns an int between 0-255 representing the value the respective color being sensed.

  • ONLY a HiTechnic color sensor will work with the I2C.

Ultrasonic RangeFinders

Ultrasonic Rangefinder LV-MaxSonar-EZ1

Data SheetBeam Pattern Experimental Data Get Started Guide for EZ2 Wpilib classes: AnalogInput

This sensor returns a voltage based on the results of sonar that bounce back to the sensor. You first need to find the supplied voltage that the board or robot is sending to the MaxSonar. This is usually around 4.9V. Then divide by 512. [(Vcc/512) = Vi] Vcc = Supplied Voltage Vi = Volts per inch (Scaling)

This gets you the volts per inch. You can then use this to convert voltages into distance through: [(Vm/Vi) = Ri] Vm = Measured Voltage Vi = Volts per Inch (Scaling) Ri = Range in inches

Note: Anything closer than 6cm to the sensor will read as 6cm. Also, the sensor is more accurate further from the object it is bouncing sound off of.

Needs to be insulated from the frame's vibration with foam tape.

Ultrasonic Rangefinder mb1023

Data Sheet MaxBotix MB1023 HRLV- MaxSonar-EZ2 Wpilib classes: AnalogInput

For the maxbotix mb1023 ultrasonic sensor:

Notes: 1. If you use the getVoltage() method, multiply the value you recieve by 512, and divide it by 5 (the number of volts powering the sensor), you will get the number of centimeters away from the object it is sensing, with the minimum of 30 cm.

2. Also note that the value it gives corresponds to the distance the chip (NOT the end of the protruding cylinder) is from the object.

Experiments conducted: 1. Aiming the sensor parallel to the ground at a rectangular trash can side of dimensions 17.5 inches wide and 30 inches tall. The sensor was placed 2 cm or more above the ground. There were no objects to the side of the setup within 2.5 feet on each side. Results: The claims of the datasheet have been verified: the sensor is very accurate from 30 cm. to 196 inches.

2. Same setup as number 1, but there is a different side facing the sensor with dimensions 8.5 inches wide and 30 inches tall. In this experiment, a laser pointer was used to aid the aim of the human holding the sensor. If the sensor was angled incorrectly, weirdly low values were returned. Results: same as number 1. the sensor was accurate up to 196 inches.

3. Same setup as number 1, and number 2. but the object used was a cardboard box face with dimensions 2 inches wide and 17.75 inches tall. Results: even with the laser pointer, we could only aim it well enough to get real values up to 140 inches. It was accurate up to 140 inches.

4. Same setup as number 1, and number 2. but the object this time was a large whiteboard angled at around 23 degrees off what would be perpendicular to line of yardsticks that I was using to measure the distance. Results: I found that readings were iffy but that we could get reasonable readings. However, the readings (because it was aimed straight on at an angled surface) were around 3 inches or so more than the actual distance. This error seemed to become slightly worse as the distance increased. I could get readings up to around 165 inches (actual) away.

5. Same setup as number 1, with the same trash can side. However, this time we had two whiteboards each 1 foot away from the sensor to the sides of the sensor and the line of yardsticks. Results: When the sensor was placed on the same plane as the back of the whiteboards (which were 32.5 inches long and around 37.5 inches tall), it could read values fine. However, when I moved it 20 inches back, to 140 inches away from the trash can, it gave me the aforementioned weirdly low values (like 17 and 22 inches). This is interesting to me because the floor is not a problem (I can hold the sensor 2 cm off the floor and still get perfect values if I hold it straight), and the floor is like a huge whiteboard I guess...

JUST FYI... This sensor has around a 0.5 second lag between when it senses a change in distance and when the computer receives it. This is because of the fact that it has a built-in 2 Hz bandwidth filter to process range data, according to the datasheet.

Maxbotix mb1010 Ultrasonic Sensor

We did the same experiment number 1. as with the mb1023 but this sensor gave us weird values and was unreliable. not worth throwing away, but we should not use it until it's reliability is verified.

Date: 1/6/2014

Ultrasonic Rangefinder mb1220

Data Sheet MaxBotix MB1220 XL MaxSonar EZ-2 Wpilib classes: AnalogInput

This sensor appears to have a much smaller lag than the MB1023. It is around 0.1 seconds rather than 0.5 seconds. This sensor can detect range from 20 to 765 centimeters. However, be careful of the cone of detection on this sensor, it appears to be wider than the MB1023.

To convert the getVoltage() value to inches, multiply the getVoltage() value by 81.37 and add 0.2498.

Optical Sensor

Wpilib classes: DigitalOutput

This sensor senses if a surface is black or white. Black returns true while white returns false in a .get() function. Using the counter class, the optical sensor can be used as an encoder to find RPM if the wheel has black and white sections colored in. The counter will count every time the sensor sense black to white to black or white to black to white. If the half the wheel is black and the other is white, then the counter counts the number of rotations. If the the wheel two black section and two white section, then the counter needs to be divided by two to get the number of rotations. More sections on the wheel will be more accurate. The timer also has to be used to get the time. Rotations divided by time gives use the rotations per second. To get RPM, just multiply the rotations per second by 60.

Finding the counts and time isn't enough to get an accurate reading for RPM because you end up with the average RPM for the time. An array has to be used to get delta count and delta time for smaller periods which will give a more instantaneous RPM.

Custom Photomicrosensor Encoder

Thorough explanation Wpilib class: Encoder

Although it is constructed completely differently from a regular encoder, the custom sensor still returns the exact same signal if the photomicrosensors are spaced properly, at an optimal 7/16" distance apart. Make sure there is a resistor to limit the current to the emitters, see the explanation for details. Declared in code as Encoder, and distance per pulse is set to the distance it takes for one photo sensor to travel past a clear and a black stripe.

Operator Input Devices

Point of View

To read values from the POV, call the joystick's getPOV method. It returns the angle of the POV measured in degrees clockwise from the up position, or -1 if it's not pressed. There are 8 different directions: up, right, down, left, and the 4 diagonals. In order to bind commands to the POV, the InternalButton class can be used. An InternalButton is essentially a virtual button that can be used to start commands.

Here is some example code. Note that this code requires the oi.updateDPad method to be called iteratively in teleopPeriodic. InternalButton upButton = new InternalButton(); InternalButton rightButton = new InternalButton(); InternalButton downButton = new InternalButton(); InternalButton leftButton = new InternalButton();

upButton.whenPressed(new UpCommand()); rightButton.whenPressed(new RightCommand()); downButton.whenPressed(new DownCommand()); leftButton.whenPressed(new LeftCommand());

private int getDPad(Joystick stick) {

   if(stick.getPOV() < 0) {
       return -1;
   } else {
       return stick.getPOV() / 45;
   }

}

public void updateDPad() {

   int value = getDPad(joystick);
   upButton.setPressed(value == 0);
   rightButton.setPressed(value == 2);
   downButton.setPressed(value == 4);
   leftButton.setPressed(value == 6);

}

Xbox 360 Controller

The Xbox 360 Controller for Windows is an alternative joystick module for operator input. It has different joystick locations and features an additional axis for trigger inputs. The Xbox 360 Controller can be easily accessed using the Joystick class in the wpi library.

Ports for Axis' and Buttons:

Axis: leftX 1 leftY 2 triggers 3 (NOTE: starts at 0.0, pressing triggers outputs to an extent of +/- 1.0) rightX 4 rightY 5

Buttons: A 1 B 2 X 3 Y 4 Left Bumper 5 Right Bumper 6 Back 7 Start 8 Left Stick 9 (Registers depression of joystick) Right Stick 10 NAVIGATION HOME BUSINESS ADMIN OF MEMBERS AND MENTORS FINANCE MEETING MINUTES PROCESSES-FORMS RESOURCES SPONSORSHIPS ELECTRONICS RESOURCES TRAINING GAME CHALLENGES FIRST STRONGHOLD INFO - 2016 MECHANICS CAD MOTORS RESOURCES SAFETY SHOP MAINTAINANCE SYSTEMS TRAINING MEDIA/WEBSITE SOFTWARE PROJECTS CUSTOM WIDGETS DEVICE CHARACTERIZATION MOTION PROFILING NETTABLES CLIENT PID CONTROL ROBORIO FILES ROBOT SIMULATOR VISION RESOURCES ROBOTS TRAINING CURRICULUM