Use the voltmeter approach and measure the voltage over a shunt resistor. Keep in mind that the input for a PSoC must be in the range of GND < Vin < VDD
Yes, nearly.R1 is your shunt, but in series to that will be your consumer (another resistor, but unknown). In your picture the volotage you measure will always be Vdd.
R2 is not the reference, it is the unknown R where the current I flows through. The same current flows through your R1, so with Ohm's law you get I = Umeasured / R1
To reduce errors further, have a look at this application note concerning "Correlated Double Sampling" (CDS)
oke, thank you.
i used code like voltmeter example and add some new for current measurement. i hope you can check it and correct me if i'm wrong.
LCD_PrintString("PSoC Ammeter" );
sprintf(tmpStr,"%+1.3f ampere", adcAmpere);
and i make the block diagram like this.
Coba 2.JPG 51.0 K
A more precision approach would be to eliminate the PGA and use
the A/D differentially, so connect its - input iput to the pin that connects
to the low side of the shunt.
Also set A/D up with bypass buffer so that you can get rail to rail performance.
In your code you did not set the value of Rshunt.
Oh thanks for the tips, i've recently read this method in "AN84783", thank you.
like this "try again" pic?
so what is the different for current measurement usig this method, PGA and TIA?
try again.JPG 40.9 K
Yes, thats the correct schematic. Basically by not using TIA or PGA
you eliminate errors associated with their signal path, like V and I offsets,
Also by using differential mode you eliminate common mode voltage
Here is more than you want to know about errors -
oke, thank you for the tips mister dana.
oh ya, so what the pin that i can use for this design?
Take a look at these -
http://www.cypress.com/?rID=40247 AN58827 - PSoC® 3 and PSoC 5LP Internal Analog Routing Considerations
http://www.cypress.com/?rID=39974 AN58304 - PSoC® 3 and PSoC 5LP – Pin Selection for Analog Designs
http://www.cypress.com/?rID=57571 AN72382 - Using PSoC® 3 and PSoC 5LP GPIO Pins
http://www.cypress.com/?rID=39677 AN57821 - PSoC® 3, PSoC 4, and PSoC 5LP Mixed Signal Circuit Board Layout Considerations