How to set TMRO & TMR3 as Counter?.


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default

    Hi,
    I'm sorry but I'm not quite sure what the problem is...?

    You can use TMR0 AND TMR1 as counters at the same time. OR you can use TMR0 AND TMR3 as counters at the same time. BUT you can NOT use TMR1 AND TMR3 as counters at the same time since they both share the same clock-pin (pin 15 on the 40-pin DIP package)

    If this doesn't help please explain what the problem is , if you can.

    /Henrik Olsson.

  2. #2
    Join Date
    Jun 2005
    Location
    Penang
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Ahh..

    Hi Henrik,

    Yes,that exactly i wanted to know ( you can NOT use TMR1 AND TMR3 as counters at the same time ).Ok,my doubt is cleared.Seems like i got to use an interrrupt pin and a counter.I hope it would work.And 1 more thing,the selection of QEI in PIC18F4431.If i don't want to use INDEX and wish to reset it using software (POSCNT=MAXCNT),am i have to set value of the maxcount ( Ex : MAXCNT = 1500 ) ??.And could i use single channel encoder output from 2 encoder which is from 2 different motor?.

    I am sorry if i am bothering you alot,but this things is new to me and locally nobody had tried this kind of stuff due to the price of these electronics and availibility.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Ok,my doubt is cleared.Seems like i got to use an interrrupt pin and a counter.
    Well, if you say so.... If you could explain what it is you're trying to do it may be easier for me or anyone else to suggest a solution. If you don't use TMR0 for anything you CAN use that AND TMR3, both as counters. If you ARE using TMR0 for something ELSE than a counter, perhaps you can shift that work to TMR3 thus making TMR0 and TMR1 available as counters - it all depends....

    And 1 more thing,the selection of QEI in PIC18F4431.
    I'm a bit confused...I thought we were talking about the 18F4550 here, the 18F4431 doesn't even have a TMR3.....

    Regarding the QEI, if you don't want to use the Index channel you can either just let the position register overflow or use the position counter reset on period match. In the later case you set MAXCNT to the value at which you want the postion counter to reset to zero, 1500 for example.... You can NOT use just one channel from the encoder. The QEI module needs two channels, 90 degrees phase shifted with respec to each other. Otherwise it can't tell which way the motor is turning.

    I am sorry if i am bothering you alot,but this things is new to me and locally nobody had tried this kind of stuff due to the price of these electronics and availibility.
    No problem at all. That's what the forum is here for.

    /Henrik Olsson.

  4. #4
    Join Date
    Jun 2005
    Location
    Penang
    Posts
    40


    Did you find this post helpful? Yes | No

    Default I am glad.

    Thanks Henrik.You understand my pain.

    Well,what i am trying to do here is actually to have single channel encoder from each encoder (2 encoder) and feed it into PIC.I want to use interrupt but i belive when the interrupt occured,you got to clear it right?.Is this might lead to missing pulse as you have to loop to clear the interrupt?.Although without pause?.I even thought about using RB Port Change Interrupt as i belive i could hook up quadrature encoder to RB7:RB4 but i belive it could make some delay in clearing and again lead to missing pulse.

    My apologise for confusing you with 18F4550 and 18F4431.I do own this chip and it's more awsome than LM629.

  5. #5
    ra68gi's Avatar
    ra68gi Guest


    Did you find this post helpful? Yes | No

    Default

    Hi nature tech,
    Its been a long time since i last posted on this forum. I have written a program for a rotary encoder. But i have written it in C. I have used pic16f72 and have made 1x, 2x, 4x measurements. In 1x it increments counter only once for every pulse. I had used a 1000ppr(pulse per rev) encoder & the count value displayed on a LCD. So the resolution is 360degrees/1000. With 2x you will get double & with 4x you get 360/4000.
    I have used different interrupt sources like portb int0, ccp,timer0, timer1.
    If you are interested i will send you the source code.
    The compiler Iam using is free version & you can write upto 2k code. And all this with instant interrupts.
    If you are interested let me know & i will post it.

    Raghunathan.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Mikro C
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    ra68gi's Avatar
    ra68gi Guest


    Did you find this post helpful? Yes | No

    Default

    No. It's BoostC.
    If you are new to C & interested to learn it quickly, see this link..http://forum.sourceboost.com/index.php?showtopic=2399. C is more structured & universal language. I migrated to C recently & its power is awsome as regards to microcontroller programming. If you intend to impliment rtos on small ram pics, that too is available called nova rtos. Have a try.
    Regards

    Raghunathan.

Similar Threads

  1. Pin won't stay high during Repeat...Until loop??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th August 2009, 23:57
  2. Interruptus Frustratus
    By Byte_Butcher in forum General
    Replies: 16
    Last Post: - 17th April 2009, 20:36
  3. Counter not counting !!!
    By lerameur in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 20th February 2009, 22:15
  4. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts