Connect with us

Usage of the same timer for 2 modules

Discussion in 'Microcontrollers, Programming and IoT' started by alexsoad, Jul 1, 2011.

Scroll to continue with content
  1. alexsoad

    alexsoad

    12
    0
    Apr 4, 2011
    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.
     
  2. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,839
    Jan 21, 2010
    Do you have to use a timer? What are you doing?
     
  3. alexsoad

    alexsoad

    12
    0
    Apr 4, 2011
    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
     
  4. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,839
    Jan 21, 2010
    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.
     
  5. alexsoad

    alexsoad

    12
    0
    Apr 4, 2011
    Yes.
    What about using a software timer for IC module?
     
  6. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,839
    Jan 21, 2010
    I think that's pretty much what I suggested.
     
  7. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    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
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-