Measuring speed using phototransistors in Arduino

Click For Summary
SUMMARY

This discussion focuses on measuring the speed of a projectile using two photo-transistors in an Arduino setup. The user experiences inconsistent speed readings for fast-moving objects, such as paintballs, while slow-moving objects yield accurate results. Key suggestions include increasing the sampling rate of the analogRead() function and implementing timer interrupts for precise timing. Additionally, adjusting the sensitivity of the photo-transistors or experimenting with different sensor types may enhance measurement accuracy.

PREREQUISITES
  • Understanding of Arduino programming and syntax
  • Familiarity with photo-transistor operation and sensitivity
  • Knowledge of timing mechanisms in microcontrollers
  • Experience with analog signal processing
NEXT STEPS
  • Research increasing the sampling rate in Arduino using analogRead()
  • Learn about implementing timer interrupts in Arduino for accurate timing
  • Explore different types of photo-transistors and their sensitivity characteristics
  • Investigate signal filtering techniques to improve measurement accuracy
USEFUL FOR

Electronics enthusiasts, Arduino developers, and anyone involved in projectile speed measurement projects will benefit from this discussion.

HHOboy
Messages
32
Reaction score
0
Hey guys, I am working on a project where I am using two photo-transistors to detect the speed of a projectile. I am trying to measure the speed of a paintball but I am getting mixed results. When a slow moving object passes through the sensors the correct speed is displayed but extremely fast objects can sometimes trick it.

Here is the sketch... It works but if you know any ways to make it more efficient please let me know, Thanks for your help!

FYI: The two sensors are 4 inches apart that is where the constant "333333" comes from the distance between the sensors in the FPS calculation

C:
int firstsens = 4;
int secondsens = 5;
unsigned long time, time2;
float fps, elap;
int val;
int val2;

void setup()
{
Serial.begin(9600);
pinMode (firstsens, INPUT);
pinMode (secondsens, INPUT);
}
void loop()
{
Serial.println("Waiting for projectile...");
val = analogRead(firstsens);
val2 = analogRead(secondsens);
while (val > 1)
{
  val = analogRead(firstsens);
}

while (val <= 1)
{
time = micros();
val = analogRead(firstsens);
}

while (val2 > 1)
{
  val2 = analogRead(secondsens);
}

while (val2 <= 1)
{
time2 = micros();
val2 = analogRead(secondsens);
}
elap = time2 - time;

fps = 333333/elap;
Serial.println(fps );
}
 
Last edited by a moderator:
Technology news on Phys.org


Hello there! It sounds like you have a very interesting project on your hands. Using photo-transistors to detect the speed of a projectile is definitely a creative approach. However, it is not surprising that you are getting mixed results when trying to measure the speed of a fast-moving object like a paintball.

One way to potentially improve the efficiency of your setup is to use a higher sampling rate for your analogRead() function. This will allow you to capture more data points and potentially get a more accurate reading for the speed of the projectile. Additionally, you may want to consider using a more precise timing mechanism, such as a timer interrupt, to accurately measure the time between the two sensors being triggered.

Another potential issue could be the sensitivity of your photo-transistors. If they are not sensitive enough, they may not be able to accurately detect the fast-moving paintball. You may want to experiment with different types of sensors or adjust the sensitivity settings to see if that improves the accuracy of your readings.

Overall, it seems like you have a good starting point for your project and with some fine-tuning and adjustments, you should be able to get more consistent and accurate results. Keep up the good work and don't hesitate to reach out if you have any further questions or need more assistance. Good luck with your project!
 

Similar threads

Replies
7
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
15K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K