Using Sensors with the RoboRIO Jeff Bernardis jeff.bernardis@gmail.com David Zhang david.chao.zhang@gmail.com A copy of this presentation is available at: https://drive.google.com/file/d/1sjlpsrm8wbguehgyblcopmrnw2qsmxkf/view?usp=sharing
Using Sensors with the RoboRIO A Sensor Catalog Types of sensors How to connect Solving problems with sensors Camera and Inertial Sensor Fusion RoboRio References: Specification: http://www.ni.com/pdf/manuals/375275a.pdf User Manual: http://www.ni.com/pdf/manuals/375274a.pdf
My Background Software Engineer - PSU 1978 Over 35 years of experience in software development for the telecommunications industry with AT&T/Bell Laboratories, and now Ericsson Amateur Astronomer and past Director of the Amateur Astronomers Association of Princeton An electronics hobbyist with high interest in 3D printing contributor to open source projects This will be my 6th year as mentor for Team 1403
Things to remember: Always inter-connect ground wires Check for ground loops via chassis Be aware of VCC differences 3.3v versus 5v (rio has 5V compatible digital inputs) Be aware of current limitations especially for things being driven through the rio or arduino Read the datasheet
Types of sensors SPI Bus CAN Bus I2C Bus Expansion Port provides additional ports Digital Analog
Digital Sensors Connect to DIO ports 3 connections Voltage, Ground, and Signal V, Gnd provide power to sensor S is the returned value, V/Gnd, True/False, 1/0 (binary) Typical Sensors: switch, encoder, hall effect sensor, optical gate
Digital Sensor - Switch Do not leave input floating 3 Wiring options: SPDT Switch SPST with pull-down resistor SPST with pull-up resistor RIO has 2.2k pull-up resistors connected to all DIO ports
Digital Sensor Optical Gate Essentially an SPST with a pull-up resistor
Digital Sensor - Encoder Requires 2 digital ports
Analog Sensors Connect to Analog In ports Same 3 connections Voltage, Ground, Signal V, Gnd power sensor S is the returned value, any voltage between V and Gnd Most analog sensors require calibration through experimentation Typical Sensors: Potentiometer, photocell, gyro, proximity/range sensors
Analog Sensor - Potentiometer S will vary between G and V S connects to wiper Almost always the center pin Take caution not to crash through the ends of the turn range single turn versus 10-turn
Bus-Based Protocols/Sensors Intelligent sensors exchange messages with RIO I2C AKA IIC (inter-integrated circuit), Wire, 2-Wire, or TWI SPI Serial Peripheral Interface CAN-Bus Controller Area Network
Bus Protocols Bus allows many devices to connect to the same port, each with its own address More sophisticated software Details are on datasheet Typical Applications: Proximity/Range sensor, Accelerometer/Gyro/Magnetometer(IMU)
I2C Bus 3 necessary wires: SCL clock SDA data Gnd electrical ground (voltage reference point) always connect grounds together VCC optional to power slaves 1 Master device - RIO N Slave devices each with a different address Master initiates transfer, addresses device(embedded in message), writes or reads data, and then ends transfer www.robot-electronics.co.uk/acatalog/i2c_tutorial.html
I2C Example Multiple Slaves address is usually set with solder bridges or jumpers
I2C Bus Magnetometer Configuration, operation, and reading values are all device specific Read the datasheet for device specifics such as address, protocol, etc
SPI Bus 5 necessary wires MOSI Master Out Slave In MISO Master In Slave Out SCK Clock SS Slave Select one for each slave Gnd ground always connect your grounds together Vcc optional power to slave (3.3v vs 5v) One master device (RIO) drives SCK, chooses one or more slaves via SS ports Multiple slave devices when selected, react to data received on MOSI line, send responses out MISO line
SPI Example
MyRIO Expansion Port
Passive Breakout Board for RoboRIO Expansion Port https://www.oshpark.com/shared_projects/dczxig8j
Using Sensors with the Talon SRX Source: http://ctr-electronics.com/talon%20srx%20user's%20guide.pdf
Talon SRX Analog Sensor Source: http://ctr-electronics.com/talon%20srx%20user's%20guide.pdf
Talon SRX - Encoder Source: http://ctr-electronics.com/talon%20srx%20user's%20guide.pdf
Talon SRX Limit Switches Source: http://ctr-electronics.com/talon%20srx%20user's%20guide.pdf
RioDuino Opens up the Arduino eco-system to the RIO Programmable in C++ using Arduino IDE Supports UART or I2C communication between RIO and RioDuino Not a lot of use or experience to draw from.
Using Sensors to Solve Problems
Using Sensors External Sensing How to determine distance traveled: encoder - count axle turns + simple + can use two encoders on opposite sides to determine turns - relative values - only know the distance between point A and B, but not where point A is - Inaccuracies caused by wheel slippage accelerometer - complex to use - only measure acceleration - best used in conjunction with other sensors
External Sensing (cont) How to determine Heading - gyro - measures rotational acceleration. Not an absolute measurement - magnetometer - may be subject to inaccuracies from nearby magnetic fields (the motors)
External Sensing the IMU Inertial Measurement Unit combination of accelerometer/gyro/magnetometer, with on-board software to simplify interactions. Very powerful and inexpensive, but can be difficult to use. AltIMU-10 v5 Gyro, Accelerometer, Compass, and Altimeter ($23) www.pololu.com
External Sensing (cont) Range finding - distance to target - IR - easy analog interface - short ranges (max 150cm ~5ft) - Narrow field - Sonar - Choices in interface - Longer ranges (max ~ 21ft) - Different field patterns available, wider than IR - Easy to get bad readings - LASER/Time of Flight - Inexpensive (~$15) - Large range (50-1200mm 2 to 40 ) - Camera - powerful, but requires complex algorithms
Using Sensors Internal Sensing Linear positioning - Limit switches, - Optical gates - String" potentiometer - Encoder - Magnet/Hall effect sensor Radial positioning - Potentiometer - Encoder - Magnet/hall effect sensor