Tle987x evalboard BEMF Motor running and stopping problem in a loop

Announcements

Webinar: Integrated solutions for smaller, simpler low-voltage motor control design.
Join the webinar to experience!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User17857
Level 3
Level 3
First like received
Hello everyone,

I am using tle987x evalboard with the example code that is names " BLDC_BC_BEMF_EXAMPLE_TLE987X". I want to run motor and after sometime i want to stop it later then i want to run it again
in a loop . My code is below. it runs the motor and afte some time it stops the motor. But the motor never runs again in the loop. What can be the problem?


static void Main_lStartMotor(void);
static void Main_lStopMotor(void);
uint32 Error;
/*******************************************************************************
** Globale Variable Definitions **
*******************************************************************************/

/*******************************************************************************
** Private Variable Definitions **
*******************************************************************************/
static uint8 bMotorRun;
static uint32 count;
uint32 Error;
/*******************************************************************************
** Private Constant Definitions **
*******************************************************************************/

/*******************************************************************************
** Global Function Definitions **
*******************************************************************************/
/** \brief Executes main test code.
*
* \param None
* \return None
*
*/
bool b;
int i=0;
int main(void)
{
/*****************************************************************************
** initialization of the hardware modules based on the configuration done **
** by using the IFXConfigWizard **
*****************************************************************************/

TLE_Init();
Emo_Init();
b=true;
count=0;


Emo_setspeedreferenz(2000);



for(;;){
/* Service watch-dog */
(void)WDT1_Service();

/* Start motor to run up to the desired speed */

count++;

if(b)
{
Error = Emo_StartMotor();
PORT_ChangePin(LED1, PORT_ACTION_SET);
}

if(count>345000 )
{
Error = Emo_StopMotor();
b=false;
if(count>(2*345000))
{
count=0;
b=true;
}
}

}
}



/* End of main() */


void Main_HandleSysTick(void)
{

} /* End of Main_HandleSysTick */


/*******************************************************************************
** Private Function Definitions **
*******************************************************************************/
static void Main_lStartMotor(void)
{


Error = EMO_ERROR_NONE;

if (Error == EMO_ERROR_NONE)
{

}

if (Error == EMO_ERROR_NONE)
{
}
else /* Error */
{
}
} /* End of Main_lStartMotor */


static void Main_lStopMotor(void)
{

Error = Emo_StopMotor();

if (Error != EMO_ERROR_NONE)
{
}
} /* End of Main_lStopMotor */


Kind Regards
Murat.
0 Likes
2 Replies
Fiz
Moderator
Moderator
Moderator
First like received 50 replies posted 25 replies posted
Hi Murat,

we will try to take a deeper look into your software.

Best,
Fiz
0 Likes
Fiz
Moderator
Moderator
Moderator
First like received 50 replies posted 25 replies posted
Hi Murat,

i adapted your code so it is somewhat performing your desired task.
But to start and stop the motor i would use a build in timer. f.e. GPT12 timer5.

Best,
Fiz
/*******************************************************************************
** Private Function Declarations **
*******************************************************************************/
static void Main_lStartMotor(void);
static void Main_lStopMotor(void);
uint32 Error;
/************************************************** *****************************
** Globale Variable Definitions **
************************************************** *****************************/

/************************************************** *****************************
** Private Variable Definitions **
************************************************** *****************************/
static uint8 bMotorRun;
static uint32 count;
uint32 Error;
/************************************************** *****************************
** Private Constant Definitions **
************************************************** *****************************/

/************************************************** *****************************
** Global Function Definitions **
************************************************** *****************************/
/** \brief Executes main test code.
*
* \param None
* \return None
*
*/
bool b;
int i=0;
int main(void)
{
/************************************************** ***************************
** initialization of the hardware modules based on the configuration done **
** by using the IFXConfigWizard **
************************************************** ***************************/

TLE_Init();
Emo_Init();
b=true;
count=0;


Emo_setspeedreferenz(2000);



for(;;){
/* Service watch-dog */
(void)WDT1_Service();

/* Start motor to run up to the desired speed */

count++;

if(b)
{
Error = Emo_StartMotor();
PORT_ChangePin(1, PORT_ACTION_SET);
}

if((count>345000)&& (b==true))
{
Error = Emo_StopMotor();
b=false;
count = 0;
}
if((count>345000)&& (b==false))
{
Error = Emo_StartMotor();
count=0;
b=true;

}

}
}



/* End of main() */


void Main_HandleSysTick(void)
{

} /* End of Main_HandleSysTick */


/************************************************** *****************************
** Private Function Definitions **
************************************************** *****************************/
static void Main_lStartMotor(void)
{


Error = EMO_ERROR_NONE;

if (Error == EMO_ERROR_NONE)
{

}

if (Error == EMO_ERROR_NONE)
{
}
else /* Error */
{
}
} /* End of Main_lStartMotor */


static void Main_lStopMotor(void)
{

Error = Emo_StopMotor();

if (Error != EMO_ERROR_NONE)
{
}
} /* End of Main_lStopMotor */
0 Likes