Counter not counting !!!


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Time to consider using interrupts for this. Increment within the interrupt. Keep it small and fast!! I don't recall if the 88 has interrupts on portB.3

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    interrupt ... ok Guess I have to read up now.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I would suspect the "light-to-voltage sensor". Most of these have response times in the millisecond range, maybe too slow.

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I am not sure how interrupt can help in this case.
    At slow speed the counter works, but at higher speeds it does not pick half the time or more.
    I reduced the pause time to 20 after the LCDout, that did not help.

    K

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi lerameur,
    I would use a photo transistor and not a photocell, a Crystal or resonator running at 20 mhz rather than intosc @ 4mhz. those things might speed things up a bit. You might use interrupts to capture counts and display on an as time permits basis instead of watching every count.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I am using this little baby for a sensor
    http://www.taosinc.com/productdetail.aspx?product=63

    I think i will user TMR0 in my program

    K

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    I was thinking . . . make a subroutine called display and do this:
    if OldOutput_Pot == Output_Pot then
    gosub display
    then do your lcd routines in there, it would display any time the counter stops incrementing.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Well, the reason for suggesting an interrupt is simple. When you poll, you spend a finite time in checking the state of the input. If you miss this(fast revolutions), you will miss counts. However, if you use interrupts, you can be sure to catch a significantly higher number of pulses than you could using the poll technique. example - you may be able to read upto 20pulses per second using the poll techniqe, but upto 200 pulses per second or even more using interrupts.

    Simple analogy to understand the difference between interrupts and polling.
    Think of yourself seated at the PC doing some work. The time you take to respond to a person at the door is your 'poll time' and depends on what you are doing at the moment and how soon it will finish. This would be similar to checking every now and then to see if there is someone at the door.

    On the contrary, if the person rings a doorbell (interrupts). You know that the door needs to be opened because of this signal. The way the processor handles it is to finish the current 'instruction' that it is executing and respond to the bell. This is much much faster than the earlier technique of checking the door now and then.

    Please don't mind the over-simplification. It might help someone else understand.

    I also second the idea that the opto interrupter may not be fast enough. But, from my experience, they work well into the KHz range.

    I suggest your Main loop should just display the counts and the interrupt routine should just count.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Replies: 42
    Last Post: - 14th January 2008, 11:38
  3. 20 Digit Virtual LED Counter
    By T.Jackson in forum Code Examples
    Replies: 9
    Last Post: - 19th November 2007, 05:02
  4. Replies: 4
    Last Post: - 18th June 2007, 13:38
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

Members who have read this thread : 0

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