CONTROLLINO-PLC / CONTROLLINO_Library

151 stars 55 forks source link

AD Converter reports different values depending on the operating voltage (12V/24V) #8

Closed Fuzzyma closed 4 years ago

Fuzzyma commented 6 years ago

I connect a voltage source to the A4 Pin on the top of the controllino. The source is at 2V (measured with multimeter).

The controllino voltage reference is defined as INTERNAL2V56.

I power the controllino with USB or 12V (no difference):

I power the controllino with 24V:

What just happend? Not only that the behavior is unexpected, it also leads to wrong volatges measured. Because 765 yields another voltage as 735 (765 beeing correct in that case).

I think this is a big bug. Do you know any solutions to this problem?

// EDIT: That also happens when using an external reference // EDIT2: There is also another problem with the external reference: connecting 2.48V reference yields to ~2.2V beeing 1024 at the AD converter. So somehow 0.18V getting lost on the way to the chip

CONTROLLINO-Support commented 6 years ago

I have tested it with the same results.

Please see the Analog/Digital INPUT block diagram. The problem is that Protection resistor and Automatic divider act as a resistor divider. And the value of the divider changes depending on the supply voltage 12/24V.

Solution is to use screw terminal analog input with defined division ratio: 12V range: 3,06 24V range: 6,14

Regarding the AREF - there is also a protection resistor there (5 kOhm). 0.18V are lost there.

msoula commented 6 years ago

Hi, The same docs says that there's a serial resistance attached on pin headers x1 and x2. Is there a way to know the resistor value for this resistance ? FIY, we are planning to connect a NTC 10k probe on these pins but we can figure out how to measure the voltage because of this resistance. Thanks for your help.

CONTROLLINO-Support commented 6 years ago

Hi, pin header in CONTROLLINO is done in following way: controllino_protectionresistors

Where R1 is: 1 kOhm for: X1.3 – X1.10 220 R for X1.12 to X1.17 1 kOhm for: X2.3 – X2.10 220 R for X2.12 to X2.21

Resistor R2 depends on the input voltage and is: 33 kOhm for 12V 13,24 kOhm for 24V

Is it enough information for you?

msoula commented 6 years ago

Hi and thank you for your explanation, I think we are going somewhere. However, there's something wrong with my understanding on how to use the controllino to read analog values from X1 connector.

My goal is to measure temperature with an analog thermistor (NTC 10k probe). This is a resistance whose value depends on temperature. We use this resistance with a voltage divider montage as explained here.

Below is my circuit using the controllino (MAXI). Input voltage is 24V. Here are the values of the resistances:

controllino

My goal is to evaluate R4 from ADC (which is the value returned by analogRead(A0)) to deduce temperature. Here what I do:

  1. evaluate Vadc = ADC * 5.015 / 1023;
  2. evaluate Vout = Vadc * (R1+R2) / R2; // (using voltage divider equation)
  3. evaluate R4 = (Vout * R3) / (Vin - Vout) // (using voltage divider equation)

All I can get are wrong results. For instance, right now the estimate value for R4 with ADC = 367 tells me ambient temperature is 37°C (using steinhard equation) which is wrong since it's at most 20°C.

Could please you tell me what is wrong with my method ?

CONTROLLINO-Support commented 6 years ago

We have done a simulation of the circuit and your measured value Vadc of 1.8 V corresponds with NTC resistance of 11.36 kOhm which shall be something between 20-25deg (see the figure below). In your evaluation of the R4 is calculated value not directly R4, but parallel combination of R4 and R1+R2. Please consider it in your calculation. Please also consider, that NTC is not fully linear.

controllino_temperaturemeasurement

msoula commented 6 years ago

Indeed my calculation was totally wrong. Thanks a lot for your replies. I think you should add your first pin header diagram into the controllino documentation, it helped a lot.

Pulletje commented 3 years ago

Msoula, Is it possible for you to show your final result. I have the same problem and I can't figure it out

msoula commented 3 years ago

Sorry @Pulletje, but finally it didn't worked for me. I can't remember why it didn't worked exactly...