1

I am using a "Dual 16-bit binary counter with 3-state output registers" (SN74LV8154) to count input pulses up to 32 bits.

It is working fine most of the time, but some of the bits in the counter seem to flip randomly. The result is reflected in the register, as I see the output value sometimes jump forward and/or backward.

Jumps are persistent (not punctual misreadings) since the value does not jump the other way around right after the issue. e.g.

  1. 0x12fe
  2. 0x12ff
  3. 0x1200 (should be 0x1300)
  4. 0x1201
  5. 0x1202 (0x0100 still not on)

The chip allows to read byte by byte with the help of a 4 bit word selector. This is done quite frequently, word by word, and I record a timeseries with the result. I expect the counter to go up by a few increments between reads.

The result is fine most of the time, but it looks like some internal carries are either forgotten or doubled.

Here are a few examples:

|----------------------+------------------------+-------------|
| Before               | After                  | Jump        |
|                      | (Expected)             |             |
|----------------------+------------------------+-------------|
| 0b010011000011111111 |  0b010011001000000000  | 0b100000000 |
|                      | (0b010011000100000000) |             |
| 0b110001000001111111 |  0b110001000000000000  | -0b10000000 |
|                      | (0b110001000010000000) |             |
| 0b111100101011111111 |  0b111100110000000000  | 0b100000000 |
|                      | (0b111100101100000000) |             |
|----------------------+------------------------+-------------|

I also saw jumps by +/- 16, +/- 32, +/-65536, so I guess the issue is not related to the word size.

Any help on how to investigate this would be much appreciated.

Julien

  • 2
    Does your circuit have bypass capacitors across the power supply of the chip? What is the source of the input pulses? If it is an electromechanical switch, did you debounce the signal? – The Photon Nov 04 '15 at 01:25
  • 1
    No bypass capacitor (I come from the software world, am a real beginner in electronics, and did not even know about these... :s I am looking into it now). As for the input, it comes from a photo interrupter. – Julien Vivenot Nov 04 '15 at 01:49
  • 1
    Another thing to note: I am still prototyping on a breadboard. Could it cause any issue ? – Julien Vivenot Nov 04 '15 at 01:51
  • 2
    On a prototype board, the bypass capacitor is even more important. – The Photon Nov 04 '15 at 02:19
  • 1
    Given the pattern of errors (occurring when a large number of output bits change), the bypass issue is more likely the root cause than input debouncing. But they're both things that are easy to forget to do on your first few designs (until they bite you on the ass once each). – The Photon Nov 04 '15 at 02:20
  • Can you show us your circuit? –  Nov 04 '15 at 03:54
  • How are you reading those bits? is it an interface voltage level incompatibility issue? – Icy Nov 04 '15 at 11:49
  • @duskwuff I'll try bypass capacitors tonight and show you the circuit if this does not work – Julien Vivenot Nov 04 '15 at 13:21
  • @Icy I am reading them from a raspberry pi through a port expander. Given the continuity of the results most of the time, I do not think this comes from a voltage level issue (the carry issue happens roughly in less 1/10000th of ticks). – Julien Vivenot Nov 04 '15 at 13:23
  • 1
    I'm not entirely convinced. Check the VOut (high) min value of your logic gate against the VIn (high) min value of your port expander, you are able to read 'high's more accurately when lots of other bits are also outputting 'high' – Icy Nov 04 '15 at 13:36
  • So... I actually had two issues. First, what I thought was just a standalone photointerrupter was actually still connected as an input to another external circuit. Some interferences came from this. When using it standalone, I was left with some unwanted behaviour. They were fixed by the addition of bypass capacitors. Thanks @ThePhoton. – Julien Vivenot Nov 09 '15 at 11:27
  • @Icy, the counter and port expander were compatible, as per their respective datasheets (Counter's VOut high min roughly 0.85vcc, while Port expander's VIn high min 0.8vcc). – Julien Vivenot Nov 09 '15 at 11:28
  • @ThePhoton Do you want to make your comment an answer, so that I can accept it? – Julien Vivenot Nov 09 '15 at 11:28

1 Answers1

0

Thanks @ThePhoton and @Icy for your comments, which helped me fix the issue.

As suspected by @ThePhoton, the issue was the lack of bypass capacitors across the counter's power supply. The issue was especially occurring when several register bits were switching as the same time.