sensors 4 frc robots by hugh meyer red alert robotics frc team 1741 center grove high school...
TRANSCRIPT
Sensors 4 FRC Sensors 4 FRC RobotsRobots
By Hugh MeyerBy Hugh Meyer
Red Alert RoboticsRed Alert Robotics
FRC Team 1741FRC Team 1741
Center Grove High Center Grove High School Greenwood School Greenwood
IndianaIndiana
October 5, 2013October 5, 2013
Why Do We Need Why Do We Need Sensors?Sensors?
Protect robot from Protect robot from self destructionself destruction
Protect robot from Protect robot from driver destructiondriver destruction
Provide closed loop Provide closed loop controlcontrol
Sense positionSense position Feedback for Feedback for
autonomous modeautonomous mode Limit range of Limit range of
motionmotion Confirmation system Confirmation system
is functioning is functioning properlyproperly
Gives electrical Gives electrical team something to team something to dodo
Mechanical Limit Mechanical Limit SwitchesSwitches
Lever or roller actuatedLever or roller actuated Several sizes availableSeveral sizes available VR7 is popular, easy to work with, VR7 is popular, easy to work with,
inexpensive, supplied in kit of inexpensive, supplied in kit of partsparts
Simple to wire – connect red and Simple to wire – connect red and black wires to NC and NO black wires to NC and NO connections, connect white signal connections, connect white signal wire to the COM connectionwire to the COM connection
Orient the lever so it wipes across Orient the lever so it wipes across the cam – Avoid having the switch the cam – Avoid having the switch become your mechanical limitbecome your mechanical limit
Mechanical Limit Mechanical Limit SwitchesSwitches
Signal is on/off or true/false Signal is on/off or true/false or 1/0or 1/0
Connected to digital I/O on Connected to digital I/O on the Digital Side Carthe Digital Side Car
Software reads a one or zeroSoftware reads a one or zero Switch connections will be Switch connections will be
labeledlabeled
Mechanical Limit Mechanical Limit SwitchesSwitches
CommonCommon Normally ClosedNormally Closed Normally OpenNormally Open Common Common
terminal is the terminal is the outputoutput
NO and NC NO and NC would be would be ground and + 5 ground and + 5 voltsvolts
Magnetic Reed Magnetic Reed SwitchesSwitches High reliability – Reed contacts High reliability – Reed contacts
are sealed in a small glass are sealed in a small glass cylindercylinder
Easy to wire – Connect one Easy to wire – Connect one terminal to the black wire and terminal to the black wire and the other to the white wirethe other to the white wire
Used on Pneumatic cylinders, Used on Pneumatic cylinders, but the cylinder must be but the cylinder must be ordered with the magnetic ring ordered with the magnetic ring optionoption
Magnet is the element in motion Magnet is the element in motion to be sensed by the reed switchto be sensed by the reed switch
Fixed Pressure Fixed Pressure SwitchSwitch
Used to control air Used to control air compressorcompressor
Switch closes when Switch closes when pressure is below a pressure is below a predefined low limit value predefined low limit value and opens when pressure and opens when pressure is above a high limit valueis above a high limit value
Simple to wire – Black Simple to wire – Black and white wire connect to and white wire connect to the switchthe switch
Pressure TransmitterPressure Transmitter
Provides an analog or Provides an analog or digital signal indicating digital signal indicating the exact pressurethe exact pressure
Analog wiring is simplest – Analog wiring is simplest – Black and red wires Black and red wires supply power to sensor supply power to sensor and the white connects to and the white connects to the analog inputthe analog input
Digital device will connect Digital device will connect to a SPI, I2C, or serial portto a SPI, I2C, or serial port
Push ButtonsPush Buttons
Momentary contactMomentary contact Suggest connecting all Suggest connecting all
three wires – Black and red three wires – Black and red to NC & NO contacts and to NC & NO contacts and white wire to the COM white wire to the COM contactcontact
Available in many different Available in many different sizes, shapes, color, and sizes, shapes, color, and stylesstyles
Driver station ultimate Driver station ultimate controlcontrol
Toggle SwitchesToggle Switches
Generally not momentary Generally not momentary action – switch stays at action – switch stays at position when releasedposition when released
Available in many different Available in many different contact arrangementscontact arrangements
FRC usage can generally use FRC usage can generally use the simple SPDT (single pole the simple SPDT (single pole double throw)double throw)
Center off is available if Center off is available if appropriateappropriate
Quadrature EncodersQuadrature Encoders
Measures speed, Measures speed, distance, and positiondistance, and position
Signal can return to the Signal can return to the cRIO or Jaguar, or bothcRIO or Jaguar, or both
Requires two digital Requires two digital inputs if you want inputs if you want directional information directional information and highest resolutionand highest resolution
Signals are 90 degrees Signals are 90 degrees out of phaseout of phase
Quadrature EncodersQuadrature Encoders Different sizes Different sizes
availableavailable Several styles Several styles
availableavailable Kit of parts encoders Kit of parts encoders
must be installed must be installed carefullycarefully
Encoder disk must be Encoder disk must be correct distance from correct distance from optical elementoptical element
Need oscilloscope to Need oscilloscope to verify correct verify correct operationoperation
Quadrature EncodersQuadrature Encoders Available in different resolutionsAvailable in different resolutions The line count specifies the The line count specifies the
resolutionresolution Higher count gives the I and D Higher count gives the I and D
components of PID faster components of PID faster information for better responseinformation for better response
Lower count is more tolerant of Lower count is more tolerant of alignment errorsalignment errors
Several functions in WPILib are Several functions in WPILib are available depending if you want available depending if you want speed or distancespeed or distance
Incremental device – If you want Incremental device – If you want absolute position then you need absolute position then you need to home the system, or always to home the system, or always start from a known positionstart from a known position
Potentiometer Absolute Potentiometer Absolute EncoderEncoder Always know where you areAlways know where you are
Standard pot supports up to 270 degrees of rotationStandard pot supports up to 270 degrees of rotation Multi-turn pots can support more than one rotationMulti-turn pots can support more than one rotation Home switch and sequence not requiredHome switch and sequence not required Analog voltage output is proportional to positionAnalog voltage output is proportional to position Black and red wires go to outer connections on potBlack and red wires go to outer connections on pot Signal comes from the wiper terminalSignal comes from the wiper terminal
Absolute Magnetic Shaft Absolute Magnetic Shaft EncoderEncoder
Similar to a single turn pot, but Similar to a single turn pot, but allows full 360 degree rotation with allows full 360 degree rotation with no stopsno stops
Available with an analog or a pulse Available with an analog or a pulse width modulated digital outputwidth modulated digital output
Output signal is proportional to the Output signal is proportional to the absolute shaft positionabsolute shaft position
Different bearing configurations are Different bearing configurations are offeredoffered
Can be used as operator control as Can be used as operator control as well as sensor on robotwell as sensor on robot
Connected to analog bumper on Connected to analog bumper on analog I/O moduleanalog I/O module
Rotary Magnetic EncoderRotary Magnetic Encoder
No mechanical contactNo mechanical contact Accurate alignment is Accurate alignment is
importantimportant Data sheet is on KOP Data sheet is on KOP
webpagewebpage Several IO optionsSeveral IO options
Linear Motion Magnetic Linear Motion Magnetic EncoderEncoder
No mechanical No mechanical contactcontact
Accurate Accurate alignment is alignment is importantimportant
Data sheet is on Data sheet is on KOP webpageKOP webpage
Several IO optionsSeveral IO options Quad outputsQuad outputs
Linear Motion Optical Linear Motion Optical EncoderEncoder
High precisionHigh precision Any length encoder Any length encoder
stripstrip Quad outputQuad output US DigitalUS Digital Resolution of sensor Resolution of sensor
and strip must and strip must matchmatch
Includes index mark Includes index mark for home positionfor home position
Gear Tooth Gear Tooth EncoderEncoder
Alignment not criticalAlignment not critical Works with steel Works with steel
chain sprockets or chain sprockets or gearsgears
Pulse width Pulse width modulated outputmodulated output
WPI Library has a WPI Library has a function to read function to read these type of sensorsthese type of sensors
Ultrasonic Distance Ultrasonic Distance SensorSensor Measures distance to a targetMeasures distance to a target
Two styles of sensors available Two styles of sensors available – Dual element and single – Dual element and single elementelement
Available with analog or digital Available with analog or digital outputsoutputs
Digital output would be the Digital output would be the preferred methodpreferred method
Good for localization for Good for localization for autonomous modeautonomous mode
Sensitively spec is used for Sensitively spec is used for scaling voltage data to feet or scaling voltage data to feet or inchesinches
Get that information from the Get that information from the data sheetdata sheet
Gyro - Inertial Turn Rate Gyro - Inertial Turn Rate SensorSensor
Measures the rate of turnMeasures the rate of turn Can be used for heading data for Can be used for heading data for
autonomous drive modeautonomous drive mode Can be used to create a field oriented Can be used to create a field oriented
style drive schemestyle drive scheme Can be used to create a target oriented Can be used to create a target oriented
style drive schemestyle drive scheme If oriented properly can be a tilt sensor, If oriented properly can be a tilt sensor,
although the accelerometer can do that although the accelerometer can do that naturally with the Z axis datanaturally with the Z axis data
Inertial Accelerometer Inertial Accelerometer SensorSensor
Measures rate of change in motion Measures rate of change in motion and the direction of gravityand the direction of gravity
Three axis sensor – X, Y, ZThree axis sensor – X, Y, Z Z axis measures direction of gravity Z axis measures direction of gravity
and can be used as a tilt sensorand can be used as a tilt sensor X axis, if oriented properly, will X axis, if oriented properly, will
measure forward and backward measure forward and backward motionmotion
Y axis, if oriented properly, will Y axis, if oriented properly, will measure sideways motionmeasure sideways motion
Inertial SensorInertial Sensor Should be mounted on a mass that Should be mounted on a mass that
is suspended in foamis suspended in foam This acts as a low pass filter and This acts as a low pass filter and
will significantly reduce high will significantly reduce high frequency noisefrequency noise
Accelerometer output is available Accelerometer output is available in digital or analog outputsin digital or analog outputs
Analog outputs require one analog Analog outputs require one analog input for each axisinput for each axis
Digital outputs require four digital Digital outputs require four digital I/O connections on the digital side I/O connections on the digital side carcar
Use the SPI interface software Use the SPI interface software functions to get the datafunctions to get the data
Use the digital outputs – This Use the digital outputs – This prevents the bias from becoming prevents the bias from becoming an issuean issue
Inertial SensorInertial Sensor Rate gyro output is available Rate gyro output is available
as an analog outputas an analog output Connect this output to the Connect this output to the
analog bumper inputanalog bumper input Use shielded wire for a clean Use shielded wire for a clean
signalsignal System must measure the System must measure the
bias when the sensor is bias when the sensor is initializedinitialized
System must be absolutely System must be absolutely stationary when the system is stationary when the system is measuring the biasmeasuring the bias
If your gyro is drifting it is If your gyro is drifting it is likely because the system was likely because the system was in motion during the in motion during the initialization periodinitialization period
Inertial SensorInertial Sensor If you have a onboard air compressor it If you have a onboard air compressor it
should not run during the gyro bias should not run during the gyro bias measurement timemeasurement time
Sensitivity must be passed to the gyro class Sensitivity must be passed to the gyro class when it is initializedwhen it is initialized
Sensitively is found on the data sheet for the Sensitively is found on the data sheet for the devicedevice
Accelerometer sensitivity will be on the order Accelerometer sensitivity will be on the order of 300 mV/gof 300 mV/g
Gyro sensitivity will be on the order of 7 Gyro sensitivity will be on the order of 7 mV/degrees/smV/degrees/s
Read the data sheet provided by Read the data sheet provided by FIRSTFIRST and and the data sheet from the manufacturerthe data sheet from the manufacturer
The FPGA in the cRIO does the integration The FPGA in the cRIO does the integration for you to get an anglefor you to get an angle
Inertial Sensors More Inertial Sensors More InformationInformation
Kevin Watson has some good Kevin Watson has some good information about these types of information about these types of sensorssensors
He has some well commented code if He has some well commented code if you really want to get into the detailsyou really want to get into the details
http://kevin.orghttp://kevin.org The FPGA in the cRIO really does the The FPGA in the cRIO really does the
hard work integrating the gyro rate hard work integrating the gyro rate data to get an angledata to get an angle
Optical Transmitted Optical Transmitted BeamBeam
Consists of two elements – a transmitter and a Consists of two elements – a transmitter and a receiverreceiver
A signal is output when the light beam is blockedA signal is output when the light beam is blocked Alignment is importantAlignment is important Simple packaging is readily available off the shelfSimple packaging is readily available off the shelf Power must be supplied to both the TX and RXPower must be supplied to both the TX and RX
Optical Transmitted Optical Transmitted BeamBeam
Use a regulated power Use a regulated power output. Most require output. Most require 24 volts which you can 24 volts which you can get using the solenoid get using the solenoid bumper wired to the bumper wired to the 24 volt supply24 volt supply
Detected object must Detected object must be large enough for the be large enough for the sensor to seesensor to see
Optical Retro Optical Retro ReflectiveReflective
Uses a retro reflective Uses a retro reflective targettarget
Only one deviceOnly one device Target can be a flag in Target can be a flag in
motionmotion Target can be stationary Target can be stationary
and have an opaque flag and have an opaque flag block the light – The flag block the light – The flag must not be reflective, or it must not be reflective, or it will be detectedwill be detected
Optical Vane Optical Vane Transmitted BeamTransmitted Beam
One piece housing in a U shape – One piece housing in a U shape – also called slot sensoralso called slot sensor
Available in several different sizesAvailable in several different sizes Will detect presence of any Will detect presence of any
opaque object that is inserted into opaque object that is inserted into the Uthe U
Very effective for home sensors Very effective for home sensors when used with incremental when used with incremental encodersencoders
No mechanical contact for high No mechanical contact for high reliabilityreliability
Simple to actuateSimple to actuate Does not require precise Does not require precise
alignment or mountingalignment or mounting
LED & Photo TransistorLED & Photo Transistor Roll your own for a fraction Roll your own for a fraction
of the costof the cost Flexible designing package Flexible designing package
since you make your ownsince you make your own LED (LTE-4208) and Photo LED (LTE-4208) and Photo
transistor (LTR-3208E) must transistor (LTR-3208E) must be a matched pairbe a matched pair
IR light is best because that IR light is best because that will reduce the effect of will reduce the effect of ambient lightambient light
Works over a wide distance Works over a wide distance rangerange
LED & Photo TransistorLED & Photo Transistor Requires resistors in the circuit to Requires resistors in the circuit to
work properlywork properly LED needs a current limiting resistor LED needs a current limiting resistor
in series with it to drop the 5 volts in series with it to drop the 5 volts down to 1.2~1.6 voltsdown to 1.2~1.6 volts
Size this resistor to draw 15 ~ 30 Size this resistor to draw 15 ~ 30 milliampsmilliamps
Check the spec sheet for the target Check the spec sheet for the target currentcurrent
A good range will be 180 ~ 221 ohms A good range will be 180 ~ 221 ohms if using a 5 volt power supply, I used if using a 5 volt power supply, I used 221 ohms for this device221 ohms for this device
You can calculate the value or You can calculate the value or measure it if you have an ammetermeasure it if you have an ammeter
LED & Photo TransistorLED & Photo Transistor Photo transistor needs a pull up Photo transistor needs a pull up
or down resistor depending on or down resistor depending on the wiring scheme you selectthe wiring scheme you select
A good range will be 2k ~ 4k A good range will be 2k ~ 4k ohm, I used 3.16k for this ohm, I used 3.16k for this devicedevice
Resistor can be above the Resistor can be above the transistor or below ittransistor or below it
Above you get a high when the Above you get a high when the light beam is blockedlight beam is blocked
Below you get a low when the Below you get a low when the light beam is blockedlight beam is blocked
LED & Photo TransistorLED & Photo Transistor
R = 221 ohmsR = 221 ohms RL = 3.16k ohmsRL = 3.16k ohms
Current SensorCurrent Sensor Measures current flowing to a motorMeasures current flowing to a motor Indicates if the motor is running within load Indicates if the motor is running within load
specificationsspecifications Helps prevent “magic smoke” from exiting the Helps prevent “magic smoke” from exiting the
motormotor Hal effect sensors can measure DC currentHal effect sensors can measure DC current IC based sensors can be inserted into the circuitIC based sensors can be inserted into the circuit Jaguar speed controllers have current measuring Jaguar speed controllers have current measuring
ability built right in – you just need to ask itability built right in – you just need to ask it
Test RigTest Rig Always measure Always measure
motor current motor current when building when building proto typesproto types
12” piece of 10 12” piece of 10 AWG wire makes AWG wire makes a good shunt a good shunt resistorresistor
1 milli-volt equals 1 milli-volt equals 1 amp current 1 amp current flowflow
CamerasCameras Two types provided over the Two types provided over the
years from the kit of partsyears from the kit of parts Axis M1011Axis M1011 Axis 206Axis 206 Any others are legal if they Any others are legal if they
are IP basedare IP based Library provided by Library provided by FIRSTFIRST is is
very advancevery advance Several teams got vision to Several teams got vision to
work for themwork for them Can be connected directly to Can be connected directly to
the cRIO or radiothe cRIO or radio Vision processing can be Vision processing can be
done on cRIO or driver done on cRIO or driver stationstation
Tools NeededTools Needed
Oscilloscope is very helpfulOscilloscope is very helpful VoltmeterVoltmeter AmmeterAmmeter Soldering EquipmentSoldering Equipment ConnectorsConnectors Shielded wireShielded wire
Software You Need to Software You Need to WriteWrite
Code that will read the sensorCode that will read the sensor Code that will log the data from the Code that will log the data from the
sensorsensor First thing you should do is hook up First thing you should do is hook up
sensors you plan to use and start sensors you plan to use and start reading datareading data
Don’t waitDon’t wait Connect sensors and start reading Connect sensors and start reading
data as soon as possible!!data as soon as possible!!
Log The DataLog The Data
Log the data to a file on the Log the data to a file on the cRIOcRIO
Send the data to the driver Send the data to the driver station and log to a file on station and log to a file on the DSthe DS
Add external device that logs Add external device that logs to a memory cardto a memory card
Logomatic by Spark Fun Logomatic by Spark Fun ElectronicsElectronics
https://www.sparkfun.com/products/https://www.sparkfun.com/products/1021610216
Sensor GuidelinesSensor Guidelines
It always needs a sensorIt always needs a sensor If a mechanism has limited travel then it If a mechanism has limited travel then it
needs an end of travel (EOT) limit sensor needs an end of travel (EOT) limit sensor on both ends!on both ends!
Start reading data from sensors as soon Start reading data from sensors as soon as you can so you will learn what is as you can so you will learn what is required and the type of datarequired and the type of data
Design your sensors into the system. Add Design your sensors into the system. Add on after thought mounting schemes tend on after thought mounting schemes tend to be unreliableto be unreliable
Kit of Parts SensorsKit of Parts Sensors
Use the resources provided by Use the resources provided by FIRSTFIRST at the kit of parts website at the kit of parts website
They have data sheets and They have data sheets and instructions specific to our instructions specific to our applicationapplication
http://www.usfirst.org/roboticsprogrhttp://www.usfirst.org/roboticsprograms/frc/2012-kit-of-parts-sensorsams/frc/2012-kit-of-parts-sensors
SuppliersSuppliers AndyMark - http://www.andymark.com/Default.aspAndyMark - http://www.andymark.com/Default.asp US Digital - http://usdigital.com/US Digital - http://usdigital.com/ Digikey - http://www.digikey.com/Digikey - http://www.digikey.com/ Mouser Electronics - http://www.mouser.com/Mouser Electronics - http://www.mouser.com/ Newark Electronics - http://www.newark.com/Newark Electronics - http://www.newark.com/ Allied Electronics - http://www.alliedelec.com/Allied Electronics - http://www.alliedelec.com/ Rockwell Automation - http://www.ab.com/catalogs/Rockwell Automation - http://www.ab.com/catalogs/ Automation Direct - Automation Direct -
http://www.automationdirect.com/adc/Shopping/Catalog/Sensors_-z-http://www.automationdirect.com/adc/Shopping/Catalog/Sensors_-z-_Encoders_Encoders
Spark Fun Electronics - http://www.sparkfun.com/Spark Fun Electronics - http://www.sparkfun.com/ Parallax Inc. - Parallax Inc. -
http://www.parallax.com/tabid/768/ProductID/92/Default.aspxhttp://www.parallax.com/tabid/768/ProductID/92/Default.aspx MaxBotix - http://www.maxbotix.com/MaxBotix - http://www.maxbotix.com/ Suzo Happ - http://na.suzohapp.com/pushbuttons/pushbuttons.htmSuzo Happ - http://na.suzohapp.com/pushbuttons/pushbuttons.htm Penny+Giles - http://www.pennyandgiles.com/Joystick-Controllers-pg-Penny+Giles - http://www.pennyandgiles.com/Joystick-Controllers-pg-
28,2,,.php28,2,,.php State Electronics - http://www.potentiometers.com/select_joystick.cfmState Electronics - http://www.potentiometers.com/select_joystick.cfm
QuestionsQuestions
Hugh MeyerHugh Meyer [email protected]@redalert1741.org 317 786-9214317 786-9214 Webpage: Webpage:
http://rar.meyermat.net/workshops/sensors/indexhttp://rar.meyermat.net/workshops/sensors/index.html.html