Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESP32] Detect board version, and adjust config accordingly #122

Closed
SmittyHalibut opened this issue Nov 26, 2024 · 5 comments
Closed

[ESP32] Detect board version, and adjust config accordingly #122

SmittyHalibut opened this issue Nov 26, 2024 · 5 comments
Assignees

Comments

@SmittyHalibut
Copy link
Collaborator

SmittyHalibut commented Nov 26, 2024

With v2, I've added a way for the ESP32 to detect which version of the board it's running on. This allows you to build a single image that will work on multiple boards.

The detection pins are GPIO36 and GPIO39 (aka: Sensor_VP and Sensor_VN).
image

Each pin can be in one of three Config States:

  • LOW: tied to ground
  • HIGH: tied to Vcc
  • Hi-Z: completely disconnected.

The code detects which state each pin is in by configuring the pin with an internal pull-up, and read its state. Then configure it with an internal pull-down, and read its state again. The mapping from Pin State to Config State is:

Config State Pull-Up Pin State Pull-Down Pin State
LOW LOW LOW
HIGH HIGH HIGH
Hi-Z HIGH LOW
error LOW HIGH

The Board Version is a 2-digit base-3 number, for a total of 9 trackable versions. The only valid Board Versions right now are:

Board Version GPIO36 GPIO39 Comment
v1.x Hi-Z Hi-Z All old versions did nothing with the Sense pins
v2.0b HIGH HIGH v2.0b requires a bodge: pins 4 and 5 on ESP to immediately adjacent 3.3v test pad.
v2.0c HIGH HIGH The first board with this actually implemented in the board. Electrically similar to v2.0b, so same Board Version.

We'll add more to that table as we make more boards that require software changes.

Let me know if you have any questions.

@SmittyHalibut
Copy link
Collaborator Author

SmittyHalibut commented Dec 3, 2024

EDIT: There's no reason to differentiate between v2.0b and v2.1a, since there isn't anything that changed from a software perspective. See #88 for full details. Consequently, I'm going to keep the detection pins disconnected/Hi-Z on v2.1a.

EDIT 2: There's no practical difference between v2.0b and the version I'm working on. It doesn't warrant a bump to v2.1. Renaming to v2.0c.

EDIT 3: Well, shoot. Hi-Z/Hi-Z will make v2.0 indifferentiable from v1.x.

OK. SO. Here's the plan.

image

Pins 4 and 5 are the sense pins. Currently, they're shown disconnected, Hi-Z state. This is what's on the v2.0b boards. This is electrically the same as the v1.x boards, hence the problem.

My proposal for v2.0b is to bodge pins 4 and 5 to the immediately adjacent 3.3v test point. I'll connect v2.0c to 3.3v on the actual board. Since they are configured the same, we can use the same config for both. See Edit 2 above.

This will make the following table:

  • v1.x: Hi-Z/Hi-Z
  • v2.0b, v2.0c: HIGH/HIGH

I'll update the table above with the current values.

@dwillmore
Copy link

There are other options as well. You can put a resistor/cap combo with different time constants on the pins and use the pullup/pulldowns to test them. That gives you a very wide range of values. If these pins can be analog inputs, you can use a resistor ladder to generate a variety of voltage which the A/D can sample. You can get quite a few bits that way.

This is one of those problems that woke me up at 4am one day and filled a page in my bedside notebook.

@SmittyHalibut
Copy link
Collaborator Author

Hehe. All very true, and the sense pins can be analog inputs as well. They're specifically designed to be a precise differential analog input, so we're well suited for options in the future.

For now though, 9 non-backward-compatible board revisions are enough to get us started. We can add more options in the future as necessary. KISS.

@VanceVagell
Copy link
Owner

I don't think I need to do anything with this enhancement request, right? Closing. Please reopen if something is needed.

@SmittyHalibut
Copy link
Collaborator Author

Dang it! I knew there were already issues for these things I've been doing! Yes, this is duplicate of #203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants