Skip to main content
Associate
October 17, 2024
Question

Pad Force Vs Velocity Implementation and Testing using STM32

  • October 17, 2024
  • 1 reply
  • 2332 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;
}

 

 

 

 

1 reply

Andrew Neil
Super User
October 17, 2024

What do you mean by "pad" here?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
RiderAuthor
Associate
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

 

 

 

Andrew Neil
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 ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.