Hardware Version Numbers

PCB Version Number resistors, as well as silkscreen space, and installed option resistors.
PCB Version Number resistors, silkscreen space, and installed option resistors.

In my past two posts, Storing When an Arduino Sketch was Compiled and Arduino Serial Number we covered how to know the Compiled date, Firmware version number and Serial number of a bit of test equipment, in this post, we will encode the Hardware Revision number, so that we know what the revision of the main PCB is.

The revision information is encoded using two resistor dividers, each of which can encode eight states.

The two dividers, each have four resistors, as for values three and four you need to put two resistors to get the right ratio.

As you can see in the schematics below, and the PCB render to the right, all the pads are laid out at the beginning, even though they are marked as DNF (Do Not Fit). Also in the image you can see that optional population-level jumpers are fitted, so the final test equipment can have different population levels but use common firmware and hardware.

The values have been chosen to minimise the quiescent vampiric current draw of the dividers. the net +5C is being used as the supply rail for the hardware version resistors, and the population level resistors. This is the same supply used to power up the microcontroller and is un-switched, separate from the supply of 5V equipment in the device.

Resistor Values for encoding hardware Version numbers.
Resistor Values for encoding hardware Version numbers.

Resistor Values

ValueRatio of VDD (dec)Top Resistor ValueBottom Resistor Value
01/16 (0.0625)4k7DNF
13/16 (0.1875)910Ω3k9
25/16 (0.3125)1k53k3
37/16 (0.4375)2k42k4 + 430Ω
49/16 (0.5625)2k4 + 430Ω2k4
511/16 (0.6875)3k31k5
613/16 (0.8125)3k9910Ω
715/16 (0.9357)DNF4k7
Version number value encoding resistors.

Falstad Simulation

You can open and close the switches in the following simulation to change the voltage across the voltmeter.

powered by Advanced iFrame. Get the Pro version on CodeCanyon.

Arduino Code for Version Numbers

VerPin0 and VerPin1 are taken to Pin_A0 and Pin_A1 on the Arduino, and the code for reading it in is as follows

  int valA = analogRead(PIN_A0);  // Analog pin A1
  int valB = analogRead(PIN_A1);  // Analog  pin A0
  valA = map(valA, 0, 1023, 7, 0); // Maps the value from analouge pin to 0-7.
  valB = map(valB, 0, 1023, 7, 0);

  if (valB != 0)
    valB = valB + 7;          // adds 7 to the MSB if it is not zero
  Hardware_Rev = valA + valB; // gives us a hardware version between 0 and 15.

This code is added to the version() function mentioned in the previous post.

Simulation of Version Numbers (Wokwi)

There is a known issue with the simulation in Wokwi, where potential dividers don’t produce the right output, so this simulation won’t work as well as it should, but if you build it in hardware it should work as required.

The below simulation can be opened full screen in Wokwi.

powered by Advanced iFrame. Get the Pro version on CodeCanyon.

In the future

Now we have encoded the Firmware, Serial number and Hardware Version Numbers in a way that is accessible to the microcontroller, we can use these values to lock specific firmware versions to only work on pre-defined hardware versions.

For test equipment I have made before, I have used SCPI (Standard Commands for Programmable Instruments) to talk to the hardware, in a future post I will talk about how to use the microcontroller.

Leave a comment

Your email address will not be published. Required fields are marked *

The maximum upload file size: 20 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop files here