stepper motor code for cortex ARM help...

Status
Not open for further replies.

embed_v

Junior Member level 1
Joined
Aug 10, 2010
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,432
hiii i have some stepper code here but i am confusing the if (Motor_Steps--) statement so help me for understanding this code

Code:
BOOL Pulse_Motor(void)
{
if(State)
{
GPIO_PORTE_DATA_R = MOTOR_STEP_OUT;
State = 0;
}
else
{
GPIO_PORTE_DATA_R = 0;
State = 1;
Step_Table_Index++;
}

if (Motor_Steps--)
{
// Set next match value
TIMER0_MATCHR_R = TIMER0_TC_R+Motor_deltaTimer_Value;
}
else
{
Motor_Stop();

}
return 0;..................................is it right?
}

if any wrg then suggest plz...
Reply With Quote
 
Last edited by a moderator:

You posted only a small portion of the code, but as far as I can see, this piece of code is related to pulse duration.

And, please, use CODE tags to format your code for readability.

Code:
BOOL Pulse_Motor(void)
{
	if(State)
	{
		GPIO_PORTE_DATA_R = MOTOR_STEP_OUT;
		State = 0;
	}
	else
	{
		GPIO_PORTE_DATA_R = 0;
		State = 1;
		Step_Table_Index++;
	}

	if (Motor_Steps--)
	{
		// Set next match value
		TIMER0_MATCHR_R = TIMER0_TC_R+Motor_deltaTimer_Value;
	}
	else
	{
		Motor_Stop();

	}
	return 0;..................................is it right?
}
 

the if (Motor_Steps--) will be true as long as the Motor_Steps variable is not zero.
Note that a post-decrement operation (changed after evaluation) is used so the value will be evaluated and then decremented.

Code C - [expand]
1
2
++x;  --x;      // pre-increment/pre-decrement operation   (changed before evaluation)
x++;  x--;      // post-increment/post-decrement operation  (changed after evaluation)



Alex
 

hai,

can u send me whole code for stepper motor,I am doing a project regarding stepper motor control & also I want to create a GUI application to control it by using serial com, I have no idea about this, can u plz help me.



 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…