I guess you're trying to measure (or calculate) resistance?
Basically my idea is the arduino will output 0-4mA current from PWM digital pin (suggestion from my supervisor)
[u]PWM[/u] is NOT analog and the Arduino (by itself) is NOT a current-source... It's a voltage-source and (as-usual) the current depends on resistance (and voltage).*
However, I did not get desired voltage value from analog pin when i tested my system with a standard reference wafer, the voltage obtained was not increasing as current outputs increases (sometime i got 0V from analog pin).
And this sounds like an industrial or production application... In general, measurement instruments in "serious applications" should be calibrated & verified. There's nothing wrong with using the Arduino in an industrial application but check with your QA department before using any "homemade" instrumentation.
- Most "things" in electronics are constant-voltage (or controlled-voltage) sources. For example, the power outlet in your home has the same voltage if you plug-in a small low-wattage lamp or a toaster, or if nothing si plugged-in... The voltage is still there. The Arduino puts-out 0V or 5V (as long as you don't overload it). Or, your stereo puts-out (about) the same voltage if you disconnect the speakers. In the case of audio, of course the voltage isn't constant because it depends on the loudness of the music, but it's "classified" as a constant voltage source because it's independent of the load (within reason and with a load resistance that's in-spec.)
There are constant current (or controlled current) power supplies for LEDs. The voltage self-adjusts to give you the correct current.... If you disconnect the load, of course you don't get any current but you get whatever maximum voltage is available as it "tries" to maintain current. If you short it out, the proper current will flow (at nearly zero volts) and unlike a regular power supply, it won't burn out if you short it.