* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Open Source Electronics for Laboratory Physics Chapter 3: Sensors
Survey
Document related concepts
Transcript
Saint Cloud State University, MN, USA [email protected] AAPT workshop W03 July 26, 2014 CH3: Sensors Resistive sensors (thermistors, photo resistors etc.) Analog sensors (PASCO or Vernier analog sensors etc. output voltage represents measurement) Digital on-off sensors (photo-gates, Hall-effect switches etc.) Digital pulse width sensors (sonic rangers) Digital sensors with serial output (some sonic rangers) Digital sensors with I2C bus (accelerometers, magnetic sensors, gyroscopes etc.) Digital sensors with SPI, One-Wire, SDI-12 interfaces Resistive sensors (10-bit) Thermistor: doped semiconductor that decreases resistance with increasing temperature. 1 1 1 𝑅 = + ln 𝑇 𝑇0 𝐵 𝑅0 𝐵 𝑇= 𝑅 ln 𝐵 −𝑇 𝑅0 𝑒 0 Light dependent resistor (LDR): doped semiconductor that decreases resistance with increasing light intensity. Also called photo resistors. Wikipedia.org Sensing resistance 𝑉𝑠𝑒𝑛 Vsen 𝑅 = 𝑅𝑓𝑖𝑥 𝑉𝑠𝑒𝑛 5𝑉 − 𝑉𝑠𝑒𝑛 Rfix The easiest way to sense resistance is to form a voltage divider using a fixed resistor and the variable resistor. R For best accuracy, the value of the fixed resistor should be equal to that of the variable resistor when it is in the middle of its range. Analog input GND 𝑅 = ∗ 5𝑉 𝑅 + 𝑅𝑓𝑖𝑥 OSPL has on-board 10Kohm pull-up resistors on channels A1, A3, and A5 so there is no need to add a resistor to the circuit. This makes prototyping and cabling a lot easier. Breadboard All 5 holes in a row are connected and they act as junctions you see on a schematic. All holes along a red bus are connected but different red buses are separate. Same goes with blue buses. Breadboard vs. schematic Photo resistor 𝑅 = 𝑅𝑓𝑖𝑥 𝑉𝑠𝑒𝑛 5𝑉 − 𝑉𝑠𝑒𝑛 Integers calculation will truncate accuracy of the result. Make sure to use floating point numbers when necessary to maintain accuracy. Use channel 0 (leftmost) Wiring: One end – White Other end – Black Thermistor: 𝑅 = 𝑅𝑓𝑖𝑥 𝑉𝑠𝑒𝑛 5𝑉 − 𝑉𝑠𝑒𝑛 𝑇= ln 𝐵 𝑅 𝑅0 𝐵 − 𝑒 𝑇0 Integers calculation will truncate accuracy of the result. Make sure to use floating point numbers when necessary to maintain accuracy. Use channel 0 (leftmost) Wiring: One end – White Other end – Black Analog sensors (10-bit) Vernier direct temperature probe (DCT-DIN) Slope 55.55DegC/V or 100DegF/V Intercept -17.7DegC or 0DegF 1. Analog voltage 2. Slope 3. Intercept 1 2 3 Vernier dual range force gauge (DFS-DIN) Slope -4.9N/V (±10N) or -24.5N/V(±50N) Intercept 12.25N (±10N) or 61.25N (±50N) Reading Vernier analog sensors Read sensor voltage Convert reading x with y=ax+b Format result send to LCD or PC Delay (for mere humans) Send measurement to PC, 4 lines of code reading=analogRead(channel); result=a*reading+b; Serial.println(result); delay(200); Line 1: acquire data: Line 2: scale data for output: Line 3: output result: Line 4: pause momentarily for user: Display measurement on the LCD, 5 lines of code reading=analogRead(channel); result=a*reading+b; lcd.clear(); lcd.print(result); delay(200); Line 1: acquire data: Line 2: scale data for output: Line 3: clear LCD: Line 4: output result: Line 5: pause momentarily for user: Optional: Reflective sensor Integers calculation will truncate accuracy of the result. Make sure to use floating point numbers when necessary to maintain accuracy. Use channel 0 (leftmost) Diode side Wiring: Left pin – 150ohm resistor 150ohm resistor – Red Transistor side wiring: Left pin – White Right pin – Black ADXL335 Accelerometer 1 2 3 Digital on-off sensors PASCO photogates No obstruction-digital HIGH Obstruction-digital LOW Predefined blocker distance (1cm) for speed calculation 10 spokes on pulley for angular speed calculation To calculate speed: 1. 2. 3. 4. 5. 6. While signal is HIGH, wait for LOW. When it becomes LOW, store time stamp and wait for HIGH again. When it becomes HIGH again, wait for LOW. When it becomes LOW, subtract stored time stamp from current time stamp. Divide predefined blocker distance by the time elapse to find speed. Best way to sense a photogate is to use an object implementing state machine Pulse-width sensor Sonic ranger Start ranging by pulling the trigger pin to HIGH for 10us or longer then return it to LOW Ranger will emit ultrasonic pulses and detect its echo Ranger pulls the echo pin HIGH for the amount of time it takes sound to travel the distance round trip Detect this pulse width with pulseIn() and calculate distance with speed of sound. Accuracy depends on timing accuracy of the receiver. Sonic ranger code and wiring Use channel 0 (leftmost) Wiring: VCC – RED Trig – Brown Echo – White GND – Black 1 1. Initialize pins A0 as output and A1 as input. 2. Initialize the serial port to 9600 baud rate. 3. Define a variable to store result. 4. Toggle the INIT pin to start ranging. 5. Get result with a function pulseIn(). 6. Convert the result into distance in mm and print it to serial monitor. 2 3 4 5 6 Serial interface sensor Maxbotix sonic rangers (car reverse parking sensors) Free running at around 10Hz Prints “R1234\n” where 1234 is the range in mm. Requires some C-string to integer conversion if range value is to be used programmatically Can be directly connected to a PC Measurements are done on board and suffers NO loss of accuracy during transmission. 2 IC sensors Inter-Integrated Circuit bus connects to many sensors. Two wires for a large number (127) of different sensors Each sensor module has a different address Measurements are done on board and suffers NO loss of accuracy during transmission. Requires the Wire library to communicate with and some understanding of the commands on data sheets. ADXL345 Accelerometer ADXL345 3-axis accelerometer ADXL345 has maximal range of 18g in all 3 dimensions First set up the device (range, power up) Then read the device data register for X, Y, and Z acceleration. Stores persistent values of offset for each axis Controls data range and accuracy Stores x, y, and z acceleration measurements, low and high bytes How to set offset registers How to set data format registers 10DOF sensor board wiring 1. 2. 3. 4. VCC_IN – Red GND – Black SCL – Write SDA – Brown Note the diagram is a mirror image of the actual sensor board. The code is so long I can only fit a small portion on this slide.