Is a R-2r ladder DAC for switches limited to 12 switches for ESP32?

MaineWoods
Posts: 2
Joined: Mon Mar 02, 2020 10:44 pm

Is a R-2r ladder DAC for switches limited to 12 switches for ESP32?

Postby MaineWoods » Mon Mar 02, 2020 11:04 pm

Hello all,

I am pretty new to arduino, I have been working with them for years but only a few projects over that time, so please forgive the following question:

I made a R-2r ladder similar to https://github.com/mickey9801/ButtonFever but with with a debounce capacitor.

I was hoping to get away with using this to operate 14 switches but understood that the ESP32 is 12 bit and figured I might be limited to 12 switches for that reason. After testing my ladder, switches 0 and 1 are not recognized but 2-13 are (and are quite stable).

Can someone confirm that this is due to the pin (35 in this case) being 12 bit and that more then 12 switches are not possible on a single pin using a R-2r? Or should I be looking for the problem somewhere else?

And yes, I know I could just use a PFC8575 - I ordered a few from china but the seller never shipped them, then I ordered a few from a US seller via ebay to get them faster and they were lost in the mail, what I do have is a box of full of resistors and capacitors and an approaching deadline.

Thanks for your help, Travis

ESP_Sprite
Posts: 9599
Joined: Thu Nov 26, 2015 4:08 am

Re: Is a R-2r ladder DAC for switches limited to 12 switches for ESP32?

Postby ESP_Sprite » Tue Mar 03, 2020 1:38 pm

I would very much not suggest using this method for more than 5-6 switches - even if the ADC of the chip you're using is perfect (and the one in the ESP32 is not), you would have resistor tolerances and electric noise upsetting the readings. With 12 R-2R steps, the difference between buttons is less than a mV.

MaineWoods
Posts: 2
Joined: Mon Mar 02, 2020 10:44 pm

Re: Is a R-2r ladder DAC for switches limited to 12 switches for ESP32?

Postby MaineWoods » Tue Mar 03, 2020 6:52 pm

Problem solved: I forgot that the number of switches had to be defined in the setup for the button manager library to function properly and I did not spot it while looking for the problem - over 800 lines gets hard to read after awhile.

Thanks for your reply ESP-Sprite. I do understand that this method and my large quantity of switches risks becoming unstable for any number of reasons that may effect the circuit voltage even in a very minor way. I don't think it's less then 1mV though - unless I am missing something? The difference between the last switch on the array and second to last measures out to 0.21v - according to what the ESP32 is measuring. So far I have only seen the switch output very by less then 24mV. My switches are located less then 10" away from the ESP32 and in a shielded box. I am using a medical grade power supply, 1% resistors and a debounce capacitor.

Who is online

Users browsing this forum: Baidu [Spider] and 153 guests