Maker Pro
Maker Pro

Help with time counter for wildlife research

Z

zebeste

Jan 1, 1970
0
Background: I'm a wildlife biologist with a background in computer programming. I also had some basic EE experience and digital logic experience when I first started in college, but what skills I had have degraded significantly over the last 8-9 years. Basically, I'm not helpless when reading simple schematics and datasheets; I can usually figure out from a high level what a circuit is supposed to do, and given enough time, can trace through individual components and pins to figure out how everything works from from a low level standpoint. Where I fail is actually designing the details of a circuit from the ground up, especially figuring out the placement of resistors, capacitors, etc, and their respective values.

The project: I do small mammal trapping involving large grids of traps. I want to attach to our traps a circuit that activates when the trap door closes and keeps track of how long it has been closed. When we arrive at the trap, we can record the time from a 7-segment display along with the current time, which allows us to determine the time at which the trap closed. This information potentially has several uses for me.

Parameters: I'd like to have it be able to run for 24 hours using rechargeable batteries. Ideally the clock would be set to increment the counter every minute, but a 5 minute interval would be acceptable if the cost savings is significant enough. I'm aiming for a $10 budget, which seems reasonable given the prices I've been able to find on digikey for things like clocks and timers. Ideally though, $5 would be awesome. The reason being that I'm aiming to make at least 10 of these things, hopefully 50-100.

What I have so far:
IMG_20150327_170949538.jpg

It's very crude and high level, but I think it'll work. Basically, to be able to count minutes for 24hrs should require a 12-bit counter, and a 4 digit display. If I go with 5 minutes, an 8-bit counter and 3 digit display will work. But as I mentioned above, the 5 minute option is only if the cost savings is significant, which I don't think it will be.

Basically, to cut down cost, I was thinking of separating the display driver and 7-segment display into a separate module because I only really need one or two. Depends on how expensive the connector will be. But it also has the added benefit that the driver and display will only draw power when we need to read it. When I first started looking for ideas, I came across the 4-digit counter and display driver with multiplexers, but at around $10 a pop, I feel like my way might be cheaper.

At the beginning of the circuit is my attempt at a latch that once activated will keep the circuit running until the power is turned off. This design choice has to do with the nature of field trapping not being a controlled environment and minimizing potential problematic situations.


So, does the overall design seem feasible? or does someone have a better (cost effective) solution? If it's good, I would really appreciate help with getting the schematic finalized.

Thanks.
 

davenn

Moderator
Sep 5, 2009
14,264
Joined
Sep 5, 2009
Messages
14,264
you seem to be doing it the difficult way and probably more expensive in the long run

How about just getting some commercial clock units that also have a built in stopwatch ?
I haven't looked specifically but surely there's those that would count over 24 hrs


Dave
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,886
Joined
Jun 21, 2012
Messages
4,886
Here is a $51 timer that is powered with a lithium-ion battery, said to be good for ten years. A simple contact closure starts or stops the timer. Readout on LCD display in hours and minutes. See attached PDF for full specifications. Or perhaps you could hack a cheap kitchen timer to add an external start switch.
 

Attachments

  • KAL-DTime_DS_990067.pdf
    299 KB · Views: 107

Laplace

Apr 4, 2010
1,252
Joined
Apr 4, 2010
Messages
1,252
...with a background in computer programming.
If you don't find any commercial timer that can be adapted for this purpose, then it seems an ideal project for a small one-chip micro-controller with crystal oscillator for an accurate timebase and with an integral flash ROM. Seems like a single-function timer should fit in 2-KByte of assembler code. But do not use any sort of external contact that would be fouled by the dirt and moisture of the Great Outdoors. For reading the output use a contactless pickup triggered by a sealed pushbutton to transmit a FSK modulated tone (like very old modems) from a small coil out through the sealed plastic case. The reader would use a coil to pickup and demodulate the timecode and unit ID. It could even be attached to a portable PC or Android for fully automated recording. There would be very little hardware involved - it's mostly software.
 
Z

zebeste

Jan 1, 1970
0
Finding something like a kitchen might be the easiest way to go (assuming I can find one that isn't just minutes and seconds). But even then, I still have to implement something so that once it starts, it can't be stopped until power is removed. The other thing is finding a timer that can operate with rechargeable batteries.

But really, this is an idea I had for a side project. It isn't something that has to happen, just something that I think has value from a research perspective, and worth trying. For me, part of the fun is getting to build and play with the circuit, and the prototype is something I'm willing to spend my own money on. If it happens to work, and is reasonably cheap, I might be able to get some of the excess research funds diverted to build more, or I might be able to get a small grant for a few hundred dollars from somewhere to build some. If it doesn't work out like I hope, at least I learn something in the process. My programming and computer skills already give me a huge advantage that most people in my field don't have, and learning to understand and build circuits gives me another advantage, and gives me more freedom to be creative when working on and designing research projects. I have other ideas, but want to start with something simple like this.

Now with that said, I've been reading that there can be accuracy issues with the 555 and different temperatures. So instead, I found one site that uses a crystal oscillator with a series of flip-flops to step down the frequency. It looks simple enough and inexpensive, so would it be a better route?

If you don't find any commercial timer that can be adapted for this purpose, then it seems an ideal project for a small one-chip micro-controller with crystal oscillator for an accurate timebase and with an integral flash ROM. Seems like a single-function timer should fit in 2-KByte of assembler code. But do not use any sort of external contact that would be fouled by the dirt and moisture of the Great Outdoors. For reading the output use a contactless pickup triggered by a sealed pushbutton to transmit a FSK modulated tone (like very old modems) from a small coil out through the sealed plastic case. The reader would use a coil to pickup and demodulate the timecode and unit ID. It could even be attached to a portable PC or Android for fully automated recording. There would be very little hardware involved - it's mostly software.

I really like this idea, but would definitely need help with it. I don't have a lot of time to look at them thoroughly at the moment, but it looks like a microcontroller that does what I need could cost less than a couple dollars? If so, I do have some familiarity with assembler, and I've already written an Android app that we use for our data collection. Integrating the two would be really fun.
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,886
Joined
Jun 21, 2012
Messages
4,886
... I've already written an Android app that we use for our data collection. Integrating the two would be really fun.
I like your attitude! And it appears you have made some progress with electronics since your previous thread several years ago. The technology available today is truly amazing, and easily accessible to the DIY amateur. Component costs are minimal (a few cents for many microprocessors) and printed circuit boards (PCBs) are both easily designed, using free or low cost software, and manufactured inexpensively by both on-shore and Asian manufacturers at very low cost.

So, my advice is... go for it! As @Laplace mentioned, a crystal-controlled oscillator and a microprocessor are the minimum (and almost the maximum!) elements you need. However, the first step is to come up with a set of performance specifications that try to anticipate the actual use environment. These "specs" will guide the actual design, but nothing is cast in concrete until a final hardware prototype exists. Even then, experience in the field may reveal the need for changes or additions to the prototype design. This is where the low cost and program-ability of modern microprocessors is a huge cost advantage.

You have no doubt discovered the plethora of inexpensive digital clocks and timers with liquid crystal displays (LCDs) available. Virtually all of these use a small silver-oxide or lithium ion cell for power. The cell is not re-chargeable, but it is inexpensive, easily replaced, and will operate a simple clock with an LCD display for at least a year. Low-power microprocessors with similar miniscule power consumption are available to implement a count-up timer for your application. For a DIY project you are free to substitute one or more rechargeable cells in lieu of disposable cells. Your choice.

There is a potential problem with "hacking" a commercial up-counting clock timer, such as this one. Even if you can get the case apart to solder a pair of wires in parallel with an existing "START" button, and this button doesn't also have other functionality that might interfere with accumulating a total interval count, there is no guarantee that the product will continue to be available. That can be a huge "gotcha" if you anticipate a continuing need but don't have the budget to make a "lifetime" purchase of a few hundred or a few thousand units. So, again, a DIY version using sustainable parts is a preferred alternative.

Your idea of using a detachable display readout has merit. Although LCD displays are inexpensive, there is probably a significant cost advantage to not including one with every count-up timer, especially if you anticipate eventually deploying several hundred timers. OTOH, you may be able to offer your DIY timer for sale to others in onesie-twosie quantities, and those will certainly require a digital display of elapsed time. It's a design consideration.

You didn't mention how the trap door closing would start the timer. Obviously some sort of switch, actuated by the closing trap door, should start the timer. However, mechanical switches can have mechanical reliability problems and also exhibit contact bounce which must be ignored. A preferred switch would be a magnetically actuated, glass-encapsulated, reed switch. Most of these are normally open until closed by a nearby magnetic field. A small permanent magnet attached to the trap door mechanism would keep the reed switch closed as long as the trap door is open.

An important design decision is the selection of a microcontroller for your count-up timer. Perhaps the most simplest, with a "sleep" capability to conserve power consumption, is best. But you should also consider the learning curve you must climb to learn how to program the chosen device in C or assembly. Although I have no experience with them (yet) the Microchip PIC10F200 series is popular and it's available in a 6-pin SMT package. See this thread for an interesting discussion on their use and programming for a "simple" switching application.

If you decide to proceed down this road, there are a lot of people here who will help you succeed in your project. All we ask is that you do the due diligence research and most of the grunt work. This does sound like a fun project that should be well within your capabilities. I happen to be busy with Arduino projects at the moment, but I will chime in if no one else picks up this thread and runs with it.

73 de AC8NS
Hop
 
Z

zebeste

Jan 1, 1970
0
So, life keeps me busy, but I managed to read through the data sheet for the PIC10F200 yesterday and for the most part it looks pretty straightforward. I drew up a quick sketch as a starting point to show roughly how I think this will work:
IMG_20150408_111631476.jpg

Basically the pins are as follows:
1: An input pin driven by a push button switch. Holding it down will cause the data to be output to pin 4, and also activate the status LED via pin 3.
2: Vss
3: An output pin that activates the status LED. I only looke briefly at the current specifications of the pin, but I think I might be able to get away without using a transistor and driving the led directly from the pin.
4: An output pin for data. I haven't decided yet how this will work; something like a wireless signal mentioned previously would be really convenient, but another option could be using a 3.5mm headphone connector to output to the headphone port of an android device. I'm leaving the details of this until I get the rest of the circuit finalized.
5. Vdd
6. An input pin that is activated by a reed switch as was suggested previously. Once the magnet is removed, the switch will activate and wake the microcontroller from sleep and start the counter.

I've also started planning the control logic, and it'll run something like this:
1. On start, activate the status LED briefly to indicate the device is on.
2. Check the input on pin 6. As long as the switch is active, indicate it with the status LED, and wait until the reed switch is opened with the magnet.
3. When the reed switch is opened (i.e., the trap door is open), turn off the LED and put the device to sleep.
4. When the magnet is removed from the reed switch by the the trap closing, the reed switch will activate, waking the device and starting the counter. I might have the status LED blink occasionally to indicate it is working
5. If the button on pin 1 is pressed, for as long as it remains pressed, keep the LED on and output the data to pin 4

I might also make use of the watchdog timer to periodically wake the device and increment a counter that lets me know roughly when the device was last reset or started.

What I need help with now is figuring out what I might be missing in the schematic in terms of resistors, capacitors, etc. I was reading up on bypass capacitors this morning, so I put one in, but I don't know if it's quite the proper position, or if I should have others. And figuring out if I need to use a transistor with LED, or if I can drive it straight from the pin.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Yes, you can drive an LED, up to 20mA directly from a PIC pin.

I would switch to the PIC10F322. It is only a few cents more, has the same pinout and more memory and capabilities, and is easier to program.

Edit:

The bypass cap is correct and should go as close as possible to the power pins.

The switches should be between the input and ground, not V+. That is because there is an internal pullup which will make the pin appear high until grounded. It will not work they way you have it.


Bob
 

KTW

Feb 22, 2015
273
Joined
Feb 22, 2015
Messages
273
I may have missed something but can't you take a $5, 24 hour kids watch, have the contacts on the door disconnect the battery to stop the watch and then count back?
 
Top