# Encoding version or configuration on PCB

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?

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.

• 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. – Socrates May 1 '18 at 19:51
• 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. – Aleksi Torhamo May 2 '18 at 5:44
• 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). – Graham May 2 '18 at 9:31
• 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. – Graham May 2 '18 at 9:42

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.

• 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. – Jeroen3 May 1 '18 at 11:17

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.

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.