Counter per minute


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Dec 2005
    Posts
    23

    Default Counter per minute

    Hello all and good years

    I will want a counter per minute with:
    -count pulses in RB0
    -setting tmr0 (prescaler 256) + loop but it can't works

    what is wrong please


    '************************************************* ***************
    '* Name : Compte tour.BAS
    '* Author : [set under view...options]
    '* Notice : Copyright (c) 2005 [set under view...options]
    '* : All Rights Reserved
    '* Date : 31/12/2005
    '* Version : 1.0
    '* Notes :
    '* :
    '************************************************* ***************
    Adcon1=7
    Define osc 20
    TRISB=%00000001 ' setting port B
    TRISA=%00000000 ' setting port A

    OPTION_REG=%01001111 ' inerruption RB0/INT
    ' Incrrase tmr0
    ' prescaller 256
    INTCON = %10010000 ' setting INTCON


    '-------------------------------------------------------------------------------

    'setting LCD

    DEFINE LCD_DREG PORTB ' LCD o/p on port B
    DEFINE LCD_DBIT 4 ' LCD on lower 4 bits of port B
    DEFINE LCD_RSREG PORTB ' LCD reset on port B
    DEFINE LCD_RSBIT 3 ' LCD reset portB.3
    DEFINE LCD_EREG PORTB ' LCD enable on port B
    DEFINE LCD_EBIT 2 ' LCD output on PortB.2
    DEFINE LCD_BITS 4 ' LCD o/p is 4 bit data
    DEFINE LCD_LINES 2 ' Number of lines on LCD = 2

    '-------------------------------------------------------------------------------

    Compte_pulse var word
    Compte_timer0 var word
    Tours_minute var word


    '-------------------------------------------------------------------------------


    On interrupt goto Isr

    '-------------------------------------------------------------------------------
    Main:

    If intcon.2=1 then
    Compte_timer0=Compte_timer0+1
    intcon.2=0
    endif
    if Compte_timer0=58500 then
    Tours_minute=Compte_pulse*20
    Lcdout$fe,1
    Lcdout,#Tours_minute," Tours/mn"

    '-------------------------------------------------------------------------------
    Compte_timer0=0
    Compte_pulse=0
    endif
    Goto Main
    disable

    '-------------------------------------------------------------------------------

    Isr:

    Compte_pulse=Compte_pulse+1
    INTCON.1 = 0 'flag d'interruption à 0
    resume
    enable

  2. #2
    Join Date
    Jul 2005
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Hi

    Its here:

    Lcdout,#Tours_minute," Tours/mn"


    It should be:

    Lcdout #Tours_minute," Tours/mn"

  3. #3
    Join Date
    Dec 2005
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    thank's for your remark Crematory my question is more general
    it's a good method of programming because the best resolution
    is of 20 turns per mn,5 would be ideal

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink THe Goal ... what's the Goal !!!

    Hi DebutPic

    The first question to ask is that one : you want to show 5 turns/min resolution , ok, BUT at which speed ???

    Where do you want to measure these RPMs ???

    There are other methods for RPM Measuring ... but depends on the use you want to do ... and mostly the pulse freq.

    Ceci dit, un joyeux pneu à toi aussi !!! ( a happy good year ... )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Dec 2005
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi Acetronics

    It's a RPM counter for a mill machine,range 0-4000 turns per mn
    i want use a sensor "hall-effect" fixed on the spindle

    and happy new years
    mon anglais est malade mais je le soigne........

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Talking Happy new year !!!

    Hi, Debut Pic

    Have a look here : http://www.parallax.com/html_pages/r...PM_display.asp ... funny, isn't it ???

    Code directly usable ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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. Counter not counting !!!
    By lerameur in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 20th February 2009, 22:15
  3. 20 Digit Virtual LED Counter
    By T.Jackson in forum Code Examples
    Replies: 9
    Last Post: - 19th November 2007, 05:02
  4. help
    By patricx in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 31st August 2007, 10:13
  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