Presentation is loading. Please wait.

Presentation is loading. Please wait.

AAPT workshop W03 July 26, 2014 Saint Cloud State University, MN, USA

Similar presentations


Presentation on theme: "AAPT workshop W03 July 26, 2014 Saint Cloud State University, MN, USA"— Presentation transcript:

1 AAPT workshop W03 July 26, 2014 Saint Cloud State University, MN, USA zliu@stcloudstate.edu

2 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 I 2 C bus (accelerometers, magnetic sensors, gyroscopes etc.) Digital sensors with SPI, One-Wire, SDI-12 interfaces

3 Resistive sensors (10-bit) Thermistor: doped semiconductor that decreases resistance with increasing temperature. Light dependent resistor (LDR): doped semiconductor that decreases resistance with increasing light intensity. Also called photo resistors. Wikipedia.org

4 Sensing resistance The easiest way to sense resistance is to form a voltage divider using a fixed resistor and the variable resistor. 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. 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. Analog input GND V sen R fix R

5 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.

6 Breadboard vs. schematic

7 Photo resistor 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

8 Thermistor: 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

9 Analog sensors (10-bit) Vernier direct temperature probe (DCT-DIN) Slope 55.55DegC/V or 100DegF/V Intercept -17.7DegC or 0DegF 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) 123 1.Analog voltage 2.Slope 3.Intercept

10 Reading Vernier analog sensors reading=analogRead(channel); Line 1: acquire data: result=a*reading+b; Line 2: scale data for output: lcd.clear(); Line 3: clear LCD: lcd.print(result); Line 4: output result: delay(200); Line 5: pause momentarily for user: reading=analogRead(channel); Line 1: acquire data: result=a*reading+b; Line 2: scale data for output: Serial.println(result);Line 3: output result: delay(200); Line 4: pause momentarily for user: Display measurement on the LCD, 5 lines of code Send measurement to PC, 4 lines of code

11 Optional: Reflective sensor Use channel 0 (leftmost) Diode side Wiring: Left pin – 150ohm resistor 150ohm resistor – Red Transistor side wiring: Left pin – White Right pin – Black Integers calculation will truncate accuracy of the result. Make sure to use floating point numbers when necessary to maintain accuracy.

12 ADXL335 Accelerometer 2 3 1

13 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.While signal is HIGH, wait for LOW. 2.When it becomes LOW, store time stamp and wait for HIGH again. 3.When it becomes HIGH again, wait for LOW. 4.When it becomes LOW, subtract stored time stamp from current time stamp. 5.Divide predefined blocker distance by the time elapse to find speed. 6.Best way to sense a photogate is to use an object implementing state machine

14 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.

15 Sonic ranger code and wiring Use channel 0 (leftmost) Wiring: VCC – RED Trig – Brown Echo – WhiteGND – Black 1 2 3 4 5 6 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.

16 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.

17 I 2 C 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.

18 ADXL345 Accelerometer

19 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.

20 Stores persistent values of offset for each axis Controls data range and accuracy Stores x, y, and z acceleration measurements, low and high bytes

21 How to set offset registers How to set data format registers

22 10DOF sensor board wiring 1.VCC_IN – Red 2.GND – Black 3.SCL – Write 4.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.


Download ppt "AAPT workshop W03 July 26, 2014 Saint Cloud State University, MN, USA"

Similar presentations


Ads by Google