cancel
Showing results for 
Search instead for 
Did you mean: 

Using MCSDK API

ccut93
Associate III

Hardware:
B_G473E_ZEST1S - Control board
STEVAL-LVLP01 - Power board
MOONS R57BLB50L2 BLDC motor

Software:
MCSDK 6.2.1
Code framework generated by MotorControl Workbench v6.2.1
IDE STM32CubeIDE
Code customized only in main.c.  See attached.

I was able to get my motor to spin reliably through Motor Pilot by going to OpenLoopDuty mode, and running at 10hz with 20% duty cycle, then switching to ClosedLoopSpeed.  Going straight to ClosedLoopSpeed from observer mode works about 6-10 times.  When it fails to start, it slowly wiggles back and forth.  If I spin it by hand, it will start spinning normally.  I want to automatically cycle start/stop of the motor to ease the debugging of the polarizing pulse. 

(My main question is not the startup behavior, but rather running the motor through the API, though comments about startup behavior is appreciated.  Picture of o-scope reading of Phase 3 during polarizing pulse is provided.)

When I've tried to run the motor through code with the API, I am unable to get the motor to start spinning, even with a kick start.

What I've Tried:
I first tried following instructions from MOOC Motor Control Part 2, but the functions they used don't seem to exist for HSO.  I've tried searching for getting started guides for HSO.  They all describe using MotorControl Workbench, but everything I've seen stops short of describing controlling in code via the API.
I wrote my code based on the comments in mc_api.c.
In my main loop, I use functions from the mc_api.  I start with MC_StartWithPolarizationMotor1(), and wait until the state is in RUN, Then I SetAccelerationMotor1(100), SetControlModeMotor1(MCM_SPEED_MODE), and MC_SetSpeedReferenceMotor1(400).

Expected Behavior:
Go to RUN mode, accelerate to 400hz at 100 hz/s, then wait 20s, stop motor for 2s, repeat

Behavior:
Motor goes to run mode, FOC mode goes to ClosedLoopSpeed, and I hear a click.  Motor slowly wiggles back and forth erratically for aprox 20s (max angular speed <2hz).  Status goes IDLE for 2s, then repeat.
Wiggle is behavior is simillar to entering ClosedLoopSpeed with a speed of 0.

1 ACCEPTED SOLUTION

Accepted Solutions
DBE
ST Employee

Hello ccut93,

Please try to use, in your application, MC_SetSpeedReferenceMotor1_F(400) API instead of MC_SetSpeedReferenceMotor1(400).

I see in your MotorPilot.png that you are using Pol. Pulse feature, please configure it by following the HSO_startup guide if not already done. You can find the link to this document in the release note.

Best regards 

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

View solution in original post

2 REPLIES 2
DBE
ST Employee

Hello ccut93,

Please try to use, in your application, MC_SetSpeedReferenceMotor1_F(400) API instead of MC_SetSpeedReferenceMotor1(400).

I see in your MotorPilot.png that you are using Pol. Pulse feature, please configure it by following the HSO_startup guide if not already done. You can find the link to this document in the release note.

Best regards 

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.
liaifat85
Senior II

Please Look for a loose connection. Also, check all the components separately.