14
\$\begingroup\$

I need to encode information about either version or configuration on the board/electrically, so the firmware can detect which board layout is used.

What options are possible and what are their pro/cons?

\$\endgroup\$
1

4 Answers 4

15
\$\begingroup\$

Off the top of my head, two easy solutions come to mind.

  1. Have n lines attached to the GPIO of your microcontroller. Tie these high or low depending on your board version. This would give you \$2^n\$ board configuration options. This would use n pins on your microcontroller. Static current draw would be negligible.
  2. Have an input to the microcontroller's ADC and use a voltage divider with different values depending on the board configuration. This would only use a single microcontroller pin. This has the disadvantage that there will be static current draw through the divider. It would also be prone to BOM errors, while the first suggestion is hard wired to the board.

Both of these suggestions do have a weakness in that the end user could easily alter them, say to open up "locked" features. This may not be a concern for you, but something to bear in mind.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ There is also a combination of [1] and [2]. You can use one pin of microcontroller for ADC, but use same value component connected in parallel to form a voltage divider. So for example you can have four 10k resistors forming 10k/float (pull to vcc), float/10k(pull to gnd), 10k/10k(vcc/2), 5k/10k(2/3 of vcc), 10k/5k (1/3 of vcc). So in short: one line in the BOM, just different quantity and one ADC input required. It also helps visually. \$\endgroup\$
    – Tomas D.
    May 1, 2018 at 19:51
  • 2
    \$\begingroup\$ You can get rid of the static current draw of the ADC solution if you can spare a second pin: Instead of a voltage divider between VCC and GND, replace either VCC or GND with the second pin - you only need to read the board configuration once, at the start of the program, so set the pin high/low as required to enable the voltage divider, do the ADC measurement, then toggle the pin so that both ends of the voltage divider are at the same potential and no current flows. \$\endgroup\$ May 2, 2018 at 5:44
  • 1
    \$\begingroup\$ The GPIO version is also prone to BOM errors, because typically this is configured with zero ohm links. You could do it in the schematic and layout, but that is more expensive (layout time costs). \$\endgroup\$
    – Graham
    May 2, 2018 at 9:31
  • 1
    \$\begingroup\$ Re the ADC, this is what we've used on products where I currently work. You do have to be careful with resistor tolerances though. If your two resistors are 1% tolerance, the voltage can be up to 2% out, so at most you get 50 steps you can resolve. In practise it's safer to halve that. So if you have 1% resistors and a 5V range on your ADC, you want versions to be reported in 0.2V steps. \$\endgroup\$
    – Graham
    May 2, 2018 at 9:42
10
\$\begingroup\$

I have used a shift register with pins tied high and low to encode board revision before now, if you're already using SPI for something on your board it's trivial to read it.

If you need to be able to change ID at run time then using jumpers rather than tying the inputs with traces would be a good idea.

\$\endgroup\$
4
  • \$\begingroup\$ I was googling for non-unique silicon serial number variant IC's, but this is a smart alternative. Especially if you combine it with a single wire IO expander. \$\endgroup\$
    – Jeroen3
    May 1, 2018 at 11:17
  • \$\begingroup\$ How do you load the version data into the shift register? \$\endgroup\$
    – Travis
    Oct 24, 2020 at 5:15
  • 1
    \$\begingroup\$ If you use a 74xx165 (or similar parallel in register) you can wire its inputs to Vdd and Vss to set what you get when you clock data out \$\endgroup\$
    – Colin
    Oct 24, 2020 at 7:15
  • 1
    \$\begingroup\$ Ah, got it. So you hard-wire the parallel inputs, connect serial output to a GPIO pin, and then need some way to drive the clock and reset pins (likely also GPIO in my case). I'm using a Raspberry PI to control various relays, so I would need to dedicate ~3 GPIO pins to versioning. If I think I'll have more than 4 versions, this would be a good way to go. \$\endgroup\$
    – Travis
    Oct 26, 2020 at 16:55
7
\$\begingroup\$

Some options I can think of:-

SMD PADS/ O OHM Resistor Links. Use a binary system for hardware configuration to reduce pin count for your processor.

Jumpers. The board would 2xN connector pins adding a jumper to the right pin would let you select your configuration. A mistake is easier to resolve. This maybe a little costly and use more board space depending on jumper.

If you have EEPROM on the board then it may be possible for you to embed the configuration into memory.

Is it possible to have you change the firmware itself using a #define or similar? Then you don't need board space and extra pins for version detection.

\$\endgroup\$
2
\$\begingroup\$

One wire EEPROMs are a nice solution because they only require one GPIO but can store a large amount of configuration information. They also allow the microcontroller to write that information during board test (e.g. calibration data). Many have a write-protect pin or one-time programmable bit to prevent further changes.

Other advantages include useful features such as guaranteed unique serial numbers.

This option is used in many systems, such as oscilloscope probes and batteries, due to only needing a single data line. The EEPROM can even be powered from the data line itself.

The main disadvantage is cost. The cost isn't high, but on mass produced products a few cents can matter.

An example of such an EEPROM is the DS2431, which stores 1kb.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.