cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 5, 3 & 1

JaRa_1183061
New Contributor II

Hi all,

Is it possible to read negative values with the ADC on the PSoC5 LP. If so how should it be configured?

I need to read values from -10mV to -1.5V.

0 Likes
1 Solution
odissey1
Honored Contributor II

JaRa,

One way to measure negative voltage is to use a resistor divider network as described by Aubrey Kagan:

Use Excel To Calculate A-D Level-shifter Resistor Values 

 

Attached are a copy of the original paper, demo project, and Excel file to calculate resistor values. Note that there are only two binding equations and three resistor values, so the number of possible solutions is infinite. By selecting a starting values for R1,R2 and R3 it is possible to affect resulting solution. The Excel solver tends to slip into very large values (megaohms), which are not useful, to resolve this issue try to set some small starting values for R1-R3 (like 9).

Note that in order not to affect the resistor network, a Delsig_ADC is used, which has a buffer with very large input impedance. The ADC_SAR input impedance is rather small (~20k), affecting the measurement, so additional buffer Opamp is a must. Unfortunately the PSoC5 Opamp input impedance is not very high (~1M), so DelSig_ADC is preferred.

Once ADC voltage is measured, the input voltage can be calculated as:

Vin = ((RE1*RE2 + RE2*RE3 + RE1*RE3) * Vadc  -  RE1*RE3 * Vdd) / (RE2*RE3) 

The calculated value depends on  the Vdd, which has to be stable for reproducible results.

/odissey1

 

Figure 1. Resistor network for shifting range from [-2V, +2V] into [0V, 2V] for ADC conversion. Note that ADC range is set to only half of that range [0V, 1.024V] to cover only negative portion of the input range.

Resistor network R1-R3 to shift input range from  [-2V, +2V] into [0V-2V] range. Note that ADC range is set to only half range  [0,V 1.02V] to cover only negative input voltages.Resistor network R1-R3 to shift input range from [-2V, +2V] into [0V-2V] range. Note that ADC range is set to only half range [0,V 1.02V] to cover only negative input voltages.

 

Figure 2. Use Data->Solver to obtain resistor values (R1,R2,R3). 

Using Excel spreadsheet solver to obtain R1,R2,R3Using Excel spreadsheet solver to obtain R1,R2,R3

View solution in original post

13 Replies
odissey1
Honored Contributor II

JaRa,

One way to measure negative voltage is to use a resistor divider network as described by Aubrey Kagan:

Use Excel To Calculate A-D Level-shifter Resistor Values 

 

Attached are a copy of the original paper, demo project, and Excel file to calculate resistor values. Note that there are only two binding equations and three resistor values, so the number of possible solutions is infinite. By selecting a starting values for R1,R2 and R3 it is possible to affect resulting solution. The Excel solver tends to slip into very large values (megaohms), which are not useful, to resolve this issue try to set some small starting values for R1-R3 (like 9).

Note that in order not to affect the resistor network, a Delsig_ADC is used, which has a buffer with very large input impedance. The ADC_SAR input impedance is rather small (~20k), affecting the measurement, so additional buffer Opamp is a must. Unfortunately the PSoC5 Opamp input impedance is not very high (~1M), so DelSig_ADC is preferred.

Once ADC voltage is measured, the input voltage can be calculated as:

Vin = ((RE1*RE2 + RE2*RE3 + RE1*RE3) * Vadc  -  RE1*RE3 * Vdd) / (RE2*RE3) 

The calculated value depends on  the Vdd, which has to be stable for reproducible results.

/odissey1

 

Figure 1. Resistor network for shifting range from [-2V, +2V] into [0V, 2V] for ADC conversion. Note that ADC range is set to only half of that range [0V, 1.024V] to cover only negative portion of the input range.

Resistor network R1-R3 to shift input range from  [-2V, +2V] into [0V-2V] range. Note that ADC range is set to only half range  [0,V 1.02V] to cover only negative input voltages.Resistor network R1-R3 to shift input range from [-2V, +2V] into [0V-2V] range. Note that ADC range is set to only half range [0,V 1.02V] to cover only negative input voltages.

 

Figure 2. Use Data->Solver to obtain resistor values (R1,R2,R3). 

Using Excel spreadsheet solver to obtain R1,R2,R3Using Excel spreadsheet solver to obtain R1,R2,R3

View solution in original post

JaRa_1183061
New Contributor II

Interesting, can I use the power supply pin VDD as the 5V and PSoC GND?.  

0 Likes
odissey1
Honored Contributor II

Sure, any Vdd and GND will do. 

 

0 Likes
odissey1
Honored Contributor II

JaRa,

This is another way to invert input voltage range using external opamp. The advantage is that measured voltage is not affected by Opamp power lines fluctuations, and SAR_ADC can be used.

LevelShifter_01a_B.png

JaRa_1183061
New Contributor II

Since I have both negative and positive values, I guess this will not work?

0 Likes
odissey1
Honored Contributor II

JaRa,

Your request was quite specific: "read values from -10mV to -1.5V".

If you have other requirements, it is time to post them

0 Likes
JaRa_1183061
New Contributor II

Ups sorry I meant +1.5. But

I look into my data again: I have to outputs. One output goes from +400mV to -400mV. The second output goes from -100mV to -1V (negative the whole way).

0 Likes
EvPa_264126
Valued Contributor II

you can use TIATIA.JPG

JaRa_1183061
New Contributor II

JaRa_1183061_0-1612462563975.png

I just tried this - by attachting the vdd 4.9V to the input of the TIA. It gives only ADC value of 13. What did I do wrong? 

0 Likes
odissey1
Honored Contributor II

JaRa,

1. Notice 100k resistor at the input of TIA. 2. It is clearly stated that TIA schematic is for negative input only.

0 Likes
EvPa_264126
Valued Contributor II

Check out the attached project.TIA_.jpg

0 Likes
odissey1
Honored Contributor II

JaRa,

Yet another method to measure negative voltage is using PSoC internal Opamp in inverting configuration (Figure 1). The advantage is that only a couple of external resistors are needed and ADC_SAR can be used. Notice that though input voltage is negative, pins Pin_34 and Pin_36 voltages comply with PSoC allowed voltage range (0-5.5V). Also, the PSoC5 Opamps are not rail-to-rail, so measurements in vicinity of -0V may slightly deviate from the actual input.

Attached is a demo project using UART to output data to external plotting software (SerialPlot). The project uses a couple of custom components (SerialPlot and PSoC AnnotationLibrary) which can be found here:

SerialPlot: interface to real-time data charts  

PSoC Annotation Library v1.0 

 

/odissey1

Figure 1. Project schematicFigure 1. Project schematic

Figure 2. Using SerialPlot component to output ADC data for visualizationFigure 2. Using SerialPlot component to output ADC data for visualization

Figure 3. Project annotation using PSoC Annotation Library v1.0. Note that USB-UART convertion is performed inside the KitProg,  no external connection is necessary.Figure 3. Project annotation using PSoC Annotation Library v1.0. Note that USB-UART convertion is performed inside the KitProg, no external connection is necessary.

Figure 4. Input signal from external signal generator. Sine Vpp=2V, offset=-1V, frequency=1HzFigure 4. Input signal from external signal generator. Sine Vpp=2V, offset=-1V, frequency=1Hz

Figure 5. SerialPlot output terminal window. Vertical scale (mV), data sampling rate - 100 samples/sec.Figure 5. SerialPlot output terminal window. Vertical scale (mV), data sampling rate - 100 samples/sec.

 

0 Likes
odissey1
Honored Contributor II

JaRa,

Attached is updated project, showing shifting ADC sampling range using Opamp. Two input ranges are shown [-0.5V, +0.5V], and [-1V, 0V], which can be achieved by simply changing the Opamp reference voltage. Opamp resistor divider is set to R1=R2=10k, but any pair of resistors of same value will do (e.g. 100k). Select resistor value depending on sensor output impedance.

/odissey1

Figure 1. DC transfer characteristics for single-supply Opamp.

RANGE SHIFT_SINGLE SUPPLY_01a_A.png

 

Figure 2. Project schematic for [-0.5V, +0.5V] sampling range. Vref = 0.256V.

ADC_range shift_01a_A1.png

 

Figure 3. Project annotation using PSoC Annotation Library v1.0 ADC_range shift_01a_KIT-059.png

 

Figure 4. Input signal from signal generator in range [-0.5V, +0.5V]ADC_range shift_01a_D1.png

 

Figure 5. Measured input signal (mV), plotted using SerialPlot charting software. ADC sampling rate 100Hz.ADC_range shift_01a_C1.png

 

Figure 6. Project schematic for [-1V, 0V] sampling range. Vref = Vssa (GND).

ADC_range shift_01a_A2.png

0 Likes