Dear Cypress Developer Community,
I got inspired by the hackster.io project "PSoC 4 : (4+3=) 7$ Auto Ranging Ohms Meter" (https://www.hackster.io/PSoC_Rocks/psoc-4-4-3-7-auto-ranging-ohms-meter-41dc9e).
Because I do not have a PSoC 4 available, I ported the project to PSoC5LP (CY8CKIT-059). By testing the code, I noticed that the ohms meter is working fine for lower unknown resistance values (Rx less than few hundred ohms), but auto ranging ohms meter is showing significant errors for higher resistances.
Step-by-step I changed the hackster.io code to try to identify the error. Attached you can find my latest PSoC Creator version. For simplicity, only 4 predefined measurement-currents are taken: 2mA, 0,2mA, 20uA, 2uA. In the first attempt, IDAC is set to 2mA. If the measured ADC-voltage is above 1V, the next current range is taken (0.2mA), and so on...
As soon as measured voltage is below 1V, the resistance value is calculated by R = U/I.
For debugging purposes, the i-range is printed out at the character LCD-display as well.
Here are some measurement results:
Rx-value resistance measured by PSoC range
100Ohm 98 Ohm 0
1,5kOhm 1482 Ohm 1
47kOhm 50 kOhm 2
100kOhm 279 kOhm 3
Interestingly, if I put a break point at code line 63 (adc_result = ADC_GetResult16();) and press continuously F5 (Resume Execution) in debug mode, I get much better measurement results:
Rx-value measured in debug mode range
100Ohm 99 Ohm (99.14 Ohm) 0
1,5kOhm 1487 Ohm (1487.79 Ohm) 1
47kOhm 46 kOhm (46.410 Ohm) 2
100kOhm 103 kOhm (103.947 Ohm) 3
I figured out that I need to add a CyDelay between
adc_result = ADC_GetResult16();
to get closer voltages. If the delay is 200ms, I still see significant errors with 100k testing resistor (measured: 133k). By setting delay to 1s, everything seems fine... but ohms meter is acting quite slow... and furthermore, I do not understand why a CyDelay is needed here at all ?!?!
I'm open for any ideas... because currently I have no clue what's going wrong here...