Skip to main content
added 137 characters in body
Source Link
Nick Bolton
  • 2.1k
  • 12
  • 41

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

SoThinking out loud, possibly rambling: I figured maybe I'd build a latch using the humble transistor. Then, I thought maybe I could simplify the circuit or at least reduce it's scale, by using a transistor array IC... then I wondered if maybeuse a latch IC or a flip flop would be better/simpler. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either.

  It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. Is this the case? If so, latch ICs are less common than flipflops and I actually have plenty of flipflop ICs already... so why not use a flipflop? If a flipflop is the best option, does it matter if D or JK? Or positive/native edge? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Edit: Seems the toggle can also be done with a timer IC.

Edit 2: Can't believe I forgot to mention this, but I'm using the PCF8574.

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

So, I figured maybe I'd build a latch using the humble transistor. Then, I thought maybe I could simplify the circuit or at least reduce it's scale, by using a transistor array IC... then I wondered if maybe a latch IC or a flip flop would be better/simpler. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either.

  It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. Is this the case? If so, latch ICs are less common than flipflops and I actually have plenty of flipflop ICs already... so why not use a flipflop? If a flipflop is the best option, does it matter if D or JK? Or positive/native edge? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Edit: Seems the toggle can also be done with a timer IC.

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

Thinking out loud, possibly rambling: I figured maybe I'd use a latch. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either. It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. If a flipflop is the best option, does it matter if D or JK? Or positive/native edge? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Edit: Seems the toggle can also be done with a timer IC.

Edit 2: Can't believe I forgot to mention this, but I'm using the PCF8574.

added 86 characters in body
Source Link
Nick Bolton
  • 2.1k
  • 12
  • 41

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

So, I figured maybe I'd build a latch using the humble transistor. Then, I thought maybe I could simplify the circuit or at least reduce it's scale, by using a transistor array IC... then I wondered if maybe a latch IC or a flip flop would be better/simpler. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either.

It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. Is this the case? If so, latch ICs are less common than flipflops and I actually have plenty of flipflop ICs already... so why not use a flipflop? If a flipflop is the best option, does it matter if D or JK? Or positive/native edge? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Edit: Seems the toggle can also be done with a timer IC.

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

So, I figured maybe I'd build a latch using the humble transistor. Then, I thought maybe I could simplify the circuit or at least reduce it's scale, by using a transistor array IC... then I wondered if maybe a latch IC or a flip flop would be better/simpler. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either.

It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. Is this the case? If so, latch ICs are less common than flipflops and I actually have plenty of flipflop ICs already... so why not use a flipflop? If a flipflop is the best option, does it matter if D or JK? Or positive/native edge? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

So, I figured maybe I'd build a latch using the humble transistor. Then, I thought maybe I could simplify the circuit or at least reduce it's scale, by using a transistor array IC... then I wondered if maybe a latch IC or a flip flop would be better/simpler. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either.

It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. Is this the case? If so, latch ICs are less common than flipflops and I actually have plenty of flipflop ICs already... so why not use a flipflop? If a flipflop is the best option, does it matter if D or JK? Or positive/native edge? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Edit: Seems the toggle can also be done with a timer IC.

added 86 characters in body
Source Link
Nick Bolton
  • 2.1k
  • 12
  • 41

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

So, I figured maybe I'd build a latch using the humble transistor. Then, I thought maybe I could simplify the circuit or at least reduce it's scale, by using a transistor array IC... then I wondered if maybe a latch IC or a flip flop would be better/simpler. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either.

It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. Is this the case? If so, latch ICs are less common than flipflops and I actually have plenty of flipflop ICs already... so why not use a flipflop? If a flipflop is the best option, does it matter if D or JK? Or positive/native edge? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

So, I figured maybe I'd build a latch using the humble transistor. Then, I thought maybe I could simplify the circuit or at least reduce it's scale, by using a transistor array IC... then I wondered if maybe a latch IC or a flip flop would be better/simpler. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either.

It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. Is this the case? If so, latch ICs are less common than flipflops and I actually have plenty of flipflop ICs already... so why not use a flipflop? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Currently, I have a few buttons connected via an I2C shift register, hooked up to an MCU. Super simple, so not sure if it needs a schematic, but I can share one (and any other details) if needed. I'm flexible with what MCU I can use, suggestions welcome.

The MCU checks the button state every n ms. The problem is that if the user presses the push button too quickly, between the MCU loop function, the button press is not detected. One temporary solution is to increase the loop speed, but this isn't super energy efficient, and only diminishes the problem. Even with a faster loop, it's still possible to miss the pulse from the button press if pressed quickly enough, since the MCU has it's speed limitations, especially if it's doing some intense operation then the loop delay is increased unpredictably.

So, I figured maybe I'd build a latch using the humble transistor. Then, I thought maybe I could simplify the circuit or at least reduce it's scale, by using a transistor array IC... then I wondered if maybe a latch IC or a flip flop would be better/simpler. I suspect there is a way of getting a good balance between hardware and firmware without over-complicating either.

It seems to me that if I want to use a push button for a simple toggle switch, it's simpler to use a latch rather than a flipflop. Is this the case? If so, latch ICs are less common than flipflops and I actually have plenty of flipflop ICs already... so why not use a flipflop? If a flipflop is the best option, does it matter if D or JK? Or positive/native edge? Or, is there a way to avoid using a flipflop altogether and let the MCU do the work?

Source Link
Nick Bolton
  • 2.1k
  • 12
  • 41
Loading