IDAC8 is a source current source, so it provides a constant current
sourced out of Vdda. In order for the current source to stay in the
constant current region it has to have a min voltage drop across it,
called compliance range. The compliance is 1V so for a 5V supply
the IDAC8 will operate over 0V to 4V, above 4V it will drop out of
regulation. So for 100 uA max R you can measure accurately is
4V / 1E-4 Amps = 40K.
The accuracy of IDAC8 is +/- 2.5%.
An analog mux, when its inputs are left floating, unconnected, will
exhibit anything from Vssa to Vdda depending on leakage.
In your code adcReading = ADC_SAR_0_GetResult16(); the API
returns a signed result, you need to change adcReading to int16,
not uint16 as it is now.
AMux_0_Start() disconnects all channels, you have to use the AMux_0_Select() or
AMux_0_Connect() API to connect a channel to the SAR ADC.
When you change the mux you should allow for a little settling time
for the analog signal to reach final value. You may have intrinsically
enough delay in your code / measurement loop, otherwise add some
delay. The delay cannot be easily computed, its impacted by IDAC8
settling time, mux Rdson, SAR input C and any stray C. The IDAC8
settles in ~ 125 nS, for a full scale step, see conditions in spec sheet.
and I made all the steps you told me, but still measuring 5 volts. Use a multimeter to see if it was that the IDAC is not working, but if measured the 1 volt I wanted.So if I see is that when I change the voltage reference. Send approached the reference values.
SAR_SPIM_USB08.cyprj.Archive01.zip 1,023.6 K
When I use Google Translate to translate spanish to english
I get unreadable result. Any chance you can post in english ?
/* Any value above 0x07 is an illegal input for mux channel selection */
#define ERROR_MASK (0x7Cu)
You are using the mux as differential, so the range of allowed channels
is 0 - 3.
When you connect mux to resistor you are connecting + input to junction of
IDAC and resistor, and - input to resistor ground ?
Right after you start mux you should issue a channel 0 select.
In the pinout view you do not have Vref external connected to a pin, should
be P0_4, and you apply a 5 V reference to it.
yes, I connect mux to resistor you are connecting + input to junction of
Another matter, when you use an external reference, your measurement
accuracy is determined by it. When you select input range with Vdd depend-
ence, the measurement is ratiometric to Vdd. That means your R measurement
will not be absolute accurate. Is that what you want ?
You are using differential measurement, but do you really need that in light of
IDAC8 accuracy only +/- 2%. You would stay with diff if you had high common
mode environment or poor grounds between Rx and PSOC or if distance was
large between Rx and PSOC, otherwise just use single ended.
I may be wrong but I would think you want internal reference, 0.0 ± 1.024V (Differential)
Input ± Vref If you do this then P0_4 would not be used. Also you would have to scale
IDAC to accomidate the A/D only measures 0 - 1.024 V.
I place 1.024V of internal reference and it send that value as a measure
IDAC8 100 uA thru a 10K resistor = 1 volt, so yes thats what you would measure.
I place 5v of internal reference and it send that value as a measure 5v
I set up A/D a little different -
1) Set to continuous conversion.
2) Issued a
outside for() loop. Removed StartConvert() inside start loop.
3) Set for Vref = 1.024, 0.0 ± 1.024V (Differential) Input ± Vref
4) Tried a 4.7K Rx and a 10K Rx and got 470 mV and 1000 mV, correct readings
5) Tried a Rx >> 10K (means > 1V) and readings turned negative as they were outside
6) You select the channel with this line of code AMux_0_Select(rdValue);
I monitored rdValue, and it was 209. That of course is wrong, rdValue can only range
from 0 to 3 because there are only 4 mux channels, so you have to fix that.
it is AMUX that affects me, because without it; I have measured result very good
You make the following calculation -
rdValue = rdBuffer - ASCII_DECIMAL_ZERO;
then issue a
to select the mux channel. The mux channel only numbers 0 - 3,
for 4 differential channels. But if you place a breakpoint on the
line you will see the rdValue is wacko, something > 200 ?
If rdBuffer ever contains anything other than "0", "1", "2", "3" then you
will have a bad value that you will be using trying to select the mux
channel. Also when you do the calculation you have a mix of signed and
unsigned variables, then you operate on them as if they were signed.
Either change their definitions or cast them when you do the calculation.
rdValue = rdBuffer - ASCII_DECIMAL_ZERO;
I use a 1k resistor with current 100uA without AMUX . Measured exactly 100mV; but when I add the AMUX not give result.if put single a channel with AMUX_Select function (0) and never give the correct result and adding more also channels.