14

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?

Henrik Hansen
  • 245
  • 1
  • 8
  • 1
    There's also this Q from a while back, answers are similar to those already given (which is good!): https://electronics.stackexchange.com/questions/41757/what-is-a-good-way-for-the-mcu-to-determine-which-hardware-version-it-is-running – awjlogan May 01 '18 at 13:52

4 Answers4

15

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.

awjlogan
  • 7,879
  • 2
  • 29
  • 45
  • 1
    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. – Tomas D. May 01 '18 at 19:51
  • 2
    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 02 '18 at 05:44
  • 1
    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 02 '18 at 09:31
  • 1
    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 02 '18 at 09:42
10

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.

Colin
  • 4,499
  • 2
  • 19
  • 33
  • 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 01 '18 at 11:17
  • How do you load the version data into the shift register? – Travis Oct 24 '20 at 05:15
  • 1
    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 – Colin Oct 24 '20 at 07:15
  • 1
    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. – Travis Oct 26 '20 at 16:55
7

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.

R.Joshi
  • 566
  • 2
  • 12
2

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.

user
  • 1,789
  • 10
  • 20