EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: ricko_uk on March 17, 2022, 06:34:01 pm

Title: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: ricko_uk on March 17, 2022, 06:34:01 pm
Hi,
I would like to have the variant and version of a PCB to be identifiable by the micro that is on the board itself (so it can be displayed on the LCD part of the system). Without need to custom program that info in the micro itself and without using more than one pin?

The simplest way I thought of was to have a voltage divider fed into the micro's ADC and with every variant and version having a different/unique value.

Any other suggestion?

Thank you :)
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: wraper on March 17, 2022, 06:36:52 pm
The simplest way I thought of was to have a voltage divider fed into the micro's ADC and with every variant and version having a different/unique value.
A lot of commercial hardware does exactly this. For example GPU in graphics cards often detect what type of VRAM is used by resistance value of a resistor soldered. And if during repair you change RAM to another vendor, you need to change the resistor as well.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: Swake on March 17, 2022, 10:40:33 pm
That one pin could also read pulses, with a different patern or frequency indicating a different board. Extra bonus points if you implement a PWM with a 555.

Alternative to a voltage divider is a zener.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: ricko_uk on March 18, 2022, 01:01:36 am
Thank you Wraper and Swake :)
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: DavidAlfa on March 19, 2022, 05:38:01 am
Unless you're going to have a lot of revisions, just make a voltage divider and read it using the ADC at boot.
Have a lookout table with ranges, knowing which ADC values match each revision.
Then just change the divider ratio in the pcb.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: ricko_uk on March 19, 2022, 11:52:27 pm
Thank you DavidAlfa and barycentric :)

Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: firehopper on March 20, 2022, 12:56:35 am
could also use a one wire eeprom maybe. could store other info in it as well.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: MegaVolt on March 21, 2022, 12:18:52 pm
To expand the number of options, you can use the drawing on the board, the same as for the divider. Further on each of the 2 positions you can bet:
- Leave position empty
- put a resistor
- install a capacitor
In total, even for identical elements, we have more than 2 easily distinguishable options. You can create:
- pullup
- pull down
- RC
- CR
These circuits are easily detected digitally.
Changing denominations will create 2 new variants. Just as easy to detect digitally.

But I would advise to put the memory. This is very convenient and you can store not only the type of board, but also its personal number. And perhaps personal settings, constants and other information.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: T3sl4co1l on March 21, 2022, 03:31:46 pm
Interestingly, the resistor/divider method is quite old: Tektronix has used this since the 60s(?) to identify scope probes.  This is how the on-screen display automatically changes to x10, etc. :)

(Or more recently, probes with actual data pins flanking the BNC.  This might be anything from a 1-2 wire EEPROM to a full on power supply and serial bus for the more complicated probes.  I forget what all they use in 'em these days; you'd have to look up the manuals.)

And yeah, have seen plenty of things with jumpers or placement options to do this.  Not uncommon at all, it's a preferred method I'd say. :)

On the more esoteric side, I've contemplated putting structures into the PCB itself for identification -- also for DRM purposes if you will, to frustrate reverse-engineering of the system, say.  Unfortunately, there's only about three or four ways to use a PCB for anything sensible:
1. DC resistance.  Copper is quite conductive, relative to the currents and voltages used by MCUs.  You could sense a few mV here or there and perhaps identify the thing; but these are also very close to the LSB sizes, or offset voltages, of typical ADCs, so you might be making a lot of duds, too!
2. Inductance or capacitance.  Trace length or pad/pour area can accumulate capacitance, and this can be sensed as above (e.g. pull-up resistor + input threshold voltage as a crude time constant).  Conversely, trace length and loop area can accumulate inductance, which is harder to sense as the impedances are again pretty low relative to bare MCUs, but some methods would still be practical.
3. Transmission lines.  The width and length of a trace corresponds to impedance and time, which can be read out directly in transient or frequency domains.  Bonus points for making the TL structure your logo, so it's critical for device operation as well as visual identification! ;D

And of these, the first two are very limited in degrees of freedom: a resistor, capacitor, inductor, or network thereof, is one value for each element, and around... oh I don't know, probably circa N^2 values for N pins, including coupling factors between things?  The last one has arbitrarily high degree of freedom, but is extremely bandwidth intensive, obviously (anything board-sized will take mere nanoseconds to propagate along!); you basically need a whole-ass TDR tester on the board itself.  Good luck implementing that with an ordinary MCU and no suspicious (let alone expensive) circuitry! :(

Also that most of these options will take up considerable board area, not at all suitable for compact / high density things.  Also, long traces snaking their way through a board stack, are prone to picking up interference or coupling it to other things, making for an ever more difficult layout as density goes up.

So, using assembled components, and not trying to enforce DRM or product selection through these means, is generally the best way to go. :)

Tim
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: fchk on March 21, 2022, 03:36:42 pm
Just to give you other ideas:

Apple used 1-Wire devices for identifying Magsafe power supplies - serial number and wattage. The used a custom version of the DS2413 with Apple specific information programmed into the ROM.

https://www.maximintegrated.com/en/products/interface/controllers-expanders/DS2413.html (https://www.maximintegrated.com/en/products/interface/controllers-expanders/DS2413.html)

The Macbook's system management controller could control the red/green led on the magesafe connector with the two GPIO pins that the DS2413-variant provides and can signal charging state or error states.

There are many 1Wire devices that have EPROM, OTP and EEPROM storage.

Microchip has got a 2kbit UNIO EEPROM with preprogrammed MAC address, which might also be useful for you. Microchip can also preprogram the user storage space of these chips for you if you buy a certain quantity.

http://ww1.microchip.com/downloads/en/DeviceDoc/11AA02E48-11AA02E64-2K-UNIO-Serial-EEPROMs-Data-Sheet-20002122E.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/11AA02E48-11AA02E64-2K-UNIO-Serial-EEPROMs-Data-Sheet-20002122E.pdf)

fchk
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: free_electron on March 21, 2022, 03:50:36 pm

On the more esoteric side,
capacitive touch principle. they are essentially a relaxation oscillator driven by a gpio pin. depending on the size of the capsense surface the base frequency is different.
your 'logo' is etched in copper and a specific size... muck up the logo and the oscillator is off.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: wraper on March 22, 2022, 07:10:28 am
The Raspberry Pi good-ol-boys like to use a one-time programmable i2c memory.
No, board revision is programmed into Broadcom SoC. EEPROM is only used in Pi4 for storing bootloader.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: ricko_uk on March 22, 2022, 04:12:00 pm
Thank you all!! :)
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: philpem on March 22, 2022, 06:52:40 pm
One project I worked on had a 3x3 pad array. Three inputs to the MCU, each with three possible connections:

- High
- Low
- Floating

The STM32 chip we used had configurable weak pull-up and pull-down resistors. So on boot, it toggled the pull-ups on, read the pins, then did the same with the pull-down active.

If the line is pulled high you'll see a '1' in both reads
If the line is pulled low you'll see a '0' in both reads
If the line is floating you'll see a '1' with the pull-up and a '0' with the pull-down.

Once you have that, you convert the single pin value into either 0, 1, or 2 -- call it Vpin.
For every version pin, calculate: Version = (Version * 3) + Vpin  [Version starts at zero]

It's an essentially zero-cost way of doing it -- and really is zero-cost if you do the versioning with PCB traces.

I love the idea pitched elsewhere in the thread of fitting a capacitor - what a grand idea! Either way it gives you 3 states. Charge the capacitor, switch to input, wait a moment, see if the pin stays at '1'. Discharge it and repeat for confirmation. There's your third value - short high, short low, or capacitor.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: ricko_uk on March 23, 2022, 12:17:34 am
Thank you philpem,
another interesting idea :)
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: DavidAlfa on March 23, 2022, 12:42:29 am
Noobs. Connect a capacitor with a series resistor to an ADC pin. Set the pin as GPIO, output.
Discharge it by setting the pin low for some time, then set it high, wait for a few uS, set pin as analog, read the ADC, then it's just matter of:  :-DD
(https://www.eevblog.com/forum/projects/easy-way-to-identify-the-pcb-version-electronically-(i-e-by-the-onboard-micro)/?action=dlattach;attach=1445965)
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: T3sl4co1l on March 23, 2022, 11:14:38 am
Noobs. Connect a capacitor with a series resistor to an ADC pin. Set the pin as GPIO, output.
Discharge it by setting the pin low for some time, then set it high, wait for a few uS, set pin as analog, read the ADC, then it's just matter of:  :-DD
(https://www.eevblog.com/forum/projects/easy-way-to-identify-the-pcb-version-electronically-(i-e-by-the-onboard-micro)/?action=dlattach;attach=1445965)

Why waste your limited supply of ADC pins when you can use the input threshold itself as a 1-bit ADC? ;D

The downside being, the accuracy is shite (a combination of variations of input threshold and pullup/down resistances), but it's still enough to get a few bits of signal out of it: say, a decade per bit, logarithmically. So, from 100pF to 100nF say, that's six levels or about 2.5 bits.

The method can be used for much more sensitive purposes, if self-calibration is allowed -- for example, using nothing but an LED (okay and maybe a current limiting resistor) as an entire communication system:
https://www.merl.com/publications/docs/TR2003-35.pdf (https://www.merl.com/publications/docs/TR2003-35.pdf)
https://github.com/ChrisMicro/LedDataTransmission (https://github.com/ChrisMicro/LedDataTransmission)

Tim
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: wraper on March 23, 2022, 11:25:57 am
The Raspberry Pi good-ol-boys like to use a one-time programmable i2c memory.
No, board revision is programmed into Broadcom SoC. EEPROM is only used in Pi4 for storing bootloader.

The HATs use I2C prom.
I don't think HATs use OTP I2C memory as it's basically non existent. Neither it's used for internal purposes but rather for external identification, similar to PC DRAM, VGA, DVI and others.
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: DavidAlfa on March 23, 2022, 11:53:32 am
Tim
Oh c'mon It was just a joke. That would be insanely overcomplicated :-DD
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: Jeroen3 on March 23, 2022, 12:37:04 pm
Just put a one wire or i2c memory on there.

When it is unprogrammed your board does nothing. During testing you scan the barcode and the board gets programmed with the right info, serial number, dates, macs, options, lcd protocol, all the stuff you may need in the future anyway that a voltage divider can't give you. Plus, you don't need to recompile the code when you make a new version (eg: board rev change to skip around part shortage without change in function).
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: free_electron on March 23, 2022, 08:17:09 pm
Noobs. Connect a capacitor with a series resistor to an ADC pin. Set the pin as GPIO, output.
Discharge it by setting the pin low for some time, then set it high, wait for a few uS, set pin as analog, read the ADC, then it's just matter of:  :-DD
(https://www.eevblog.com/forum/projects/easy-way-to-identify-the-pcb-version-electronically-(i-e-by-the-onboard-micro)/?action=dlattach;attach=1445965)
noob  .no need for a resistor or capacitor. make an embedded capacitor in the board. I wrote that several posts ago. its the principle of a touch sensor
Title: Re: Easy way to identify the PCB version electronically (i.e. by the onboard micro)
Post by: DavidAlfa on March 24, 2022, 06:59:58 am
 :-DD