Maker Pro
Maker Pro

Usage of the same timer for 2 modules

Hello,

My dspic (dsPIC30F3014) does have only 3 timers.
For OC module ( output compare ) and IC module ( input capture ) there are available only 2 timers, Timer 2 and Timer 3.
I need to command 2 DC motors, and i use 2 OC modules, using a timer each.
Now, for my IC module, i do not have any timer left available. I need some help with this issue.

Thank you,
Alex.
 
Do you have to use a timer? What are you doing?

For my line follower robot.
I use 2 OC for controling 2 DC motors independently. OC modules use Timer 2 and Timer 3.
I need also to start/stop the robot remotely, using some RF pic trasmmiter/reciever.
And the best method i think, for intercepting the signal emitted by transmitter is to use a Input Compare module
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
So you're doing PWM on the 2 motors?

You may be able to use one timer to interrupt the program and write code to handle the PWM manually. For example you might interrupt the code 5000 times per second and decide whether to keep the motors on for 0 to 100 counts in each 100 interrupts. That will operate the motor at 50Hz which may well be fast enough.

I'm not sure that you need to do anything special with timers for the white line detectors, but this method will leave you with enough timers to do what you want to do.
 
You can run two PWMs off the same timer. Each OC unit has it's own duty cycle register. The only restriction is that that PWM periods are the same, and for your purpose I would think you would want the same period, only the duty cycles would vary.

Bob
 
Top