Skip to main content
Visitor II
October 17, 2024
Question

Pad Force Vs Velocity Implementation and Testing using STM32

  • October 17, 2024
  • 1 reply
  • 993 views

Hello, 

I am trying to implement a STM32 based pad assessment functionality, in which the applied force should be converted to the velocity based on user set polynomial degrees as in below image. I have implemented the code to calculate velocity based on ADC values and apply it to pad curve functionality. But I don't have any mechanical setup to measure the force applied so I can plot the Force vs Velocity curves. I would like to get some feedback on the implementation and need some idea on how to test the same.

frcvsvel.png

 

 

FinalVelocity = ApplyPadCurve(user_velocity, usr_degree);

uint8_t ApplyPadCurve(uint8_t velocity, uint8_t degree) 
{
	uint8_t FinalscaledValue = scaledValue;
	switch (degree)
	{
	case 1: // Curve deg 1 (Linear)
		FinalscaledValue = scaledValue; 
		break;

	case 2: // Curve deg 2 (Quadratic)
		FinalscaledValue = pow(scaledValue, 2.0) / 100; 
		break;

 case 3: // Curve deg 3 (Cubic)
 FinalscaledValue = pow(scaledValue, 3.0) / pow(100, 2.0); 
		break;

 case 4: // Curve deg 4 (Quartic)
 FinalscaledValue = pow(scaledValue, 4.0) / pow(100, 3.0);
		break;

 default:
 break;
 }
	return FinalscaledValue;
}

 

 

 

 

    This topic has been closed for replies.

    1 reply

    Super User
    October 17, 2024

    What do you mean by "pad" here?

    RiderAuthor
    Visitor II
    October 17, 2024

    Hello Andrew Neil,

    I’m referring to the velocity-sensitive pads used in MIDI instruments, as shown in the image below.

    Rider_1-1729181319677.png

     

     

     

    Super User
    October 17, 2024

    So where did you get that curve from?

    Are you creating a new device, or just "hacking" an existing product?

    If it's an existing product, can't you just just look at the MIDI output it gives?

     


    @Rider wrote:

    I don't have any mechanical setup to measure the force applied


    Weight is a force ...

     

    But isn't what you're really interested in just the velocity? The actual force is immaterial, surely?

    You could measure velocity with a light-gate.

    Or drop a known weight from a known height - so velocity can be calculated ...