Controlling brushless motor position using Arduino Due and BTS7960B

Hi everyone!
I want to control the position of a brushless motor (as if it was a stepper) using two H bridge BTS7960 and an optical encoder (400bm).
My idea is to send three SPWM (with a difference of 120 degrees between each one) to the brushless motor to control the velocity. Then, with the help of an encoder, I want to make a close loop to control the position of the motor.
Any example of the three SPWM code? Any advice, considerations?
Thank you!!

You would need three of those chips to control most regular brushless motors.

I don't think that chip is ideal for brushless motors. I've used a few Infineon chips in various projects and one of their good features is the "slew rate control" which ramps up the power slowly for each pulse of PWM. That's good for not radiating high-frequency EMI but it means the output isn't exactly what you put in. At 95% PWM, then output only drops a little in between PWM pulses so the output is more like 99%.

Brushless motors are so common now that it should not be hard to find dedicated chips specifically built for this purpose. So long as you're not trying to control a big motor, you could probably find a chip with all three half-H bridges. The applications list on the BTS7960 includes things like sunroofs and power windows - all brushed motors.

TommyGant:
My idea is to send three SPWM (with a difference of 120 degrees between each one) to the brushless motor to control the velocity. Then, with the help of an encoder, I want to make a close loop to control the position of the motor.

The PWM peripheral on a DUE has a synchro feature to output, e.g., 3 SPWM with a 120 degrees phase shift . There are also 2 hardware quadrature decoder.

Here is a link to an example of this in practice.

You can also use 3-phase sinusoidal PWM for a 3-phase motor - in fact its probably the right thing to
do if using encoder rather than hall-switches, since you have full phasor information - just be sure
to use an ABZ encoder so you can get absolute position after a test rotation in open-loop control.

Closed loop control like this is termed vector control or field oriented control, and you will have
a decision to make about how much to use amplitude and how much use phase in the control loop.
The easiest is full amplitude, vary the phase difference (from actual measured phase).