Continuing on from measuring speed, here we look at how to measure acceleration with a light gate. A video supporting this article is also available:
If you’ve not built your light gate then see this guide. Also if your interested in measuring speed check this article out.
What is acceleration?
If you’re accelerating then your speed is increasing. That is to say your speed is getting faster and faster all the time. The faster it increases the higher the acceleration. So acceleration is the rate at which your speed increases over time. In physics the time is usually expressed in seconds so acceleration is the how much the speed changes per second.
The Units
As speed is distance over time or m/s and acceleration is the change in speed per second then the unit for acceleration is m/s/s (metres per second per second). Sounds confusing but it’s just the change in speed (metres per second) every second (per second. Instead of writing m/s/s it’s most commonly written as m/s² which mathematically is the same as m/s/s. Whatever you do don’t let the units confuse you, acceleration is still only how fast somethings speed is increasing every second.
The equation
So we need to to know by how much an objects speed has increased, for that we need to measure its speed twice in order to see just how the speed has changed. That’s simple the difference in speed is just the difference of Speed2-Speed1 ( or commonly termed start and end speed). And as we noted above acceleration is how fast the speed changed, i.e. over what time did this speed change take place. So the equation becomes;
Measuring acceleration – method 1 (don’t do it this way!)
In this method we need two light gates so we can measure the objects speed as it goes through the first one and then again as it goes through the second one. But this means you need two light gates, there is a method of measuring acceleration without using two light gates.
Measuring acceleration – method 2 (do it this way!)
Instead of having two light gates we have two pieces of card (same length) on top of our car (or whatever moving object) a small distance apart. As we have a very accurate timekeeper accurate to 1 thousand of a second this is a very valid way of doing this. If the object under test was travelling very very fast then two light gates may be required but unlikely in the scenario of what is being built. Below is a diagram of how it might appear:
And in the real world my solution looked like this:
Note : The distance between the two pieces of card is relatively unimportant unless they are so close together that the increase in speed is very little or that the Arduino cannot spot the change from one card to another or doesn’t have time to set up ready for the next card. It is certainly not critical as far as any calculations are concerned so just stick them on top a short distance apart as shown. Both cards must be the same length though.
The Code
Here’s the code you’ll need to upload, again (as in the speed article) if you are not using 5cm card you will need to alter the value at the start of the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
#include <IRremote.h> float LengthOfCard=0.05; #define PIN_IR 3 #define PIN_DETECT 2 #define PIN_STATUS 13 IRsend irsend; void setup() { pinMode(PIN_DETECT, INPUT); pinMode(PIN_STATUS, OUTPUT); irsend.enableIROut(36); irsend.mark(0); Serial.begin(9600); delay(1000); // wait for system to settle } float WaitForSpeedReading() { /// returns a speed reading // wait for active digitalWrite(PIN_STATUS,false); while(digitalRead(PIN_DETECT)==true); digitalWrite(PIN_STATUS,true); // wait for "thing" to cross beam while(digitalRead(PIN_DETECT)==false); // start timing digitalWrite(PIN_STATUS,false); long int StartTime=millis(); // wait for thing to stop blocking beam while(digitalRead(PIN_DETECT)==true); // end timing long int EndTime=millis(); long int TotalTime=EndTime-StartTime; float Secs=float(TotalTime)/1000; return LengthOfCard/Secs; } void loop() { float Speed1,Speed2; Speed1=WaitForSpeedReading(); // for accel it's the change in speed over a time period, so after measuring // the first speed we record start time that this speed was recorded at // then after the second speed measurement we do the same again and then record // the time between these speed changes long int StartTime=millis(); Speed2=WaitForSpeedReading(); // record end time long int EndTime=millis(); // get the time between both speed readings and convert to seconds float TimeTaken=(float(EndTime-StartTime)/1000); // equation for acceleration is // accel=EndSpeed-StartSpeed/Time Taken for that change float accel=float((Speed2-Speed1)/TimeTaken); Serial.print("Start Speed "); Serial.print(Speed1); Serial.print("m/s , "); Serial.print("End Speed "); Serial.print(Speed2); Serial.print("m/s , "); Serial.print("Time Taken : "); Serial.print(TimeTaken); Serial.println("s"); Serial.print("Acceleration = "); Serial.print(accel); Serial.println("m/s2"); } |
And that’s it, improvements would be the inclusion of a screen of some sort to easily display the results. In the next article we’ll look at calculating the acceleration of objects due to gravity.