CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

stepper motor for loop
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
zeyad



Joined: 24 Feb 2015
Posts: 22

View user's profile Send private message

reply
PostPosted: Wed Mar 04, 2015 10:57 pm     Reply with quote

Ttelmah wrote:
You are still ignoring lots of things you have been told. I'll put some comments in part of your code, _read them_:
Code:

{
int j;
int i=0;

for(i=0;i<(rev*360/1.8);i++){
//rev *360, will overflow the maths being used as soon rev>1

  output_b(ax[i%4]);
  for (j=1000;j<50;j--){
//What is the biggest number that 'j' can hold?.
//Is the loop ever going to execute?. j is never '<50' so loop
//will exit immediately.

    delay_ms(j);
//If it did work, just how long is this going to take?. 1 step per second
//at the start!.....
   }
 }
}


Code:
{
int8 j;
int8 i=0;

for(i=0;i<(rev*360/1.8);i++){

  output_b(ax[i%4]);
  for (j=55;j>90;j--){
    delay_ms(j);

   }
 }
still problem ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19326

View user's profile Send private message

PostPosted: Thu Mar 05, 2015 1:55 am     Reply with quote

All three comments still apply.....
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Re: reply
PostPosted: Thu Mar 05, 2015 2:30 am     Reply with quote

zeyad wrote:
Ttelmah wrote:
You are still ignoring lots of things you have been told. I'll put some comments in part of your code, _read them_:
Code:

{
int j;
int i=0;

for(i=0;i<(rev*360/1.8);i++){
//rev *360, will overflow the maths being used as soon rev>1

  output_b(ax[i%4]);
  for (j=1000;j<50;j--){
//What is the biggest number that 'j' can hold?.
//Is the loop ever going to execute?. j is never '<50' so loop
//will exit immediately.

    delay_ms(j);
//If it did work, just how long is this going to take?. 1 step per second
//at the start!.....
   }
 }
}


Code:
{
int8 j;
int8 i=0;

for(i=0;i<(rev*360/1.8);i++){

  output_b(ax[i%4]);
  for (j=55;j>90;j--){
    delay_ms(j);

   }
 }
still problem ?
Run your code in MPLABSIM.
Examine the values for i, j and portB.
Are they what you expect them to be?
The penny may drop, you SHOULD then understand what Ttelmah is saying.

Mike
zeyad



Joined: 24 Feb 2015
Posts: 22

View user's profile Send private message

Re: reply
PostPosted: Thu Mar 05, 2015 3:58 am     Reply with quote

Mike Walne wrote:
zeyad wrote:
Ttelmah wrote:
You are still ignoring lots of things you have been told. I'll put some comments in part of your code, _read them_:
Code:

{
int j;
int i=0;

for(i=0;i<(rev*360/1.8);i++){
//rev *360, will overflow the maths being used as soon rev>1

  output_b(ax[i%4]);
  for (j=1000;j<50;j--){
//What is the biggest number that 'j' can hold?.
//Is the loop ever going to execute?. j is never '<50' so loop
//will exit immediately.

    delay_ms(j);
//If it did work, just how long is this going to take?. 1 step per second
//at the start!.....
   }
 }
}


Code:
{
int8 j;
int8 i=0;

for(i=0;i<(rev*360/1.8);i++){

  output_b(ax[i%4]);
  for (j=55;j>90;j--){
    delay_ms(j);

   }
 }
still problem ?
Run your code in MPLABSIM.
Examine the values for i, j and portB.
Are they what you expect them to be?
The penny may drop, you SHOULD then understand what Ttelmah is saying.

Mike


thank you
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Mar 05, 2015 7:15 pm     Reply with quote

Just another suggestion: To improve readability don't quote each and every message.
What you are doing is good usage in mailing lists but here you are on a forum website where everybody clearly sees all previous messages. Quote nothing if you are responding to the full last message. Quote a message part when you are responding to an older message.

For example, in your last post there is a full page of text on my screen with only two new words of you: 'thank you'.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group