Count Per Second


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Mar 2007
    Posts
    30

    Default Count Per Second

    Hi all,

    i've got a question for you,

    I've a Geiger-Muller Tube, an instrument for measuring radiations, which gives me an output in the form of a pulse of minimum 90uS,

    i need to measure the number of pulses per second with the minimal possible error,

    cause the pulse is minimum 90uS every second i can have at max
    1.000.000uS / 90uS = 11.111 CPS (Counts Per Second)

    this means that every 5 seconds i have to store the variable in an I2C memory (To be downloaded in a PC)

    i was thinking to something like a loop to check for the pulses and store them in a RAM word-sized variable and use an interrupt that every 5 seconds store the variable into the I2C mem,

    like this:

    GEIGER VAR PORTD.0
    CNT VAR WORD
    ADD VAR WORD
    CONTROL VAR BYTE

    CONTROL = $A0
    ADD = 0

    CheckLoop:
    IF GEIGEG THEN
    CNT = CNT + 1
    ENDIF
    GOTO CheckLoop

    IntHand:
    I2CWRITE SDA,SCL,CONTROL,ADD,[CNT]
    ADD = ADD + 1
    CNT = 0
    RESUME

    Do you think it would suit me? (I don't know a lot about pic timing...)
    there would be a better way to count or to check for the pulse? (i'm not interested in the pulse lenght)
    (Please ignore the missing TMR or INTCONT)

    Thank you,

    Luca

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    If that's the only thing the PIC will do this may work:
    Code:
    GEIGER VAR PORTD.0
    CNT VAR WORD
    ADD VAR WORD
    CONTROL VAR BYTE
    
    Start:
      CNT = 0
      COUNT GEIGER, 5000, CNT     'Count pulses for 5 seconds, store in CNT.
      Gosub SaveData
    Goto Start
    
    SaveData:
      'Save data to EEPROM here
    RETURN
    /Henrik Olsson.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    If that's the only thing the PIC will do this may work:
    Code:
    GEIGER VAR PORTD.0
    CNT VAR WORD
    ADD VAR WORD
    CONTROL VAR BYTE
    
    Start:
      CNT = 0
      COUNT GEIGER, 5000, CNT     'Count pulses for 5 seconds, store in CNT.
      Gosub SaveData
    Goto Start
    
    SaveData:
      'Save data to EEPROM here
    RETURN
    /Henrik Olsson.
    Assuming you don't get over 65,535 pulses...
    What happens if you overflow too early? I've never tried, but does COUNT kick out before 5 seconds if it hits 65,535, does it roll over...
    And don't forget, COUNT is entirely dependant upon the PICs oscillator speed and will only count low to high transitions (not that either of those should matter much).

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Assuming you don't get over 65,535 pulses...
    Yes, but you don't since each pulse is said to be 90uS or longer... About the oscillator speed, yes, COUNT depends on the accuracy of the oscillator but so does any other method I can think of.

    /Henrik Olsson.

  5. #5
    Join Date
    Mar 2007
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    Cause i have pulses not shorter than 90uS, i can have a max of 11.111 pulses per second, in 5 seconds i can have a max of 55.555 pulses, there's a way to count for more than 5 seconds, (In other words, there's a way to use a variable longer than a word, like a double word) ?

    with a double word i could count up to 4.294.967.296 which is 386.550 seconds!

    thank you,

    Luca

  6. #6
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83


    Did you find this post helpful? Yes | No

    Default big count

    I had a similar problem where the count might exceed 65000.
    I divided up the COUNT into 4 COUNTS.
    It can be argued that there is holes between each COUNT. It does work! Don't think about the holes. time=4 seconds
    rons
    COUNT GEIGER, 1000, CNT1
    COUNT GEIGER, 1000, CNT2
    COUNT GEIGER, 1000, CNT3
    COUNT GEIGER, 1000, CNT4

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  2. Can't get COUNT to count
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd March 2009, 23:14
  3. Count pulses between VARIABLE TIME
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 12:44
  4. Multiplex Display with count comand
    By mdaweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th October 2005, 04:09
  5. Count command
    By hawk72501 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2005, 19:04

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