1

I'm trying to figure out how to read-in a configuration to the small ATtiny10 microcontroller. I want to find out 5 or 6 different configurations, adjustable by hardware into one IO using the same firmware to make settings in the program. At the moment there are 3 DIP-switches used for this, and as you expect we need full 3 IOs. This corresponds to 8 different configurations. Can this be reduced to only using one IO? So I can switch over to an ATtiny10...

Of course I could also use the internal ADC and attach a voltage divider. Maybe it could also be purely digital. Internal Pull-Up (software switchable) has according to data sheet 20 kΩ to 50 kΩ. I come up with different possibilities to use an IO as configuration input:

  • (a) Pull-Up (high impedance) e.g. 470kΩ to VCC/VDD,
  • (b) Pull-Down (high impedance) e.g. 470kΩ to GND/VSS,
  • (c) Pull-Down (low impedance) e.g. 1kΩ to GND/VSS, if the internal pull-up resistor is on, it will be overridden during a read-in with internal pull-up set,
  • (d) Using an RC-element, see schematics,
  • (e) RC-element using another configuration.

schematic

simulate this circuit – Schematic created using CircuitLab

My idea and procedure (for instance):

  1. Set IO to input, internal pull-up on, wait a minimum of 500 ms,
  2. Read input: High on a), b), d), e) ; LOW on c) -> case (c) detected;
  3. Internal pull-up off, no wait;
  4. Read input: High on a) d) e) ; LOW on b) c) -> case (b) detected;
  5. Wait 1 ms,
  6. Read input: High on a) e) ; LOW on b) c) d) -> case (d) detected;
  7. Wait 500 ms,
  8. Read input: High on a) ; LOW on b) c) d) e) -> case (e) detected; and case (a) also detected.
  9. If d) or e) was detected set output pin to GND, else keep it as input.

In these cases, I therefore only need to mount two components on the circuit board in three designated places: (a) 0R + 470k (b) 0R + 470k (c) 0R + 1k (d) 100k + 1n (e) 470k + 100n; with all the same component size (e.g. 0603)

I hope that you can support me with further ideas?

Tom Kuschel
  • 501
  • 2
  • 11
  • 1
    ADC is probably best or a single UART RX line that you can send a serial message to from the PC. You can remember the setting in MCU FLASH or EEPROM – DKNguyen Feb 09 '20 at 22:53
  • @Tom - Your question of "reading multiple configuration settings using just one GPIO pin" (my summary) seems quite similar to the underlying question in this previous topic: "[Add a passive hardware token using a 3.5mm jack](https://electronics.stackexchange.com/q/472783/101852)". Even if you don't choose the same as the "accepted" answer there (1-Wire), you might find the approaches in the other answers useful too. I have not voted for yours as a duplicate of that one, but you might decide that it is, if the answers there are close enough to what you want. See what you think. – SamGibson Feb 09 '20 at 23:13
  • @SamGibson It's a nice idea to use a 1-wire device for programming, but not my intention for this question. Thank you very much for your good feedback Sam! – Tom Kuschel Feb 10 '20 at 17:24
  • @Tom - "*It's a nice idea to use a 1-wire device for programming*" Understood (I thought that wasn't a great "fit" for your case), but other answers include some details about how to implement RC networks, which may help with your other suggestions. So please don't focus on the 1-Wire answer to that question - I was deliberately trying to point towards the *other* answers. Anyway, good luck Tom! – SamGibson Feb 10 '20 at 17:32

0 Answers0