How to use Arduino PWM to control motor force.

I been doing a project for Stroke Patient, it is related to a load cell to test the grip strength of the patient.

Project includes:
Arduino Mega 2560
Planetary dc motor (IG42-S14E DC12V 405RPM 6.5kg.cm)
13Amp 6V-30V DC Motor Driver
5kg Load Cell and module XFW-HX711

Below is the attachment photo for the project.

I'm learning how to use Arduino PWM to control the force of the motor. Anyone can help me? cause i'm still new with Arduino and motor stuff.

Please edit your post to use code tags ("</>" button) instead of quote tags.

This looks odd:
units = scale.get_units(), 10;

larryd:
This looks odd:
units = scale.get_units(), 10;

Well I use a coding I found at Instructables about load cell to check how it works. Right now I'm trying to do another coding for it.

PWM doesn't control the force consistently I'm afraid.

You need to measure the current through the motor, that is linearly related to the torque of the motor.

You can then use a PID loop to set the torque by adjusting the PWM in a feedback loop.

However if the motor is stalled (stationary), then the relationship between PWM and force will be more
consistent. It will change as the motor warms up though.

MarkT:
PWM doesn't control the force consistently I'm afraid.

You need to measure the current through the motor, that is linearly related to the torque of the motor.

You can then use a PID loop to set the torque by adjusting the PWM in a feedback loop.

However if the motor is stalled (stationary), then the relationship between PWM and force will be more
consistent. It will change as the motor warms up though.

Is there a tutorial? cause i can't seem to find any related to it.

can you give some details about your motor driver module?

hesam_m:
can you give some details about your motor driver module?

My motor driver is from Cytron Technologies. MD13S. Rare right?

SoraJayson:
My motor driver is from Cytron Technologies. MD13S. Rare right?

it looks like a brushless motor driver, but your DC motor is ordinary. You probably you don't need this.

just use a logic level Mosfet and connect your load to the drain with a protection diode
if I am right brushless motors used in the applications where speed matters, such as a quadcopter

SoraJayson:
Is there a tutorial? cause i can't seem to find any related to it.

I doubt anyone else is doing this - is it being used stalled as I surmized? The only accurate way
is to measure the current, and even then you have some uncertainty related to static friction.
Stalled motors tend to heat up (no air cooling), so the friction can change, as will the response to
PWM (the windings increase in resistance). Measuring the current seems like the most repeatable
and sensible approach if consistency is important.