CT515 Counter-debouncher from Emesystems
Moskog
Posts: 554
Hi, while reading through Tracy Allen's environment-pages I found this chip for counting/debounching. This chip sounds very interesting for me who is frequently dealing with counters, anemometers, switches and other related devices. I understand it an handle up to five counters while occupying only one microcontroller pin. So, my question now is where can I get this chip, does emesystems still make and sell them and how much will I need to pay for a handfull of them? Does it exist a "getting started-code" i Spin for this chip?
Comments
I developed that originally for a customer who needed to monitor flow meters with a BASIC Stamp, for irrigation. At the time the flow meters often had big reed relays with lots of bounce. We also wanted to throw in a rain gage and anemometer, both with reed relays too. Keeping track of multiple asynchronous bouncy inputs along with ADC and other tasks tasks along with micro-power is not a task well suited to the Stamp. The debounce circuits I saw commercially available did not quite fit the bill. Enter the CT515. As Mike surmised, it is an 8-pin PIC chip running my proprietary firmware, which is a state machine keyed to the wake-on-change interrupt. The interface is simple 9600 baud serial, TTL level. The Stamp (or Prop) brings the data pin low for 10 milliseconds, and when it releases that pin (open drain), the CT515 responds with a string of 12 bytes that includes the current state of each pin as well as the accumulated 16-bit count for each of the 5 channels, and then the counts are reset to zero. I've incorporated the CT515 in breakout boards for my OWL2pe data loggers ever since. Not on the Propeller boards though, because it can devote a cog to the same purpose. Even so, there would be good reasons to offload the task, to save pins or code space, or to provide a level of isolation.
Originally the maximum input frequency was limited to 100Hz, but now that those big slow reed relays are a thing of the past, I field requests for flow meters that have higher resolution, clean hall effect or optical switches, and output up to 400 or 500 Hz.
I do have the chip available as a separate item. Sorry, I don't have an shopping cart on line, but can take orders via email, and payment by paypal and by the usual means. The price page is here.
Program so far is as follows:
The program is supposed to be based on the BS2pe example in the datasheet, using the SPSTR formatter and wait for the $80 startbyte. But there is something wrong here,it doesn't seem to work like I wanted. And I'm too blind to be able to see the problem!
I like the resonance of the new word debounche/debaunche. That has panache, to wit, to eradicate a more serious rodent than a dull debounce!
The thing that strikes me about the code is that the serial output of the CT515 is non-inverted, but in your Spin implementation of the serial input, I think you have it as inverted. I'm not sure, I'll have to take a closer look.
The start edge should be a high to low transition.
Yes, the inverted was set to true, I corrected that and also found some errors in the calculate-pub, and then did a few changes to the receive-pub. Now it seems to work. I get the same output as in one of the debug-screens of your original basic stamp code. I still see things could have been done more smoothly but will correct that when integrating with the main project. Most important is that it works the way I want.
Here is a scrennshot of the updated code:
Thanks again!
The first character in the response from the CT515 is an ascii $80. The program measures the width of that pulse (8 bit-times low) and uses it to autobaud the rest of the communication. (That way of implementing autobaud was expedient with the BASIC Stamp.) The PIC675 is set for a nominal baud rate of 9600. However, it is running on its RC clock. While temperature compensated, the TickTimer method tracks it for applications that might be out in extremes of temperature.
I implemented the debounce algorithm on the PIC as a vertical counter. It operates in parallel on all 6 input pins, and the debounced signals are followed by the event counters for each channel. I think when I first started with this, I was looking at commercial hex debouncers like the MC14490. Or maybe it was a Maxim chip. But they didn't include the event counters, so doing it on a PIC with a unified serial interface to the Stamp made sense.
I also have a version of the CT515 program that uses fullDuplexSerial4port. It measures the CT515 baud rate, which may come out slightly more or less than 9600, and uses that when it starts the ports. The RxTime(port, timeout) method subsequently takes care of the timeouts.
Dave