View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 28, 2010 2:29 am |
|
|
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
|
|
Posted: Thu Jan 28, 2010 4:44 am |
|
|
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
|
|
Posted: Thu Jan 28, 2010 7:20 am |
|
|
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
|
|
Posted: Thu Jan 28, 2010 8:15 am |
|
|
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. |
|
|
|