# tennis racket/ball speed/impact detection using the MPU-6050

#### HappyC4mper

Joined Oct 13, 2017
71
I have a mini project I'm trying to accomplish using an arduino nano and an mpu-6050. What my code does is basically trying to find the speed of the racket on impact and perhaps the impact force on the ball. What I have at the moment is that it it detects the interval of the tennis stroke and the time it takes for that stroke to occur (back swing, acceleration, contact and then follow through) during that time it calculates the Impact acceleration of the value when the racket hits ball in m/s2. Now my question is, is there a way to measure the speed of the ball after in contact with the racket knowing the acceleration of the racket? Is it possible to just convert m/s2 to speed?
Also After identifying what the curve looks like after contact, is there a way to detect this small change(circled in the image attached)? Sometimes, on contact, it shows a smooth triangle curve with no impact mark which is quite hard to identify when trying to write a logic for this code.

#### Attachments

• 41.7 KB Views: 13

#### drc_567

Joined Dec 29, 2008
1,088
What is the significance of the small irregular step in the front side of the large triangular peak?
Would that be the time duration that the tennis ball requires to decelerate from its incoming velocity to zero velocity as it changes direction from forward to reverse?

Last edited:

#### HappyC4mper

Joined Oct 13, 2017
71
What is the significance of the small irregular step in the front side of the large triangular peak?
Would that be the time duration that the tennis ball requires to decelerate from its incoming velocity to zero velocity as it changes direction from forward to reverse?
That is pretty much bang on! I'm not sure how I can code a logic to be able to detect that interruption.

#### drc_567

Joined Dec 29, 2008
1,088
It seems like the very fine features/curves of that front slope feature need to be examined, if possible.
A useful bit of information would be the time segment duration for the ball to decelerate to zero. However, the small waveform shown seems to have an extra oscillation. So maybe half of the small wave oscillation is incoming deflection, and the other half is rebound deflection.

#### StayatHomeElectronics

Joined Sep 25, 2008
1,070
Can you calculate the slope of the curve during the forward acceleration, contact, and follow through?

On the easily identifiable contacts the slope goes from positive to negative. Maybe the change of slope will pick up some features on the other curves, where the acceleration is not affected in such a drastic manner.

#### drc_567

Joined Dec 29, 2008
1,088
One experiment that might be of interest would be to use a radar gun or similar device to measure the velocity of the incoming tennis ball, and also observe the time on the mpu-6050 that the ball takes to reach zero velocity on the display, from which numbers the magnitude of deceleration could be calculated. This deceleration number could then be compared to the mpu-6050 result, giving an idea of the accelerometer accuracy.

Last edited:

#### Janis59

Joined Aug 21, 2017
1,297
Haaah, when I was student I bit cover with ignorance the sports lessons (why engineer needs that) so in the semester end those tutor cached me and said the only way to get the pardon is to solder for him a hockey team anayzer device for measuring the hit force. So I used the grammaphone piezo sensor fixing it on the vaneer piece where the hit will happen, and 1980~ epoch operational amplifier. On the scale of whole soviet 140UD1 catastrophy mine was a spaceflight - Riga Alfa was begun to laid out the 153UD1. So, identical box was fixed on hockey beat and both signals was sent to the factory made standard frequency meter in time shift measure regime. Lets clapp, and it shows the flight time between beat and target. Few years it worked well, but then sensors was degraded and I hadnt anymore a motivation to renew anything. It was anno 1981.

If today, I would probably use the light-gates with two laser rays. Then the beat is wire-less and no degradation because the hard hits.

#### HappyC4mper

Joined Oct 13, 2017
71
One experiment that might be of interest would be to use a radar gun or similar device to measure the velocity of the incoming tennis ball, and also observe the time on the mpu-6050 that the ball takes to reach zero velocity on the display, from which numbers the magnitude of deceleration could be calculated. This deceleration number could then be compared to the mpu-6050 result, giving an idea of the accelerometer accuracy.
I've managed to figure out how to find the contact point of the ball by using the Yacceleration curve to find the sudden deceleration on impact.
To find the speed of the racket/ball i used newtons law V=at, Where V is the speed of the racket, a acceleration t time elapsed. Lets say we have the mass of bat and ball (m1,m2). Energy Conservation law is M1*V1=M2*V2 So,v2=m1*v1/m2 Which should be the speed of ball right? I have a ball speed app on my phone which should measure the ball speed (not the most accurate probably +-8 in error) and i can use that as a conversion factor where the mpu acceleration data(metres/s) divided by the app data(mph). Therefore speed of the ball * the calibration factor.
For the racket speed what i did was have the acceleration data multiplied by the time it took from the start of the swing to the contact point.

so i have this logic :
v1=(n*impactTime)/1000; //calculating the speed of racket, 1 sec=1000 msec
v2=((m1/m2)*v1); //calculating the speed of ball
v2=v2*calFactor; //Ballspeed(From speedapp) = Ballspeed(MPU6050)* Factor

Would this be sufficient to find the ball speed or am I missing or not taking another factor into consideration reason im asking is because After testing this i get ridiculous values for my racket speed and very off values for my ball speed.

#### drc_567

Joined Dec 29, 2008
1,088
... It may be that a handheld tennis racket will dampen any oscillation produced by a ball hitting the netting of a racket. You can get the faint impact oscillation trace, as you have shown in the first post. However, obtaining impact oscillation traces with actual numerical significance may require a different method.
... You might try placing the racket and accelerometer in a rigid fixture of some sort and then hitting the fixed racket with a tennis ball, in order to see if you achieve a more prominent impact signal.
... might work, might not work.

Last edited:

#### HappyC4mper

Joined Oct 13, 2017
71
... It may be that a handheld tennis racket will dampen any oscillation produced by a ball hitting the netting of a racket. You can get the faint impact oscillation trace, as you have shown in the first post. However, obtaining impact oscillation traces with actual numerical significance may require a different method.
... You might try placing the racket and accelerometer in a rigid fixture of some sort and then hitting the fixed racket with a tennis ball, in order to see if you achieve a more prominent impact signal.
... might work, might not work.
since I'm only looking at data from a short distance(back swing to contact)and one axis (z axis) is dead reckoning still possible without many errors?

#### doodleman

Joined Sep 1, 2020
1
I've managed to figure out how to find the contact point of the ball by using the Yacceleration curve to find the sudden deceleration on impact.
To find the speed of the racket/ball i used newtons law V=at, Where V is the speed of the racket, a acceleration t time elapsed. Lets say we have the mass of bat and ball (m1,m2). Energy Conservation law is M1*V1=M2*V2 So,v2=m1*v1/m2 Which should be the speed of ball right? I have a ball speed app on my phone which should measure the ball speed (not the most accurate probably +-8 in error) and i can use that as a conversion factor where the mpu acceleration data(metres/s) divided by the app data(mph). Therefore speed of the ball * the calibration factor.
For the racket speed what i did was have the acceleration data multiplied by the time it took from the start of the swing to the contact point.

so i have this logic :
v1=(n*impactTime)/1000; //calculating the speed of racket, 1 sec=1000 msec
v2=((m1/m2)*v1); //calculating the speed of ball
v2=v2*calFactor; //Ballspeed(From speedapp) = Ballspeed(MPU6050)* Factor

Would this be sufficient to find the ball speed or am I missing or not taking another factor into consideration reason im asking is because After testing this i get ridiculous values for my racket speed and very off values for my ball speed.
since I'm only looking at data from a short distance(back swing to contact)and one axis (z axis) is dead reckoning still possible without many errors?
I've managed to figure out how to find the contact point of the ball by using the Yacceleration curve to find the sudden deceleration on impact.
To find the speed of the racket/ball i used newtons law V=at, Where V is the speed of the racket, a acceleration t time elapsed. Lets say we have the mass of bat and ball (m1,m2). Energy Conservation law is M1*V1=M2*V2 So,v2=m1*v1/m2 Which should be the speed of ball right? I have a ball speed app on my phone which should measure the ball speed (not the most accurate probably +-8 in error) and i can use that as a conversion factor where the mpu acceleration data(metres/s) divided by the app data(mph). Therefore speed of the ball * the calibration factor.
For the racket speed what i did was have the acceleration data multiplied by the time it took from the start of the swing to the contact point.

so i have this logic :
v1=(n*impactTime)/1000; //calculating the speed of racket, 1 sec=1000 msec
v2=((m1/m2)*v1); //calculating the speed of ball
v2=v2*calFactor; //Ballspeed(From speedapp) = Ballspeed(MPU6050)* Factor

Would this be sufficient to find the ball speed or am I missing or not taking another factor into consideration reason im asking is because After testing this i get ridiculous values for my racket speed and very off values for my ball speed.
I think you should calculate the racket speed and ball speed separately?! like not involving the racket speed and ball speed in the same formula.

#### andrewmm

Joined Feb 25, 2011
1,140
regarding the mpu,
whats the interface to the processor ?
how is the MPU set up.

I seem to remember that this part has an I2C or SPI interface,
and the internal sencors have built in integration, and a reading time measured in milli seconds.

I dont know anything about the bat ball, but my guess is the time of contact between the too is of the order of a milli second.

The bit I'm getting to is does the IMU actulay give you a reliable meassurment,