```
#macro GetVdd
_VoltageDebug("@GetVdd")
calibadc10 _VoltageADCval 'Read reference 1.024v (Value = 1023 * 1.024V / Vdd)
Voltage_Vdd = 10450 / _VoltageADCval * 100 'Obtain first 2 digits, nnxx. Max=5200(5211), Min=1800(1803)
_VoltageModulus = 10450 // _VoltageADCval 'Find remainder. Max=580, Min=0
Voltage_Vdd = 100 * _VoltageModulus / _VoltageADCval + Voltage_Vdd 'Obtain last 2 digits, xxnn. Max=99(=100*580/581), Min=0
_VoltageDebug(" (Ref_1.024V=",#_VoltageADCval,", Vdd=",#Voltage_Vdd," mV)",cr,lf)
#endmacro
#macro SetVdd(VoltsW)
_VoltageDebug("@SetVdd")
Voltage_Vdd = VoltsW
#endmacro
#macro VoltsByVdd(VoltsW, Channel)
'The measured voltage is Vdd(1800 mV to 5200 mV) * ADC_Reading(0 to 1023) / 1023(ADC_Range). NB: ADC range is approximately 1024
_VoltageDebug("@VoltsByVdd")
readadc10 Channel, _VoltageADCval 'Read ADC Channel, the range is 0 to 1023 from Gnd to Vdd.
VoltsW = Voltage_Vdd */ _VoltageADCval 'Get the middle word of Vdd * ADC10, so the result is divided by 256.
VoltsW = VoltsW / 4 'Then divide by 4, now we have approximately Vdd * ADC_Reading / 1023.
_VoltageDebug(" (ADC",#Channel,"=",#_VoltageADCval,", Voltage=",#VoltsW," mV)",cr,lf)
#endmacro
```