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?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
Off the top of my head, two easy solutions come to mind.
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.
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.
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.