Yes, you could just change the value of the 12V pull-up, so that the float pull-down keeps the output voltage below the ADC Vref.I don't know that much about it, given that I have only just implemented a voltage divider for the first time (the windvane discussed earlier).Are the switches still performing their original function on the vehicle's equipment, or has that been removed? It is quite possible that the original wiring adds a 12V supply through a resistor, so that the output becomes a voltage which is altered by operation of the switches. The Pico will not be happy with that.
But, can't you make the Pico happy with it simply by multiplying the divider resistance you'd use by the inverse of the ratio of the logic levels? In this case, 1/4? So if you would use a 1000 ohm resistor at the 3.3v logic level, you'd use a 4000 ohm divider resistor to achieve the same observed levels at the ADC pin? A simulation in CircuitLab seems to suggest it is so, although it is easily possible a newbie like myself has made a mistake:
https://www.circuitlab.com/circuit/kv7p ... v-vs-3_3v/
BTW, it's worth noting that the Pico ADC has less than 9 effective bits of precision. Therefore, you need to choose a good divider to maximize the separation between the voltages to be observed. When implementing the windvane on the Pico, I wrote a script to help with this:
https://github.com/jaguilar/weatherstat ... _levels.py
(Could be bugs, no warranty express or implied!)
When the 12V pull-up and the original equipment are not connected, you can fit your own Vref pull-up with whatever value helps give discrete values for each switch. Note that you must choose a value that works with the highest and lowest switch resistors used, and their nearest neighbours. It may or may not to be the same value as the original 12V pull-up, which will work with the fitted resistors to give discrete voltages for the original equipment. It depends on the input range of the original ADC. At a first glance, separating five levels on an ADC capable of 512 digital values is not hard -- though a vehicle is an electrically noisy environment that may cause issues. Be prepared to fit bypass capacitors.
Long ago, I designed (professionally) alarm systems using five-level analogue signalling. In the years BC (Before Computer), we used comparators to recognise each condition. Microprocessors and ADCs made life a lot easier! Or, at least, transferred some of the difficulties from hardware to software.
[Updated to reflect OP's post made while I was writing.]
Statistics: Posted by davidcoton — Fri Jun 14, 2024 9:26 pm