Forgive me for the monologue. Looking at the code, it does not look like multiplexing is something that the current code supports.
I am not an expert in electronics and new to programming MCUs.
I guess my specific question is if it is possible to only set temperature when external speed sensor hall is high? With NTC 10k pulling down from hall, the voltage during high phase would be inversely proportional to thermistor resistance, but it can only be measured when hall signal is high. Of course the highest supported temperature has to be low enough for the digital logic to detect high, otherwise if NTC pulldown resistance is high enough, speed hall will never register.
If I am reading code correctly, looks like hall sensor events are counted (?) on fall of digital pin transition to low using interrupt handler and there is a built in pullup enabled on digital pin.
Would
this be a good place to read temperature instead of
this location to only measure when hall is high?
Another question I have is about mapping of adcData array to individual MCU pins and signal names.
This header file maps pins to signals. Is it universal across Lishui boards? . Looking at the second picture
here it looks like Motor_Temp is on PB0, but looking at
code it reads it from adcData[6], which is described as PB1
here, so is it PB0 or PB1?
(edit) Confirmed Motor_Temp is on PB0 on LSW12G board
Looking further at datasheets, driven by 5V STM32 has to register >2.71V on digital pin to reliably register High
Built-in pullup is at about 40k
NTC 10k (Ametherm DG103395) resistance at 125C is about 359 Ohms, so if the additional external pull-up is 220 Ohm, we are getting logical high voltage from 4.99V at -20C to 3.11V at +125C, which should be high enough.
If ADC Vref is 3.3v, this provides ADC raw values from 6192 at -20C to 3854 at +125C, which is good enough resolution for the purpose of protecting the motor. 3.11v is also enough to register logical high.
This is what I have in mind. I suspect I am missing a voltage divider that's between TEMP_SENSOR pin and PB0. Does this look like something that may work?
I should try it when I get my motor back together - I am expecting some replacement bearings.