[sci.electronics] EVENT COUNTER

akcs.rick@vpnet.chi.il.us (fred salchli) (08/31/90)

I am a grad student working in neurophysiology, attempting to both
perform detailed data aquisition/analysis and streamline both as well. I
am currently researching mammalian circadian rhythms and am using
locomotor activity as an assay. Rodents are placed in cages with a
running wheel, the running wheel is coupled to a microswitch and the
signal is recorded on a strip chart recorder. This is not quantitative,
making statistical analysis difficult if not impossible, and also messy.
     
What I have been trying to do is build a computerized system. However, I
have not had much success building a circuit which will reliably latch
when the animal runs. What I want is a circuit that will latch (I have
tried various flip/flop configurations) until my I/O card reads it and
then resets it. I have also tried an edge detection chip, but continue to
have the same problem: If the switch is depressed the chip latches, but
if the switch is not released immedietly, the chip records another wheel
revolution when it finally is released. 

If anyone can help me with a design or a chip which can accurately
perform to my requirements I would be greatly indebted. Leafing through
application sheets has not yet yielded the right configuration, and if I
work my way through all of them I will get my PhD in 2025. Thanks!

P.S. I have thought about putting a delay in the aquisition software, but
in order to get the greatest revolution, I must sample at a rate of at
least 5Hz. 

corey@verdix.com (Corey Ashford) (08/31/90)

In article <26dd5749-39csci.electronics@vpnet.chi.il.us>
akcs.rick@vpnet.chi.il.us (fred salchli) writes:
... some stuff ...
>when the animal runs. What I want is a circuit that will latch (I have
>tried various flip/flop configurations) until my I/O card reads it and
>then resets it. I have also tried an edge detection chip, but continue to
>have the same problem: If the switch is depressed the chip latches, but
>if the switch is not released immedietly, the chip records another wheel
>revolution when it finally is released. 

Sounds like the microswitch is bouncing when it opens.  A simple debounce
circuit like the following should help.

                     +5V
                      |
                      /10k
                      \
               /      /   |\ CMOS Schmitt trigger inverter 4584
      +------@/ @-----@---| >o-----------------------------------> out
      |               |   |/
      |   microsw     |
      |              ---
      |              --- 1 uF
      |               |
      |		      |
     Gnd             Gnd


The output will stay high as long as the switch is closed and will go
low about 10ms after the switch opens.

- Corey

cgordon@vpnet.chi.il.us (Gordon Hlavenka) (09/01/90)

>... Rodents are placed in cages with a
>running wheel, the running wheel is coupled to a microswitch...

>... What I want is a circuit that will latch (I have
>tried various flip/flop configurations) until my I/O card reads it and
>then resets it.

What exactly are you trying to do?  If you're after a count of wheel
revolutions, I would suggest you try an optical solution.  The metal running
wheels with which I'm familiar have a single crosspiece on each side for
support.  By positioning a photodetector properly, one could simply count
optical occlusions and divide by two to get wheel revolutions.  Obviously,
it would be important to arrange the optical path so as to minimize
interference from non-wheel-related activities of the rodents.

It should not be difficult to interface this type of circuit to the printer
port of a PC and sample the input at a rate far in excess of 5 Hz, so that
latching would be unnecessary.  If your hardware configuration precludes
this, you might consider a microcontroller such as the 8749.  These are
quite inexpensive, entirely self-contained, and easily programmable.  The
8751 even includes a built-in serial port.

-----------------------------------------------------
Gordon S. Hlavenka            cgordon@vpnet.chi.il.us
Disclaimer:                Yeah, I said it.  So what?

akcs.rick@vpnet.chi.il.us (fred salchli) (09/01/90)

More info about my problem . . . . . . .  .
      I'm attempting to build a BIG system, 144 or more channels and
building optical sensors would involve rewiring our facilities, and
refitting all our cages. A circuit which could clean or ignore the noisy
signal from the microswitch seems to be the easiest out. I'm open to any
and all ideas.

wb8foz@mthvax.cs.miami.edu (David Lesher) (09/01/90)

[needed debouncing, if I understood correctly]

I built some special IO boards for a DEC Falcon {a micro-PDP-11 beast}
that had to debounce switch inputs. I used a 16 pin dip hex debouncer.
I *think* it was a 14490, or 14409, but it's been a while;-}

In any case, its law was simple: For the output to go up, the input had
to go up and stay up for 5 periods. To then go low again, it had to go
low and stay low, etc. You set the period of the internal clock with a
cap I recall. There was WIDE variation in periods available -- maybe
large us to several seconds.

It worked well for me on several hundred boards with 8 per board. But I
should mention that another designer cursed it roundly, as he never had
any luck with it.
-- 
A host is a host from coast to coast.....wb8foz@mthvax.cs.miami.edu 
& no one will talk to a host that's close............(305) 255-RTFM
Unless the host (that isn't close)......................pob 570-335
is busy, hung or dead....................................33257-0335

whit@milton.u.washington.edu (John Whitmore) (09/02/90)

In article <26ded58a-39c.2sci.electronics-1@vpnet.chi.il.us> akcs.rick@vpnet.chi.il.us (fred salchli) writes:
>More info about my problem . . . . . . .  .
>      I'm attempting to build a BIG system, 144 or more channels and
>building optical sensors would involve rewiring our facilities, and
>refitting all our cages. A circuit which could clean or ignore the noisy
>signal from the microswitch seems to be the easiest out.
	(relating to multiple counters running slowly; less than 10 Hz)

	Firstly, a microswitch has NO and NC contacts; an S/R flipflop
can be connected with SET on 'NO' and RESET on 'NC' and there will be
no bounce in the flipflop's output.  This, however, adds a third wire
to the switch connections.
	How about getting a large parallel port (boards with 144 inputs
are probably not feasible, but three PC plugin boards with 64 circuits 
each would be suitable) and just strobing them in software?  With a 
60 Hz clock, add to a (software) counter every time a switch goes high
for at least two consecutive cycles after being low for at least two cycles.
	The PC could even do something else in its spare time, if the
clock were connected in interrupt fashion.

I am known for my brilliance,             John Whitmore
 by those who do not know me well.