Accelerometer ********************* Description ============ The accelerometer is a device used to measure velocity of a moving object between two distant points and its acceleration. It is designed and constructed based on the engineering design process that is followed in the Coder-Maker program. Learning Objectives ==================== The accelerometer is a device that helps students learn and apply the following: - Coding, electronics, and physical science through a hands-on application that can be directly related to real life situations. - Motion concepts of the science of linear motion, mainly velocity and acceleration: + Initial and final velocity + Average velocity + Time + Acceleration - The implementation of the engineering design process - Application of theoretical concepts to real life situations Materials Needed ================= - Raspberry Pi with micro SD card with Raspbian - One ultrasonic sensor - Jumper wires - Resistors 300Ω or similar - Breadboard - Glue gun and glue sticks - Cutter blades or scissors - Thin sturdy cardboard (poster or portfolio cardboard) Setup and Functionality ======================== The accelerometer is a simple device that is programmed on the Raspberry Pi and uses an ultrasonic sensor to collect data of a moving object. When an object is moving towards the sensor, the program starts collecting data about the distance travelled over a defined period of time. Using this data, it will calculate the initial and final velocity of the object in this time interval, and from the velocity and time values, it calculates acceleration. Resistors of 300Ω or similar ones are used in this setup. This will ensure protection of the GPIO on the Raspberry Pi and at the same time all components connected to them will still work properly. As shown in the diagrams below, the accelerometer can be constructed in two different ways. One setup (figure 1) is designed to measure acceleration using one ultrasonic sensor. This setup enables the sensor to measure the acceleration of an object that is moving towards. The program codes for calculation of acceleration and gives a reading every two seconds. The average acceleration over a certain time interval is considered to be the average acceleration value. The other setup (figure 2) is designed to measure the acceleration of an object moving across the sensors. In other words, the moving object will pass in front of sensor one first and then in front of sensor two. In this setup, the start position has to be set at a 15 cm distance from sensor one. Circuitry and Electronics ========================== The digrams below show all the wiring and connections of all the componenets in the setups of both accelerometers: .. figure:: _static/img/accelerometer1.png :align: center Figure 1: shows the wiring and connections of one ultrasonic sensor to the Raspberry Pi. .. figure:: _static/img/accelerometer2.png Figure 2: shows the wiring and connections of two ultrasonic sensors to the Raspberry Pi. .. warning:: The use of resistors is important for the protection of GPIO on the raspberry Pi. The value of the resistors should be properly chosen based on the components used to ensure proper functioning (see above). Programming ============ The accelerometer has been programmed using Python language: **Code of the accelerometer that is using one ultrasonic sensor:** .. literalinclude:: ../examples/accelerometer/Accelerometer1code.py **Code of the accelerometer that is using two ultrasonic sensors:** .. literalinclude:: ../examples/accelerometer/Accelerometer2code.py .. include:: scienceConcepts/accelerometerPythonSC.rst