Download presentation
Presentation is loading. Please wait.
Published byShauna Taylor Modified over 8 years ago
1
Hit-and-Run Detection Camera Group #25: Nick Prozorovsky, Eric Stiles, and Wilson Wang
2
Introduction Hit-and-run incidents are common and frustrating This camera provides proof of the incident Mounted in rear window of car Automatically detects accidents Decreases storage requirement
3
Features Automatic detection of an accident using accelerometer Microcontroller interaction with all hardware Low car battery detection and product shutdown User interface with LED’s and buttons Voltage regulation from car battery to microcontroller
4
System Overview Hardware: Accelerometer Microcontroller (Raspberry Pi) Camera Voltage Regulator Voltage Comparator Buttons/LED interface Software: Main python script Accelerometer polling python script Startup bash script
5
3. Camera 7. Button/LED Interface 6. Voltage Comparator (PCB) 1. Accelerometer 2. Microcontroller (Raspberry Pi) 4. Voltage Regulator Components
6
= Signal = Power Block Diagram Data Collection A. Execution B. Accelerometer 1. Microcontroller 2. Camera 3. 12.6v Car Battery 5. Voltage Regulator (*v->5v) 4. Voltage Comparator (PCB) 6. Buttons/LED interface 7. = Power = Signal
7
Accelerometer Inputs: 3.3V, GND Outputs: SDA and SCL Data Lines ADXL 326 ADC ADXL 345 ± 16 g 2,4,8,16 3.3 V
8
Microcontroller Inputs: Power, accelerometer data lines, camera data, buttons, PCB shutdown Outputs: Accelerometer power, camera data/power, LEDs Raspberry Pi Model B+ 512MB SDRAM Micro SD GPIO Pins Accelerometer data 5V Input Pin
9
Camera Inputs: 3.3v, data control Outputs: Video data Continuously running Up to 1080p30
10
Voltage Regulator Inputs: Car Battery Outputs: 5V 12.6 V to 5 V 4.975 V Original circuit Voltage Regulator – LM 7805A TO-220 5 mA to 1 A, up to 15W Rpi draws around.5 A, averaging 2.5W
11
Car Battery Inputs: None Outputs: Approximately 12.6 V DC Actual amount will vary Uncontrollable variable Should not drop below 12 V
12
Voltage Comparator LM339N Comparator Chip Output Resistor divider circuit regulates output to 3.3V when V+ is above V- LM339N Chip grounds its output when V+ drops below V- Diode holds V- at a constant 6.8V Resistor divider circuit drops 12 V down to 6.8V IN4736A Zener Diode
13
V- = 6.67 Volts V+ = Vin [R2/(R1+R2)] V+ = 12 [10/(8+10)] = 6.67 Examples: Vin = 13 V+ = 7.22 > 6.67 Vin = 11.9 V+ = 6.61 < 6.67 Vin V+ V- Voltage Comparator Calculations
14
Conditions: Vin = 11 V V+ = 6.11 V V- = 6.67 V Output should have been grounded, but wasn’t Vin = 7.2 V V+ = 4 V V- = 6.67 Output became grounded Vin V+ V- Voltage Comparator Issue
15
Voltage Comparator Issue (Cont.) Breadboard circuit conditions: Vin = 12 V V+ = 6.68 V- = 6.67 Output was not grounded Vin = 11.99 V V+ = 6.66 V V- = 6.67 V Output was grounded Deduction: LM339 Chip on PCB was faulty
16
PCB Design Voltage Regulator Output V+ V-
17
Button/LED Interface 3 1 4 2 1.5 Volt connection from Raspberry Pi 2.GPIO Output connection 3.GPIO Input connection 4.Ground connection
18
Button/LED Interface 1 2 3 4 1.5 Volt power from Raspberry Pi 2.GPIO output connection 3.Push button 4.GPIO input connection Output Voltage: 5*[9.92/(9.92+5.65)] = 3.2 Volts
19
Software Function Overview (hitNrun.py) def log(string) Inputs: String to log to USB. Outputs: None. Purpose: Log strings to USB for debugging and event timestamps. Description: Helper function for debugging. Logs events to USB. Helpful when no monitor is attached to Raspberry Pi.
20
Software Function Overview (hitNrun.py) def moveFiles() Inputs: None. Outputs: None. Purpose: Save files in a folder so they cannot be overwritten. Description: Creates new directory with timestamp. Moves all video files to new directory. Attempts to copy entire folder to USB.
21
Software Function Overview (hitNrun.py) def deleteFiles(clipsToKeep) Inputs: Integer representing the number of looping clips to keep. Outputs: None. Purpose: Deletes oldest clips to save storage space. Description: Ensures less than ‘clipsToKeep’ total video clips. If more, deletes oldest video clip.
22
Software Function Overview (hitNrun.py) def deleteDirectories(direcsToKeep) Inputs: Integer representing the number of saved directories to keep. Outputs: None. Purpose: Deletes oldest saved directories to save storage space. Description: Ensures less than ‘direcsToKeep’ total saved directories. If more, deletes oldest saved directory. Reduces false-positive saves.
23
Software Function Overview (hitNrun.py) def check_accel() Inputs: None. Outputs: Character in the signal text file. 0 – Accelerometer is not triggered. 1 – Accelerometer has been triggered. 2 – Accelerometer is disconnected. Purpose: Communicates with accelerometer script to determine when to save files. Description: Reads from signal file to determine accelerometer status. Returns code to main function to determine appropriate action.
24
Software Function Overview (hitNrun.py) def check_buttons() Inputs: None. Outputs: Whether or not files need to be moved. 0 – No buttons are pressed. 1 – Manual save button pressed. Shutdown – Reset button pressed or input voltage too low, shuts down Raspberry Pi immediately. Purpose: Interfaces with buttons and PCB directly to receive user-inputs. Description: Buttons have to be held down for >3 seconds so buttons are not accidentally pressed. If manual save button held, return 1 to main file to indicate file save. If PCB outputs voltage high or reset button held, powers down Raspberry Pi.
25
Software Function Overview (hitNrun.py) def powerdown(option=0) Inputs: Optional integer value to indicate power down or restart Outputs: None Purpose: Helper function to power down the Raspberry Pi. Description: Shuts down Raspberry Pi by default. If ‘option’ specified, attempt to restart Raspberry Pi.
26
Software Function Overview (hitNrun.py) def main() Inputs: None. Outputs: None. Purpose: Initializes variables, starts camera recording, calls all helper functions and takes appropriate actions. Description: Initializes variables, turns red LED on to indicate power. Camera started, constantly checks accelerometer and buttons. If accelerometer triggered or manual save button, sleep for ‘clipLength’ time and save all video files. If accelerometer error, save video files and blink red LED, wait for reset. Call deleteFiles and deleteDirectories functions to clean up old files.
27
Software Function Overview (accel.py) def writeToFile(option) Inputs: Character to write to signal file. Outputs: None. Purpose: Writes signal character to signal file to communicate with main script. Description: Opens up signal file. Writes accelerometer status to file. Closes file pointer.
28
Software Function Overview (accel.py) def main() Inputs: None. Outputs: None. Purpose: Reads accelerometer axes to determine if threshold is exceeded or if an error is present. Description: Infinite loop to get data from accelerometer, writes data to USB file for graphing. If accelerometer values exceed threshold, alert main script. If accelerometer error, alert main script. If trigger or error, wait for 5 seconds so main script has time to acknowledge.
29
Software Function Overview (start.sh) None Inputs: None. Outputs: None. Purpose: Bash script to launch on startup and start both python scripts. Description: Starts both python scripts in background. Attempts to copy new USB scripts to update scripts for next bootup.
30
Software Flowchart
32
Accelerometer Verification -Rotation of device on all three axes -Shows 1g on each axis when rotated -1g = 9.8 m/s 2 Accelerometer is functioning properly
33
Accelerometer Data 1 2 3 4 Product run-through in Car 1. Slamming car door (.5g) 2. Slamming car trunk (.8g) 3. Hitting a pothole (.65g) 4. Slamming on brakes while traveling 30mph (1.25g) Results: Normal activity will not cause false positives if tripping value is 2g’s
34
Accelerometer Data (Cont.) -Data collected from shaking device -Triggers at magnitude of 3g’s -Offset of 1g due to gravity
35
Rear End Collision Acceleration -Acceleration from collisions are all 3g’s or greater -Set tripping value to 2g’s -False positives ignored -Accidents will be captured Table taken from “Real World and Vehicle Test Data” from the Motor Insurance Repair Research Centre Rear End Collision Data
36
Requirements and Verifications Product powers on from voltage regulator Accelerometer triggers at correct values Footage is saved and events are logged on USB Device shuts down with low voltage (@7 volts instead of 12) Buttons and LED interface properly interact with software
37
Current Limitations/Future Work Replace faulty comparator chip Replace voltage regulator/heat sink with one rated for higher power Send data to cloud storage From lab to car: Way to mount system down so camera and accelerometer are stable Way to wire/power it up throughout the car Car batteries are not all same, they won’t all be in 12.6v-12v range Raspberry Pi still draws a very small amount of current even when powered down
38
Thanks!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.