Searching \ for 'PULSE COUNTING' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/timers.htm?key=count
Search entire site for: 'PULSE COUNTING'.

Truncated match.
PICList Thread
'PULSE COUNTING'
1999\06\07@110059 by DANNY ROWELL

flavicon
face
part 0 16 bytes
</x-html>

1999\06\08@095733 by DANNY ROWELL

flavicon
face
part 0 16 bytes
</x-html>

1999\06\08@102436 by DANNY ROWELL

flavicon
face
part 0 16 bytes
</x-html>

1999\06\08@104100 by Darren Logan

picon face
Im no expert, but i dont think you can achieve this simultaneous counting.
You an only count one pin at a time, this is easy.
Maybe you should use external logic counters for each input.
The program would look thus:

1) Reset all counters to zero
2) Enable counters (start counting)
3) After a fixed period, read the count value from each counter
4) Output the results (or whatever !)
5) Goto 1

Such logic chips are inexpensive so dont be affraid to use them.

Regards,
Darren

1999\06\08@191530 by Regulus Berdin

picon face
Darren Logan wrote:
>
> Im no expert, but i dont think you can achieve this simultaneous counting.

I think this can be done using vertical counters.  Check out Scott's
page on this topic:
http://www.interstice.com/~sdattalo/technical/software/pic/vertcnt.html

regards,
Reggie

--
e-mail: spam_OUTrberdinTakeThisOuTspambigfoot.com
ICQ#:   31651436
URL:    http://www.bigfoot.com/~rberdin

1999\06\08@194442 by Tony Nixon

flavicon
picon face
> DANNY ROWELL wrote:
>
> I AM TRYING TO PROGRAM AN ELECTRONIC PULSE COUNTING DEVICE WHICH CAN
> COUNT FROM UP TO 8 SIMULTANEOUS INPUTS. NEED TO COUNT DC NORMALLY LOW
> GOING HIGH AND DC NORMALLY HIGH GOING LOW. PULSES WILL APPEAR RANDOMLY
> ON ALL 8 INPUTS. DOES ANYONE HAVE ANY .ASM CODE THAT CAN HELP ME ??
> THANKS

Try this. I haven't tested it but it seems feasable.
The counters are only 8 bit, but can be changed easily.


MnLoop  ; Delay here if you want one

       movf portb,w            ; read portb pins
       movwf current           ; store current reading
       xorwf previous,w        ; test if any bits have changed since last
       btfsc status,z
       goto MnLoop             ; no

       andwf previous,w        ; bits that equal 1 now, indicate bits that
       movwf Temp              ; changed from 1 to 0
       btfss status,z          ; if all = 0 then none changed from 1 to 0
       call Bs2Zero            ; some did

       movf current,w          ; do test again
       xorwf previous,w
       andwf current,w         ; bits that equal 1 now, indicate bits that
       movwf Temp              ; changed from 0 to 1
       btfss status,z
       call Bs2One             ; some changed
       movf current,w          ; previous data becomes current data
       movwf previous
       goto MnLoop             ; none changed from 0 to 1

Bs2Zero clrf Offset             ; set offset for 1 to 0 bit counters
       goto AddUps

Bs2One  movlw 10h               ; set offset for 0 to 1 bit counters
       movwf Offset

AddUps  movlw 8h
       movwf Count

LoopAd  rrf Temp                ; increment appropriate counter if carry is set
       btfss status,carry
       goto NextBit

change  movf Offset,w
       addwf pcl
       incf HiToLo0            ; PB0 changed Hi to Lo, Inc counter
       goto NextBit
       incf HiToLo1            ; PB1 changed Hi to Lo, Inc counter
       goto NextBit
       incf HiToLo2            ; PB2 changed Hi to Lo, Inc counter
       goto NextBit
       incf HiToLo3            ; PB3 changed Hi to Lo, Inc counter
       goto NextBit
       incf HiToLo4            ; PB4 changed Hi to Lo, Inc counter
       goto NextBit
       incf HiToLo5            ; PB5 changed Hi to Lo, Inc counter
       goto NextBit
       incf HiToLo6            ; PB6 changed Hi to Lo, Inc counter
       goto NextBit
       incf HiToLo7            ; PB7 changed Hi to Lo, Inc counter
       goto NextBit

       incf LoToHi0            ; PB0 changed Lo to Hi, Inc counter
       goto NextBit
       incf LoToHi1            ; PB1 changed Lo to Hi, Inc counter
       goto NextBit
       incf LoToHi2            ; PB2 changed Lo to Hi, Inc counter
       goto NextBit
       incf LoToHi3            ; PB3 changed Lo to Hi, Inc counter
       goto NextBit
       incf LoToHi4            ; PB4 changed Lo to Hi, Inc counter
       goto NextBit
       incf LoToHi5            ; PB5 changed Lo to Hi, Inc counter
       goto NextBit
       incf LoToHi6            ; PB6 changed Lo to Hi, Inc counter
       goto NextBit
       incf LoToHi7            ; PB7 changed Lo to Hi, Inc counter

NextBit movlw 2h                ; set ready for next count register
       addwf Offset
       decfsz Count
       goto LoopAd             ; continue for all 8 bits
       return                  ; finished


--
Best regards

Tony

PicNPoke - Multimedia 16F84 Beginners PIC Tools.

http://www.picnpoke.com
Email .....picnpokeKILLspamspam@spam@cdi.com.au

1999\06\08@195956 by Tony Nixon

flavicon
picon face
Sorry about the length of the last post.

This will shorten the counter increment routine somewhat.

Bs2Zero movlw HiToLo0
       goto AddUps
Bs2On   movlw LoToHi0

AddUps  movwf fsr
       movlw 8h
       movwf Count

LoopAd  rrf Temp
       btfsc status,carry
       incf indirect
       incf fsr
       decfsz Count
       goto LoopAd
       return

--
Best regards

Tony

PicNPoke - Multimedia 16F84 Beginners PIC Tools.

http://www.picnpoke.com
Email picnpokespamKILLspamcdi.com.au

1999\06\08@203117 by Scott Dattalo

face
flavicon
face
On Wed, 9 Jun 1999, Tony Nixon wrote:

>
> > DANNY ROWELL wrote:
> >
> > I AM TRYING TO PROGRAM AN ELECTRONIC PULSE COUNTING DEVICE WHICH CAN
> > COUNT FROM UP TO 8 SIMULTANEOUS INPUTS. NEED TO COUNT DC NORMALLY LOW
> > GOING HIGH AND DC NORMALLY HIGH GOING LOW. PULSES WILL APPEAR RANDOMLY
> > ON ALL 8 INPUTS. DOES ANYONE HAVE ANY .ASM CODE THAT CAN HELP ME ??
> > THANKS
>
> Try this. I haven't tested it but it seems feasable.
> The counters are only 8 bit, but can be changed easily.
>

Kinda big Tony. I guess you didn't see the post yesterday (or did it not
make it?)

Two comments:

The xor trick works well for differentiating and replacing the old sample
with the new. Using your variables:

  movf  portb,w
  xorwf current,w
  movwf differences
  xorwf current,f


This section will compute the difference between the current and the
previous samples and store the results in 'differences'. In addition,
you can xor the differences with the current value and get the latest
sample. Redirecting this result to current (via the ,f) provides a very
simple and efficient way to store the new sample in place of the old.

To check for the low to high transitions is accomplished by:

  andwf current,W     ;Now W contains all of the low -> high deltas

And the high to low transitions (there is an error here in what I posted
yesterday, BTW):

  comf  current,W
  andwf differences,W ;Now W contains all of the high -> low deltas

Secondly:

The looping/table look up case can be unrolled. If there are no special
checks, then incrementing the 8 up-counters and 8 down-counters takes a
constant 32 cycles. A simple check similar to the one you use can avoid
wasted time if there are no changes:

  movf  portb,w
  xorwf current,w
  skpnz
   return
  movwf differences
  xorwf current,f

In other words, if there are no changes then only 5-cycles are required.


{Quote hidden}

1999\06\08@203501 by May Scott

flavicon
picon face
I presume that the inputs are on one port.
- Set up 8 counter variables, of the required size.
- read the port, save as old_port
- [loop back here] read the port
- XOR with old_port
- AND with the current port value
- any remaining 1's are where a pin went high
- simply AND with 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 and if
true, increment the respective counter
- copy the current port value to old_port
- loop back to [loop back here]

And Danny, please type in mixed case, all upcase is really hard on tired
eyes!

Till later,
Scott.
Û¼¡`¡¼Û¿,üü,¿Û¼¡`¡¼Û¿,üü,¿
Scott May.
EraseMEscott.mayspam_OUTspamTakeThisOuTdnr.qld.gov.au <scott.mayspamspam_OUTdnr.qld.gov.au>  
@spam@scottKILLspamspamsmartdata.com.au <KILLspamscottKILLspamspamsmartdata.com.au>
Û¼¡`¡¼Û¿,üü,¿Û¼¡`¡¼Û¿,üü,¿

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...