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 CCS Technical Support

Step Counting using pwm.
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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 28, 2010 2:29 am     Reply with quote

If that's what he wants to do, it can also be done by increasing the
postscaler on Timer2. The postscaler affects only the Timer2 interrupt.
At the maximum setting, you will get one interrupt for every 16 PWM
cycles. Currently it's set at 1 in the example program.
bruno.gf



Joined: 26 Jan 2010
Posts: 9

View user's profile Send private message

PostPosted: Thu Jan 28, 2010 4:44 am     Reply with quote

Thank you John P. thats a good idea, i'll think(and study) more about it.

And PCM Programmer, setting the postscaler to 1 is what i need, since i want to count every pulse, right??
If i set it to 16 i'll only count pulses that are multiples of 16.

Thanks.

Best Wishes.
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Thu Jan 28, 2010 7:20 am     Reply with quote

Using the postscaler is much more elegant than tying up a second timer and making sure it's coordinated with TMR2. It sounds like a way better solution. Count in 16's until you get close to the goal, then switch over to counting single pulses.

But if this device is to drive a stepper motor, is there a need to slow down at the end of a move? That makes things more complicated.
bruno.gf



Joined: 26 Jan 2010
Posts: 9

View user's profile Send private message

PostPosted: Thu Jan 28, 2010 8:15 am     Reply with quote

Hi John P.

Quote:
But if this device is to drive a stepper motor, is there a need to slow down at the end of a move? That makes things more complicated.


Is the opposite, I don't want it to slow down.

I need the interruptions just to do the variable increase (in one unit), and then I want it to run normally.
I know the interrupt function has some delays; about 40 or 50 us ( as PCM Programmer said), but I don't need that precision.

Best Wishes.
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