COUNT is not counting again


Results 1 to 34 of 34

Threaded View

  1. #23
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    This code;
    Code:
     @ device  pic16F690, intrc_osc_noclkout, wdt_off, mclr_off, protect_off 
      K CON 15     ' Calibration factor for flow meter = # pulses per gal
      
    ' Setup Timer0 as an 8-bit counter with the clock input on RA2.
    ' 1:1 TMR0 prescaler
    ' TMR0 counts on high-to-low transitions
      OPTION_REG = %00111000
      
    ' A/D & Comparators disabled
      ANSEL=0           ' all digital
      ANSELH=0          ' analog module disabled
      CM1CON0=0
      CM2CON0=0
      
    ' Port setup
      PORTC = 0         ' LEDs off, PULSOUT RC3 provides a high-going pulse
      PORTA = 0
      TRISC = %11110000 ' lower 4 pins outputs
      TRISA = %11111111 ' RA2 = TMR0 clock input for simulated meter pulse inputs
      TMR0 = 0          ' clear TMR0 count       
      
    Main:
      IF TMR0 < K  THEN
                        ' Keep the valve open...do nothing..let water flow
      ELSE
        PULSOUT PORTC.3,1000  ' Generate required 10 msec pulse to RC3
        WRITE 7, TMR0   ' write count if you need to?
        TMR0 = 0        ' clear TMR0 count
        HIGH PORTC.0    ' LED toggle stuff
        PAUSE 500
        LOW PORTC.0 
      ENDIF
      GOTO Main
      
      END
    With the schematic attached - works. It writes 15 to EEPROM after precisely
    15 press/release actions on the switch.

    Tested on the PICkit 2 low pin count demo board.

    The cap on RA3 is 0.01uF, which helps eliminate contact bounce from the switch.

    The switch on the PICkit 2 demo board connects to RA3, so a wire runs directly from
    RA3 to RA2. Remove the cap, and switch bounce causes problems. It's a really simple
    fix.

    If your circuit is powered from 5V, and you measure 5V between the PIC VDD/VSS pins,
    and you only see 3.2V on RA2 with a pull-up to VDD, then check your circuit. There's a
    problem somewhere with your wiring or connections.
    Attached Images Attached Images  
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Can't get COUNT to count
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd March 2009, 23:14
  2. Remain counting while sending out a pulse
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th January 2007, 15:51
  3. hardware counting while software runs
    By Archangel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd October 2006, 03:26
  4. continious counting process (capture)
    By asynch in forum General
    Replies: 1
    Last Post: - 17th February 2006, 07:42
  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