Usually the voice playing function of a toy is realized by pressing keys, but for some other toys, this function is realized by selecting different cards. This method can play various voices, whereas it needs more IO ports. At present, to realize the voice playing by using cards, the resistance measuring function is mostly used.
Therefore, to meet our customers needs of realizing this function, EzCode4G has included the resistance measuring options and commands, which can also make the programming become more easy.
Theory of Resistance Measuring Function
Since MCU ouput high level from IO to charge capacitor via resistor, we can utilize this to measure the time of charging capacitor. If the capacitances are the same while the resistances are different, the charge time will be different. By this means, the different resistances can be distinguished.
In the cases of application, since the error of measuring charge time may occur due to capacitors or voltages impact, we take a resistor charge time for reference and get the ratio between the resistor to be tested and reference resistor to raise the measurement precision.
Circuit of Resistance Measuring.

R0: Reference Resistor
Rx: Resistor to be tested
D1, D2, D3: Diodes used to restrict current flow with RxPin, R0Pin, DisChange Pin respectively.
ReadPin: IO pin to read charge status, used to identify whether the charge is completed or not.
R0Pin: Output pin of reference resistor
RxPin: Output pin of resistor to be tested
DisChargePin: Pin to discharge to capacitor after the charge is completed
C0: Capacitor for charge / discharge
Note: The D1, D2 and D3 are added in this circuit since the IO state of 4G cannot convert from output into floating input, which may affect IO charging.
... ...